react 0.12.2 → 0.13.0-beta.2
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.
- package/dist/JSXTransformer.js +986 -511
- package/dist/react-with-addons.js +6076 -4560
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +5386 -4170
- package/dist/react.min.js +6 -7
- package/lib/AutoFocusMixin.js +2 -2
- package/lib/BeforeInputEventPlugin.js +388 -115
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +2 -2
- package/lib/CSSPropertyOperations.js +58 -11
- package/lib/CallbackQueue.js +3 -3
- package/lib/ChangeEventPlugin.js +4 -4
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +10 -47
- package/lib/DOMProperty.js +2 -2
- package/lib/DOMPropertyOperations.js +11 -16
- package/lib/Danger.js +8 -7
- package/lib/DefaultEventPluginOrder.js +3 -4
- package/lib/EnterLeaveEventPlugin.js +2 -2
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +1 -1
- package/lib/EventPluginHub.js +10 -8
- package/lib/EventPluginRegistry.js +2 -2
- package/lib/EventPluginUtils.js +4 -4
- package/lib/EventPropagators.js +2 -2
- package/lib/ExecutionEnvironment.js +3 -4
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +23 -10
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/LocalEventTrapMixin.js +10 -3
- package/lib/MobileSafariClickEventPlugin.js +2 -2
- package/lib/Object.assign.js +4 -2
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +19 -58
- package/lib/ReactBrowserComponentMixin.js +4 -14
- package/lib/ReactBrowserEventEmitter.js +6 -8
- package/lib/ReactCSSTransitionGroup.js +5 -2
- package/lib/ReactCSSTransitionGroupChild.js +20 -7
- package/lib/ReactChildReconciler.js +125 -0
- package/lib/ReactChildren.js +13 -10
- package/lib/ReactClass.js +918 -0
- package/lib/ReactComponent.js +98 -406
- package/lib/ReactComponentBrowserEnvironment.js +11 -84
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +574 -1140
- package/lib/ReactContext.js +17 -3
- package/lib/ReactCurrentOwner.js +2 -2
- package/lib/ReactDOM.js +4 -9
- package/lib/ReactDOMButton.js +6 -7
- package/lib/ReactDOMComponent.js +123 -105
- package/lib/ReactDOMForm.js +6 -7
- package/lib/ReactDOMIDOperations.js +59 -77
- package/lib/ReactDOMIframe.js +43 -0
- package/lib/ReactDOMImg.js +5 -7
- package/lib/ReactDOMInput.js +6 -7
- package/lib/ReactDOMOption.js +6 -7
- package/lib/ReactDOMSelect.js +58 -66
- package/lib/ReactDOMSelection.js +7 -3
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
- package/lib/ReactDOMTextarea.js +6 -7
- package/lib/ReactDefaultBatchingStrategy.js +5 -5
- package/lib/ReactDefaultInjection.js +39 -9
- package/lib/ReactDefaultPerf.js +17 -8
- package/lib/ReactDefaultPerfAnalysis.js +2 -2
- package/lib/ReactElement.js +23 -15
- package/lib/ReactElementValidator.js +206 -89
- package/lib/ReactEmptyComponent.js +33 -15
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +4 -5
- package/lib/ReactFragment.js +172 -0
- package/lib/ReactInjection.js +8 -6
- package/lib/ReactInputSelection.js +4 -5
- package/lib/ReactInstanceHandles.js +4 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLifeCycle.js +35 -0
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +2 -2
- package/lib/ReactMount.js +264 -71
- package/lib/ReactMultiChild.js +50 -48
- package/lib/ReactMultiChildUpdateTypes.js +2 -2
- package/lib/ReactNativeComponent.js +59 -25
- package/lib/ReactOwner.js +5 -49
- package/lib/ReactPerf.js +22 -2
- package/lib/ReactPropTransferer.js +3 -58
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +2 -2
- package/lib/ReactPropTypes.js +17 -25
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +2 -2
- package/lib/ReactReconciler.js +121 -0
- package/lib/ReactRef.js +69 -0
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +6 -4
- package/lib/ReactServerRenderingTransaction.js +2 -2
- package/lib/ReactStateSetters.js +2 -2
- package/lib/ReactTestUtils.js +113 -27
- package/lib/ReactTransitionChildMapping.js +8 -4
- package/lib/ReactTransitionEvents.js +2 -2
- package/lib/ReactTransitionGroup.js +53 -12
- package/lib/ReactUpdateQueue.js +295 -0
- package/lib/ReactUpdates.js +54 -62
- package/lib/ReactWithAddons.js +4 -2
- package/lib/SVGDOMPropertyConfig.js +2 -2
- package/lib/SelectEventPlugin.js +4 -4
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +4 -4
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -2
- package/lib/SyntheticEvent.js +12 -4
- package/lib/SyntheticFocusEvent.js +2 -2
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -2
- package/lib/SyntheticMouseEvent.js +3 -5
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +2 -2
- package/lib/Transaction.js +4 -4
- package/lib/ViewportMetrics.js +3 -6
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +1 -1
- package/lib/camelizeStyleName.js +1 -1
- package/lib/cloneWithProps.js +4 -4
- package/lib/containsNode.js +1 -1
- package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
- package/lib/createFullPageComponent.js +4 -4
- package/lib/createNodesFromMarkup.js +4 -4
- package/lib/cx.js +1 -1
- package/lib/dangerousStyleValue.js +2 -2
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +1 -1
- package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +12 -23
- package/lib/focusNode.js +1 -1
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +2 -2
- package/lib/getEventModifierState.js +2 -2
- package/lib/getEventTarget.js +2 -2
- package/lib/getIteratorFn.js +42 -0
- package/lib/getMarkupWrap.js +1 -1
- package/lib/getNodeForCharacterOffset.js +3 -3
- package/lib/getReactRootElementInContainer.js +2 -2
- package/lib/getTextContentAccessor.js +2 -2
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +1 -1
- package/lib/hyphenateStyleName.js +1 -1
- package/lib/instantiateReactComponent.js +90 -68
- package/lib/invariant.js +1 -1
- package/lib/isEventSupported.js +2 -2
- package/lib/isNode.js +4 -5
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +2 -2
- package/lib/keyOf.js +1 -1
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +5 -6
- package/lib/onlyChild.js +2 -2
- package/lib/performance.js +1 -1
- package/lib/performanceNow.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +26 -0
- package/lib/setInnerHTML.js +13 -2
- package/lib/setTextContent.js +40 -0
- package/lib/shallowEqual.js +2 -2
- package/lib/shouldUpdateReactComponent.js +71 -7
- package/lib/toArray.js +2 -2
- package/lib/traverseAllChildren.js +114 -56
- package/lib/update.js +2 -2
- package/lib/warning.js +20 -2
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/copyProperties.js +0 -54
- package/lib/deprecated.js +0 -47
- package/lib/merge.js +0 -34
- package/lib/mergeInto.js +0 -24
- package/lib/monitorCodeUse.js +0 -30
package/lib/ReactDOMForm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,17 +9,15 @@
|
|
|
9
9
|
* @providesModule ReactDOMForm
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var EventConstants = require("./EventConstants");
|
|
15
15
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
16
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
17
|
-
var
|
|
17
|
+
var ReactClass = require("./ReactClass");
|
|
18
18
|
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactDOM = require("./ReactDOM");
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
20
|
+
var form = ReactElement.createFactory('form');
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
|
|
@@ -27,8 +25,9 @@ var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
|
27
25
|
* do to accomplish this, but the most reliable is to make <form> a
|
|
28
26
|
* composite component and use `componentDidMount` to attach the event handlers.
|
|
29
27
|
*/
|
|
30
|
-
var ReactDOMForm =
|
|
28
|
+
var ReactDOMForm = ReactClass.createClass({
|
|
31
29
|
displayName: 'ReactDOMForm',
|
|
30
|
+
tagName: 'FORM',
|
|
32
31
|
|
|
33
32
|
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
34
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/*jslint evil: true */
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
'use strict';
|
|
16
16
|
|
|
17
17
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
18
18
|
var DOMChildrenOperations = require("./DOMChildrenOperations");
|
|
@@ -37,7 +37,7 @@ var INVALID_PROPERTY_ERRORS = {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Operations used to process updates to DOM nodes. This is made injectable via
|
|
40
|
-
* `
|
|
40
|
+
* `ReactDOMComponent.BackendIDOperations`.
|
|
41
41
|
*/
|
|
42
42
|
var ReactDOMIDOperations = {
|
|
43
43
|
|
|
@@ -50,27 +50,23 @@ var ReactDOMIDOperations = {
|
|
|
50
50
|
* @param {*} value New value of the property.
|
|
51
51
|
* @internal
|
|
52
52
|
*/
|
|
53
|
-
updatePropertyByID:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
69
|
-
} else {
|
|
70
|
-
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
71
|
-
}
|
|
53
|
+
updatePropertyByID: function(id, name, value) {
|
|
54
|
+
var node = ReactMount.getNode(id);
|
|
55
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
56
|
+
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
57
|
+
'updatePropertyByID(...): %s',
|
|
58
|
+
INVALID_PROPERTY_ERRORS[name]
|
|
59
|
+
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
60
|
+
|
|
61
|
+
// If we're updating to null or undefined, we should remove the property
|
|
62
|
+
// from the DOM node instead of inadvertantly setting to a string. This
|
|
63
|
+
// brings us in line with the same behavior we have on initial render.
|
|
64
|
+
if (value != null) {
|
|
65
|
+
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
66
|
+
} else {
|
|
67
|
+
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
72
68
|
}
|
|
73
|
-
|
|
69
|
+
},
|
|
74
70
|
|
|
75
71
|
/**
|
|
76
72
|
* Updates a DOM node to remove a property. This should only be used to remove
|
|
@@ -80,19 +76,15 @@ var ReactDOMIDOperations = {
|
|
|
80
76
|
* @param {string} name A property name to remove, see `DOMProperty`.
|
|
81
77
|
* @internal
|
|
82
78
|
*/
|
|
83
|
-
deletePropertyByID:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
93
|
-
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
94
|
-
}
|
|
95
|
-
),
|
|
79
|
+
deletePropertyByID: function(id, name, value) {
|
|
80
|
+
var node = ReactMount.getNode(id);
|
|
81
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
82
|
+
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
83
|
+
'updatePropertyByID(...): %s',
|
|
84
|
+
INVALID_PROPERTY_ERRORS[name]
|
|
85
|
+
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
86
|
+
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
87
|
+
},
|
|
96
88
|
|
|
97
89
|
/**
|
|
98
90
|
* Updates a DOM node with new style values. If a value is specified as '',
|
|
@@ -102,14 +94,10 @@ var ReactDOMIDOperations = {
|
|
|
102
94
|
* @param {object} styles Mapping from styles to values.
|
|
103
95
|
* @internal
|
|
104
96
|
*/
|
|
105
|
-
updateStylesByID:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var node = ReactMount.getNode(id);
|
|
110
|
-
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
111
|
-
}
|
|
112
|
-
),
|
|
97
|
+
updateStylesByID: function(id, styles) {
|
|
98
|
+
var node = ReactMount.getNode(id);
|
|
99
|
+
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
100
|
+
},
|
|
113
101
|
|
|
114
102
|
/**
|
|
115
103
|
* Updates a DOM node's innerHTML.
|
|
@@ -118,14 +106,10 @@ var ReactDOMIDOperations = {
|
|
|
118
106
|
* @param {string} html An HTML string.
|
|
119
107
|
* @internal
|
|
120
108
|
*/
|
|
121
|
-
updateInnerHTMLByID:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var node = ReactMount.getNode(id);
|
|
126
|
-
setInnerHTML(node, html);
|
|
127
|
-
}
|
|
128
|
-
),
|
|
109
|
+
updateInnerHTMLByID: function(id, html) {
|
|
110
|
+
var node = ReactMount.getNode(id);
|
|
111
|
+
setInnerHTML(node, html);
|
|
112
|
+
},
|
|
129
113
|
|
|
130
114
|
/**
|
|
131
115
|
* Updates a DOM node's text content set by `props.content`.
|
|
@@ -134,14 +118,10 @@ var ReactDOMIDOperations = {
|
|
|
134
118
|
* @param {string} content Text content.
|
|
135
119
|
* @internal
|
|
136
120
|
*/
|
|
137
|
-
updateTextContentByID:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var node = ReactMount.getNode(id);
|
|
142
|
-
DOMChildrenOperations.updateTextContent(node, content);
|
|
143
|
-
}
|
|
144
|
-
),
|
|
121
|
+
updateTextContentByID: function(id, content) {
|
|
122
|
+
var node = ReactMount.getNode(id);
|
|
123
|
+
DOMChildrenOperations.updateTextContent(node, content);
|
|
124
|
+
},
|
|
145
125
|
|
|
146
126
|
/**
|
|
147
127
|
* Replaces a DOM node that exists in the document with markup.
|
|
@@ -151,14 +131,10 @@ var ReactDOMIDOperations = {
|
|
|
151
131
|
* @internal
|
|
152
132
|
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
|
|
153
133
|
*/
|
|
154
|
-
dangerouslyReplaceNodeWithMarkupByID:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var node = ReactMount.getNode(id);
|
|
159
|
-
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
|
160
|
-
}
|
|
161
|
-
),
|
|
134
|
+
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
|
|
135
|
+
var node = ReactMount.getNode(id);
|
|
136
|
+
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
|
137
|
+
},
|
|
162
138
|
|
|
163
139
|
/**
|
|
164
140
|
* Updates a component's children by processing a series of updates.
|
|
@@ -167,16 +143,22 @@ var ReactDOMIDOperations = {
|
|
|
167
143
|
* @param {array<string>} markup List of markup strings.
|
|
168
144
|
* @internal
|
|
169
145
|
*/
|
|
170
|
-
dangerouslyProcessChildrenUpdates:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function(updates, markup) {
|
|
174
|
-
for (var i = 0; i < updates.length; i++) {
|
|
175
|
-
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
|
176
|
-
}
|
|
177
|
-
DOMChildrenOperations.processUpdates(updates, markup);
|
|
146
|
+
dangerouslyProcessChildrenUpdates: function(updates, markup) {
|
|
147
|
+
for (var i = 0; i < updates.length; i++) {
|
|
148
|
+
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
|
178
149
|
}
|
|
179
|
-
|
|
150
|
+
DOMChildrenOperations.processUpdates(updates, markup);
|
|
151
|
+
}
|
|
180
152
|
};
|
|
181
153
|
|
|
154
|
+
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
|
|
155
|
+
updatePropertyByID: 'updatePropertyByID',
|
|
156
|
+
deletePropertyByID: 'deletePropertyByID',
|
|
157
|
+
updateStylesByID: 'updateStylesByID',
|
|
158
|
+
updateInnerHTMLByID: 'updateInnerHTMLByID',
|
|
159
|
+
updateTextContentByID: 'updateTextContentByID',
|
|
160
|
+
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
|
|
161
|
+
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
|
|
162
|
+
});
|
|
163
|
+
|
|
182
164
|
module.exports = ReactDOMIDOperations;
|
|
@@ -0,0 +1,43 @@
|
|
|
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;
|
package/lib/ReactDOMImg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,17 +9,15 @@
|
|
|
9
9
|
* @providesModule ReactDOMImg
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var EventConstants = require("./EventConstants");
|
|
15
15
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
16
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
17
|
-
var
|
|
17
|
+
var ReactClass = require("./ReactClass");
|
|
18
18
|
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactDOM = require("./ReactDOM");
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
var img = ReactElement.createFactory(ReactDOM.img.type);
|
|
20
|
+
var img = ReactElement.createFactory('img');
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
|
|
@@ -27,7 +25,7 @@ var img = ReactElement.createFactory(ReactDOM.img.type);
|
|
|
27
25
|
* to accomplish this, but the most reliable is to make <img> a composite
|
|
28
26
|
* component and use `componentDidMount` to attach the event handlers.
|
|
29
27
|
*/
|
|
30
|
-
var ReactDOMImg =
|
|
28
|
+
var ReactDOMImg = ReactClass.createClass({
|
|
31
29
|
displayName: 'ReactDOMImg',
|
|
32
30
|
tagName: 'IMG',
|
|
33
31
|
|
package/lib/ReactDOMInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,23 +9,21 @@
|
|
|
9
9
|
* @providesModule ReactDOMInput
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
15
15
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
16
16
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
17
17
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
18
|
-
var
|
|
18
|
+
var ReactClass = require("./ReactClass");
|
|
19
19
|
var ReactElement = require("./ReactElement");
|
|
20
|
-
var ReactDOM = require("./ReactDOM");
|
|
21
20
|
var ReactMount = require("./ReactMount");
|
|
22
21
|
var ReactUpdates = require("./ReactUpdates");
|
|
23
22
|
|
|
24
23
|
var assign = require("./Object.assign");
|
|
25
24
|
var invariant = require("./invariant");
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
var input = ReactElement.createFactory(ReactDOM.input.type);
|
|
26
|
+
var input = ReactElement.createFactory('input');
|
|
29
27
|
|
|
30
28
|
var instancesByReactID = {};
|
|
31
29
|
|
|
@@ -52,8 +50,9 @@ function forceUpdateIfMounted() {
|
|
|
52
50
|
*
|
|
53
51
|
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
|
|
54
52
|
*/
|
|
55
|
-
var ReactDOMInput =
|
|
53
|
+
var ReactDOMInput = ReactClass.createClass({
|
|
56
54
|
displayName: 'ReactDOMInput',
|
|
55
|
+
tagName: 'INPUT',
|
|
57
56
|
|
|
58
57
|
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
59
58
|
|
package/lib/ReactDOMOption.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,23 +9,22 @@
|
|
|
9
9
|
* @providesModule ReactDOMOption
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
15
|
-
var
|
|
15
|
+
var ReactClass = require("./ReactClass");
|
|
16
16
|
var ReactElement = require("./ReactElement");
|
|
17
|
-
var ReactDOM = require("./ReactDOM");
|
|
18
17
|
|
|
19
18
|
var warning = require("./warning");
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
var option = ReactElement.createFactory(ReactDOM.option.type);
|
|
20
|
+
var option = ReactElement.createFactory('option');
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Implements an <option> native component that warns when `selected` is set.
|
|
26
24
|
*/
|
|
27
|
-
var ReactDOMOption =
|
|
25
|
+
var ReactDOMOption = ReactClass.createClass({
|
|
28
26
|
displayName: 'ReactDOMOption',
|
|
27
|
+
tagName: 'OPTION',
|
|
29
28
|
|
|
30
29
|
mixins: [ReactBrowserComponentMixin],
|
|
31
30
|
|
package/lib/ReactDOMSelect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, 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,26 +9,27 @@
|
|
|
9
9
|
* @providesModule ReactDOMSelect
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
15
15
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
16
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
17
|
-
var
|
|
17
|
+
var ReactClass = require("./ReactClass");
|
|
18
18
|
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactDOM = require("./ReactDOM");
|
|
20
19
|
var ReactUpdates = require("./ReactUpdates");
|
|
21
20
|
|
|
22
21
|
var assign = require("./Object.assign");
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
var select = ReactElement.createFactory(ReactDOM.select.type);
|
|
23
|
+
var select = ReactElement.createFactory('select');
|
|
26
24
|
|
|
27
|
-
function
|
|
25
|
+
function updateOptionsIfPendingUpdateAndMounted() {
|
|
28
26
|
/*jshint validthis:true */
|
|
29
|
-
if (this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
27
|
+
if (this._pendingUpdate) {
|
|
28
|
+
this._pendingUpdate = false;
|
|
29
|
+
var value = LinkedValueUtils.getValue(this);
|
|
30
|
+
if (value != null && this.isMounted()) {
|
|
31
|
+
updateOptions(this, value);
|
|
32
|
+
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -38,7 +39,7 @@ function updateWithPendingValueIfMounted() {
|
|
|
38
39
|
*/
|
|
39
40
|
function selectValueType(props, propName, componentName) {
|
|
40
41
|
if (props[propName] == null) {
|
|
41
|
-
return;
|
|
42
|
+
return null;
|
|
42
43
|
}
|
|
43
44
|
if (props.multiple) {
|
|
44
45
|
if (!Array.isArray(props[propName])) {
|
|
@@ -58,40 +59,43 @@ function selectValueType(props, propName, componentName) {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
|
-
* If `value` is supplied, updates <option> elements on mount and update.
|
|
62
62
|
* @param {ReactComponent} component Instance of ReactDOMSelect
|
|
63
|
-
* @param {
|
|
64
|
-
* controlled components, a string (or with `multiple`, a list of strings).
|
|
63
|
+
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
|
|
65
64
|
* @private
|
|
66
65
|
*/
|
|
67
66
|
function updateOptions(component, propValue) {
|
|
68
|
-
var multiple = component.props.multiple;
|
|
69
|
-
var value = propValue != null ? propValue : component.state.value;
|
|
70
|
-
var options = component.getDOMNode().options;
|
|
71
67
|
var selectedValue, i, l;
|
|
72
|
-
|
|
68
|
+
var options = component.getDOMNode().options;
|
|
69
|
+
|
|
70
|
+
if (component.props.multiple) {
|
|
73
71
|
selectedValue = {};
|
|
74
|
-
for (i = 0, l =
|
|
75
|
-
selectedValue['' +
|
|
72
|
+
for (i = 0, l = propValue.length; i < l; i++) {
|
|
73
|
+
selectedValue['' + propValue[i]] = true;
|
|
74
|
+
}
|
|
75
|
+
for (i = 0, l = options.length; i < l; i++) {
|
|
76
|
+
var selected = selectedValue.hasOwnProperty(options[i].value);
|
|
77
|
+
if (options[i].selected !== selected) {
|
|
78
|
+
options[i].selected = selected;
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
} else {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
options[i].selected = selected;
|
|
82
|
+
// Do not set `select.value` as exact behavior isn't consistent across all
|
|
83
|
+
// browsers for all cases.
|
|
84
|
+
selectedValue = '' + propValue;
|
|
85
|
+
for (i = 0, l = options.length; i < l; i++) {
|
|
86
|
+
if (options[i].value === selectedValue) {
|
|
87
|
+
options[i].selected = true;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
87
90
|
}
|
|
91
|
+
options[0].selected = true;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
96
|
* Implements a <select> native component that allows optionally setting the
|
|
93
97
|
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
|
|
94
|
-
*
|
|
98
|
+
* stringable. If `multiple` is true, the prop must be an array of stringables.
|
|
95
99
|
*
|
|
96
100
|
* If `value` is not supplied (or null/undefined), user actions that change the
|
|
97
101
|
* selected option will trigger updates to the rendered options.
|
|
@@ -103,8 +107,9 @@ function updateOptions(component, propValue) {
|
|
|
103
107
|
* If `defaultValue` is provided, any options with the supplied values will be
|
|
104
108
|
* selected.
|
|
105
109
|
*/
|
|
106
|
-
var ReactDOMSelect =
|
|
110
|
+
var ReactDOMSelect = ReactClass.createClass({
|
|
107
111
|
displayName: 'ReactDOMSelect',
|
|
112
|
+
tagName: 'SELECT',
|
|
108
113
|
|
|
109
114
|
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
110
115
|
|
|
@@ -113,22 +118,6 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
|
|
|
113
118
|
value: selectValueType
|
|
114
119
|
},
|
|
115
120
|
|
|
116
|
-
getInitialState: function() {
|
|
117
|
-
return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
componentWillMount: function() {
|
|
121
|
-
this._pendingValue = null;
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
componentWillReceiveProps: function(nextProps) {
|
|
125
|
-
if (!this.props.multiple && nextProps.multiple) {
|
|
126
|
-
this.setState({value: [this.state.value]});
|
|
127
|
-
} else if (this.props.multiple && !nextProps.multiple) {
|
|
128
|
-
this.setState({value: this.state.value[0]});
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
121
|
render: function() {
|
|
133
122
|
// Clone `this.props` so we don't mutate the input.
|
|
134
123
|
var props = assign({}, this.props);
|
|
@@ -139,16 +128,32 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
|
|
|
139
128
|
return select(props, this.props.children);
|
|
140
129
|
},
|
|
141
130
|
|
|
131
|
+
componentWillMount: function() {
|
|
132
|
+
this._pendingUpdate = false;
|
|
133
|
+
},
|
|
134
|
+
|
|
142
135
|
componentDidMount: function() {
|
|
143
|
-
|
|
136
|
+
var value = LinkedValueUtils.getValue(this);
|
|
137
|
+
if (value != null) {
|
|
138
|
+
updateOptions(this, value);
|
|
139
|
+
} else if (this.props.defaultValue != null) {
|
|
140
|
+
updateOptions(this, this.props.defaultValue);
|
|
141
|
+
}
|
|
144
142
|
},
|
|
145
143
|
|
|
146
144
|
componentDidUpdate: function(prevProps) {
|
|
147
145
|
var value = LinkedValueUtils.getValue(this);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (value != null || prevMultiple !== multiple) {
|
|
146
|
+
if (value != null) {
|
|
147
|
+
this._pendingUpdate = false;
|
|
151
148
|
updateOptions(this, value);
|
|
149
|
+
} else if (!prevProps.multiple !== !this.props.multiple) {
|
|
150
|
+
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
|
|
151
|
+
if (this.props.defaultValue != null) {
|
|
152
|
+
updateOptions(this, this.props.defaultValue);
|
|
153
|
+
} else {
|
|
154
|
+
// Revert the select back to its default unselected state.
|
|
155
|
+
updateOptions(this, this.props.multiple ? [] : '');
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
158
|
},
|
|
154
159
|
|
|
@@ -159,21 +164,8 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
|
|
|
159
164
|
returnValue = onChange.call(this, event);
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
selectedValue = [];
|
|
165
|
-
var options = event.target.options;
|
|
166
|
-
for (var i = 0, l = options.length; i < l; i++) {
|
|
167
|
-
if (options[i].selected) {
|
|
168
|
-
selectedValue.push(options[i].value);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
selectedValue = event.target.value;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
this._pendingValue = selectedValue;
|
|
176
|
-
ReactUpdates.asap(updateWithPendingValueIfMounted, this);
|
|
167
|
+
this._pendingUpdate = true;
|
|
168
|
+
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
|
|
177
169
|
return returnValue;
|
|
178
170
|
}
|
|
179
171
|
|