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

Method _scopeSelectorPart

packages/compiler/src/shadow_css.ts:753–780  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

751 const attrName = `[${scopeSelector}]`;
752
753 const _scopeSelectorPart = (p: string) => {
754 let scopedP = p.trim();
755
756 // Comments are replaced with placeholders before scoping. A part that only consists of
757 // comments is not a selector and must be left untouched.
758 if (!scopedP || scopedP === '&' || _onlyCommentPlaceholdersRe.test(scopedP)) {
759 return p;
760 }
761
762 if (p.includes(_polyfillHostNoCombinator)) {
763 scopedP = this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
764 if (!p.match(_polyfillHostNoCombinatorOutsidePseudoFunction)) {
765 const [_, before, colon, after] = scopedP.match(/([^:]*)(:*)([\s\S]*)/)!;
766 scopedP = before + attrName + colon + after;
767 }
768 } else {
769 // remove :host since it should be unnecessary
770 const t = p.replace(_polyfillHostRe, '');
771 if (t.length > 0) {
772 const matches = t.match(/([^:]*)(:*)([\s\S]*)/);
773 if (matches) {
774 scopedP = matches[1] + attrName + matches[2] + matches[3];
775 }
776 }
777 }
778
779 return scopedP;
780 };
781
782 // Wraps `_scopeSelectorPart()` to not use it directly on selectors with
783 // pseudo selector functions like `:where()`. Selectors within pseudo selector

Callers

nothing calls this directly

Calls 4

testMethod · 0.45
matchMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected