MCPcopy Index your code
hub / github.com/angular/angular / unescapeAttribute

Method unescapeAttribute

packages/compiler/src/directive_matching.ts:133–152  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

parseMethod · 0.80

Calls 1

charAtMethod · 0.80

Tested by

no test coverage detected