Skip to content

Fix field->code transformation in some corner cases - #27

Closed
jviide wants to merge 3 commits into
developit:masterfrom
jviide:patch-03
Closed

jviide wants to merge 3 commits into
developit:masterfrom
jviide:patch-03

Conversation

@jviide

@jviide jviide commented Nov 23, 2018

Copy link
Copy Markdown
Collaborator

In src/index.mjs fields are serialized to generated code. The transformation can in some cases produce malformed code. This pull request fixes the serialization function and and adds a relevant test.

An example of a problematic case is <div>",${name}</div>, where the expected output is something like h("div",{},["\\",",name]);. However, the post-processing step in the serialization function gets rid of the substring "," in the middle, resulting in malformed code.

The fix is to first split the serialized value to alternating static and dynamic pieces and then stringify only the static ones.

The fixed index.mjs is a bit smaller gzipped, 683 B against master's 688 B. In my environment the performance seems to stay the same.

@jviide

jviide commented Nov 23, 2018

Copy link
Copy Markdown
Collaborator Author

Fixed a == comparison into a === comparison where the other side might be an undefined. Force pushed the fixed version.

@jviide

jviide commented Nov 26, 2018

Copy link
Copy Markdown
Collaborator Author

Modified the field serialization implementation a bit, dropping the gzipped size to 655 B (when merged against master).

@jviide

jviide commented Dec 18, 2018

Copy link
Copy Markdown
Collaborator Author

Closing this in preparation to #38.

@jviide jviide closed this Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant