We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5916e4f commit ec23e34Copy full SHA for ec23e34
lib/utils.js
@@ -1,10 +1,15 @@
1
-var isString = require('lodash/lang/isString');
2
-
3
-function getContainerNode(value) {
4
- if (isString(value)) {
5
- 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`');
6
}
7
- return value;
+
8
+ return selectorOrHTMLElement;
9
+}
10
11
+function isDomElement(o) {
12
+ return o instanceof HTMLElement || o && o.nodeType > 0;
13
14
15
function renderTemplate(template, data) {
0 commit comments