Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/compiler/src/shadow_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ const nthRegex = new RegExp(String.raw`(:nth-[-\w]+)` + _parenSuffix, 'g');
const _cssColonHostRe = new RegExp(_polyfillHost + _parenSuffix + '?([^,{]*)', 'gim');
// note: :host-context patterns are terminated with `{`, as opposed to :host which
// is both `{` and `,` because :host-context handles top-level commas differently.
const _hostContextPattern = _polyfillHostContext + _parenSuffix + '?([^{]*)';
const _hostContextPattern = _polyfillHostContext + _parenSuffix + '([^{]*)';
const _cssColonHostContextReGlobal = new RegExp(
`${_cssScopedPseudoFunctionPrefix}(${_hostContextPattern})`,
'gim',
Expand All @@ -1106,8 +1106,8 @@ const _shadowDOMSelectorsRe = [
const _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g;
const _selectorReSuffix = '([>\\s~+[.,{:][\\s\\S]*)?$';
const _polyfillHostRe = /-shadowcsshost/gim;
const _colonHostRe = /:host/gim;
const _colonHostContextRe = /:host-context/gim;
const _colonHostRe = /:host(?!\-context)/gim;
const _colonHostContextRe = /:host-context(?=\(\s*[^)\s])/gim;

const _newLinesRe = /\r?\n/g;
const _commentRe = /\/\*[\s\S]*?\*\//g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,17 @@ describe('ShadowCss, :host and :host-context', () => {
);
});

// It is not clear what the behavior should be for a `:host-context` with no selectors.
// This test is checking that the result is backward compatible with previous behavior.
// Arguably it should actually be an error that should be reported.
it('should handle :host-context with no ancestor selectors', () => {
expect(shim(':host-context .inner {}', 'contenta', 'a-host')).toEqualCss(
'[a-host] .inner[contenta] {}',
'[contenta]:host-context .inner[contenta] {}',
);
expect(shim(':host-context() .inner {}', 'contenta', 'a-host')).toEqualCss(
'[a-host] .inner[contenta] {}',
'[contenta]:host-context() .inner[contenta] {}',
);
expect(shim(':host-context :host-context(.a) {}', 'contenta', 'host-a')).toEqualCss(
'.a[host-a], .a [host-a] {}',
':host-context .a[host-a], .a [host-a] {}',
);
});

Expand Down
Loading