react 0.14.10 → 15.0.0

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 (193) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +4900 -4627
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +4556 -4059
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +10 -1
  9. package/lib/CSSPropertyOperations.js +49 -19
  10. package/lib/CallbackQueue.js +16 -4
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +91 -61
  13. package/lib/DOMLazyTree.js +105 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +18 -39
  16. package/lib/DOMPropertyOperations.js +42 -53
  17. package/lib/Danger.js +13 -14
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +6 -1
  21. package/lib/EventPluginHub.js +22 -66
  22. package/lib/EventPluginRegistry.js +30 -9
  23. package/lib/EventPluginUtils.js +61 -36
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +4 -4
  26. package/lib/HTMLDOMPropertyConfig.js +131 -152
  27. package/lib/LinkedStateMixin.js +1 -2
  28. package/lib/LinkedValueUtils.js +6 -7
  29. package/lib/MetaMatchers.js +2 -2
  30. package/lib/OrderedMap.js +17 -16
  31. package/lib/PooledClass.js +2 -2
  32. package/lib/React.js +50 -20
  33. package/lib/ReactBrowserEventEmitter.js +19 -26
  34. package/lib/ReactCSSTransitionGroup.js +4 -5
  35. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  36. package/lib/ReactChildReconciler.js +15 -13
  37. package/lib/ReactChildren.js +5 -4
  38. package/lib/ReactClass.js +44 -92
  39. package/lib/ReactComponent.js +9 -10
  40. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  41. package/lib/ReactComponentEnvironment.js +4 -4
  42. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  43. package/lib/ReactCompositeComponent.js +166 -74
  44. package/lib/ReactCurrentOwner.js +2 -1
  45. package/lib/ReactDOM.js +27 -15
  46. package/lib/ReactDOMButton.js +2 -2
  47. package/lib/ReactDOMComponent.js +186 -250
  48. package/lib/ReactDOMComponentFlags.js +18 -0
  49. package/lib/ReactDOMComponentTree.js +186 -0
  50. package/lib/ReactDOMContainerInfo.js +32 -0
  51. package/lib/ReactDOMDebugTool.js +61 -0
  52. package/lib/ReactDOMEmptyComponent.js +60 -0
  53. package/lib/ReactDOMFactories.js +1 -2
  54. package/lib/ReactDOMFeatureFlags.js +2 -2
  55. package/lib/ReactDOMIDOperations.js +5 -60
  56. package/lib/ReactDOMInput.js +73 -23
  57. package/lib/ReactDOMInstrumentation.js +16 -0
  58. package/lib/ReactDOMOption.js +14 -12
  59. package/lib/ReactDOMSelect.js +43 -19
  60. package/lib/ReactDOMSelection.js +4 -4
  61. package/lib/ReactDOMServer.js +1 -1
  62. package/lib/ReactDOMTextComponent.js +87 -45
  63. package/lib/ReactDOMTextarea.js +39 -11
  64. package/lib/ReactDOMTreeTraversal.js +134 -0
  65. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  66. package/lib/ReactDebugInstanceMap.js +102 -0
  67. package/lib/ReactDebugTool.js +72 -0
  68. package/lib/ReactDefaultBatchingStrategy.js +4 -3
  69. package/lib/ReactDefaultInjection.js +11 -15
  70. package/lib/ReactDefaultPerf.js +105 -26
  71. package/lib/ReactDefaultPerfAnalysis.js +23 -15
  72. package/lib/ReactElement.js +63 -23
  73. package/lib/ReactElementValidator.js +9 -9
  74. package/lib/ReactEmptyComponent.js +8 -33
  75. package/lib/ReactErrorUtils.js +1 -2
  76. package/lib/ReactEventEmitterMixin.js +3 -8
  77. package/lib/ReactEventListener.js +23 -77
  78. package/lib/ReactFeatureFlags.js +21 -0
  79. package/lib/ReactFragment.js +6 -6
  80. package/lib/ReactInjection.js +3 -3
  81. package/lib/ReactInputSelection.js +4 -4
  82. package/lib/ReactInstanceHandles.js +10 -12
  83. package/lib/ReactInstanceMap.js +2 -1
  84. package/lib/ReactInstrumentation.js +16 -0
  85. package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
  86. package/lib/ReactLink.js +2 -3
  87. package/lib/ReactMarkupChecksum.js +8 -3
  88. package/lib/ReactMount.js +88 -460
  89. package/lib/ReactMultiChild.js +106 -200
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +6 -5
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +2 -25
  94. package/lib/ReactOwner.js +7 -6
  95. package/lib/ReactPerf.js +2 -2
  96. package/lib/ReactPropTransferer.js +5 -4
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +31 -7
  100. package/lib/ReactReconcileTransaction.js +20 -9
  101. package/lib/ReactReconciler.js +29 -6
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +17 -35
  105. package/lib/ReactServerRenderingTransaction.js +11 -29
  106. package/lib/ReactSimpleEmptyComponent.js +36 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +47 -28
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +8 -44
  111. package/lib/ReactTransitionGroup.js +4 -3
  112. package/lib/ReactUMDEntry.js +26 -0
  113. package/lib/ReactUpdateQueue.js +24 -66
  114. package/lib/ReactUpdates.js +29 -11
  115. package/lib/ReactVersion.js +2 -2
  116. package/lib/ReactWithAddons.js +1 -21
  117. package/lib/ReactWithAddonsUMDEntry.js +26 -0
  118. package/lib/ResponderEventPlugin.js +54 -66
  119. package/lib/ResponderSyntheticEvent.js +2 -3
  120. package/lib/ResponderTouchHistoryStore.js +5 -5
  121. package/lib/SVGDOMPropertyConfig.js +267 -94
  122. package/lib/SelectEventPlugin.js +13 -18
  123. package/lib/SimpleEventPlugin.js +57 -17
  124. package/lib/SyntheticAnimationEvent.js +39 -0
  125. package/lib/SyntheticClipboardEvent.js +2 -3
  126. package/lib/SyntheticCompositionEvent.js +2 -3
  127. package/lib/SyntheticDragEvent.js +2 -3
  128. package/lib/SyntheticEvent.js +102 -21
  129. package/lib/SyntheticFocusEvent.js +2 -3
  130. package/lib/SyntheticInputEvent.js +2 -3
  131. package/lib/SyntheticKeyboardEvent.js +2 -3
  132. package/lib/SyntheticMouseEvent.js +2 -3
  133. package/lib/SyntheticTouchEvent.js +2 -3
  134. package/lib/SyntheticTransitionEvent.js +39 -0
  135. package/lib/SyntheticUIEvent.js +2 -3
  136. package/lib/SyntheticWheelEvent.js +2 -3
  137. package/lib/TapEventPlugin.js +3 -12
  138. package/lib/Transaction.js +3 -3
  139. package/lib/ViewportMetrics.js +1 -1
  140. package/lib/accumulate.js +2 -2
  141. package/lib/accumulateInto.js +2 -2
  142. package/lib/adler32.js +3 -2
  143. package/lib/canDefineProperty.js +1 -1
  144. package/lib/createHierarchyRenderer.js +1 -1
  145. package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
  146. package/lib/dangerousStyleValue.js +25 -3
  147. package/lib/deprecated.js +7 -4
  148. package/lib/escapeTextContentForBrowser.js +1 -1
  149. package/lib/findDOMNode.js +15 -8
  150. package/lib/flattenChildren.js +2 -2
  151. package/lib/forEachAccumulated.js +2 -1
  152. package/lib/getEventCharCode.js +2 -2
  153. package/lib/getEventKey.js +1 -2
  154. package/lib/getEventModifierState.js +1 -2
  155. package/lib/getEventTarget.js +8 -2
  156. package/lib/getIteratorFn.js +2 -2
  157. package/lib/getNativeComponentFromComposite.js +30 -0
  158. package/lib/getNodeForCharacterOffset.js +2 -1
  159. package/lib/getTestDocument.js +1 -1
  160. package/lib/getTextContentAccessor.js +1 -1
  161. package/lib/getVendorPrefixedEventName.js +101 -0
  162. package/lib/instantiateReactComponent.js +12 -13
  163. package/lib/isEventSupported.js +2 -2
  164. package/lib/isTextInputElement.js +2 -1
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/quoteAttributeValueForBrowser.js +1 -1
  167. package/lib/reactComponentExpect.js +5 -4
  168. package/lib/renderSubtreeIntoContainer.js +1 -1
  169. package/lib/setInnerHTML.js +6 -14
  170. package/lib/setTextContent.js +1 -1
  171. package/lib/shallowCompare.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +2 -3
  173. package/lib/sliceChildren.js +1 -1
  174. package/lib/traverseAllChildren.js +8 -8
  175. package/lib/update.js +16 -15
  176. package/lib/validateDOMNesting.js +18 -13
  177. package/package.json +23 -32
  178. package/addons.js +0 -13
  179. package/cjs/react-jsx-dev-runtime.development.js +0 -861
  180. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  181. package/cjs/react-jsx-runtime.development.js +0 -883
  182. package/cjs/react-jsx-runtime.production.min.js +0 -10
  183. package/jsx-dev-runtime.js +0 -7
  184. package/jsx-runtime.js +0 -7
  185. package/lib/Object.assign.js +0 -47
  186. package/lib/React.native.js +0 -5
  187. package/lib/ReactBrowserComponentMixin.js +0 -36
  188. package/lib/ReactEmptyComponentRegistry.js +0 -48
  189. package/lib/ReactIsomorphic.js +0 -74
  190. package/lib/ReactRootIndex.js +0 -29
  191. package/lib/ServerReactRootIndex.js +0 -29
  192. package/lib/cloneWithProps.js +0 -54
  193. package/lib/webcomponents.js +0 -6379
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -41,7 +41,7 @@ function isEventSupported(eventNameSuffix, capture) {
41
41
  }
42
42
 
43
43
  var eventName = 'on' + eventNameSuffix;
44
- var isSupported = (eventName in document);
44
+ var isSupported = eventName in document;
45
45
 
46
46
  if (!isSupported) {
47
47
  var element = document.createElement('div');
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -14,6 +14,7 @@
14
14
  /**
15
15
  * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
16
16
  */
17
+
17
18
  var supportedInputTypes = {
18
19
  'color': true,
19
20
  'date': true,
package/lib/onlyChild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -26,7 +26,7 @@ var invariant = require('fbjs/lib/invariant');
26
26
  * structure.
27
27
  */
28
28
  function onlyChild(children) {
29
- !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined;
29
+ !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : void 0;
30
30
  return children;
31
31
  }
32
32
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, 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 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -12,10 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
+ var _assign = require('object-assign');
16
+
15
17
  var ReactInstanceMap = require('./ReactInstanceMap');
16
18
  var ReactTestUtils = require('./ReactTestUtils');
17
19
 
18
- var assign = require('./Object.assign');
19
20
  var invariant = require('fbjs/lib/invariant');
20
21
 
21
22
  function reactComponentExpect(instance) {
@@ -30,7 +31,7 @@ function reactComponentExpect(instance) {
30
31
  expect(instance).not.toBeNull();
31
32
  expect(instance).not.toBeUndefined();
32
33
 
33
- !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : undefined;
34
+ !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : void 0;
34
35
  var internalInstance = ReactInstanceMap.get(instance);
35
36
 
36
37
  expect(typeof internalInstance).toBe('object');
@@ -44,7 +45,7 @@ function reactComponentExpectInternal(internalInstance) {
44
45
  this._instance = internalInstance;
45
46
  }
46
47
 
47
- assign(reactComponentExpectInternal.prototype, {
48
+ _assign(reactComponentExpectInternal.prototype, {
48
49
  // Getters -------------------------------------------------------------------
49
50
 
50
51
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, 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 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,8 +9,6 @@
9
9
  * @providesModule setInnerHTML
10
10
  */
11
11
 
12
- /* globals MSApp */
13
-
14
12
  'use strict';
15
13
 
16
14
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
@@ -18,6 +16,8 @@ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
18
16
  var WHITESPACE_TEST = /^[ \r\n\t\f]/;
19
17
  var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
20
18
 
19
+ var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
20
+
21
21
  /**
22
22
  * Set the innerHTML property of a node, ensuring that whitespace is preserved
23
23
  * even in IE8.
@@ -26,18 +26,9 @@ var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
26
26
  * @param {string} html
27
27
  * @internal
28
28
  */
29
- var setInnerHTML = function (node, html) {
29
+ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
30
30
  node.innerHTML = html;
31
- };
32
-
33
- // Win8 apps: Allow all html to be inserted
34
- if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
35
- setInnerHTML = function (node, html) {
36
- MSApp.execUnsafeLocalFunction(function () {
37
- node.innerHTML = html;
38
- });
39
- };
40
- }
31
+ });
41
32
 
42
33
  if (ExecutionEnvironment.canUseDOM) {
43
34
  // IE8: When updating a just created node with innerHTML only leading
@@ -85,6 +76,7 @@ if (ExecutionEnvironment.canUseDOM) {
85
76
  }
86
77
  };
87
78
  }
79
+ testElement = null;
88
80
  }
89
81
 
90
82
  module.exports = setInnerHTML;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, 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 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, 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 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule shouldUpdateReactComponent
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -23,6 +22,7 @@
23
22
  * @return {boolean} True if the existing instance should be updated.
24
23
  * @protected
25
24
  */
25
+
26
26
  function shouldUpdateReactComponent(prevElement, nextElement) {
27
27
  var prevEmpty = prevElement === null || prevElement === false;
28
28
  var nextEmpty = nextElement === null || nextElement === false;
@@ -37,7 +37,6 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
37
37
  } else {
38
38
  return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
39
39
  }
40
- return false;
41
40
  }
42
41
 
43
42
  module.exports = shouldUpdateReactComponent;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, 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 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -13,13 +13,12 @@
13
13
 
14
14
  var ReactCurrentOwner = require('./ReactCurrentOwner');
15
15
  var ReactElement = require('./ReactElement');
16
- var ReactInstanceHandles = require('./ReactInstanceHandles');
17
16
 
18
17
  var getIteratorFn = require('./getIteratorFn');
19
18
  var invariant = require('fbjs/lib/invariant');
20
19
  var warning = require('fbjs/lib/warning');
21
20
 
22
- var SEPARATOR = ReactInstanceHandles.SEPARATOR;
21
+ var SEPARATOR = '.';
23
22
  var SUBSEPARATOR = ':';
24
23
 
25
24
  /**
@@ -29,11 +28,10 @@ var SUBSEPARATOR = ':';
29
28
 
30
29
  var userProvidedKeyEscaperLookup = {
31
30
  '=': '=0',
32
- '.': '=1',
33
31
  ':': '=2'
34
32
  };
35
33
 
36
- var userProvidedKeyEscapeRegex = /[=.:]/g;
34
+ var userProvidedKeyEscapeRegex = /[=:]/g;
37
35
 
38
36
  var didWarnAboutMaps = false;
39
37
 
@@ -49,7 +47,9 @@ function userProvidedKeyEscaper(match) {
49
47
  * @return {string}
50
48
  */
51
49
  function getComponentKey(component, index) {
52
- if (component && component.key != null) {
50
+ // Do some typechecking here since we call this blindly. We want to ensure
51
+ // that we don't block potential future ES APIs.
52
+ if (component && typeof component === 'object' && component.key != null) {
53
53
  // Explicit key
54
54
  return wrapUserProvidedKey(component.key);
55
55
  }
@@ -127,7 +127,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
127
127
  }
128
128
  } else {
129
129
  if (process.env.NODE_ENV !== 'production') {
130
- process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : undefined;
130
+ process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : void 0;
131
131
  didWarnAboutMaps = true;
132
132
  }
133
133
  // Iterator will provide entry [k,v] tuples rather than values.
@@ -155,7 +155,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
155
155
  }
156
156
  }
157
157
  var childrenString = String(children);
158
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : undefined;
158
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : void 0;
159
159
  }
160
160
  }
161
161
 
package/lib/update.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -13,16 +13,17 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- var assign = require('./Object.assign');
16
+ var _assign = require('object-assign');
17
+
17
18
  var keyOf = require('fbjs/lib/keyOf');
18
19
  var invariant = require('fbjs/lib/invariant');
19
- var hasOwnProperty = ({}).hasOwnProperty;
20
+ var hasOwnProperty = {}.hasOwnProperty;
20
21
 
21
22
  function shallowCopy(x) {
22
23
  if (Array.isArray(x)) {
23
24
  return x.concat();
24
25
  } else if (x && typeof x === 'object') {
25
- return assign(new x.constructor(), x);
26
+ return _assign(new x.constructor(), x);
26
27
  } else {
27
28
  return x;
28
29
  }
@@ -44,16 +45,16 @@ ALL_COMMANDS_LIST.forEach(function (command) {
44
45
  });
45
46
 
46
47
  function invariantArrayCase(value, spec, command) {
47
- !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : invariant(false) : undefined;
48
+ !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : invariant(false) : void 0;
48
49
  var specValue = spec[command];
49
- !Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. ' + 'Did you forget to wrap your parameter in an array?', command, specValue) : invariant(false) : undefined;
50
+ !Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. ' + 'Did you forget to wrap your parameter in an array?', command, specValue) : invariant(false) : void 0;
50
51
  }
51
52
 
52
53
  function update(value, spec) {
53
- !(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one ' + 'of %s. Did you forget to include {%s: ...}?', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : invariant(false) : undefined;
54
+ !(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one ' + 'of %s. Did you forget to include {%s: ...}?', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : invariant(false) : void 0;
54
55
 
55
56
  if (hasOwnProperty.call(spec, COMMAND_SET)) {
56
- !(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : invariant(false) : undefined;
57
+ !(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : invariant(false) : void 0;
57
58
 
58
59
  return spec[COMMAND_SET];
59
60
  }
@@ -62,9 +63,9 @@ function update(value, spec) {
62
63
 
63
64
  if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
64
65
  var mergeObj = spec[COMMAND_MERGE];
65
- !(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : invariant(false) : undefined;
66
- !(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : invariant(false) : undefined;
67
- assign(nextValue, spec[COMMAND_MERGE]);
66
+ !(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : invariant(false) : void 0;
67
+ !(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : invariant(false) : void 0;
68
+ _assign(nextValue, spec[COMMAND_MERGE]);
68
69
  }
69
70
 
70
71
  if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
@@ -82,16 +83,16 @@ function update(value, spec) {
82
83
  }
83
84
 
84
85
  if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
85
- !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : invariant(false) : undefined;
86
- !Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : undefined;
86
+ !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : invariant(false) : void 0;
87
+ !Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : void 0;
87
88
  spec[COMMAND_SPLICE].forEach(function (args) {
88
- !Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : undefined;
89
+ !Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : void 0;
89
90
  nextValue.splice.apply(nextValue, args);
90
91
  });
91
92
  }
92
93
 
93
94
  if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
94
- !(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : invariant(false) : undefined;
95
+ !(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : invariant(false) : void 0;
95
96
  nextValue = spec[COMMAND_APPLY](nextValue);
96
97
  }
97
98
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2015, Facebook, Inc.
2
+ * Copyright 2015-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -11,7 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var assign = require('./Object.assign');
14
+ var _assign = require('object-assign');
15
+
15
16
  var emptyFunction = require('fbjs/lib/emptyFunction');
16
17
  var warning = require('fbjs/lib/warning');
17
18
 
@@ -47,7 +48,7 @@ if (process.env.NODE_ENV !== 'production') {
47
48
  var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
48
49
 
49
50
  var emptyAncestorInfo = {
50
- parentTag: null,
51
+ current: null,
51
52
 
52
53
  formTag: null,
53
54
  aTagInScope: null,
@@ -60,7 +61,7 @@ if (process.env.NODE_ENV !== 'production') {
60
61
  };
61
62
 
62
63
  var updatedAncestorInfo = function (oldInfo, tag, instance) {
63
- var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
64
+ var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
64
65
  var info = { tag: tag, instance: instance };
65
66
 
66
67
  if (inScopeTags.indexOf(tag) !== -1) {
@@ -79,7 +80,7 @@ if (process.env.NODE_ENV !== 'production') {
79
80
  ancestorInfo.dlItemTagAutoclosing = null;
80
81
  }
81
82
 
82
- ancestorInfo.parentTag = info;
83
+ ancestorInfo.current = info;
83
84
 
84
85
  if (tag === 'form') {
85
86
  ancestorInfo.formTag = info;
@@ -152,6 +153,8 @@ if (process.env.NODE_ENV !== 'production') {
152
153
  // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
153
154
  case 'html':
154
155
  return tag === 'head' || tag === 'body';
156
+ case '#document':
157
+ return tag === 'html';
155
158
  }
156
159
 
157
160
  // Probably in the "in body" parsing mode, so we outlaw only tag combos
@@ -175,6 +178,7 @@ if (process.env.NODE_ENV !== 'production') {
175
178
  case 'colgroup':
176
179
  case 'frame':
177
180
  case 'head':
181
+ case 'html':
178
182
  case 'tbody':
179
183
  case 'td':
180
184
  case 'tfoot':
@@ -273,9 +277,7 @@ if (process.env.NODE_ENV !== 'production') {
273
277
  }
274
278
 
275
279
  var stack = [];
276
- /*eslint-disable space-after-keywords */
277
280
  do {
278
- /*eslint-enable space-after-keywords */
279
281
  stack.push(instance);
280
282
  } while (instance = instance._currentElement._owner);
281
283
  stack.reverse();
@@ -286,7 +288,7 @@ if (process.env.NODE_ENV !== 'production') {
286
288
 
287
289
  validateDOMNesting = function (childTag, childInstance, ancestorInfo) {
288
290
  ancestorInfo = ancestorInfo || emptyAncestorInfo;
289
- var parentInfo = ancestorInfo.parentTag;
291
+ var parentInfo = ancestorInfo.current;
290
292
  var parentTag = parentInfo && parentInfo.tag;
291
293
 
292
294
  var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
@@ -335,26 +337,29 @@ if (process.env.NODE_ENV !== 'production') {
335
337
  }
336
338
  didWarn[warnKey] = true;
337
339
 
340
+ var tagDisplayName = childTag;
341
+ if (childTag !== '#text') {
342
+ tagDisplayName = '<' + childTag + '>';
343
+ }
344
+
338
345
  if (invalidParent) {
339
346
  var info = '';
340
347
  if (ancestorTag === 'table' && childTag === 'tr') {
341
348
  info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
342
349
  }
343
- process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s>. ' + 'See %s.%s', childTag, ancestorTag, ownerInfo, info) : undefined;
350
+ process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>. ' + 'See %s.%s', tagDisplayName, ancestorTag, ownerInfo, info) : void 0;
344
351
  } else {
345
- process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a descendant of ' + '<%s>. See %s.', childTag, ancestorTag, ownerInfo) : undefined;
352
+ process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>. See %s.', tagDisplayName, ancestorTag, ownerInfo) : void 0;
346
353
  }
347
354
  }
348
355
  };
349
356
 
350
- validateDOMNesting.ancestorInfoContextKey = '__validateDOMNesting_ancestorInfo$' + Math.random().toString(36).slice(2);
351
-
352
357
  validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo;
353
358
 
354
359
  // For testing
355
360
  validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) {
356
361
  ancestorInfo = ancestorInfo || emptyAncestorInfo;
357
- var parentInfo = ancestorInfo.parentTag;
362
+ var parentInfo = ancestorInfo.current;
358
363
  var parentTag = parentInfo && parentInfo.tag;
359
364
  return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo);
360
365
  };