fix diff for root=document and no m("html")
This commit is contained in:
parent
6cbe17cd08
commit
7cf7e2cba5
2 changed files with 7 additions and 6 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
- fixed bug in keys algorithm when mixing keyed and unkeyed elements [#246](https://github.com/lhorie/mithril.js/issues/246)
|
- fixed bug in keys algorithm when mixing keyed and unkeyed elements [#246](https://github.com/lhorie/mithril.js/issues/246)
|
||||||
- added promise exception monitor and reverted promise exception handling semantics to v0.1.19 semantics (see [mithril.deferred.md#unchecked-error-handling]
|
- added promise exception monitor and reverted promise exception handling semantics to v0.1.19 semantics (see [mithril.deferred.md#unchecked-error-handling]
|
||||||
- fixed redraw scheduling bug in old version of IE
|
- fixed redraw scheduling bug in old version of IE
|
||||||
|
- fixed incorrect diff when document is root, and html element is omitted
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
12
mithril.js
12
mithril.js
|
|
@ -380,12 +380,10 @@ Mithril = m = new function app(window, undefined) {
|
||||||
},
|
},
|
||||||
appendChild: function(node) {
|
appendChild: function(node) {
|
||||||
if (html === undefined) html = window.document.createElement("html")
|
if (html === undefined) html = window.document.createElement("html")
|
||||||
if (node.nodeName == "HTML") html = node
|
if (window.document.documentElement && window.document.documentElement !== node) {
|
||||||
else html.appendChild(node)
|
window.document.replaceChild(node, window.document.documentElement)
|
||||||
if (window.document.documentElement && window.document.documentElement !== html) {
|
|
||||||
window.document.replaceChild(html, window.document.documentElement)
|
|
||||||
}
|
}
|
||||||
else window.document.appendChild(html)
|
else window.document.appendChild(node)
|
||||||
},
|
},
|
||||||
insertBefore: function(node) {
|
insertBefore: function(node) {
|
||||||
this.appendChild(node)
|
this.appendChild(node)
|
||||||
|
|
@ -397,7 +395,9 @@ Mithril = m = new function app(window, undefined) {
|
||||||
var configs = []
|
var configs = []
|
||||||
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.")
|
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.")
|
||||||
var id = getCellCacheKey(root)
|
var id = getCellCacheKey(root)
|
||||||
var node = root == window.document || root == window.document.documentElement ? documentNode : root
|
var isDocumentRoot = root == window.document
|
||||||
|
var node = isDocumentRoot || root == window.document.documentElement ? documentNode : root
|
||||||
|
if (isDocumentRoot && cell.tag != "html") cell = {tag: "html", attrs: {}, children: cell}
|
||||||
if (cellCache[id] === undefined) clear(node.childNodes)
|
if (cellCache[id] === undefined) clear(node.childNodes)
|
||||||
if (forceRecreation === true) reset(root)
|
if (forceRecreation === true) reset(root)
|
||||||
cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs)
|
cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue