({
selector,
scopeSelector,
hostSelector,
isParentSelector = false,
}: {
selector: string;
scopeSelector: string;
hostSelector: string;
isParentSelector?: boolean;
})
| 661 | // for example `selector = 'a:where(.one)'` could be the parent, while recursive call |
| 662 | // would have `selector = '.one'`. |
| 663 | private _scopeSelector({ |
| 664 | selector, |
| 665 | scopeSelector, |
| 666 | hostSelector, |
| 667 | isParentSelector = false, |
| 668 | }: { |
| 669 | selector: string; |
| 670 | scopeSelector: string; |
| 671 | hostSelector: string; |
| 672 | isParentSelector?: boolean; |
| 673 | }): string { |
| 674 | return selector |
| 675 | .split(_selectorSplitRe) |
| 676 | .map((part) => part.split(_shadowDeepSelectors)) |
| 677 | .map((deepParts) => { |
| 678 | const [shallowPart, ...otherParts] = deepParts; |
| 679 | const applyScope = (shallowPart: string) => { |
| 680 | if (this._selectorNeedsScoping(shallowPart, scopeSelector)) { |
| 681 | return this._applySelectorScope({ |
| 682 | selector: shallowPart, |
| 683 | scopeSelector, |
| 684 | hostSelector, |
| 685 | isParentSelector, |
| 686 | }); |
| 687 | } else { |
| 688 | return shallowPart; |
| 689 | } |
| 690 | }; |
| 691 | return [applyScope(shallowPart), ...otherParts].join(' '); |
| 692 | }) |
| 693 | .join(', '); |
| 694 | } |
| 695 | |
| 696 | private _selectorNeedsScoping(selector: string, scopeSelector: string): boolean { |
| 697 | const re = this._makeScopeMatcher(scopeSelector); |
no test coverage detected