Skip to content

Commit d325f9b

Browse files
GeorgySergadevversion
authored andcommitted
fix(compiler): fix parsing of the :host-context with pseudo selectors (#57796)
fix regexp which is used to test for host inside pseudo selectors PR Close #57796
1 parent aea747a commit d325f9b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/compiler/src/shadow_css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ const _cssColonHostContextReGlobal = new RegExp(_polyfillHostContext + _parenSuf
980980
const _cssColonHostContextRe = new RegExp(_polyfillHostContext + _parenSuffix, 'im');
981981
const _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
982982
const _polyfillHostNoCombinatorWithinPseudoFunction = new RegExp(
983-
`:.*(.*${_polyfillHostNoCombinator}.*)`,
983+
`:.*\\(.*${_polyfillHostNoCombinator}.*\\)`,
984984
);
985985
const _polyfillExactHostNoCombinatorReGlobal = /-shadowcsshost-no-combinator/g;
986986
const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;

packages/compiler/test/shadow_css/shadow_css_spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('ShadowCss', () => {
6969
expect(shim('[attr] {}', 'contenta')).toEqualCss('[attr][contenta] {}');
7070
});
7171

72-
it('should transform :host with attributes and pseudo selectors', () => {
72+
it('should transform :host and :host-context with attributes and pseudo selectors', () => {
7373
expect(shim(':host [attr] {}', 'contenta', 'hosta')).toEqualCss('[hosta] [attr][contenta] {}');
7474
expect(shim(':host(create-first-project) {}', 'contenta', 'hosta')).toEqualCss(
7575
'create-first-project[hosta] {}',
@@ -78,6 +78,11 @@ describe('ShadowCss', () => {
7878
expect(shim(':host[attr]:where(:not(.cm-button)) {}', 'contenta', 'hosta')).toEqualCss(
7979
'[hosta][attr]:where(:not(.cm-button)) {}',
8080
);
81+
expect(
82+
shim(':host-context(backdrop:not(.borderless)) .backdrop {}', 'contenta', 'hosta'),
83+
).toEqualCss(
84+
'backdrop:not(.borderless)[hosta] .backdrop[contenta], backdrop:not(.borderless) [hosta] .backdrop[contenta] {}',
85+
);
8186
});
8287

8388
it('should handle escaped sequences in selectors', () => {

0 commit comments

Comments
 (0)