react 15.0.0-rc.1 → 15.0.2-alpha.1

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 (90) hide show
  1. package/dist/react-with-addons.js +1446 -1195
  2. package/dist/react-with-addons.min.js +6 -6
  3. package/dist/react.js +1330 -1109
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSProperty.js +6 -0
  6. package/lib/CSSPropertyOperations.js +31 -15
  7. package/lib/CallbackQueue.js +3 -2
  8. package/lib/DOMChildrenOperations.js +0 -3
  9. package/lib/DOMLazyTree.js +11 -2
  10. package/lib/DOMPropertyOperations.js +0 -46
  11. package/lib/EventPluginUtils.js +2 -2
  12. package/lib/FallbackCompositionState.js +3 -2
  13. package/lib/HTMLDOMPropertyConfig.js +111 -111
  14. package/lib/IOSDefaultEventPluginOrder.js +16 -0
  15. package/lib/IOSNativeBridgeEventPlugin.js +57 -0
  16. package/lib/NativeMethodsMixin.js +165 -0
  17. package/lib/OrderedMap.js +3 -2
  18. package/lib/PanResponder.js +362 -0
  19. package/lib/React.js +68 -9
  20. package/lib/ReactBrowserEventEmitter.js +3 -2
  21. package/lib/ReactCSSTransitionGroup.js +3 -3
  22. package/lib/ReactClass.js +7 -6
  23. package/lib/ReactComponent.js +2 -2
  24. package/lib/ReactCompositeComponent.js +5 -4
  25. package/lib/ReactDOMComponent.js +14 -15
  26. package/lib/ReactDOMDebugTool.js +0 -8
  27. package/lib/ReactDOMEmptyComponent.js +3 -3
  28. package/lib/ReactDOMInput.js +5 -4
  29. package/lib/ReactDOMOption.js +13 -2
  30. package/lib/ReactDOMSelect.js +3 -2
  31. package/lib/ReactDOMTextComponent.js +3 -2
  32. package/lib/ReactDOMTextarea.js +3 -2
  33. package/lib/ReactDebugInstanceMap.js +102 -0
  34. package/lib/ReactDefaultBatchingStrategy.js +3 -2
  35. package/lib/ReactDefaultPerf.js +46 -7
  36. package/lib/ReactDefaultPerfAnalysis.js +7 -7
  37. package/lib/ReactElement.js +5 -4
  38. package/lib/ReactEventListener.js +3 -2
  39. package/lib/ReactMarkupChecksum.js +7 -2
  40. package/lib/ReactMount.js +1 -0
  41. package/lib/ReactNative.js +71 -0
  42. package/lib/ReactNativeAttributePayload.js +397 -0
  43. package/lib/ReactNativeBaseComponent.js +196 -0
  44. package/lib/ReactNativeComponent.js +3 -2
  45. package/lib/ReactNativeComponentEnvironment.js +38 -0
  46. package/lib/ReactNativeComponentTree.js +66 -0
  47. package/lib/ReactNativeContainerInfo.js +21 -0
  48. package/lib/ReactNativeDOMIDOperations.js +83 -0
  49. package/lib/ReactNativeDefaultInjection.js +99 -0
  50. package/lib/ReactNativeEventEmitter.js +180 -0
  51. package/lib/ReactNativeGlobalInteractionHandler.js +33 -0
  52. package/lib/ReactNativeGlobalResponderHandler.js +25 -0
  53. package/lib/ReactNativeMount.js +190 -0
  54. package/lib/ReactNativePropRegistry.js +52 -0
  55. package/lib/ReactNativeReconcileTransaction.js +100 -0
  56. package/lib/ReactNativeTagHandles.js +54 -0
  57. package/lib/ReactNativeTextComponent.js +70 -0
  58. package/lib/ReactNativeTreeTraversal.js +127 -0
  59. package/lib/ReactOwner.js +4 -3
  60. package/lib/ReactPropTransferer.js +4 -3
  61. package/lib/ReactReconcileTransaction.js +3 -3
  62. package/lib/ReactServerRenderingTransaction.js +3 -3
  63. package/lib/ReactSimpleEmptyComponent.js +3 -3
  64. package/lib/ReactTestUtils.js +14 -4
  65. package/lib/ReactTransitionGroup.js +3 -2
  66. package/lib/ReactUMDEntry.js +26 -0
  67. package/lib/ReactUpdateQueue.js +20 -3
  68. package/lib/ReactUpdates.js +3 -2
  69. package/lib/ReactVersion.js +1 -1
  70. package/lib/ReactWithAddons.js +0 -7
  71. package/lib/ReactWithAddonsUMDEntry.js +26 -0
  72. package/lib/ResponderSyntheticEvent.js +1 -1
  73. package/lib/SVGDOMPropertyConfig.js +266 -52
  74. package/lib/SyntheticEvent.js +5 -4
  75. package/lib/TouchHistoryMath.js +99 -0
  76. package/lib/createReactNativeComponentClass.js +42 -0
  77. package/lib/deprecated.js +3 -2
  78. package/lib/findNodeHandle.js +89 -0
  79. package/lib/instantiateReactComponent.js +3 -2
  80. package/lib/reactComponentExpect.js +3 -2
  81. package/lib/setInnerHTML.js +1 -0
  82. package/lib/update.js +4 -3
  83. package/lib/validateDOMNesting.js +3 -2
  84. package/package.json +5 -4
  85. package/addons.js +0 -15
  86. package/lib/Object.assign.js +0 -47
  87. package/lib/React.native.js +0 -5
  88. package/lib/ReactDOM.native.js +0 -12
  89. package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +0 -61
  90. package/lib/ReactIsomorphic.js +0 -74
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
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.
8
+ *
9
+ * @providesModule ReactNativeReconcileTransaction
10
+ *
11
+ */
12
+ 'use strict';
13
+
14
+ var _assign = require('object-assign');
15
+
16
+ var CallbackQueue = require('./CallbackQueue');
17
+ var PooledClass = require('./PooledClass');
18
+ var Transaction = require('./Transaction');
19
+
20
+ /**
21
+ * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
22
+ * the performing of the transaction.
23
+ */
24
+ var ON_DOM_READY_QUEUEING = {
25
+ /**
26
+ * Initializes the internal `onDOMReady` queue.
27
+ */
28
+ initialize: function () {
29
+ this.reactMountReady.reset();
30
+ },
31
+
32
+ /**
33
+ * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
34
+ */
35
+ close: function () {
36
+ this.reactMountReady.notifyAll();
37
+ }
38
+ };
39
+
40
+ /**
41
+ * Executed within the scope of the `Transaction` instance. Consider these as
42
+ * being member methods, but with an implied ordering while being isolated from
43
+ * each other.
44
+ */
45
+ var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
46
+
47
+ /**
48
+ * Currently:
49
+ * - The order that these are listed in the transaction is critical:
50
+ * - Suppresses events.
51
+ * - Restores selection range.
52
+ *
53
+ * Future:
54
+ * - Restore document/overflow scroll positions that were unintentionally
55
+ * modified via DOM insertions above the top viewport boundary.
56
+ * - Implement/integrate with customized constraint based layout system and keep
57
+ * track of which dimensions must be remeasured.
58
+ *
59
+ * @class ReactNativeReconcileTransaction
60
+ */
61
+ function ReactNativeReconcileTransaction() {
62
+ this.reinitializeTransaction();
63
+ this.reactMountReady = CallbackQueue.getPooled(null);
64
+ }
65
+
66
+ var Mixin = {
67
+ /**
68
+ * @see Transaction
69
+ * @abstract
70
+ * @final
71
+ * @return {array<object>} List of operation wrap procedures.
72
+ * TODO: convert to array<TransactionWrapper>
73
+ */
74
+ getTransactionWrappers: function () {
75
+ return TRANSACTION_WRAPPERS;
76
+ },
77
+
78
+ /**
79
+ * @return {object} The queue to collect `onDOMReady` callbacks with.
80
+ * TODO: convert to ReactMountReady
81
+ */
82
+ getReactMountReady: function () {
83
+ return this.reactMountReady;
84
+ },
85
+
86
+ /**
87
+ * `PooledClass` looks for this, and will invoke this before allowing this
88
+ * instance to be reused.
89
+ */
90
+ destructor: function () {
91
+ CallbackQueue.release(this.reactMountReady);
92
+ this.reactMountReady = null;
93
+ }
94
+ };
95
+
96
+ _assign(ReactNativeReconcileTransaction.prototype, Transaction.Mixin, ReactNativeReconcileTransaction, Mixin);
97
+
98
+ PooledClass.addPoolingTo(ReactNativeReconcileTransaction);
99
+
100
+ module.exports = ReactNativeReconcileTransaction;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
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.
8
+ *
9
+ * @providesModule ReactNativeTagHandles
10
+ *
11
+ */
12
+ 'use strict';
13
+
14
+ var invariant = require('fbjs/lib/invariant');
15
+
16
+ /**
17
+ * Keeps track of allocating and associating native "tags" which are numeric,
18
+ * unique view IDs. All the native tags are negative numbers, to avoid
19
+ * collisions, but in the JS we keep track of them as positive integers to store
20
+ * them effectively in Arrays. So we must refer to them as "inverses" of the
21
+ * native tags (that are * normally negative).
22
+ *
23
+ * It *must* be the case that every `rootNodeID` always maps to the exact same
24
+ * `tag` forever. The easiest way to accomplish this is to never delete
25
+ * anything from this table.
26
+ * Why: Because `dangerouslyReplaceNodeWithMarkupByID` relies on being able to
27
+ * unmount a component with a `rootNodeID`, then mount a new one in its place,
28
+ */
29
+ var INITIAL_TAG_COUNT = 1;
30
+ var ReactNativeTagHandles = {
31
+ tagsStartAt: INITIAL_TAG_COUNT,
32
+ tagCount: INITIAL_TAG_COUNT,
33
+
34
+ allocateTag: function () {
35
+ // Skip over root IDs as those are reserved for native
36
+ while (this.reactTagIsNativeTopRootID(ReactNativeTagHandles.tagCount)) {
37
+ ReactNativeTagHandles.tagCount++;
38
+ }
39
+ var tag = ReactNativeTagHandles.tagCount;
40
+ ReactNativeTagHandles.tagCount++;
41
+ return tag;
42
+ },
43
+
44
+ assertRootTag: function (tag) {
45
+ !this.reactTagIsNativeTopRootID(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expect a native root tag, instead got %s', tag) : invariant(false) : void 0;
46
+ },
47
+
48
+ reactTagIsNativeTopRootID: function (reactTag) {
49
+ // We reserve all tags that are 1 mod 10 for native root views
50
+ return reactTag % 10 === 1;
51
+ }
52
+ };
53
+
54
+ module.exports = ReactNativeTagHandles;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
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.
8
+ *
9
+ * @providesModule ReactNativeTextComponent
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _assign = require('object-assign');
15
+
16
+ var ReactNativeComponentTree = require('./ReactNativeComponentTree');
17
+ var ReactNativeTagHandles = require('./ReactNativeTagHandles');
18
+ var UIManager = require('UIManager');
19
+
20
+ var invariant = require('fbjs/lib/invariant');
21
+
22
+ var ReactNativeTextComponent = function (text) {
23
+ // This is really a ReactText (ReactNode), not a ReactElement
24
+ this._currentElement = text;
25
+ this._stringText = '' + text;
26
+ this._nativeParent = null;
27
+ this._rootNodeID = null;
28
+ };
29
+
30
+ _assign(ReactNativeTextComponent.prototype, {
31
+
32
+ mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
33
+ // TODO: nativeParent should have this context already. Stop abusing context.
34
+ !context.isInAParentText ? process.env.NODE_ENV !== 'production' ? invariant(false, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText) : invariant(false) : void 0;
35
+ this._nativeParent = nativeParent;
36
+ var tag = ReactNativeTagHandles.allocateTag();
37
+ this._rootNodeID = tag;
38
+ var nativeTopRootTag = nativeContainerInfo._tag;
39
+ UIManager.createView(tag, 'RCTRawText', nativeTopRootTag, { text: this._stringText });
40
+
41
+ ReactNativeComponentTree.precacheNode(this, tag);
42
+
43
+ return tag;
44
+ },
45
+
46
+ getNativeNode: function () {
47
+ return this._rootNodeID;
48
+ },
49
+
50
+ receiveComponent: function (nextText, transaction, context) {
51
+ if (nextText !== this._currentElement) {
52
+ this._currentElement = nextText;
53
+ var nextStringText = '' + nextText;
54
+ if (nextStringText !== this._stringText) {
55
+ this._stringText = nextStringText;
56
+ UIManager.updateView(this._rootNodeID, 'RCTRawText', { text: this._stringText });
57
+ }
58
+ }
59
+ },
60
+
61
+ unmountComponent: function () {
62
+ ReactNativeComponentTree.uncacheNode(this);
63
+ this._currentElement = null;
64
+ this._stringText = null;
65
+ this._rootNodeID = null;
66
+ }
67
+
68
+ });
69
+
70
+ module.exports = ReactNativeTextComponent;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Copyright 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
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.
8
+ *
9
+ * @providesModule ReactNativeTreeTraversal
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ // Same as ReactDOMTreeTraversal without the invariants.
15
+
16
+ /**
17
+ * Return the lowest common ancestor of A and B, or null if they are in
18
+ * different trees.
19
+ */
20
+
21
+ function getLowestCommonAncestor(instA, instB) {
22
+ var depthA = 0;
23
+ for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
24
+ depthA++;
25
+ }
26
+ var depthB = 0;
27
+ for (var tempB = instB; tempB; tempB = tempB._nativeParent) {
28
+ depthB++;
29
+ }
30
+
31
+ // If A is deeper, crawl up.
32
+ while (depthA - depthB > 0) {
33
+ instA = instA._nativeParent;
34
+ depthA--;
35
+ }
36
+
37
+ // If B is deeper, crawl up.
38
+ while (depthB - depthA > 0) {
39
+ instB = instB._nativeParent;
40
+ depthB--;
41
+ }
42
+
43
+ // Walk in lockstep until we find a match.
44
+ var depth = depthA;
45
+ while (depth--) {
46
+ if (instA === instB) {
47
+ return instA;
48
+ }
49
+ instA = instA._nativeParent;
50
+ instB = instB._nativeParent;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * Return if A is an ancestor of B.
57
+ */
58
+ function isAncestor(instA, instB) {
59
+ while (instB) {
60
+ if (instB === instA) {
61
+ return true;
62
+ }
63
+ instB = instB._nativeParent;
64
+ }
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * Return the parent instance of the passed-in instance.
70
+ */
71
+ function getParentInstance(inst) {
72
+ return inst._nativeParent;
73
+ }
74
+
75
+ /**
76
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
77
+ */
78
+ function traverseTwoPhase(inst, fn, arg) {
79
+ var path = [];
80
+ while (inst) {
81
+ path.push(inst);
82
+ inst = inst._nativeParent;
83
+ }
84
+ var i;
85
+ for (i = path.length; i-- > 0;) {
86
+ fn(path[i], false, arg);
87
+ }
88
+ for (i = 0; i < path.length; i++) {
89
+ fn(path[i], true, arg);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
95
+ * should would receive a `mouseEnter` or `mouseLeave` event.
96
+ *
97
+ * Does not invoke the callback on the nearest common ancestor because nothing
98
+ * "entered" or "left" that element.
99
+ */
100
+ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
101
+ var common = from && to ? getLowestCommonAncestor(from, to) : null;
102
+ var pathFrom = [];
103
+ while (from && from !== common) {
104
+ pathFrom.push(from);
105
+ from = from._nativeParent;
106
+ }
107
+ var pathTo = [];
108
+ while (to && to !== common) {
109
+ pathTo.push(to);
110
+ to = to._nativeParent;
111
+ }
112
+ var i;
113
+ for (i = 0; i < pathFrom.length; i++) {
114
+ fn(pathFrom[i], true, argFrom);
115
+ }
116
+ for (i = pathTo.length; i-- > 0;) {
117
+ fn(pathTo[i], false, argTo);
118
+ }
119
+ }
120
+
121
+ module.exports = {
122
+ isAncestor: isAncestor,
123
+ getLowestCommonAncestor: getLowestCommonAncestor,
124
+ getParentInstance: getParentInstance,
125
+ traverseTwoPhase: traverseTwoPhase,
126
+ traverseEnterLeave: traverseEnterLeave
127
+ };
package/lib/ReactOwner.js CHANGED
@@ -79,9 +79,10 @@ var ReactOwner = {
79
79
  */
80
80
  removeComponentAsRefFrom: function (component, ref, owner) {
81
81
  !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : void 0;
82
- // Check that `component` is still the current ref because we do not want to
83
- // detach the ref if another component stole it.
84
- if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
82
+ var ownerPublicInstance = owner.getPublicInstance();
83
+ // Check that `component`'s owner is still alive and that `component` is still the current ref
84
+ // because we do not want to detach the ref if another component stole it.
85
+ if (ownerPublicInstance && ownerPublicInstance.refs[ref] === component.getPublicInstance()) {
85
86
  owner.detachRef(ref);
86
87
  }
87
88
  }
@@ -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 joinClasses = require('fbjs/lib/joinClasses');
17
18
 
@@ -36,7 +37,7 @@ var transferStrategyMerge = createTransferStrategy(function (a, b) {
36
37
  // `merge` overrides the first object's (`props[key]` above) keys using the
37
38
  // second object's (`value`) keys. An object's style's existing `propA` would
38
39
  // get overridden. Flip the order here.
39
- return assign({}, b, a);
40
+ return _assign({}, b, a);
40
41
  });
41
42
 
42
43
  /**
@@ -100,7 +101,7 @@ var ReactPropTransferer = {
100
101
  * @return {object} a new object containing both sets of props merged.
101
102
  */
102
103
  mergeProps: function (oldProps, newProps) {
103
- return transferInto(assign({}, oldProps), newProps);
104
+ return transferInto(_assign({}, oldProps), newProps);
104
105
  }
105
106
 
106
107
  };
@@ -11,14 +11,14 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _assign = require('object-assign');
15
+
14
16
  var CallbackQueue = require('./CallbackQueue');
15
17
  var PooledClass = require('./PooledClass');
16
18
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
17
19
  var ReactInputSelection = require('./ReactInputSelection');
18
20
  var Transaction = require('./Transaction');
19
21
 
20
- var assign = require('./Object.assign');
21
-
22
22
  /**
23
23
  * Ensures that, when possible, the selection range (currently selected text
24
24
  * input) is not disturbed by performing the transaction.
@@ -155,7 +155,7 @@ var Mixin = {
155
155
  }
156
156
  };
157
157
 
158
- assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
158
+ _assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
159
159
 
160
160
  PooledClass.addPoolingTo(ReactReconcileTransaction);
161
161
 
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _assign = require('object-assign');
15
+
14
16
  var PooledClass = require('./PooledClass');
15
17
  var Transaction = require('./Transaction');
16
18
 
17
- var assign = require('./Object.assign');
18
-
19
19
  /**
20
20
  * Executed within the scope of the `Transaction` instance. Consider these as
21
21
  * being member methods, but with an implied ordering while being isolated from
@@ -62,7 +62,7 @@ var Mixin = {
62
62
  destructor: function () {}
63
63
  };
64
64
 
65
- assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
65
+ _assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
66
66
 
67
67
  PooledClass.addPoolingTo(ReactServerRenderingTransaction);
68
68