From 334409d675722b3b974eba7cb0b5d86f19c0047a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 17 Mar 2017 16:33:47 +0000 Subject: [PATCH 1/9] Delete addons --- .travis.yml | 2 - Gruntfile.js | 16 - docs/Rakefile | 2 - grunt/config/browserify.js | 33 -- grunt/tasks/npm-react-addons.js | 151 -------- grunt/tasks/npm-react.js | 2 - grunt/tasks/release.js | 2 - gulp/tasks/version-check.js | 5 - gulpfile.js | 1 - .../.gitignore | 1 - .../README.md | 31 -- .../package.json | 17 - .../jsx_orphaned_brackets_transformer/run.js | 166 --------- .../transforms/react.js | 52 --- packages/react-addons/package.json | 24 -- packages/react-linked-input/LinkedInput.js | 27 -- packages/react-linked-input/README.md | 11 - .../__test__/LinkedInput-test.js | 42 --- packages/react-linked-input/package.json | 25 -- scripts/circleci/upload_build.sh | 2 - scripts/fiber/tests-passing.txt | 76 ---- scripts/release-manager/commands/utils/npm.js | 9 - src/addons/ReactAddonsDOMDependencies.js | 37 -- .../ReactComponentWithPureRenderMixin.js | 48 --- src/addons/ReactFragment.js | 88 ----- src/addons/ReactWithAddons.js | 51 --- .../ReactComponentWithPureRenderMixin-test.js | 137 ------- src/addons/__tests__/ReactFragment-test.js | 99 ------ .../renderSubtreeIntoContainer-test.js | 300 ---------------- src/addons/__tests__/update-test.js | 189 ---------- src/addons/shallowCompare.js | 26 -- .../transitions/ReactCSSTransitionGroup.js | 99 ------ .../ReactCSSTransitionGroupChild.js | 173 --------- .../ReactTransitionChildMapping.js | 105 ------ .../transitions/ReactTransitionEvents.js | 73 ---- .../transitions/ReactTransitionGroup.js | 243 ------------- .../__tests__/ReactCSSTransitionGroup-test.js | 325 ----------------- .../ReactTransitionChildMapping-test.js | 137 ------- .../__tests__/ReactTransitionGroup-test.js | 334 ------------------ src/addons/update.js | 169 --------- src/umd/ReactDOMUMDEntry.js | 6 - src/umd/ReactWithAddonsUMDEntry.js | 37 -- .../ReactAddonsDOMDependenciesUMDShim.js | 36 -- 43 files changed, 3409 deletions(-) delete mode 100644 grunt/tasks/npm-react-addons.js delete mode 100644 packages/jsx_orphaned_brackets_transformer/.gitignore delete mode 100644 packages/jsx_orphaned_brackets_transformer/README.md delete mode 100644 packages/jsx_orphaned_brackets_transformer/package.json delete mode 100644 packages/jsx_orphaned_brackets_transformer/run.js delete mode 100644 packages/jsx_orphaned_brackets_transformer/transforms/react.js delete mode 100644 packages/react-addons/package.json delete mode 100644 packages/react-linked-input/LinkedInput.js delete mode 100644 packages/react-linked-input/README.md delete mode 100644 packages/react-linked-input/__test__/LinkedInput-test.js delete mode 100644 packages/react-linked-input/package.json delete mode 100644 src/addons/ReactAddonsDOMDependencies.js delete mode 100644 src/addons/ReactComponentWithPureRenderMixin.js delete mode 100644 src/addons/ReactFragment.js delete mode 100644 src/addons/ReactWithAddons.js delete mode 100644 src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js delete mode 100644 src/addons/__tests__/ReactFragment-test.js delete mode 100644 src/addons/__tests__/renderSubtreeIntoContainer-test.js delete mode 100644 src/addons/__tests__/update-test.js delete mode 100644 src/addons/shallowCompare.js delete mode 100644 src/addons/transitions/ReactCSSTransitionGroup.js delete mode 100644 src/addons/transitions/ReactCSSTransitionGroupChild.js delete mode 100644 src/addons/transitions/ReactTransitionChildMapping.js delete mode 100644 src/addons/transitions/ReactTransitionEvents.js delete mode 100644 src/addons/transitions/ReactTransitionGroup.js delete mode 100644 src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js delete mode 100644 src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js delete mode 100644 src/addons/transitions/__tests__/ReactTransitionGroup-test.js delete mode 100644 src/addons/update.js delete mode 100644 src/umd/ReactWithAddonsUMDEntry.js delete mode 100644 src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js diff --git a/.travis.yml b/.travis.yml index 2a56780f56f02..a1989ffb476e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,8 +63,6 @@ script: curl \ -F "react=@build/react.js" \ -F "react.min=@build/react.min.js" \ - -F "react-with-addons=@build/react-with-addons.js" \ - -F "react-with-addons.min=@build/react-with-addons.min.js" \ -F "react-dom=@build/react-dom.js" \ -F "react-dom.min=@build/react-dom.min.js" \ -F "react-dom-server=@build/react-dom-server.js" \ diff --git a/Gruntfile.js b/Gruntfile.js index 1782deee778ba..58c832e29c87d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -84,10 +84,6 @@ module.exports = function(grunt) { 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); @@ -106,19 +102,11 @@ module.exports = function(grunt) { 'version-check', 'browserify:basic', ]); - grunt.registerTask('build:addons', [ - 'build-modules', - 'browserify:addons', - ]); grunt.registerTask('build:min', [ 'build-modules', 'version-check', 'browserify:min', ]); - grunt.registerTask('build:addons-min', [ - 'build-modules', - 'browserify:addonsMin', - ]); grunt.registerTask('build:dom', [ 'build-modules', 'version-check', @@ -169,9 +157,7 @@ module.exports = function(grunt) { 'build-modules', 'version-check', 'browserify:basic', - 'browserify:addons', 'browserify:min', - 'browserify:addonsMin', 'browserify:dom', 'browserify:domMin', 'browserify:domServer', @@ -184,8 +170,6 @@ module.exports = function(grunt) { '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', 'npm-react-noop:release', diff --git a/docs/Rakefile b/docs/Rakefile index 7a9872b7c057b..5f5e1e4c7b355 100644 --- a/docs/Rakefile +++ b/docs/Rakefile @@ -37,8 +37,6 @@ task :update_hashes do map = { 'react.js' => 'dev', 'react.min.js' => 'prod', - 'react-with-addons.js' => 'addons_dev', - 'react-with-addons.min.js' => 'addons_prod', 'react-dom.js' => 'dom_dev', 'react-dom.min.js' => 'dom_prod', 'react-dom-server.js' => 'dom_server_dev', diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 5cc3f1f840a76..3997d8c36fcc6 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -172,37 +172,6 @@ var min = { after: [minify, bannerify], }; -var addons = { - entries: [ - './build/node_modules/react/lib/ReactWithAddonsUMDEntry.js', - ], - outfile: './build/react-with-addons.js', - debug: false, - standalone: 'React', - packageName: 'React (with addons)', - transforms: [shimDOMModules], - globalTransforms: [envifyDev], - plugins: [collapser], - after: [derequire, simpleBannerify], -}; - -var addonsMin = { - entries: [ - './build/node_modules/react/lib/ReactWithAddonsUMDEntry.js', - ], - outfile: './build/react-with-addons.min.js', - debug: false, - standalone: 'React', - packageName: 'React (with addons)', - transforms: [shimDOMModules, envifyProd, uglifyify], - globalTransforms: [envifyProd], - plugins: [collapser], - // No need to derequire because the minifier will mangle - // the "require" calls. - - after: [minify, bannerify], -}; - // The DOM Builds var dom = { entries: [ @@ -303,8 +272,6 @@ var domFiberMin = { module.exports = { basic: basic, min: min, - addons: addons, - addonsMin: addonsMin, dom: dom, domMin: domMin, domServer: domServer, diff --git a/grunt/tasks/npm-react-addons.js b/grunt/tasks/npm-react-addons.js deleted file mode 100644 index c0818ff75fe60..0000000000000 --- a/grunt/tasks/npm-react-addons.js +++ /dev/null @@ -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, -}; diff --git a/grunt/tasks/npm-react.js b/grunt/tasks/npm-react.js index 038d2fec513ce..35c8a520ea558 100644 --- a/grunt/tasks/npm-react.js +++ b/grunt/tasks/npm-react.js @@ -11,8 +11,6 @@ var dist = dest + 'dist/'; var distFiles = [ 'react.js', 'react.min.js', - 'react-with-addons.js', - 'react-with-addons.min.js', ]; function buildRelease() { diff --git a/grunt/tasks/release.js b/grunt/tasks/release.js index 0ddab043d8f59..87186227bb67c 100644 --- a/grunt/tasks/release.js +++ b/grunt/tasks/release.js @@ -7,8 +7,6 @@ var BOWER_GLOB = [BOWER_PATH + '*.{js}']; var BOWER_FILES = [ 'react.js', 'react.min.js', - 'react-with-addons.js', - 'react-with-addons.min.js', 'react-dom.js', 'react-dom.min.js', 'react-dom-server.js', diff --git a/gulp/tasks/version-check.js b/gulp/tasks/version-check.js index 9e0cb2366748b..31118527d4fd7 100644 --- a/gulp/tasks/version-check.js +++ b/gulp/tasks/version-check.js @@ -15,7 +15,6 @@ 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, @@ -23,10 +22,6 @@ module.exports = function(gulp, plugins) { 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'), diff --git a/gulpfile.js b/gulpfile.js index cea6003e62e09..27bc2cfa0e8d5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -35,7 +35,6 @@ var paths = { 'src/umd/shims/**/*.js', 'src/isomorphic/**/*.js', - 'src/addons/**/*.js', 'src/ReactVersion.js', 'src/shared/**/*.js', diff --git a/packages/jsx_orphaned_brackets_transformer/.gitignore b/packages/jsx_orphaned_brackets_transformer/.gitignore deleted file mode 100644 index 3c3629e647f5d..0000000000000 --- a/packages/jsx_orphaned_brackets_transformer/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/packages/jsx_orphaned_brackets_transformer/README.md b/packages/jsx_orphaned_brackets_transformer/README.md deleted file mode 100644 index e0fa3908edb22..0000000000000 --- a/packages/jsx_orphaned_brackets_transformer/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# JSX Orphaned Brackets Transformer - -React 0.13 no longer parses orphaned > and } as text. - -Take this example block: - -```js -
- > } -
-``` - -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 -``` diff --git a/packages/jsx_orphaned_brackets_transformer/package.json b/packages/jsx_orphaned_brackets_transformer/package.json deleted file mode 100644 index 44331721825a3..0000000000000 --- a/packages/jsx_orphaned_brackets_transformer/package.json +++ /dev/null @@ -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 -} diff --git a/packages/jsx_orphaned_brackets_transformer/run.js b/packages/jsx_orphaned_brackets_transformer/run.js deleted file mode 100644 index 7ce8a4a94bbf9..0000000000000 --- a/packages/jsx_orphaned_brackets_transformer/run.js +++ /dev/null @@ -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; diff --git a/packages/jsx_orphaned_brackets_transformer/transforms/react.js b/packages/jsx_orphaned_brackets_transformer/transforms/react.js deleted file mode 100644 index 1d9a28907a19d..0000000000000 --- a/packages/jsx_orphaned_brackets_transformer/transforms/react.js +++ /dev/null @@ -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 = '}'; // or {'}'} - var rightAngledBracket = '>'; // or {'>'} - - value = value.replace(/\}/g, rightCurlyBracket); - value = value.replace(/\>/g, rightAngledBracket); - - utils.append(value, state); - utils.move(object.range[1], state); -} - -exports.visitReactTag = visitReactTag; diff --git a/packages/react-addons/package.json b/packages/react-addons/package.json deleted file mode 100644 index 9c32da9881cd5..0000000000000 --- a/packages/react-addons/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "react-addons-template", - "version": "16.0.0-alpha.4", - "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": "^16.0.0-alpha.4" - }, - "files": [ - "LICENSE", - "PATENTS", - "README.md", - "index.js" - ] -} diff --git a/packages/react-linked-input/LinkedInput.js b/packages/react-linked-input/LinkedInput.js deleted file mode 100644 index 394056e039762..0000000000000 --- a/packages/react-linked-input/LinkedInput.js +++ /dev/null @@ -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; - diff --git a/packages/react-linked-input/README.md b/packages/react-linked-input/README.md deleted file mode 100644 index 3109ea7df1234..0000000000000 --- a/packages/react-linked-input/README.md +++ /dev/null @@ -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(, container); -``` diff --git a/packages/react-linked-input/__test__/LinkedInput-test.js b/packages/react-linked-input/__test__/LinkedInput-test.js deleted file mode 100644 index fab7c3d5282ec..0000000000000 --- a/packages/react-linked-input/__test__/LinkedInput-test.js +++ /dev/null @@ -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(, container); - var input = ReactDOM.findDOMNode(component); - expect(input.value).toBe('foo'); - ReactDOM.render(, container); - expect(input.value).toBe('boo'); - }); - - it('should throw', function() { - var container = document.createElement('div'); - var element = ; - expect(function() { - ReactDOM.render(element, container); - }).toThrow(); - }); -}); diff --git a/packages/react-linked-input/package.json b/packages/react-linked-input/package.json deleted file mode 100644 index 07f65db07c5a5..0000000000000 --- a/packages/react-linked-input/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "react-linked-input", - "version": "1.0.1", - "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.1" - } -} diff --git a/scripts/circleci/upload_build.sh b/scripts/circleci/upload_build.sh index 0558ba8dd0575..6b57fceac206c 100755 --- a/scripts/circleci/upload_build.sh +++ b/scripts/circleci/upload_build.sh @@ -6,8 +6,6 @@ if [ -z $CI_PULL_REQUEST ] && [ -n "$BUILD_SERVER_ENDPOINT" ]; then curl \ -F "react=@build/react.js" \ -F "react.min=@build/react.min.js" \ - -F "react-with-addons=@build/react-with-addons.js" \ - -F "react-with-addons.min=@build/react-with-addons.min.js" \ -F "react-dom=@build/react-dom.js" \ -F "react-dom.min=@build/react-dom.min.js" \ -F "react-dom-server=@build/react-dom-server.js" \ diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 60e666174ebba..6e9cd96e452da 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -42,82 +42,6 @@ scripts/error-codes/__tests__/invertObject-test.js * should take the last value when there're duplications in vals * should preserve the original order -src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js -* provides a default shouldComponentUpdate implementation -* does not do a deep comparison - -src/addons/__tests__/ReactFragment-test.js -* should throw if a plain object is used as a child -* should throw if a plain object even if it is in an owner -* warns for numeric keys on objects as children -* should warn if passing null to createFragment -* should warn if passing an array to createFragment -* should warn if passing a ReactElement to createFragment - -src/addons/__tests__/renderSubtreeIntoContainer-test.js -* should pass context when rendering subtree elsewhere -* should throw if parentComponent is invalid -* should update context if it changes due to setState -* should update context if it changes due to re-render -* should render portal with non-context-provider parent -* should get context through non-context-provider parent -* should get context through middle non-context-provider layer - -src/addons/__tests__/update-test.js -* pushes -* does not mutate the original object -* only pushes an array -* only pushes unto an array -* unshifts -* does not mutate the original object -* only unshifts an array -* only unshifts unto an array -* splices -* does not mutate the original object -* only splices an array of arrays -* only splices unto an array -* merges -* does not mutate the original object -* only merges with an object -* only merges with an object -* sets -* does not mutate the original object -* applies -* does not mutate the original object -* only applies a function -* should support deep updates -* should require a command -* should perform safe hasOwnProperty check - -src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js -* should warn if timeouts aren't specified -* should not warn if timeouts is zero -* should clean-up silently after the timeout elapses -* should keep both sets of DOM nodes around -* should switch transitionLeave from false to true -* should work with no children -* should work with a null child -* should transition from one to null -* should transition from false to one -* should use transition-type specific names when they're provided -* should clear transition timeouts when unmounted -* should handle unmounted elements properly - -src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js -* should support getChildMapping -* should support mergeChildMappings for adding keys -* should support mergeChildMappings for removing keys -* should support mergeChildMappings for adding and removing -* should reconcile overlapping insertions and deletions -* should support mergeChildMappings with undefined input - -src/addons/transitions/__tests__/ReactTransitionGroup-test.js -* should handle willEnter correctly -* should handle enter/leave/enter/leave correctly -* should handle enter/leave/enter correctly -* should handle entering/leaving several elements at once -* should warn for duplicated keys - src/isomorphic/__tests__/React-test.js * should log a deprecation warning once when using React.createMixin diff --git a/scripts/release-manager/commands/utils/npm.js b/scripts/release-manager/commands/utils/npm.js index 5a9bf235fc02b..65c87d33cc7dc 100644 --- a/scripts/release-manager/commands/utils/npm.js +++ b/scripts/release-manager/commands/utils/npm.js @@ -3,15 +3,6 @@ const querystring = require('querystring'); const PACKAGES = [ - 'react-addons-create-fragment', - 'react-addons-css-transition-group', - 'react-addons-linked-state-mixin', - 'react-addons-perf', - 'react-addons-pure-render-mixin', - 'react-addons-shallow-compare', - 'react-addons-test-utils', - 'react-addons-transition-group', - 'react-addons-update', 'react-dom', 'react-native-renderer', 'react-test-renderer', diff --git a/src/addons/ReactAddonsDOMDependencies.js b/src/addons/ReactAddonsDOMDependencies.js deleted file mode 100644 index db86d1f49597f..0000000000000 --- a/src/addons/ReactAddonsDOMDependencies.js +++ /dev/null @@ -1,37 +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. - * - * @providesModule ReactAddonsDOMDependencies - */ - -'use strict'; - -var ReactDOM = require('react-dom'); - -exports.getReactDOM = function() { - return ReactDOM; -}; - -if (__DEV__) { - var ReactPerf; - var ReactTestUtils; - - exports.getReactPerf = function() { - if (!ReactPerf) { - ReactPerf = require('react-dom/lib/ReactPerf'); - } - return ReactPerf; - }; - - exports.getReactTestUtils = function() { - if (!ReactTestUtils) { - ReactTestUtils = require('react-dom/lib/ReactTestUtils'); - } - return ReactTestUtils; - }; -} diff --git a/src/addons/ReactComponentWithPureRenderMixin.js b/src/addons/ReactComponentWithPureRenderMixin.js deleted file mode 100644 index cf00d7cb3deb1..0000000000000 --- a/src/addons/ReactComponentWithPureRenderMixin.js +++ /dev/null @@ -1,48 +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. - * - * @providesModule ReactComponentWithPureRenderMixin - */ - -'use strict'; - -var shallowCompare = require('shallowCompare'); - -/** - * If your React component's render function is "pure", e.g. it will render the - * same result given the same props and state, provide this mixin for a - * considerable performance boost. - * - * Most React components have pure render functions. - * - * Example: - * - * var ReactComponentWithPureRenderMixin = - * require('ReactComponentWithPureRenderMixin'); - * React.createClass({ - * mixins: [ReactComponentWithPureRenderMixin], - * - * render: function() { - * return
foo
; - * } - * }); - * - * Note: This only checks shallow equality for props and state. If these contain - * complex data structures this mixin may have false-negatives for deeper - * differences. Only mixin to components which have simple props and state, or - * use `forceUpdate()` when you know deep data structures have changed. - * - * See https://facebook.github.io/react/docs/pure-render-mixin.html - */ -var ReactComponentWithPureRenderMixin = { - shouldComponentUpdate: function(nextProps, nextState) { - return shallowCompare(this, nextProps, nextState); - }, -}; - -module.exports = ReactComponentWithPureRenderMixin; diff --git a/src/addons/ReactFragment.js b/src/addons/ReactFragment.js deleted file mode 100644 index 14efe88759c5c..0000000000000 --- a/src/addons/ReactFragment.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2015-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. - * - * @providesModule ReactFragment - */ - -'use strict'; - -var ReactChildren = require('ReactChildren'); -var ReactElement = require('ReactElement'); - -var emptyFunction = require('fbjs/lib/emptyFunction'); -var invariant = require('fbjs/lib/invariant'); -var warning = require('fbjs/lib/warning'); - -/** - * We used to allow keyed objects to serve as a collection of ReactElements, - * or nested sets. This allowed us a way to explicitly key a set or fragment of - * components. This is now being replaced with an opaque data structure. - * The upgrade path is to call React.addons.createFragment({ key: value }) to - * create a keyed fragment. The resulting data structure is an array. - */ - -var numericPropertyRegex = /^\d+$/; - -var warnedAboutNumeric = false; - -var ReactFragment = { - /** - * Wrap a keyed object in an opaque proxy that warns you if you access any - * of its properties. - * See https://facebook.github.io/react/docs/create-fragment.html - */ - create: function(object) { - if (typeof object !== 'object' || !object || Array.isArray(object)) { - warning( - false, - 'React.addons.createFragment only accepts a single object. Got: %s', - object, - ); - return object; - } - if (ReactElement.isValidElement(object)) { - warning( - false, - 'React.addons.createFragment does not accept a ReactElement ' + - 'without a wrapper object.', - ); - return object; - } - - invariant( - object.nodeType !== 1, - 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + - 'elements are not valid children of React components.', - ); - - var result = []; - - for (var key in object) { - if (__DEV__) { - if (!warnedAboutNumeric && numericPropertyRegex.test(key)) { - warning( - false, - 'React.addons.createFragment(...): Child objects should have ' + - 'non-numeric keys so ordering is preserved.', - ); - warnedAboutNumeric = true; - } - } - ReactChildren.mapIntoWithKeyPrefixInternal( - object[key], - result, - key, - emptyFunction.thatReturnsArgument, - ); - } - - return result; - }, -}; - -module.exports = ReactFragment; diff --git a/src/addons/ReactWithAddons.js b/src/addons/ReactWithAddons.js deleted file mode 100644 index 6a20a3ae368e1..0000000000000 --- a/src/addons/ReactWithAddons.js +++ /dev/null @@ -1,51 +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. - * - * @providesModule ReactWithAddons - */ - -'use strict'; - -var React = require('react'); -var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies'); -var ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin'); -var ReactCSSTransitionGroup = require('ReactCSSTransitionGroup'); -var ReactFragment = require('ReactFragment'); -var ReactTransitionGroup = require('ReactTransitionGroup'); - -var shallowCompare = require('shallowCompare'); -var update = require('update'); - -React.addons = { - CSSTransitionGroup: ReactCSSTransitionGroup, - PureRenderMixin: ReactComponentWithPureRenderMixin, - TransitionGroup: ReactTransitionGroup, - - createFragment: ReactFragment.create, - shallowCompare: shallowCompare, - update: update, -}; - -if (__DEV__) { - // For the UMD build we get these lazily from the global since they're tied - // to the DOM renderer and it hasn't loaded yet. - Object.defineProperty(React.addons, 'Perf', { - enumerable: true, - get: function() { - return ReactAddonsDOMDependencies.getReactPerf(); - }, - }); - Object.defineProperty(React.addons, 'TestUtils', { - enumerable: true, - get: function() { - return ReactAddonsDOMDependencies.getReactTestUtils(); - }, - }); -} - -module.exports = React; diff --git a/src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js b/src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js deleted file mode 100644 index d9d1683fcbc59..0000000000000 --- a/src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright 2015-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'; - -var React; -var ReactComponentWithPureRenderMixin; -var ReactTestUtils; - -describe('ReactComponentWithPureRenderMixin', () => { - beforeEach(() => { - React = require('react'); - ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin'); - ReactTestUtils = require('ReactTestUtils'); - }); - - it('provides a default shouldComponentUpdate implementation', () => { - var renderCalls = 0; - class PlasticWrap extends React.Component { - constructor(props, context) { - super(props, context); - this.state = { - color: 'green', - }; - } - - render() { - return ; - } - } - - var Apple = React.createClass({ - mixins: [ReactComponentWithPureRenderMixin], - - getInitialState: function() { - return { - cut: false, - slices: 1, - }; - }, - - cut: function() { - this.setState({ - cut: true, - slices: 10, - }); - }, - - eatSlice: function() { - this.setState({ - slices: this.state.slices - 1, - }); - }, - - render: function() { - renderCalls++; - return
; - }, - }); - - var instance = ReactTestUtils.renderIntoDocument(); - expect(renderCalls).toBe(1); - - // Do not re-render based on props - instance.setState({color: 'green'}); - expect(renderCalls).toBe(1); - - // Re-render based on props - instance.setState({color: 'red'}); - expect(renderCalls).toBe(2); - - // Re-render base on state - instance.refs.apple.cut(); - expect(renderCalls).toBe(3); - - // No re-render based on state - instance.refs.apple.cut(); - expect(renderCalls).toBe(3); - - // Re-render based on state again - instance.refs.apple.eatSlice(); - expect(renderCalls).toBe(4); - }); - - it('does not do a deep comparison', () => { - function getInitialState() { - return { - foo: [1, 2, 3], - bar: {a: 4, b: 5, c: 6}, - }; - } - - var renderCalls = 0; - var initialSettings = getInitialState(); - - var Component = React.createClass({ - mixins: [ReactComponentWithPureRenderMixin], - - getInitialState: function() { - return initialSettings; - }, - - render: function() { - renderCalls++; - return
; - }, - }); - - var instance = ReactTestUtils.renderIntoDocument(); - expect(renderCalls).toBe(1); - - // Do not re-render if state is equal - var settings = { - foo: initialSettings.foo, - bar: initialSettings.bar, - }; - instance.setState(settings); - expect(renderCalls).toBe(1); - - // Re-render because one field changed - initialSettings.foo = [1, 2, 3]; - instance.setState(initialSettings); - expect(renderCalls).toBe(2); - - // Re-render because the object changed - instance.setState(getInitialState()); - expect(renderCalls).toBe(3); - }); -}); diff --git a/src/addons/__tests__/ReactFragment-test.js b/src/addons/__tests__/ReactFragment-test.js deleted file mode 100644 index a295aaef6aa22..0000000000000 --- a/src/addons/__tests__/ReactFragment-test.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright 2015-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'; - -var React; -var ReactDOM; -var ReactFragment; - -describe('ReactFragment', () => { - beforeEach(() => { - React = require('react'); - ReactDOM = require('react-dom'); - ReactFragment = require('ReactFragment'); - }); - - it('should throw if a plain object is used as a child', () => { - var children = { - x: , - y: , - z: , - }; - var element =
{[children]}
; - var container = document.createElement('div'); - expect(() => ReactDOM.render(element, container)).toThrowError( - 'Objects are not valid as a React child (found: object with keys ' + - '{x, y, z}). If you meant to render a collection of children, use an ' + - 'array instead or wrap the object using createFragment(object) from ' + - 'the React add-ons.', - ); - }); - - it('should throw if a plain object even if it is in an owner', () => { - class Foo extends React.Component { - render() { - var children = { - a: , - b: , - c: , - }; - return
{[children]}
; - } - } - var container = document.createElement('div'); - expect(() => ReactDOM.render(, container)).toThrowError( - 'Objects are not valid as a React child (found: object with keys ' + - '{a, b, c}). If you meant to render a collection of children, use an ' + - 'array instead or wrap the object using createFragment(object) from ' + - 'the React add-ons.\n\nCheck the render method of `Foo`.', - ); - }); - - it('warns for numeric keys on objects as children', () => { - spyOn(console, 'error'); - - ReactFragment.create({1: , 2: }); - - expectDev(console.error.calls.count()).toBe(1); - expectDev(console.error.calls.argsFor(0)[0]).toContain( - 'Child objects should have non-numeric keys so ordering is preserved.', - ); - }); - - it('should warn if passing null to createFragment', () => { - spyOn(console, 'error'); - ReactFragment.create(null); - expectDev(console.error.calls.count()).toBe(1); - expectDev(console.error.calls.argsFor(0)[0]).toContain( - 'React.addons.createFragment only accepts a single object.', - ); - }); - - it('should warn if passing an array to createFragment', () => { - spyOn(console, 'error'); - ReactFragment.create([]); - expectDev(console.error.calls.count()).toBe(1); - expectDev(console.error.calls.argsFor(0)[0]).toContain( - 'React.addons.createFragment only accepts a single object.', - ); - }); - - it('should warn if passing a ReactElement to createFragment', () => { - spyOn(console, 'error'); - ReactFragment.create(
); - expectDev(console.error.calls.count()).toBe(1); - expectDev(console.error.calls.argsFor(0)[0]).toContain( - 'React.addons.createFragment does not accept a ReactElement without a ' + - 'wrapper object.', - ); - }); -}); diff --git a/src/addons/__tests__/renderSubtreeIntoContainer-test.js b/src/addons/__tests__/renderSubtreeIntoContainer-test.js deleted file mode 100644 index 30e617480b1fa..0000000000000 --- a/src/addons/__tests__/renderSubtreeIntoContainer-test.js +++ /dev/null @@ -1,300 +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'; - -var React = require('react'); -var ReactDOM = require('react-dom'); -var ReactTestUtils = require('ReactTestUtils'); -var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer'); - -describe('renderSubtreeIntoContainer', () => { - it('should pass context when rendering subtree elsewhere', () => { - var portal = document.createElement('div'); - - class Component extends React.Component { - static contextTypes = { - foo: React.PropTypes.string.isRequired, - }; - - render() { - return
{this.context.foo}
; - } - } - - class Parent extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - }; - - getChildContext() { - return { - foo: 'bar', - }; - } - - render() { - return null; - } - - componentDidMount() { - expect( - function() { - renderSubtreeIntoContainer(this, , portal); - }.bind(this), - ).not.toThrow(); - } - } - - ReactTestUtils.renderIntoDocument(); - expect(portal.firstChild.innerHTML).toBe('bar'); - }); - - it('should throw if parentComponent is invalid', () => { - var portal = document.createElement('div'); - - class Component extends React.Component { - static contextTypes = { - foo: React.PropTypes.string.isRequired, - }; - - render() { - return
{this.context.foo}
; - } - } - - // ESLint is confused here and thinks Parent is unused, presumably because - // it is only used inside of the class body? - // eslint-disable-next-line no-unused-vars - class Parent extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - }; - - getChildContext() { - return { - foo: 'bar', - }; - } - - render() { - return null; - } - - componentDidMount() { - expect(function() { - renderSubtreeIntoContainer(, , portal); - }).toThrowError('parentComponentmust be a valid React Component'); - } - } - }); - - it('should update context if it changes due to setState', () => { - var container = document.createElement('div'); - document.body.appendChild(container); - var portal = document.createElement('div'); - - class Component extends React.Component { - static contextTypes = { - foo: React.PropTypes.string.isRequired, - getFoo: React.PropTypes.func.isRequired, - }; - - render() { - return
{this.context.foo + '-' + this.context.getFoo()}
; - } - } - - class Parent extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - getFoo: React.PropTypes.func.isRequired, - }; - - state = { - bar: 'initial', - }; - - getChildContext() { - return { - foo: this.state.bar, - getFoo: () => this.state.bar, - }; - } - - render() { - return null; - } - - componentDidMount() { - renderSubtreeIntoContainer(this, , portal); - } - - componentDidUpdate() { - renderSubtreeIntoContainer(this, , portal); - } - } - - var instance = ReactDOM.render(, container); - expect(portal.firstChild.innerHTML).toBe('initial-initial'); - instance.setState({bar: 'changed'}); - expect(portal.firstChild.innerHTML).toBe('changed-changed'); - }); - - it('should update context if it changes due to re-render', () => { - var container = document.createElement('div'); - document.body.appendChild(container); - var portal = document.createElement('div'); - - class Component extends React.Component { - static contextTypes = { - foo: React.PropTypes.string.isRequired, - getFoo: React.PropTypes.func.isRequired, - }; - - render() { - return
{this.context.foo + '-' + this.context.getFoo()}
; - } - } - - class Parent extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - getFoo: React.PropTypes.func.isRequired, - }; - - getChildContext() { - return { - foo: this.props.bar, - getFoo: () => this.props.bar, - }; - } - - render() { - return null; - } - - componentDidMount() { - renderSubtreeIntoContainer(this, , portal); - } - - componentDidUpdate() { - renderSubtreeIntoContainer(this, , portal); - } - } - - ReactDOM.render(, container); - expect(portal.firstChild.innerHTML).toBe('initial-initial'); - ReactDOM.render(, container); - expect(portal.firstChild.innerHTML).toBe('changed-changed'); - }); - - it('should render portal with non-context-provider parent', () => { - var container = document.createElement('div'); - document.body.appendChild(container); - var portal = document.createElement('div'); - - class Parent extends React.Component { - render() { - return null; - } - - componentDidMount() { - renderSubtreeIntoContainer(this,
hello
, portal); - } - } - - ReactDOM.render(, container); - expect(portal.firstChild.innerHTML).toBe('hello'); - }); - - it('should get context through non-context-provider parent', () => { - var container = document.createElement('div'); - document.body.appendChild(container); - var portal = document.createElement('div'); - - class Parent extends React.Component { - render() { - return ; - } - getChildContext() { - return {value: this.props.value}; - } - static childContextTypes = { - value: React.PropTypes.string.isRequired, - }; - } - - class Middle extends React.Component { - render() { - return null; - } - componentDidMount() { - renderSubtreeIntoContainer(this, , portal); - } - } - - class Child extends React.Component { - static contextTypes = { - value: React.PropTypes.string.isRequired, - }; - render() { - return
{this.context.value}
; - } - } - - ReactDOM.render(, container); - expect(portal.textContent).toBe('foo'); - }); - - it('should get context through middle non-context-provider layer', () => { - var container = document.createElement('div'); - document.body.appendChild(container); - var portal1 = document.createElement('div'); - var portal2 = document.createElement('div'); - - class Parent extends React.Component { - render() { - return null; - } - getChildContext() { - return {value: this.props.value}; - } - componentDidMount() { - renderSubtreeIntoContainer(this, , portal1); - } - static childContextTypes = { - value: React.PropTypes.string.isRequired, - }; - } - - class Middle extends React.Component { - render() { - return null; - } - componentDidMount() { - renderSubtreeIntoContainer(this, , portal2); - } - } - - class Child extends React.Component { - static contextTypes = { - value: React.PropTypes.string.isRequired, - }; - render() { - return
{this.context.value}
; - } - } - - ReactDOM.render(, container); - expect(portal2.textContent).toBe('foo'); - }); -}); diff --git a/src/addons/__tests__/update-test.js b/src/addons/__tests__/update-test.js deleted file mode 100644 index 15cf7ff75d5fa..0000000000000 --- a/src/addons/__tests__/update-test.js +++ /dev/null @@ -1,189 +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'; - -var update = require('update'); - -describe('update', () => { - describe('$push', () => { - it('pushes', () => { - expect(update([1], {$push: [7]})).toEqual([1, 7]); - }); - it('does not mutate the original object', () => { - var obj = [1]; - update(obj, {$push: [7]}); - expect(obj).toEqual([1]); - }); - it('only pushes an array', () => { - expect(update.bind(null, [], {$push: 7})).toThrowError( - 'update(): expected spec of $push to be an array; got 7. Did you ' + - 'forget to wrap your parameter in an array?', - ); - }); - it('only pushes unto an array', () => { - expect(update.bind(null, 1, {$push: 7})).toThrowError( - 'update(): expected target of $push to be an array; got 1.', - ); - }); - }); - - describe('$unshift', () => { - it('unshifts', () => { - expect(update([1], {$unshift: [7]})).toEqual([7, 1]); - }); - it('does not mutate the original object', () => { - var obj = [1]; - update(obj, {$unshift: [7]}); - expect(obj).toEqual([1]); - }); - it('only unshifts an array', () => { - expect(update.bind(null, [], {$unshift: 7})).toThrowError( - 'update(): expected spec of $unshift to be an array; got 7. Did you ' + - 'forget to wrap your parameter in an array?', - ); - }); - it('only unshifts unto an array', () => { - expect(update.bind(null, 1, {$unshift: 7})).toThrowError( - 'update(): expected target of $unshift to be an array; got 1.', - ); - }); - }); - - describe('$splice', () => { - it('splices', () => { - expect(update([1, 4, 3], {$splice: [[1, 1, 2]]})).toEqual([1, 2, 3]); - }); - it('does not mutate the original object', () => { - var obj = [1, 4, 3]; - update(obj, {$splice: [[1, 1, 2]]}); - expect(obj).toEqual([1, 4, 3]); - }); - it('only splices an array of arrays', () => { - expect(update.bind(null, [], {$splice: 1})).toThrowError( - 'update(): expected spec of $splice to be an array of arrays; got 1. ' + - 'Did you forget to wrap your parameters in an array?', - ); - expect(update.bind(null, [], {$splice: [1]})).toThrowError( - 'update(): expected spec of $splice to be an array of arrays; got 1. ' + - 'Did you forget to wrap your parameters in an array?', - ); - }); - it('only splices unto an array', () => { - expect(update.bind(null, 1, {$splice: 7})).toThrowError( - 'Expected $splice target to be an array; got 1', - ); - }); - }); - - describe('$merge', () => { - it('merges', () => { - expect(update({a: 'b'}, {$merge: {c: 'd'}})).toEqual({a: 'b', c: 'd'}); - }); - it('does not mutate the original object', () => { - var obj = {a: 'b'}; - update(obj, {$merge: {c: 'd'}}); - expect(obj).toEqual({a: 'b'}); - }); - it('only merges with an object', () => { - expect(update.bind(null, {}, {$merge: 7})).toThrowError( - "update(): $merge expects a spec of type 'object'; got 7", - ); - }); - it('only merges with an object', () => { - expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError( - "update(): $merge expects a target of type 'object'; got 7", - ); - }); - }); - - describe('$set', () => { - it('sets', () => { - expect(update({a: 'b'}, {$set: {c: 'd'}})).toEqual({c: 'd'}); - }); - it('does not mutate the original object', () => { - var obj = {a: 'b'}; - update(obj, {$set: {c: 'd'}}); - expect(obj).toEqual({a: 'b'}); - }); - }); - - describe('$apply', () => { - var applier = function(node) { - return {v: node.v * 2}; - }; - it('applies', () => { - expect(update({v: 2}, {$apply: applier})).toEqual({v: 4}); - }); - it('does not mutate the original object', () => { - var obj = {v: 2}; - update(obj, {$apply: applier}); - expect(obj).toEqual({v: 2}); - }); - it('only applies a function', () => { - expect(update.bind(null, 2, {$apply: 123})).toThrowError( - 'update(): expected spec of $apply to be a function; got 123.', - ); - }); - }); - - it('should support deep updates', () => { - expect( - update( - { - a: 'b', - c: { - d: 'e', - f: [1], - g: [2], - h: [3], - i: {j: 'k'}, - l: 4, - }, - }, - { - c: { - d: {$set: 'm'}, - f: {$push: [5]}, - g: {$unshift: [6]}, - h: {$splice: [[0, 1, 7]]}, - i: {$merge: {n: 'o'}}, - l: {$apply: x => x * 2}, - }, - }, - ), - ).toEqual({ - a: 'b', - c: { - d: 'm', - f: [1, 5], - g: [6, 2], - h: [7], - i: {j: 'k', n: 'o'}, - l: 8, - }, - }); - }); - - it('should require a command', () => { - expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrowError( - 'update(): You provided a key path to update() that did not contain ' + - 'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' + - 'forget to include {$set: ...}?', - ); - }); - - it('should perform safe hasOwnProperty check', () => { - expect(update({}, {hasOwnProperty: {$set: 'a'}})).toEqual({ - hasOwnProperty: 'a', - }); - }); -}); diff --git a/src/addons/shallowCompare.js b/src/addons/shallowCompare.js deleted file mode 100644 index 5bb1f500a86a4..0000000000000 --- a/src/addons/shallowCompare.js +++ /dev/null @@ -1,26 +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. - * - * @providesModule shallowCompare - */ - -'use strict'; - -var shallowEqual = require('fbjs/lib/shallowEqual'); - -/** - * Does a shallow comparison for props and state. - * See ReactComponentWithPureRenderMixin - * See also https://facebook.github.io/react/docs/shallow-compare.html - */ -function shallowCompare(instance, nextProps, nextState) { - return !shallowEqual(instance.props, nextProps) || - !shallowEqual(instance.state, nextState); -} - -module.exports = shallowCompare; diff --git a/src/addons/transitions/ReactCSSTransitionGroup.js b/src/addons/transitions/ReactCSSTransitionGroup.js deleted file mode 100644 index 97f1075a0ff75..0000000000000 --- a/src/addons/transitions/ReactCSSTransitionGroup.js +++ /dev/null @@ -1,99 +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. - * - * @providesModule ReactCSSTransitionGroup - */ - -'use strict'; - -var React = require('react'); - -var ReactTransitionGroup = require('ReactTransitionGroup'); -var ReactCSSTransitionGroupChild = require('ReactCSSTransitionGroupChild'); - -function createTransitionTimeoutPropValidator(transitionType) { - var timeoutPropName = 'transition' + transitionType + 'Timeout'; - var enabledPropName = 'transition' + transitionType; - - return function(props) { - // If the transition is enabled - if (props[enabledPropName]) { - // If no timeout duration is provided - if (props[timeoutPropName] == null) { - return new Error( - timeoutPropName + - " wasn't supplied to ReactCSSTransitionGroup: " + - "this can cause unreliable animations and won't be supported in " + - 'a future version of React. See ' + - 'https://fb.me/react-animation-transition-group-timeout for more ' + - 'information.', - ); - - // If the duration isn't a number - } else if (typeof props[timeoutPropName] !== 'number') { - return new Error( - timeoutPropName + ' must be a number (in milliseconds)', - ); - } - } - }; -} - -/** - * An easy way to perform CSS transitions and animations when a React component - * enters or leaves the DOM. - * See https://facebook.github.io/react/docs/animation.html#high-level-api-reactcsstransitiongroup - */ -class ReactCSSTransitionGroup extends React.Component { - static displayName = 'ReactCSSTransitionGroup'; - - static propTypes = { - transitionName: ReactCSSTransitionGroupChild.propTypes.name, - - transitionAppear: React.PropTypes.bool, - transitionEnter: React.PropTypes.bool, - transitionLeave: React.PropTypes.bool, - transitionAppearTimeout: createTransitionTimeoutPropValidator('Appear'), - transitionEnterTimeout: createTransitionTimeoutPropValidator('Enter'), - transitionLeaveTimeout: createTransitionTimeoutPropValidator('Leave'), - }; - - static defaultProps = { - transitionAppear: false, - transitionEnter: true, - transitionLeave: true, - }; - - _wrapChild = child => { - // We need to provide this childFactory so that - // ReactCSSTransitionGroupChild can receive updates to name, enter, and - // leave while it is leaving. - return React.createElement( - ReactCSSTransitionGroupChild, - { - name: this.props.transitionName, - appear: this.props.transitionAppear, - enter: this.props.transitionEnter, - leave: this.props.transitionLeave, - appearTimeout: this.props.transitionAppearTimeout, - enterTimeout: this.props.transitionEnterTimeout, - leaveTimeout: this.props.transitionLeaveTimeout, - }, - child, - ); - }; - - render() { - return React.createElement( - ReactTransitionGroup, - Object.assign({}, this.props, {childFactory: this._wrapChild}), - ); - } -} - -module.exports = ReactCSSTransitionGroup; diff --git a/src/addons/transitions/ReactCSSTransitionGroupChild.js b/src/addons/transitions/ReactCSSTransitionGroupChild.js deleted file mode 100644 index e2a794d0fad55..0000000000000 --- a/src/addons/transitions/ReactCSSTransitionGroupChild.js +++ /dev/null @@ -1,173 +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. - * - * @providesModule ReactCSSTransitionGroupChild - */ - -'use strict'; - -var React = require('react'); -var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies'); - -var CSSCore = require('fbjs/lib/CSSCore'); -var ReactTransitionEvents = require('ReactTransitionEvents'); - -var onlyChild = require('onlyChild'); - -var TICK = 17; - -var ReactCSSTransitionGroupChild = React.createClass({ - displayName: 'ReactCSSTransitionGroupChild', - - propTypes: { - name: React.PropTypes.oneOfType([ - React.PropTypes.string, - React.PropTypes.shape({ - enter: React.PropTypes.string, - leave: React.PropTypes.string, - active: React.PropTypes.string, - }), - React.PropTypes.shape({ - enter: React.PropTypes.string, - enterActive: React.PropTypes.string, - leave: React.PropTypes.string, - leaveActive: React.PropTypes.string, - appear: React.PropTypes.string, - appearActive: React.PropTypes.string, - }), - ]).isRequired, - - // Once we require timeouts to be specified, we can remove the - // boolean flags (appear etc.) and just accept a number - // or a bool for the timeout flags (appearTimeout etc.) - appear: React.PropTypes.bool, - enter: React.PropTypes.bool, - leave: React.PropTypes.bool, - appearTimeout: React.PropTypes.number, - enterTimeout: React.PropTypes.number, - leaveTimeout: React.PropTypes.number, - }, - - transition: function(animationType, finishCallback, userSpecifiedDelay) { - var node = ReactAddonsDOMDependencies.getReactDOM().findDOMNode(this); - - if (!node) { - if (finishCallback) { - finishCallback(); - } - return; - } - - var className = this.props.name[animationType] || - this.props.name + '-' + animationType; - var activeClassName = this.props.name[animationType + 'Active'] || - className + '-active'; - var timeout = null; - - var endListener = function(e) { - if (e && e.target !== node) { - return; - } - - clearTimeout(timeout); - - CSSCore.removeClass(node, className); - CSSCore.removeClass(node, activeClassName); - - ReactTransitionEvents.removeEndEventListener(node, endListener); - - // Usually this optional callback is used for informing an owner of - // a leave animation and telling it to remove the child. - if (finishCallback) { - finishCallback(); - } - }; - - CSSCore.addClass(node, className); - - // Need to do this to actually trigger a transition. - this.queueClassAndNode(activeClassName, node); - - // If the user specified a timeout delay. - if (userSpecifiedDelay) { - // Clean-up the animation after the specified delay - timeout = setTimeout(endListener, userSpecifiedDelay); - this.transitionTimeouts.push(timeout); - } else { - // DEPRECATED: this listener will be removed in a future version of react - ReactTransitionEvents.addEndEventListener(node, endListener); - } - }, - - queueClassAndNode: function(className, node) { - this.classNameAndNodeQueue.push({ - className: className, - node: node, - }); - - if (!this.timeout) { - this.timeout = setTimeout(this.flushClassNameAndNodeQueue, TICK); - } - }, - - flushClassNameAndNodeQueue: function() { - if (this.isMounted()) { - this.classNameAndNodeQueue.forEach(function(obj) { - CSSCore.addClass(obj.node, obj.className); - }); - } - this.classNameAndNodeQueue.length = 0; - this.timeout = null; - }, - - componentWillMount: function() { - this.classNameAndNodeQueue = []; - this.transitionTimeouts = []; - }, - - componentWillUnmount: function() { - if (this.timeout) { - clearTimeout(this.timeout); - } - this.transitionTimeouts.forEach(function(timeout) { - clearTimeout(timeout); - }); - - this.classNameAndNodeQueue.length = 0; - }, - - componentWillAppear: function(done) { - if (this.props.appear) { - this.transition('appear', done, this.props.appearTimeout); - } else { - done(); - } - }, - - componentWillEnter: function(done) { - if (this.props.enter) { - this.transition('enter', done, this.props.enterTimeout); - } else { - done(); - } - }, - - componentWillLeave: function(done) { - if (this.props.leave) { - this.transition('leave', done, this.props.leaveTimeout); - } else { - done(); - } - }, - - render: function() { - return onlyChild(this.props.children); - }, -}); - -module.exports = ReactCSSTransitionGroupChild; diff --git a/src/addons/transitions/ReactTransitionChildMapping.js b/src/addons/transitions/ReactTransitionChildMapping.js deleted file mode 100644 index 4ba6795dfce94..0000000000000 --- a/src/addons/transitions/ReactTransitionChildMapping.js +++ /dev/null @@ -1,105 +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. - * - * @providesModule ReactTransitionChildMapping - */ - -'use strict'; - -var flattenChildren = require('flattenChildren'); - -var ReactTransitionChildMapping = { - /** - * Given `this.props.children`, return an object mapping key to child. Just - * simple syntactic sugar around flattenChildren(). - * - * @param {*} children `this.props.children` - * @param {number=} selfDebugID Optional debugID of the current internal instance. - * @return {object} Mapping of key to child - */ - getChildMapping: function(children, selfDebugID) { - if (!children) { - return children; - } - - if (__DEV__) { - return flattenChildren(children, selfDebugID); - } - - return flattenChildren(children); - }, - - /** - * When you're adding or removing children some may be added or removed in the - * same render pass. We want to show *both* since we want to simultaneously - * animate elements in and out. This function takes a previous set of keys - * and a new set of keys and merges them with its best guess of the correct - * ordering. In the future we may expose some of the utilities in - * ReactMultiChild to make this easy, but for now React itself does not - * directly have this concept of the union of prevChildren and nextChildren - * so we implement it here. - * - * @param {object} prev prev children as returned from - * `ReactTransitionChildMapping.getChildMapping()`. - * @param {object} next next children as returned from - * `ReactTransitionChildMapping.getChildMapping()`. - * @return {object} a key set that contains all keys in `prev` and all keys - * in `next` in a reasonable order. - */ - mergeChildMappings: function(prev, next) { - prev = prev || {}; - next = next || {}; - - function getValueForKey(key) { - if (next.hasOwnProperty(key)) { - return next[key]; - } else { - return prev[key]; - } - } - - // For each key of `next`, the list of keys to insert before that key in - // the combined list - var nextKeysPending = {}; - - var pendingKeys = []; - for (var prevKey in prev) { - if (next.hasOwnProperty(prevKey)) { - if (pendingKeys.length) { - nextKeysPending[prevKey] = pendingKeys; - pendingKeys = []; - } - } else { - pendingKeys.push(prevKey); - } - } - - var i; - var childMapping = {}; - for (var nextKey in next) { - if (nextKeysPending.hasOwnProperty(nextKey)) { - for (i = 0; i < nextKeysPending[nextKey].length; i++) { - var pendingNextKey = nextKeysPending[nextKey][i]; - childMapping[nextKeysPending[nextKey][i]] = getValueForKey( - pendingNextKey, - ); - } - } - childMapping[nextKey] = getValueForKey(nextKey); - } - - // Finally, add the keys which didn't appear before any key in `next` - for (i = 0; i < pendingKeys.length; i++) { - childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]); - } - - return childMapping; - }, -}; - -module.exports = ReactTransitionChildMapping; diff --git a/src/addons/transitions/ReactTransitionEvents.js b/src/addons/transitions/ReactTransitionEvents.js deleted file mode 100644 index 82d8b464805fb..0000000000000 --- a/src/addons/transitions/ReactTransitionEvents.js +++ /dev/null @@ -1,73 +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. - * - * @providesModule ReactTransitionEvents - */ - -'use strict'; - -var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); - -var getVendorPrefixedEventName = require('react-dom/lib/getVendorPrefixedEventName'); - -var endEvents = []; - -function detectEvents() { - var animEnd = getVendorPrefixedEventName('animationend'); - var transEnd = getVendorPrefixedEventName('transitionend'); - - if (animEnd) { - endEvents.push(animEnd); - } - - if (transEnd) { - endEvents.push(transEnd); - } -} - -if (ExecutionEnvironment.canUseDOM) { - detectEvents(); -} - -// We use the raw {add|remove}EventListener() call because EventListener -// does not know how to remove event listeners and we really should -// clean up. Also, these events are not triggered in older browsers -// so we should be A-OK here. - -function addEventListener(node, eventName, eventListener) { - node.addEventListener(eventName, eventListener, false); -} - -function removeEventListener(node, eventName, eventListener) { - node.removeEventListener(eventName, eventListener, false); -} - -var ReactTransitionEvents = { - addEndEventListener: function(node, eventListener) { - if (endEvents.length === 0) { - // If CSS transitions are not supported, trigger an "end animation" - // event immediately. - window.setTimeout(eventListener, 0); - return; - } - endEvents.forEach(function(endEvent) { - addEventListener(node, endEvent, eventListener); - }); - }, - - removeEndEventListener: function(node, eventListener) { - if (endEvents.length === 0) { - return; - } - endEvents.forEach(function(endEvent) { - removeEventListener(node, endEvent, eventListener); - }); - }, -}; - -module.exports = ReactTransitionEvents; diff --git a/src/addons/transitions/ReactTransitionGroup.js b/src/addons/transitions/ReactTransitionGroup.js deleted file mode 100644 index 0b25c5feb09d3..0000000000000 --- a/src/addons/transitions/ReactTransitionGroup.js +++ /dev/null @@ -1,243 +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. - * - * @providesModule ReactTransitionGroup - */ - -'use strict'; - -var React = require('react'); -var ReactTransitionChildMapping = require('ReactTransitionChildMapping'); - -var emptyFunction = require('fbjs/lib/emptyFunction'); - -/** - * A basis for animations. When children are declaratively added or removed, - * special lifecycle hooks are called. - * See https://facebook.github.io/react/docs/animation.html#low-level-api-reacttransitiongroup - */ -class ReactTransitionGroup extends React.Component { - static displayName = 'ReactTransitionGroup'; - - static propTypes = { - component: React.PropTypes.any, - childFactory: React.PropTypes.func, - }; - - static defaultProps = { - component: 'span', - childFactory: emptyFunction.thatReturnsArgument, - }; - - state = { - // TODO: can we get useful debug information to show at this point? - children: ReactTransitionChildMapping.getChildMapping(this.props.children), - }; - - componentWillMount() { - this.currentlyTransitioningKeys = {}; - this.keysToEnter = []; - this.keysToLeave = []; - } - - componentDidMount() { - var initialChildMapping = this.state.children; - for (var key in initialChildMapping) { - if (initialChildMapping[key]) { - this.performAppear(key); - } - } - } - - componentWillReceiveProps(nextProps) { - var nextChildMapping = ReactTransitionChildMapping.getChildMapping( - nextProps.children, - ); - var prevChildMapping = this.state.children; - - this.setState({ - children: ReactTransitionChildMapping.mergeChildMappings( - prevChildMapping, - nextChildMapping, - ), - }); - - var key; - - for (key in nextChildMapping) { - var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key); - if ( - nextChildMapping[key] && - !hasPrev && - !this.currentlyTransitioningKeys[key] - ) { - this.keysToEnter.push(key); - } - } - - for (key in prevChildMapping) { - var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key); - if ( - prevChildMapping[key] && - !hasNext && - !this.currentlyTransitioningKeys[key] - ) { - this.keysToLeave.push(key); - } - } - - // If we want to someday check for reordering, we could do it here. - } - - componentDidUpdate() { - var keysToEnter = this.keysToEnter; - this.keysToEnter = []; - keysToEnter.forEach(this.performEnter); - - var keysToLeave = this.keysToLeave; - this.keysToLeave = []; - keysToLeave.forEach(this.performLeave); - } - - performAppear = key => { - this.currentlyTransitioningKeys[key] = true; - - var component = this.refs[key]; - - if (component.componentWillAppear) { - component.componentWillAppear(this._handleDoneAppearing.bind(this, key)); - } else { - this._handleDoneAppearing(key); - } - }; - - _handleDoneAppearing = key => { - var component = this.refs[key]; - if (component.componentDidAppear) { - component.componentDidAppear(); - } - - delete this.currentlyTransitioningKeys[key]; - - var currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ); - - if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) { - // This was removed before it had fully appeared. Remove it. - this.performLeave(key); - } - }; - - performEnter = key => { - this.currentlyTransitioningKeys[key] = true; - - var component = this.refs[key]; - - if (component.componentWillEnter) { - component.componentWillEnter(this._handleDoneEntering.bind(this, key)); - } else { - this._handleDoneEntering(key); - } - }; - - _handleDoneEntering = key => { - var component = this.refs[key]; - if (component.componentDidEnter) { - component.componentDidEnter(); - } - - delete this.currentlyTransitioningKeys[key]; - - var currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ); - - if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) { - // This was removed before it had fully entered. Remove it. - this.performLeave(key); - } - }; - - performLeave = key => { - this.currentlyTransitioningKeys[key] = true; - - var component = this.refs[key]; - if (component.componentWillLeave) { - component.componentWillLeave(this._handleDoneLeaving.bind(this, key)); - } else { - // Note that this is somewhat dangerous b/c it calls setState() - // again, effectively mutating the component before all the work - // is done. - this._handleDoneLeaving(key); - } - }; - - _handleDoneLeaving = key => { - var component = this.refs[key]; - - if (component.componentDidLeave) { - component.componentDidLeave(); - } - - delete this.currentlyTransitioningKeys[key]; - - var currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ); - - if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) { - // This entered again before it fully left. Add it again. - this.performEnter(key); - } else { - this.setState(function(state) { - var newChildren = Object.assign({}, state.children); - delete newChildren[key]; - return {children: newChildren}; - }); - } - }; - - render() { - // TODO: we could get rid of the need for the wrapper node - // by cloning a single child - var childrenToRender = []; - for (var key in this.state.children) { - var child = this.state.children[key]; - if (child) { - // You may need to apply reactive updates to a child as it is leaving. - // The normal React way to do it won't work since the child will have - // already been removed. In case you need this behavior you can provide - // a childFactory function to wrap every child, even the ones that are - // leaving. - childrenToRender.push( - React.cloneElement(this.props.childFactory(child), { - ref: key, - key: key, - }), - ); - } - } - - // Do not forward ReactTransitionGroup props to primitive DOM nodes - var props = Object.assign({}, this.props); - delete props.transitionLeave; - delete props.transitionName; - delete props.transitionAppear; - delete props.transitionEnter; - delete props.childFactory; - delete props.transitionLeaveTimeout; - delete props.transitionEnterTimeout; - delete props.transitionAppearTimeout; - delete props.component; - - return React.createElement(this.props.component, props, childrenToRender); - } -} - -module.exports = ReactTransitionGroup; diff --git a/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js b/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js deleted file mode 100644 index aaecb6e485221..0000000000000 --- a/src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js +++ /dev/null @@ -1,325 +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'; - -var CSSCore = require('fbjs/lib/CSSCore'); - -var React; -var ReactDOM; -var ReactCSSTransitionGroup; - -// Most of the real functionality is covered in other unit tests, this just -// makes sure we're wired up correctly. -describe('ReactCSSTransitionGroup', () => { - var container; - - beforeEach(() => { - jest.resetModules(); - React = require('react'); - ReactDOM = require('react-dom'); - ReactCSSTransitionGroup = require('ReactCSSTransitionGroup'); - - container = document.createElement('div'); - spyOn(console, 'error'); - }); - - it("should warn if timeouts aren't specified", () => { - ReactDOM.render( - - - , - container, - ); - - // Warning about the missing transitionLeaveTimeout prop - expectDev(console.error.calls.count()).toBe(1); - }); - - it('should not warn if timeouts is zero', () => { - ReactDOM.render( - - - , - container, - ); - - expectDev(console.error.calls.count()).toBe(0); - }); - - it('should clean-up silently after the timeout elapses', () => { - var a = ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - - setTimeout.mock.calls.length = 0; - - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two'); - expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('one'); - - // For some reason jst is adding extra setTimeout()s and grunt test isn't, - // so we need to do this disgusting hack. - for (var i = 0; i < setTimeout.mock.calls.length; i++) { - if (setTimeout.mock.calls[i][1] === 200) { - setTimeout.mock.calls[i][0](); - break; - } - } - - // No warnings - expectDev(console.error.calls.count()).toBe(0); - - // The leaving child has been removed - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two'); - }); - - it('should keep both sets of DOM nodes around', () => { - var a = ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two'); - expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('one'); - }); - - it('should switch transitionLeave from false to true', () => { - var a = ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('three'); - expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('two'); - }); - - it('should work with no children', () => { - ReactDOM.render( - , - container, - ); - }); - - it('should work with a null child', () => { - ReactDOM.render( - - {[null]} - , - container, - ); - }); - - it('should transition from one to null', () => { - var a = ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - ReactDOM.render( - - {null} - , - container, - ); - // (Here, we expect the original child to stick around but test that no - // exception is thrown) - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one'); - }); - - it('should transition from false to one', () => { - var a = ReactDOM.render( - - {false} - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(0); - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one'); - }); - - it("should use transition-type specific names when they're provided", () => { - var customTransitionNames = { - enter: 'custom-entering', - leave: 'custom-leaving', - }; - - var a = ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1); - - // Add an element - ReactDOM.render( - - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2); - - var enteringNode = ReactDOM.findDOMNode(a).childNodes[1]; - expect(CSSCore.hasClass(enteringNode, 'custom-entering')).toBe(true); - - // Remove an element - ReactDOM.render( - - - , - container, - ); - expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(2); - - var leavingNode = ReactDOM.findDOMNode(a).childNodes[0]; - expect(CSSCore.hasClass(leavingNode, 'custom-leaving')).toBe(true); - }); - - it('should clear transition timeouts when unmounted', () => { - class Component extends React.Component { - render() { - return ( - - {this.props.children} - - ); - } - } - - ReactDOM.render(, container); - ReactDOM.render( - , - container, - ); - - ReactDOM.unmountComponentAtNode(container); - - // Testing that no exception is thrown here, as the timeout has been cleared. - jest.runAllTimers(); - }); - - it('should handle unmounted elements properly', () => { - class Child extends React.Component { - render() { - if (!this.props.show) { - return null; - } - return
; - } - } - - class Component extends React.Component { - state = {showChild: true}; - - componentDidMount() { - this.setState({showChild: false}); - } - - render() { - return ( - - - - ); - } - } - - ReactDOM.render(, container); - - // Testing that no exception is thrown here, as the timeout has been cleared. - jest.runAllTimers(); - }); -}); diff --git a/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js b/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js deleted file mode 100644 index a383d11f5148e..0000000000000 --- a/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js +++ /dev/null @@ -1,137 +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'; - -var React; -var ReactTransitionChildMapping; - -describe('ReactTransitionChildMapping', () => { - beforeEach(() => { - React = require('react'); - ReactTransitionChildMapping = require('ReactTransitionChildMapping'); - }); - - it('should support getChildMapping', () => { - var oneone =
; - var onetwo =
; - var one =
{oneone}{onetwo}
; - var two =
; - var component =
{one}{two}
; - expect( - ReactTransitionChildMapping.getChildMapping(component.props.children), - ).toEqual({ - '.$one': one, - '.$two': two, - }); - }); - - it('should support mergeChildMappings for adding keys', () => { - var prev = { - one: true, - two: true, - }; - var next = { - one: true, - two: true, - three: true, - }; - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - one: true, - two: true, - three: true, - }); - }); - - it('should support mergeChildMappings for removing keys', () => { - var prev = { - one: true, - two: true, - three: true, - }; - var next = { - one: true, - two: true, - }; - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - one: true, - two: true, - three: true, - }); - }); - - it('should support mergeChildMappings for adding and removing', () => { - var prev = { - one: true, - two: true, - three: true, - }; - var next = { - one: true, - two: true, - four: true, - }; - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - one: true, - two: true, - three: true, - four: true, - }); - }); - - it('should reconcile overlapping insertions and deletions', () => { - var prev = { - one: true, - two: true, - four: true, - five: true, - }; - var next = { - one: true, - two: true, - three: true, - five: true, - }; - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - one: true, - two: true, - three: true, - four: true, - five: true, - }); - }); - - it('should support mergeChildMappings with undefined input', () => { - var prev = { - one: true, - two: true, - }; - - var next = undefined; - - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - one: true, - two: true, - }); - - prev = undefined; - - next = { - three: true, - four: true, - }; - - expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({ - three: true, - four: true, - }); - }); -}); diff --git a/src/addons/transitions/__tests__/ReactTransitionGroup-test.js b/src/addons/transitions/__tests__/ReactTransitionGroup-test.js deleted file mode 100644 index b9cce0db9787f..0000000000000 --- a/src/addons/transitions/__tests__/ReactTransitionGroup-test.js +++ /dev/null @@ -1,334 +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'; - -var React; -var ReactDOM; -var ReactTransitionGroup; - -// Most of the real functionality is covered in other unit tests, this just -// makes sure we're wired up correctly. -describe('ReactTransitionGroup', () => { - var container; - - beforeEach(() => { - React = require('react'); - ReactDOM = require('react-dom'); - ReactTransitionGroup = require('ReactTransitionGroup'); - - container = document.createElement('div'); - }); - - it('should handle willEnter correctly', () => { - var log = []; - - class Child extends React.Component { - componentDidMount() { - log.push('didMount'); - } - - componentWillAppear = cb => { - log.push('willAppear'); - cb(); - }; - - componentDidAppear = () => { - log.push('didAppear'); - }; - - componentWillEnter = cb => { - log.push('willEnter'); - cb(); - }; - - componentDidEnter = () => { - log.push('didEnter'); - }; - - componentWillLeave = cb => { - log.push('willLeave'); - cb(); - }; - - componentDidLeave = () => { - log.push('didLeave'); - }; - - componentWillUnmount() { - log.push('willUnmount'); - } - - render() { - return ; - } - } - - class Component extends React.Component { - state = {count: 1}; - - render() { - var children = []; - for (var i = 0; i < this.state.count; i++) { - children.push(); - } - return {children}; - } - } - - var instance = ReactDOM.render(, container); - expect(log).toEqual(['didMount', 'willAppear', 'didAppear']); - - log = []; - instance.setState({count: 2}, function() { - expect(log).toEqual(['didMount', 'willEnter', 'didEnter']); - - log = []; - instance.setState({count: 1}); - }); - - expect(log).toEqual(['willLeave', 'didLeave', 'willUnmount']); - }); - - it('should handle enter/leave/enter/leave correctly', () => { - var log = []; - var willEnterCb; - - class Child extends React.Component { - componentDidMount() { - log.push('didMount'); - } - - componentWillEnter = cb => { - log.push('willEnter'); - willEnterCb = cb; - }; - - componentDidEnter = () => { - log.push('didEnter'); - }; - - componentWillLeave = cb => { - log.push('willLeave'); - cb(); - }; - - componentDidLeave = () => { - log.push('didLeave'); - }; - - componentWillUnmount() { - log.push('willUnmount'); - } - - render() { - return ; - } - } - - class Component extends React.Component { - state = {count: 1}; - - render() { - var children = []; - for (var i = 0; i < this.state.count; i++) { - children.push(); - } - return {children}; - } - } - - var instance = ReactDOM.render(, container); - expect(log).toEqual(['didMount']); - instance.setState({count: 2}); - expect(log).toEqual(['didMount', 'didMount', 'willEnter']); - for (var k = 0; k < 5; k++) { - instance.setState({count: 2}); - expect(log).toEqual(['didMount', 'didMount', 'willEnter']); - instance.setState({count: 1}); - } - // other animations are blocked until willEnterCb is called - willEnterCb(); - expect(log).toEqual([ - 'didMount', - 'didMount', - 'willEnter', - 'didEnter', - 'willLeave', - 'didLeave', - 'willUnmount', - ]); - }); - - it('should handle enter/leave/enter correctly', () => { - var log = []; - var willEnterCb; - - class Child extends React.Component { - componentDidMount() { - log.push('didMount'); - } - - componentWillEnter = cb => { - log.push('willEnter'); - willEnterCb = cb; - }; - - componentDidEnter = () => { - log.push('didEnter'); - }; - - componentWillLeave = cb => { - log.push('willLeave'); - cb(); - }; - - componentDidLeave = () => { - log.push('didLeave'); - }; - - componentWillUnmount() { - log.push('willUnmount'); - } - - render() { - return ; - } - } - - class Component extends React.Component { - state = {count: 1}; - - render() { - var children = []; - for (var i = 0; i < this.state.count; i++) { - children.push(); - } - return {children}; - } - } - - var instance = ReactDOM.render(, container); - expect(log).toEqual(['didMount']); - instance.setState({count: 2}); - expect(log).toEqual(['didMount', 'didMount', 'willEnter']); - for (var k = 0; k < 5; k++) { - instance.setState({count: 1}); - expect(log).toEqual(['didMount', 'didMount', 'willEnter']); - instance.setState({count: 2}); - } - willEnterCb(); - expect(log).toEqual(['didMount', 'didMount', 'willEnter', 'didEnter']); - }); - - it('should handle entering/leaving several elements at once', () => { - var log = []; - - class Child extends React.Component { - componentDidMount() { - log.push('didMount' + this.props.id); - } - - componentWillEnter = cb => { - log.push('willEnter' + this.props.id); - cb(); - }; - - componentDidEnter = () => { - log.push('didEnter' + this.props.id); - }; - - componentWillLeave = cb => { - log.push('willLeave' + this.props.id); - cb(); - }; - - componentDidLeave = () => { - log.push('didLeave' + this.props.id); - }; - - componentWillUnmount() { - log.push('willUnmount' + this.props.id); - } - - render() { - return ; - } - } - - class Component extends React.Component { - state = {count: 1}; - - render() { - var children = []; - for (var i = 0; i < this.state.count; i++) { - children.push(); - } - return {children}; - } - } - - var instance = ReactDOM.render(, container); - expect(log).toEqual(['didMount0']); - log = []; - - instance.setState({count: 3}); - expect(log).toEqual([ - 'didMount1', - 'didMount2', - 'willEnter1', - 'didEnter1', - 'willEnter2', - 'didEnter2', - ]); - log = []; - - instance.setState({count: 0}); - expect(log).toEqual([ - 'willLeave0', - 'didLeave0', - 'willLeave1', - 'didLeave1', - 'willLeave2', - 'didLeave2', - 'willUnmount0', - 'willUnmount1', - 'willUnmount2', - ]); - }); - - it('should warn for duplicated keys', () => { - spyOn(console, 'error'); - - class Component extends React.Component { - render() { - var children = [
,
]; - return {children}; - } - } - - ReactDOM.render(, container); - - expectDev(console.error.calls.count()).toBe(2); - expectDev(console.error.calls.argsFor(0)[0]).toBe( - 'Warning: flattenChildren(...): ' + - 'Encountered two children with the same key, `1`. ' + - 'Child keys must be unique; when two children share a key, ' + - 'only the first child will be used.', - ); - expectDev(console.error.calls.argsFor(1)[0]).toBe( - 'Warning: flattenChildren(...): ' + - 'Encountered two children with the same key, `1`. ' + - 'Child keys must be unique; when two children share a key, ' + - 'only the first child will be used.', - ); - }); -}); diff --git a/src/addons/update.js b/src/addons/update.js deleted file mode 100644 index d690c6723aed3..0000000000000 --- a/src/addons/update.js +++ /dev/null @@ -1,169 +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. - * - * @providesModule update - */ - -/* global hasOwnProperty:true */ - -'use strict'; - -var invariant = require('fbjs/lib/invariant'); -var hasOwnProperty = {}.hasOwnProperty; - -function shallowCopy(x) { - if (Array.isArray(x)) { - return x.concat(); - } else if (x && typeof x === 'object') { - return Object.assign(new x.constructor(), x); - } else { - return x; - } -} - -var COMMAND_PUSH = '$push'; -var COMMAND_UNSHIFT = '$unshift'; -var COMMAND_SPLICE = '$splice'; -var COMMAND_SET = '$set'; -var COMMAND_MERGE = '$merge'; -var COMMAND_APPLY = '$apply'; - -var ALL_COMMANDS_LIST = [ - COMMAND_PUSH, - COMMAND_UNSHIFT, - COMMAND_SPLICE, - COMMAND_SET, - COMMAND_MERGE, - COMMAND_APPLY, -]; - -var ALL_COMMANDS_SET = {}; - -ALL_COMMANDS_LIST.forEach(function(command) { - ALL_COMMANDS_SET[command] = true; -}); - -function invariantArrayCase(value, spec, command) { - invariant( - Array.isArray(value), - 'update(): expected target of %s to be an array; got %s.', - command, - value, - ); - var specValue = spec[command]; - invariant( - Array.isArray(specValue), - 'update(): expected spec of %s to be an array; got %s. ' + - 'Did you forget to wrap your parameter in an array?', - command, - specValue, - ); -} - -/** - * Returns a updated shallow copy of an object without mutating the original. - * See https://facebook.github.io/react/docs/update.html for details. - */ -function update(value, spec) { - invariant( - typeof spec === 'object', - 'update(): You provided a key path to update() that did not contain one ' + - 'of %s. Did you forget to include {%s: ...}?', - ALL_COMMANDS_LIST.join(', '), - COMMAND_SET, - ); - - if (hasOwnProperty.call(spec, COMMAND_SET)) { - invariant( - Object.keys(spec).length === 1, - 'Cannot have more than one key in an object with %s', - COMMAND_SET, - ); - - return spec[COMMAND_SET]; - } - - var nextValue = shallowCopy(value); - - if (hasOwnProperty.call(spec, COMMAND_MERGE)) { - var mergeObj = spec[COMMAND_MERGE]; - invariant( - mergeObj && typeof mergeObj === 'object', - "update(): %s expects a spec of type 'object'; got %s", - COMMAND_MERGE, - mergeObj, - ); - invariant( - nextValue && typeof nextValue === 'object', - "update(): %s expects a target of type 'object'; got %s", - COMMAND_MERGE, - nextValue, - ); - Object.assign(nextValue, spec[COMMAND_MERGE]); - } - - if (hasOwnProperty.call(spec, COMMAND_PUSH)) { - invariantArrayCase(value, spec, COMMAND_PUSH); - spec[COMMAND_PUSH].forEach(function(item) { - nextValue.push(item); - }); - } - - if (hasOwnProperty.call(spec, COMMAND_UNSHIFT)) { - invariantArrayCase(value, spec, COMMAND_UNSHIFT); - spec[COMMAND_UNSHIFT].forEach(function(item) { - nextValue.unshift(item); - }); - } - - if (hasOwnProperty.call(spec, COMMAND_SPLICE)) { - invariant( - Array.isArray(value), - 'Expected %s target to be an array; got %s', - COMMAND_SPLICE, - value, - ); - invariant( - Array.isArray(spec[COMMAND_SPLICE]), - 'update(): expected spec of %s to be an array of arrays; got %s. ' + - 'Did you forget to wrap your parameters in an array?', - COMMAND_SPLICE, - spec[COMMAND_SPLICE], - ); - spec[COMMAND_SPLICE].forEach(function(args) { - invariant( - Array.isArray(args), - 'update(): expected spec of %s to be an array of arrays; got %s. ' + - 'Did you forget to wrap your parameters in an array?', - COMMAND_SPLICE, - spec[COMMAND_SPLICE], - ); - nextValue.splice.apply(nextValue, args); - }); - } - - if (hasOwnProperty.call(spec, COMMAND_APPLY)) { - invariant( - typeof spec[COMMAND_APPLY] === 'function', - 'update(): expected spec of %s to be a function; got %s.', - COMMAND_APPLY, - spec[COMMAND_APPLY], - ); - nextValue = spec[COMMAND_APPLY](nextValue); - } - - for (var k in spec) { - if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) { - nextValue[k] = update(value[k], spec[k]); - } - } - - return nextValue; -} - -module.exports = update; diff --git a/src/umd/ReactDOMUMDEntry.js b/src/umd/ReactDOMUMDEntry.js index be641918b01be..1eb0de55c34d0 100644 --- a/src/umd/ReactDOMUMDEntry.js +++ b/src/umd/ReactDOMUMDEntry.js @@ -25,10 +25,4 @@ if (__DEV__) { }; } -// Inject ReactDOM into React for the addons UMD build that depends on ReactDOM (TransitionGroup). -// We can remove this after we deprecate and remove the addons UMD build. -if (React.addons) { - React.__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMUMDEntry; -} - module.exports = ReactDOMUMDEntry; diff --git a/src/umd/ReactWithAddonsUMDEntry.js b/src/umd/ReactWithAddonsUMDEntry.js deleted file mode 100644 index 3e02225990219..0000000000000 --- a/src/umd/ReactWithAddonsUMDEntry.js +++ /dev/null @@ -1,37 +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. - * - * @providesModule ReactWithAddonsUMDEntry - */ - -'use strict'; - -var ReactWithAddons = require('ReactWithAddons'); - -// `version` will be added here by the React module. -var ReactWithAddonsUMDEntry = Object.assign( - { - __SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: null, // Will be injected by ReactDOM UMD build. - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { - ReactCurrentOwner: require('react/lib/ReactCurrentOwner'), - }, - }, - ReactWithAddons, -); - -if (__DEV__) { - Object.assign( - ReactWithAddonsUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - { - // ReactComponentTreeHook should not be included in production. - ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'), - }, - ); -} - -module.exports = ReactWithAddonsUMDEntry; diff --git a/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js b/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js deleted file mode 100644 index f4c06de045e18..0000000000000 --- a/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js +++ /dev/null @@ -1,36 +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. - * - * @providesModule ReactAddonsDOMDependenciesUMDShim - */ - -'use strict'; - -var ReactDOM; - -function getReactDOM() { - if (!ReactDOM) { - // This is safe to use because current module only exists in the addons build: - var ReactWithAddonsUMDEntry = require('ReactWithAddonsUMDEntry'); - // This is injected by the ReactDOM UMD build: - ReactDOM = ReactWithAddonsUMDEntry.__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - } - return ReactDOM; -} - -exports.getReactDOM = getReactDOM; - -if (__DEV__) { - exports.getReactPerf = function() { - return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf; - }; - - exports.getReactTestUtils = function() { - return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils; - }; -} From ef45923eafca70ac28a7a98692b2f163b2d85e09 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 17 Mar 2017 23:13:03 +0000 Subject: [PATCH 2/9] Remove ReactFragment dependency from tests --- .../children/__tests__/ReactChildren-test.js | 160 +++++++----------- .../children/__tests__/onlyChild-test.js | 4 +- .../types/__tests__/ReactPropTypes-test.js | 25 +-- src/renderers/__tests__/ReactIdentity-test.js | 20 +-- 4 files changed, 65 insertions(+), 144 deletions(-) diff --git a/src/isomorphic/children/__tests__/ReactChildren-test.js b/src/isomorphic/children/__tests__/ReactChildren-test.js index 6c3421c96d62d..c982509bb3f98 100644 --- a/src/isomorphic/children/__tests__/ReactChildren-test.js +++ b/src/isomorphic/children/__tests__/ReactChildren-test.js @@ -13,12 +13,10 @@ describe('ReactChildren', () => { var React; - var ReactFragment; beforeEach(() => { jest.resetModules(); React = require('react'); - ReactFragment = require('ReactFragment'); }); it('should support identity for simple', () => { @@ -150,8 +148,8 @@ describe('ReactChildren', () => { var instance = (
{div} - {[ReactFragment.create({span})]} - {ReactFragment.create({a: a})} + {[[span]]} + {[a]} {'string'} {1234} {true} @@ -164,8 +162,8 @@ describe('ReactChildren', () => { function assertCalls() { expect(callback.calls.count()).toBe(9); expect(callback).toHaveBeenCalledWith(div, 0); - expect(callback).toHaveBeenCalledWith(, 1); - expect(callback).toHaveBeenCalledWith(, 2); + expect(callback).toHaveBeenCalledWith(span, 1); + expect(callback).toHaveBeenCalledWith(a, 2); expect(callback).toHaveBeenCalledWith('string', 3); expect(callback).toHaveBeenCalledWith(1234, 4); expect(callback).toHaveBeenCalledWith(null, 5); @@ -186,8 +184,8 @@ describe('ReactChildren', () => { assertCalls(); expect(mappedChildren).toEqual([
, - , - , + , + , 'string', 1234, ]); @@ -199,12 +197,7 @@ describe('ReactChildren', () => { var two =
; var three = null; var four =
; - var five =
; - // five is placed into a JS object with a key that is joined to the - // component key attribute. - // Precedence is as follows: - // 1. If grouped in an Object, the object key combined with `key` prop - // 2. If grouped in an Array, the `key` prop, falling back to array index + var five =
; var context = {}; var callback = jasmine.createSpy().and.callFake(function(kid) { @@ -213,34 +206,18 @@ describe('ReactChildren', () => { var instance = (
- {[ - ReactFragment.create({ - firstHalfKey: [zero, one, two], - secondHalfKey: [three, four], - keyFive: five, - }), - ]} + {[[zero, one, two], [three, four], five]}
); function assertCalls() { - expect(callback.calls.count()).toBe(4); - expect(callback).toHaveBeenCalledWith( -
, - 0, - ); - expect(callback).toHaveBeenCalledWith( -
, - 1, - ); - expect(callback).toHaveBeenCalledWith( -
, - 2, - ); - expect(callback).toHaveBeenCalledWith( -
, - 3, - ); + expect(callback.calls.count()).toBe(6); + expect(callback).toHaveBeenCalledWith(zero, 0); + expect(callback).toHaveBeenCalledWith(one, 1); + expect(callback).toHaveBeenCalledWith(two, 2); + expect(callback).toHaveBeenCalledWith(three, 3); + expect(callback).toHaveBeenCalledWith(four, 4); + expect(callback).toHaveBeenCalledWith(five, 5); callback.calls.reset(); } @@ -254,10 +231,10 @@ describe('ReactChildren', () => { ); assertCalls(); expect(mappedChildren).toEqual([ -
, -
, -
, -
, +
, +
, +
, +
, ]); }); @@ -601,52 +578,49 @@ describe('ReactChildren', () => { var two =
; var three = null; var four =
; - var five =
; - // five is placed into a JS object with a key that is joined to the - // component key attribute. - // Precedence is as follows: - // 1. If grouped in an Object, the object key combined with `key` prop - // 2. If grouped in an Array, the `key` prop, falling back to array index + var five =
; var zeroMapped =
; // Key should be overridden var twoMapped =
; // Key should be added even if not supplied! var fourMapped =
; var fiveMapped =
; - var callback = jasmine.createSpy().and.callFake(function(kid, index) { - return index === 0 - ? zeroMapped - : index === 1 ? twoMapped : index === 2 ? fourMapped : fiveMapped; + var callback = jasmine.createSpy().and.callFake(function(kid) { + switch (kid) { + case zero: + return zeroMapped; + case two: + return twoMapped; + case four: + return fourMapped; + case five: + return fiveMapped; + default: + return kid; + } }); - var frag = ReactFragment.create({ - firstHalfKey: [zero, one, two], - secondHalfKey: [three, four], - keyFive: five, - }); + var frag = [[zero, one, two], [three, four], five]; var instance =
{[frag]}
; - expect([frag[0].key, frag[1].key, frag[2].key, frag[3].key]).toEqual([ - 'firstHalfKey/.$keyZero', - 'firstHalfKey/.$keyTwo', - 'secondHalfKey/.$keyFour', - 'keyFive/.$keyFiveInner', - ]); - React.Children.forEach(instance.props.children, callback); - expect(callback.calls.count()).toBe(4); - expect(callback).toHaveBeenCalledWith(frag[0], 0); - expect(callback).toHaveBeenCalledWith(frag[1], 1); - expect(callback).toHaveBeenCalledWith(frag[2], 2); - expect(callback).toHaveBeenCalledWith(frag[3], 3); + expect(callback.calls.count()).toBe(6); + expect(callback).toHaveBeenCalledWith(zero, 0); + expect(callback).toHaveBeenCalledWith(one, 1); + expect(callback).toHaveBeenCalledWith(two, 2); + expect(callback).toHaveBeenCalledWith(three, 3); + expect(callback).toHaveBeenCalledWith(four, 4); + expect(callback).toHaveBeenCalledWith(five, 5); callback.calls.reset(); var mappedChildren = React.Children.map(instance.props.children, callback); - expect(callback.calls.count()).toBe(4); - expect(callback).toHaveBeenCalledWith(frag[0], 0); - expect(callback).toHaveBeenCalledWith(frag[1], 1); - expect(callback).toHaveBeenCalledWith(frag[2], 2); - expect(callback).toHaveBeenCalledWith(frag[3], 3); + expect(callback.calls.count()).toBe(6); + expect(callback).toHaveBeenCalledWith(zero, 0); + expect(callback).toHaveBeenCalledWith(one, 1); + expect(callback).toHaveBeenCalledWith(two, 2); + expect(callback).toHaveBeenCalledWith(three, 3); + expect(callback).toHaveBeenCalledWith(four, 4); + expect(callback).toHaveBeenCalledWith(five, 5); expect(React.Children.count(mappedChildren)).toBe(4); // Keys default to indices. @@ -656,20 +630,16 @@ describe('ReactChildren', () => { mappedChildren[2].key, mappedChildren[3].key, ]).toEqual([ - 'giraffe/.0:$firstHalfKey/.$keyZero', - '.0:$firstHalfKey/.$keyTwo', - 'keyFour/.0:$secondHalfKey/.$keyFour', - '.0:$keyFive/.$keyFiveInner', + 'giraffe/.0:0:$keyZero', + '.0:0:$keyTwo', + '.0:1:$keyFour', + '.0:$keyFive', ]); - expect(mappedChildren[0]).toEqual( -
, - ); - expect(mappedChildren[1]).toEqual(
); - expect(mappedChildren[2]).toEqual( -
, - ); - expect(mappedChildren[3]).toEqual(
); + expect(mappedChildren[0]).toEqual(
); + expect(mappedChildren[1]).toEqual(
); + expect(mappedChildren[2]).toEqual(
); + expect(mappedChildren[3]).toEqual(
); }); it('should retain key across two mappings', () => { @@ -812,27 +782,15 @@ describe('ReactChildren', () => { var two =
; var three = null; var four =
; - var five =
; - // five is placed into a JS object with a key that is joined to the - // component key attribute. - // Precedence is as follows: - // 1. If grouped in an Object, the object key combined with `key` prop - // 2. If grouped in an Array, the `key` prop, falling back to array index + var five =
; var instance = (
- {[ - ReactFragment.create({ - firstHalfKey: [zero, one, two], - secondHalfKey: [three, four], - keyFive: five, - }), - null, - ]} + {[[[zero, one, two], [three, four], five], null]}
); var numberOfChildren = React.Children.count(instance.props.children); - expect(numberOfChildren).toBe(5); + expect(numberOfChildren).toBe(7); }); it('should flatten children to an array', () => { diff --git a/src/isomorphic/children/__tests__/onlyChild-test.js b/src/isomorphic/children/__tests__/onlyChild-test.js index 45ee0f74b3735..606f1be71a668 100644 --- a/src/isomorphic/children/__tests__/onlyChild-test.js +++ b/src/isomorphic/children/__tests__/onlyChild-test.js @@ -13,13 +13,11 @@ describe('onlyChild', () => { var React; - var ReactFragment; var onlyChild; var WrapComponent; beforeEach(() => { React = require('react'); - ReactFragment = require('ReactFragment'); onlyChild = require('onlyChild'); WrapComponent = class extends React.Component { render() { @@ -68,7 +66,7 @@ describe('onlyChild', () => { expect(function() { var instance = ( - {ReactFragment.create({oneThing: })} + {{oneThing: }} ); onlyChild(instance.props.children); diff --git a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js index c5ba572fb25cf..74059935308c9 100644 --- a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js +++ b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js @@ -16,7 +16,6 @@ var checkPropTypes; var checkReactTypeSpec; var React; var ReactDOM; -var ReactFragment; var Component; var MyComponent; @@ -115,7 +114,6 @@ describe('ReactPropTypes', () => { PropTypes = require('ReactPropTypes'); React = require('react'); ReactDOM = require('react-dom'); - ReactFragment = require('ReactFragment'); resetWarningCache(); }); @@ -615,39 +613,20 @@ describe('ReactPropTypes', () => { }); it('should not warn for valid values', () => { - spyOn(console, 'error'); typeCheckPass(PropTypes.node,
); typeCheckPass(PropTypes.node, false); typeCheckPass(PropTypes.node, ); typeCheckPass(PropTypes.node, 'Some string'); typeCheckPass(PropTypes.node, []); - typeCheckPass(PropTypes.node, [ 123, 'Some string',
, ['Another string', [456], , ], , + null, + undefined, ]); - - // Object of renderable things - var frag = ReactFragment.create; - typeCheckPass( - PropTypes.node, - frag({ - k0: 123, - k1: 'Some string', - k2:
, - k3: frag({ - k30: , - k31: frag({k310: }), - k32: 'Another string', - }), - k4: null, - k5: undefined, - }), - ); - expectDev(console.error.calls.count()).toBe(0); }); it('should not warn for iterables', () => { diff --git a/src/renderers/__tests__/ReactIdentity-test.js b/src/renderers/__tests__/ReactIdentity-test.js index e25f1ff049d6e..369c62570660d 100644 --- a/src/renderers/__tests__/ReactIdentity-test.js +++ b/src/renderers/__tests__/ReactIdentity-test.js @@ -13,7 +13,6 @@ var React; var ReactDOM; -var ReactFragment; var ReactTestUtils; describe('ReactIdentity', () => { @@ -21,14 +20,9 @@ describe('ReactIdentity', () => { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); - ReactFragment = require('ReactFragment'); ReactTestUtils = require('ReactTestUtils'); }); - function frag(obj) { - return ReactFragment.create(obj); - } - it('should allow key property to express identity', () => { var node; var Component = props => ( @@ -72,21 +66,13 @@ describe('ReactIdentity', () => { function renderAComponentWithKeyIntoContainer(key, container) { class Wrapper extends React.Component { render() { - var s1 = ; - var s2 = ; - - var map = {}; - map[key] = s2; - return
{[s1, frag(map)]}
; + return
; } } var instance = ReactDOM.render(, container); - var span1 = instance.refs.span1; - var span2 = instance.refs.span2; - - expect(ReactDOM.findDOMNode(span1)).not.toBe(null); - expect(ReactDOM.findDOMNode(span2)).not.toBe(null); + var span = instance.refs.span; + expect(ReactDOM.findDOMNode(span)).not.toBe(null); } it('should allow any character as a key, in a detached parent', () => { From 9f2dd9e05305201ea6acf48e54467a1e8172cdae Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 18 Mar 2017 00:05:16 +0000 Subject: [PATCH 3/9] Remove addons testing from fixtures --- fixtures/packaging/README.md | 4 ++-- fixtures/packaging/browserify/index.html | 10 -------- fixtures/packaging/browserify/input.js | 11 +-------- fixtures/packaging/brunch/app/initialize.js | 11 +-------- fixtures/packaging/brunch/index.html | 10 -------- fixtures/packaging/brunch/input.js | 11 +-------- fixtures/packaging/brunch/package.json | 2 +- fixtures/packaging/globals.html | 23 ++----------------- fixtures/packaging/requirejs.html | 23 ++----------------- fixtures/packaging/rjs/config.js | 2 +- fixtures/packaging/rjs/index.html | 10 -------- fixtures/packaging/rjs/input.js | 11 +-------- fixtures/packaging/systemjs-builder/config.js | 2 +- .../packaging/systemjs-builder/index.html | 10 -------- fixtures/packaging/systemjs-builder/input.js | 11 +-------- fixtures/packaging/systemjs.html | 23 ++----------------- fixtures/packaging/webpack-alias/config.js | 2 +- fixtures/packaging/webpack-alias/index.html | 10 -------- fixtures/packaging/webpack-alias/input.js | 11 +-------- fixtures/packaging/webpack/index.html | 10 -------- fixtures/packaging/webpack/input.js | 11 +-------- 21 files changed, 19 insertions(+), 199 deletions(-) diff --git a/fixtures/packaging/README.md b/fixtures/packaging/README.md index 4cfaa439ba56e..af59bcaa1607e 100644 --- a/fixtures/packaging/README.md +++ b/fixtures/packaging/README.md @@ -6,7 +6,7 @@ If you use React you don't need to worry about it. These fixtures verify that the built React distributions are usable in different environments. **They are not running automatically.** (At least not yet, feel free to contribute to automate them.) -Run them when you make changes to how we package React, ReactDOM, and addons. +Run them when you make changes to how we package React and ReactDOM. ## How to Run @@ -46,5 +46,5 @@ open http://localhost:9000/fixtures/webpack-alias/index.html You should see two things: -* "Hello World" fading in with an animation. +* "Hello World" is rendered. * No errors in the console. diff --git a/fixtures/packaging/browserify/index.html b/fixtures/packaging/browserify/index.html index d2b798e524e57..e010d6b31db68 100644 --- a/fixtures/packaging/browserify/index.html +++ b/fixtures/packaging/browserify/index.html @@ -1,15 +1,5 @@ -
diff --git a/fixtures/packaging/browserify/input.js b/fixtures/packaging/browserify/input.js index da6cc5d0ff1fd..93a0e76d43dfb 100644 --- a/fixtures/packaging/browserify/input.js +++ b/fixtures/packaging/browserify/input.js @@ -1,16 +1,7 @@ var React = require('react'); -var CSSTransitionGroup = require('react-addons-css-transition-group'); var ReactDOM = require('react-dom'); ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); diff --git a/fixtures/packaging/brunch/app/initialize.js b/fixtures/packaging/brunch/app/initialize.js index da6cc5d0ff1fd..93a0e76d43dfb 100644 --- a/fixtures/packaging/brunch/app/initialize.js +++ b/fixtures/packaging/brunch/app/initialize.js @@ -1,16 +1,7 @@ var React = require('react'); -var CSSTransitionGroup = require('react-addons-css-transition-group'); var ReactDOM = require('react-dom'); ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); diff --git a/fixtures/packaging/brunch/index.html b/fixtures/packaging/brunch/index.html index 859d98d0f2be4..5902a1a6905dc 100644 --- a/fixtures/packaging/brunch/index.html +++ b/fixtures/packaging/brunch/index.html @@ -1,15 +1,5 @@ -
diff --git a/fixtures/packaging/brunch/input.js b/fixtures/packaging/brunch/input.js index da6cc5d0ff1fd..93a0e76d43dfb 100644 --- a/fixtures/packaging/brunch/input.js +++ b/fixtures/packaging/brunch/input.js @@ -1,16 +1,7 @@ var React = require('react'); -var CSSTransitionGroup = require('react-addons-css-transition-group'); var ReactDOM = require('react-dom'); ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); diff --git a/fixtures/packaging/brunch/package.json b/fixtures/packaging/brunch/package.json index 8799e2956ee3e..4713d27c21c33 100644 --- a/fixtures/packaging/brunch/package.json +++ b/fixtures/packaging/brunch/package.json @@ -5,6 +5,6 @@ "javascript-brunch": "^2.0.0" }, "scripts": { - "build": "rm -rf public && ln -fs ../../../../build/packages/react node_modules/react && ln -fs ../../../../build/packages/react-dom node_modules/react-dom && ln -fs ../../../../build/packages/react-addons-css-transition-group node_modules/react-addons-css-transition-group && brunch build" + "build": "rm -rf public && ln -fs ../../../../build/packages/react node_modules/react && ln -fs ../../../../build/packages/react-dom node_modules/react-dom && brunch build" } } \ No newline at end of file diff --git a/fixtures/packaging/globals.html b/fixtures/packaging/globals.html index 1bc3ef5e4f8f2..3c80fbfe8d47d 100644 --- a/fixtures/packaging/globals.html +++ b/fixtures/packaging/globals.html @@ -1,30 +1,11 @@ - + -
diff --git a/fixtures/packaging/requirejs.html b/fixtures/packaging/requirejs.html index d181b28f4fe19..325a2f031a6ef 100644 --- a/fixtures/packaging/requirejs.html +++ b/fixtures/packaging/requirejs.html @@ -1,37 +1,18 @@ -
diff --git a/fixtures/packaging/rjs/input.js b/fixtures/packaging/rjs/input.js index 2b0deee96c2c4..510e71da20221 100644 --- a/fixtures/packaging/rjs/input.js +++ b/fixtures/packaging/rjs/input.js @@ -1,15 +1,6 @@ require(['react', 'react-dom'], function(React, ReactDOM) { - var CSSTransitionGroup = React.addons.CSSTransitionGroup; ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); }); diff --git a/fixtures/packaging/systemjs-builder/config.js b/fixtures/packaging/systemjs-builder/config.js index 931a037bd9c7c..4a4a2c0c3e437 100644 --- a/fixtures/packaging/systemjs-builder/config.js +++ b/fixtures/packaging/systemjs-builder/config.js @@ -1,6 +1,6 @@ System.config({ paths: { - react: '../../../build/react-with-addons.js', + react: '../../../build/react.js', 'react-dom': '../../../build/react-dom.js', }, }); diff --git a/fixtures/packaging/systemjs-builder/index.html b/fixtures/packaging/systemjs-builder/index.html index d2b798e524e57..e010d6b31db68 100644 --- a/fixtures/packaging/systemjs-builder/index.html +++ b/fixtures/packaging/systemjs-builder/index.html @@ -1,15 +1,5 @@ -
diff --git a/fixtures/packaging/systemjs-builder/input.js b/fixtures/packaging/systemjs-builder/input.js index 27d5c10086ca9..e919c6f098b16 100644 --- a/fixtures/packaging/systemjs-builder/input.js +++ b/fixtures/packaging/systemjs-builder/input.js @@ -1,16 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -var CSSTransitionGroup = React.addons.CSSTransitionGroup; ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); diff --git a/fixtures/packaging/systemjs.html b/fixtures/packaging/systemjs.html index 7cd000c939fa8..2f4125c702d5f 100644 --- a/fixtures/packaging/systemjs.html +++ b/fixtures/packaging/systemjs.html @@ -1,21 +1,11 @@ -
diff --git a/fixtures/packaging/webpack-alias/input.js b/fixtures/packaging/webpack-alias/input.js index f1e2d79e23c8f..93a0e76d43dfb 100644 --- a/fixtures/packaging/webpack-alias/input.js +++ b/fixtures/packaging/webpack-alias/input.js @@ -1,16 +1,7 @@ var React = require('react'); var ReactDOM = require('react-dom'); -var CSSTransitionGroup = React.addons.CSSTransitionGroup; ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); diff --git a/fixtures/packaging/webpack/index.html b/fixtures/packaging/webpack/index.html index d2b798e524e57..e010d6b31db68 100644 --- a/fixtures/packaging/webpack/index.html +++ b/fixtures/packaging/webpack/index.html @@ -1,15 +1,5 @@ -
diff --git a/fixtures/packaging/webpack/input.js b/fixtures/packaging/webpack/input.js index da6cc5d0ff1fd..93a0e76d43dfb 100644 --- a/fixtures/packaging/webpack/input.js +++ b/fixtures/packaging/webpack/input.js @@ -1,16 +1,7 @@ var React = require('react'); -var CSSTransitionGroup = require('react-addons-css-transition-group'); var ReactDOM = require('react-dom'); ReactDOM.render( - React.createElement(CSSTransitionGroup, { - transitionName: 'example', - transitionAppear: true, - transitionAppearTimeout: 500, - transitionEnterTimeout: 0, - transitionLeaveTimeout: 0, - }, React.createElement('h1', null, - 'Hello World!' - )), + React.createElement('h1', null, 'Hello World!'), document.getElementById('container') ); From 056a630e63f117d9a0fb3dc626a478b885a87e9c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 18 Mar 2017 00:08:06 +0000 Subject: [PATCH 4/9] Don't mention createFragment() in a warning --- src/isomorphic/children/__tests__/ReactChildren-test.js | 6 ++---- src/renderers/shared/fiber/ReactChildFiber.js | 3 +-- src/shared/utils/traverseAllChildren.js | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/isomorphic/children/__tests__/ReactChildren-test.js b/src/isomorphic/children/__tests__/ReactChildren-test.js index c982509bb3f98..a71ea8f7a7cf9 100644 --- a/src/isomorphic/children/__tests__/ReactChildren-test.js +++ b/src/isomorphic/children/__tests__/ReactChildren-test.js @@ -836,8 +836,7 @@ describe('ReactChildren', () => { }).toThrowError( 'Objects are not valid as a React child (found: object with keys ' + '{a, b}). If you meant to render a collection of children, use an ' + - 'array instead or wrap the object using createFragment(object) from ' + - 'the React add-ons.', + 'array instead.', ); }); @@ -848,8 +847,7 @@ describe('ReactChildren', () => { React.Children.forEach(/abc/, function() {}, null); }).toThrowError( 'Objects are not valid as a React child (found: /abc/). If you meant ' + - 'to render a collection of children, use an array instead or wrap the ' + - 'object using createFragment(object) from the React add-ons.', + 'to render a collection of children, use an array instead.', ); }); }); diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index 9c8c416abb00d..f56c80e1b9e7b 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -127,8 +127,7 @@ function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { let addendum = ''; if (__DEV__) { addendum = ' If you meant to render a collection of children, use an array ' + - 'instead or wrap the object using createFragment(object) from the ' + - 'React add-ons.'; + 'instead.'; const owner = ReactCurrentOwner.owner || returnFiber._debugOwner; if (owner && typeof owner.tag === 'number') { const name = getComponentName((owner: any)); diff --git a/src/shared/utils/traverseAllChildren.js b/src/shared/utils/traverseAllChildren.js index 933c1e5d9ba6d..dd8b49fb58006 100644 --- a/src/shared/utils/traverseAllChildren.js +++ b/src/shared/utils/traverseAllChildren.js @@ -151,8 +151,7 @@ function traverseAllChildrenImpl( var addendum = ''; if (__DEV__) { addendum = ' If you meant to render a collection of children, use an array ' + - 'instead or wrap the object using createFragment(object) from the ' + - 'React add-ons.'; + 'instead.'; if (ReactCurrentOwner.current) { var name = ReactCurrentOwner.current.getName(); if (name) { From eecd6ce605755fdae070b9f79c3f1396f3486b66 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 18 Mar 2017 16:20:44 +0000 Subject: [PATCH 5/9] Address feedback --- src/isomorphic/children/__tests__/onlyChild-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isomorphic/children/__tests__/onlyChild-test.js b/src/isomorphic/children/__tests__/onlyChild-test.js index 606f1be71a668..2fbd4196efb31 100644 --- a/src/isomorphic/children/__tests__/onlyChild-test.js +++ b/src/isomorphic/children/__tests__/onlyChild-test.js @@ -66,7 +66,7 @@ describe('onlyChild', () => { expect(function() { var instance = ( - {{oneThing: }} + {[]} ); onlyChild(instance.props.children); From 25430d8f61af8e1d1d63f62170d0d44805358ce4 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 18 Mar 2017 16:25:45 +0000 Subject: [PATCH 6/9] Remove unused variables --- grunt/config/browserify.js | 6 ------ src/umd/ReactDOMUMDEntry.js | 1 - 2 files changed, 7 deletions(-) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 3997d8c36fcc6..4cbdef2b25aa9 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -21,12 +21,6 @@ var shimSharedModules = aliasify.configure({ }, }); -var shimDOMModules = aliasify.configure({ - 'aliases': { - './ReactAddonsDOMDependencies': {relative: './ReactAddonsDOMDependenciesUMDShim'}, - }, -}); - var SIMPLE_TEMPLATE = grunt.file.read('./grunt/data/header-template-short.txt'); diff --git a/src/umd/ReactDOMUMDEntry.js b/src/umd/ReactDOMUMDEntry.js index 1eb0de55c34d0..5ab5d8a0202cc 100644 --- a/src/umd/ReactDOMUMDEntry.js +++ b/src/umd/ReactDOMUMDEntry.js @@ -11,7 +11,6 @@ 'use strict'; -var React = require('react'); var ReactDOM = require('react-dom'); var ReactDOMUMDEntry = ReactDOM; From e3dd5a6c627fc6f4855321367ee25b51bf1cc604 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 18 Mar 2017 16:27:35 +0000 Subject: [PATCH 7/9] Remove mention of deleted file --- gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 27bc2cfa0e8d5..f25bc585b5755 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,7 +31,6 @@ var paths = { react: { src: [ 'src/umd/ReactUMDEntry.js', - 'src/umd/ReactWithAddonsUMDEntry.js', 'src/umd/shims/**/*.js', 'src/isomorphic/**/*.js', From b9ea86b2a3fceb95dce209c53bb057c8bd7fe39f Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 19 Mar 2017 18:36:54 +0000 Subject: [PATCH 8/9] Add a missing key to the test --- src/isomorphic/children/__tests__/onlyChild-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isomorphic/children/__tests__/onlyChild-test.js b/src/isomorphic/children/__tests__/onlyChild-test.js index 2fbd4196efb31..7ca054b76ce39 100644 --- a/src/isomorphic/children/__tests__/onlyChild-test.js +++ b/src/isomorphic/children/__tests__/onlyChild-test.js @@ -66,7 +66,7 @@ describe('onlyChild', () => { expect(function() { var instance = ( - {[]} + {[]} ); onlyChild(instance.props.children); From 25cea63b4e3fe55b96866cfbcaca83e2266aa077 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 20 Mar 2017 13:35:15 +0000 Subject: [PATCH 9/9] Fix lint --- src/isomorphic/children/__tests__/onlyChild-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isomorphic/children/__tests__/onlyChild-test.js b/src/isomorphic/children/__tests__/onlyChild-test.js index 7ca054b76ce39..082c389e6b532 100644 --- a/src/isomorphic/children/__tests__/onlyChild-test.js +++ b/src/isomorphic/children/__tests__/onlyChild-test.js @@ -66,7 +66,7 @@ describe('onlyChild', () => { expect(function() { var instance = ( - {[]} + {[]} ); onlyChild(instance.props.children);