MCPcopy Index your code
hub / github.com/nodejs/node / scanJsxIdentifier

Function scanJsxIdentifier

test/fixtures/snapshot/typescript.js:12093–12128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12091 // Scans a JSX identifier; these differ from normal identifiers in that
12092 // they allow dashes
12093 function scanJsxIdentifier() {
12094 if (tokenIsIdentifierOrKeyword(token)) {
12095 // An identifier or keyword has already been parsed - check for a `-` or a single instance of `:` and then append it and
12096 // everything after it to the token
12097 // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token
12098 // Any caller should be expecting this behavior and should only read the pos or token value after calling it.
12099 var namespaceSeparator = false;
12100 while (pos < end) {
12101 var ch = text.charCodeAt(pos);
12102 if (ch === 45 /* CharacterCodes.minus */) {
12103 tokenValue += "-";
12104 pos++;
12105 continue;
12106 }
12107 else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) {
12108 tokenValue += ":";
12109 pos++;
12110 namespaceSeparator = true;
12111 token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind
12112 continue;
12113 }
12114 var oldPos = pos;
12115 tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled
12116 if (pos === oldPos) {
12117 break;
12118 }
12119 }
12120 // Do not include a trailing namespace separator in the token, since this is against the spec.
12121 if (tokenValue.slice(-1) === ":") {
12122 tokenValue = tokenValue.slice(0, -1);
12123 pos--;
12124 }
12125 return getIdentifierToken();
12126 }
12127 return token;
12128 }
12129 function scanJsxAttributeValue() {
12130 startPos = pos;
12131 switch (text.charCodeAt(pos)) {

Callers 2

parseJsxElementNameFunction · 0.85
parseJsxAttributeFunction · 0.85

Calls 4

scanIdentifierPartsFunction · 0.85
getIdentifierTokenFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…