react 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/addons.js +0 -3
- package/lib/AutoFocusMixin.js +32 -0
- package/lib/CSSCore.js +23 -22
- package/lib/CSSProperty.js +32 -1
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/ChangeEventPlugin.js +27 -5
- package/lib/ClientReactRootIndex.js +30 -0
- package/lib/CompositionEventPlugin.js +58 -10
- package/lib/DOMChildrenOperations.js +39 -3
- package/lib/DOMProperty.js +9 -5
- package/lib/DOMPropertyOperations.js +21 -8
- package/lib/Danger.js +9 -8
- package/lib/DefaultDOMPropertyConfig.js +23 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +38 -5
- package/lib/EventConstants.js +4 -1
- package/lib/EventListener.js +42 -34
- package/lib/EventPluginHub.js +118 -13
- package/lib/EventPluginRegistry.js +62 -18
- package/lib/EventPluginUtils.js +33 -4
- package/lib/EventPropagators.js +7 -43
- package/lib/ExecutionEnvironment.js +4 -1
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +160 -0
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/PooledClass.js +7 -1
- package/lib/React.js +30 -4
- package/lib/ReactBrowserComponentMixin.js +42 -0
- package/lib/ReactCSSTransitionGroup.js +65 -0
- package/lib/{ReactTransitionableChild.js → ReactCSSTransitionGroupChild.js} +22 -36
- package/lib/ReactChildren.js +4 -4
- package/lib/ReactComponent.js +163 -83
- package/lib/ReactComponentBrowserEnvironment.js +55 -71
- package/lib/ReactCompositeComponent.js +686 -119
- package/lib/ReactContext.js +67 -0
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +19 -6
- package/lib/ReactDOMButton.js +6 -1
- package/lib/ReactDOMComponent.js +66 -24
- package/lib/ReactDOMForm.js +13 -3
- package/lib/ReactDOMIDOperations.js +106 -61
- package/lib/ReactDOMImg.js +61 -0
- package/lib/ReactDOMInput.js +28 -15
- package/lib/ReactDOMOption.js +13 -8
- package/lib/ReactDOMSelect.js +38 -18
- package/lib/ReactDOMSelection.js +1 -1
- package/lib/ReactDOMTextarea.js +19 -11
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +60 -26
- package/lib/ReactDefaultPerf.js +208 -371
- package/lib/ReactDefaultPerfAnalysis.js +199 -0
- package/lib/ReactErrorUtils.js +6 -15
- package/lib/ReactEventEmitter.js +144 -146
- package/lib/ReactEventEmitterMixin.js +1 -33
- package/lib/ReactEventTopLevelCallback.js +75 -15
- package/lib/ReactInjection.js +43 -0
- package/lib/ReactInputSelection.js +3 -2
- package/lib/ReactInstanceHandles.js +36 -20
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +136 -104
- package/lib/ReactMountReady.js +2 -2
- package/lib/ReactMultiChild.js +40 -49
- package/lib/ReactMultiChildUpdateTypes.js +3 -1
- package/lib/ReactOwner.js +17 -4
- package/lib/ReactPerf.js +6 -9
- package/lib/ReactPropTransferer.js +41 -22
- package/lib/ReactPropTypeLocationNames.js +31 -0
- package/lib/{ReactComponentEnvironment.js → ReactPropTypeLocations.js} +11 -6
- package/lib/ReactPropTypes.js +249 -48
- package/lib/ReactPutListenerQueue.js +61 -0
- package/lib/ReactReconcileTransaction.js +28 -7
- package/lib/ReactRootIndex.js +36 -0
- package/lib/ReactServerRendering.js +46 -19
- package/lib/ReactServerRenderingTransaction.js +116 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +394 -0
- package/lib/ReactTextComponent.js +33 -6
- package/lib/{ReactTransitionKeySet.js → ReactTransitionChildMapping.js} +43 -48
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +133 -58
- package/lib/ReactUpdates.js +15 -12
- package/lib/ReactWithAddons.js +15 -3
- package/lib/SelectEventPlugin.js +23 -40
- package/lib/ServerReactRootIndex.js +36 -0
- package/lib/SimpleEventPlugin.js +55 -7
- package/lib/SyntheticClipboardEvent.js +8 -2
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +44 -0
- package/lib/SyntheticEvent.js +3 -2
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +5 -3
- package/lib/SyntheticMouseEvent.js +1 -1
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +11 -8
- package/lib/Transaction.js +62 -37
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +59 -0
- package/lib/containsNode.js +1 -1
- package/lib/copyProperties.js +1 -1
- package/lib/createArrayFrom.js +11 -14
- package/lib/createFullPageComponent.js +63 -0
- package/lib/createNodesFromMarkup.js +1 -1
- package/lib/createObjectFrom.js +1 -1
- package/lib/cx.js +3 -3
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +27 -0
- package/lib/escapeTextForBrowser.js +1 -1
- package/lib/flattenChildren.js +6 -3
- package/lib/focusNode.js +33 -0
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getActiveElement.js +5 -4
- package/lib/getEventKey.js +85 -0
- package/lib/getEventTarget.js +1 -1
- package/lib/getMarkupWrap.js +11 -1
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +6 -4
- package/lib/getUnboundedScrollPosition.js +3 -3
- package/lib/hyphenate.js +1 -1
- package/lib/instantiateReactComponent.js +70 -0
- package/lib/invariant.js +20 -12
- package/lib/isEventSupported.js +8 -12
- package/lib/isNode.js +2 -2
- package/lib/isTextInputElement.js +1 -1
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/keyOf.js +1 -1
- package/lib/memoizeStringOnly.js +1 -1
- package/lib/merge.js +1 -1
- package/lib/mergeHelpers.js +6 -7
- package/lib/mergeInto.js +1 -1
- package/lib/mixInto.js +1 -1
- package/lib/monitorCodeUse.js +37 -0
- package/lib/objMap.js +1 -1
- package/lib/objMapKeyVal.js +1 -1
- package/lib/onlyChild.js +43 -0
- package/lib/performanceNow.js +1 -1
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +61 -0
- package/lib/toArray.js +75 -0
- package/lib/traverseAllChildren.js +72 -9
- package/lib/update.js +159 -0
- package/lib/warning.js +48 -0
- package/package.json +3 -3
- package/react.js +0 -3
- package/ReactJSErrors.js +0 -40
- package/lib/$.js +0 -46
- package/lib/CallbackRegistry.js +0 -91
- package/lib/LinkedValueMixin.js +0 -68
- package/lib/ex.js +0 -49
- package/lib/filterAttributes.js +0 -45
- package/lib/ge.js +0 -76
- package/lib/mutateHTMLNodeWithMarkup.js +0 -100
package/README.md
CHANGED
|
@@ -5,18 +5,10 @@ without also requiring the JSX transformer. This is especially useful for cases
|
|
|
5
5
|
want to [`browserify`](https://github.com/substack/node-browserify) your module using
|
|
6
6
|
`React`.
|
|
7
7
|
|
|
8
|
-
## The `react` npm package has recently changed!
|
|
9
|
-
|
|
10
|
-
If you're looking for jeffbski's [React.js](https://github.com/jeffbski/react) project, it's now in `npm` as `autoflow` rather than `react`.
|
|
11
8
|
|
|
12
9
|
## Example Usage
|
|
13
10
|
|
|
14
11
|
```js
|
|
15
|
-
|
|
16
|
-
// Previously, you might access React with react-tools.
|
|
17
|
-
var React = require('react-tools').React;
|
|
18
|
-
|
|
19
|
-
// Now you can access React directly with react-core.
|
|
20
12
|
var React = require('react');
|
|
21
13
|
|
|
22
14
|
// You can also access ReactWithAddons.
|
package/addons.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule AutoFocusMixin
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var focusNode = require("./focusNode");
|
|
23
|
+
|
|
24
|
+
var AutoFocusMixin = {
|
|
25
|
+
componentDidMount: function() {
|
|
26
|
+
if (this.props.autoFocus) {
|
|
27
|
+
focusNode(this.getDOMNode());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = AutoFocusMixin;
|
package/lib/CSSCore.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -22,29 +22,11 @@ var invariant = require("./invariant");
|
|
|
22
22
|
/**
|
|
23
23
|
* The CSSCore module specifies the API (and implements most of the methods)
|
|
24
24
|
* that should be used when dealing with the display of elements (via their
|
|
25
|
-
* CSS classes and visibility on
|
|
25
|
+
* CSS classes and visibility on screen. It is an API focused on mutating the
|
|
26
26
|
* display and not reading it as no logical state should be encoded in the
|
|
27
27
|
* display of elements.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* Tests whether the element has the class specified.
|
|
32
|
-
*
|
|
33
|
-
* Note: This function is not exported in CSSCore because CSS classNames should
|
|
34
|
-
* not store any logical information about the element. Use DataStore to store
|
|
35
|
-
* information on an element.
|
|
36
|
-
*
|
|
37
|
-
* @param {DOMElement} element the element to set the class on
|
|
38
|
-
* @param {string} className the CSS className
|
|
39
|
-
* @returns {boolean} true if the element has the class, false if not
|
|
40
|
-
*/
|
|
41
|
-
function hasClass(element, className) {
|
|
42
|
-
if (element.classList) {
|
|
43
|
-
return !!className && element.classList.contains(className);
|
|
44
|
-
}
|
|
45
|
-
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
30
|
var CSSCore = {
|
|
49
31
|
|
|
50
32
|
/**
|
|
@@ -64,7 +46,7 @@ var CSSCore = {
|
|
|
64
46
|
if (className) {
|
|
65
47
|
if (element.classList) {
|
|
66
48
|
element.classList.add(className);
|
|
67
|
-
} else if (!hasClass(element, className)) {
|
|
49
|
+
} else if (!CSSCore.hasClass(element, className)) {
|
|
68
50
|
element.className = element.className + ' ' + className;
|
|
69
51
|
}
|
|
70
52
|
}
|
|
@@ -88,7 +70,7 @@ var CSSCore = {
|
|
|
88
70
|
if (className) {
|
|
89
71
|
if (element.classList) {
|
|
90
72
|
element.classList.remove(className);
|
|
91
|
-
} else if (hasClass(element, className)) {
|
|
73
|
+
} else if (CSSCore.hasClass(element, className)) {
|
|
92
74
|
element.className = element.className
|
|
93
75
|
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
|
|
94
76
|
.replace(/\s+/g, ' ') // multiple spaces to one
|
|
@@ -108,7 +90,26 @@ var CSSCore = {
|
|
|
108
90
|
*/
|
|
109
91
|
conditionClass: function(element, className, bool) {
|
|
110
92
|
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Tests whether the element has the class specified.
|
|
97
|
+
*
|
|
98
|
+
* @param {DOMNode|DOMWindow} element the element to set the class on
|
|
99
|
+
* @param {string} className the CSS className
|
|
100
|
+
* @returns {boolean} true if the element has the class, false if not
|
|
101
|
+
*/
|
|
102
|
+
hasClass: function(element, className) {
|
|
103
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
104
|
+
!/\s/.test(className),
|
|
105
|
+
'CSS.hasClass takes only a single class name.'
|
|
106
|
+
) : invariant(!/\s/.test(className)));
|
|
107
|
+
if (element.classList) {
|
|
108
|
+
return !!className && element.classList.contains(className);
|
|
109
|
+
}
|
|
110
|
+
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
|
111
111
|
}
|
|
112
|
+
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
module.exports = CSSCore;
|
package/lib/CSSProperty.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -22,15 +22,46 @@
|
|
|
22
22
|
* CSS properties which accept numbers but are not in units of "px".
|
|
23
23
|
*/
|
|
24
24
|
var isUnitlessNumber = {
|
|
25
|
+
columnCount: true,
|
|
25
26
|
fillOpacity: true,
|
|
27
|
+
flex: true,
|
|
28
|
+
flexGrow: true,
|
|
29
|
+
flexShrink: true,
|
|
26
30
|
fontWeight: true,
|
|
31
|
+
lineClamp: true,
|
|
27
32
|
lineHeight: true,
|
|
28
33
|
opacity: true,
|
|
34
|
+
order: true,
|
|
29
35
|
orphans: true,
|
|
36
|
+
widows: true,
|
|
30
37
|
zIndex: true,
|
|
31
38
|
zoom: true
|
|
32
39
|
};
|
|
33
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
43
|
+
* @param {string} key style name, eg: transitionDuration
|
|
44
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
45
|
+
* WebkitTransitionDuration
|
|
46
|
+
*/
|
|
47
|
+
function prefixKey(prefix, key) {
|
|
48
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
53
|
+
* of vendor prefixes.
|
|
54
|
+
*/
|
|
55
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
|
56
|
+
|
|
57
|
+
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
58
|
+
// infinite loop, because it iterates over the newly added props too.
|
|
59
|
+
Object.keys(isUnitlessNumber).forEach(function(prop) {
|
|
60
|
+
prefixes.forEach(function(prefix) {
|
|
61
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
34
65
|
/**
|
|
35
66
|
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
|
36
67
|
* doesn't like doing that with shorthand properties so for the properties that
|
package/lib/ChangeEventPlugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -22,6 +22,7 @@ var EventConstants = require("./EventConstants");
|
|
|
22
22
|
var EventPluginHub = require("./EventPluginHub");
|
|
23
23
|
var EventPropagators = require("./EventPropagators");
|
|
24
24
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
25
|
+
var ReactUpdates = require("./ReactUpdates");
|
|
25
26
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
26
27
|
|
|
27
28
|
var isEventSupported = require("./isEventSupported");
|
|
@@ -35,7 +36,17 @@ var eventTypes = {
|
|
|
35
36
|
phasedRegistrationNames: {
|
|
36
37
|
bubbled: keyOf({onChange: null}),
|
|
37
38
|
captured: keyOf({onChangeCapture: null})
|
|
38
|
-
}
|
|
39
|
+
},
|
|
40
|
+
dependencies: [
|
|
41
|
+
topLevelTypes.topBlur,
|
|
42
|
+
topLevelTypes.topChange,
|
|
43
|
+
topLevelTypes.topClick,
|
|
44
|
+
topLevelTypes.topFocus,
|
|
45
|
+
topLevelTypes.topInput,
|
|
46
|
+
topLevelTypes.topKeyDown,
|
|
47
|
+
topLevelTypes.topKeyUp,
|
|
48
|
+
topLevelTypes.topSelectionChange
|
|
49
|
+
]
|
|
39
50
|
}
|
|
40
51
|
};
|
|
41
52
|
|
|
@@ -73,10 +84,21 @@ function manualDispatchChangeEvent(nativeEvent) {
|
|
|
73
84
|
);
|
|
74
85
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
75
86
|
|
|
76
|
-
// If change bubbled, we'd just bind to it like all the
|
|
77
|
-
// and have it go through ReactEventTopLevelCallback. Since it
|
|
78
|
-
// manually listen for the
|
|
87
|
+
// If change and propertychange bubbled, we'd just bind to it like all the
|
|
88
|
+
// other events and have it go through ReactEventTopLevelCallback. Since it
|
|
89
|
+
// doesn't, we manually listen for the events and so we have to enqueue and
|
|
79
90
|
// process the abstract event manually.
|
|
91
|
+
//
|
|
92
|
+
// Batching is necessary here in order to ensure that all event handlers run
|
|
93
|
+
// before the next rerender (including event handlers attached to ancestor
|
|
94
|
+
// elements instead of directly on the input). Without this, controlled
|
|
95
|
+
// components don't work properly in conjunction with event bubbling because
|
|
96
|
+
// the component is rerendered and the value reverted before all the event
|
|
97
|
+
// handlers can run. See https://github.com/facebook/react/issues/708.
|
|
98
|
+
ReactUpdates.batchedUpdates(runEventInBatch, event);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function runEventInBatch(event) {
|
|
80
102
|
EventPluginHub.enqueueEvents(event);
|
|
81
103
|
EventPluginHub.processEventQueue();
|
|
82
104
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule ClientReactRootIndex
|
|
17
|
+
* @typechecks
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var nextReactRootIndex = 0;
|
|
23
|
+
|
|
24
|
+
var ClientReactRootIndex = {
|
|
25
|
+
createReactRootIndex: function() {
|
|
26
|
+
return nextReactRootIndex++;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = ClientReactRootIndex;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -31,8 +31,22 @@ var keyOf = require("./keyOf");
|
|
|
31
31
|
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
|
|
32
32
|
var START_KEYCODE = 229;
|
|
33
33
|
|
|
34
|
-
var useCompositionEvent =
|
|
35
|
-
|
|
34
|
+
var useCompositionEvent = (
|
|
35
|
+
ExecutionEnvironment.canUseDOM &&
|
|
36
|
+
'CompositionEvent' in window
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// In IE9+, we have access to composition events, but the data supplied
|
|
40
|
+
// by the native compositionend event may be incorrect. In Korean, for example,
|
|
41
|
+
// the compositionend event contains only one character regardless of
|
|
42
|
+
// how many characters have been composed since compositionstart.
|
|
43
|
+
// We therefore use the fallback data while still using the native
|
|
44
|
+
// events as triggers.
|
|
45
|
+
var useFallbackData = (
|
|
46
|
+
!useCompositionEvent ||
|
|
47
|
+
'documentMode' in document && document.documentMode > 8
|
|
48
|
+
);
|
|
49
|
+
|
|
36
50
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
37
51
|
var currentComposition = null;
|
|
38
52
|
|
|
@@ -42,19 +56,43 @@ var eventTypes = {
|
|
|
42
56
|
phasedRegistrationNames: {
|
|
43
57
|
bubbled: keyOf({onCompositionEnd: null}),
|
|
44
58
|
captured: keyOf({onCompositionEndCapture: null})
|
|
45
|
-
}
|
|
59
|
+
},
|
|
60
|
+
dependencies: [
|
|
61
|
+
topLevelTypes.topBlur,
|
|
62
|
+
topLevelTypes.topCompositionEnd,
|
|
63
|
+
topLevelTypes.topKeyDown,
|
|
64
|
+
topLevelTypes.topKeyPress,
|
|
65
|
+
topLevelTypes.topKeyUp,
|
|
66
|
+
topLevelTypes.topMouseDown
|
|
67
|
+
]
|
|
46
68
|
},
|
|
47
69
|
compositionStart: {
|
|
48
70
|
phasedRegistrationNames: {
|
|
49
71
|
bubbled: keyOf({onCompositionStart: null}),
|
|
50
72
|
captured: keyOf({onCompositionStartCapture: null})
|
|
51
|
-
}
|
|
73
|
+
},
|
|
74
|
+
dependencies: [
|
|
75
|
+
topLevelTypes.topBlur,
|
|
76
|
+
topLevelTypes.topCompositionStart,
|
|
77
|
+
topLevelTypes.topKeyDown,
|
|
78
|
+
topLevelTypes.topKeyPress,
|
|
79
|
+
topLevelTypes.topKeyUp,
|
|
80
|
+
topLevelTypes.topMouseDown
|
|
81
|
+
]
|
|
52
82
|
},
|
|
53
83
|
compositionUpdate: {
|
|
54
84
|
phasedRegistrationNames: {
|
|
55
85
|
bubbled: keyOf({onCompositionUpdate: null}),
|
|
56
86
|
captured: keyOf({onCompositionUpdateCapture: null})
|
|
57
|
-
}
|
|
87
|
+
},
|
|
88
|
+
dependencies: [
|
|
89
|
+
topLevelTypes.topBlur,
|
|
90
|
+
topLevelTypes.topCompositionUpdate,
|
|
91
|
+
topLevelTypes.topKeyDown,
|
|
92
|
+
topLevelTypes.topKeyPress,
|
|
93
|
+
topLevelTypes.topKeyUp,
|
|
94
|
+
topLevelTypes.topMouseDown
|
|
95
|
+
]
|
|
58
96
|
}
|
|
59
97
|
};
|
|
60
98
|
|
|
@@ -183,13 +221,23 @@ var CompositionEventPlugin = {
|
|
|
183
221
|
eventType = getCompositionEventType(topLevelType);
|
|
184
222
|
} else if (!currentComposition) {
|
|
185
223
|
if (isFallbackStart(topLevelType, nativeEvent)) {
|
|
186
|
-
eventType = eventTypes.
|
|
187
|
-
currentComposition = new FallbackCompositionState(topLevelTarget);
|
|
224
|
+
eventType = eventTypes.compositionStart;
|
|
188
225
|
}
|
|
189
226
|
} else if (isFallbackEnd(topLevelType, nativeEvent)) {
|
|
190
227
|
eventType = eventTypes.compositionEnd;
|
|
191
|
-
|
|
192
|
-
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (useFallbackData) {
|
|
231
|
+
// The current composition is stored statically and must not be
|
|
232
|
+
// overwritten while composition continues.
|
|
233
|
+
if (!currentComposition && eventType === eventTypes.compositionStart) {
|
|
234
|
+
currentComposition = new FallbackCompositionState(topLevelTarget);
|
|
235
|
+
} else if (eventType === eventTypes.compositionEnd) {
|
|
236
|
+
if (currentComposition) {
|
|
237
|
+
data = currentComposition.getData();
|
|
238
|
+
currentComposition = null;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
193
241
|
}
|
|
194
242
|
|
|
195
243
|
if (eventType) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -30,7 +30,7 @@ var getTextContentAccessor = require("./getTextContentAccessor");
|
|
|
30
30
|
* @type {string}
|
|
31
31
|
* @private
|
|
32
32
|
*/
|
|
33
|
-
var textContentAccessor = getTextContentAccessor()
|
|
33
|
+
var textContentAccessor = getTextContentAccessor();
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Inserts `childNode` as a child of `parentNode` at the `index`.
|
|
@@ -57,6 +57,37 @@ function insertChildAt(parentNode, childNode, index) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
var updateTextContent;
|
|
61
|
+
if (textContentAccessor === 'textContent') {
|
|
62
|
+
/**
|
|
63
|
+
* Sets the text content of `node` to `text`.
|
|
64
|
+
*
|
|
65
|
+
* @param {DOMElement} node Node to change
|
|
66
|
+
* @param {string} text New text content
|
|
67
|
+
*/
|
|
68
|
+
updateTextContent = function(node, text) {
|
|
69
|
+
node.textContent = text;
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
/**
|
|
73
|
+
* Sets the text content of `node` to `text`.
|
|
74
|
+
*
|
|
75
|
+
* @param {DOMElement} node Node to change
|
|
76
|
+
* @param {string} text New text content
|
|
77
|
+
*/
|
|
78
|
+
updateTextContent = function(node, text) {
|
|
79
|
+
// In order to preserve newlines correctly, we can't use .innerText to set
|
|
80
|
+
// the contents (see #1080), so we empty the element then append a text node
|
|
81
|
+
while (node.firstChild) {
|
|
82
|
+
node.removeChild(node.firstChild);
|
|
83
|
+
}
|
|
84
|
+
if (text) {
|
|
85
|
+
var doc = node.ownerDocument || document;
|
|
86
|
+
node.appendChild(doc.createTextNode(text));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
60
91
|
/**
|
|
61
92
|
* Operations for updating with DOM children.
|
|
62
93
|
*/
|
|
@@ -64,6 +95,8 @@ var DOMChildrenOperations = {
|
|
|
64
95
|
|
|
65
96
|
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
|
66
97
|
|
|
98
|
+
updateTextContent: updateTextContent,
|
|
99
|
+
|
|
67
100
|
/**
|
|
68
101
|
* Updates a component's children by processing a series of updates. The
|
|
69
102
|
* update configurations are each expected to have a `parentNode` property.
|
|
@@ -121,7 +154,10 @@ var DOMChildrenOperations = {
|
|
|
121
154
|
);
|
|
122
155
|
break;
|
|
123
156
|
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
|
124
|
-
|
|
157
|
+
updateTextContent(
|
|
158
|
+
update.parentNode,
|
|
159
|
+
update.textContent
|
|
160
|
+
);
|
|
125
161
|
break;
|
|
126
162
|
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
|
127
163
|
// Already removed by the for-loop above.
|