Skip to content

Commit

Permalink
chore(postcss-merge-rules): refactor
Browse files Browse the repository at this point in the history
Move all checks together.
  • Loading branch information
ludofischer committed May 11, 2021
1 parent 491d19b commit 70091c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/postcss-merge-rules/src/index.js
Expand Up @@ -94,11 +94,6 @@ function canMerge(ruleA, ruleB, browsers, compatibilityCache) {
const b = ruleB.selectors;

const selectors = a.concat(b);
const hasHost = selectors.some((selector) => selector.includes(':host'));

if (hasHost) {
return false;
}

if (!ensureCompatibility(selectors, browsers, compatibilityCache)) {
return false;
Expand Down
9 changes: 9 additions & 0 deletions packages/postcss-merge-rules/src/lib/ensureCompatibility.js
Expand Up @@ -61,6 +61,10 @@ function isCssMixin(selector) {
return selector[selector.length - 1] === ':';
}

function isHostPseudoClass(selector) {
return selector.includes(':host');
}

const isSupportedCache = {};

// Move to util in future
Expand All @@ -85,6 +89,11 @@ export default function ensureCompatibility(
if (selectors.some(isCssMixin)) {
return false;
}

// Should not merge :host selector https://github.com/angular/angular-cli/issues/18672
if (selectors.some(isHostPseudoClass)) {
return false;
}
return selectors.every((selector) => {
if (simpleSelectorRe.test(selector)) {
return true;
Expand Down

0 comments on commit 70091c6

Please sign in to comment.