Skip to content

Commit

Permalink
hyperscript: handles shared empty attrs, fixes MithrilJS#2821
Browse files Browse the repository at this point in the history
  • Loading branch information
kfule authored and dead-claudia committed Feb 23, 2023
1 parent a1159b7 commit 88da9e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion render/hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions render/tests/test-hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 88da9e5

Please sign in to comment.