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
|
@@ -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.
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
|
+
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
23
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
22
24
|
var ReactComponent = require("./ReactComponent");
|
|
23
|
-
var ReactMount = require("./ReactMount");
|
|
24
25
|
|
|
25
26
|
var escapeTextForBrowser = require("./escapeTextForBrowser");
|
|
26
27
|
var mixInto = require("./mixInto");
|
|
@@ -44,7 +45,18 @@ var ReactTextComponent = function(initialText) {
|
|
|
44
45
|
this.construct({text: initialText});
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Used to clone the text descriptor object before it's mounted.
|
|
50
|
+
*
|
|
51
|
+
* @param {object} props
|
|
52
|
+
* @return {object} A new ReactTextComponent instance
|
|
53
|
+
*/
|
|
54
|
+
ReactTextComponent.ConvenienceConstructor = function(props) {
|
|
55
|
+
return new ReactTextComponent(props.text);
|
|
56
|
+
};
|
|
57
|
+
|
|
47
58
|
mixInto(ReactTextComponent, ReactComponent.Mixin);
|
|
59
|
+
mixInto(ReactTextComponent, ReactBrowserComponentMixin);
|
|
48
60
|
mixInto(ReactTextComponent, {
|
|
49
61
|
|
|
50
62
|
/**
|
|
@@ -52,7 +64,7 @@ mixInto(ReactTextComponent, {
|
|
|
52
64
|
* any features besides containing text content.
|
|
53
65
|
*
|
|
54
66
|
* @param {string} rootID DOM ID of the root node.
|
|
55
|
-
* @param {ReactReconcileTransaction} transaction
|
|
67
|
+
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
56
68
|
* @param {number} mountDepth number of components in the owner hierarchy
|
|
57
69
|
* @return {string} Markup for this text node.
|
|
58
70
|
* @internal
|
|
@@ -64,9 +76,19 @@ mixInto(ReactTextComponent, {
|
|
|
64
76
|
transaction,
|
|
65
77
|
mountDepth
|
|
66
78
|
);
|
|
79
|
+
|
|
80
|
+
var escapedText = escapeTextForBrowser(this.props.text);
|
|
81
|
+
|
|
82
|
+
if (transaction.renderToStaticMarkup) {
|
|
83
|
+
// Normally we'd wrap this in a `span` for the reasons stated above, but
|
|
84
|
+
// since this is a situation where React won't take over (static pages),
|
|
85
|
+
// we can simply return the text as it is.
|
|
86
|
+
return escapedText;
|
|
87
|
+
}
|
|
88
|
+
|
|
67
89
|
return (
|
|
68
|
-
'<span ' +
|
|
69
|
-
|
|
90
|
+
'<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
|
|
91
|
+
escapedText +
|
|
70
92
|
'</span>'
|
|
71
93
|
);
|
|
72
94
|
},
|
|
@@ -82,7 +104,7 @@ mixInto(ReactTextComponent, {
|
|
|
82
104
|
var nextProps = nextComponent.props;
|
|
83
105
|
if (nextProps.text !== this.props.text) {
|
|
84
106
|
this.props.text = nextProps.text;
|
|
85
|
-
ReactComponent.
|
|
107
|
+
ReactComponent.BackendIDOperations.updateTextContentByID(
|
|
86
108
|
this._rootNodeID,
|
|
87
109
|
nextProps.text
|
|
88
110
|
);
|
|
@@ -91,4 +113,9 @@ mixInto(ReactTextComponent, {
|
|
|
91
113
|
|
|
92
114
|
});
|
|
93
115
|
|
|
116
|
+
// Expose the constructor on itself and the prototype for consistency with other
|
|
117
|
+
// descriptors.
|
|
118
|
+
ReactTextComponent.type = ReactTextComponent;
|
|
119
|
+
ReactTextComponent.prototype.type = ReactTextComponent;
|
|
120
|
+
|
|
94
121
|
module.exports = ReactTextComponent;
|
|
@@ -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.
|
|
@@ -14,16 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
16
|
* @typechecks static-only
|
|
17
|
-
* @providesModule
|
|
17
|
+
* @providesModule ReactTransitionChildMapping
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
22
|
var ReactChildren = require("./ReactChildren");
|
|
23
23
|
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var ReactTransitionKeySet = {
|
|
24
|
+
var ReactTransitionChildMapping = {
|
|
27
25
|
/**
|
|
28
26
|
* Given `this.props.children`, return an object mapping key to child. Just
|
|
29
27
|
* simple syntactic sugar around ReactChildren.map().
|
|
@@ -37,19 +35,6 @@ var ReactTransitionKeySet = {
|
|
|
37
35
|
});
|
|
38
36
|
},
|
|
39
37
|
|
|
40
|
-
/**
|
|
41
|
-
* Simple syntactic sugar to get an object with keys of all of `children`.
|
|
42
|
-
* Does not have references to the children themselves.
|
|
43
|
-
*
|
|
44
|
-
* @param {*} children `this.props.children`
|
|
45
|
-
* @return {object} Mapping of key to the value "true"
|
|
46
|
-
*/
|
|
47
|
-
getKeySet: function(children) {
|
|
48
|
-
return ReactChildren.map(children, function() {
|
|
49
|
-
return true;
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
|
|
53
38
|
/**
|
|
54
39
|
* When you're adding or removing children some may be added or removed in the
|
|
55
40
|
* same render pass. We want ot show *both* since we want to simultaneously
|
|
@@ -60,52 +45,62 @@ var ReactTransitionKeySet = {
|
|
|
60
45
|
* directly have this concept of the union of prevChildren and nextChildren
|
|
61
46
|
* so we implement it here.
|
|
62
47
|
*
|
|
63
|
-
* @param {object} prev prev
|
|
64
|
-
* `
|
|
65
|
-
* @param {object} next next
|
|
66
|
-
* `
|
|
48
|
+
* @param {object} prev prev children as returned from
|
|
49
|
+
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
50
|
+
* @param {object} next next children as returned from
|
|
51
|
+
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
67
52
|
* @return {object} a key set that contains all keys in `prev` and all keys
|
|
68
53
|
* in `next` in a reasonable order.
|
|
69
54
|
*/
|
|
70
|
-
|
|
55
|
+
mergeChildMappings: function(prev, next) {
|
|
71
56
|
prev = prev || {};
|
|
72
57
|
next = next || {};
|
|
73
58
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var prevKey = prevKeys[i];
|
|
80
|
-
if (next[prevKey]) {
|
|
81
|
-
continue;
|
|
59
|
+
function getValueForKey(key) {
|
|
60
|
+
if (next.hasOwnProperty(key)) {
|
|
61
|
+
return next[key];
|
|
62
|
+
} else {
|
|
63
|
+
return prev[key];
|
|
82
64
|
}
|
|
65
|
+
}
|
|
83
66
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// still in nextKeys, and inserting right before it.
|
|
88
|
-
// I know this is O(n^2), but this is not a particularly
|
|
89
|
-
// hot code path.
|
|
90
|
-
var insertPos = -1;
|
|
67
|
+
// For each key of `next`, the list of keys to insert before that key in
|
|
68
|
+
// the combined list
|
|
69
|
+
var nextKeysPending = {};
|
|
91
70
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
71
|
+
var pendingKeys = [];
|
|
72
|
+
for (var prevKey in prev) {
|
|
73
|
+
if (next[prevKey]) {
|
|
74
|
+
if (pendingKeys.length) {
|
|
75
|
+
nextKeysPending[prevKey] = pendingKeys;
|
|
76
|
+
pendingKeys = [];
|
|
96
77
|
}
|
|
78
|
+
} else {
|
|
79
|
+
pendingKeys.push(prevKey);
|
|
97
80
|
}
|
|
81
|
+
}
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|
|
83
|
+
var i;
|
|
84
|
+
var childMapping = {};
|
|
85
|
+
for (var nextKey in next) {
|
|
86
|
+
if (nextKeysPending[nextKey]) {
|
|
87
|
+
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
|
|
88
|
+
var pendingNextKey = nextKeysPending[nextKey][i];
|
|
89
|
+
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
|
|
90
|
+
pendingNextKey
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
childMapping[nextKey] = getValueForKey(nextKey);
|
|
101
95
|
}
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
// Finally, add the keys which didn't appear before any key in `next`
|
|
98
|
+
for (i = 0; i < pendingKeys.length; i++) {
|
|
99
|
+
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
|
|
105
100
|
}
|
|
106
101
|
|
|
107
|
-
return
|
|
102
|
+
return childMapping;
|
|
108
103
|
}
|
|
109
104
|
};
|
|
110
105
|
|
|
111
|
-
module.exports =
|
|
106
|
+
module.exports = ReactTransitionChildMapping;
|
|
@@ -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.
|
|
@@ -19,93 +19,168 @@
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
21
|
var React = require("./React");
|
|
22
|
-
var
|
|
23
|
-
|
|
22
|
+
var ReactTransitionChildMapping = require("./ReactTransitionChildMapping");
|
|
23
|
+
|
|
24
|
+
var cloneWithProps = require("./cloneWithProps");
|
|
25
|
+
var emptyFunction = require("./emptyFunction");
|
|
26
|
+
var merge = require("./merge");
|
|
24
27
|
|
|
25
28
|
var ReactTransitionGroup = React.createClass({
|
|
26
29
|
|
|
27
30
|
propTypes: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
transitionLeave: React.PropTypes.bool,
|
|
31
|
-
onTransition: React.PropTypes.func,
|
|
32
|
-
component: React.PropTypes.func
|
|
31
|
+
component: React.PropTypes.func,
|
|
32
|
+
childFactory: React.PropTypes.func
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
getDefaultProps: function() {
|
|
36
36
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
component: React.DOM.span,
|
|
38
|
+
childFactory: emptyFunction.thatReturnsArgument
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
getInitialState: function() {
|
|
43
|
+
return {
|
|
44
|
+
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
|
|
40
45
|
};
|
|
41
46
|
},
|
|
42
47
|
|
|
48
|
+
componentWillReceiveProps: function(nextProps) {
|
|
49
|
+
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
50
|
+
nextProps.children
|
|
51
|
+
);
|
|
52
|
+
var prevChildMapping = this.state.children;
|
|
53
|
+
|
|
54
|
+
this.setState({
|
|
55
|
+
children: ReactTransitionChildMapping.mergeChildMappings(
|
|
56
|
+
prevChildMapping,
|
|
57
|
+
nextChildMapping
|
|
58
|
+
)
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var key;
|
|
62
|
+
|
|
63
|
+
for (key in nextChildMapping) {
|
|
64
|
+
if (!prevChildMapping.hasOwnProperty(key) &&
|
|
65
|
+
!this.currentlyTransitioningKeys[key]) {
|
|
66
|
+
this.keysToEnter.push(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (key in prevChildMapping) {
|
|
71
|
+
if (!nextChildMapping.hasOwnProperty(key) &&
|
|
72
|
+
!this.currentlyTransitioningKeys[key]) {
|
|
73
|
+
this.keysToLeave.push(key);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If we want to someday check for reordering, we could do it here.
|
|
78
|
+
},
|
|
79
|
+
|
|
43
80
|
componentWillMount: function() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// call to animateChildren() which happens in render(), so we can't
|
|
48
|
-
// call setState() in there.
|
|
49
|
-
this._transitionGroupCurrentKeys = {};
|
|
81
|
+
this.currentlyTransitioningKeys = {};
|
|
82
|
+
this.keysToEnter = [];
|
|
83
|
+
this.keysToLeave = [];
|
|
50
84
|
},
|
|
51
85
|
|
|
52
86
|
componentDidUpdate: function() {
|
|
53
|
-
|
|
54
|
-
|
|
87
|
+
var keysToEnter = this.keysToEnter;
|
|
88
|
+
this.keysToEnter = [];
|
|
89
|
+
keysToEnter.forEach(this.performEnter);
|
|
90
|
+
|
|
91
|
+
var keysToLeave = this.keysToLeave;
|
|
92
|
+
this.keysToLeave = [];
|
|
93
|
+
keysToLeave.forEach(this.performLeave);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
performEnter: function(key) {
|
|
97
|
+
this.currentlyTransitioningKeys[key] = true;
|
|
98
|
+
|
|
99
|
+
var component = this.refs[key];
|
|
100
|
+
|
|
101
|
+
if (component.componentWillEnter) {
|
|
102
|
+
component.componentWillEnter(
|
|
103
|
+
this._handleDoneEntering.bind(this, key)
|
|
104
|
+
);
|
|
105
|
+
} else {
|
|
106
|
+
this._handleDoneEntering(key);
|
|
55
107
|
}
|
|
56
108
|
},
|
|
57
109
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
110
|
+
_handleDoneEntering: function(key) {
|
|
111
|
+
var component = this.refs[key];
|
|
112
|
+
if (component.componentDidEnter) {
|
|
113
|
+
component.componentDidEnter();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
delete this.currentlyTransitioningKeys[key];
|
|
64
117
|
|
|
65
|
-
var
|
|
66
|
-
this.
|
|
67
|
-
ReactTransitionKeySet.getKeySet(sourceChildren)
|
|
118
|
+
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
119
|
+
this.props.children
|
|
68
120
|
);
|
|
69
121
|
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
// may look up an old key in the new children, and it may switch to
|
|
74
|
-
// undefined. React's reconciler will keep the ReactTransitionableChild
|
|
75
|
-
// instance alive such that we can animate it.
|
|
76
|
-
if (childMapping[key] || this.props.transitionLeave) {
|
|
77
|
-
children[key] = ReactTransitionableChild({
|
|
78
|
-
name: this.props.transitionName,
|
|
79
|
-
enter: this.props.transitionEnter,
|
|
80
|
-
onDoneLeaving: this._handleDoneLeaving.bind(this, key)
|
|
81
|
-
}, childMapping[key]);
|
|
82
|
-
}
|
|
122
|
+
if (!currentChildMapping.hasOwnProperty(key)) {
|
|
123
|
+
// This was removed before it had fully entered. Remove it.
|
|
124
|
+
this.performLeave(key);
|
|
83
125
|
}
|
|
126
|
+
},
|
|
84
127
|
|
|
85
|
-
|
|
128
|
+
performLeave: function(key) {
|
|
129
|
+
this.currentlyTransitioningKeys[key] = true;
|
|
86
130
|
|
|
87
|
-
|
|
131
|
+
var component = this.refs[key];
|
|
132
|
+
if (component.componentWillLeave) {
|
|
133
|
+
component.componentWillLeave(this._handleDoneLeaving.bind(this, key));
|
|
134
|
+
} else {
|
|
135
|
+
// Note that this is somewhat dangerous b/c it calls setState()
|
|
136
|
+
// again, effectively mutating the component before all the work
|
|
137
|
+
// is done.
|
|
138
|
+
this._handleDoneLeaving(key);
|
|
139
|
+
}
|
|
88
140
|
},
|
|
89
141
|
|
|
90
142
|
_handleDoneLeaving: function(key) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
143
|
+
var component = this.refs[key];
|
|
144
|
+
|
|
145
|
+
if (component.componentDidLeave) {
|
|
146
|
+
component.componentDidLeave();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
delete this.currentlyTransitioningKeys[key];
|
|
150
|
+
|
|
151
|
+
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
152
|
+
this.props.children
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
if (currentChildMapping.hasOwnProperty(key)) {
|
|
156
|
+
// This entered again before it fully left. Add it again.
|
|
157
|
+
this.performEnter(key);
|
|
158
|
+
} else {
|
|
159
|
+
var newChildren = merge(this.state.children);
|
|
160
|
+
delete newChildren[key];
|
|
161
|
+
this.setState({children: newChildren});
|
|
162
|
+
}
|
|
95
163
|
},
|
|
96
164
|
|
|
97
165
|
render: function() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
166
|
+
// TODO: we could get rid of the need for the wrapper node
|
|
167
|
+
// by cloning a single child
|
|
168
|
+
var childrenToRender = {};
|
|
169
|
+
for (var key in this.state.children) {
|
|
170
|
+
var child = this.state.children[key];
|
|
171
|
+
if (child) {
|
|
172
|
+
// You may need to apply reactive updates to a child as it is leaving.
|
|
173
|
+
// The normal React way to do it won't work since the child will have
|
|
174
|
+
// already been removed. In case you need this behavior you can provide
|
|
175
|
+
// a childFactory function to wrap every child, even the ones that are
|
|
176
|
+
// leaving.
|
|
177
|
+
childrenToRender[key] = cloneWithProps(
|
|
178
|
+
this.props.childFactory(child),
|
|
179
|
+
{ref: key}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return this.transferPropsTo(this.props.component(null, childrenToRender));
|
|
109
184
|
}
|
|
110
185
|
});
|
|
111
186
|
|