Skip to content

Commit

Permalink
fix(compiler): scope css rules within @layer blocks (#45396)
Browse files Browse the repository at this point in the history
This commit starts scoping CSS rules nested within `@layer` blocks.

Fixes #45389

PR Close #45396
  • Loading branch information
JoostK authored and alxhub committed Mar 21, 2022
1 parent e5300d6 commit 3714305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/compiler/src/shadow_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions packages/compiler/test/shadow_css_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);}}';
Expand Down

0 comments on commit 3714305

Please sign in to comment.