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

Function consumeQuotedText

packages/core/src/render3/styling/styling_parser.ts:295–319  ·  view source on GitHub ↗
(
  text: string,
  quoteCharCode: number,
  startIndex: number,
  endIndex: number,
)

Source from the content-addressed store, hash-verified

293 * @returns Index after quoted characters.
294 */
295export function consumeQuotedText(
296 text: string,
297 quoteCharCode: number,
298 startIndex: number,
299 endIndex: number,
300): number {
301 let ch1 = -1; // 1st previous character
302 let index = startIndex;
303 while (index < endIndex) {
304 const ch = text.charCodeAt(index++);
305 if (ch == quoteCharCode && ch1 !== CharCode.BACK_SLASH) {
306 return index;
307 }
308 if (ch == CharCode.BACK_SLASH && ch1 === CharCode.BACK_SLASH) {
309 // two back slashes cancel each other out. For example `"\\"` should properly end the
310 // quotation. (It should not assume that the last `"` is escaped.)
311 ch1 = 0;
312 } else {
313 ch1 = ch;
314 }
315 }
316 throw ngDevMode
317 ? malformedStyleError(text, String.fromCharCode(quoteCharCode), endIndex)
318 : new Error();
319}
320
321function malformedStyleError(text: string, expecting: string, index: number): never {
322 ngDevMode && assertEqual(typeof text === 'string', true, 'String expected here');

Callers 1

consumeStyleValueFunction · 0.85

Calls 1

malformedStyleErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…