react 0.8.0 → 0.9.0-rc1

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 (107) hide show
  1. package/README.md +0 -8
  2. package/addons.js +0 -3
  3. package/lib/AutoFocusMixin.js +30 -0
  4. package/lib/CSSCore.js +22 -21
  5. package/lib/CSSProperty.js +31 -0
  6. package/lib/ChangeEventPlugin.js +26 -4
  7. package/lib/ClientReactRootIndex.js +30 -0
  8. package/lib/CompositionEventPlugin.js +57 -9
  9. package/lib/DOMChildrenOperations.js +32 -2
  10. package/lib/DOMProperty.js +2 -0
  11. package/lib/DOMPropertyOperations.js +14 -1
  12. package/lib/Danger.js +8 -7
  13. package/lib/DefaultDOMPropertyConfig.js +12 -2
  14. package/lib/EnterLeaveEventPlugin.js +37 -4
  15. package/lib/EventConstants.js +3 -0
  16. package/lib/EventListener.js +42 -34
  17. package/lib/EventPluginHub.js +113 -12
  18. package/lib/EventPluginRegistry.js +39 -16
  19. package/lib/EventPluginUtils.js +32 -3
  20. package/lib/EventPropagators.js +6 -42
  21. package/lib/ExecutionEnvironment.js +3 -0
  22. package/lib/LinkedValueUtils.js +161 -0
  23. package/lib/PooledClass.js +6 -0
  24. package/lib/React.js +27 -3
  25. package/lib/ReactCSSTransitionGroup.js +65 -0
  26. package/lib/{ReactTransitionableChild.js → ReactCSSTransitionGroupChild.js} +21 -35
  27. package/lib/ReactComponent.js +87 -52
  28. package/lib/ReactComponentBrowserEnvironment.js +67 -49
  29. package/lib/ReactComponentEnvironment.js +2 -0
  30. package/lib/ReactCompositeComponent.js +547 -112
  31. package/lib/ReactContext.js +67 -0
  32. package/lib/ReactDOM.js +13 -0
  33. package/lib/ReactDOMButton.js +4 -0
  34. package/lib/ReactDOMComponent.js +46 -21
  35. package/lib/ReactDOMForm.js +9 -2
  36. package/lib/ReactDOMIDOperations.js +105 -60
  37. package/lib/ReactDOMImg.js +58 -0
  38. package/lib/ReactDOMInput.js +26 -14
  39. package/lib/ReactDOMOption.js +1 -0
  40. package/lib/ReactDOMSelect.js +36 -17
  41. package/lib/ReactDOMTextarea.js +12 -8
  42. package/lib/ReactDefaultInjection.js +50 -26
  43. package/lib/ReactDefaultPerf.js +207 -370
  44. package/lib/ReactDefaultPerfAnalysis.js +199 -0
  45. package/lib/ReactErrorUtils.js +5 -14
  46. package/lib/ReactEventEmitter.js +141 -145
  47. package/lib/ReactEventEmitterMixin.js +0 -32
  48. package/lib/ReactEventTopLevelCallback.js +32 -12
  49. package/lib/ReactInjection.js +39 -0
  50. package/lib/ReactInstanceHandles.js +35 -19
  51. package/lib/ReactLink.js +1 -1
  52. package/lib/ReactMount.js +127 -103
  53. package/lib/ReactMountReady.js +1 -1
  54. package/lib/ReactMultiChild.js +30 -46
  55. package/lib/ReactMultiChildUpdateTypes.js +2 -0
  56. package/lib/ReactOwner.js +10 -2
  57. package/lib/ReactPerf.js +5 -8
  58. package/lib/ReactPropTransferer.js +40 -21
  59. package/lib/ReactPropTypeLocationNames.js +31 -0
  60. package/lib/ReactPropTypeLocations.js +29 -0
  61. package/lib/ReactPropTypes.js +248 -47
  62. package/lib/ReactPutListenerQueue.js +61 -0
  63. package/lib/ReactReconcileTransaction.js +20 -0
  64. package/lib/ReactRootIndex.js +36 -0
  65. package/lib/ReactServerRendering.js +8 -11
  66. package/lib/ReactTextComponent.js +8 -3
  67. package/lib/{ReactTransitionKeySet.js → ReactTransitionChildMapping.js} +42 -47
  68. package/lib/ReactTransitionGroup.js +132 -57
  69. package/lib/ReactUpdates.js +14 -11
  70. package/lib/ReactWithAddons.js +7 -2
  71. package/lib/SelectEventPlugin.js +22 -39
  72. package/lib/ServerReactRootIndex.js +36 -0
  73. package/lib/SimpleEventPlugin.js +54 -6
  74. package/lib/SyntheticClipboardEvent.js +7 -1
  75. package/lib/SyntheticDragEvent.js +44 -0
  76. package/lib/SyntheticEvent.js +2 -1
  77. package/lib/SyntheticKeyboardEvent.js +4 -2
  78. package/lib/SyntheticWheelEvent.js +10 -7
  79. package/lib/Transaction.js +61 -36
  80. package/lib/cloneWithProps.js +59 -0
  81. package/lib/createArrayFrom.js +10 -13
  82. package/lib/createFullPageComponent.js +63 -0
  83. package/lib/cx.js +2 -2
  84. package/lib/flattenChildren.js +5 -2
  85. package/lib/getActiveElement.js +4 -3
  86. package/lib/getEventKey.js +85 -0
  87. package/lib/getMarkupWrap.js +10 -0
  88. package/lib/getTextContentAccessor.js +5 -3
  89. package/lib/getUnboundedScrollPosition.js +2 -2
  90. package/lib/invariant.js +12 -4
  91. package/lib/isEventSupported.js +7 -11
  92. package/lib/mergeHelpers.js +5 -6
  93. package/lib/onlyChild.js +43 -0
  94. package/lib/shouldUpdateReactComponent.js +58 -0
  95. package/lib/toArray.js +75 -0
  96. package/lib/traverseAllChildren.js +69 -7
  97. package/lib/warning.js +40 -0
  98. package/package.json +2 -3
  99. package/react.js +0 -3
  100. package/ReactJSErrors.js +0 -40
  101. package/lib/$.js +0 -46
  102. package/lib/CallbackRegistry.js +0 -91
  103. package/lib/LinkedValueMixin.js +0 -68
  104. package/lib/ex.js +0 -49
  105. package/lib/filterAttributes.js +0 -45
  106. package/lib/ge.js +0 -76
  107. package/lib/mutateHTMLNodeWithMarkup.js +0 -100
package/lib/warning.js ADDED
@@ -0,0 +1,40 @@
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 warning
17
+ */
18
+
19
+
20
+ /**
21
+ * Similar to invariant but only logs a warning if the condition is not met.
22
+ * This can be used to log issues in development environments in critical
23
+ * paths. Removing the logging code for production environments will keep the
24
+ * same logic and follow the same code paths.
25
+ */
26
+ function warning(condition, format ) {var args=Array.prototype.slice.call(arguments,2);
27
+ if (format === undefined) {
28
+ throw new Error(
29
+ '`warning(condition, format, ...args)` requires a warning ' +
30
+ 'message argument'
31
+ );
32
+ }
33
+
34
+ if (!condition) {
35
+ var argIndex = 0;
36
+ console.warn('Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}));
37
+ }
38
+ }
39
+
40
+ module.exports = warning;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-rc1",
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
@@ -16,7 +16,6 @@
16
16
  "README.md",
17
17
  "addons.js",
18
18
  "react.js",
19
- "ReactJSErrors.js",
20
19
  "lib/"
21
20
  ],
22
21
  "main": "react.js",
@@ -28,7 +27,7 @@
28
27
  "node": ">=0.10.0"
29
28
  },
30
29
  "peerDependencies": {
31
- "envify": "~0.2.0"
30
+ "envify": "~1.0.1"
32
31
  },
33
32
  "browserify": {
34
33
  "transform": [
package/react.js CHANGED
@@ -1,4 +1 @@
1
1
  module.exports = require('./lib/React');
2
- if ('production' !== process.env.NODE_ENV) {
3
- module.exports = require('./ReactJSErrors').wrap(module.exports);
4
- }
package/ReactJSErrors.js DELETED
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- var copyProperties = require('./lib/copyProperties');
4
-
5
- var WARNING_MESSAGE = (
6
- 'It looks like you\'re trying to use jeffbski\'s React.js project.\n' +
7
- 'The `react` npm package now points to the React JavaScript library for ' +
8
- 'building user interfaces, not the React.js project for managing asynchronous ' +
9
- 'control flow. If you\'re looking for that library, please npm install autoflow.'
10
- );
11
-
12
- function error() {
13
- throw new Error(WARNING_MESSAGE);
14
- }
15
-
16
- // Model the React.js project's public interface exactly.
17
-
18
- function ReactJSShim() {
19
- error();
20
- }
21
-
22
- ReactJSShim.logEvents = error;
23
- ReactJSShim.resolvePromises = error;
24
- ReactJSShim.trackTasks = error;
25
- ReactJSShim.createEventCollector = error;
26
-
27
- // These could throw using defineProperty() but supporting older browsers will
28
- // be painful. Additionally any error messages around this will contain the string
29
- // so I think this is sufficient.
30
- ReactJSShim.options = WARNING_MESSAGE;
31
- ReactJSShim.events = WARNING_MESSAGE;
32
-
33
- var ReactJSErrors = {
34
- wrap: function(module) {
35
- copyProperties(ReactJSShim, module);
36
- return ReactJSShim;
37
- }
38
- };
39
-
40
- module.exports = ReactJSErrors;
package/lib/$.js DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * Copyright 2013 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 $
17
- * @typechecks
18
- */
19
-
20
- var ge = require("./ge");
21
- var ex = require("./ex");
22
-
23
- /**
24
- * Find a node by ID.
25
- *
26
- * If your application code depends on the existence of the element, use $,
27
- * which will throw if the element doesn't exist.
28
- *
29
- * If you're not sure whether or not the element exists, use ge instead, and
30
- * manually check for the element's existence in your application code.
31
- *
32
- * @param {string|DOMDocument|DOMElement|DOMTextNode|Comment} id
33
- * @return {DOMDocument|DOMElement|DOMTextNode|Comment}
34
- */
35
- function $(id) {
36
- var element = ge(id);
37
- if (!element) {
38
- throw new Error(ex(
39
- 'Tried to get element with id of "%s" but it is not present on the page.',
40
- id
41
- ));
42
- }
43
- return element;
44
- }
45
-
46
- module.exports = $;
@@ -1,91 +0,0 @@
1
- /**
2
- * Copyright 2013 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 CallbackRegistry
17
- * @typechecks static-only
18
- */
19
-
20
- "use strict";
21
-
22
- var listenerBank = {};
23
-
24
- /**
25
- * Stores "listeners" by `registrationName`/`id`. There should be at most one
26
- * "listener" per `registrationName`/`id` in the `listenerBank`.
27
- *
28
- * Access listeners via `listenerBank[registrationName][id]`.
29
- *
30
- * @class CallbackRegistry
31
- * @internal
32
- */
33
- var CallbackRegistry = {
34
-
35
- /**
36
- * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
37
- *
38
- * @param {string} id ID of the DOM element.
39
- * @param {string} registrationName Name of listener (e.g. `onClick`).
40
- * @param {?function} listener The callback to store.
41
- */
42
- putListener: function(id, registrationName, listener) {
43
- var bankForRegistrationName =
44
- listenerBank[registrationName] || (listenerBank[registrationName] = {});
45
- bankForRegistrationName[id] = listener;
46
- },
47
-
48
- /**
49
- * @param {string} id ID of the DOM element.
50
- * @param {string} registrationName Name of listener (e.g. `onClick`).
51
- * @return {?function} The stored callback.
52
- */
53
- getListener: function(id, registrationName) {
54
- var bankForRegistrationName = listenerBank[registrationName];
55
- return bankForRegistrationName && bankForRegistrationName[id];
56
- },
57
-
58
- /**
59
- * Deletes a listener from the registration bank.
60
- *
61
- * @param {string} id ID of the DOM element.
62
- * @param {string} registrationName Name of listener (e.g. `onClick`).
63
- */
64
- deleteListener: function(id, registrationName) {
65
- var bankForRegistrationName = listenerBank[registrationName];
66
- if (bankForRegistrationName) {
67
- delete bankForRegistrationName[id];
68
- }
69
- },
70
-
71
- /**
72
- * Deletes all listeners for the DOM element with the supplied ID.
73
- *
74
- * @param {string} id ID of the DOM element.
75
- */
76
- deleteAllListeners: function(id) {
77
- for (var registrationName in listenerBank) {
78
- delete listenerBank[registrationName][id];
79
- }
80
- },
81
-
82
- /**
83
- * This is needed for tests only. Do not use!
84
- */
85
- __purge: function() {
86
- listenerBank = {};
87
- }
88
-
89
- };
90
-
91
- module.exports = CallbackRegistry;
@@ -1,68 +0,0 @@
1
- /**
2
- * Copyright 2013 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 LinkedValueMixin
17
- * @typechecks static-only
18
- */
19
-
20
- "use strict";
21
-
22
- var invariant = require("./invariant");
23
-
24
- /**
25
- * Provide a linked `value` attribute for controlled forms. You should not use
26
- * this outside of the ReactDOM controlled form components.
27
- */
28
- var LinkedValueMixin = {
29
- _assertLink: function() {
30
- ("production" !== process.env.NODE_ENV ? invariant(
31
- this.props.value == null && this.props.onChange == null,
32
- 'Cannot provide a valueLink and a value or onChange event. If you ' +
33
- 'want to use value or onChange, you probably don\'t want to use ' +
34
- 'valueLink'
35
- ) : invariant(this.props.value == null && this.props.onChange == null));
36
- },
37
-
38
- /**
39
- * @return {*} current value of the input either from value prop or link.
40
- */
41
- getValue: function() {
42
- if (this.props.valueLink) {
43
- this._assertLink();
44
- return this.props.valueLink.value;
45
- }
46
- return this.props.value;
47
- },
48
-
49
- /**
50
- * @return {function} change callback either from onChange prop or link.
51
- */
52
- getOnChange: function() {
53
- if (this.props.valueLink) {
54
- this._assertLink();
55
- return this._handleLinkedValueChange;
56
- }
57
- return this.props.onChange;
58
- },
59
-
60
- /**
61
- * @param {SyntheticEvent} e change event to handle
62
- */
63
- _handleLinkedValueChange: function(e) {
64
- this.props.valueLink.requestChange(e.target.value);
65
- }
66
- };
67
-
68
- module.exports = LinkedValueMixin;
package/lib/ex.js DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * Copyright 2013 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 ex
17
- * @typechecks
18
- * @nostacktrace
19
- */
20
-
21
- /**
22
- * This function transforms error message with arguments into plain text error
23
- * message, so that it can be passed to window.onerror without losing anything.
24
- * It can then be transformed back by `erx()` function.
25
- *
26
- * Usage:
27
- * throw new Error(ex('Error %s from %s', errorCode, userID));
28
- *
29
- * @param {string} errorMessage
30
- */
31
-
32
- var ex = function(errorMessage/*, arg1, arg2, ...*/) {
33
- var args = Array.prototype.slice.call(arguments).map(function(arg) {
34
- return String(arg);
35
- });
36
- var expectedLength = errorMessage.split('%s').length - 1;
37
-
38
- if (expectedLength !== args.length - 1) {
39
- // something wrong with the formatting string
40
- return ex('ex args number mismatch: %s', JSON.stringify(args));
41
- }
42
-
43
- return ex._prefix + JSON.stringify(args) + ex._suffix;
44
- };
45
-
46
- ex._prefix = '<![EX[';
47
- ex._suffix = ']]>';
48
-
49
- module.exports = ex;
@@ -1,45 +0,0 @@
1
- /**
2
- * Copyright 2013 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 filterAttributes
17
- * @typechecks static-only
18
- */
19
-
20
- /*jslint evil: true */
21
-
22
- 'use strict';
23
-
24
- /**
25
- * Like filter(), but for a DOM nodes attributes. Returns an array of
26
- * the filter DOMAttribute objects. Does some perf related this like
27
- * caching attributes.length.
28
- *
29
- * @param {DOMElement} node Node whose attributes you want to filter
30
- * @return {array} array of DOM attribute objects.
31
- */
32
- function filterAttributes(node, func, context) {
33
- var attributes = node.attributes;
34
- var numAttributes = attributes.length;
35
- var accumulator = [];
36
- for (var i = 0; i < numAttributes; i++) {
37
- var attr = attributes.item(i);
38
- if (func.call(context, attr)) {
39
- accumulator.push(attr);
40
- }
41
- }
42
- return accumulator;
43
- }
44
-
45
- module.exports = filterAttributes;
package/lib/ge.js DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- * Copyright 2013 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 ge
17
- */
18
-
19
- /**
20
- * Find a node by ID. Optionally search a sub-tree outside of the document
21
- *
22
- * Use ge if you're not sure whether or not the element exists. You can test
23
- * for existence yourself in your application code.
24
- *
25
- * If your application code depends on the existence of the element, use $
26
- * instead, which will throw in DEV if the element doesn't exist.
27
- */
28
- function ge(arg, root, tag) {
29
- return typeof arg != 'string' ? arg :
30
- !root ? document.getElementById(arg) :
31
- _geFromSubtree(arg, root, tag);
32
- }
33
-
34
- function _geFromSubtree(id, root, tag) {
35
- var elem, children, ii;
36
-
37
- if (_getNodeID(root) == id) {
38
- return root;
39
- } else if (root.getElementsByTagName) {
40
- // All Elements implement this, which does an iterative DFS, which is
41
- // faster than recursion and doesn't run into stack depth issues.
42
- children = root.getElementsByTagName(tag || '*');
43
- for (ii = 0; ii < children.length; ii++) {
44
- if (_getNodeID(children[ii]) == id) {
45
- return children[ii];
46
- }
47
- }
48
- } else {
49
- // DocumentFragment does not implement getElementsByTagName, so
50
- // recurse over its children. Its children must be Elements, so
51
- // each child will use the getElementsByTagName case instead.
52
- children = root.childNodes;
53
- for (ii = 0; ii < children.length; ii++) {
54
- elem = _geFromSubtree(id, children[ii]);
55
- if (elem) {
56
- return elem;
57
- }
58
- }
59
- }
60
-
61
- return null;
62
- }
63
-
64
- /**
65
- * Return the ID value for a given node. This allows us to avoid issues
66
- * with forms that contain inputs with name="id".
67
- *
68
- * @return string (null if attribute not set)
69
- */
70
- function _getNodeID(node) {
71
- // #document and #document-fragment do not have getAttributeNode.
72
- var id = node.getAttributeNode && node.getAttributeNode('id');
73
- return id ? id.value : null;
74
- }
75
-
76
- module.exports = ge;