MCPcopy Index your code
hub / github.com/angular/components / getSelector

Method getSelector

src/cdk/testing/component-harness.ts:703–725  ·  view source on GitHub ↗

Gets the selector used to find candidate elements.

()

Source from the content-addressed store, hash-verified

701
702 /** Gets the selector used to find candidate elements. */
703 getSelector() {
704 // We don't have to go through the extra trouble if there are no ancestors.
705 if (!this._ancestor) {
706 return (this.harnessType.hostSelector || '').trim();
707 }
708
709 const [ancestors, ancestorPlaceholders] = _splitAndEscapeSelector(this._ancestor);
710 const [selectors, selectorPlaceholders] = _splitAndEscapeSelector(
711 this.harnessType.hostSelector || '',
712 );
713 const result: string[] = [];
714
715 // We have to add the ancestor to each part of the host compound selector, otherwise we can get
716 // incorrect results. E.g. `.ancestor .a, .ancestor .b` vs `.ancestor .a, .b`.
717 ancestors.forEach(escapedAncestor => {
718 const ancestor = _restoreSelector(escapedAncestor, ancestorPlaceholders);
719 return selectors.forEach(escapedSelector =>
720 result.push(`${ancestor} ${_restoreSelector(escapedSelector, selectorPlaceholders)}`),
721 );
722 });
723
724 return result.join(', ');
725 }
726}
727
728/** Represent a value as a string for the purpose of logging. */

Callers 2

Calls 3

_splitAndEscapeSelectorFunction · 0.85
_restoreSelectorFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected