react 0.14.0-alpha2 → 0.14.0-beta3
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/README.md +5 -2
- package/addons.js +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
|
@@ -0,0 +1,177 @@
|
|
|
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 ReactDOMFactories
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactElementValidator = require('./ReactElementValidator');
|
|
17
|
+
|
|
18
|
+
var mapObject = require('fbjs/lib/mapObject');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a factory that creates HTML tag elements.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} tag Tag name (e.g. `div`).
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
function createDOMFactory(tag) {
|
|
27
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
+
return ReactElementValidator.createFactory(tag);
|
|
29
|
+
}
|
|
30
|
+
return ReactElement.createFactory(tag);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
|
|
35
|
+
* This is also accessible via `React.DOM`.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
var ReactDOMFactories = mapObject({
|
|
40
|
+
a: 'a',
|
|
41
|
+
abbr: 'abbr',
|
|
42
|
+
address: 'address',
|
|
43
|
+
area: 'area',
|
|
44
|
+
article: 'article',
|
|
45
|
+
aside: 'aside',
|
|
46
|
+
audio: 'audio',
|
|
47
|
+
b: 'b',
|
|
48
|
+
base: 'base',
|
|
49
|
+
bdi: 'bdi',
|
|
50
|
+
bdo: 'bdo',
|
|
51
|
+
big: 'big',
|
|
52
|
+
blockquote: 'blockquote',
|
|
53
|
+
body: 'body',
|
|
54
|
+
br: 'br',
|
|
55
|
+
button: 'button',
|
|
56
|
+
canvas: 'canvas',
|
|
57
|
+
caption: 'caption',
|
|
58
|
+
cite: 'cite',
|
|
59
|
+
code: 'code',
|
|
60
|
+
col: 'col',
|
|
61
|
+
colgroup: 'colgroup',
|
|
62
|
+
data: 'data',
|
|
63
|
+
datalist: 'datalist',
|
|
64
|
+
dd: 'dd',
|
|
65
|
+
del: 'del',
|
|
66
|
+
details: 'details',
|
|
67
|
+
dfn: 'dfn',
|
|
68
|
+
dialog: 'dialog',
|
|
69
|
+
div: 'div',
|
|
70
|
+
dl: 'dl',
|
|
71
|
+
dt: 'dt',
|
|
72
|
+
em: 'em',
|
|
73
|
+
embed: 'embed',
|
|
74
|
+
fieldset: 'fieldset',
|
|
75
|
+
figcaption: 'figcaption',
|
|
76
|
+
figure: 'figure',
|
|
77
|
+
footer: 'footer',
|
|
78
|
+
form: 'form',
|
|
79
|
+
h1: 'h1',
|
|
80
|
+
h2: 'h2',
|
|
81
|
+
h3: 'h3',
|
|
82
|
+
h4: 'h4',
|
|
83
|
+
h5: 'h5',
|
|
84
|
+
h6: 'h6',
|
|
85
|
+
head: 'head',
|
|
86
|
+
header: 'header',
|
|
87
|
+
hgroup: 'hgroup',
|
|
88
|
+
hr: 'hr',
|
|
89
|
+
html: 'html',
|
|
90
|
+
i: 'i',
|
|
91
|
+
iframe: 'iframe',
|
|
92
|
+
img: 'img',
|
|
93
|
+
input: 'input',
|
|
94
|
+
ins: 'ins',
|
|
95
|
+
kbd: 'kbd',
|
|
96
|
+
keygen: 'keygen',
|
|
97
|
+
label: 'label',
|
|
98
|
+
legend: 'legend',
|
|
99
|
+
li: 'li',
|
|
100
|
+
link: 'link',
|
|
101
|
+
main: 'main',
|
|
102
|
+
map: 'map',
|
|
103
|
+
mark: 'mark',
|
|
104
|
+
menu: 'menu',
|
|
105
|
+
menuitem: 'menuitem',
|
|
106
|
+
meta: 'meta',
|
|
107
|
+
meter: 'meter',
|
|
108
|
+
nav: 'nav',
|
|
109
|
+
noscript: 'noscript',
|
|
110
|
+
object: 'object',
|
|
111
|
+
ol: 'ol',
|
|
112
|
+
optgroup: 'optgroup',
|
|
113
|
+
option: 'option',
|
|
114
|
+
output: 'output',
|
|
115
|
+
p: 'p',
|
|
116
|
+
param: 'param',
|
|
117
|
+
picture: 'picture',
|
|
118
|
+
pre: 'pre',
|
|
119
|
+
progress: 'progress',
|
|
120
|
+
q: 'q',
|
|
121
|
+
rp: 'rp',
|
|
122
|
+
rt: 'rt',
|
|
123
|
+
ruby: 'ruby',
|
|
124
|
+
s: 's',
|
|
125
|
+
samp: 'samp',
|
|
126
|
+
script: 'script',
|
|
127
|
+
section: 'section',
|
|
128
|
+
select: 'select',
|
|
129
|
+
small: 'small',
|
|
130
|
+
source: 'source',
|
|
131
|
+
span: 'span',
|
|
132
|
+
strong: 'strong',
|
|
133
|
+
style: 'style',
|
|
134
|
+
sub: 'sub',
|
|
135
|
+
summary: 'summary',
|
|
136
|
+
sup: 'sup',
|
|
137
|
+
table: 'table',
|
|
138
|
+
tbody: 'tbody',
|
|
139
|
+
td: 'td',
|
|
140
|
+
textarea: 'textarea',
|
|
141
|
+
tfoot: 'tfoot',
|
|
142
|
+
th: 'th',
|
|
143
|
+
thead: 'thead',
|
|
144
|
+
time: 'time',
|
|
145
|
+
title: 'title',
|
|
146
|
+
tr: 'tr',
|
|
147
|
+
track: 'track',
|
|
148
|
+
u: 'u',
|
|
149
|
+
ul: 'ul',
|
|
150
|
+
'var': 'var',
|
|
151
|
+
video: 'video',
|
|
152
|
+
wbr: 'wbr',
|
|
153
|
+
|
|
154
|
+
// SVG
|
|
155
|
+
circle: 'circle',
|
|
156
|
+
clipPath: 'clipPath',
|
|
157
|
+
defs: 'defs',
|
|
158
|
+
ellipse: 'ellipse',
|
|
159
|
+
g: 'g',
|
|
160
|
+
image: 'image',
|
|
161
|
+
line: 'line',
|
|
162
|
+
linearGradient: 'linearGradient',
|
|
163
|
+
mask: 'mask',
|
|
164
|
+
path: 'path',
|
|
165
|
+
pattern: 'pattern',
|
|
166
|
+
polygon: 'polygon',
|
|
167
|
+
polyline: 'polyline',
|
|
168
|
+
radialGradient: 'radialGradient',
|
|
169
|
+
rect: 'rect',
|
|
170
|
+
stop: 'stop',
|
|
171
|
+
svg: 'svg',
|
|
172
|
+
text: 'text',
|
|
173
|
+
tspan: 'tspan'
|
|
174
|
+
|
|
175
|
+
}, createDOMFactory);
|
|
176
|
+
|
|
177
|
+
module.exports = ReactDOMFactories;
|
|
@@ -12,17 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var CSSPropertyOperations = require(
|
|
16
|
-
var DOMChildrenOperations = require(
|
|
17
|
-
var DOMPropertyOperations = require(
|
|
18
|
-
var ReactMount = require(
|
|
19
|
-
var ReactPerf = require(
|
|
15
|
+
var CSSPropertyOperations = require('./CSSPropertyOperations');
|
|
16
|
+
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
17
|
+
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
18
|
+
var ReactMount = require('./ReactMount');
|
|
19
|
+
var ReactPerf = require('./ReactPerf');
|
|
20
20
|
|
|
21
|
-
var invariant = require(
|
|
22
|
-
var setInnerHTML = require("./setInnerHTML");
|
|
21
|
+
var invariant = require('fbjs/lib/invariant');
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
* Errors for properties that should not be updated with `
|
|
24
|
+
* Errors for properties that should not be updated with `updatePropertyByID()`.
|
|
26
25
|
*
|
|
27
26
|
* @type {object}
|
|
28
27
|
* @private
|
|
@@ -49,7 +48,7 @@ var ReactDOMIDOperations = {
|
|
|
49
48
|
*/
|
|
50
49
|
updatePropertyByID: function (id, name, value) {
|
|
51
50
|
var node = ReactMount.getNode(id);
|
|
52
|
-
|
|
51
|
+
!!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
|
|
53
52
|
|
|
54
53
|
// If we're updating to null or undefined, we should remove the property
|
|
55
54
|
// from the DOM node instead of inadvertantly setting to a string. This
|
|
@@ -61,6 +60,20 @@ var ReactDOMIDOperations = {
|
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Updates a DOM node with new property values.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} id ID of the node to update.
|
|
67
|
+
* @param {string} name A valid property name.
|
|
68
|
+
* @param {*} value New value of the property.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
updateAttributeByID: function (id, name, value) {
|
|
72
|
+
var node = ReactMount.getNode(id);
|
|
73
|
+
!!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
|
|
74
|
+
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
|
75
|
+
},
|
|
76
|
+
|
|
64
77
|
/**
|
|
65
78
|
* Updates a DOM node to remove a property. This should only be used to remove
|
|
66
79
|
* DOM properties in `DOMProperty`.
|
|
@@ -71,7 +84,7 @@ var ReactDOMIDOperations = {
|
|
|
71
84
|
*/
|
|
72
85
|
deletePropertyByID: function (id, name, value) {
|
|
73
86
|
var node = ReactMount.getNode(id);
|
|
74
|
-
|
|
87
|
+
!!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
|
|
75
88
|
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
76
89
|
},
|
|
77
90
|
|
|
@@ -88,18 +101,6 @@ var ReactDOMIDOperations = {
|
|
|
88
101
|
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
89
102
|
},
|
|
90
103
|
|
|
91
|
-
/**
|
|
92
|
-
* Updates a DOM node's innerHTML.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} id ID of the node to update.
|
|
95
|
-
* @param {string} html An HTML string.
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
updateInnerHTMLByID: function (id, html) {
|
|
99
|
-
var node = ReactMount.getNode(id);
|
|
100
|
-
setInnerHTML(node, html);
|
|
101
|
-
},
|
|
102
|
-
|
|
103
104
|
/**
|
|
104
105
|
* Updates a DOM node's text content set by `props.content`.
|
|
105
106
|
*
|
|
@@ -144,7 +145,6 @@ ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
|
|
|
144
145
|
updatePropertyByID: 'updatePropertyByID',
|
|
145
146
|
deletePropertyByID: 'deletePropertyByID',
|
|
146
147
|
updateStylesByID: 'updateStylesByID',
|
|
147
|
-
updateInnerHTMLByID: 'updateInnerHTMLByID',
|
|
148
148
|
updateTextContentByID: 'updateTextContentByID',
|
|
149
149
|
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
|
|
150
150
|
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
|
package/lib/ReactDOMInput.js
CHANGED
|
@@ -11,27 +11,20 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var ReactClass = require("./ReactClass");
|
|
19
|
-
var ReactElement = require("./ReactElement");
|
|
20
|
-
var ReactMount = require("./ReactMount");
|
|
21
|
-
var ReactUpdates = require("./ReactUpdates");
|
|
14
|
+
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
15
|
+
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
16
|
+
var ReactMount = require('./ReactMount');
|
|
17
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
22
18
|
|
|
23
|
-
var assign = require(
|
|
24
|
-
var
|
|
25
|
-
var invariant = require("./invariant");
|
|
26
|
-
|
|
27
|
-
var input = ReactElement.createFactory('input');
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
28
21
|
|
|
29
22
|
var instancesByReactID = {};
|
|
30
23
|
|
|
31
24
|
function forceUpdateIfMounted() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
if (this._rootNodeID) {
|
|
26
|
+
// DOM component is still mounted; update
|
|
27
|
+
ReactDOMInput.updateWrapper(this);
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
30
|
|
|
@@ -51,110 +44,101 @@ function forceUpdateIfMounted() {
|
|
|
51
44
|
*
|
|
52
45
|
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
|
|
53
46
|
*/
|
|
54
|
-
var ReactDOMInput =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
47
|
+
var ReactDOMInput = {
|
|
48
|
+
getNativeProps: function (inst, props, context) {
|
|
49
|
+
var value = LinkedValueUtils.getValue(props);
|
|
50
|
+
var checked = LinkedValueUtils.getChecked(props);
|
|
51
|
+
|
|
52
|
+
var nativeProps = assign({}, props, {
|
|
53
|
+
defaultChecked: undefined,
|
|
54
|
+
defaultValue: undefined,
|
|
55
|
+
value: value != null ? value : inst._wrapperState.initialValue,
|
|
56
|
+
checked: checked != null ? checked : inst._wrapperState.initialChecked,
|
|
57
|
+
onChange: inst._wrapperState.onChange
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return nativeProps;
|
|
66
61
|
},
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var props = assign({}, this.props);
|
|
71
|
-
|
|
72
|
-
props.defaultChecked = null;
|
|
73
|
-
props.defaultValue = null;
|
|
63
|
+
mountWrapper: function (inst, props) {
|
|
64
|
+
LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner);
|
|
74
65
|
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
props.onChange = this._handleChange;
|
|
66
|
+
var defaultValue = props.defaultValue;
|
|
67
|
+
inst._wrapperState = {
|
|
68
|
+
initialChecked: props.defaultChecked || false,
|
|
69
|
+
initialValue: defaultValue != null ? defaultValue : null,
|
|
70
|
+
onChange: _handleChange.bind(inst)
|
|
71
|
+
};
|
|
82
72
|
|
|
83
|
-
|
|
73
|
+
instancesByReactID[inst._rootNodeID] = inst;
|
|
84
74
|
},
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
instancesByReactID[id] = this;
|
|
76
|
+
unmountWrapper: function (inst) {
|
|
77
|
+
delete instancesByReactID[inst._rootNodeID];
|
|
89
78
|
},
|
|
90
79
|
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
var id = ReactMount.getID(rootNode);
|
|
94
|
-
delete instancesByReactID[id];
|
|
95
|
-
},
|
|
80
|
+
updateWrapper: function (inst) {
|
|
81
|
+
var props = inst._currentElement.props;
|
|
96
82
|
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
if (
|
|
100
|
-
|
|
83
|
+
// TODO: Shouldn't this be getChecked(props)?
|
|
84
|
+
var checked = props.checked;
|
|
85
|
+
if (checked != null) {
|
|
86
|
+
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'checked', checked || false);
|
|
101
87
|
}
|
|
102
88
|
|
|
103
|
-
var value = LinkedValueUtils.getValue(
|
|
89
|
+
var value = LinkedValueUtils.getValue(props);
|
|
104
90
|
if (value != null) {
|
|
105
91
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
106
92
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
107
|
-
|
|
93
|
+
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
|
|
108
94
|
}
|
|
109
|
-
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function _handleChange(event) {
|
|
99
|
+
var props = this._currentElement.props;
|
|
100
|
+
|
|
101
|
+
var returnValue = LinkedValueUtils.executeOnChange(props, event);
|
|
102
|
+
|
|
103
|
+
// Here we use asap to wait until all updates have propagated, which
|
|
104
|
+
// is important when using controlled components within layers:
|
|
105
|
+
// https://github.com/facebook/react/issues/1698
|
|
106
|
+
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
var name = props.name;
|
|
109
|
+
if (props.type === 'radio' && name != null) {
|
|
110
|
+
var rootNode = ReactMount.getNode(this._rootNodeID);
|
|
111
|
+
var queryRoot = rootNode;
|
|
112
|
+
|
|
113
|
+
while (queryRoot.parentNode) {
|
|
114
|
+
queryRoot = queryRoot.parentNode;
|
|
116
115
|
}
|
|
117
|
-
// Here we use asap to wait until all updates have propagated, which
|
|
118
|
-
// is important when using controlled components within layers:
|
|
119
|
-
// https://github.com/facebook/react/issues/1698
|
|
120
|
-
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
121
|
-
|
|
122
|
-
var name = this.props.name;
|
|
123
|
-
if (this.props.type === 'radio' && name != null) {
|
|
124
|
-
var rootNode = findDOMNode(this);
|
|
125
|
-
var queryRoot = rootNode;
|
|
126
|
-
|
|
127
|
-
while (queryRoot.parentNode) {
|
|
128
|
-
queryRoot = queryRoot.parentNode;
|
|
129
|
-
}
|
|
130
116
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
var otherID = ReactMount.getID(otherNode);
|
|
145
|
-
'production' !== process.env.NODE_ENV ? invariant(otherID, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(otherID);
|
|
146
|
-
var otherInstance = instancesByReactID[otherID];
|
|
147
|
-
'production' !== process.env.NODE_ENV ? invariant(otherInstance, 'ReactDOMInput: Unknown radio button ID %s.', otherID) : invariant(otherInstance);
|
|
148
|
-
// If this is a controlled radio button group, forcing the input that
|
|
149
|
-
// was previously checked to update will cause it to be come re-checked
|
|
150
|
-
// as appropriate.
|
|
151
|
-
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
|
|
117
|
+
// If `rootNode.form` was non-null, then we could try `form.elements`,
|
|
118
|
+
// but that sometimes behaves strangely in IE8. We could also try using
|
|
119
|
+
// `form.getElementsByName`, but that will only return direct children
|
|
120
|
+
// and won't include inputs that use the HTML5 `form=` attribute. Since
|
|
121
|
+
// the input might not even be in a form, let's just use the global
|
|
122
|
+
// `querySelectorAll` to ensure we don't miss anything.
|
|
123
|
+
var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
|
|
124
|
+
|
|
125
|
+
for (var i = 0; i < group.length; i++) {
|
|
126
|
+
var otherNode = group[i];
|
|
127
|
+
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
|
|
128
|
+
continue;
|
|
152
129
|
}
|
|
130
|
+
var otherID = ReactMount.getID(otherNode);
|
|
131
|
+
!otherID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(false) : undefined;
|
|
132
|
+
var otherInstance = instancesByReactID[otherID];
|
|
133
|
+
!otherInstance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Unknown radio button ID %s.', otherID) : invariant(false) : undefined;
|
|
134
|
+
// If this is a controlled radio button group, forcing the input that
|
|
135
|
+
// was previously checked to update will cause it to be come re-checked
|
|
136
|
+
// as appropriate.
|
|
137
|
+
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
|
|
153
138
|
}
|
|
154
|
-
|
|
155
|
-
return returnValue;
|
|
156
139
|
}
|
|
157
140
|
|
|
158
|
-
|
|
141
|
+
return returnValue;
|
|
142
|
+
}
|
|
159
143
|
|
|
160
144
|
module.exports = ReactDOMInput;
|