postcss-merge-idents
Advanced tools
Comparing version 5.0.3 to 5.1.0
{ | ||
"name": "postcss-merge-idents", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "Merge keyframe and counter style identifiers.", | ||
"main": "src/index.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"LICENSE-MIT" | ||
"LICENSE-MIT", | ||
"types" | ||
], | ||
@@ -25,3 +27,3 @@ "keywords": [ | ||
"dependencies": { | ||
"cssnano-utils": "^3.0.2", | ||
"cssnano-utils": "^3.1.0", | ||
"postcss-value-parser": "^4.2.0" | ||
@@ -28,0 +30,0 @@ }, |
@@ -5,2 +5,6 @@ 'use strict'; | ||
/** | ||
* @param {Record<string, string>} obj | ||
* @return {(key: string) => string} | ||
*/ | ||
function canonical(obj) { | ||
@@ -10,2 +14,6 @@ // Prevent potential infinite loops | ||
/** | ||
* @param {string} key | ||
* @return {string} | ||
*/ | ||
return function recurse(key) { | ||
@@ -28,10 +36,32 @@ if ( | ||
function mergeAtRules(css, pairs) { | ||
pairs.forEach((pair) => { | ||
pair.cache = []; | ||
pair.replacements = []; | ||
pair.decls = []; | ||
pair.removals = []; | ||
}); | ||
/** | ||
* @param {import('postcss').Root} css | ||
* @return {void} | ||
*/ | ||
function mergeAtRules(css) { | ||
const pairs = [ | ||
{ | ||
atrule: /keyframes/i, | ||
decl: /animation/i, | ||
/** @type {import('postcss').AtRule[]} */ | ||
cache: [], | ||
replacements: {}, | ||
/** @type {import('postcss').Declaration[]} */ | ||
decls: [], | ||
/** @type {import('postcss').AtRule[]} */ | ||
removals: [], | ||
}, | ||
{ | ||
atrule: /counter-style/i, | ||
decl: /(list-style|system)/i, | ||
cache: [], | ||
replacements: {}, | ||
decls: [], | ||
removals: [], | ||
}, | ||
]; | ||
/** | ||
* @type {{atrule: RegExp, decl: RegExp, replacements: Record<string, string>, removals: import('postcss').AtRule[], cache: import('postcss').AtRule[], decls: import('postcss').Declaration[]}} | ||
*/ | ||
let relevant; | ||
@@ -58,3 +88,6 @@ | ||
cached.name.toLowerCase() === node.name.toLowerCase() && | ||
sameParent(cached, node) && | ||
sameParent( | ||
/** @type {any} */ (cached), | ||
/** @type {any} */ (node) | ||
) && | ||
cached.nodes.toString() === toString | ||
@@ -102,2 +135,6 @@ ) { | ||
/** | ||
* @type {import('postcss').PluginCreator<void>} | ||
* @return {import('postcss').Plugin} | ||
*/ | ||
function pluginCreator() { | ||
@@ -108,12 +145,3 @@ return { | ||
OnceExit(css) { | ||
mergeAtRules(css, [ | ||
{ | ||
atrule: /keyframes/i, | ||
decl: /animation/i, | ||
}, | ||
{ | ||
atrule: /counter-style/i, | ||
decl: /(list-style|system)/i, | ||
}, | ||
]); | ||
mergeAtRules(css); | ||
}, | ||
@@ -120,0 +148,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7886
5
134
Updatedcssnano-utils@^3.1.0