react 0.13.0-alpha.2 → 0.13.0-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/JSXTransformer.js +1798 -1194
  2. package/dist/react-with-addons.js +2640 -2046
  3. package/dist/react-with-addons.min.js +7 -6
  4. package/dist/react.js +2459 -1930
  5. package/dist/react.min.js +6 -6
  6. package/lib/AutoFocusMixin.js +1 -1
  7. package/lib/BeforeInputEventPlugin.js +1 -5
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +3 -1
  10. package/lib/CSSPropertyOperations.js +43 -16
  11. package/lib/CallbackQueue.js +1 -1
  12. package/lib/ChangeEventPlugin.js +1 -1
  13. package/lib/ClientReactRootIndex.js +1 -1
  14. package/lib/DOMChildrenOperations.js +4 -43
  15. package/lib/DOMProperty.js +1 -1
  16. package/lib/DOMPropertyOperations.js +10 -15
  17. package/lib/Danger.js +1 -1
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +1 -1
  20. package/lib/EventConstants.js +1 -1
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +1 -1
  23. package/lib/EventPluginRegistry.js +1 -1
  24. package/lib/EventPluginUtils.js +3 -3
  25. package/lib/EventPropagators.js +1 -1
  26. package/lib/ExecutionEnvironment.js +1 -1
  27. package/lib/FallbackCompositionState.js +1 -1
  28. package/lib/HTMLDOMPropertyConfig.js +12 -5
  29. package/lib/LinkedStateMixin.js +1 -1
  30. package/lib/LinkedValueUtils.js +1 -1
  31. package/lib/LocalEventTrapMixin.js +9 -2
  32. package/lib/MobileSafariClickEventPlugin.js +1 -1
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +1 -1
  35. package/lib/React.js +11 -14
  36. package/lib/ReactBrowserComponentMixin.js +1 -1
  37. package/lib/ReactBrowserEventEmitter.js +2 -2
  38. package/lib/ReactCSSTransitionGroup.js +1 -1
  39. package/lib/ReactCSSTransitionGroupChild.js +8 -5
  40. package/lib/ReactChildReconciler.js +9 -5
  41. package/lib/ReactChildren.js +3 -2
  42. package/lib/ReactClass.js +144 -76
  43. package/lib/ReactComponent.js +99 -166
  44. package/lib/ReactComponentBrowserEnvironment.js +1 -1
  45. package/lib/ReactComponentEnvironment.js +1 -1
  46. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  47. package/lib/ReactCompositeComponent.js +261 -480
  48. package/lib/ReactContext.js +13 -3
  49. package/lib/ReactCurrentOwner.js +1 -1
  50. package/lib/ReactDOM.js +1 -1
  51. package/lib/ReactDOMButton.js +1 -1
  52. package/lib/ReactDOMComponent.js +23 -48
  53. package/lib/ReactDOMForm.js +1 -1
  54. package/lib/ReactDOMIDOperations.js +3 -3
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +1 -1
  57. package/lib/ReactDOMInput.js +1 -1
  58. package/lib/ReactDOMOption.js +1 -1
  59. package/lib/ReactDOMSelect.js +1 -1
  60. package/lib/ReactDOMSelection.js +1 -1
  61. package/lib/ReactDOMTextComponent.js +3 -12
  62. package/lib/ReactDOMTextarea.js +1 -1
  63. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  64. package/lib/ReactDefaultInjection.js +25 -1
  65. package/lib/ReactDefaultPerf.js +11 -3
  66. package/lib/ReactDefaultPerfAnalysis.js +1 -1
  67. package/lib/ReactElement.js +59 -4
  68. package/lib/ReactElementValidator.js +141 -85
  69. package/lib/ReactEmptyComponent.js +5 -5
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +1 -1
  72. package/lib/ReactEventListener.js +1 -2
  73. package/lib/ReactFragment.js +181 -0
  74. package/lib/ReactInjection.js +1 -1
  75. package/lib/ReactInputSelection.js +1 -1
  76. package/lib/ReactInstanceHandles.js +1 -1
  77. package/lib/ReactInstanceMap.js +1 -1
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +1 -1
  80. package/lib/ReactMarkupChecksum.js +1 -1
  81. package/lib/ReactMount.js +77 -20
  82. package/lib/ReactMultiChild.js +7 -4
  83. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  84. package/lib/ReactNativeComponent.js +33 -36
  85. package/lib/ReactOwner.js +1 -1
  86. package/lib/ReactPerf.js +1 -1
  87. package/lib/ReactPropTransferer.js +1 -1
  88. package/lib/ReactPropTypeLocationNames.js +1 -1
  89. package/lib/ReactPropTypeLocations.js +1 -1
  90. package/lib/ReactPropTypes.js +5 -3
  91. package/lib/ReactPutListenerQueue.js +1 -1
  92. package/lib/ReactReconcileTransaction.js +1 -1
  93. package/lib/ReactReconciler.js +120 -0
  94. package/lib/ReactRef.js +40 -67
  95. package/lib/ReactRootIndex.js +1 -1
  96. package/lib/ReactServerRendering.js +1 -1
  97. package/lib/ReactServerRenderingTransaction.js +1 -1
  98. package/lib/ReactStateSetters.js +1 -1
  99. package/lib/ReactTestUtils.js +48 -7
  100. package/lib/ReactTransitionChildMapping.js +7 -3
  101. package/lib/ReactTransitionEvents.js +1 -1
  102. package/lib/ReactTransitionGroup.js +5 -5
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +11 -20
  105. package/lib/ReactWithAddons.js +3 -1
  106. package/lib/SVGDOMPropertyConfig.js +1 -1
  107. package/lib/SelectEventPlugin.js +1 -1
  108. package/lib/ServerReactRootIndex.js +1 -1
  109. package/lib/SimpleEventPlugin.js +3 -3
  110. package/lib/SyntheticClipboardEvent.js +1 -1
  111. package/lib/SyntheticCompositionEvent.js +1 -1
  112. package/lib/SyntheticDragEvent.js +1 -1
  113. package/lib/SyntheticEvent.js +1 -1
  114. package/lib/SyntheticFocusEvent.js +1 -1
  115. package/lib/SyntheticInputEvent.js +1 -1
  116. package/lib/SyntheticKeyboardEvent.js +1 -1
  117. package/lib/SyntheticMouseEvent.js +1 -1
  118. package/lib/SyntheticTouchEvent.js +1 -1
  119. package/lib/SyntheticUIEvent.js +1 -1
  120. package/lib/SyntheticWheelEvent.js +1 -1
  121. package/lib/Transaction.js +2 -2
  122. package/lib/ViewportMetrics.js +1 -1
  123. package/lib/accumulateInto.js +1 -1
  124. package/lib/adler32.js +1 -1
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +1 -1
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +16 -1
  133. package/lib/dangerousStyleValue.js +1 -1
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +4 -5
  137. package/lib/findDOMNode.js +19 -1
  138. package/lib/flattenChildren.js +1 -1
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +1 -1
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +1 -1
  143. package/lib/getEventKey.js +1 -1
  144. package/lib/getEventModifierState.js +1 -1
  145. package/lib/getEventTarget.js +1 -1
  146. package/lib/getIteratorFn.js +1 -1
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +1 -1
  149. package/lib/getReactRootElementInContainer.js +1 -1
  150. package/lib/getTextContentAccessor.js +1 -1
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +20 -20
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +1 -1
  157. package/lib/isNode.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +1 -1
  161. package/lib/keyMirror.js +1 -1
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +1 -1
  165. package/lib/onlyChild.js +1 -1
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +1 -1
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +32 -10
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +18 -4
  175. package/lib/update.js +1 -1
  176. package/lib/warning.js +12 -1
  177. package/package.json +1 -1
  178. package/lib/ReactComponentBase.js +0 -126
  179. package/lib/accumulate.js +0 -47
  180. package/lib/copyProperties.js +0 -56
  181. package/lib/merge.js +0 -34
  182. package/lib/mergeInto.js +0 -24
  183. package/lib/monitorCodeUse.js +0 -30
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -242,10 +242,18 @@ var ReactDefaultPerf = {
242
242
  addValue(entry.inclusive, rootNodeID, totalTime);
243
243
  }
244
244
 
245
+ var displayName = null;
246
+ if (this._instance.constructor.displayName) {
247
+ displayName = this._instance.constructor.displayName;
248
+ } else if (this._currentElement.type) {
249
+ displayName = this._currentElement.type;
250
+ }
251
+
245
252
  entry.displayNames[rootNodeID] = {
246
- current: this.constructor.displayName,
253
+ current: displayName,
247
254
  owner: this._currentElement._owner ?
248
- this._currentElement._owner.constructor.displayName : '<root>'
255
+ this._currentElement._owner._instance.constructor.displayName :
256
+ '<root>'
249
257
  };
250
258
 
251
259
  return rv;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014, Facebook, Inc.
2
+ * Copyright 2014-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -45,8 +45,9 @@ function defineWarningProperty(object, key) {
45
45
  set: function(value) {
46
46
  ("production" !== process.env.NODE_ENV ? warning(
47
47
  false,
48
- 'Don\'t set the ' + key + ' property of the React element. Instead, ' +
49
- 'specify the correct value when initially creating the element.'
48
+ 'Don\'t set the %s property of the React element. Instead, ' +
49
+ 'specify the correct value when initially creating the element.',
50
+ key
50
51
  ) : null);
51
52
  this._store[key] = value;
52
53
  }
@@ -107,7 +108,7 @@ var ReactElement = function(type, key, ref, owner, context, props) {
107
108
  // an external backing store so that we can freeze the whole object.
108
109
  // This can be replaced with a WeakMap once they are implemented in
109
110
  // commonly used development environments.
110
- this._store = { props: props, originalProps: assign({}, props) };
111
+ this._store = {props: props, originalProps: assign({}, props)};
111
112
 
112
113
  // To make comparing ReactElements easier for testing purposes, we make
113
114
  // the validation flag non-enumerable (where possible, which should
@@ -227,6 +228,60 @@ ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
227
228
  return newElement;
228
229
  };
229
230
 
231
+ ReactElement.cloneElement = function(element, config, children) {
232
+ var propName;
233
+
234
+ // Original props are copied
235
+ var props = assign({}, element.props);
236
+
237
+ // Reserved names are extracted
238
+ var key = element.key;
239
+ var ref = element.ref;
240
+
241
+ // Owner will be preserved, unless ref is overridden
242
+ var owner = element._owner;
243
+
244
+ if (config != null) {
245
+ if (config.ref !== undefined) {
246
+ // Silently steal the ref from the parent.
247
+ ref = config.ref;
248
+ owner = ReactCurrentOwner.current;
249
+ }
250
+ if (config.key !== undefined) {
251
+ key = '' + config.key;
252
+ }
253
+ // Remaining properties override existing props
254
+ for (propName in config) {
255
+ if (config.hasOwnProperty(propName) &&
256
+ !RESERVED_PROPS.hasOwnProperty(propName)) {
257
+ props[propName] = config[propName];
258
+ }
259
+ }
260
+ }
261
+
262
+ // Children can be more than one argument, and those are transferred onto
263
+ // the newly allocated props object.
264
+ var childrenLength = arguments.length - 2;
265
+ if (childrenLength === 1) {
266
+ props.children = children;
267
+ } else if (childrenLength > 1) {
268
+ var childArray = Array(childrenLength);
269
+ for (var i = 0; i < childrenLength; i++) {
270
+ childArray[i] = arguments[i + 2];
271
+ }
272
+ props.children = childArray;
273
+ }
274
+
275
+ return new ReactElement(
276
+ element.type,
277
+ key,
278
+ ref,
279
+ owner,
280
+ element._context,
281
+ props
282
+ );
283
+ };
284
+
230
285
  /**
231
286
  * @param {?object} object
232
287
  * @return {boolean} True if `object` is a valid component.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014, Facebook, Inc.
2
+ * Copyright 2014-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -19,25 +19,32 @@
19
19
  'use strict';
20
20
 
21
21
  var ReactElement = require("./ReactElement");
22
+ var ReactFragment = require("./ReactFragment");
22
23
  var ReactPropTypeLocations = require("./ReactPropTypeLocations");
23
24
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
24
25
  var ReactCurrentOwner = require("./ReactCurrentOwner");
26
+ var ReactNativeComponent = require("./ReactNativeComponent");
25
27
 
26
28
  var getIteratorFn = require("./getIteratorFn");
27
- var monitorCodeUse = require("./monitorCodeUse");
28
29
  var invariant = require("./invariant");
29
30
  var warning = require("./warning");
30
31
 
32
+ function getDeclarationErrorAddendum() {
33
+ if (ReactCurrentOwner.current) {
34
+ var name = ReactCurrentOwner.current.getName();
35
+ if (name) {
36
+ return ' Check the render method of `' + name + '`.';
37
+ }
38
+ }
39
+ return '';
40
+ }
41
+
31
42
  /**
32
43
  * Warn if there's no key explicitly set on dynamic arrays of children or
33
44
  * object keys are not valid. This allows us to keep track of children between
34
45
  * updates.
35
46
  */
36
- var ownerHasKeyUseWarning = {
37
- 'react_key_warning': {},
38
- 'react_numeric_key_warning': {}
39
- };
40
- var ownerHasMonitoredObjectMap = {};
47
+ var ownerHasKeyUseWarning = {};
41
48
 
42
49
  var loggedTypeFailures = {};
43
50
 
@@ -91,7 +98,6 @@ function validateExplicitKey(element, parentType) {
91
98
  element._store.validated = true;
92
99
 
93
100
  warnAndMonitorForKeyUse(
94
- 'react_key_warning',
95
101
  'Each child in an array or iterator should have a unique "key" prop.',
96
102
  element,
97
103
  parentType
@@ -112,7 +118,6 @@ function validatePropertyKey(name, element, parentType) {
112
118
  return;
113
119
  }
114
120
  warnAndMonitorForKeyUse(
115
- 'react_numeric_key_warning',
116
121
  'Child objects should have non-numeric keys so ordering is preserved.',
117
122
  element,
118
123
  parentType
@@ -123,60 +128,48 @@ function validatePropertyKey(name, element, parentType) {
123
128
  * Shared warning and monitoring code for the key warnings.
124
129
  *
125
130
  * @internal
126
- * @param {string} warningID The id used when logging.
127
131
  * @param {string} message The base warning that gets output.
128
132
  * @param {ReactElement} element Component that requires a key.
129
133
  * @param {*} parentType element's parent's type.
130
134
  */
131
- function warnAndMonitorForKeyUse(warningID, message, element, parentType) {
135
+ function warnAndMonitorForKeyUse(message, element, parentType) {
132
136
  var ownerName = getCurrentOwnerDisplayName();
133
- var parentName = parentType.displayName || parentType.name;
137
+ var parentName = typeof parentType === 'string' ?
138
+ parentType : parentType.displayName || parentType.name;
134
139
 
135
140
  var useName = ownerName || parentName;
136
- var memoizer = ownerHasKeyUseWarning[warningID];
141
+ var memoizer = ownerHasKeyUseWarning[message] || (
142
+ (ownerHasKeyUseWarning[message] = {})
143
+ );
137
144
  if (memoizer.hasOwnProperty(useName)) {
138
145
  return;
139
146
  }
140
147
  memoizer[useName] = true;
141
148
 
142
- message += ownerName ?
143
- (" Check the render method of " + ownerName + ".") :
144
- (" Check the React.render call using <" + parentName + ">.");
149
+ var parentOrOwnerAddendum =
150
+ ownerName ? (" Check the render method of " + ownerName + ".") :
151
+ parentName ? (" Check the React.render call using <" + parentName + ">.") :
152
+ '';
145
153
 
146
154
  // Usually the current owner is the offender, but if it accepts children as a
147
155
  // property, it may be the creator of the child that's responsible for
148
156
  // assigning it a key.
149
- var childOwnerName = null;
157
+ var childOwnerAddendum = '';
150
158
  if (element &&
151
159
  element._owner &&
152
160
  element._owner !== ReactCurrentOwner.current) {
153
161
  // Name of the component that originally created this child.
154
- childOwnerName = getName(element._owner);
162
+ var childOwnerName = getName(element._owner);
155
163
 
156
- message += (" It was passed a child from " + childOwnerName + ".");
164
+ childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
157
165
  }
158
166
 
159
- message += ' See http://fb.me/react-warning-keys for more information.';
160
- monitorCodeUse(warningID, {
161
- component: useName,
162
- componentOwner: childOwnerName
163
- });
164
- console.warn(message);
165
- }
166
-
167
- /**
168
- * Log that we're using an object map. We're considering deprecating this
169
- * feature and replace it with proper Map and ImmutableMap data structures.
170
- *
171
- * @internal
172
- */
173
- function monitorUseOfObjectMap() {
174
- var currentName = getCurrentOwnerDisplayName() || '';
175
- if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) {
176
- return;
177
- }
178
- ownerHasMonitoredObjectMap[currentName] = true;
179
- monitorCodeUse('react_object_map_children');
167
+ ("production" !== process.env.NODE_ENV ? warning(
168
+ false,
169
+ message + '%s%s See http://fb.me/react-warning-keys for more information.',
170
+ parentOrOwnerAddendum,
171
+ childOwnerAddendum
172
+ ) : null);
180
173
  }
181
174
 
182
175
  /**
@@ -202,19 +195,21 @@ function validateChildKeys(node, parentType) {
202
195
  } else if (node) {
203
196
  var iteratorFn = getIteratorFn(node);
204
197
  // Entry iterators provide implicit keys.
205
- if (iteratorFn && iteratorFn !== node.entries) {
206
- var iterator = iteratorFn.call(node);
207
- var step;
208
- while (!(step = iterator.next()).done) {
209
- if (ReactElement.isValidElement(step.value)) {
210
- validateExplicitKey(step.value, parentType);
198
+ if (iteratorFn) {
199
+ if (iteratorFn !== node.entries) {
200
+ var iterator = iteratorFn.call(node);
201
+ var step;
202
+ while (!(step = iterator.next()).done) {
203
+ if (ReactElement.isValidElement(step.value)) {
204
+ validateExplicitKey(step.value, parentType);
205
+ }
211
206
  }
212
207
  }
213
208
  } else if (typeof node === 'object') {
214
- monitorUseOfObjectMap();
215
- for (var key in node) {
216
- if (node.hasOwnProperty(key)) {
217
- validatePropertyKey(key, node[key], parentType);
209
+ var fragment = ReactFragment.extractIfFragment(node);
210
+ for (var key in fragment) {
211
+ if (fragment.hasOwnProperty(key)) {
212
+ validatePropertyKey(key, fragment[key], parentType);
218
213
  }
219
214
  }
220
215
  }
@@ -256,11 +251,9 @@ function checkPropTypes(componentName, propTypes, props, location) {
256
251
  // Only monitor this failure once because there tends to be a lot of the
257
252
  // same error.
258
253
  loggedTypeFailures[error.message] = true;
259
- // This will soon use the warning module
260
- monitorCodeUse(
261
- 'react_failed_descriptor_type_check',
262
- { message: error.message }
263
- );
254
+
255
+ var addendum = getDeclarationErrorAddendum(this);
256
+ ("production" !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
264
257
  }
265
258
  }
266
259
  }
@@ -297,12 +290,28 @@ function warnForPropsMutation(propName, element) {
297
290
 
298
291
  ("production" !== process.env.NODE_ENV ? warning(
299
292
  false,
300
- 'Don\'t set .props.' + propName + ' of the React component' +
301
- elementInfo + '. Instead, specify the correct value when ' +
302
- 'initially creating the element.' + ownerInfo
293
+ 'Don\'t set .props.%s of the React component%s. ' +
294
+ 'Instead, specify the correct value when ' +
295
+ 'initially creating the element.%s',
296
+ propName,
297
+ elementInfo,
298
+ ownerInfo
303
299
  ) : null);
304
300
  }
305
301
 
302
+ // Inline Object.is polyfill
303
+ function is(a, b) {
304
+ if (a !== a) {
305
+ // NaN
306
+ return b !== b;
307
+ }
308
+ if (a === 0 && b === 0) {
309
+ // +-0
310
+ return 1 / a === 1 / b;
311
+ }
312
+ return a === b;
313
+ }
314
+
306
315
  /**
307
316
  * Given an element, check if its props have been mutated since element
308
317
  * creation (or the last call to this function). In particular, check if any
@@ -324,7 +333,7 @@ function checkAndWarnForMutatedProps(element) {
324
333
  for (var propName in props) {
325
334
  if (props.hasOwnProperty(propName)) {
326
335
  if (!originalProps.hasOwnProperty(propName) ||
327
- originalProps[propName] !== props[propName]) {
336
+ !is(originalProps[propName], props[propName])) {
328
337
  warnForPropsMutation(propName, element);
329
338
 
330
339
  // Copy over the new value so that the two props objects match again
@@ -334,6 +343,42 @@ function checkAndWarnForMutatedProps(element) {
334
343
  }
335
344
  }
336
345
 
346
+ /**
347
+ * Given an element, validate that its props follow the propTypes definition,
348
+ * provided by the type.
349
+ *
350
+ * @param {ReactElement} element
351
+ */
352
+ function validatePropTypes(element) {
353
+ if (element.type == null) {
354
+ // This has already warned. Don't throw.
355
+ return;
356
+ }
357
+ // Extract the component class from the element. Converts string types
358
+ // to a composite class which may have propTypes.
359
+ // TODO: Validating a string's propTypes is not decoupled from the
360
+ // rendering target which is problematic.
361
+ var componentClass = ReactNativeComponent.getComponentClassForElement(
362
+ element
363
+ );
364
+ var name = componentClass.displayName || componentClass.name;
365
+ if (componentClass.propTypes) {
366
+ checkPropTypes(
367
+ name,
368
+ componentClass.propTypes,
369
+ element.props,
370
+ ReactPropTypeLocations.prop
371
+ );
372
+ }
373
+ if (typeof componentClass.getDefaultProps === 'function') {
374
+ ("production" !== process.env.NODE_ENV ? warning(
375
+ componentClass.getDefaultProps.isReactClassApproved,
376
+ 'getDefaultProps is only used on classic React.createClass ' +
377
+ 'definitions. Use a static property named `defaultProps` instead.'
378
+ ) : null);
379
+ }
380
+ }
381
+
337
382
  var ReactElementValidator = {
338
383
 
339
384
  checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
@@ -360,32 +405,7 @@ var ReactElementValidator = {
360
405
  validateChildKeys(arguments[i], type);
361
406
  }
362
407
 
363
- if (type) {
364
- var name = type.displayName || type.name;
365
- if (type.propTypes) {
366
- checkPropTypes(
367
- name,
368
- type.propTypes,
369
- element.props,
370
- ReactPropTypeLocations.prop
371
- );
372
- }
373
- if (type.contextTypes) {
374
- checkPropTypes(
375
- name,
376
- type.contextTypes,
377
- element._context,
378
- ReactPropTypeLocations.context
379
- );
380
- }
381
- if (typeof type.getDefaultProps === 'function') {
382
- ("production" !== process.env.NODE_ENV ? warning(
383
- type.getDefaultProps.isReactClassApproved,
384
- 'getDefaultProps is only used on classic React.createClass ' +
385
- 'definitions. Use a static property named `defaultProps` instead.'
386
- ) : null);
387
- }
388
- }
408
+ validatePropTypes(element);
389
409
 
390
410
  return element;
391
411
  },
@@ -397,7 +417,43 @@ var ReactElementValidator = {
397
417
  );
398
418
  // Legacy hook TODO: Warn if this is accessed
399
419
  validatedFactory.type = type;
420
+
421
+ if ("production" !== process.env.NODE_ENV) {
422
+ try {
423
+ Object.defineProperty(
424
+ validatedFactory,
425
+ 'type',
426
+ {
427
+ enumerable: false,
428
+ get: function() {
429
+ ("production" !== process.env.NODE_ENV ? warning(
430
+ false,
431
+ 'Factory.type is deprecated. Access the class directly ' +
432
+ 'before passing it to createFactory.'
433
+ ) : null);
434
+ Object.defineProperty(this, 'type', {
435
+ value: type
436
+ });
437
+ return type;
438
+ }
439
+ }
440
+ );
441
+ } catch (x) {
442
+ // IE will fail on defineProperty (es5-shim/sham too)
443
+ }
444
+ }
445
+
446
+
400
447
  return validatedFactory;
448
+ },
449
+
450
+ cloneElement: function(element, props, children) {
451
+ var newElement = ReactElement.cloneElement.apply(this, arguments);
452
+ for (var i = 2; i < arguments.length; i++) {
453
+ validateChildKeys(arguments[i], newElement.type);
454
+ }
455
+ validatePropTypes(newElement);
456
+ return newElement;
401
457
  }
402
458
 
403
459
  };