Gets the selector used to find candidate elements.
()
| 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. */ |
no test coverage detected