Merge pull request #1475 from igor-k/next
contenteditable node w/ focus is updated when data is changed (fixes #1458)
This commit is contained in:
commit
b42c3d1ba0
2 changed files with 21 additions and 2 deletions
|
|
@ -524,7 +524,7 @@
|
||||||
parentTag
|
parentTag
|
||||||
) {
|
) {
|
||||||
var nodes = cached.nodes
|
var nodes = cached.nodes
|
||||||
if (!editable || editable !== $document.activeElement) {
|
if (!editable || editable !== $document.activeElement || data !== cached) {
|
||||||
if (data.$trusted) {
|
if (data.$trusted) {
|
||||||
clear(nodes, cached)
|
clear(nodes, cached)
|
||||||
nodes = injectHTML(parentElement, index, data)
|
nodes = injectHTML(parentElement, index, data)
|
||||||
|
|
|
||||||
|
|
@ -1588,7 +1588,26 @@ describe("m.render()", function () {
|
||||||
m.render(root, m("span", {contenteditable: false}, t1))
|
m.render(root, m("span", {contenteditable: false}, t1))
|
||||||
|
|
||||||
expect(root.childNodes[0].innerHTML).to.equal(t1.valueOf())
|
expect(root.childNodes[0].innerHTML).to.equal(t1.valueOf())
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("editable node w/ focus is updated on data change", 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