Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): make sure selectors inside container queries are corre…
…ctly handled improve the emulated shadowDom implementation so that it can correctly scope selectors present inside the @container at-rule (recently added to the css specs) resolves #48264
- Loading branch information
1 parent
192df71
commit bf16ca8
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/compiler/test/shadow_css/conatiner_queries_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {ShadowCss} from '@angular/compiler/src/shadow_css'; | ||
|
||
describe('ShadowCss, container queries', () => { | ||
function s(css: string, contentAttr: string, hostAttr: string = '') { | ||
const shadowCss = new ShadowCss(); | ||
return shadowCss.shimCssText(css, contentAttr, hostAttr); | ||
} | ||
|
||
it('should scope normal selectors inside an unnamed container rules', () => { | ||
const css = ` | ||
@container max(max-width: 500px) { | ||
.item { | ||
color: red; | ||
} | ||
} | ||
`; | ||
const result = s(css, 'host-a'); | ||
expect(result).toContain('.item[host-a] {'); | ||
}); | ||
|
||
it('should scope normal selectors inside a named container rules', () => { | ||
const css = ` | ||
@container container max(max-width: 500px) { | ||
.item { | ||
color: red; | ||
} | ||
} | ||
`; | ||
const result = s(css, 'host-a'); | ||
expect(result).toContain('.item[host-a] {'); | ||
}); | ||
}); |