Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Refined VNode comparison for better exists.
Browse files Browse the repository at this point in the history
1. Created new property on container: previousVNode. This contains a clone of the previous VNode before patching. This means its element properties all have null values, same as a newly provided VNode would.
2. The patchElement function in vdom.js now check the container's previousVNode property to check with the provided VNode from render. If the two objects are identical, it exists. Before this didn't happen because the default vnode property on the container has references to DOM elements from the last patch.
  • Loading branch information
Wobbabits committed Jun 7, 2019
1 parent 1fddf9c commit f2ffabe
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# composi/core Changelog

## 1.6.1 (June 7, 2019)

### src/render.js
* Now taking the VNode passed as an argument to the render function and clone it to save on the component container element as the value of property `previousVNode`.

### src/vdom.js
* Now the `patchElement` function checks the new `previousVNode` property on the parent element to see if the new VNode is identical to the older vision. If they are it exits the patch immediately. Previously, the diff was checking a plain VNode against one which resulted from patching. Problem was, patching made the saved VNode always have DOM values for element, where as a fresh VNode has elements with a value of null. Using `previousVNode` allows the diff to check the resulting new VNode with the previous version before patching adds elements. This allows for quick exiting from the diff if there are no differences.

The save VNode in the `vnode` property of the continer is still used for patching, since it holds the last DOM render information.

## 1.6.0 (June 5, 2019)

### src/vdom.js
Expand Down
2 changes: 1 addition & 1 deletion dist/composi-core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/composi-core.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/composi-core.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit f2ffabe

Please sign in to comment.