prevent null ref
This commit is contained in:
parent
b9cdd940bc
commit
41d3ee2983
1 changed files with 2 additions and 4 deletions
|
|
@ -162,10 +162,7 @@ Mithril = m = new function app(window) {
|
||||||
return cachedAttrs
|
return cachedAttrs
|
||||||
}
|
}
|
||||||
function clear(nodes) {
|
function clear(nodes) {
|
||||||
if (nodes.length > 0) {
|
for (var i = nodes.length - 1; i > -1; i--) if (nodes[i]) nodes[i].parentNode.removeChild(nodes[i])
|
||||||
var parent = nodes[i].parentNode
|
|
||||||
for (var i = nodes.length - 1; i > -1; i--) parent.removeChild(nodes[i])
|
|
||||||
}
|
|
||||||
nodes.length = 0
|
nodes.length = 0
|
||||||
}
|
}
|
||||||
function injectHTML(parentElement, index, data) {
|
function injectHTML(parentElement, index, data) {
|
||||||
|
|
@ -209,6 +206,7 @@ Mithril = m = new function app(window) {
|
||||||
}
|
}
|
||||||
var nodeCache = [], cellCache = {}
|
var nodeCache = [], cellCache = {}
|
||||||
m.render = function(root, cell) {
|
m.render = function(root, cell) {
|
||||||
|
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.")
|
||||||
var index = nodeCache.indexOf(root)
|
var index = nodeCache.indexOf(root)
|
||||||
var id = index < 0 ? nodeCache.push(root) - 1 : index
|
var id = index < 0 ? nodeCache.push(root) - 1 : index
|
||||||
var node = root == window.document || root == window.document.documentElement ? documentNode : root
|
var node = root == window.document || root == window.document.documentElement ? documentNode : root
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue