From 658f5282d90a392897f34e3602ea28c4a1935c6e Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 15 Dec 2021 17:29:13 +0100 Subject: [PATCH 1/2] remove early return so that all plugins are handled We had an early return so that once a plugin was matched, that we could stop running the code through the other plugins. However, in this case we have an issue that user defined css is technically also a plugin. This means that: - `bg-green-light` Would check for: - `bg-green-light` (no hit, continue) - `bg-green` (Hit! Don't execute next plugins) - `bg` (This is the one that would have generated `bg-green-light`) We tested this change and it doesn't seem to have an impact functionally and also not really performance wise. --- src/lib/generateRules.js | 1 - tests/basic-usage.test.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/lib/generateRules.js b/src/lib/generateRules.js index 806a70747e63..be479c4b6487 100644 --- a/src/lib/generateRules.js +++ b/src/lib/generateRules.js @@ -325,7 +325,6 @@ function* resolveMatchedPlugins(classCandidate, context) { for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) { if (context.candidateRuleMap.has(prefix)) { yield [context.candidateRuleMap.get(prefix), negative ? `-${modifier}` : modifier] - return } } } diff --git a/tests/basic-usage.test.js b/tests/basic-usage.test.js index 33adf24df5d6..3bb5bf3741c8 100644 --- a/tests/basic-usage.test.js +++ b/tests/basic-usage.test.js @@ -1,7 +1,7 @@ import fs from 'fs' import path from 'path' -import { run, css } from './util/run' +import { html, run, css } from './util/run' test('basic usage', () => { let config = { @@ -22,3 +22,38 @@ test('basic usage', () => { expect(result.css).toMatchFormattedCss(expected) }) }) + +test('all plugins are executed that match a candidate', () => { + let config = { + content: [{ raw: html`
` }], + theme: { + colors: { + green: { + light: 'green', + }, + }, + }, + corePlugins: { preflight: false }, + } + + let input = css` + @tailwind utilities; + + .bg-green { + /* Empty on purpose */ + } + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .bg-green-light { + --tw-bg-opacity: 1; + background-color: rgb(0 128 0 / var(--tw-bg-opacity)); + } + + .bg-green { + /* Empty on purpose */ + } + `) + }) +}) From 764c5c0f1f987190a9d2e6f40da1322a03638ce9 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 15 Dec 2021 17:38:09 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bb17b909070..860e7cc9b69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Support square bracket notation in paths ([#6519](https://github.com/tailwindlabs/tailwindcss/pull/6519)) +- Ensure all plugins are executed for a given candidate ([#6540](https://github.com/tailwindlabs/tailwindcss/pull/6540)) ## [3.0.5] - 2021-12-15 @@ -35,7 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix text decoration utilities from overriding the new text decoration color/style/thickness utilities when used with a modifier ([#6378](https://github.com/tailwindlabs/tailwindcss/pull/6378)) - Move defaults to their own always-on layer ([#6500](https://github.com/tailwindlabs/tailwindcss/pull/6500)) - Support negative values in safelist patterns ([#6480](https://github.com/tailwindlabs/tailwindcss/pull/6480)) -- Support square bracket notation in paths ([#6519](https://github.com/tailwindlabs/tailwindcss/pull/6519)) ## [3.0.2] - 2021-12-13