Skip to content

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

Merged
merged 4 commits into from
Nov 14, 2017

Conversation

meyer
Copy link
Contributor

@meyer meyer commented Nov 12, 2017

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 (?)

@msftclas
Copy link

msftclas commented Nov 12, 2017

CLA assistant check
All CLA requirements met.

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a 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

@meyer
Copy link
Contributor Author

meyer commented Nov 12, 2017

@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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ch.toLowerCase() === ch || ch === "_" ?

Copy link
Contributor

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..

Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhegazy good catch, thanks!

Copy link
Contributor Author

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…

@mhegazy mhegazy merged commit 36ce7ea into microsoft:master Nov 14, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants