Warn about reusing mutated attrs object - fixes #2719
This commit is contained in:
parent
8ef7844f5a
commit
b97fd59381
2 changed files with 20 additions and 0 deletions
|
|
@ -756,4 +756,21 @@ o.spec("attributes", function() {
|
|||
o(succeeded).equals(true)
|
||||
})
|
||||
})
|
||||
o.spec("mutate attr object", function() {
|
||||
o("warn when reusing attrs object", function() {
|
||||
const _consoleWarn = console.warn
|
||||
console.warn = o.spy()
|
||||
|
||||
const attrs = {className: "on"}
|
||||
render(root, {tag: "input", attrs})
|
||||
|
||||
attrs.className = "off"
|
||||
render(root, {tag: "input", attrs})
|
||||
|
||||
o(console.warn.callCount).equals(1)
|
||||
o(console.warn.args[0]).equals("Don't reuse attrs object, use new object for every redraw, this will throw in next major")
|
||||
|
||||
console.warn = _consoleWarn
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue