diff --git a/lib/instance-selector.js b/lib/instance-selector.js index e911fbe..000c4b4 100644 --- a/lib/instance-selector.js +++ b/lib/instance-selector.js @@ -72,7 +72,12 @@ function findAll(inst, test, includeSelf) { if (isDOMComponent(publicInst)) { (function () { - var renderedChildren = inst._renderedChildren || {}; + var renderedChildren = inst._renderedChildren || {}, + child = inst._currentElement.props.children; + + if (typeof child === 'string' && test(child, null, parent)) { + found = found.concat(child); + } Object.keys(renderedChildren).forEach(function (key) { found = found.concat(findAll(renderedChildren[key], test, true, parent)); diff --git a/lib/package.json b/lib/package.json index 4ee67d0..d2d64c9 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "bill", - "version": "1.3.0", + "version": "1.3.1", "description": "css selectors for React Elements", "main": "index.js", "repository": { diff --git a/src/element-selector.js b/src/element-selector.js index 298b06a..c6ccdd9 100644 --- a/src/element-selector.js +++ b/src/element-selector.js @@ -41,13 +41,7 @@ export function findAll(root, test, includeSelf, getParent = ()=> ({ parent: nul React.Children.forEach(children, child => { let parent = ()=> ({ parent: root, getParent }); - - if (React.isValidElement(child)){ - if (test(child, parent)) - found.push(child); - - found = found.concat(findAll(child, test, false, parent)) - } + found = found.concat(findAll(child, test, true, parent)) }) return found