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

Method _applySimpleSelectorScope

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

Source from the content-addressed store, hash-verified

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