This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Couldn't load subscription status.
- Fork 57
Replace virtual-dom library with a custom reconciliation implementation #41
Merged
Conversation
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
Implementation is cribbed from snabbdom, but pruned down a bit. Still need to test all the cases.
In all these places, the node can be a text node, which isn't technically an element.
Support the same set of events that React supports.
Signed-off-by: Nathan Sobo <nathan@github.com>
Signed-off-by: Nathan Sobo <nathan@github.com>
Signed-off-by: Nathan Sobo <nathan@github.com>
...which supports --interactive
d8f2022 to
827f311
Compare
nathansobo
commented
Feb 23, 2017
src/patch.js
Outdated
| } | ||
| } | ||
|
|
||
| if (newProps && newProps.key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat worried about the overhead of always copying the props object. I deliberately avoided doing it in other places such as populated the events sub-object. Thinking about our alternatives...
- We could mutate the props object we are given. This is somewhat more dangerous than the events case because we're losing information at that point and if the props object gets reused somehow it could be trouble.
- We could only clone the object and delete the key when passing props down to a component, then explicitly ignore the key in our normal DOM patching operations.
- We could change the logic and just pass the key through to the component. It would be the component's responsibility to ignore it. This seems maybe the simplest and fastest to me but could require changes to existing application code using previous Etch versions.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Previously, Etch wrapped the
virtual-domlibrary to perform DOM updates. This PR eliminates that dependency and handles DOM reconciliation directly in Etch itself, simplifying various aspects of the implementation in the process.The reconciliation code in our new patch function is largely based on Snabbdom's implementation with some tweaks to support Etch's features.
Implementing our own reconciliation makes Etch simpler in multiple ways:
updatemethod.addEventListeneris also now supported via aneventsproperty pointing to a hash of (event name, listener) pairs, with an automaticthisbinding on the parent component.I haven't formally benchmarked this change, but it should also be more performant. Snabbdom, the library on which this reconciliation solution is based, performs well in benchmarks. The big difference from the previous implementation is that patch operates on DOM nodes directly rather than producing a diff object to apply later. Early usage in Atom's text editor and find and replace implementation are showing solid performance.
Remaining tasks:
masterlibnow that Babel is out of the picture and removesrcfrom.npmignore