Repository navigation
Custom JSX Parser - #38
Merged
Merged
Conversation
Fix some corner cases in the custom JSX parser and add tests
Fix multiple spread props in one element
Don't use endsWith, produce cleaner output, fix text with a lone quote
…ic segments as the joiner (crazy, I know)
jviide
reviewed
Dec 18, 2018
This was referenced Dec 18, 2018
Prefix the key with a non-numeric character, as this seems to give a speed-up on Chrome.
Use JSON.stringify for cache key generation
dy
reviewed
Dec 18, 2018
| }); | ||
|
|
||
| test('auto-closing tag', () => { | ||
| expect(html`<a><//>`).toEqual({ tag: 'a', props: null, children: [] }); |
There was a problem hiding this comment.
Not related to the PR - but what was the motivation for double-slash closing tag? JSX introduces </> for the purpose of closing fragments, and tbh I had that expectation here too, like <${Component}></>. Are there some collisions?
Owner
Author
There was a problem hiding this comment.
The original reason was that it was easy to parse - end tag names were ignored in the HTML parser version and are ignored in the custom parser version too. Really you could give the tag any name, like <a></>.
There was a problem hiding this comment.
Does the new parser ignore end tags due to the same reason?
Owner
Author
There was a problem hiding this comment.
just to save bytes. It doesn't validate the opening and closing tags match.
Reorganize the Babel plugin, add support for non-literal template variables
Use $[] instead of $_h[] inside the generated functions
…nst the Babel plugin
If set to `false`, calls to the pragma function are always generated with exactly 3 arguments. Also: never pass `children:[[]]`.
Attempt to fix babel plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces
htm's DOM-based parsing with a custom parser implementing the complete JSX syntax.The result is a fair bit smaller (~600b), produces higher-quality intermediary code, and likely consumes/retains a lot less memory since no objects are created.
/cc @jviide sorry for taking so long to get this PR'd!