Merge branch '15.6-dev' into 15-stable

This commit is contained in:
Dan Abramov
2017-06-15 00:34:49 +01:00
48 changed files with 126 additions and 756 deletions
-12
View File
@@ -80,14 +80,6 @@ module.exports = function(grunt) {
grunt.registerTask('npm-react-dom:release', npmReactDOMTasks.buildRelease);
grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease);
var npmReactNativeTasks = require('./grunt/tasks/npm-react-native');
grunt.registerTask('npm-react-native:release', npmReactNativeTasks.buildRelease);
grunt.registerTask('npm-react-native:pack', npmReactNativeTasks.packRelease);
var npmReactAddonsTasks = require('./grunt/tasks/npm-react-addons');
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);
var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);
@@ -178,10 +170,6 @@ module.exports = function(grunt) {
'npm-react:pack',
'npm-react-dom:release',
'npm-react-dom:pack',
'npm-react-native:release',
'npm-react-native:pack',
'npm-react-addons:release',
'npm-react-addons:pack',
'npm-react-test:release',
'npm-react-test:pack',
'compare_size',
+4 -3
View File
@@ -46,9 +46,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -44,9 +44,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -47,9 +47,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -45,9 +45,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -45,9 +45,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -41,9 +41,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
+4 -3
View File
@@ -41,9 +41,10 @@ env.beforeEach(() => {
compare(actual) {
return {
pass: callCount === 0,
message: 'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
message:
'Expected test not to warn. If the warning is expected, mock ' +
"it out using spyOn(console, 'error'); and test that the " +
'warning occurs.'
};
}
};
-151
View File
@@ -1,151 +0,0 @@
'use strict';
var fs = require('fs');
var grunt = require('grunt');
var path = require('path');
var addons = {
CSSTransitionGroup: {
peerDependency: 'react',
module: 'ReactCSSTransitionGroup',
name: 'css-transition-group',
docs: 'animation',
},
LinkedStateMixin: {
peerDependency: 'react',
module: 'LinkedStateMixin',
name: 'linked-state-mixin',
docs: 'two-way-binding-helpers',
},
Perf: {
peerDependency: 'react-dom',
module: 'ReactPerf',
name: 'perf',
docs: 'perf',
},
PureRenderMixin: {
peerDependency: 'react',
module: 'ReactComponentWithPureRenderMixin',
name: 'pure-render-mixin',
docs: 'pure-render-mixin',
},
TestUtils: {
peerDependency: 'react-dom',
module: 'ReactTestUtils',
name: 'test-utils',
docs: 'test-utils',
},
TransitionGroup: {
peerDependency: 'react',
module: 'ReactTransitionGroup',
name: 'transition-group',
docs: 'animation',
},
createFragment: {
peerDependency: 'react',
module: 'ReactFragment',
method: 'create',
name: 'create-fragment',
docs: 'create-fragment',
},
shallowCompare: {
peerDependency: 'react',
module: 'shallowCompare',
name: 'shallow-compare',
docs: 'shallow-compare',
},
updates: {
peerDependency: 'react',
module: 'update',
name: 'update',
docs: 'update',
},
};
function generateSource(info) {
var pieces = [
'module.exports = require(\'',
info.peerDependency,
'/lib/',
info.module,
'\')',
];
if (info.method) {
pieces.push('.', info.method);
}
pieces.push(';');
return pieces.join('');
}
function buildReleases() {
var pkgTemplate = grunt.file.readJSON('./packages/react-addons/package.json');
Object.keys(addons).map(function(k) {
var info = addons[k];
var pkgName = 'react-addons-' + info.name;
var destDir = 'build/packages/' + pkgName;
var destLicense = path.join(destDir, 'LICENSE');
var destPatents = path.join(destDir, 'PATENTS');
var pkgData = Object.assign({}, pkgTemplate);
pkgData.name = pkgName;
var version = pkgTemplate.peerDependencies.react;
if (info.peerDependency !== 'react') {
pkgData.peerDependencies = {};
pkgData.peerDependencies[info.peerDependency] = version;
}
grunt.file.mkdir(destDir);
var link = info.docs ? info.docs : 'addons';
link = `https://facebook.github.io/react/docs/${link}.html`;
fs.writeFileSync(path.join(destDir, 'index.js'), generateSource(info));
fs.writeFileSync(path.join(destDir, 'package.json'), JSON.stringify(pkgData, null, 2));
grunt.file.copy('LICENSE', destLicense);
grunt.file.copy('PATENTS', destPatents);
fs.writeFileSync(
path.join(destDir, 'README.md'),
`
# ${pkgName}
This package provides the React ${k} add-on.
See <${link}> for more information.`.slice(1)
);
});
}
function packReleases() {
var done = this.async();
var count = 0;
var addonKeys = Object.keys(addons);
addonKeys.forEach(function(k) {
var info = addons[k];
var pkgName = 'react-addons-' + info.name;
var pkgDir = 'build/packages/' + pkgName;
var spawnCmd = {
cmd: 'npm',
args: ['pack', pkgDir],
};
grunt.util.spawn(spawnCmd, function() {
var buildSrc = pkgName + '-' + grunt.config.data.pkg.version + '.tgz';
var buildDest = 'build/packages/' + pkgName + '.tgz';
fs.rename(buildSrc, buildDest, maybeDone);
});
});
function maybeDone() {
if (++count === addonKeys.length) {
done();
}
}
}
module.exports = {
buildReleases: buildReleases,
packReleases: packReleases,
};
-52
View File
@@ -1,52 +0,0 @@
'use strict';
var fs = require('fs');
var grunt = require('grunt');
var src = 'packages/react-native-renderer/';
var dest = 'build/packages/react-native-renderer/';
var modSrc = 'build/node_modules/react-native/lib';
var lib = dest + 'lib/';
function buildRelease() {
if (grunt.file.exists(dest)) {
grunt.file.delete(dest);
}
// Copy to build/packages/react-native-renderer
var mappings = [].concat(
grunt.file.expandMapping('**/*', dest, {cwd: src}),
grunt.file.expandMapping('**/*', lib, {cwd: modSrc}),
grunt.file.expandMapping('{LICENSE,PATENTS}', dest)
);
mappings.forEach(function(mapping) {
var mappingSrc = mapping.src[0];
var mappingDest = mapping.dest;
if (grunt.file.isDir(mappingSrc)) {
grunt.file.mkdir(mappingDest);
} else {
grunt.file.copy(mappingSrc, mappingDest);
}
});
}
function packRelease() {
var done = this.async();
var spawnCmd = {
cmd: 'npm',
args: ['pack', 'packages/react-native-renderer'],
opts: {
cwd: 'build/',
},
};
grunt.util.spawn(spawnCmd, function() {
var buildSrc = 'build/react-native-renderer-' + grunt.config.data.pkg.version + '.tgz';
var buildDest = 'build/packages/react-native-renderer.tgz';
fs.rename(buildSrc, buildDest, done);
});
}
module.exports = {
buildRelease: buildRelease,
packRelease: packRelease,
};
-7
View File
@@ -15,18 +15,11 @@ module.exports = function(gulp, plugins) {
return function(done) {
var reactVersion = require('../../package.json').version;
var addonsData = require('../../packages/react-addons/package.json');
var versions = {
'packages/react/package.json':
require('../../packages/react/package.json').version,
'packages/react-dom/package.json':
require('../../packages/react-dom/package.json').version,
'packages/react-native-renderer/package.json':
require('../../packages/react-native-renderer/package.json').version,
'packages/react-addons/package.json (version)': addonsData.version,
'packages/react-addons/package.json (react dependency)':
// Get the "version" without the range bit
addonsData.peerDependencies.react.slice(1),
'packages/react-test-renderer/package.json':
require('../../packages/react-test-renderer/package.json').version,
'src/ReactVersion.js': require('../../src/ReactVersion'),
@@ -1 +0,0 @@
node_modules
@@ -1,31 +0,0 @@
# JSX Orphaned Brackets Transformer
React 0.13 no longer parses orphaned > and } as text.
Take this example block:
```js
<div>
> }
</div>
```
In 0.12 and below, this would be transformed to the following:
```js
React.DOM.div(null,
"> }",
)
```
In 0.13, this will instead throw a parser error.
## Usage
The `jsx_orphaned_brackets_transformer` module ships an executable which transforms a file or directory of files. Files will be modified in place, so be sure you are prepared for that.
```sh
$ npm -g install jsx_orphaned_brackets_transformer
$ jsx_orphaned_brackets_transformer <path_to_file_or_files>
```
@@ -1,17 +0,0 @@
{
"name": "jsx_orphaned_brackets_transformer",
"description": "A utility to update your JSX to work with React 0.13.",
"version": "1.0.1",
"main": "run.js",
"dependencies": {
"graceful-fs": "~2.0.0",
"jstransform": "~8.2.0",
"node-find-files": "0.0.2",
"optimist": "~0.6.0"
},
"bin": {
"jsx_orphaned_brackets_transformer": "./run.js"
},
"license": "BSD-3-Clause",
"preferGlobal": true
}
@@ -1,166 +0,0 @@
#!/usr/bin/env node
'use strict';
var FileFinder = require('node-find-files');
var fs = require('graceful-fs');
var jstransform = require('jstransform');
var path = require('path');
var visitReactTag = require('./transforms/react').visitReactTag;
/*eslint-disable no-shadow*/
var S = jstransform.Syntax;
var USAGE =
'Read a file (or directory of files) from disk, transform any orphaned ' +
'} and > characters to avoid parser errors with React 0.13.';
function _visitFbt(node, path, state) {
return false;
}
_visitFbt.test = function(node, path, state) {
return node.type === S.XJSElement
&& node.openingElement.name.name === 'fbt';
};
var VISITORS_LIST = [
_visitFbt,
visitReactTag,
];
function _transformSource(source) {
return jstransform.transform(VISITORS_LIST, source).code;
}
function transformDir(dirPath, exclude) {
var finder = new FileFinder({
rootFolder: dirPath,
filterFunction: function(path, stat) {
return /\.jsx?$/.test(path) && (!exclude || !exclude.test(path));
},
});
var numTransforms = 0;
var completeTransforms = 0;
var findingComplete = false;
function _printProgress() {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(
completeTransforms + '/' + numTransforms + ' transforms complete'
);
if (findingComplete && completeTransforms === numTransforms) {
console.log('\ndone!');
}
}
finder.on('match', function(pathStr, stat) {
fs.readFile(pathStr, 'utf8', function(err, data) {
if (err) {
err.message = err.message + ' (' + pathStr + ')';
throw err;
}
numTransforms++;
_printProgress();
var transformedData;
try {
transformedData = _transformSource(data);
} catch (e) {
e.message = e.message + ' (' + pathStr + ')';
throw e;
}
if (transformedData !== data) {
fs.writeFile(pathStr, transformedData, function(err) {
if (err) {
err.message = err.message + ' (' + pathStr + ')';
throw err;
}
completeTransforms++;
_printProgress();
});
} else {
completeTransforms++;
_printProgress();
}
});
});
finder.on('error', function(err) {
console.log('\nError: ', err.stack);
throw err;
});
finder.on('complete', function() {
findingComplete = true;
});
finder.startSearch();
}
function transformFile(pathStr) {
fs.readFile(pathStr, 'utf8', function(err, data) {
if (err) {
err.message = err.message + ' (' + pathStr + ')';
throw err;
}
var transformedData;
try {
transformedData = _transformSource(data);
} catch (e) {
e.message = e.message + ' (' + pathStr + ')';
throw e;
}
if (transformedData !== data) {
fs.writeFile(pathStr, transformedData, function(err) {
if (err) {
err.message = err.message + ' (' + pathStr + ')';
throw err;
}
console.log('done!');
});
} else {
console.log('done!');
}
});
}
if (require.main === module) {
var argv = require('optimist')
.usage(USAGE)
.argv;
if (argv._.length === 0) {
throw new Error(
'Please specify a file or directory path as the first arg!'
);
}
argv._.forEach(function(arg) {
var absPath = path.resolve(arg);
fs.stat(absPath, function(err, stat) {
if (err) {
throw err;
}
if (stat.isFile()) {
transformFile(absPath);
} else if (stat.isDirectory()) {
var exclude = null;
if (argv.exclude) {
exclude = new RegExp(argv.exclude);
}
transformDir(absPath, exclude);
} else {
throw new Error('Unknown filesystem node type: ' + absPath);
}
});
});
}
exports.transformDir = transformDir;
@@ -1,52 +0,0 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*global exports:true*/
'use strict';
var jstransform = require('jstransform');
var Syntax = jstransform.Syntax;
var utils = require('jstransform/src/utils');
function visitReactTag(traverse, object, path, state) {
object.openingElement.attributes.forEach(function(attr, index) {
if (attr.value) {
traverse(attr.value, path, state);
}
});
object.children.forEach(function(child, index) {
if (child.type === Syntax.Literal) {
codemodXJSLiteral(child, state);
} else {
traverse(child, path, state);
}
});
return false;
}
visitReactTag.test = function(object, path, state) {
return object.type === Syntax.XJSElement;
};
function codemodXJSLiteral(object, state) {
var value = object.raw;
utils.catchup(object.range[0], state);
var rightCurlyBracket = '&#125;'; // or {'}'}
var rightAngledBracket = '&gt;'; // or {'>'}
value = value.replace(/\}/g, rightCurlyBracket);
value = value.replace(/\>/g, rightAngledBracket);
utils.append(value, state);
utils.move(object.range[1], state);
}
exports.visitReactTag = visitReactTag;
-24
View File
@@ -1,24 +0,0 @@
{
"name": "react-addons-template",
"version": "15.6.0",
"main": "index.js",
"repository": "facebook/react",
"keywords": [
"react",
"react-addon"
],
"license": "BSD-3-Clause",
"dependencies": {
"fbjs": "^0.8.9",
"object-assign": "^4.1.0"
},
"peerDependencies": {
"react": "^15.6.0"
},
"files": [
"LICENSE",
"PATENTS",
"README.md",
"index.js"
]
}
+1 -1
View File
@@ -16,7 +16,7 @@
"fbjs": "^0.8.9",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.0",
"prop-types": "~15.5.7"
"prop-types": "^15.5.10"
},
"peerDependencies": {
"react": "^15.6.0-rc.1"
-27
View File
@@ -1,27 +0,0 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var React = require('react');
var LinkedValueUtils = require('react-dom/lib/LinkedValueUtils');
class LinkedInput extends React.Component {
render() {
var newProps = Object.assign({}, this.props);
newProps.value = LinkedValueUtils.getValue(this.props);
newProps.checked = LinkedValueUtils.getChecked(this.props);
delete newProps.valueLink;
delete newProps.checkedLink;
return React.createElement('input', newProps);
}
}
module.exports = LinkedInput;
-11
View File
@@ -1,11 +0,0 @@
This component supports the ReactLink API (valueLink, etc) for input components. Support for ReactLink on DOM elements will be removed from React. This component may be used as a migration plan (so your code doesn't break in the next version of React) or may be used if you just like the ReactLink data binding semantics. However, this component is not maintained, so use at your own risk.
```
var React = require('react');
var ReactDOM = require('react-dom');
var LinkedInput = require('react-linked-input');
var link = {value: 'boo', requestChange: function() {}};
React.render(<LinkedInput valueLink={link} />, container);
```
@@ -1,42 +0,0 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('LinkedStateMixin', function() {
var LinkedInput;
var React;
var ReactDOM;
beforeEach(function() {
LinkedInput = require('LinkedInput');
React = require('React');
ReactDOM = require('ReactDOM');
});
it('should basically work', function() {
var container = document.createElement('div');
var component = ReactDOM.render(<LinkedInput value="foo" onChange={function() {}} />, container);
var input = ReactDOM.findDOMNode(component);
expect(input.value).toBe('foo');
ReactDOM.render(<LinkedInput valueLink={{value: 'boo', requestChange: function() {}}} />, container);
expect(input.value).toBe('boo');
});
it('should throw', function() {
var container = document.createElement('div');
var element = <LinkedInput value="foo" valueLink={{value: 'boo', requestChange: function() {}}} />;
expect(function() {
ReactDOM.render(element, container);
}).toThrow();
});
});
-25
View File
@@ -1,25 +0,0 @@
{
"name": "react-linked-input",
"version": "1.0.0",
"description": "LinkedInput supports the ReactLink semantics",
"main": "LinkedInput.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/react.git"
},
"keywords": [
"react",
"linkedinput",
"input",
"linked",
"reactlink"
],
"author": "",
"license": "BSD-3-Clause",
"peerDependencies": {
"react": "^15.0.0"
}
}
-5
View File
@@ -1,5 +0,0 @@
# `react-native-renderer`
This package is the renderer that is used by the react-native package.
It is intended to be used inside the react-native environment. It is not
intended to be used stand alone.
-3
View File
@@ -1,3 +0,0 @@
'use strict';
module.exports = require('./lib/ReactNative');
@@ -1,30 +0,0 @@
{
"name": "react-native-renderer",
"version": "15.6.0",
"description": "React package for use inside react-native.",
"main": "index.js",
"repository": "facebook/react",
"keywords": [
"react",
"react-native"
],
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://facebook.github.io/react-native/",
"dependencies": {
"fbjs": "^0.8.9",
"object-assign": "^4.1.0"
},
"peerDependencies": {
"react": "^15.6.0-rc.1"
},
"files": [
"LICENSE",
"PATENTS",
"README.md",
"index.js",
"lib/"
]
}
+2 -2
View File
@@ -23,11 +23,11 @@
"node": ">=0.10.0"
},
"dependencies": {
"create-react-class": "^15.5.2",
"create-react-class": "^15.6.0",
"fbjs": "^0.8.9",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.0",
"prop-types": "^15.5.7"
"prop-types": "^15.5.10"
},
"browserify": {
"transform": [
+1 -2
View File
@@ -23,8 +23,7 @@ fi
# These seem out of order but extract-errors must be run after jest.
if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
COMMANDS_TO_RUN+=('./node_modules/.bin/gulp lint')
# Temporary: I can't figure out why it fails on CI but works locally
# COMMANDS_TO_RUN+=('node ./scripts/prettier/index')
COMMANDS_TO_RUN+=('node ./scripts/prettier/index')
COMMANDS_TO_RUN+=('./node_modules/.bin/gulp flow')
COMMANDS_TO_RUN+=('./node_modules/.bin/grunt build')
COMMANDS_TO_RUN+=('./scripts/circleci/test_extract_errors.sh')
@@ -40,7 +40,7 @@ function typeCheckFailRequiredValues(declaration) {
'`testComponent`, but its value is `null`.';
var unspecifiedMsg =
'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is \`undefined\`.';
'`testComponent`, but its value is `undefined`.';
var props1 = {testProp: null};
var error1 = declaration(
props1,
+2 -1
View File
@@ -47,7 +47,8 @@ if (
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
ComponentTree: {
getClosestInstanceFromNode: ReactDOMComponentTree.getClosestInstanceFromNode,
getClosestInstanceFromNode:
ReactDOMComponentTree.getClosestInstanceFromNode,
getNodeFromInstance: function(inst) {
// inst is an internal instance (but could be a composite)
if (inst._renderedComponent) {
@@ -84,10 +84,10 @@ var reactTopListenersCounter = 0;
var topEventMapping = {
topAbort: 'abort',
topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend',
topAnimationIteration: getVendorPrefixedEventName('animationiteration') ||
'animationiteration',
topAnimationStart: getVendorPrefixedEventName('animationstart') ||
'animationstart',
topAnimationIteration:
getVendorPrefixedEventName('animationiteration') || 'animationiteration',
topAnimationStart:
getVendorPrefixedEventName('animationstart') || 'animationstart',
topBlur: 'blur',
topCanPlay: 'canplay',
topCanPlayThrough: 'canplaythrough',
@@ -144,8 +144,8 @@ var topEventMapping = {
topTouchEnd: 'touchend',
topTouchMove: 'touchmove',
topTouchStart: 'touchstart',
topTransitionEnd: getVendorPrefixedEventName('transitionend') ||
'transitionend',
topTransitionEnd:
getVendorPrefixedEventName('transitionend') || 'transitionend',
topVolumeChange: 'volumechange',
topWaiting: 'waiting',
topWheel: 'wheel',
@@ -209,8 +209,10 @@ var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
* @return {boolean} True if callbacks are enabled.
*/
isEnabled: function() {
return !!(ReactBrowserEventEmitter.ReactEventListener &&
ReactBrowserEventEmitter.ReactEventListener.isEnabled());
return !!(
ReactBrowserEventEmitter.ReactEventListener &&
ReactBrowserEventEmitter.ReactEventListener.isEnabled()
);
},
/**
+15 -11
View File
@@ -216,9 +216,11 @@ function hasNonRootReactChild(container) {
*/
function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl &&
return !!(
rootEl &&
isReactNode(rootEl) &&
!ReactDOMComponentTree.getInstanceFromNode(rootEl));
!ReactDOMComponentTree.getInstanceFromNode(rootEl)
);
}
/**
@@ -229,10 +231,12 @@ function nodeIsRenderedByOtherInstance(container) {
* @internal
*/
function isValidContainer(node) {
return !!(node &&
return !!(
node &&
(node.nodeType === ELEMENT_NODE_TYPE ||
node.nodeType === DOC_NODE_TYPE ||
node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)
);
}
/**
@@ -445,13 +449,13 @@ var ReactMount = {
? " Instead of passing a string like 'div', pass " +
"React.createElement('div') or <div />."
: typeof nextElement === 'function'
? ' Instead of passing a class like Foo, pass ' +
'React.createElement(Foo) or <Foo />.'
: // Check if it quacks like an element
nextElement != null && nextElement.props !== undefined
? ' This may be caused by unintentionally loading two independent ' +
'copies of React.'
: '',
? ' Instead of passing a class like Foo, pass ' +
'React.createElement(Foo) or <Foo />.'
: // Check if it quacks like an element
nextElement != null && nextElement.props !== undefined
? ' This may be caused by unintentionally loading two independent ' +
'copies of React.'
: '',
);
warning(
@@ -29,9 +29,9 @@ var WheelEventInterface = {
? event.deltaY
: // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
'wheelDeltaY' in event
? -event.wheelDeltaY
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
'wheelDelta' in event ? -event.wheelDelta : 0;
? -event.wheelDeltaY
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
'wheelDelta' in event ? -event.wheelDelta : 0;
},
deltaZ: null,
+2 -2
View File
@@ -163,8 +163,8 @@ var DOMProperty = {
ROOT_ATTRIBUTE_NAME: 'data-reactroot',
ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR,
ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR +
'\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040',
ATTRIBUTE_NAME_CHAR:
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040',
/**
* Map from property "standard name" to an object with info about how to set
@@ -20,7 +20,8 @@ var ReactDOMIDOperations = require('ReactDOMIDOperations');
* need for this injection.
*/
var ReactComponentBrowserEnvironment = {
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
processChildrenUpdates:
ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup,
};
@@ -59,8 +59,8 @@ if (__DEV__) {
var standardName = DOMProperty.isCustomAttribute(lowerCasedName)
? lowerCasedName
: DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName)
? DOMProperty.getPossibleStandardName[lowerCasedName]
: null;
? DOMProperty.getPossibleStandardName[lowerCasedName]
: null;
var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(
lowerCasedName,
+2 -1
View File
@@ -41,7 +41,8 @@ var ReactNative = {
unstable_batchedUpdates: ReactUpdates.batchedUpdates,
/* eslint-enable camelcase */
unmountComponentAtNodeAndRemoveContainer: ReactNativeMount.unmountComponentAtNodeAndRemoveContainer,
unmountComponentAtNodeAndRemoveContainer:
ReactNativeMount.unmountComponentAtNodeAndRemoveContainer,
};
// Inject the runtime into a devtools global hook regardless of browser.
@@ -15,9 +15,11 @@ var ReactNativeDOMIDOperations = require('ReactNativeDOMIDOperations');
var ReactNativeReconcileTransaction = require('ReactNativeReconcileTransaction');
var ReactNativeComponentEnvironment = {
processChildrenUpdates: ReactNativeDOMIDOperations.dangerouslyProcessChildrenUpdates,
processChildrenUpdates:
ReactNativeDOMIDOperations.dangerouslyProcessChildrenUpdates,
replaceNodeWithMarkup: ReactNativeDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
replaceNodeWithMarkup:
ReactNativeDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
/**
* @param {DOMElement} Element to clear.
+8 -6
View File
@@ -118,9 +118,10 @@ function getTreeSnapshot(registeredIDs) {
updateCount: ReactComponentTreeHook.getUpdateCount(id),
childIDs: ReactComponentTreeHook.getChildIDs(id),
// Text nodes don't have owners but this is close enough.
ownerID: ownerID ||
(parentID && ReactComponentTreeHook.getOwnerID(parentID)) ||
0,
ownerID:
ownerID ||
(parentID && ReactComponentTreeHook.getOwnerID(parentID)) ||
0,
parentID,
};
return tree;
@@ -205,9 +206,10 @@ function endLifeCycleTimer(debugID, timerType) {
currentFlushMeasurements.push({
timerType,
instanceID: debugID,
duration: performanceNow() -
currentTimerStartTime -
currentTimerNestedFlushDuration,
duration:
performanceNow() -
currentTimerStartTime -
currentTimerNestedFlushDuration,
});
}
currentTimerStartTime = 0;
@@ -50,9 +50,9 @@ describe('ReactCoroutine', () => {
function HandleYields(props, yields) {
ops.push('HandleYields');
return yields.map(y => (
<y.continuation isSame={props.foo === y.props.bar} />
));
return yields.map(y =>
<y.continuation isSame={props.foo === y.props.bar} />,
);
}
// An alternative API could mark Parent as something that needs
@@ -159,8 +159,9 @@ describe('ReactHostOperationHistoryHook', () => {
{
instanceID: inst._debugID,
type: 'mount',
payload: '<div style="color:red;background-color:yellow;" ' +
'data-reactroot="" data-reactid="1"></div>',
payload:
'<div style="color:red;background-color:yellow;" ' +
'data-reactroot="" data-reactid="1"></div>',
},
]);
}
@@ -279,8 +280,9 @@ describe('ReactHostOperationHistoryHook', () => {
{
instanceID: inst._debugID,
type: 'mount',
payload: '<div class="rad" tabindex="42" data-reactroot="" ' +
'data-reactid="1"></div>',
payload:
'<div class="rad" tabindex="42" data-reactroot="" ' +
'data-reactid="1"></div>',
},
]);
}
@@ -382,8 +384,9 @@ describe('ReactHostOperationHistoryHook', () => {
{
instanceID: inst._debugID,
type: 'mount',
payload: '<div data-x="rad" data-y="42" data-reactroot="" ' +
'data-reactid="1"></div>',
payload:
'<div data-x="rad" data-y="42" data-reactroot="" ' +
'data-reactid="1"></div>',
},
]);
}
@@ -460,8 +463,9 @@ describe('ReactHostOperationHistoryHook', () => {
{
instanceID: inst._debugID,
type: 'mount',
payload: '<my-component className="rad" tabIndex="42" ' +
'data-reactroot="" data-reactid="1"></my-component>',
payload:
'<my-component className="rad" tabIndex="42" ' +
'data-reactroot="" data-reactid="1"></my-component>',
},
]);
}
@@ -322,10 +322,10 @@ function setResponderAndExtractTransfer(
var shouldSetEventType = isStartish(topLevelType)
? eventTypes.startShouldSetResponder
: isMoveish(topLevelType)
? eventTypes.moveShouldSetResponder
: topLevelType === 'topSelectionChange'
? eventTypes.selectionChangeShouldSetResponder
: eventTypes.scrollShouldSetResponder;
? eventTypes.moveShouldSetResponder
: topLevelType === 'topSelectionChange'
? eventTypes.selectionChangeShouldSetResponder
: eventTypes.scrollShouldSetResponder;
// TODO: stop one short of the current responder.
var bubbleShouldSetFrom = !responderInst
@@ -519,8 +519,8 @@ var ResponderEventPlugin = {
var incrementalTouch = isResponderTouchStart
? eventTypes.responderStart
: isResponderTouchMove
? eventTypes.responderMove
: isResponderTouchEnd ? eventTypes.responderEnd : null;
? eventTypes.responderMove
: isResponderTouchEnd ? eventTypes.responderEnd : null;
if (incrementalTouch) {
var gesture = ResponderSyntheticEvent.getPooled(
@@ -43,10 +43,10 @@ var TouchHistoryMath = {
total += ofCurrent && isXAxis
? oneTouchData.currentPageX
: ofCurrent && !isXAxis
? oneTouchData.currentPageY
: !ofCurrent && isXAxis
? oneTouchData.previousPageX
: oneTouchData.previousPageY;
? oneTouchData.currentPageY
: !ofCurrent && isXAxis
? oneTouchData.previousPageX
: oneTouchData.previousPageY;
count = 1;
}
} else {
@@ -69,12 +69,12 @@ var _touchConfig = function(
var activeTouchObjects = topType === 'topTouchStart'
? allTouchObjects
: topType === 'topTouchMove'
? allTouchObjects
: topType === 'topTouchEnd'
? antiSubsequence(allTouchObjects, changedIndices)
: topType === 'topTouchCancel'
? antiSubsequence(allTouchObjects, changedIndices)
: null;
? allTouchObjects
: topType === 'topTouchEnd'
? antiSubsequence(allTouchObjects, changedIndices)
: topType === 'topTouchCancel'
? antiSubsequence(allTouchObjects, changedIndices)
: null;
return {
nativeEvent: touchEvent(
@@ -22,9 +22,11 @@ import type {ReactInstance} from 'ReactInstanceType';
* @final
*/
function isValidOwner(object: any): boolean {
return !!(object &&
return !!(
object &&
typeof object.attachRef === 'function' &&
typeof object.detachRef === 'function');
typeof object.detachRef === 'function'
);
}
/**
@@ -31,12 +31,11 @@ describe('ReactIdentity', () => {
it('should allow key property to express identity', () => {
var node;
var Component = props => (
var Component = props =>
<div ref={c => (node = c)}>
<div key={props.swap ? 'banana' : 'apple'} />
<div key={props.swap ? 'apple' : 'banana'} />
</div>
);
</div>;
var container = document.createElement('div');
ReactDOM.render(<Component />, container);
+1 -1
View File
@@ -134,7 +134,7 @@ var TransactionImpl = {
E,
F,
G,
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G,
>(method: T, scope: any, a: A, b: B, c: C, d: D, e: E, f: F): G {
/* eslint-enable space-before-function-paren */
invariant(
@@ -64,7 +64,8 @@ Object.assign(ShallowComponentWrapper.prototype, ReactCompositeComponent, {
return new NoopInternalComponent(element);
},
_replaceNodeWithMarkup: function() {},
_renderValidatedComponent: ReactCompositeComponent._renderValidatedComponentWithoutOwnerOrContext,
_renderValidatedComponent:
ReactCompositeComponent._renderValidatedComponentWithoutOwnerOrContext,
});
function _batchedRender(renderer, element, context) {
+3 -2
View File
@@ -156,8 +156,9 @@ var ReactTestUtils = {
var internalInstance = ReactInstanceMap.get(inst);
var constructor = internalInstance._currentElement.type;
return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
constructor === type);
return !!(
ReactTestUtils.isCompositeComponentElement(inst) && constructor === type
);
},
getRenderedChildOfCompositeComponent: function(inst) {