-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add `collapseDuplicateDeclarations` This will allow us to remove duplicate declarations. This occurs when you are using `@apply` for example. The reason I implemented it as a separate step, is because this doesn't only happen for `@apply`, but it also happens if you do something like: ```js addComponents({ '.btn-blue, .btm-red': { padding: '10px' } }) ``` So instead of tracking down every place this is happening, it now happens at the very end. * use new plugin in processTailwindFeatures * add/update tests by removing duplicate declarations * update changelog
- Loading branch information
1 parent
0c2f1a6
commit ea6f14a
Showing
7 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default function collapseDuplicateDeclarations() { | ||
return (root) => { | ||
root.walkRules((node) => { | ||
let seen = new Map() | ||
let droppable = new Set([]) | ||
|
||
node.walkDecls((decl) => { | ||
// This could happen if we have nested selectors. In that case the | ||
// parent will loop over all its declarations but also the declarations | ||
// of nested rules. With this we ensure that we are shallowly checking | ||
// declarations. | ||
if (decl.parent !== node) { | ||
return | ||
} | ||
|
||
if (seen.has(decl.prop)) { | ||
droppable.add(seen.get(decl.prop)) | ||
} | ||
|
||
seen.set(decl.prop, decl) | ||
}) | ||
|
||
for (let decl of droppable) { | ||
decl.remove() | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters