Skip to content

Commit

Permalink
Always keep key in vnode.attrs if it exists
Browse files Browse the repository at this point in the history
Because vnode.attrs is never null by commit f9e5163
  • Loading branch information
kfule committed Sep 25, 2024
1 parent b1a5840 commit 1f9cc7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions render/hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function execSelector(state, vnode) {
var className = hasClass ? attrs.class : attrs.className

vnode.tag = state.tag
vnode.attrs = {}

if (!isEmpty(state.attrs)) {
var newAttrs = {}
Expand Down Expand Up @@ -64,12 +63,7 @@ function execSelector(state, vnode) {

if (hasClass) attrs.class = null

for (var key in attrs) {
if (hasOwn.call(attrs, key) && key !== "key") {
vnode.attrs = attrs
break
}
}
vnode.attrs = attrs

return vnode
}
Expand Down
4 changes: 2 additions & 2 deletions render/tests/test-hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ o.spec("hyperscript", function() {
var vnode = m("div", {key:"a"})

o(vnode.tag).equals("div")
o(vnode.attrs).deepEquals({})
o(vnode.attrs).deepEquals({key:"a"})
o(vnode.key).equals("a")
})
o("handles many attrs", function() {
Expand Down Expand Up @@ -343,7 +343,7 @@ o.spec("hyperscript", function() {
var vnode = m("custom-element", {key:"a"})

o(vnode.tag).equals("custom-element")
o(vnode.attrs).deepEquals({})
o(vnode.attrs).deepEquals({key:"a"})
o(vnode.key).equals("a")
})
o("handles many attrs", function() {
Expand Down

0 comments on commit 1f9cc7d

Please sign in to comment.