-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fix attribute strings spec to match implementations #133
Conversation
According to my understanding of the JSX specification, the following code should define one attribute whose name is `attr` and whose value is `hello/*"*/world`: function MyComponent() { return <div attr="hello/*"*/world" />; } However, I found no implementation which parses the code this way. All implementations treat `/*` as part of the `JSXSingleStringCharacters` rule rather than the beginning of a block comment. Disallow parsing `Comment` and `WhiteSpace` rules between elements of `JSXSingleStringCharacters`, etc. This makes the specification match implementations. Implementations tested, all of which agree with the modified grammar: * @babel/parser version 7.15.3 * Flow version 0.144.0 * TypeScript version 4.0.3 * acorn version 8.3.0 * espree version 6.2.1
Hi @strager! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
The text contains:
There are several other cases where the text is theoretically ambiguous (e.g., comments or whitespace inside inside identifiers?). But to me I don’t see any reason to assume that comments or whitespace would be allowed in a group of characters? It seems a bit too over the top to add that big bold capitalized “NO WHITESPACE OR COMMENT” everywhere? |
If we want to make the spec "correct" as an extension to the ECMAScript spec, the solution is to use |
I was following the lead of
This sounds like a great solution! |
@strager Sorry, you are right that |
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
Let's be faithful to the de-facto and capture the HTML semantics to the spec. I haven't seen any practices specifying transipilers via ECMA-262 so this was a bit challenging may seems foreign. I ended up extending `Static Semantics: SV` to make it concise and (hopefully) accurate enough. I think this is a cool hack ;) - Introduced `JSXStringCharacter` and `JSXString` - Fix facebook#133 by using `::` to make problematic grammars lexcial I intentionally making the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set but this is open to discuss.
## Summary Let's be faithful to the de-facto and document the HTML entity behaviors to the spec. Note that this is not about whether we should "drop this semantics or not", but about documenting the current behaviors that everyone has been living with for years. ### The Proposed Normative Change I'm not aware of any practices specifying such transpiler/transform semantics in ECMA-262 so this is a really interesting attempt 🙂 So I ended up extending `Static Semantics: SV` which is the smartest way I can find to hack the semantics into the ECMA-262 spec. I think this should work and should be accurate enough. I'm curious on how implementors think about it though. <del>I also intentionally left the set of supported HTML entities implementation-defined to allow either HTML4 or HTML5 set. This may be seen as a breaking change in some regard and **this is open to discuss here**. </del> We've reached consensus that only HTML4 entities are allowed. This commit also close #133 by using `::` for characters which are supposed to be lexical grammars. Close #126 Close #4 ## Test Plan open `index.html` and proof-read the spec ;)
According to my understanding of the JSX specification, the following
code should define one attribute whose name is
attr
and whose value ishello/*"*/world
:However, I found no implementation which parses the code this way. All
implementations treat
/*
as part of theJSXSingleStringCharacters
rule rather than the beginning of a block comment.
Disallow parsing
Comment
andWhiteSpace
rules between elements ofJSXSingleStringCharacters
, etc. This makes the specification matchimplementations.
Implementations tested, all of which agree with the modified grammar: