editable node w/ focus is updated when data is changed.
This commit is contained in:
parent
544bb503b9
commit
caaa8c9cbe
2 changed files with 21 additions and 1 deletions
|
|
@ -524,7 +524,7 @@
|
|||
parentTag
|
||||
) {
|
||||
var nodes = cached.nodes
|
||||
if (!editable || editable !== $document.activeElement) {
|
||||
if (!editable || editable !== $document.activeElement || data !== cached) {
|
||||
if (data.$trusted) {
|
||||
clear(nodes, cached)
|
||||
nodes = injectHTML(parentElement, index, data)
|
||||
|
|
|
|||
|
|
@ -1589,5 +1589,25 @@ describe("m.render()", function () {
|
|||
|
||||
expect(root.childNodes[0].innerHTML).to.equal(t1.valueOf())
|
||||
})
|
||||
|
||||
it("caches children of editable on update", function () {
|
||||
var root = document.createElement('div')
|
||||
|
||||
// need this in order for focus & activeElement to work properly
|
||||
document.body.appendChild(root)
|
||||
|
||||
m.render(root, m('span', {
|
||||
config: function(el) { el.focus() },
|
||||
contenteditable: true
|
||||
}, 'a'))
|
||||
|
||||
m.render(root, m('span', {
|
||||
config: function(el) { el.focus() },
|
||||
contenteditable: true
|
||||
}, 'b'))
|
||||
|
||||
expect(root.childNodes[0].innerHTML).to.equal('b')
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue