react 0.9.0 → 0.11.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 (114) hide show
  1. package/README.md +3 -0
  2. package/dist/JSXTransformer.js +13448 -0
  3. package/dist/react-with-addons.js +20235 -0
  4. package/dist/react-with-addons.min.js +22 -0
  5. package/dist/react.js +18443 -0
  6. package/dist/react.min.js +21 -0
  7. package/lib/AutoFocusMixin.js +3 -1
  8. package/lib/BeforeInputEventPlugin.js +222 -0
  9. package/lib/CSSPropertyOperations.js +3 -3
  10. package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
  11. package/lib/ChangeEventPlugin.js +1 -1
  12. package/lib/CompositionEventPlugin.js +5 -1
  13. package/lib/DOMChildrenOperations.js +33 -20
  14. package/lib/DOMProperty.js +51 -21
  15. package/lib/DOMPropertyOperations.js +28 -16
  16. package/lib/DefaultEventPluginOrder.js +1 -0
  17. package/lib/EventConstants.js +1 -0
  18. package/lib/EventListener.js +5 -2
  19. package/lib/EventPluginHub.js +2 -5
  20. package/lib/EventPluginRegistry.js +6 -4
  21. package/lib/EventPluginUtils.js +11 -1
  22. package/lib/ExecutionEnvironment.js +8 -2
  23. package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +41 -58
  24. package/lib/LinkedValueUtils.js +26 -28
  25. package/lib/LocalEventTrapMixin.js +52 -0
  26. package/lib/React.js +39 -3
  27. package/lib/ReactBrowserComponentMixin.js +46 -0
  28. package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
  29. package/lib/ReactCSSTransitionGroup.js +12 -10
  30. package/lib/ReactCSSTransitionGroupChild.js +2 -5
  31. package/lib/ReactChildren.js +31 -10
  32. package/lib/ReactComponent.js +119 -223
  33. package/lib/ReactComponentBrowserEnvironment.js +3 -36
  34. package/lib/ReactComponentWithPureRenderMixin.js +54 -0
  35. package/lib/ReactCompositeComponent.js +249 -287
  36. package/lib/ReactDOM.js +25 -23
  37. package/lib/ReactDOMButton.js +2 -1
  38. package/lib/ReactDOMComponent.js +42 -23
  39. package/lib/ReactDOMForm.js +7 -12
  40. package/lib/ReactDOMIDOperations.js +2 -31
  41. package/lib/ReactDOMImg.js +7 -13
  42. package/lib/ReactDOMInput.js +2 -1
  43. package/lib/ReactDOMOption.js +11 -7
  44. package/lib/ReactDOMSelect.js +18 -16
  45. package/lib/ReactDOMSelection.js +35 -10
  46. package/lib/ReactDOMTextarea.js +9 -7
  47. package/lib/ReactDefaultBatchingStrategy.js +3 -3
  48. package/lib/ReactDefaultInjection.js +27 -14
  49. package/lib/ReactDefaultPerf.js +28 -11
  50. package/lib/ReactDefaultPerfAnalysis.js +4 -0
  51. package/lib/ReactDescriptor.js +251 -0
  52. package/lib/ReactDescriptorValidator.js +283 -0
  53. package/lib/ReactEmptyComponent.js +78 -0
  54. package/lib/ReactEventEmitterMixin.js +1 -3
  55. package/lib/ReactEventListener.js +189 -0
  56. package/lib/ReactInjection.js +8 -2
  57. package/lib/ReactInputSelection.js +2 -1
  58. package/lib/ReactLink.js +24 -0
  59. package/lib/ReactMount.js +61 -21
  60. package/lib/ReactMultiChild.js +18 -13
  61. package/lib/ReactOwner.js +6 -1
  62. package/lib/ReactPropTransferer.js +44 -29
  63. package/lib/ReactPropTypes.js +226 -242
  64. package/lib/ReactPutListenerQueue.js +2 -2
  65. package/lib/ReactReconcileTransaction.js +21 -20
  66. package/lib/ReactServerRendering.js +41 -11
  67. package/lib/ReactServerRenderingTransaction.js +115 -0
  68. package/lib/ReactTestUtils.js +39 -21
  69. package/lib/ReactTextComponent.js +21 -13
  70. package/lib/ReactTransitionChildMapping.js +2 -2
  71. package/lib/ReactTransitionEvents.js +19 -0
  72. package/lib/ReactTransitionGroup.js +9 -6
  73. package/lib/ReactUpdates.js +139 -22
  74. package/lib/ReactWithAddons.js +8 -3
  75. package/lib/SVGDOMPropertyConfig.js +97 -0
  76. package/lib/SimpleEventPlugin.js +7 -1
  77. package/lib/SyntheticInputEvent.js +52 -0
  78. package/lib/SyntheticKeyboardEvent.js +33 -4
  79. package/lib/SyntheticMouseEvent.js +3 -0
  80. package/lib/SyntheticTouchEvent.js +4 -1
  81. package/lib/SyntheticUIEvent.js +24 -2
  82. package/lib/Transaction.js +0 -32
  83. package/lib/cloneWithProps.js +10 -8
  84. package/lib/createFullPageComponent.js +1 -1
  85. package/lib/dangerousStyleValue.js +11 -5
  86. package/lib/{ReactComponentEnvironment.js → emptyObject.js} +6 -5
  87. package/lib/escapeTextForBrowser.js +2 -3
  88. package/lib/flattenChildren.js +9 -7
  89. package/lib/focusNode.js +33 -0
  90. package/lib/getEventKey.js +35 -5
  91. package/lib/getEventModifierState.js +52 -0
  92. package/lib/getMarkupWrap.js +2 -0
  93. package/lib/getTextContentAccessor.js +1 -1
  94. package/lib/hyphenate.js +3 -0
  95. package/lib/hyphenateStyleName.js +46 -0
  96. package/lib/instantiateReactComponent.js +62 -0
  97. package/lib/invariant.js +17 -19
  98. package/lib/isNode.js +1 -1
  99. package/lib/{objMap.js → mapObject.js} +8 -3
  100. package/lib/mergeHelpers.js +11 -0
  101. package/lib/mergeInto.js +3 -2
  102. package/lib/monitorCodeUse.js +37 -0
  103. package/lib/onlyChild.js +3 -3
  104. package/lib/performance.js +33 -0
  105. package/lib/performanceNow.js +5 -14
  106. package/lib/setInnerHTML.js +77 -0
  107. package/lib/shouldUpdateReactComponent.js +14 -28
  108. package/lib/toArray.js +1 -1
  109. package/lib/traverseAllChildren.js +9 -5
  110. package/lib/update.js +171 -0
  111. package/package.json +4 -3
  112. package/lib/ReactEventTopLevelCallback.js +0 -149
  113. package/lib/createObjectFrom.js +0 -61
  114. package/lib/objMapKeyVal.js +0 -47
@@ -1,149 +0,0 @@
1
- /**
2
- * Copyright 2013-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 ReactEventTopLevelCallback
17
- * @typechecks static-only
18
- */
19
-
20
- "use strict";
21
-
22
- var PooledClass = require("./PooledClass");
23
- var ReactEventEmitter = require("./ReactEventEmitter");
24
- var ReactInstanceHandles = require("./ReactInstanceHandles");
25
- var ReactMount = require("./ReactMount");
26
-
27
- var getEventTarget = require("./getEventTarget");
28
- var mixInto = require("./mixInto");
29
-
30
- /**
31
- * @type {boolean}
32
- * @private
33
- */
34
- var _topLevelListenersEnabled = true;
35
-
36
- /**
37
- * Finds the parent React component of `node`.
38
- *
39
- * @param {*} node
40
- * @return {?DOMEventTarget} Parent container, or `null` if the specified node
41
- * is not nested.
42
- */
43
- function findParent(node) {
44
- // TODO: It may be a good idea to cache this to prevent unnecessary DOM
45
- // traversal, but caching is difficult to do correctly without using a
46
- // mutation observer to listen for all DOM changes.
47
- var nodeID = ReactMount.getID(node);
48
- var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
49
- var container = ReactMount.findReactContainerForID(rootID);
50
- var parent = ReactMount.getFirstReactDOM(container);
51
- return parent;
52
- }
53
-
54
- /**
55
- * Calls ReactEventEmitter.handleTopLevel for each node stored in bookKeeping's
56
- * ancestor list. Separated from createTopLevelCallback to avoid try/finally
57
- * deoptimization.
58
- *
59
- * @param {string} topLevelType
60
- * @param {DOMEvent} nativeEvent
61
- * @param {TopLevelCallbackBookKeeping} bookKeeping
62
- */
63
- function handleTopLevelImpl(topLevelType, nativeEvent, bookKeeping) {
64
- var topLevelTarget = ReactMount.getFirstReactDOM(
65
- getEventTarget(nativeEvent)
66
- ) || window;
67
-
68
- // Loop through the hierarchy, in case there's any nested components.
69
- // It's important that we build the array of ancestors before calling any
70
- // event handlers, because event handlers can modify the DOM, leading to
71
- // inconsistencies with ReactMount's node cache. See #1105.
72
- var ancestor = topLevelTarget;
73
- while (ancestor) {
74
- bookKeeping.ancestors.push(ancestor);
75
- ancestor = findParent(ancestor);
76
- }
77
-
78
- for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
79
- topLevelTarget = bookKeeping.ancestors[i];
80
- var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
81
- ReactEventEmitter.handleTopLevel(
82
- topLevelType,
83
- topLevelTarget,
84
- topLevelTargetID,
85
- nativeEvent
86
- );
87
- }
88
- }
89
-
90
- // Used to store ancestor hierarchy in top level callback
91
- function TopLevelCallbackBookKeeping() {
92
- this.ancestors = [];
93
- }
94
- mixInto(TopLevelCallbackBookKeeping, {
95
- destructor: function() {
96
- this.ancestors.length = 0;
97
- }
98
- });
99
- PooledClass.addPoolingTo(TopLevelCallbackBookKeeping);
100
-
101
- /**
102
- * Top-level callback creator used to implement event handling using delegation.
103
- * This is used via dependency injection.
104
- */
105
- var ReactEventTopLevelCallback = {
106
-
107
- /**
108
- * Sets whether or not any created callbacks should be enabled.
109
- *
110
- * @param {boolean} enabled True if callbacks should be enabled.
111
- */
112
- setEnabled: function(enabled) {
113
- _topLevelListenersEnabled = !!enabled;
114
- },
115
-
116
- /**
117
- * @return {boolean} True if callbacks are enabled.
118
- */
119
- isEnabled: function() {
120
- return _topLevelListenersEnabled;
121
- },
122
-
123
- /**
124
- * Creates a callback for the supplied `topLevelType` that could be added as
125
- * a listener to the document. The callback computes a `topLevelTarget` which
126
- * should be the root node of a mounted React component where the listener
127
- * is attached.
128
- *
129
- * @param {string} topLevelType Record from `EventConstants`.
130
- * @return {function} Callback for handling top-level events.
131
- */
132
- createTopLevelCallback: function(topLevelType) {
133
- return function(nativeEvent) {
134
- if (!_topLevelListenersEnabled) {
135
- return;
136
- }
137
-
138
- var bookKeeping = TopLevelCallbackBookKeeping.getPooled();
139
- try {
140
- handleTopLevelImpl(topLevelType, nativeEvent, bookKeeping);
141
- } finally {
142
- TopLevelCallbackBookKeeping.release(bookKeeping);
143
- }
144
- };
145
- }
146
-
147
- };
148
-
149
- module.exports = ReactEventTopLevelCallback;
@@ -1,61 +0,0 @@
1
- /**
2
- * Copyright 2013-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 createObjectFrom
17
- */
18
-
19
- /**
20
- * Construct an object from an array of keys
21
- * and optionally specified value or list of values.
22
- *
23
- * >>> createObjectFrom(['a','b','c']);
24
- * {a: true, b: true, c: true}
25
- *
26
- * >>> createObjectFrom(['a','b','c'], false);
27
- * {a: false, b: false, c: false}
28
- *
29
- * >>> createObjectFrom(['a','b','c'], 'monkey');
30
- * {c:'monkey', b:'monkey' c:'monkey'}
31
- *
32
- * >>> createObjectFrom(['a','b','c'], [1,2,3]);
33
- * {a: 1, b: 2, c: 3}
34
- *
35
- * >>> createObjectFrom(['women', 'men'], [true, false]);
36
- * {women: true, men: false}
37
- *
38
- * @param Array list of keys
39
- * @param mixed optional value or value array. defaults true.
40
- * @returns object
41
- */
42
- function createObjectFrom(keys, values /* = true */) {
43
- if ("production" !== process.env.NODE_ENV) {
44
- if (!Array.isArray(keys)) {
45
- throw new TypeError('Must pass an array of keys.');
46
- }
47
- }
48
-
49
- var object = {};
50
- var isArray = Array.isArray(values);
51
- if (typeof values == 'undefined') {
52
- values = true;
53
- }
54
-
55
- for (var ii = keys.length; ii--;) {
56
- object[keys[ii]] = isArray ? values[ii] : values;
57
- }
58
- return object;
59
- }
60
-
61
- module.exports = createObjectFrom;
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright 2013-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 objMapKeyVal
17
- */
18
-
19
- "use strict";
20
-
21
- /**
22
- * Behaves the same as `objMap` but invokes func with the key first, and value
23
- * second. Use `objMap` unless you need this special case.
24
- * Invokes func as:
25
- *
26
- * func(key, value, iteration)
27
- *
28
- * @param {?object} obj Object to map keys over
29
- * @param {!function} func Invoked for each key/val pair.
30
- * @param {?*} context
31
- * @return {?object} Result of mapping or null if obj is falsey
32
- */
33
- function objMapKeyVal(obj, func, context) {
34
- if (!obj) {
35
- return null;
36
- }
37
- var i = 0;
38
- var ret = {};
39
- for (var key in obj) {
40
- if (obj.hasOwnProperty(key)) {
41
- ret[key] = func.call(context, key, obj[key], i++);
42
- }
43
- }
44
- return ret;
45
- }
46
-
47
- module.exports = objMapKeyVal;