diff --git a/lib/utils.js b/lib/utils.js index 9df27676b1..c4ecdb3d92 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,10 +1,15 @@ -var isString = require('lodash/lang/isString'); - -function getContainerNode(value) { - if (isString(value)) { - return document.querySelector(value); +function getContainerNode(selectorOrHTMLElement) { + if (typeof selectorOrHTMLElement === 'string') { + return document.querySelector(selectorOrHTMLElement); + } else if (!isDomElement(selectorOrHTMLElement)) { + throw new Error('Container must be `string` or `HTMLElement`'); } - return value; + + return selectorOrHTMLElement; +} + +function isDomElement(o) { + return o instanceof HTMLElement || o && o.nodeType > 0; } function renderTemplate(template, data) {