(cssText: string, scopeSelector: string, hostSelector: string)
| 592 | |
| 593 | // change a selector like 'div' to 'name div' |
| 594 | private _scopeSelectors(cssText: string, scopeSelector: string, hostSelector: string): string { |
| 595 | return processRules(cssText, (rule: CssRule) => { |
| 596 | let selector = rule.selector; |
| 597 | let content = rule.content; |
| 598 | if (rule.selector[0] !== '@') { |
| 599 | if (rule.isBlock) { |
| 600 | const selectorParts = selector.split(_selectorSplitRe); |
| 601 | const containsDeep = selectorParts.some((part) => _shadowDeepSelectorRe.test(part)); |
| 602 | |
| 603 | selector = this._scopeSelector({ |
| 604 | selector, |
| 605 | scopeSelector, |
| 606 | hostSelector, |
| 607 | isParentSelector: true, |
| 608 | }); |
| 609 | |
| 610 | content = |
| 611 | // Only recurse into content if there might be any child blocks. |
| 612 | // TODO: support something like `.parent { ::ng-deep { .child {} } }` |
| 613 | !containsDeep && rule.content.includes('{') |
| 614 | ? this._scopeSelectors(rule.content, scopeSelector, hostSelector) |
| 615 | : this._stripScopingSelectors(rule.content); |
| 616 | } |
| 617 | } else if (scopedAtRuleIdentifiers.some((atRule) => rule.selector.startsWith(atRule))) { |
| 618 | content = this._scopeSelectors(rule.content, scopeSelector, hostSelector); |
| 619 | } else if (rule.selector.startsWith('@font-face') || rule.selector.startsWith('@page')) { |
| 620 | content = this._stripScopingSelectors(rule.content); |
| 621 | } |
| 622 | return new CssRule(selector, content, rule.isBlock); |
| 623 | }); |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * Handle a css text that is within a rule that should not contain scope selectors by simply |
no test coverage detected