From 6c1c5cf1064105be6890e0f0d61e93b347c63e3a Mon Sep 17 00:00:00 2001 From: Keita Furui Date: Wed, 15 Feb 2023 11:11:18 +0900 Subject: [PATCH] hyperscript: handles shared empty attrs, fixes #2821 --- render/hyperscript.js | 2 +- render/tests/test-hyperscript.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/render/hyperscript.js b/render/hyperscript.js index 26ff753e..0015b26e 100644 --- a/render/hyperscript.js +++ b/render/hyperscript.js @@ -38,7 +38,7 @@ function execSelector(state, vnode) { vnode.tag = state.tag vnode.attrs = {} - if (!isEmpty(state.attrs) && !isEmpty(attrs)) { + if (!isEmpty(state.attrs)) { var newAttrs = {} for (var key in attrs) { diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index 59751f44..fcf69d25 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -580,6 +580,15 @@ o.spec("hyperscript", function() { o(nodeB.attrs.className).equals("b") o(nodeB.attrs.a).equals("b") }) + o("handles shared empty attrs (#2821)", function() { + var attrs = {} + + var nodeA = m(".a", attrs) + var nodeB = m(".b", attrs) + + o(nodeA.attrs.className).equals("a") + o(nodeB.attrs.className).equals("b") + }) o("doesnt modify passed attributes object", function() { var attrs = {a: "b"} m(".a", attrs)