Compare user-changeable element properties against their actual values from the element
See original GitHub issueIn props.js when updating the properties, we compare the new props
against the oldProps
of that vnode
, instead of comparing against the actual properties of that element
.
This causes problems when updating user-changeable properties of an element (like value
or checked
property of an input
or textarea
). Just typing into an input field already changes the property value of value
, the assumptions that only snabbdom changes the property is not true.
For example, we want to clear the value
an input field, whenever a button is clicked. We can then patch
the node
with { "props": { "value": "" }}
. But what if the user changes the value
of the input field in between. Then comparing only the old properties and new properties of the vnode does not suffice.
An example to illustrate the behavior: https://jsfiddle.net/0q6uueou/4/#.
How about changing the relevant code in props.js to this?
for (key in props) {
cur = props[key];
old = elm[key];
if (old !== cur) {
elm[key] = cur;
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
I just measured and reading from dom seems to be ~10x slower than from virtual dom. But both are still quite fast enough to not matter in most cases (~50M ops/sec).
https://jsperf.com/property-plain/1
A PR to solve this could possibly benefit from a benchmark system.