mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-27 22:54:46 +08:00
Update core libraries for React 0.14 final
Summary: All minor changes since we were already on the beta: most notable is that destructors are required in pooling to help prevent memory leaks. public Reviewed By: sebmarkbage Differential Revision: D2608692 fb-gh-sync-id: acdad38768f7f48c0f0e7e44cbff6f0db316f4ca
This commit is contained in:
committed by
facebook-github-bot-7
parent
3b9cc4c2a5
commit
bbee3c6f60
18
.flowconfig
18
.flowconfig
@@ -7,12 +7,18 @@
|
||||
# Some modules have their own node_modules with overlap
|
||||
.*/node_modules/node-haste/.*
|
||||
|
||||
# Ignore react-tools where there are overlaps, but don't ignore anything that
|
||||
# react-native relies on
|
||||
.*/node_modules/react-tools/src/React.js
|
||||
.*/node_modules/react-tools/src/renderers/shared/event/EventPropagators.js
|
||||
.*/node_modules/react-tools/src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
|
||||
.*/node_modules/react-tools/src/shared/vendor/core/ExecutionEnvironment.js
|
||||
# Ignore react and fbjs where there are overlaps, but don't ignore
|
||||
# anything that react-native relies on
|
||||
.*/node_modules/fbjs-haste/.*/__tests__/.*
|
||||
.*/node_modules/fbjs-haste/__forks__/Map.js
|
||||
.*/node_modules/fbjs-haste/__forks__/Promise.js
|
||||
.*/node_modules/fbjs-haste/__forks__/fetch.js
|
||||
.*/node_modules/fbjs-haste/core/ExecutionEnvironment.js
|
||||
.*/node_modules/fbjs-haste/core/isEmpty.js
|
||||
.*/node_modules/fbjs-haste/crypto/crc32.js
|
||||
.*/node_modules/fbjs-haste/stubs/ErrorUtils.js
|
||||
.*/node_modules/react-haste/React.js
|
||||
.*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
|
||||
|
||||
# Ignore commoner tests
|
||||
.*/node_modules/commoner/test/.*
|
||||
|
||||
@@ -20,6 +20,11 @@ function BoundingDimensions(width, height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
BoundingDimensions.prototype.destructor = function() {
|
||||
this.width = null;
|
||||
this.height = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} element Element to return `BoundingDimensions` for.
|
||||
* @return {BoundingDimensions} Bounding dimensions of `element`.
|
||||
|
||||
@@ -21,6 +21,11 @@ function Position(left, top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
Position.prototype.destructor = function() {
|
||||
this.left = null;
|
||||
this.top = null;
|
||||
};
|
||||
|
||||
PooledClass.addPoolingTo(Position, twoArgumentPooler);
|
||||
|
||||
module.exports = Position;
|
||||
|
||||
@@ -34,6 +34,10 @@ function instanceNumberToChildRootID(rootNodeID, instanceNumber) {
|
||||
* here.
|
||||
*/
|
||||
var TopLevelWrapper = function() {};
|
||||
TopLevelWrapper.prototype.isReactComponent = {};
|
||||
if (__DEV__) {
|
||||
TopLevelWrapper.displayName = 'TopLevelWrapper';
|
||||
}
|
||||
TopLevelWrapper.prototype.render = function() {
|
||||
// this.props is actually a ReactElement
|
||||
return this.props;
|
||||
@@ -111,6 +115,8 @@ var ReactNativeMount = {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
nextElement
|
||||
);
|
||||
|
||||
|
||||
163
Libraries/vendor/react/event/EventPropagators.js
vendored
163
Libraries/vendor/react/event/EventPropagators.js
vendored
@@ -1,163 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2014 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @providesModule EventPropagators
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var EventConstants = require('EventConstants');
|
||||
var EventPluginHub = require('EventPluginHub');
|
||||
|
||||
var accumulateInto = require('accumulateInto');
|
||||
var forEachAccumulated = require('forEachAccumulated');
|
||||
|
||||
var PropagationPhases = EventConstants.PropagationPhases;
|
||||
var getListener = EventPluginHub.getListener;
|
||||
|
||||
/**
|
||||
* Some event types have a notion of different registration names for different
|
||||
* "phases" of propagation. This finds listeners by a given phase.
|
||||
*/
|
||||
function listenerAtPhase(id, event, propagationPhase) {
|
||||
var registrationName =
|
||||
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
||||
return getListener(id, registrationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
|
||||
* here, allows us to not have to bind or create functions for each event.
|
||||
* Mutating the event's members allows us to not have to create a wrapping
|
||||
* "dispatch" object that pairs the event with the listener.
|
||||
*/
|
||||
function accumulateDirectionalDispatches(domID, upwards, event) {
|
||||
if (__DEV__) {
|
||||
if (!domID) {
|
||||
throw new Error('Dispatching id must not be null');
|
||||
}
|
||||
}
|
||||
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
||||
var listener = listenerAtPhase(domID, event, phase);
|
||||
if (listener) {
|
||||
event._dispatchListeners =
|
||||
accumulateInto(event._dispatchListeners, listener);
|
||||
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect dispatches (must be entirely collected before dispatching - see unit
|
||||
* tests). Lazily allocate the array to conserve memory. We must loop through
|
||||
* each event and perform the traversal for each one. We can not perform a
|
||||
* single traversal for the entire collection of events because each event may
|
||||
* have a different target.
|
||||
*/
|
||||
function accumulateTwoPhaseDispatchesSingle(event) {
|
||||
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
|
||||
event.dispatchMarker,
|
||||
accumulateDirectionalDispatches,
|
||||
event
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
|
||||
*/
|
||||
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
||||
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(
|
||||
event.dispatchMarker,
|
||||
accumulateDirectionalDispatches,
|
||||
event
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Accumulates without regard to direction, does not look for phased
|
||||
* registration names. Same as `accumulateDirectDispatchesSingle` but without
|
||||
* requiring that the `dispatchMarker` be the same as the dispatched ID.
|
||||
*/
|
||||
function accumulateDispatches(id, ignoredDirection, event) {
|
||||
if (event && event.dispatchConfig.registrationName) {
|
||||
var registrationName = event.dispatchConfig.registrationName;
|
||||
var listener = getListener(id, registrationName);
|
||||
if (listener) {
|
||||
event._dispatchListeners =
|
||||
accumulateInto(event._dispatchListeners, listener);
|
||||
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accumulates dispatches on an `SyntheticEvent`, but only for the
|
||||
* `dispatchMarker`.
|
||||
* @param {SyntheticEvent} event
|
||||
*/
|
||||
function accumulateDirectDispatchesSingle(event) {
|
||||
if (event && event.dispatchConfig.registrationName) {
|
||||
accumulateDispatches(event.dispatchMarker, null, event);
|
||||
}
|
||||
}
|
||||
|
||||
function accumulateTwoPhaseDispatches(events) {
|
||||
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
||||
}
|
||||
|
||||
function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
||||
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
||||
}
|
||||
|
||||
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
|
||||
fromID,
|
||||
toID,
|
||||
accumulateDispatches,
|
||||
leave,
|
||||
enter
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function accumulateDirectDispatches(events) {
|
||||
forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A small set of propagation patterns, each of which will accept a small amount
|
||||
* of information, and generate a set of "dispatch ready event objects" - which
|
||||
* are sets of events that have already been annotated with a set of dispatched
|
||||
* listener functions/ids. The API is designed this way to discourage these
|
||||
* propagation strategies from actually executing the dispatches, since we
|
||||
* always want to collect the entire set of dispatches before executing event a
|
||||
* single one.
|
||||
*
|
||||
* @constructor EventPropagators
|
||||
*/
|
||||
var EventPropagators = {
|
||||
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
|
||||
accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
|
||||
accumulateDirectDispatches: accumulateDirectDispatches,
|
||||
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
||||
};
|
||||
|
||||
module.exports = EventPropagators;
|
||||
@@ -13,37 +13,58 @@ var path = require('path');
|
||||
// Don't forget to everything listed here to `testConfig.json`
|
||||
// modulePathIgnorePatterns.
|
||||
var sharedBlacklist = [
|
||||
'node_modules/react-tools/src/React.js',
|
||||
'node_modules/react-tools/src/renderers/shared/event/EventPropagators.js',
|
||||
'node_modules/react-tools/src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js',
|
||||
'node_modules/react-tools/src/shared/vendor/core/ExecutionEnvironment.js',
|
||||
'node_modules/react-tools/docs/js/react.js',
|
||||
'node_modules/react-tools/src/package.json',
|
||||
'node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js',
|
||||
'node_modules/react-haste/React.js',
|
||||
|
||||
// Those conflicts with the ones in react-tools/. We need to blacklist the
|
||||
// For each of these fbjs files (especially the non-forks/stubs), we should
|
||||
// consider deleting the conflicting copy and just using the fbjs version.
|
||||
'node_modules/fbjs-haste/__forks__/Map.js',
|
||||
'node_modules/fbjs-haste/__forks__/Promise.js',
|
||||
'node_modules/fbjs-haste/__forks__/fetch.js',
|
||||
'node_modules/fbjs-haste/core/Deferred.js',
|
||||
'node_modules/fbjs-haste/core/PromiseMap.js',
|
||||
'node_modules/fbjs-haste/core/areEqual.js',
|
||||
'node_modules/fbjs-haste/core/flattenArray.js',
|
||||
'node_modules/fbjs-haste/core/isEmpty.js',
|
||||
'node_modules/fbjs-haste/core/removeFromArray.js',
|
||||
'node_modules/fbjs-haste/core/resolveImmediate.js',
|
||||
'node_modules/fbjs-haste/core/sprintf.js',
|
||||
'node_modules/fbjs-haste/crypto/crc32.js',
|
||||
'node_modules/fbjs-haste/fetch/fetchWithRetries.js',
|
||||
'node_modules/fbjs-haste/functional/everyObject.js',
|
||||
'node_modules/fbjs-haste/functional/filterObject.js',
|
||||
'node_modules/fbjs-haste/functional/forEachObject.js',
|
||||
'node_modules/fbjs-haste/functional/someObject.js',
|
||||
'node_modules/fbjs-haste/request/xhrSimpleDataSerializer.js',
|
||||
'node_modules/fbjs-haste/stubs/ErrorUtils.js',
|
||||
'node_modules/fbjs-haste/stubs/URI.js',
|
||||
'node_modules/fbjs-haste/useragent/UserAgent.js',
|
||||
'node_modules/fbjs-haste/utils/nullthrows.js',
|
||||
|
||||
// Those conflicts with the ones in fbjs-haste/. We need to blacklist the
|
||||
// internal version otherwise they won't work in open source.
|
||||
'downstream/core/invariant.js',
|
||||
'downstream/key-mirror/keyMirror.js',
|
||||
'downstream/core/CSSCore.js',
|
||||
'downstream/core/TouchEventUtils.js',
|
||||
'downstream/core/camelize.js',
|
||||
'downstream/core/createArrayFromMixed.js',
|
||||
'downstream/core/createNodesFromMarkup.js',
|
||||
'downstream/core/dom/containsNode.js',
|
||||
'downstream/core/dom/focusNode.js',
|
||||
'downstream/core/dom/getActiveElement.js',
|
||||
'downstream/core/dom/getUnboundedScrollPosition.js',
|
||||
'downstream/core/dom/isNode.js',
|
||||
'downstream/core/dom/isTextNode.js',
|
||||
'downstream/core/emptyFunction.js',
|
||||
'downstream/core/emptyObject.js',
|
||||
'downstream/key-mirror/keyOf.js',
|
||||
'downstream/core/dom/isNode.js',
|
||||
'downstream/core/TouchEventUtils.js',
|
||||
'downstream/core/nativeRequestAnimationFrame.js',
|
||||
'downstream/core/dom/containsNode.js',
|
||||
'downstream/core/dom/isTextNode.js',
|
||||
'downstream/functional/mapObject.js',
|
||||
'downstream/core/camelize.js',
|
||||
'downstream/core/hyphenate.js',
|
||||
'downstream/core/createArrayFromMixed.js',
|
||||
'downstream/core/toArray.js',
|
||||
'downstream/core/dom/getActiveElement.js',
|
||||
'downstream/core/dom/focusNode.js',
|
||||
'downstream/core/dom/getUnboundedScrollPosition.js',
|
||||
'downstream/core/createNodesFromMarkup.js',
|
||||
'downstream/core/CSSCore.js',
|
||||
'downstream/core/getMarkupWrap.js',
|
||||
'downstream/core/hyphenate.js',
|
||||
'downstream/core/hyphenateStyleName.js',
|
||||
'downstream/core/invariant.js',
|
||||
'downstream/core/nativeRequestAnimationFrame.js',
|
||||
'downstream/core/toArray.js',
|
||||
'downstream/functional/mapObject.js',
|
||||
'downstream/key-mirror/keyMirror.js',
|
||||
'downstream/key-mirror/keyOf.js',
|
||||
];
|
||||
|
||||
// Raw unescaped patterns in case you need to use wildcards
|
||||
|
||||
@@ -2245,9 +2245,9 @@ describe('DependencyGraph', function() {
|
||||
'require("wontWork");',
|
||||
].join('\n'),
|
||||
'node_modules': {
|
||||
'react-tools': {
|
||||
'react-haste': {
|
||||
'package.json': JSON.stringify({
|
||||
name: 'react-tools',
|
||||
name: 'react-haste',
|
||||
main: 'main.js',
|
||||
}),
|
||||
'main.js': [
|
||||
@@ -2315,7 +2315,7 @@ describe('DependencyGraph', function() {
|
||||
},
|
||||
{
|
||||
id: 'shouldWork',
|
||||
path: '/root/node_modules/react-tools/main.js',
|
||||
path: '/root/node_modules/react-haste/main.js',
|
||||
dependencies: ['submodule'],
|
||||
isAsset: false,
|
||||
isAsset_DEPRECATED: false,
|
||||
@@ -2325,7 +2325,7 @@ describe('DependencyGraph', function() {
|
||||
},
|
||||
{
|
||||
id: 'submodule/main.js',
|
||||
path: '/root/node_modules/react-tools/node_modules/submodule/main.js',
|
||||
path: '/root/node_modules/react-haste/node_modules/submodule/main.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
isAsset_DEPRECATED: false,
|
||||
@@ -2338,9 +2338,9 @@ describe('DependencyGraph', function() {
|
||||
});
|
||||
|
||||
pit('should not be confused by prev occuring whitelisted names', function() {
|
||||
var root = '/react-tools';
|
||||
var root = '/react-haste';
|
||||
fs.__setMockFilesystem({
|
||||
'react-tools': {
|
||||
'react-haste': {
|
||||
'index.js': [
|
||||
'/**',
|
||||
' * @providesModule index',
|
||||
@@ -2348,9 +2348,9 @@ describe('DependencyGraph', function() {
|
||||
'require("shouldWork");',
|
||||
].join('\n'),
|
||||
'node_modules': {
|
||||
'react-tools': {
|
||||
'react-haste': {
|
||||
'package.json': JSON.stringify({
|
||||
name: 'react-tools',
|
||||
name: 'react-haste',
|
||||
main: 'main.js',
|
||||
}),
|
||||
'main.js': [
|
||||
@@ -2369,12 +2369,12 @@ describe('DependencyGraph', function() {
|
||||
assetExts: ['png', 'jpg'],
|
||||
cache: cache,
|
||||
});
|
||||
return getOrderedDependenciesAsJSON(dgraph, '/react-tools/index.js').then(function(deps) {
|
||||
return getOrderedDependenciesAsJSON(dgraph, '/react-haste/index.js').then(function(deps) {
|
||||
expect(deps)
|
||||
.toEqual([
|
||||
{
|
||||
id: 'index',
|
||||
path: '/react-tools/index.js',
|
||||
path: '/react-haste/index.js',
|
||||
dependencies: ['shouldWork'],
|
||||
isAsset: false,
|
||||
isAsset_DEPRECATED: false,
|
||||
@@ -2384,7 +2384,7 @@ describe('DependencyGraph', function() {
|
||||
},
|
||||
{
|
||||
id: 'shouldWork',
|
||||
path: '/react-tools/node_modules/react-tools/main.js',
|
||||
path: '/react-haste/node_modules/react-haste/main.js',
|
||||
dependencies: [],
|
||||
isAsset: false,
|
||||
isAsset_DEPRECATED: false,
|
||||
|
||||
@@ -49,7 +49,8 @@ const validateOpts = declareOpts({
|
||||
providesModuleNodeModules: {
|
||||
type: 'array',
|
||||
default: [
|
||||
'react-tools',
|
||||
'fbjs-haste',
|
||||
'react-haste',
|
||||
'react-native',
|
||||
// Parse requires AsyncStorage. They will
|
||||
// change that to require('react-native') which
|
||||
|
||||
Reference in New Issue
Block a user