* Unescape `\$` sequences from the CSS attribute selector. * * This is needed because `$` can have a special meaning in CSS selectors, * but we might want to match an attribute that contains `$`. * [MDN web link for more * info](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribu
(attr: string)
| 131 | * @returns the unescaped string. |
| 132 | */ |
| 133 | unescapeAttribute(attr: string): string { |
| 134 | let result = ''; |
| 135 | let escaping = false; |
| 136 | for (let i = 0; i < attr.length; i++) { |
| 137 | const char = attr.charAt(i); |
| 138 | if (char === '\\') { |
| 139 | escaping = true; |
| 140 | continue; |
| 141 | } |
| 142 | if (char === '$' && !escaping) { |
| 143 | throw new Error( |
| 144 | `Error in attribute selector "${attr}". ` + |
| 145 | `Unescaped "$" is not supported. Please escape with "\\$".`, |
| 146 | ); |
| 147 | } |
| 148 | escaping = false; |
| 149 | result += char; |
| 150 | } |
| 151 | return result; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Escape `$` sequences from the CSS attribute selector. |