From 8e022c02142bbb6bf23d72b12a125cbc2ee32c24 Mon Sep 17 00:00:00 2001 From: Pusztai Tibor Date: Mon, 25 Sep 2017 14:54:36 +0200 Subject: [PATCH] Fallback to children when item is unset --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 97b8252..f3b7261 100644 --- a/src/index.js +++ b/src/index.js @@ -21,14 +21,19 @@ } var Minigrid = function(props) { - var containerEle = props.container instanceof Node ? ( + var containerEle = typeof props.container !== 'string' ? ( props.container ) : ( document.querySelector(props.container) ); - var itemsNodeList = props.item instanceof NodeList ? - props.item : containerEle.querySelectorAll(props.item); + var itemsNodeList; + if (props.item) { + itemsNodeList = typeof props.item !== 'string' ? + props.item : containerEle.querySelectorAll(props.item); + } else { + itemsNodeList = containerEle.children; + } this.props = extend(props, { container: containerEle,