Remove length restriction from JSX entities, and ignore Object.prototype#14327
Remove length restriction from JSX entities, and ignore Object.prototype#14327nicolo-ribaudo merged 5 commits intobabel:mainfrom
Object.prototype#14327Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51411/ |
| let val; | ||
|
|
||
| if (code === charCodes.underscore) { | ||
| if (code === charCodes.underscore && allowNumSeparator !== "bail") { |
There was a problem hiding this comment.
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.
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.
| codePoint && | |
| codePoint !== null && |
� is valid html entity.
There was a problem hiding this comment.
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)
| 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.
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.
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.