From 0c58f4f6b12bd7856b73f14163db905cb13c5fc7 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Mon, 11 May 2015 17:02:26 -0700 Subject: [PATCH] Set _reactChildKeysValidated in dev mode only --- src/classic/element/ReactElement.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/classic/element/ReactElement.js b/src/classic/element/ReactElement.js index 53e9f5f2da..9f79e6392b 100644 --- a/src/classic/element/ReactElement.js +++ b/src/classic/element/ReactElement.js @@ -157,19 +157,21 @@ ReactElement.createElement = function(type, config, children) { } else if (childrenLength > 1) { var childArray = Array(childrenLength); - // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - try { - Object.defineProperty(childArray, '_reactChildKeysValidated', { - configurable: false, - enumerable: false, - writable: true - }); - } catch (x) { + if (__DEV__) { + // To make comparing ReactElements easier for testing purposes, we make + // the validation flag non-enumerable (where possible, which should + // include every environment we run tests in), so the test framework + // ignores it. + try { + Object.defineProperty(childArray, '_reactChildKeysValidated', { + configurable: false, + enumerable: false, + writable: true + }); + } catch (x) { + } + childArray._reactChildKeysValidated = true; } - childArray._reactChildKeysValidated = true; for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2];