fix(compiler): scope css rules within @layer blocks (#45396)

This commit starts scoping CSS rules nested within `@layer` blocks.

Fixes #45389

PR Close #45396
This commit is contained in:
JoostK
2022-03-19 15:08:15 +01:00
committed by Alex Rickabaugh
parent aec9abd374
commit fffa023803
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -370,7 +370,7 @@ export class ShadowCss {
this._scopeSelector(rule.selector, scopeSelector, hostSelector, this.strictStyling);
} else if (
rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') ||
rule.selector.startsWith('@document')) {
rule.selector.startsWith('@document') || rule.selector.startsWith('@layer')) {
content = this._scopeSelectors(rule.content, scopeSelector, hostSelector);
} else if (rule.selector.startsWith('@font-face') || rule.selector.startsWith('@page')) {
content = this._stripScopingSelectors(rule.content);
@@ -120,6 +120,12 @@ import {normalizeCSS} from '@angular/platform-browser/testing/src/browser_util';
expect(s(css, 'contenta')).toEqual(expected);
});
it('should handle layer rules', () => {
const css = '@layer utilities {section {display: flex;}}';
const expected = '@layer utilities {section[contenta] {display:flex;}}';
expect(s(css, 'contenta')).toEqual(expected);
});
// Check that the browser supports unprefixed CSS animation
it('should handle keyframes rules', () => {
const css = '@keyframes foo {0% {transform:translate(-50%) scaleX(0);}}';