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
Remove length restriction from JSX entities, and ignore Object.prototype
#14327
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51411/ |
@@ -1197,7 +1197,7 @@ export default class Tokenizer extends ParserErrors { | |||
const code = this.input.charCodeAt(this.state.pos); | |||
let val; | |||
|
|||
if (code === charCodes.underscore) { | |||
if (code === charCodes.underscore && allowNumSeparator !== "bail") { |
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.
The invalid JSX syntax �_0;
is recoverable: we can either pass allowNumSeparator: false
and refine the error message of NumericSeparatorInEscapeSequence
, or pass a context string so we can throw different errors. Though personally I think html entities are just like escape sequences in JS.
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.
It's not invalid, it's rendeded as-is and not as an HTML entity. I'll add a test.
/* allowNumSeparator */ "bail", | ||
); | ||
if ( | ||
codePoint && |
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.
codePoint && | |
codePoint !== null && |
�
is valid html entity.
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.
This might be another one to spec in JSX btw, because there’s likely divergence between implementations. There are a bunch of different things not allowed by XML/HTML/markdown (such as \0
or lone surrogates)
@@ -1197,7 +1197,7 @@ export default class Tokenizer extends ParserErrors { | |||
const code = this.input.charCodeAt(this.state.pos); | |||
let val; | |||
|
|||
if (code === charCodes.underscore) { | |||
if (code === charCodes.underscore && allowNumSeparator !== "bail") { | |||
const prev = this.input.charCodeAt(this.state.pos - 1); | |||
const next = this.input.charCodeAt(this.state.pos + 1); | |||
if (allowedSiblings.indexOf(next) === -1) { |
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.
Not related to this PR: these errors should be thrown only when allowNumSeparator
is true
, otherwise the errors might be confusing.
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.
I'll open a PR when this is merged.
343f2cc
to
de37f2b
Compare
The second/third commits are for a bug I found while fixing the main one.