mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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);}}';
|
||||
|
||||
Reference in New Issue
Block a user