postcss-merge-rules
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -6,2 +6,14 @@ # Change Log | ||
## [5.0.1](https://github.com/cssnano/cssnano/compare/postcss-merge-rules@5.0.0...postcss-merge-rules@5.0.1) (2021-05-19) | ||
### Bug Fixes | ||
* **postcss-merge-rules:** add some missing known pseudo classes. ([#1099](https://github.com/cssnano/cssnano/issues/1099)) ([4d7fe36](https://github.com/cssnano/cssnano/commit/4d7fe367bebab86c7b5664ed4621ee7586ca7d86)) | ||
* **postcss-merge-rules:** prevent breaking rule merges ([#1072](https://github.com/cssnano/cssnano/issues/1072)) ([c5e0a5e](https://github.com/cssnano/cssnano/commit/c5e0a5eac171089ae994fcba21d9c565fb462577)), closes [#999](https://github.com/cssnano/cssnano/issues/999) | ||
# [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-merge-rules@5.0.0-rc.2...postcss-merge-rules@5.0.0) (2021-04-06) | ||
@@ -8,0 +20,0 @@ |
@@ -10,12 +10,8 @@ "use strict"; | ||
var _vendors = _interopRequireDefault(require("vendors")); | ||
var _cssnanoUtils = require("cssnano-utils"); | ||
var _ensureCompatibility = _interopRequireDefault(require("./lib/ensureCompatibility")); | ||
var _ensureCompatibility = require("./lib/ensureCompatibility"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** @type {string[]} */ | ||
const prefixes = _vendors.default.map(v => `-${v}-`); | ||
/** | ||
@@ -26,4 +22,2 @@ * @param {postcss.Declaration} a | ||
*/ | ||
function declarationIsEqual(a, b) { | ||
@@ -70,34 +64,4 @@ return a.important === b.important && a.prop === b.prop && a.value === b.value; | ||
return a.every((d, index) => declarationIsEqual(d, b[index])); | ||
} // Internet Explorer use :-ms-input-placeholder. | ||
// Microsoft Edge use ::-ms-input-placeholder. | ||
const findMsInputPlaceholder = selector => ~selector.search(/-ms-input-placeholder/i); | ||
/** | ||
* @param {string} selector | ||
* @return {string[]} | ||
*/ | ||
function filterPrefixes(selector) { | ||
return prefixes.filter(prefix => selector.indexOf(prefix) !== -1); | ||
} | ||
function sameVendor(selectorsA, selectorsB) { | ||
let same = selectors => selectors.map(filterPrefixes).join(); | ||
let findMsVendor = selectors => selectors.find(findMsInputPlaceholder); | ||
return same(selectorsA) === same(selectorsB) && !(findMsVendor(selectorsA) && findMsVendor(selectorsB)); | ||
} | ||
/** | ||
* @param {string} selector | ||
* @return {boolean} | ||
*/ | ||
function noVendor(selector) { | ||
return !filterPrefixes(selector).length; | ||
} | ||
/** | ||
* @param {postcss.Rule} ruleA | ||
@@ -116,3 +80,3 @@ * @param {postcss.Rule} ruleB | ||
if (!(0, _ensureCompatibility.default)(selectors, browsers, compatibilityCache)) { | ||
if (!(0, _ensureCompatibility.ensureCompatibility)(selectors, browsers, compatibilityCache)) { | ||
return false; | ||
@@ -130,3 +94,3 @@ } | ||
return parent && (selectors.every(noVendor) || sameVendor(a, b)); | ||
return parent && (selectors.every(_ensureCompatibility.noVendor) || (0, _ensureCompatibility.sameVendor)(a, b)); | ||
} | ||
@@ -133,0 +97,0 @@ /** |
@@ -6,3 +6,6 @@ "use strict"; | ||
}); | ||
exports.default = ensureCompatibility; | ||
exports.filterPrefixes = filterPrefixes; | ||
exports.sameVendor = sameVendor; | ||
exports.noVendor = noVendor; | ||
exports.ensureCompatibility = ensureCompatibility; | ||
exports.pseudoElements = void 0; | ||
@@ -14,2 +17,4 @@ | ||
var _vendors = _interopRequireDefault(require("vendors")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,5 +29,41 @@ | ||
const cssInOutOfRange = 'css-in-out-of-range'; | ||
const formValidation = 'form-validation'; | ||
/** @type {string[]} */ | ||
const prefixes = _vendors.default.map(v => `-${v}-`); | ||
/** | ||
* @param {string} selector | ||
* @return {string[]} | ||
*/ | ||
function filterPrefixes(selector) { | ||
return prefixes.filter(prefix => selector.indexOf(prefix) !== -1); | ||
} // Internet Explorer use :-ms-input-placeholder. | ||
// Microsoft Edge use ::-ms-input-placeholder. | ||
const findMsInputPlaceholder = selector => ~selector.search(/-ms-input-placeholder/i); | ||
function sameVendor(selectorsA, selectorsB) { | ||
let same = selectors => selectors.map(filterPrefixes).join(); | ||
let findMsVendor = selectors => selectors.find(findMsInputPlaceholder); | ||
return same(selectorsA) === same(selectorsB) && !(findMsVendor(selectorsA) && findMsVendor(selectorsB)); | ||
} | ||
/** | ||
* @param {string} selector | ||
* @return {boolean} | ||
*/ | ||
function noVendor(selector) { | ||
return !filterPrefixes(selector).length; | ||
} | ||
const pseudoElements = { | ||
':active': cssSel2, | ||
':after': cssGencontent, | ||
':any-link': 'css-any-link', | ||
':before': cssGencontent, | ||
@@ -46,5 +87,8 @@ ':checked': cssSel3, | ||
':indeterminate': 'css-indeterminate-pseudo', | ||
':invalid': formValidation, | ||
':is': 'css-matches-pseudo', | ||
':lang': cssSel2, | ||
':last-child': cssSel3, | ||
':last-of-type': cssSel3, | ||
':link': cssSel2, | ||
':matches': 'css-matches-pseudo', | ||
@@ -61,2 +105,3 @@ ':not': cssSel3, | ||
':placeholder-shown': 'css-placeholder-shown', | ||
':required': formValidation, | ||
':root': cssSel3, | ||
@@ -71,3 +116,5 @@ ':target': cssSel3, | ||
'::placeholder': 'css-placeholder', | ||
'::selection': 'css-selection' | ||
'::selection': 'css-selection', | ||
':valid': formValidation, | ||
':visited': cssSel2 | ||
}; | ||
@@ -80,2 +127,6 @@ exports.pseudoElements = pseudoElements; | ||
function isHostPseudoClass(selector) { | ||
return selector.includes(':host'); | ||
} | ||
const isSupportedCache = {}; // Move to util in future | ||
@@ -102,2 +153,7 @@ | ||
return false; | ||
} // Should not merge :host selector https://github.com/angular/angular-cli/issues/18672 | ||
if (selectors.some(isHostPseudoClass)) { | ||
return false; | ||
} | ||
@@ -125,2 +181,6 @@ | ||
if (!entry && noVendor(value)) { | ||
compatible = false; | ||
} | ||
if (entry && compatible) { | ||
@@ -127,0 +187,0 @@ compatible = isSupportedCached(entry, browsers); |
{ | ||
"name": "postcss-merge-rules", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Merge CSS rules with PostCSS.", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"", | ||
"prepublish": "yarn build" | ||
@@ -33,4 +33,4 @@ }, | ||
"caniuse-api": "^3.0.0", | ||
"cssnano-utils": "^2.0.0", | ||
"postcss-selector-parser": "^6.0.4", | ||
"cssnano-utils": "^2.0.1", | ||
"postcss-selector-parser": "^6.0.5", | ||
"vendors": "^1.0.3" | ||
@@ -45,8 +45,8 @@ }, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
"postcss": "^8.2.15" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
"postcss": "^8.2.15" | ||
}, | ||
"gitHead": "0e2c3bf5835bafcdc8783bef66f730a24194c8f3" | ||
"gitHead": "28c247175032fa03f04911cde56ad82d74d211cc" | ||
} |
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
23615
505
Updatedcssnano-utils@^2.0.1