react 0.11.2 → 0.12.2

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 (173) hide show
  1. package/dist/JSXTransformer.js +2714 -7859
  2. package/dist/react-with-addons.js +3139 -3593
  3. package/dist/react-with-addons.min.js +11 -17
  4. package/dist/react.js +2940 -3308
  5. package/dist/react.min.js +11 -16
  6. package/lib/AutoFocusMixin.js +5 -12
  7. package/lib/BeforeInputEventPlugin.js +12 -14
  8. package/lib/CSSCore.js +6 -13
  9. package/lib/CSSProperty.js +10 -14
  10. package/lib/CSSPropertyOperations.js +46 -12
  11. package/lib/CallbackQueue.js +7 -14
  12. package/lib/ChangeEventPlugin.js +5 -12
  13. package/lib/ClientReactRootIndex.js +5 -12
  14. package/lib/CompositionEventPlugin.js +5 -12
  15. package/lib/DOMChildrenOperations.js +8 -15
  16. package/lib/DOMProperty.js +16 -19
  17. package/lib/DOMPropertyOperations.js +14 -14
  18. package/lib/Danger.js +12 -17
  19. package/lib/DefaultEventPluginOrder.js +5 -12
  20. package/lib/EnterLeaveEventPlugin.js +5 -12
  21. package/lib/EventConstants.js +5 -12
  22. package/lib/EventListener.js +14 -0
  23. package/lib/EventPluginHub.js +8 -26
  24. package/lib/EventPluginRegistry.js +5 -12
  25. package/lib/EventPluginUtils.js +5 -12
  26. package/lib/EventPropagators.js +12 -17
  27. package/lib/ExecutionEnvironment.js +5 -12
  28. package/lib/HTMLDOMPropertyConfig.js +16 -15
  29. package/lib/LinkedStateMixin.js +5 -12
  30. package/lib/LinkedValueUtils.js +5 -12
  31. package/lib/LocalEventTrapMixin.js +8 -14
  32. package/lib/MobileSafariClickEventPlugin.js +5 -12
  33. package/lib/Object.assign.js +45 -0
  34. package/lib/PooledClass.js +5 -12
  35. package/lib/React.js +87 -54
  36. package/lib/ReactBrowserComponentMixin.js +5 -12
  37. package/lib/ReactBrowserEventEmitter.js +7 -14
  38. package/lib/ReactCSSTransitionGroup.js +15 -17
  39. package/lib/ReactCSSTransitionGroupChild.js +9 -13
  40. package/lib/ReactChildren.js +5 -12
  41. package/lib/ReactComponent.js +61 -68
  42. package/lib/ReactComponentBrowserEnvironment.js +5 -12
  43. package/lib/ReactComponentWithPureRenderMixin.js +5 -12
  44. package/lib/ReactCompositeComponent.js +191 -180
  45. package/lib/ReactContext.js +8 -15
  46. package/lib/ReactCurrentOwner.js +5 -12
  47. package/lib/ReactDOM.js +145 -177
  48. package/lib/ReactDOMButton.js +8 -14
  49. package/lib/ReactDOMComponent.js +103 -38
  50. package/lib/ReactDOMForm.js +9 -15
  51. package/lib/ReactDOMIDOperations.js +5 -12
  52. package/lib/ReactDOMImg.js +8 -14
  53. package/lib/ReactDOMInput.js +30 -38
  54. package/lib/ReactDOMOption.js +8 -14
  55. package/lib/ReactDOMSelect.js +25 -24
  56. package/lib/ReactDOMSelection.js +11 -18
  57. package/lib/ReactDOMTextarea.js +19 -24
  58. package/lib/ReactDefaultBatchingStrategy.js +14 -18
  59. package/lib/ReactDefaultInjection.js +23 -26
  60. package/lib/ReactDefaultPerf.js +14 -17
  61. package/lib/ReactDefaultPerfAnalysis.js +18 -17
  62. package/lib/ReactElement.js +242 -0
  63. package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
  64. package/lib/ReactEmptyComponent.js +8 -13
  65. package/lib/ReactErrorUtils.js +5 -12
  66. package/lib/ReactEventEmitterMixin.js +5 -12
  67. package/lib/ReactEventListener.js +7 -14
  68. package/lib/ReactInjection.js +7 -14
  69. package/lib/ReactInputSelection.js +5 -12
  70. package/lib/ReactInstanceHandles.js +5 -12
  71. package/lib/ReactLegacyElement.js +243 -0
  72. package/lib/ReactLink.js +5 -12
  73. package/lib/ReactMarkupChecksum.js +5 -12
  74. package/lib/ReactMount.js +45 -32
  75. package/lib/ReactMultiChild.js +14 -18
  76. package/lib/ReactMultiChildUpdateTypes.js +5 -12
  77. package/lib/ReactNativeComponent.js +69 -0
  78. package/lib/ReactOwner.js +5 -12
  79. package/lib/ReactPerf.js +8 -13
  80. package/lib/ReactPropTransferer.js +34 -33
  81. package/lib/ReactPropTypeLocationNames.js +5 -12
  82. package/lib/ReactPropTypeLocations.js +5 -12
  83. package/lib/ReactPropTypes.js +38 -29
  84. package/lib/ReactPutListenerQueue.js +7 -14
  85. package/lib/ReactReconcileTransaction.js +7 -15
  86. package/lib/ReactRootIndex.js +5 -12
  87. package/lib/ReactServerRendering.js +21 -34
  88. package/lib/ReactServerRenderingTransaction.js +11 -15
  89. package/lib/ReactStateSetters.js +5 -12
  90. package/lib/ReactTestUtils.js +31 -33
  91. package/lib/ReactTextComponent.js +18 -21
  92. package/lib/ReactTransitionChildMapping.js +6 -13
  93. package/lib/ReactTransitionEvents.js +5 -12
  94. package/lib/ReactTransitionGroup.js +14 -17
  95. package/lib/ReactUpdates.js +43 -22
  96. package/lib/ReactWithAddons.js +7 -13
  97. package/lib/SVGDOMPropertyConfig.js +5 -12
  98. package/lib/SelectEventPlugin.js +13 -20
  99. package/lib/ServerReactRootIndex.js +5 -12
  100. package/lib/SimpleEventPlugin.js +20 -15
  101. package/lib/SyntheticClipboardEvent.js +5 -12
  102. package/lib/SyntheticCompositionEvent.js +5 -12
  103. package/lib/SyntheticDragEvent.js +5 -12
  104. package/lib/SyntheticEvent.js +9 -17
  105. package/lib/SyntheticFocusEvent.js +5 -12
  106. package/lib/SyntheticInputEvent.js +4 -11
  107. package/lib/SyntheticKeyboardEvent.js +17 -19
  108. package/lib/SyntheticMouseEvent.js +5 -12
  109. package/lib/SyntheticTouchEvent.js +5 -12
  110. package/lib/SyntheticUIEvent.js +5 -12
  111. package/lib/SyntheticWheelEvent.js +5 -12
  112. package/lib/Transaction.js +5 -12
  113. package/lib/ViewportMetrics.js +5 -12
  114. package/lib/accumulateInto.js +62 -0
  115. package/lib/adler32.js +6 -13
  116. package/lib/camelize.js +30 -0
  117. package/lib/camelizeStyleName.js +40 -0
  118. package/lib/cloneWithProps.js +9 -15
  119. package/lib/containsNode.js +5 -12
  120. package/lib/copyProperties.js +12 -12
  121. package/lib/createArrayFrom.js +5 -12
  122. package/lib/createFullPageComponent.js +12 -18
  123. package/lib/createNodesFromMarkup.js +5 -12
  124. package/lib/cx.js +5 -12
  125. package/lib/dangerousStyleValue.js +5 -12
  126. package/lib/deprecated.js +47 -0
  127. package/lib/emptyFunction.js +11 -22
  128. package/lib/emptyObject.js +5 -12
  129. package/lib/escapeTextForBrowser.js +5 -12
  130. package/lib/flattenChildren.js +19 -13
  131. package/lib/focusNode.js +10 -16
  132. package/lib/forEachAccumulated.js +5 -12
  133. package/lib/getActiveElement.js +5 -12
  134. package/lib/getEventCharCode.js +50 -0
  135. package/lib/getEventKey.js +9 -21
  136. package/lib/getEventModifierState.js +4 -11
  137. package/lib/getEventTarget.js +5 -12
  138. package/lib/getMarkupWrap.js +5 -12
  139. package/lib/getNodeForCharacterOffset.js +5 -12
  140. package/lib/getReactRootElementInContainer.js +5 -12
  141. package/lib/getTextContentAccessor.js +5 -12
  142. package/lib/getUnboundedScrollPosition.js +5 -12
  143. package/lib/hyphenate.js +5 -12
  144. package/lib/hyphenateStyleName.js +8 -15
  145. package/lib/instantiateReactComponent.js +90 -42
  146. package/lib/invariant.js +5 -12
  147. package/lib/isEventSupported.js +5 -12
  148. package/lib/isNode.js +5 -12
  149. package/lib/isTextInputElement.js +5 -12
  150. package/lib/isTextNode.js +5 -12
  151. package/lib/joinClasses.js +8 -13
  152. package/lib/keyMirror.js +5 -12
  153. package/lib/keyOf.js +5 -12
  154. package/lib/mapObject.js +35 -36
  155. package/lib/memoizeStringOnly.js +5 -12
  156. package/lib/merge.js +14 -17
  157. package/lib/mergeInto.js +13 -35
  158. package/lib/monitorCodeUse.js +5 -12
  159. package/lib/onlyChild.js +8 -15
  160. package/lib/performance.js +5 -12
  161. package/lib/performanceNow.js +5 -12
  162. package/lib/setInnerHTML.js +10 -19
  163. package/lib/shallowEqual.js +6 -13
  164. package/lib/shouldUpdateReactComponent.js +14 -22
  165. package/lib/toArray.js +5 -12
  166. package/lib/traverseAllChildren.js +34 -48
  167. package/lib/update.js +8 -15
  168. package/lib/warning.js +6 -13
  169. package/package.json +3 -8
  170. package/lib/ReactDescriptor.js +0 -251
  171. package/lib/accumulate.js +0 -54
  172. package/lib/mergeHelpers.js +0 -147
  173. package/lib/mixInto.js +0 -34
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule setInnerHTML
17
10
  */
@@ -20,6 +13,9 @@
20
13
 
21
14
  var ExecutionEnvironment = require("./ExecutionEnvironment");
22
15
 
16
+ var WHITESPACE_TEST = /^[ \r\n\t\f]/;
17
+ var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
18
+
23
19
  /**
24
20
  * Set the innerHTML property of a node, ensuring that whitespace is preserved
25
21
  * even in IE8.
@@ -56,13 +52,8 @@ if (ExecutionEnvironment.canUseDOM) {
56
52
  // thin air on IE8, this only happens if there is no visible text
57
53
  // in-front of the non-visible tags. Piggyback on the whitespace fix
58
54
  // and simply check if any non-visible tags appear in the source.
59
- if (html.match(/^[ \r\n\t\f]/) ||
60
- html[0] === '<' && (
61
- html.indexOf('<noscript') !== -1 ||
62
- html.indexOf('<script') !== -1 ||
63
- html.indexOf('<style') !== -1 ||
64
- html.indexOf('<meta') !== -1 ||
65
- html.indexOf('<link') !== -1)) {
55
+ if (WHITESPACE_TEST.test(html) ||
56
+ html[0] === '<' && NONVISIBLE_TEST.test(html)) {
66
57
  // Recover leading whitespace by temporarily prepending any character.
67
58
  // \uFEFF has the potential advantage of being zero-width/invisible.
68
59
  node.innerHTML = '\uFEFF' + html;
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule shallowEqual
17
10
  */
@@ -37,7 +30,7 @@ function shallowEqual(objA, objB) {
37
30
  return false;
38
31
  }
39
32
  }
40
- // Test for B'a keys missing from A.
33
+ // Test for B's keys missing from A.
41
34
  for (key in objB) {
42
35
  if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
43
36
  return false;
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule shouldUpdateReactComponent
17
10
  * @typechecks static-only
@@ -20,22 +13,21 @@
20
13
  "use strict";
21
14
 
22
15
  /**
23
- * Given a `prevDescriptor` and `nextDescriptor`, determines if the existing
16
+ * Given a `prevElement` and `nextElement`, determines if the existing
24
17
  * instance should be updated as opposed to being destroyed or replaced by a new
25
- * instance. Both arguments are descriptors. This ensures that this logic can
18
+ * instance. Both arguments are elements. This ensures that this logic can
26
19
  * operate on stateless trees without any backing instance.
27
20
  *
28
- * @param {?object} prevDescriptor
29
- * @param {?object} nextDescriptor
21
+ * @param {?object} prevElement
22
+ * @param {?object} nextElement
30
23
  * @return {boolean} True if the existing instance should be updated.
31
24
  * @protected
32
25
  */
33
- function shouldUpdateReactComponent(prevDescriptor, nextDescriptor) {
34
- if (prevDescriptor && nextDescriptor &&
35
- prevDescriptor.type === nextDescriptor.type && (
36
- (prevDescriptor.props && prevDescriptor.props.key) ===
37
- (nextDescriptor.props && nextDescriptor.props.key)
38
- ) && prevDescriptor._owner === nextDescriptor._owner) {
26
+ function shouldUpdateReactComponent(prevElement, nextElement) {
27
+ if (prevElement && nextElement &&
28
+ prevElement.type === nextElement.type &&
29
+ prevElement.key === nextElement.key &&
30
+ prevElement._owner === nextElement._owner) {
39
31
  return true;
40
32
  }
41
33
  return false;
package/lib/toArray.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2014 Facebook, Inc.
2
+ * Copyright 2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule toArray
17
10
  * @typechecks
@@ -1,25 +1,18 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule traverseAllChildren
17
10
  */
18
11
 
19
12
  "use strict";
20
13
 
14
+ var ReactElement = require("./ReactElement");
21
15
  var ReactInstanceHandles = require("./ReactInstanceHandles");
22
- var ReactTextComponent = require("./ReactTextComponent");
23
16
 
24
17
  var invariant = require("./invariant");
25
18
 
@@ -54,9 +47,9 @@ function userProvidedKeyEscaper(match) {
54
47
  * @return {string}
55
48
  */
56
49
  function getComponentKey(component, index) {
57
- if (component && component.props && component.props.key != null) {
50
+ if (component && component.key != null) {
58
51
  // Explicit key
59
- return wrapUserProvidedKey(component.props.key);
52
+ return wrapUserProvidedKey(component.key);
60
53
  }
61
54
  // Implicit key determined by the index in the set
62
55
  return index.toString(36);
@@ -97,16 +90,17 @@ function wrapUserProvidedKey(key) {
97
90
  */
98
91
  var traverseAllChildrenImpl =
99
92
  function(children, nameSoFar, indexSoFar, callback, traverseContext) {
93
+ var nextName, nextIndex;
100
94
  var subtreeCount = 0; // Count of children found in the current subtree.
101
95
  if (Array.isArray(children)) {
102
96
  for (var i = 0; i < children.length; i++) {
103
97
  var child = children[i];
104
- var nextName = (
98
+ nextName = (
105
99
  nameSoFar +
106
100
  (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
107
101
  getComponentKey(child, i)
108
102
  );
109
- var nextIndex = indexSoFar + subtreeCount;
103
+ nextIndex = indexSoFar + subtreeCount;
110
104
  subtreeCount += traverseAllChildrenImpl(
111
105
  child,
112
106
  nextName,
@@ -126,40 +120,32 @@ var traverseAllChildrenImpl =
126
120
  // All of the above are perceived as null.
127
121
  callback(traverseContext, null, storageName, indexSoFar);
128
122
  subtreeCount = 1;
129
- } else if (children.type && children.type.prototype &&
130
- children.type.prototype.mountComponentIntoNode) {
123
+ } else if (type === 'string' || type === 'number' ||
124
+ ReactElement.isValidElement(children)) {
131
125
  callback(traverseContext, children, storageName, indexSoFar);
132
126
  subtreeCount = 1;
133
- } else {
134
- if (type === 'object') {
135
- ("production" !== process.env.NODE_ENV ? invariant(
136
- !children || children.nodeType !== 1,
137
- 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
138
- 'elements are not valid children of React components.'
139
- ) : invariant(!children || children.nodeType !== 1));
140
- for (var key in children) {
141
- if (children.hasOwnProperty(key)) {
142
- subtreeCount += traverseAllChildrenImpl(
143
- children[key],
144
- (
145
- nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
146
- wrapUserProvidedKey(key) + SUBSEPARATOR +
147
- getComponentKey(children[key], 0)
148
- ),
149
- indexSoFar + subtreeCount,
150
- callback,
151
- traverseContext
152
- );
153
- }
127
+ } else if (type === 'object') {
128
+ ("production" !== process.env.NODE_ENV ? invariant(
129
+ !children || children.nodeType !== 1,
130
+ 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
131
+ 'elements are not valid children of React components.'
132
+ ) : invariant(!children || children.nodeType !== 1));
133
+ for (var key in children) {
134
+ if (children.hasOwnProperty(key)) {
135
+ nextName = (
136
+ nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
137
+ wrapUserProvidedKey(key) + SUBSEPARATOR +
138
+ getComponentKey(children[key], 0)
139
+ );
140
+ nextIndex = indexSoFar + subtreeCount;
141
+ subtreeCount += traverseAllChildrenImpl(
142
+ children[key],
143
+ nextName,
144
+ nextIndex,
145
+ callback,
146
+ traverseContext
147
+ );
154
148
  }
155
- } else if (type === 'string') {
156
- var normalizedText = ReactTextComponent(children);
157
- callback(traverseContext, normalizedText, storageName, indexSoFar);
158
- subtreeCount += 1;
159
- } else if (type === 'number') {
160
- var normalizedNumber = ReactTextComponent('' + children);
161
- callback(traverseContext, normalizedNumber, storageName, indexSoFar);
162
- subtreeCount += 1;
163
149
  }
164
150
  }
165
151
  }
package/lib/update.js CHANGED
@@ -1,24 +1,17 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule update
17
10
  */
18
11
 
19
12
  "use strict";
20
13
 
21
- var copyProperties = require("./copyProperties");
14
+ var assign = require("./Object.assign");
22
15
  var keyOf = require("./keyOf");
23
16
  var invariant = require("./invariant");
24
17
 
@@ -26,7 +19,7 @@ function shallowCopy(x) {
26
19
  if (Array.isArray(x)) {
27
20
  return x.concat();
28
21
  } else if (x && typeof x === 'object') {
29
- return copyProperties(new x.constructor(), x);
22
+ return assign(new x.constructor(), x);
30
23
  } else {
31
24
  return x;
32
25
  }
@@ -106,7 +99,7 @@ function update(value, spec) {
106
99
  COMMAND_MERGE,
107
100
  nextValue
108
101
  ) : invariant(nextValue && typeof nextValue === 'object'));
109
- copyProperties(nextValue, spec[COMMAND_MERGE]);
102
+ assign(nextValue, spec[COMMAND_MERGE]);
110
103
  }
111
104
 
112
105
  if (spec.hasOwnProperty(COMMAND_PUSH)) {
package/lib/warning.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2014 Facebook, Inc.
2
+ * Copyright 2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
15
8
  *
16
9
  * @providesModule warning
17
10
  */
@@ -30,7 +23,7 @@ var emptyFunction = require("./emptyFunction");
30
23
  var warning = emptyFunction;
31
24
 
32
25
  if ("production" !== process.env.NODE_ENV) {
33
- warning = function(condition, format ) {var args=Array.prototype.slice.call(arguments,2);
26
+ warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
34
27
  if (format === undefined) {
35
28
  throw new Error(
36
29
  '`warning(condition, format, ...args)` requires a warning ' +
package/package.json CHANGED
@@ -1,18 +1,13 @@
1
1
  {
2
2
  "name": "react",
3
3
  "description": "React is a JavaScript library for building user interfaces.",
4
- "version": "0.11.2",
4
+ "version": "0.12.2",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
8
8
  "homepage": "https://github.com/facebook/react/tree/master/npm-react",
9
9
  "bugs": "https://github.com/facebook/react/issues?labels=react-core",
10
- "licenses": [
11
- {
12
- "type": "Apache-2.0",
13
- "url": "http://www.apache.org/licenses/LICENSE-2.0"
14
- }
15
- ],
10
+ "license": "BSD-3-Clause",
16
11
  "files": [
17
12
  "README.md",
18
13
  "addons.js",
@@ -29,7 +24,7 @@
29
24
  "node": ">=0.10.0"
30
25
  },
31
26
  "dependencies": {
32
- "envify": "^2.0.0"
27
+ "envify": "^3.0.0"
33
28
  },
34
29
  "browserify": {
35
30
  "transform": [
@@ -1,251 +0,0 @@
1
- /**
2
- * Copyright 2014 Facebook, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- * @providesModule ReactDescriptor
17
- */
18
-
19
- "use strict";
20
-
21
- var ReactContext = require("./ReactContext");
22
- var ReactCurrentOwner = require("./ReactCurrentOwner");
23
-
24
- var merge = require("./merge");
25
- var warning = require("./warning");
26
-
27
- /**
28
- * Warn for mutations.
29
- *
30
- * @internal
31
- * @param {object} object
32
- * @param {string} key
33
- */
34
- function defineWarningProperty(object, key) {
35
- Object.defineProperty(object, key, {
36
-
37
- configurable: false,
38
- enumerable: true,
39
-
40
- get: function() {
41
- if (!this._store) {
42
- return null;
43
- }
44
- return this._store[key];
45
- },
46
-
47
- set: function(value) {
48
- ("production" !== process.env.NODE_ENV ? warning(
49
- false,
50
- 'Don\'t set the ' + key + ' property of the component. ' +
51
- 'Mutate the existing props object instead.'
52
- ) : null);
53
- this._store[key] = value;
54
- }
55
-
56
- });
57
- }
58
-
59
- /**
60
- * This is updated to true if the membrane is successfully created.
61
- */
62
- var useMutationMembrane = false;
63
-
64
- /**
65
- * Warn for mutations.
66
- *
67
- * @internal
68
- * @param {object} descriptor
69
- */
70
- function defineMutationMembrane(prototype) {
71
- try {
72
- var pseudoFrozenProperties = {
73
- props: true
74
- };
75
- for (var key in pseudoFrozenProperties) {
76
- defineWarningProperty(prototype, key);
77
- }
78
- useMutationMembrane = true;
79
- } catch (x) {
80
- // IE will fail on defineProperty
81
- }
82
- }
83
-
84
- /**
85
- * Transfer static properties from the source to the target. Functions are
86
- * rebound to have this reflect the original source.
87
- */
88
- function proxyStaticMethods(target, source) {
89
- if (typeof source !== 'function') {
90
- return;
91
- }
92
- for (var key in source) {
93
- if (source.hasOwnProperty(key)) {
94
- var value = source[key];
95
- if (typeof value === 'function') {
96
- var bound = value.bind(source);
97
- // Copy any properties defined on the function, such as `isRequired` on
98
- // a PropTypes validator. (mergeInto refuses to work on functions.)
99
- for (var k in value) {
100
- if (value.hasOwnProperty(k)) {
101
- bound[k] = value[k];
102
- }
103
- }
104
- target[key] = bound;
105
- } else {
106
- target[key] = value;
107
- }
108
- }
109
- }
110
- }
111
-
112
- /**
113
- * Base constructor for all React descriptors. This is only used to make this
114
- * work with a dynamic instanceof check. Nothing should live on this prototype.
115
- *
116
- * @param {*} type
117
- * @internal
118
- */
119
- var ReactDescriptor = function() {};
120
-
121
- if ("production" !== process.env.NODE_ENV) {
122
- defineMutationMembrane(ReactDescriptor.prototype);
123
- }
124
-
125
- ReactDescriptor.createFactory = function(type) {
126
-
127
- var descriptorPrototype = Object.create(ReactDescriptor.prototype);
128
-
129
- var factory = function(props, children) {
130
- // For consistency we currently allocate a new object for every descriptor.
131
- // This protects the descriptor from being mutated by the original props
132
- // object being mutated. It also protects the original props object from
133
- // being mutated by children arguments and default props. This behavior
134
- // comes with a performance cost and could be deprecated in the future.
135
- // It could also be optimized with a smarter JSX transform.
136
- if (props == null) {
137
- props = {};
138
- } else if (typeof props === 'object') {
139
- props = merge(props);
140
- }
141
-
142
- // Children can be more than one argument, and those are transferred onto
143
- // the newly allocated props object.
144
- var childrenLength = arguments.length - 1;
145
- if (childrenLength === 1) {
146
- props.children = children;
147
- } else if (childrenLength > 1) {
148
- var childArray = Array(childrenLength);
149
- for (var i = 0; i < childrenLength; i++) {
150
- childArray[i] = arguments[i + 1];
151
- }
152
- props.children = childArray;
153
- }
154
-
155
- // Initialize the descriptor object
156
- var descriptor = Object.create(descriptorPrototype);
157
-
158
- // Record the component responsible for creating this descriptor.
159
- descriptor._owner = ReactCurrentOwner.current;
160
-
161
- // TODO: Deprecate withContext, and then the context becomes accessible
162
- // through the owner.
163
- descriptor._context = ReactContext.current;
164
-
165
- if ("production" !== process.env.NODE_ENV) {
166
- // The validation flag and props are currently mutative. We put them on
167
- // an external backing store so that we can freeze the whole object.
168
- // This can be replaced with a WeakMap once they are implemented in
169
- // commonly used development environments.
170
- descriptor._store = { validated: false, props: props };
171
-
172
- // We're not allowed to set props directly on the object so we early
173
- // return and rely on the prototype membrane to forward to the backing
174
- // store.
175
- if (useMutationMembrane) {
176
- Object.freeze(descriptor);
177
- return descriptor;
178
- }
179
- }
180
-
181
- descriptor.props = props;
182
- return descriptor;
183
- };
184
-
185
- // Currently we expose the prototype of the descriptor so that
186
- // <Foo /> instanceof Foo works. This is controversial pattern.
187
- factory.prototype = descriptorPrototype;
188
-
189
- // Expose the type on the factory and the prototype so that it can be
190
- // easily accessed on descriptors. E.g. <Foo />.type === Foo.type and for
191
- // static methods like <Foo />.type.staticMethod();
192
- // This should not be named constructor since this may not be the function
193
- // that created the descriptor, and it may not even be a constructor.
194
- factory.type = type;
195
- descriptorPrototype.type = type;
196
-
197
- proxyStaticMethods(factory, type);
198
-
199
- // Expose a unique constructor on the prototype is that this works with type
200
- // systems that compare constructor properties: <Foo />.constructor === Foo
201
- // This may be controversial since it requires a known factory function.
202
- descriptorPrototype.constructor = factory;
203
-
204
- return factory;
205
-
206
- };
207
-
208
- ReactDescriptor.cloneAndReplaceProps = function(oldDescriptor, newProps) {
209
- var newDescriptor = Object.create(oldDescriptor.constructor.prototype);
210
- // It's important that this property order matches the hidden class of the
211
- // original descriptor to maintain perf.
212
- newDescriptor._owner = oldDescriptor._owner;
213
- newDescriptor._context = oldDescriptor._context;
214
-
215
- if ("production" !== process.env.NODE_ENV) {
216
- newDescriptor._store = {
217
- validated: oldDescriptor._store.validated,
218
- props: newProps
219
- };
220
- if (useMutationMembrane) {
221
- Object.freeze(newDescriptor);
222
- return newDescriptor;
223
- }
224
- }
225
-
226
- newDescriptor.props = newProps;
227
- return newDescriptor;
228
- };
229
-
230
- /**
231
- * Checks if a value is a valid descriptor constructor.
232
- *
233
- * @param {*}
234
- * @return {boolean}
235
- * @public
236
- */
237
- ReactDescriptor.isValidFactory = function(factory) {
238
- return typeof factory === 'function' &&
239
- factory.prototype instanceof ReactDescriptor;
240
- };
241
-
242
- /**
243
- * @param {?object} object
244
- * @return {boolean} True if `object` is a valid component.
245
- * @final
246
- */
247
- ReactDescriptor.isValidDescriptor = function(object) {
248
- return object instanceof ReactDescriptor;
249
- };
250
-
251
- module.exports = ReactDescriptor;