Skip to content

Commit e4b4791

Browse files
committed
setAttr/removeAttr: remove key === "is", fixes MithrilJS#2799
This allows the "is" attribute to be set or removed like any other attribute.
1 parent f5fc394 commit e4b4791

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

render/render.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ module.exports = function() {
643643
}
644644
}
645645
function setAttr(vnode, key, old, value, ns) {
646-
if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== "object") return
646+
if (key === "key" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== "object") return
647647
if (key[0] === "o" && key[1] === "n") return updateEvent(vnode, key, value)
648648
if (key.slice(0, 6) === "xlink:") vnode.dom.setAttributeNS("http://www.w3.org/1999/xlink", key.slice(6), value)
649649
else if (key === "style") updateStyle(vnode.dom, old, value)
@@ -676,7 +676,7 @@ module.exports = function() {
676676
}
677677
}
678678
function removeAttr(vnode, key, old, ns) {
679-
if (key === "key" || key === "is" || old == null || isLifecycleMethod(key)) return
679+
if (key === "key" || old == null || isLifecycleMethod(key)) return
680680
if (key[0] === "o" && key[1] === "n") updateEvent(vnode, key, undefined)
681681
else if (key === "style") updateStyle(vnode.dom, old, null)
682682
else if (

render/tests/test-attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ o.spec("attributes", function() {
8080
o(spies[0].callCount).equals(0)
8181
o(spies[2].callCount).equals(0)
8282
o(spies[3].calls).deepEquals([{this: spies[3].elem, args: ["custom", "x"]}])
83-
o(spies[4].calls).deepEquals([{this: spies[4].elem, args: ["custom", "x"]}])
84-
o(spies[5].calls).deepEquals([{this: spies[5].elem, args: ["custom", "x"]}])
83+
o(spies[4].calls).deepEquals([{this: spies[4].elem, args: ["is", "something-special"]}, {this: spies[4].elem, args: ["custom", "x"]}])
84+
o(spies[5].calls).deepEquals([{this: spies[5].elem, args: ["is", "something-special"]}, {this: spies[5].elem, args: ["custom", "x"]}])
8585
})
8686

8787
o("when vnode is customElement with property, custom setAttribute not called", function(){
@@ -124,8 +124,8 @@ o.spec("attributes", function() {
124124
o(spies[1].callCount).equals(0)
125125
o(spies[2].callCount).equals(0)
126126
o(spies[3].callCount).equals(0)
127-
o(spies[4].callCount).equals(0)
128-
o(spies[5].callCount).equals(0)
127+
o(spies[4].callCount).equals(1) // setAttribute("is", "something-special") is called
128+
o(spies[5].callCount).equals(1) // setAttribute("is", "something-special") is called
129129
o(getters[0].callCount).equals(0)
130130
o(getters[1].callCount).equals(0)
131131
o(getters[2].callCount).equals(0)

0 commit comments

Comments
 (0)