mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Even better checks for the arguments to UI.insert
This commit is contained in:
@@ -173,8 +173,10 @@ UI.insert = function (renderedTemplate, parentElement, nextNode) {
|
||||
// parentElement must be a DOM node. in particular, can't be the
|
||||
// result of a call to `$`. Can't check if `parentElement instanceof
|
||||
// Node` since 'Node' is undefined in IE8.
|
||||
if (typeof parentElement.nodeType !== 'number')
|
||||
if (! parentElement || typeof parentElement.nodeType !== 'number')
|
||||
throw new Error("'parentElement' must be a DOM node");
|
||||
if (nextNode && typeof nextNode.nodeType !== 'number') // 'nextNode' is optional
|
||||
throw new Error("'nextNode' must be a DOM node");
|
||||
|
||||
if (! renderedTemplate.dom)
|
||||
throw new Error("Expected template rendered with UI.render");
|
||||
|
||||
@@ -626,7 +626,10 @@ Tinytest.add("ui - UI.insert fails on jQuery objects", function (test) {
|
||||
});
|
||||
test.throws(function () {
|
||||
UI.insert(UI.render(tmpl), $('body'));
|
||||
}, /must be a DOM node/);
|
||||
}, /'parentElement' must be a DOM node/);
|
||||
test.throws(function () {
|
||||
UI.insert(UI.render(tmpl), document.body, $('body'));
|
||||
}, /'nextNode' must be a DOM node/);
|
||||
});
|
||||
|
||||
Tinytest.add("ui - UI.getDataContext", function (test) {
|
||||
|
||||
Reference in New Issue
Block a user