Store text node's text content as VNode.props instead of VNode.text #1600
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 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 asvnode.props
. This should be ok, as previously text nodes have hadnull
as.props
, and non-text nodes havenull
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.