MCPcopy Create free account
hub / github.com/angular/angular / _scopeSelector

Method _scopeSelector

packages/compiler/src/shadow_css.ts:651–689  ·  view source on GitHub ↗
({
    selector,
    scopeSelector,
    hostSelector,
    isParentSelector = false,
  }: {
    selector: string;
    scopeSelector: string;
    hostSelector: string;
    isParentSelector?: boolean;
  })

Source from the content-addressed store, hash-verified

649 // for example `selector = 'a:where(.one)'` could be the parent, while recursive call
650 // would have `selector = '.one'`.
651 private _scopeSelector({
652 selector,
653 scopeSelector,
654 hostSelector,
655 isParentSelector = false,
656 }: {
657 selector: string;
658 scopeSelector: string;
659 hostSelector: string;
660 isParentSelector?: boolean;
661 }): string {
662 // Split the selector into independent parts by `,` (comma) unless
663 // comma is within parenthesis, for example `:is(.one, two)`.
664 // Negative lookup after comma allows not splitting inside nested parenthesis,
665 // up to three levels (((,))).
666 const selectorSplitRe =
667 / ?,(?!(?:[^)(]*(?:\([^)(]*(?:\([^)(]*(?:\([^)(]*\)[^)(]*)*\)[^)(]*)*\)[^)(]*)*\))) ?/;
668
669 return selector
670 .split(selectorSplitRe)
671 .map((part) => part.split(_shadowDeepSelectors))
672 .map((deepParts) => {
673 const [shallowPart, ...otherParts] = deepParts;
674 const applyScope = (shallowPart: string) => {
675 if (this._selectorNeedsScoping(shallowPart, scopeSelector)) {
676 return this._applySelectorScope({
677 selector: shallowPart,
678 scopeSelector,
679 hostSelector,
680 isParentSelector,
681 });
682 } else {
683 return shallowPart;
684 }
685 };
686 return [applyScope(shallowPart), ...otherParts].join(' ');
687 })
688 .join(', ');
689 }
690
691 private _selectorNeedsScoping(selector: string, scopeSelector: string): boolean {
692 const re = this._makeScopeMatcher(scopeSelector);

Callers 2

_scopeSelectorsMethod · 0.95

Calls 2

mapMethod · 0.80
joinMethod · 0.65

Tested by

no test coverage detected