postcss-minify-selectors
Advanced tools
Comparing version 5.1.3 to 5.2.0
{ | ||
"name": "postcss-minify-selectors", | ||
"version": "5.1.3", | ||
"version": "5.2.0", | ||
"description": "Minify selectors with PostCSS.", | ||
"main": "src/index.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"LICENSE-MIT" | ||
"LICENSE-MIT", | ||
"types" | ||
], | ||
@@ -10,0 +12,0 @@ "keywords": [ |
@@ -12,2 +12,6 @@ 'use strict'; | ||
/** | ||
* @param {parser.Attribute} selector | ||
* @return {void} | ||
*/ | ||
function attribute(selector) { | ||
@@ -24,3 +28,5 @@ if (selector.value) { | ||
if (selector.operator) { | ||
selector.operator = selector.operator.trim(); | ||
selector.operator = /** @type {parser.AttributeOperator} */ ( | ||
selector.operator.trim() | ||
); | ||
} | ||
@@ -38,22 +44,24 @@ } | ||
selector.raws.spaces.attribute = { | ||
before: '', | ||
after: '', | ||
}; | ||
if (selector.raws.spaces) { | ||
selector.raws.spaces.attribute = { | ||
before: '', | ||
after: '', | ||
}; | ||
selector.raws.spaces.operator = { | ||
before: '', | ||
after: '', | ||
}; | ||
selector.raws.spaces.value = { | ||
before: '', | ||
after: selector.insensitive ? ' ' : '', | ||
}; | ||
if (selector.insensitive) { | ||
selector.raws.spaces.insensitive = { | ||
selector.raws.spaces.operator = { | ||
before: '', | ||
after: '', | ||
}; | ||
selector.raws.spaces.value = { | ||
before: '', | ||
after: selector.insensitive ? ' ' : '', | ||
}; | ||
if (selector.insensitive) { | ||
selector.raws.spaces.insensitive = { | ||
before: '', | ||
after: '', | ||
}; | ||
} | ||
} | ||
@@ -64,2 +72,6 @@ | ||
/** | ||
* @param {parser.Combinator} selector | ||
* @return {void} | ||
*/ | ||
function combinator(selector) { | ||
@@ -81,2 +93,6 @@ const value = selector.value.trim(); | ||
/** | ||
* @param {parser.Pseudo} selector | ||
* @return {void} | ||
*/ | ||
function pseudo(selector) { | ||
@@ -93,3 +109,3 @@ const value = selector.value.toLowerCase(); | ||
parser.pseudo({ | ||
value: pseudoReplacements.get(value), | ||
value: /** @type {string} */ (pseudoReplacements.get(value)), | ||
}) | ||
@@ -99,3 +115,3 @@ ); | ||
if (one.value.toLowerCase() === 'even') { | ||
if (one.value && one.value.toLowerCase() === 'even') { | ||
one.value = '2n'; | ||
@@ -110,2 +126,3 @@ } | ||
if ( | ||
one.value && | ||
one.value.toLowerCase() === '2n' && | ||
@@ -149,2 +166,6 @@ two.value === '+' && | ||
/** | ||
* @param {parser.Tag} selector | ||
* @return {void} | ||
*/ | ||
function tag(selector) { | ||
@@ -154,6 +175,10 @@ const value = selector.value.toLowerCase(); | ||
if (tagReplacements.has(value)) { | ||
selector.value = tagReplacements.get(value); | ||
selector.value = /** @type {string} */ (tagReplacements.get(value)); | ||
} | ||
} | ||
/** | ||
* @param {parser.Universal} selector | ||
* @return {void} | ||
*/ | ||
function universal(selector) { | ||
@@ -167,10 +192,16 @@ const next = selector.next(); | ||
const reducers = new Map([ | ||
['attribute', attribute], | ||
['combinator', combinator], | ||
['pseudo', pseudo], | ||
['tag', tag], | ||
['universal', universal], | ||
]); | ||
const reducers = new Map( | ||
/** @type {[string, ((selector: parser.Node) => void)][]}*/ ([ | ||
['attribute', attribute], | ||
['combinator', combinator], | ||
['pseudo', pseudo], | ||
['tag', tag], | ||
['universal', universal], | ||
]) | ||
); | ||
/** | ||
* @type {import('postcss').PluginCreator<void>} | ||
* @return {import('postcss').Plugin} | ||
*/ | ||
function pluginCreator() { | ||
@@ -196,3 +227,7 @@ return { | ||
if (sel.type === 'selector' && sel.parent.type !== 'pseudo') { | ||
if ( | ||
sel.type === 'selector' && | ||
sel.parent && | ||
sel.parent.type !== 'pseudo' | ||
) { | ||
if (!uniqueSelectors.has(toString)) { | ||
@@ -199,0 +234,0 @@ uniqueSelectors.add(toString); |
@@ -12,2 +12,6 @@ 'use strict'; | ||
/** | ||
* @param {string} value | ||
* @return {boolean} | ||
*/ | ||
module.exports = function canUnquote(value) { | ||
@@ -14,0 +18,0 @@ if (value === '-' || value === '') { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10169
7
250
0
1