react 0.12.2 → 0.13.0-alpha.1
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 +6 -4
- package/dist/react-with-addons.js +4022 -3267
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3853 -3358
- package/dist/react.min.js +6 -6
- package/lib/BeforeInputEventPlugin.js +388 -111
- package/lib/CSSPropertyOperations.js +20 -0
- package/lib/ChangeEventPlugin.js +2 -2
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +0 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +87 -0
- package/lib/HTMLDOMPropertyConfig.js +1 -0
- package/lib/Object.assign.js +3 -1
- package/lib/React.js +14 -49
- package/lib/ReactBrowserComponentMixin.js +2 -12
- package/lib/ReactBrowserEventEmitter.js +2 -4
- package/lib/ReactCSSTransitionGroup.js +3 -0
- package/lib/ReactCSSTransitionGroupChild.js +8 -0
- package/lib/ReactChildReconciler.js +121 -0
- package/lib/ReactClass.js +916 -0
- package/lib/ReactComponent.js +36 -286
- package/lib/ReactComponentBrowserEnvironment.js +9 -82
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactCompositeComponent.js +608 -1026
- package/lib/ReactContext.js +5 -1
- package/lib/ReactDOM.js +2 -7
- package/lib/ReactDOMButton.js +4 -5
- package/lib/ReactDOMComponent.js +97 -69
- package/lib/ReactDOMForm.js +4 -5
- package/lib/ReactDOMIDOperations.js +55 -73
- package/lib/ReactDOMImg.js +3 -5
- package/lib/ReactDOMInput.js +4 -5
- package/lib/ReactDOMOption.js +4 -5
- package/lib/ReactDOMSelect.js +55 -63
- package/lib/ReactDOMSelection.js +5 -1
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +54 -34
- package/lib/ReactDOMTextarea.js +4 -5
- package/lib/ReactDefaultInjection.js +13 -7
- package/lib/ReactDefaultPerf.js +6 -5
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +17 -11
- package/lib/ReactElementValidator.js +74 -37
- package/lib/ReactEmptyComponent.js +17 -10
- package/lib/ReactInjection.js +6 -4
- package/lib/ReactInputSelection.js +2 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactMount.js +193 -64
- package/lib/ReactMultiChild.js +32 -42
- package/lib/ReactNativeComponent.js +45 -8
- package/lib/ReactOwner.js +3 -47
- package/lib/ReactPerf.js +20 -0
- package/lib/ReactPropTransferer.js +0 -55
- package/lib/ReactPropTypes.js +1 -17
- package/lib/ReactRef.js +96 -0
- package/lib/ReactServerRendering.js +3 -2
- package/lib/ReactTestUtils.js +82 -25
- package/lib/ReactTransitionGroup.js +47 -6
- package/lib/ReactUpdates.js +43 -42
- package/lib/SyntheticMouseEvent.js +1 -3
- package/lib/ViewportMetrics.js +1 -4
- package/lib/accumulate.js +47 -0
- package/lib/cloneWithProps.js +2 -2
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +2 -2
- package/lib/findDOMNode.js +52 -0
- package/lib/flattenChildren.js +1 -14
- package/lib/getIteratorFn.js +42 -0
- package/lib/instantiateReactComponent.js +88 -65
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +1 -2
- package/lib/shouldUpdateReactComponent.js +13 -5
- package/lib/traverseAllChildren.js +110 -54
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/deprecated.js +0 -47
|
@@ -34,6 +34,9 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if ("production" !== process.env.NODE_ENV) {
|
|
37
|
+
// 'msTransform' is correct, but the other prefixes should be capitalized
|
|
38
|
+
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
|
39
|
+
|
|
37
40
|
var warnedStyleNames = {};
|
|
38
41
|
|
|
39
42
|
var warnHyphenatedStyleName = function(name) {
|
|
@@ -48,6 +51,19 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
48
51
|
camelizeStyleName(name) + '?'
|
|
49
52
|
) : null);
|
|
50
53
|
};
|
|
54
|
+
|
|
55
|
+
var warnBadVendoredStyleName = function(name) {
|
|
56
|
+
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
warnedStyleNames[name] = true;
|
|
61
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
62
|
+
false,
|
|
63
|
+
'Unsupported vendor-prefixed style property ' + name + '. Did you mean ' +
|
|
64
|
+
name.charAt(0).toUpperCase() + name.slice(1) + '?'
|
|
65
|
+
) : null);
|
|
66
|
+
};
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
/**
|
|
@@ -76,6 +92,8 @@ var CSSPropertyOperations = {
|
|
|
76
92
|
if ("production" !== process.env.NODE_ENV) {
|
|
77
93
|
if (styleName.indexOf('-') > -1) {
|
|
78
94
|
warnHyphenatedStyleName(styleName);
|
|
95
|
+
} else if (badVendoredStyleNamePattern.test(styleName)) {
|
|
96
|
+
warnBadVendoredStyleName(styleName);
|
|
79
97
|
}
|
|
80
98
|
}
|
|
81
99
|
var styleValue = styles[styleName];
|
|
@@ -103,6 +121,8 @@ var CSSPropertyOperations = {
|
|
|
103
121
|
if ("production" !== process.env.NODE_ENV) {
|
|
104
122
|
if (styleName.indexOf('-') > -1) {
|
|
105
123
|
warnHyphenatedStyleName(styleName);
|
|
124
|
+
} else if (badVendoredStyleNamePattern.test(styleName)) {
|
|
125
|
+
warnBadVendoredStyleName(styleName);
|
|
106
126
|
}
|
|
107
127
|
}
|
|
108
128
|
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
|
package/lib/ChangeEventPlugin.js
CHANGED
|
@@ -65,7 +65,7 @@ var doesChangeEventBubble = false;
|
|
|
65
65
|
if (ExecutionEnvironment.canUseDOM) {
|
|
66
66
|
// See `handleChange` comment below
|
|
67
67
|
doesChangeEventBubble = isEventSupported('change') && (
|
|
68
|
-
!('documentMode' in document) || document.documentMode > 8
|
|
68
|
+
(!('documentMode' in document) || document.documentMode > 8)
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -142,7 +142,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
142
142
|
// IE9 claims to support the input event but fails to trigger it when
|
|
143
143
|
// deleting text, so we ignore its input events
|
|
144
144
|
isInputEventSupported = isEventSupported('input') && (
|
|
145
|
-
!('documentMode' in document) || document.documentMode > 9
|
|
145
|
+
(!('documentMode' in document) || document.documentMode > 9)
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
|
package/lib/Danger.js
CHANGED
|
@@ -170,7 +170,7 @@ var Danger = {
|
|
|
170
170
|
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
|
|
171
171
|
'<html> node. This is because browser quirks make this unreliable ' +
|
|
172
172
|
'and/or slow. If you want to render to the root you must use ' +
|
|
173
|
-
'server rendering. See
|
|
173
|
+
'server rendering. See React.renderToString().'
|
|
174
174
|
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
|
|
175
175
|
|
|
176
176
|
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
@@ -29,7 +29,6 @@ var DefaultEventPluginOrder = [
|
|
|
29
29
|
keyOf({EnterLeaveEventPlugin: null}),
|
|
30
30
|
keyOf({ChangeEventPlugin: null}),
|
|
31
31
|
keyOf({SelectEventPlugin: null}),
|
|
32
|
-
keyOf({CompositionEventPlugin: null}),
|
|
33
32
|
keyOf({BeforeInputEventPlugin: null}),
|
|
34
33
|
keyOf({AnalyticsEventPlugin: null}),
|
|
35
34
|
keyOf({MobileSafariClickEventPlugin: null})
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 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 FallbackCompositionState
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
var PooledClass = require("./PooledClass");
|
|
16
|
+
|
|
17
|
+
var assign = require("./Object.assign");
|
|
18
|
+
var getTextContentAccessor = require("./getTextContentAccessor");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This helper class stores information about text content of a target node,
|
|
22
|
+
* allowing comparison of content before and after a given event.
|
|
23
|
+
*
|
|
24
|
+
* Identify the node where selection currently begins, then observe
|
|
25
|
+
* both its text content and its current position in the DOM. Since the
|
|
26
|
+
* browser may natively replace the target node during composition, we can
|
|
27
|
+
* use its position to find its replacement.
|
|
28
|
+
*
|
|
29
|
+
* @param {DOMEventTarget} root
|
|
30
|
+
*/
|
|
31
|
+
function FallbackCompositionState(root) {
|
|
32
|
+
this._root = root;
|
|
33
|
+
this._startText = this.getText();
|
|
34
|
+
this._fallbackText = null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
assign(FallbackCompositionState.prototype, {
|
|
38
|
+
/**
|
|
39
|
+
* Get current text of input.
|
|
40
|
+
*
|
|
41
|
+
* @return {string}
|
|
42
|
+
*/
|
|
43
|
+
getText: function() {
|
|
44
|
+
if ('value' in this._root) {
|
|
45
|
+
return this._root.value;
|
|
46
|
+
}
|
|
47
|
+
return this._root[getTextContentAccessor()];
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Determine the differing substring between the initially stored
|
|
52
|
+
* text content and the current content.
|
|
53
|
+
*
|
|
54
|
+
* @return {string}
|
|
55
|
+
*/
|
|
56
|
+
getData: function() {
|
|
57
|
+
if (this._fallbackText) {
|
|
58
|
+
return this._fallbackText;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var endValue = this.getText();
|
|
62
|
+
var startValue = this._startText;
|
|
63
|
+
var startLength = startValue.length;
|
|
64
|
+
var endLength = endValue.length;
|
|
65
|
+
|
|
66
|
+
for (var start = 0; start < startLength; start++) {
|
|
67
|
+
if (startValue[start] !== endValue[start]) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var minEnd = startLength - start;
|
|
73
|
+
for (var end = 1; end <= minEnd; end++) {
|
|
74
|
+
if (startValue[startLength - end] !== endValue[endLength - end]) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var sliceTail = end > 1 ? 1 - end : undefined;
|
|
80
|
+
this._fallbackText = endValue.slice(start, sliceTail);
|
|
81
|
+
return this._fallbackText;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
PooledClass.addPoolingTo(FallbackCompositionState);
|
|
86
|
+
|
|
87
|
+
module.exports = FallbackCompositionState;
|
package/lib/Object.assign.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
|
13
13
|
|
|
14
|
+
"use strict";
|
|
15
|
+
|
|
14
16
|
function assign(target, sources) {
|
|
15
17
|
if (target == null) {
|
|
16
18
|
throw new TypeError('Object.assign target cannot be null or undefined');
|
|
@@ -40,6 +42,6 @@ function assign(target, sources) {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
return to;
|
|
43
|
-
}
|
|
45
|
+
}
|
|
44
46
|
|
|
45
47
|
module.exports = assign;
|
package/lib/React.js
CHANGED
|
@@ -9,31 +9,33 @@
|
|
|
9
9
|
* @providesModule React
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
|
|
13
|
+
|
|
12
14
|
"use strict";
|
|
13
15
|
|
|
14
16
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
15
17
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
16
18
|
var ReactChildren = require("./ReactChildren");
|
|
17
19
|
var ReactComponent = require("./ReactComponent");
|
|
18
|
-
var
|
|
20
|
+
var ReactClass = require("./ReactClass");
|
|
19
21
|
var ReactContext = require("./ReactContext");
|
|
20
22
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
21
23
|
var ReactElement = require("./ReactElement");
|
|
22
24
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
23
25
|
var ReactDOM = require("./ReactDOM");
|
|
24
26
|
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
27
|
+
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
|
|
25
28
|
var ReactDefaultInjection = require("./ReactDefaultInjection");
|
|
26
29
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
27
|
-
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
28
30
|
var ReactMount = require("./ReactMount");
|
|
29
31
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
30
32
|
var ReactPerf = require("./ReactPerf");
|
|
31
33
|
var ReactPropTypes = require("./ReactPropTypes");
|
|
34
|
+
var ReactRef = require("./ReactRef");
|
|
32
35
|
var ReactServerRendering = require("./ReactServerRendering");
|
|
33
|
-
var ReactTextComponent = require("./ReactTextComponent");
|
|
34
36
|
|
|
35
37
|
var assign = require("./Object.assign");
|
|
36
|
-
var
|
|
38
|
+
var findDOMNode = require("./findDOMNode");
|
|
37
39
|
var onlyChild = require("./onlyChild");
|
|
38
40
|
|
|
39
41
|
ReactDefaultInjection.inject();
|
|
@@ -46,14 +48,6 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
46
48
|
createFactory = ReactElementValidator.createFactory;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
// TODO: Drop legacy elements once classes no longer export these factories
|
|
50
|
-
createElement = ReactLegacyElement.wrapCreateElement(
|
|
51
|
-
createElement
|
|
52
|
-
);
|
|
53
|
-
createFactory = ReactLegacyElement.wrapCreateFactory(
|
|
54
|
-
createFactory
|
|
55
|
-
);
|
|
56
|
-
|
|
57
51
|
var render = ReactPerf.measure('React', 'render', ReactMount.render);
|
|
58
52
|
|
|
59
53
|
var React = {
|
|
@@ -68,51 +62,24 @@ var React = {
|
|
|
68
62
|
initializeTouchEvents: function(shouldUseTouch) {
|
|
69
63
|
EventPluginUtils.useTouchEvents = shouldUseTouch;
|
|
70
64
|
},
|
|
71
|
-
createClass:
|
|
65
|
+
createClass: ReactClass.createClass,
|
|
72
66
|
createElement: createElement,
|
|
73
67
|
createFactory: createFactory,
|
|
68
|
+
createRef: function() {
|
|
69
|
+
return new ReactRef();
|
|
70
|
+
},
|
|
74
71
|
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
|
|
75
72
|
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
|
|
73
|
+
findDOMNode: findDOMNode,
|
|
76
74
|
render: render,
|
|
77
75
|
renderToString: ReactServerRendering.renderToString,
|
|
78
76
|
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
|
79
77
|
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
|
80
|
-
isValidClass: ReactLegacyElement.isValidClass,
|
|
81
78
|
isValidElement: ReactElement.isValidElement,
|
|
82
79
|
withContext: ReactContext.withContext,
|
|
83
80
|
|
|
84
81
|
// Hook for JSX spread, don't use this for anything else.
|
|
85
|
-
__spread: assign
|
|
86
|
-
|
|
87
|
-
// Deprecations (remove for 0.13)
|
|
88
|
-
renderComponent: deprecated(
|
|
89
|
-
'React',
|
|
90
|
-
'renderComponent',
|
|
91
|
-
'render',
|
|
92
|
-
this,
|
|
93
|
-
render
|
|
94
|
-
),
|
|
95
|
-
renderComponentToString: deprecated(
|
|
96
|
-
'React',
|
|
97
|
-
'renderComponentToString',
|
|
98
|
-
'renderToString',
|
|
99
|
-
this,
|
|
100
|
-
ReactServerRendering.renderToString
|
|
101
|
-
),
|
|
102
|
-
renderComponentToStaticMarkup: deprecated(
|
|
103
|
-
'React',
|
|
104
|
-
'renderComponentToStaticMarkup',
|
|
105
|
-
'renderToStaticMarkup',
|
|
106
|
-
this,
|
|
107
|
-
ReactServerRendering.renderToStaticMarkup
|
|
108
|
-
),
|
|
109
|
-
isValidComponent: deprecated(
|
|
110
|
-
'React',
|
|
111
|
-
'isValidComponent',
|
|
112
|
-
'isValidElement',
|
|
113
|
-
this,
|
|
114
|
-
ReactElement.isValidElement
|
|
115
|
-
)
|
|
82
|
+
__spread: assign
|
|
116
83
|
};
|
|
117
84
|
|
|
118
85
|
// Inject the runtime into a devtools global hook regardless of browser.
|
|
@@ -128,7 +95,7 @@ if (
|
|
|
128
95
|
InstanceHandles: ReactInstanceHandles,
|
|
129
96
|
Mount: ReactMount,
|
|
130
97
|
MultiChild: ReactMultiChild,
|
|
131
|
-
TextComponent:
|
|
98
|
+
TextComponent: ReactDOMTextComponent
|
|
132
99
|
});
|
|
133
100
|
}
|
|
134
101
|
|
|
@@ -177,8 +144,6 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
177
144
|
}
|
|
178
145
|
}
|
|
179
146
|
|
|
180
|
-
|
|
181
|
-
// internal version.
|
|
182
|
-
React.version = '0.12.2';
|
|
147
|
+
React.version = '0.13.0-alpha.1';
|
|
183
148
|
|
|
184
149
|
module.exports = React;
|
|
@@ -11,10 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var ReactMount = require("./ReactMount");
|
|
16
|
-
|
|
17
|
-
var invariant = require("./invariant");
|
|
14
|
+
var findDOMNode = require("./findDOMNode");
|
|
18
15
|
|
|
19
16
|
var ReactBrowserComponentMixin = {
|
|
20
17
|
/**
|
|
@@ -25,14 +22,7 @@ var ReactBrowserComponentMixin = {
|
|
|
25
22
|
* @protected
|
|
26
23
|
*/
|
|
27
24
|
getDOMNode: function() {
|
|
28
|
-
|
|
29
|
-
this.isMounted(),
|
|
30
|
-
'getDOMNode(): A component must be mounted to have a DOM node.'
|
|
31
|
-
) : invariant(this.isMounted()));
|
|
32
|
-
if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return ReactMount.getNode(this._rootNodeID);
|
|
25
|
+
return findDOMNode(this);
|
|
36
26
|
}
|
|
37
27
|
};
|
|
38
28
|
|
|
@@ -183,8 +183,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
|
|
183
183
|
*/
|
|
184
184
|
isEnabled: function() {
|
|
185
185
|
return !!(
|
|
186
|
-
ReactBrowserEventEmitter.ReactEventListener &&
|
|
187
|
-
ReactBrowserEventEmitter.ReactEventListener.isEnabled()
|
|
186
|
+
(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled())
|
|
188
187
|
);
|
|
189
188
|
},
|
|
190
189
|
|
|
@@ -219,8 +218,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
|
|
219
218
|
for (var i = 0, l = dependencies.length; i < l; i++) {
|
|
220
219
|
var dependency = dependencies[i];
|
|
221
220
|
if (!(
|
|
222
|
-
isListening.hasOwnProperty(dependency) &&
|
|
223
|
-
isListening[dependency]
|
|
221
|
+
(isListening.hasOwnProperty(dependency) && isListening[dependency])
|
|
224
222
|
)) {
|
|
225
223
|
if (dependency === topLevelTypes.topWheel) {
|
|
226
224
|
if (isEventSupported('wheel')) {
|
|
@@ -28,12 +28,14 @@ var ReactCSSTransitionGroup = React.createClass({
|
|
|
28
28
|
|
|
29
29
|
propTypes: {
|
|
30
30
|
transitionName: React.PropTypes.string.isRequired,
|
|
31
|
+
transitionAppear: React.PropTypes.bool,
|
|
31
32
|
transitionEnter: React.PropTypes.bool,
|
|
32
33
|
transitionLeave: React.PropTypes.bool
|
|
33
34
|
},
|
|
34
35
|
|
|
35
36
|
getDefaultProps: function() {
|
|
36
37
|
return {
|
|
38
|
+
transitionAppear: false,
|
|
37
39
|
transitionEnter: true,
|
|
38
40
|
transitionLeave: true
|
|
39
41
|
};
|
|
@@ -46,6 +48,7 @@ var ReactCSSTransitionGroup = React.createClass({
|
|
|
46
48
|
return ReactCSSTransitionGroupChild(
|
|
47
49
|
{
|
|
48
50
|
name: this.props.transitionName,
|
|
51
|
+
appear: this.props.transitionAppear,
|
|
49
52
|
enter: this.props.transitionEnter,
|
|
50
53
|
leave: this.props.transitionLeave
|
|
51
54
|
},
|
|
@@ -107,6 +107,14 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
109
|
|
|
110
|
+
componentWillAppear: function(done) {
|
|
111
|
+
if (this.props.appear) {
|
|
112
|
+
this.transition('appear', done);
|
|
113
|
+
} else {
|
|
114
|
+
done();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
110
118
|
componentWillEnter: function(done) {
|
|
111
119
|
if (this.props.enter) {
|
|
112
120
|
this.transition('enter', done);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014, 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 ReactChildReconciler
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
var flattenChildren = require("./flattenChildren");
|
|
16
|
+
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
17
|
+
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ReactChildReconciler provides helpers for initializing or updating a set of
|
|
21
|
+
* children. Its output is suitable for passing it onto ReactMultiChild which
|
|
22
|
+
* does diffed reordering and insertion.
|
|
23
|
+
*/
|
|
24
|
+
var ReactChildReconciler = {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generates a "mount image" for each of the supplied children. In the case
|
|
28
|
+
* of `ReactDOMComponent`, a mount image is a string of markup.
|
|
29
|
+
*
|
|
30
|
+
* @param {?object} nestedChildNodes Nested child maps.
|
|
31
|
+
* @return {?object} A set of child instances.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
instantiateChildren: function(nestedChildNodes, transaction, context) {
|
|
35
|
+
var children = flattenChildren(nestedChildNodes);
|
|
36
|
+
for (var name in children) {
|
|
37
|
+
if (children.hasOwnProperty(name)) {
|
|
38
|
+
var child = children[name];
|
|
39
|
+
// The rendered children must be turned into instances as they're
|
|
40
|
+
// mounted.
|
|
41
|
+
var childInstance = instantiateReactComponent(child, null);
|
|
42
|
+
children[name] = childInstance;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return children;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Updates the rendered children and returns a new set of children.
|
|
50
|
+
*
|
|
51
|
+
* @param {?object} prevChildren Previously initialized set of children.
|
|
52
|
+
* @param {?object} nextNestedChildNodes Nested child maps.
|
|
53
|
+
* @param {ReactReconcileTransaction} transaction
|
|
54
|
+
* @param {object} context
|
|
55
|
+
* @return {?object} A new set of child instances.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
updateChildren: function(
|
|
59
|
+
prevChildren,
|
|
60
|
+
nextNestedChildNodes,
|
|
61
|
+
transaction,
|
|
62
|
+
context) {
|
|
63
|
+
// We currently don't have a way to track moves here but if we use iterators
|
|
64
|
+
// instead of for..in we can zip the iterators and check if an item has
|
|
65
|
+
// moved.
|
|
66
|
+
// TODO: If nothing has changed, return the prevChildren object so that we
|
|
67
|
+
// can quickly bailout if nothing has changed.
|
|
68
|
+
var nextChildren = flattenChildren(nextNestedChildNodes);
|
|
69
|
+
if (!nextChildren && !prevChildren) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
var name;
|
|
73
|
+
for (name in nextChildren) {
|
|
74
|
+
if (!nextChildren.hasOwnProperty(name)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
var prevChild = prevChildren && prevChildren[name];
|
|
78
|
+
var prevElement = prevChild && prevChild._currentElement;
|
|
79
|
+
var nextElement = nextChildren[name];
|
|
80
|
+
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
81
|
+
prevChild.receiveComponent(nextElement, transaction, context);
|
|
82
|
+
nextChildren[name] = prevChild;
|
|
83
|
+
} else {
|
|
84
|
+
if (prevChild) {
|
|
85
|
+
prevChild.unmountComponent();
|
|
86
|
+
}
|
|
87
|
+
// The child must be instantiated before it's mounted.
|
|
88
|
+
var nextChildInstance = instantiateReactComponent(
|
|
89
|
+
nextElement,
|
|
90
|
+
null
|
|
91
|
+
);
|
|
92
|
+
nextChildren[name] = nextChildInstance;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Unmount children that are no longer present.
|
|
96
|
+
for (name in prevChildren) {
|
|
97
|
+
if (prevChildren.hasOwnProperty(name) &&
|
|
98
|
+
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
99
|
+
prevChildren[name].unmountComponent();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return nextChildren;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Unmounts all rendered children. This should be used to clean up children
|
|
107
|
+
* when this component is unmounted.
|
|
108
|
+
*
|
|
109
|
+
* @param {?object} renderedChildren Previously initialized set of children.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
unmountChildren: function(renderedChildren) {
|
|
113
|
+
for (var name in renderedChildren) {
|
|
114
|
+
var renderedChild = renderedChildren[name];
|
|
115
|
+
renderedChild.unmountComponent();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
module.exports = ReactChildReconciler;
|