-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Update JSX intrinsic element test to match babel’s #19946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you missed a baseline
@RyanCavanaugh updated, thanks! |
// An escaped identifier had a leading underscore prior to being escaped, which would return true | ||
// The escape adds an extra underscore which does not change the result | ||
const ch = (name as string).substr(0, 1); | ||
return ch.toLowerCase() === ch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ch.toLowerCase() === ch || ch === "_"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aah.. that is the opposite.. sorry..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ch = (name as string).charCodeAt(0);
return (ch >= CharacterCodes.a && ch <= CharacterCodes.z) ||
ch == CharacterCodes._ ||
(name as string).indexof("-") > 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and avoid the creation of a regexp on every invocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhegazy good catch, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, missed the comment before. Updating…
This PR changes the intrinsic element check in src/compiler/utilities.ts#L2436 to use babel’s instead.
Fixes #19945
Babel’s JSXElement name test: babel-types/src/react.js#L5-L7
This PR undoes some of the changes added by #16915 and makes the
doubleUnderscoreReactNamespace
test redundant. Might be good to get input from @weswigham (?)