@samitouri / QOS-React-2 / commits / 0c58f4f6b1

Set _reactChildKeysValidated in dev mode only

Ben Alpert committed May 11, 2015 at 17:02 UTC 0c58f4f6b12bd7856b73f14163db905cb13c5fc7
1 file changed +14 -12
src/classic/element/ReactElement.js
+14 -12
@@ -157,19 +157,21 @@ ReactElement.createElement = function(type, config, children) {
157 } else if (childrenLength > 1) {
158 var childArray = Array(childrenLength);
159
160 - // To make comparing ReactElements easier for testing purposes, we make
161 - // the validation flag non-enumerable (where possible, which should
162 - // include every environment we run tests in), so the test framework
163 - // ignores it.
164 - try {
165 - Object.defineProperty(childArray, '_reactChildKeysValidated', {
166 - configurable: false,
167 - enumerable: false,
168 - writable: true
169 - });
170 - } catch (x) {
160 + if (__DEV__) {
161 + // To make comparing ReactElements easier for testing purposes, we make
162 + // the validation flag non-enumerable (where possible, which should
163 + // include every environment we run tests in), so the test framework
164 + // ignores it.
165 + try {
166 + Object.defineProperty(childArray, '_reactChildKeysValidated', {
167 + configurable: false,
168 + enumerable: false,
169 + writable: true
170 + });
171 + } catch (x) {
172 + }
173 + childArray._reactChildKeysValidated = true;
174 }
172 - childArray._reactChildKeysValidated = true;
175
176 for (var i = 0; i < childrenLength; i++) {
177 childArray[i] = arguments[i + 2];