(at: number, nesting: number)
| 272 | |
| 273 | /** The offset after the `}` that closes the `{` at `at`, or -1. */ |
| 274 | const expressionEnd = (at: number, nesting: number): number => { |
| 275 | if (wasted > limit) return -1; |
| 276 | let open = 0; |
| 277 | let j = at; |
| 278 | scan: while (j < n) { |
| 279 | const c = source.charCodeAt(j); |
| 280 | switch (c) { |
| 281 | case Ch.OpenBrace: |
| 282 | open++; |
| 283 | j++; |
| 284 | break; |
| 285 | case Ch.CloseBrace: |
| 286 | j++; |
| 287 | if (--open === 0) return j; |
| 288 | break; |
| 289 | case Ch.DoubleQuote: |
| 290 | case Ch.SingleQuote: { |
| 291 | const end = stringEnd(j, c); |
| 292 | j = end < 0 ? j + 1 : end; |
| 293 | break; |
| 294 | } |
| 295 | case Ch.Backtick: { |
| 296 | const end = templateEnd(j, nesting); |
| 297 | j = end < 0 ? j + 1 : end; |
| 298 | break; |
| 299 | } |
| 300 | case Ch.Slash: { |
| 301 | const next = source.charCodeAt(j + 1); |
| 302 | if (next === Ch.Slash) { |
| 303 | const end = source.indexOf('\n', j); |
| 304 | j = end < 0 ? n : end; |
| 305 | } else if (next === Ch.Star) { |
| 306 | const end = j >= noBlockCommentEndFrom ? -1 : source.indexOf('*/', j + 2); |
| 307 | if (end < 0) noBlockCommentEndFrom = Math.min(noBlockCommentEndFrom, j); |
| 308 | j = end < 0 ? j + 2 : end + 2; |
| 309 | } else j++; |
| 310 | break; |
| 311 | } |
| 312 | case Ch.Less: { |
| 313 | if (host === 'astro') { |
| 314 | if (source.startsWith('<!--', j)) j = commentEnd(j); |
| 315 | else { |
| 316 | const end = elementEnd(j); |
| 317 | j = end < 0 ? j + 1 : end; |
| 318 | } |
| 319 | } else if (isElementTag(j)) break scan; |
| 320 | else j++; |
| 321 | break; |
| 322 | } |
| 323 | default: |
| 324 | j++; |
| 325 | } |
| 326 | } |
| 327 | wasted += j - at; |
| 328 | return -1; |
| 329 | }; |
| 330 | |
| 331 | /** The offset after the quoted attribute value at `at`, or -1. */ |
no test coverage detected