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

Method _applySimpleSelectorScope

packages/compiler/src/shadow_css.ts:709–733  ·  view source on GitHub ↗
(
    selector: string,
    scopeSelector: string,
    hostSelector: string,
  )

Source from the content-addressed store, hash-verified

707
708 // scope via name and [is=name]
709 private _applySimpleSelectorScope(
710 selector: string,
711 scopeSelector: string,
712 hostSelector: string,
713 ): string {
714 // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
715 _polyfillHostRe.lastIndex = 0;
716 if (_polyfillHostRe.test(selector)) {
717 const replaceBy = `[${hostSelector}]`;
718 let result = selector;
719 while (result.match(_polyfillHostNoCombinatorRe)) {
720 result = result.replace(_polyfillHostNoCombinatorRe, (_hnc, selector) => {
721 return selector.replace(
722 /([^:\)]*)(:*)(.*)/,
723 (_: string, before: string, colon: string, after: string) => {
724 return before + replaceBy + colon + after;
725 },
726 );
727 });
728 }
729 return result.replace(_polyfillHostRe, replaceBy);
730 }
731
732 return scopeSelector + ' ' + selector;
733 }
734
735 // return a selector with [name] suffix on each simple selector
736 // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] /** @internal */

Callers 1

_scopeSelectorPartMethod · 0.95

Calls 3

testMethod · 0.45
matchMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected