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
17 changes: 7 additions & 10 deletions packages/compiler/src/shadow_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,20 +511,17 @@ export class ShadowCss {
private _convertColonHost(cssText: string): string {
return cssText.replace(_cssColonHostRe, (_, hostSelectors: string, otherSelectors: string) => {
if (hostSelectors) {
const convertedSelectors: string[] = [];
for (const hostSelector of this._splitOnTopLevelCommas(hostSelectors, true)) {
const trimmedHostSelector = hostSelector.trim();
if (!trimmedHostSelector) break;
const convertedSelector =
const hostSelector = this._splitOnTopLevelCommas(hostSelectors, true).next().value;
const trimmedHostSelector = hostSelector ? hostSelector.trim() : '';
if (trimmedHostSelector) {
return (
_polyfillHostNoCombinator +
trimmedHostSelector.replace(_polyfillHost, '') +
otherSelectors;
convertedSelectors.push(convertedSelector);
otherSelectors
);
}
return convertedSelectors.join(',');
} else {
return _polyfillHostNoCombinator + otherSelectors;
}
return _polyfillHostNoCombinator + otherSelectors;
});
}

Expand Down
20 changes: 0 additions & 20 deletions packages/compiler/test/shadow_css/host_and_host_context_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,10 @@ describe('ShadowCss, :host and :host-context', () => {
expect(shim(':host.pr\\fc fung {}', 'contenta', 'a-host')).toEqual('.pr\\fc fung[a-host] {}');
});

it('should handle multiple tag selectors', () => {
expect(shim(':host(ul,li) {}', 'contenta', 'a-host')).toEqualCss('ul[a-host], li[a-host] {}');
expect(shim(':host(ul,li) > .z {}', 'contenta', 'a-host')).toEqualCss(
'ul[a-host] > .z[contenta], li[a-host] > .z[contenta] {}',
);
});

it('should handle compound class selectors', () => {
expect(shim(':host(.a.b) {}', 'contenta', 'a-host')).toEqualCss('.a.b[a-host] {}');
});

it('should handle multiple class selectors', () => {
expect(shim(':host(.x,.y) {}', 'contenta', 'a-host')).toEqualCss('.x[a-host], .y[a-host] {}');
expect(shim(':host(.x,.y) > .z {}', 'contenta', 'a-host')).toEqualCss(
'.x[a-host] > .z[contenta], .y[a-host] > .z[contenta] {}',
);
});

it('should handle multiple attribute selectors', () => {
expect(shim(':host([a="b"],[c=d]) {}', 'contenta', 'a-host')).toEqualCss(
'[a="b"][a-host], [c=d][a-host] {}',
);
});

it('should handle pseudo selectors', () => {
expect(shim(':host(:before) {}', 'contenta', 'a-host')).toEqualCss('[a-host]:before {}');
expect(shim(':host:before {}', 'contenta', 'a-host')).toEqualCss('[a-host]:before {}');
Expand Down
Loading