From b1a5840749cd7f2c9f98e4d3f1d1e2e7e65798d1 Mon Sep 17 00:00:00 2001 From: kfule Date: Wed, 25 Sep 2024 20:08:28 +0900 Subject: [PATCH 1/2] Remove code when vnode.attrs is null Because vnode.attrs is never null by commit f9e5163 --- render/render.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/render/render.js b/render/render.js index a95396716..a41244324 100644 --- a/render/render.js +++ b/render/render.js @@ -453,9 +453,6 @@ module.exports = function() { var element = vnode.dom = old.dom ns = getNameSpace(vnode) || ns - if (vnode.tag === "textarea") { - if (vnode.attrs == null) vnode.attrs = {} - } updateAttrs(vnode, old.attrs, vnode.attrs, ns) if (!maybeSetContentEditable(vnode)) { updateNodes(element, old.children, vnode.children, hooks, null, ns) From 1f9cc7dabeedd30e96cfd1e3cea57f9617dda299 Mon Sep 17 00:00:00 2001 From: kfule Date: Wed, 25 Sep 2024 20:12:18 +0900 Subject: [PATCH 2/2] Always keep key in vnode.attrs if it exists Because vnode.attrs is never null by commit f9e5163 --- render/hyperscript.js | 8 +------- render/tests/test-hyperscript.js | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/render/hyperscript.js b/render/hyperscript.js index 0015b26eb..028c8bdbe 100644 --- a/render/hyperscript.js +++ b/render/hyperscript.js @@ -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 = {} @@ -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 } diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index fcf69d25d..ed918fe1e 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -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() { @@ -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() {