Skip to content
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

Store text node's text content as VNode.props instead of VNode.text #1600

Merged
merged 2 commits into from
May 4, 2019
Merged

Conversation

jviide
Copy link
Contributor

@jviide jviide commented May 4, 2019

This pull request modifies how text VNodes are represented internally. Instead of storing a text node's text content as vnode.text the content string is stored as vnode.props. This should be ok, as previously text nodes have had null as .props, and non-text nodes have null as .text.

Text node handling is still circuited when diffing, and the performance seems to stay on the same level with master. I used Chrome 74, MacOS 10.14.4 and https://github.com/mathieuancelin/js-repaint-perfs for testing, so YMMV.

These changes bring the preact.js.gz bundle size down by 28 bytes.

Some tests had to be modified accordingly. One now-irrelevant test got removed altogether. The devtools integration code also required some modifications - all devtools tests are passing, but I haven't actually tried to run the code with React devtools.

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is soo good 😍💯 Outstanding work, makes me giddy with excitement 👍👍

@marvinhagemeister marvinhagemeister merged commit dc4ad8d into preactjs:master May 4, 2019
@jviide jviide deleted the no-text branch May 4, 2019 20:25
robertknight added a commit to preactjs/enzyme-adapter-preact-pure that referenced this pull request Jun 1, 2019
The representation of text nodes changed in this release due to
preactjs/preact#1600.

The `text` property is no longer present on vnodes. Instead strings or
numbers passed to `createElement` get converted to vnodes with type
`null` and `vnode.props` equal to the string or number value.

This PR is backwards-compatible with earlier betas.

Fixes #48
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.

None yet

2 participants