Skip to content

Commit

Permalink
Merge pull request #604 from aweary/fix-text-children
Browse files Browse the repository at this point in the history
Ignore text nodes in childrenOfInstInternal
  • Loading branch information
aweary committed Jan 10, 2017
2 parents 64ac744 + 8fa8717 commit fa13167
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/MountedTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export function childrenOfInstInternal(inst) {
if (REACT013 && !node.getPublicInstance) {
return false;
}
if (typeof node._stringText !== 'undefined') {
return false;
}
return true;
}).map((node) => {
if (!REACT013 && typeof node._currentElement.type === 'function') {
Expand Down
6 changes: 6 additions & 0 deletions test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,12 @@ describeWithDOM('mount', () => {
expect(children.at(1).hasClass('baz')).to.equal(true);
});

it('should not attempt to get an instance for text nodes', () => {
const wrapper = mount(<div>B<span />C</div>);
const children = wrapper.children();
expect(children.length).to.equal(1);
});

describeIf(!REACT013, 'stateless function components', () => {
it('should handle mixed children with and without arrays', () => {
const Foo = props => (
Expand Down

0 comments on commit fa13167

Please sign in to comment.