(start: CharacterCursor, nameStart: CharacterCursor)
| 1306 | } |
| 1307 | |
| 1308 | private _consumeDirective(start: CharacterCursor, nameStart: CharacterCursor) { |
| 1309 | this._requireCharCode(chars.$AT); |
| 1310 | |
| 1311 | // Skip over the @ since it's not part of the name. |
| 1312 | this._cursor.advance(); |
| 1313 | |
| 1314 | // Capture the rest of the name. |
| 1315 | while (isSelectorlessNameChar(this._cursor.peek())) { |
| 1316 | this._cursor.advance(); |
| 1317 | } |
| 1318 | |
| 1319 | // Capture the opening token. |
| 1320 | this._beginToken(TokenType.DIRECTIVE_NAME, start); |
| 1321 | const name = this._cursor.getChars(nameStart); |
| 1322 | this._endToken([name]); |
| 1323 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 1324 | |
| 1325 | // Optionally there might be attributes bound to the specific directive. |
| 1326 | // Stop parsing if there's no opening character for them. |
| 1327 | if (this._cursor.peek() !== chars.$LPAREN) { |
| 1328 | return; |
| 1329 | } |
| 1330 | |
| 1331 | this._openDirectiveCount++; |
| 1332 | this._beginToken(TokenType.DIRECTIVE_OPEN); |
| 1333 | this._cursor.advance(); |
| 1334 | this._endToken([]); |
| 1335 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 1336 | |
| 1337 | // Capture all the attributes until we hit a closing paren. |
| 1338 | while (!isAttributeTerminator(this._cursor.peek()) && this._cursor.peek() !== chars.$RPAREN) { |
| 1339 | this._consumeAttribute(); |
| 1340 | } |
| 1341 | |
| 1342 | // Trim any trailing whitespace. |
| 1343 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 1344 | this._openDirectiveCount--; |
| 1345 | |
| 1346 | if (this._cursor.peek() !== chars.$RPAREN) { |
| 1347 | // Stop parsing, instead of throwing, if we've hit the end of the tag. |
| 1348 | // This can be handled better later when turning the tokens into AST. |
| 1349 | if (this._cursor.peek() === chars.$GT || this._cursor.peek() === chars.$SLASH) { |
| 1350 | return; |
| 1351 | } |
| 1352 | |
| 1353 | throw this._createError( |
| 1354 | _unexpectedCharacterErrorMsg(this._cursor.peek()), |
| 1355 | this._cursor.getSpan(start), |
| 1356 | ); |
| 1357 | } |
| 1358 | |
| 1359 | // Capture the closing token. |
| 1360 | this._beginToken(TokenType.DIRECTIVE_CLOSE); |
| 1361 | this._cursor.advance(); |
| 1362 | this._endToken([]); |
| 1363 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 1364 | } |
| 1365 |
no test coverage detected