react 0.14.0-alpha3 → 0.14.0-beta1

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 (103) hide show
  1. package/README.md +5 -2
  2. package/addons.js +2 -2
  3. package/dist/JSXTransformer.js +69 -70
  4. package/dist/react-with-addons.js +2047 -2078
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +1861 -1904
  7. package/dist/react.min.js +5 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +13 -3
  9. package/lib/ChangeEventPlugin.js +4 -2
  10. package/lib/DOMProperty.js +81 -116
  11. package/lib/DOMPropertyOperations.js +70 -25
  12. package/lib/EnterLeaveEventPlugin.js +3 -3
  13. package/lib/EventPluginHub.js +2 -2
  14. package/lib/EventPluginUtils.js +6 -6
  15. package/lib/HTMLDOMPropertyConfig.js +8 -1
  16. package/lib/LinkedValueUtils.js +45 -33
  17. package/lib/PooledClass.js +12 -0
  18. package/lib/React.js +1 -1
  19. package/lib/ReactCSSTransitionGroupChild.js +8 -0
  20. package/lib/ReactChildren.js +3 -3
  21. package/lib/ReactClass.js +29 -47
  22. package/lib/ReactComponent.js +11 -6
  23. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  24. package/lib/ReactCompositeComponent.js +45 -72
  25. package/lib/ReactDOM.js +1 -0
  26. package/lib/ReactDOMButton.js +15 -26
  27. package/lib/ReactDOMClient.js +9 -4
  28. package/lib/ReactDOMComponent.js +302 -24
  29. package/lib/ReactDOMIDOperations.js +14 -0
  30. package/lib/ReactDOMInput.js +78 -94
  31. package/lib/ReactDOMOption.js +19 -38
  32. package/lib/ReactDOMSelect.js +85 -95
  33. package/lib/ReactDOMTextarea.js +39 -52
  34. package/lib/ReactDefaultInjection.js +0 -47
  35. package/lib/ReactElement.js +18 -79
  36. package/lib/ReactElementValidator.js +29 -98
  37. package/lib/ReactErrorUtils.js +1 -1
  38. package/lib/ReactEventEmitterMixin.js +2 -3
  39. package/lib/ReactEventListener.js +43 -3
  40. package/lib/ReactFragment.js +12 -7
  41. package/lib/ReactInputSelection.js +4 -3
  42. package/lib/ReactInstanceHandles.js +3 -2
  43. package/lib/ReactMount.js +20 -40
  44. package/lib/ReactNativeComponent.js +0 -5
  45. package/lib/ReactNoopUpdateQueue.js +118 -0
  46. package/lib/ReactPropTypes.js +3 -3
  47. package/lib/ReactReconcileTransaction.js +2 -2
  48. package/lib/ReactReconciler.js +8 -10
  49. package/lib/ReactServerBatchingStrategy.js +23 -0
  50. package/lib/ReactServerRendering.js +13 -0
  51. package/lib/ReactServerRenderingTransaction.js +2 -2
  52. package/lib/ReactTestUtils.js +56 -33
  53. package/lib/ReactUpdateQueue.js +51 -26
  54. package/lib/ReactUpdates.js +0 -3
  55. package/lib/ReactWithAddons.js +0 -2
  56. package/lib/SelectEventPlugin.js +6 -7
  57. package/lib/SimpleEventPlugin.js +4 -4
  58. package/lib/SyntheticClipboardEvent.js +2 -2
  59. package/lib/SyntheticCompositionEvent.js +2 -2
  60. package/lib/SyntheticDragEvent.js +2 -2
  61. package/lib/SyntheticEvent.js +6 -5
  62. package/lib/SyntheticFocusEvent.js +2 -2
  63. package/lib/SyntheticInputEvent.js +2 -2
  64. package/lib/SyntheticKeyboardEvent.js +2 -2
  65. package/lib/SyntheticMouseEvent.js +2 -2
  66. package/lib/SyntheticTouchEvent.js +2 -2
  67. package/lib/SyntheticUIEvent.js +2 -2
  68. package/lib/SyntheticWheelEvent.js +2 -2
  69. package/lib/Transaction.js +10 -4
  70. package/lib/cloneWithProps.js +1 -1
  71. package/lib/deprecated.js +47 -0
  72. package/lib/findDOMNode.js +2 -3
  73. package/lib/forEachAccumulated.js +1 -1
  74. package/lib/getEventCharCode.js +1 -1
  75. package/lib/getEventModifierState.js +0 -1
  76. package/lib/getMarkupWrap.js +13 -35
  77. package/lib/instantiateReactComponent.js +13 -9
  78. package/lib/isTextInputElement.js +2 -1
  79. package/lib/joinClasses.js +1 -1
  80. package/lib/setInnerHTML.js +1 -1
  81. package/lib/traverseAllChildren.js +1 -1
  82. package/lib/warning.js +0 -4
  83. package/package.json +1 -1
  84. package/react.js +53 -1
  85. package/addons/CSSTransitionGroup.js +0 -1
  86. package/addons/LinkedStateMixin.js +0 -1
  87. package/addons/Perf.js +0 -1
  88. package/addons/PureRenderMixin.js +0 -1
  89. package/addons/TestUtils.js +0 -1
  90. package/addons/TransitionGroup.js +0 -1
  91. package/addons/batchedUpdates.js +0 -1
  92. package/addons/cloneWithProps.js +0 -1
  93. package/addons/createFragment.js +0 -1
  94. package/addons/renderSubtreeIntoContainer.js +0 -1
  95. package/addons/shallowCompare.js +0 -1
  96. package/addons/update.js +0 -1
  97. package/lib/LocalEventTrapMixin.js +0 -46
  98. package/lib/ReactContext.js +0 -32
  99. package/lib/ReactDOMForm.js +0 -47
  100. package/lib/ReactDOMIframe.js +0 -43
  101. package/lib/ReactDOMImg.js +0 -44
  102. package/lib/ReactLifeCycle.js +0 -35
  103. package/lib/createFullPageComponent.js +0 -51
@@ -26,6 +26,16 @@ assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin,
26
26
  _instantiateReactComponent: instantiateReactComponent
27
27
  });
28
28
 
29
+ function getDeclarationErrorAddendum(owner) {
30
+ if (owner) {
31
+ var name = owner.getName();
32
+ if (name) {
33
+ return ' Check the render method of `' + name + '`.';
34
+ }
35
+ }
36
+ return '';
37
+ }
38
+
29
39
  /**
30
40
  * Check if the type reference is a known internal type. I.e. not a user
31
41
  * provided composite type.
@@ -41,11 +51,10 @@ function isInternalComponentType(type) {
41
51
  * Given a ReactNode, create an instance that will actually be mounted.
42
52
  *
43
53
  * @param {ReactNode} node
44
- * @param {*} parentCompositeType The composite type that resolved this.
45
54
  * @return {object} A new instance of the element's constructor.
46
55
  * @protected
47
56
  */
48
- function instantiateReactComponent(node, parentCompositeType) {
57
+ function instantiateReactComponent(node) {
49
58
  var instance;
50
59
 
51
60
  if (node === null || node === false) {
@@ -54,16 +63,11 @@ function instantiateReactComponent(node, parentCompositeType) {
54
63
 
55
64
  if (typeof node === 'object') {
56
65
  var element = node;
57
- if ('production' !== process.env.NODE_ENV) {
58
- 'production' !== process.env.NODE_ENV ? warning(element && (typeof element.type === 'function' || typeof element.type === 'string'), 'Only functions or strings can be mounted as React components.') : undefined;
59
- }
66
+ !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
60
67
 
61
68
  // Special case string values
62
- if (parentCompositeType === element.type && typeof element.type === 'string') {
63
- // Avoid recursion if the wrapper renders itself.
69
+ if (typeof element.type === 'string') {
64
70
  instance = ReactNativeComponent.createInternalComponent(element);
65
- // All native components are currently wrapped in a composite so we're
66
- // safe to assume that this is what we should instantiate.
67
71
  } else if (isInternalComponentType(element.type)) {
68
72
  // This is temporarily available for custom components that are not string
69
73
  // represenations. I.e. ART. Once those are updated to use the string
@@ -33,7 +33,8 @@ var supportedInputTypes = {
33
33
  };
34
34
 
35
35
  function isTextInputElement(elem) {
36
- return elem && (elem.nodeName === 'INPUT' && supportedInputTypes[elem.type] || elem.nodeName === 'TEXTAREA');
36
+ var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
37
+ return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
37
38
  }
38
39
 
39
40
  module.exports = isTextInputElement;
@@ -16,7 +16,7 @@
16
16
  * Combines multiple className strings into one.
17
17
  * http://jsperf.com/joinclasses-args-vs-array
18
18
  *
19
- * @param {...?string} classes
19
+ * @param {...?string} className
20
20
  * @return {string}
21
21
  */
22
22
  function joinClasses(className /*, ... */) {
@@ -70,7 +70,7 @@ if (ExecutionEnvironment.canUseDOM) {
70
70
  // in hopes that this is preserved even if "\uFEFF" is transformed to
71
71
  // the actual Unicode character (by Babel, for example).
72
72
  // https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
73
- node.innerHTML = String.fromCharCode(65279) + html;
73
+ node.innerHTML = String.fromCharCode(0xFEFF) + html;
74
74
 
75
75
  // deleteData leaves an empty `TextNode` which offsets the index of all
76
76
  // children. Definitely want to avoid this.
@@ -60,7 +60,7 @@ function getComponentKey(component, index) {
60
60
  /**
61
61
  * Escape a component key so that it is safe to use in a reactid.
62
62
  *
63
- * @param {*} key Component key to be escaped.
63
+ * @param {*} text Component key to be escaped.
64
64
  * @return {string} An escaped string.
65
65
  */
66
66
  function escapeUserProvidedKey(text) {
package/lib/warning.js CHANGED
@@ -32,10 +32,6 @@ if ('production' !== process.env.NODE_ENV) {
32
32
  throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
33
33
  }
34
34
 
35
- if (format.length < 10 || /^[s\W]*$/.test(format)) {
36
- throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format);
37
- }
38
-
39
35
  if (format.indexOf('Failed Composite propType: ') === 0) {
40
36
  return; // Ignore CompositeComponent proptype check.
41
37
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react",
3
3
  "description": "React is a JavaScript library for building user interfaces.",
4
- "version": "0.14.0-alpha3",
4
+ "version": "0.14.0-beta1",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
package/react.js CHANGED
@@ -1 +1,53 @@
1
- module.exports = require('./lib/React');
1
+ 'use strict';
2
+
3
+ var React = require('./lib/React');
4
+
5
+ var assign = require('./lib/Object.assign');
6
+ var deprecated = require('./lib/deprecated');
7
+
8
+ // We want to warn once when any of these methods are used.
9
+ if (process.env.NODE_ENV !== 'production') {
10
+ var deprecations = {
11
+ // ReactDOMClient
12
+ findDOMNode: deprecated(
13
+ 'findDOMNode',
14
+ 'react-dom',
15
+ React,
16
+ React.findDOMNode
17
+ ),
18
+ render: deprecated(
19
+ 'render',
20
+ 'react-dom',
21
+ React,
22
+ React.render
23
+ ),
24
+ unmountComponentAtNode: deprecated(
25
+ 'unmountComponentAtNode',
26
+ 'react-dom',
27
+ React,
28
+ React.unmountComponentAtNode
29
+ ),
30
+ // ReactDOMServer
31
+ renderToString: deprecated(
32
+ 'renderToString',
33
+ 'react-dom/server',
34
+ React,
35
+ React.renderToString
36
+ ),
37
+ renderToStaticMarkup: deprecated(
38
+ 'renderToStaticMarkup',
39
+ 'react-dom/server',
40
+ React,
41
+ React.renderToStaticMarkup
42
+ ),
43
+ };
44
+ // Export a wrapped object. We'll use assign and take advantage of the fact
45
+ // that this will override the original methods in React.
46
+ module.exports = assign(
47
+ {},
48
+ React,
49
+ deprecations
50
+ );
51
+ } else {
52
+ module.exports = React;
53
+ }
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactCSSTransitionGroup');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/LinkedStateMixin');
package/addons/Perf.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactDefaultPerf');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactComponentWithPureRenderMixin');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactTestUtils');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactTransitionGroup');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactUpdates').batchedUpdates;
@@ -1 +0,0 @@
1
- module.exports = require('../lib/cloneWithProps');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/ReactFragment').create;
@@ -1 +0,0 @@
1
- module.exports = require('../lib/renderSubtreeIntoContainer');
@@ -1 +0,0 @@
1
- module.exports = require('../lib/shallowCompare');
package/addons/update.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('../lib/update');
@@ -1,46 +0,0 @@
1
- /**
2
- * Copyright 2014-2015, 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 LocalEventTrapMixin
10
- */
11
-
12
- 'use strict';
13
-
14
- var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
15
-
16
- var accumulateInto = require("./accumulateInto");
17
- var findDOMNode = require("./findDOMNode");
18
- var forEachAccumulated = require("./forEachAccumulated");
19
- var invariant = require("./invariant");
20
-
21
- function remove(event) {
22
- event.remove();
23
- }
24
-
25
- var LocalEventTrapMixin = {
26
- trapBubbledEvent: function (topLevelType, handlerBaseName) {
27
- !this.isMounted() ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined;
28
- // If a component renders to null or if another component fatals and causes
29
- // the state of the tree to be corrupted, `node` here can be null.
30
- var node = findDOMNode(this);
31
- !node ? 'production' !== process.env.NODE_ENV ? invariant(false, 'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined;
32
- var listener = ReactBrowserEventEmitter.trapBubbledEvent(topLevelType, handlerBaseName, node);
33
- this._localEventListeners = accumulateInto(this._localEventListeners, listener);
34
- },
35
-
36
- // trapCapturedEvent would look nearly identical. We don't implement that
37
- // method because it isn't currently needed.
38
-
39
- componentWillUnmount: function () {
40
- if (this._localEventListeners) {
41
- forEachAccumulated(this._localEventListeners, remove);
42
- }
43
- }
44
- };
45
-
46
- module.exports = LocalEventTrapMixin;
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright 2013-2015, 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 ReactContext
10
- */
11
-
12
- 'use strict';
13
-
14
- var emptyObject = require("./emptyObject");
15
-
16
- /**
17
- * Keeps track of the current context.
18
- *
19
- * The context is automatically passed down the component ownership hierarchy
20
- * and is accessible via `this.context` on ReactCompositeComponents.
21
- */
22
- var ReactContext = {
23
-
24
- /**
25
- * @internal
26
- * @type {object}
27
- */
28
- current: emptyObject
29
-
30
- };
31
-
32
- module.exports = ReactContext;
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright 2013-2015, 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 ReactDOMForm
10
- */
11
-
12
- 'use strict';
13
-
14
- var EventConstants = require("./EventConstants");
15
- var LocalEventTrapMixin = require("./LocalEventTrapMixin");
16
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
17
- var ReactClass = require("./ReactClass");
18
- var ReactElement = require("./ReactElement");
19
-
20
- var form = ReactElement.createFactory('form');
21
-
22
- /**
23
- * Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
24
- * to capture it on the <form> element itself. There are lots of hacks we could
25
- * do to accomplish this, but the most reliable is to make <form> a
26
- * composite component and use `componentDidMount` to attach the event handlers.
27
- */
28
- var ReactDOMForm = ReactClass.createClass({
29
- displayName: 'ReactDOMForm',
30
- tagName: 'FORM',
31
-
32
- mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
33
-
34
- render: function () {
35
- // TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
36
- // `jshint` fails to parse JSX so in order for linting to work in the open
37
- // source repo, we need to just use `ReactDOM.form`.
38
- return form(this.props);
39
- },
40
-
41
- componentDidMount: function () {
42
- this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
43
- this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
44
- }
45
- });
46
-
47
- module.exports = ReactDOMForm;
@@ -1,43 +0,0 @@
1
- /**
2
- * Copyright 2013-2015, 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 ReactDOMIframe
10
- */
11
-
12
- 'use strict';
13
-
14
- var EventConstants = require("./EventConstants");
15
- var LocalEventTrapMixin = require("./LocalEventTrapMixin");
16
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
17
- var ReactClass = require("./ReactClass");
18
- var ReactElement = require("./ReactElement");
19
-
20
- var iframe = ReactElement.createFactory('iframe');
21
-
22
- /**
23
- * Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
24
- * capture it on the <iframe> element itself. There are lots of hacks we could
25
- * do to accomplish this, but the most reliable is to make <iframe> a composite
26
- * component and use `componentDidMount` to attach the event handlers.
27
- */
28
- var ReactDOMIframe = ReactClass.createClass({
29
- displayName: 'ReactDOMIframe',
30
- tagName: 'IFRAME',
31
-
32
- mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
33
-
34
- render: function () {
35
- return iframe(this.props);
36
- },
37
-
38
- componentDidMount: function () {
39
- this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
40
- }
41
- });
42
-
43
- module.exports = ReactDOMIframe;
@@ -1,44 +0,0 @@
1
- /**
2
- * Copyright 2013-2015, 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 ReactDOMImg
10
- */
11
-
12
- 'use strict';
13
-
14
- var EventConstants = require("./EventConstants");
15
- var LocalEventTrapMixin = require("./LocalEventTrapMixin");
16
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
17
- var ReactClass = require("./ReactClass");
18
- var ReactElement = require("./ReactElement");
19
-
20
- var img = ReactElement.createFactory('img');
21
-
22
- /**
23
- * Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
24
- * capture it on the <img> element itself. There are lots of hacks we could do
25
- * to accomplish this, but the most reliable is to make <img> a composite
26
- * component and use `componentDidMount` to attach the event handlers.
27
- */
28
- var ReactDOMImg = ReactClass.createClass({
29
- displayName: 'ReactDOMImg',
30
- tagName: 'IMG',
31
-
32
- mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
33
-
34
- render: function () {
35
- return img(this.props);
36
- },
37
-
38
- componentDidMount: function () {
39
- this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
40
- this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
41
- }
42
- });
43
-
44
- module.exports = ReactDOMImg;
@@ -1,35 +0,0 @@
1
- /**
2
- * Copyright 2015, 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 ReactLifeCycle
10
- */
11
-
12
- 'use strict';
13
-
14
- /**
15
- * This module manages the bookkeeping when a component is in the process
16
- * of being mounted or being unmounted. This is used as a way to enforce
17
- * invariants (or warnings) when it is not recommended to call
18
- * setState/forceUpdate.
19
- *
20
- * currentlyMountingInstance: During the construction phase, it is not possible
21
- * to trigger an update since the instance is not fully mounted yet. However, we
22
- * currently allow this as a convenience for mutating the initial state.
23
- *
24
- * currentlyUnmountingInstance: During the unmounting phase, the instance is
25
- * still mounted and can therefore schedule an update. However, this is not
26
- * recommended and probably an error since it's about to be unmounted.
27
- * Therefore we still want to trigger in an error for that case.
28
- */
29
-
30
- var ReactLifeCycle = {
31
- currentlyMountingInstance: null,
32
- currentlyUnmountingInstance: null
33
- };
34
-
35
- module.exports = ReactLifeCycle;