From 8cf226e44241aeafe147f6256a1351b46ac3cf91 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 29 Apr 2015 00:21:00 -0700 Subject: [PATCH] Fix infinite recursion in browsers with iterators My old code here didn't work properly -- for a string child, getIteratorFn would return an iterator that gave each character as its own string, and we'd attempt to loop over that too. Tests now work in Chrome again. --- src/classic/element/ReactElementValidator.js | 5 ++++- src/classic/element/__tests__/ReactElementValidator-test.js | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/classic/element/ReactElementValidator.js b/src/classic/element/ReactElementValidator.js index 36ba7bfd09..db101b7c86 100644 --- a/src/classic/element/ReactElementValidator.js +++ b/src/classic/element/ReactElementValidator.js @@ -194,7 +194,10 @@ function validateChildKeys(node, parentType) { validateChildKeys(child, parentType); } } - } else if (ReactElement.isValidElement(node)) { + } else if ( + typeof node === 'string' || typeof node === 'number' || + ReactElement.isValidElement(node) + ) { // This element was passed in a valid location. return; } else if (node) { diff --git a/src/classic/element/__tests__/ReactElementValidator-test.js b/src/classic/element/__tests__/ReactElementValidator-test.js index 01b1a1b240..5d5b0bed96 100644 --- a/src/classic/element/__tests__/ReactElementValidator-test.js +++ b/src/classic/element/__tests__/ReactElementValidator-test.js @@ -173,7 +173,6 @@ describe('ReactElementValidator', function() { it('does not warn for keys when passing children down', function() { spyOn(console, 'error'); - debugger; var Wrapper = React.createClass({ render: function() { return (