Scans a JSX identifier; these differ from normal identifiers in that they allow dashes
()
| 1319 | |
| 1320 | // Scans a JSX identifier; these differ from normal identifiers in that they allow dashes |
| 1321 | func (s *Scanner) ScanJsxIdentifier() ast.Kind { |
| 1322 | if tokenIsIdentifierOrKeyword(s.token) { |
| 1323 | // An identifier or keyword has already been parsed - check for a `-` or a single instance of `:` and then append it and |
| 1324 | // everything after it to the token |
| 1325 | // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token |
| 1326 | // Any caller should be expecting this behavior and should only read the pos or token value after calling it. |
| 1327 | for { |
| 1328 | ch := s.char() |
| 1329 | if ch < 0 { |
| 1330 | break |
| 1331 | } |
| 1332 | if ch == '-' { |
| 1333 | s.tokenValue += "-" |
| 1334 | s.pos++ |
| 1335 | continue |
| 1336 | } |
| 1337 | oldPos := s.pos |
| 1338 | s.tokenValue += s.scanIdentifierParts() // reuse `scanIdentifierParts` so unicode escapes are handled |
| 1339 | if s.pos == oldPos { |
| 1340 | break |
| 1341 | } |
| 1342 | } |
| 1343 | s.token = GetIdentifierToken(s.tokenValue) |
| 1344 | } |
| 1345 | return s.token |
| 1346 | } |
| 1347 | |
| 1348 | func (s *Scanner) ScanJsxAttributeValue() ast.Kind { |
| 1349 | s.fullStartPos = s.pos |
no test coverage detected