MCPcopy Index your code
hub / github.com/angular/angular / _applySimpleSelectorScope

Method _applySimpleSelectorScope

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

Source from the content-addressed store, hash-verified

701
702 // scope via name and [is=name]
703 private _applySimpleSelectorScope(
704 selector: string,
705 scopeSelector: string,
706 hostSelector: string,
707 ): string {
708 // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
709 _polyfillHostRe.lastIndex = 0;
710 if (_polyfillHostRe.test(selector)) {
711 const replaceBy = `[${hostSelector}]`;
712 let result = selector;
713 while (result.match(_polyfillHostNoCombinatorRe)) {
714 result = result.replace(_polyfillHostNoCombinatorRe, (_hnc, selector) => {
715 return selector.replace(
716 /([^:\)]*)(:*)(.*)/,
717 (_: string, before: string, colon: string, after: string) => {
718 return before + replaceBy + colon + after;
719 },
720 );
721 });
722 }
723 return result.replace(_polyfillHostRe, replaceBy);
724 }
725
726 return scopeSelector + ' ' + selector;
727 }
728
729 // return a selector with [name] suffix on each simple selector
730 // 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