Cache the childrens of editable elements
This commit is contained in:
parent
6ab9570474
commit
ec95de9908
2 changed files with 14 additions and 0 deletions
|
|
@ -533,6 +533,7 @@
|
||||||
} else if (editable) {
|
} else if (editable) {
|
||||||
// contenteditable nodes use `innerHTML` instead of `nodeValue`.
|
// contenteditable nodes use `innerHTML` instead of `nodeValue`.
|
||||||
editable.innerHTML = data
|
editable.innerHTML = data
|
||||||
|
nodes = [].slice.call(editable.childNodes)
|
||||||
} else {
|
} else {
|
||||||
// was a trusted string
|
// was a trusted string
|
||||||
if (nodes[0].nodeType === 1 || nodes.length > 1 ||
|
if (nodes[0].nodeType === 1 || nodes.length > 1 ||
|
||||||
|
|
|
||||||
|
|
@ -1577,5 +1577,18 @@ describe("m.render()", function () {
|
||||||
// This works only if select value is set after its options exist.
|
// This works only if select value is set after its options exist.
|
||||||
expect(root.childNodes[0].value).to.equal("b")
|
expect(root.childNodes[0].value).to.equal("b")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("caches children of editable on update", function () {
|
||||||
|
var root = document.createElement("span")
|
||||||
|
var t1 = m.trust("<h1>fo</h1>o")
|
||||||
|
var t2 = "foo"
|
||||||
|
|
||||||
|
m.render(root, m("span", {contenteditable: false}, t1))
|
||||||
|
m.render(root, m("span", {contenteditable: true}, t2))
|
||||||
|
m.render(root, m("span", {contenteditable: false}, t1))
|
||||||
|
|
||||||
|
expect(root.childNodes[0].innerHTML).to.equal(t1.valueOf())
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue