Skip to content

Commit

Permalink
fix: strict container check
Browse files Browse the repository at this point in the history
  • Loading branch information
vvo committed Sep 15, 2015
1 parent 5916e4f commit ec23e34
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit ec23e34

Please sign in to comment.