diff --git a/fixtures/README.md b/fixtures/README.md new file mode 100644 index 0000000000000..0c9646ce4d11d --- /dev/null +++ b/fixtures/README.md @@ -0,0 +1,50 @@ +# Manual Testing Fixtures + +This folder exists for **React contributors** only. +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. + +## How to Run + +First, build React and the fixtures: + +``` +cd react +npm run build + +cd fixtures +node build-all.js +``` + +Then run a local server at the root of the repo, e.g. + +``` +npm i -g pushstate-server +cd .. +pushstate-server . +``` + +(Too complicated? Send a PR to simplify this :-). + +Then open the corresponding URLs, for example: + +``` +open http://localhost:9000/fixtures/globals.html +open http://localhost:9000/fixtures/requirejs.html +open http://localhost:9000/fixtures/systemjs.html +open http://localhost:9000/fixtures/browserify/index.html +open http://localhost:9000/fixtures/brunch/index.html +open http://localhost:9000/fixtures/rjs/index.html +open http://localhost:9000/fixtures/systemjs-builder/index.html +open http://localhost:9000/fixtures/webpack/index.html +open http://localhost:9000/fixtures/webpack-alias/index.html +``` + +You should see two things: + +* "Hello World" fading in with an animation. +* No errors in the console. diff --git a/fixtures/browserify/.gitignore b/fixtures/browserify/.gitignore new file mode 100644 index 0000000000000..66b00e6a05af0 --- /dev/null +++ b/fixtures/browserify/.gitignore @@ -0,0 +1 @@ +output.js diff --git a/fixtures/browserify/index.html b/fixtures/browserify/index.html new file mode 100644 index 0000000000000..d2b798e524e57 --- /dev/null +++ b/fixtures/browserify/index.html @@ -0,0 +1,16 @@ + +
+ + + + + \ No newline at end of file diff --git a/fixtures/browserify/input.js b/fixtures/browserify/input.js new file mode 100644 index 0000000000000..da6cc5d0ff1fd --- /dev/null +++ b/fixtures/browserify/input.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/browserify/package.json b/fixtures/browserify/package.json new file mode 100644 index 0000000000000..dbcf1dd834aa4 --- /dev/null +++ b/fixtures/browserify/package.json @@ -0,0 +1,10 @@ +{ + "name": "webpack-test", + "private": true, + "dependencies": { + "browserify": "^13.3.0" + }, + "scripts": { + "build": "rm -f output.js && NODE_PATH=../../build/packages browserify ./input.js -o output.js" + } +} diff --git a/fixtures/brunch/.gitignore b/fixtures/brunch/.gitignore new file mode 100644 index 0000000000000..b8d1dfad58f8f --- /dev/null +++ b/fixtures/brunch/.gitignore @@ -0,0 +1,2 @@ +output.js +output.js.map \ No newline at end of file diff --git a/fixtures/brunch/app/initialize.js b/fixtures/brunch/app/initialize.js new file mode 100644 index 0000000000000..da6cc5d0ff1fd --- /dev/null +++ b/fixtures/brunch/app/initialize.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/brunch/config.js b/fixtures/brunch/config.js new file mode 100644 index 0000000000000..ba12fc72c23d6 --- /dev/null +++ b/fixtures/brunch/config.js @@ -0,0 +1,10 @@ +exports.config = { + paths: { + public: '.', + }, + files: { + javascripts: { + joinTo: 'output.js', + }, + }, +}; diff --git a/fixtures/brunch/index.html b/fixtures/brunch/index.html new file mode 100644 index 0000000000000..859d98d0f2be4 --- /dev/null +++ b/fixtures/brunch/index.html @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/fixtures/brunch/input.js b/fixtures/brunch/input.js new file mode 100644 index 0000000000000..da6cc5d0ff1fd --- /dev/null +++ b/fixtures/brunch/input.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/brunch/package.json b/fixtures/brunch/package.json new file mode 100644 index 0000000000000..d00bcc0ef023d --- /dev/null +++ b/fixtures/brunch/package.json @@ -0,0 +1,10 @@ +{ + "name": "brunch-test", + "devDependencies": { + "brunch": "^2.9.1", + "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" + } +} \ No newline at end of file diff --git a/fixtures/build-all.js b/fixtures/build-all.js new file mode 100644 index 0000000000000..b5620c0fa32e0 --- /dev/null +++ b/fixtures/build-all.js @@ -0,0 +1,30 @@ +var fs = require('fs'); +var path = require('path'); +var { spawnSync } = require('child_process'); + +var fixtureDirs = fs.readdirSync(__dirname).filter((file) => { + return fs.statSync(path.join(__dirname, file)).isDirectory(); +}); + +var cmdArgs = [ + {cmd: 'npm', args: ['install']}, + {cmd: 'npm', args: ['run', 'build']}, +]; + +for (const dir of fixtureDirs) { + for (const cmdArg of cmdArgs) { + const opts = { + cwd: path.join(__dirname, dir), + stdio: 'inherit', + }; + let result = spawnSync(cmdArg.cmd, cmdArg.args, opts); + if (result.status !== 0) { + throw new Error('Failed to build fixtures.'); + } + } +} + +console.log('-------------------------'); +console.log('All fixtures were built!'); +console.log('Now make sure to open each HTML file in this directory and each index.html in subdirectories.'); +console.log('-------------------------'); diff --git a/fixtures/globals.html b/fixtures/globals.html new file mode 100644 index 0000000000000..c3a7da3c59525 --- /dev/null +++ b/fixtures/globals.html @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/fixtures/requirejs.html b/fixtures/requirejs.html new file mode 100644 index 0000000000000..c2ff2338a3e34 --- /dev/null +++ b/fixtures/requirejs.html @@ -0,0 +1,40 @@ + + + + + + + + \ No newline at end of file diff --git a/fixtures/rjs/.gitignore b/fixtures/rjs/.gitignore new file mode 100644 index 0000000000000..fa213fe698b13 --- /dev/null +++ b/fixtures/rjs/.gitignore @@ -0,0 +1 @@ +output.js \ No newline at end of file diff --git a/fixtures/rjs/config.js b/fixtures/rjs/config.js new file mode 100644 index 0000000000000..f15dc11003552 --- /dev/null +++ b/fixtures/rjs/config.js @@ -0,0 +1,10 @@ +module.exports = { + baseUrl: '.', + name: 'input', + out: 'output.js', + optimize: 'none', + paths: { + react: '../../build/react-with-addons', + 'react-dom': '../../build/react-dom', + }, +}; diff --git a/fixtures/rjs/index.html b/fixtures/rjs/index.html new file mode 100644 index 0000000000000..24995379a1228 --- /dev/null +++ b/fixtures/rjs/index.html @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/fixtures/rjs/input.js b/fixtures/rjs/input.js new file mode 100644 index 0000000000000..2b0deee96c2c4 --- /dev/null +++ b/fixtures/rjs/input.js @@ -0,0 +1,15 @@ +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!' + )), + document.getElementById('container') + ); +}); diff --git a/fixtures/rjs/package.json b/fixtures/rjs/package.json new file mode 100644 index 0000000000000..bc94a37011eea --- /dev/null +++ b/fixtures/rjs/package.json @@ -0,0 +1,10 @@ +{ + "name": "rjs-test", + "private": true, + "dependencies": { + "requirejs": "^2.3.2" + }, + "scripts": { + "build": "rm -f output.js && r.js -o config.js" + } +} diff --git a/fixtures/systemjs-builder/.gitignore b/fixtures/systemjs-builder/.gitignore new file mode 100644 index 0000000000000..fa213fe698b13 --- /dev/null +++ b/fixtures/systemjs-builder/.gitignore @@ -0,0 +1 @@ +output.js \ No newline at end of file diff --git a/fixtures/systemjs-builder/build.js b/fixtures/systemjs-builder/build.js new file mode 100644 index 0000000000000..d476c09a64624 --- /dev/null +++ b/fixtures/systemjs-builder/build.js @@ -0,0 +1,12 @@ +var Builder = require('systemjs-builder'); + +var builder = new Builder('/', './config.js'); +builder + .buildStatic('./input.js', './output.js') + .then(function() { + console.log('Build complete'); + }) + .catch(function(err) { + console.log('Build error'); + console.log(err); + }); diff --git a/fixtures/systemjs-builder/config.js b/fixtures/systemjs-builder/config.js new file mode 100644 index 0000000000000..baed2db8c624c --- /dev/null +++ b/fixtures/systemjs-builder/config.js @@ -0,0 +1,6 @@ +System.config({ + paths: { + react: '../../build/react-with-addons.js', + 'react-dom': '../../build/react-dom.js', + }, +}); diff --git a/fixtures/systemjs-builder/index.html b/fixtures/systemjs-builder/index.html new file mode 100644 index 0000000000000..d2b798e524e57 --- /dev/null +++ b/fixtures/systemjs-builder/index.html @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/fixtures/systemjs-builder/input.js b/fixtures/systemjs-builder/input.js new file mode 100644 index 0000000000000..27d5c10086ca9 --- /dev/null +++ b/fixtures/systemjs-builder/input.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/systemjs-builder/package.json b/fixtures/systemjs-builder/package.json new file mode 100644 index 0000000000000..b4c6acdccad5e --- /dev/null +++ b/fixtures/systemjs-builder/package.json @@ -0,0 +1,10 @@ +{ + "name": "systemjs-builder-test", + "private": true, + "dependencies": { + "systemjs-builder": "^0.15.34" + }, + "scripts": { + "build": "rm -f output.js && node build.js" + } +} diff --git a/fixtures/systemjs.html b/fixtures/systemjs.html new file mode 100644 index 0000000000000..9c4430791cb80 --- /dev/null +++ b/fixtures/systemjs.html @@ -0,0 +1,46 @@ + + + + + + + + \ No newline at end of file diff --git a/fixtures/webpack-alias/.gitignore b/fixtures/webpack-alias/.gitignore new file mode 100644 index 0000000000000..fa213fe698b13 --- /dev/null +++ b/fixtures/webpack-alias/.gitignore @@ -0,0 +1 @@ +output.js \ No newline at end of file diff --git a/fixtures/webpack-alias/config.js b/fixtures/webpack-alias/config.js new file mode 100644 index 0000000000000..dcc0c3a907216 --- /dev/null +++ b/fixtures/webpack-alias/config.js @@ -0,0 +1,13 @@ +module.exports = { + entry: './input', + output: { + filename: 'output.js', + }, + resolve: { + root: '../../build/packages', + alias: { + 'react': 'react/dist/react-with-addons', + 'react-dom': 'react-dom/dist/react-dom', + }, + }, +}; diff --git a/fixtures/webpack-alias/index.html b/fixtures/webpack-alias/index.html new file mode 100644 index 0000000000000..d2b798e524e57 --- /dev/null +++ b/fixtures/webpack-alias/index.html @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/fixtures/webpack-alias/input.js b/fixtures/webpack-alias/input.js new file mode 100644 index 0000000000000..f1e2d79e23c8f --- /dev/null +++ b/fixtures/webpack-alias/input.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/webpack-alias/package.json b/fixtures/webpack-alias/package.json new file mode 100644 index 0000000000000..8ea2da478bbef --- /dev/null +++ b/fixtures/webpack-alias/package.json @@ -0,0 +1,10 @@ +{ + "name": "webpack-test", + "private": true, + "dependencies": { + "webpack": "^1.14.0" + }, + "scripts": { + "build": "rm -f output.js && webpack --config config.js" + } +} diff --git a/fixtures/webpack/.gitignore b/fixtures/webpack/.gitignore new file mode 100644 index 0000000000000..fa213fe698b13 --- /dev/null +++ b/fixtures/webpack/.gitignore @@ -0,0 +1 @@ +output.js \ No newline at end of file diff --git a/fixtures/webpack/config.js b/fixtures/webpack/config.js new file mode 100644 index 0000000000000..685cac24ee906 --- /dev/null +++ b/fixtures/webpack/config.js @@ -0,0 +1,9 @@ +module.exports = { + entry: './input', + output: { + filename: 'output.js', + }, + resolve: { + root: '../../build/packages', + }, +}; diff --git a/fixtures/webpack/index.html b/fixtures/webpack/index.html new file mode 100644 index 0000000000000..d2b798e524e57 --- /dev/null +++ b/fixtures/webpack/index.html @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/fixtures/webpack/input.js b/fixtures/webpack/input.js new file mode 100644 index 0000000000000..da6cc5d0ff1fd --- /dev/null +++ b/fixtures/webpack/input.js @@ -0,0 +1,16 @@ +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!' + )), + document.getElementById('container') +); diff --git a/fixtures/webpack/package.json b/fixtures/webpack/package.json new file mode 100644 index 0000000000000..8ea2da478bbef --- /dev/null +++ b/fixtures/webpack/package.json @@ -0,0 +1,10 @@ +{ + "name": "webpack-test", + "private": true, + "dependencies": { + "webpack": "^1.14.0" + }, + "scripts": { + "build": "rm -f output.js && webpack --config config.js" + } +} diff --git a/scripts/fiber/tests-passing-except-dev.txt b/scripts/fiber/tests-passing-except-dev.txt index 63f25e6d56093..df708821eb6f7 100644 --- a/scripts/fiber/tests-passing-except-dev.txt +++ b/scripts/fiber/tests-passing-except-dev.txt @@ -1,6 +1,3 @@ -src/addons/transitions/__tests__/ReactTransitionGroup-test.js -* should warn for duplicated keys with component stack info - src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js * should not warn when server-side rendering `onScroll` * should warn about incorrect casing on properties (ssr) diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 922e9985011a8..4e55c2cf76781 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -105,6 +105,7 @@ src/addons/transitions/__tests__/ReactTransitionGroup-test.js * 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/children/__tests__/ReactChildren-test.js * should support identity for simple diff --git a/src/addons/ReactAddonsDOMDependencies.js b/src/addons/ReactAddonsDOMDependencies.js index e0b5eb45a5e42..70856ec6c5feb 100644 --- a/src/addons/ReactAddonsDOMDependencies.js +++ b/src/addons/ReactAddonsDOMDependencies.js @@ -12,25 +12,26 @@ 'use strict'; var ReactDOM = require('ReactDOM'); -var ReactInstanceMap = require('ReactInstanceMap'); exports.getReactDOM = function() { return ReactDOM; }; -exports.getReactInstanceMap = function() { - return ReactInstanceMap; -}; - if (__DEV__) { - var ReactPerf = require('ReactPerf'); - var ReactTestUtils = require('ReactTestUtils'); + var ReactPerf; + var ReactTestUtils; exports.getReactPerf = function() { + if (!ReactPerf) { + ReactPerf = require('ReactPerf'); + } return ReactPerf; }; exports.getReactTestUtils = function() { + if (!ReactTestUtils) { + ReactTestUtils = require('ReactTestUtils'); + } return ReactTestUtils; }; } diff --git a/src/addons/transitions/ReactTransitionGroup.js b/src/addons/transitions/ReactTransitionGroup.js index 001b06fb9d0e0..62372801fa3fd 100644 --- a/src/addons/transitions/ReactTransitionGroup.js +++ b/src/addons/transitions/ReactTransitionGroup.js @@ -12,7 +12,6 @@ 'use strict'; var React = require('React'); -var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies'); var ReactTransitionChildMapping = require('ReactTransitionChildMapping'); var emptyFunction = require('emptyFunction'); @@ -56,17 +55,9 @@ class ReactTransitionGroup extends React.Component { } componentWillReceiveProps(nextProps) { - var nextChildMapping; - if (__DEV__) { - nextChildMapping = ReactTransitionChildMapping.getChildMapping( - nextProps.children, - ReactAddonsDOMDependencies.getReactInstanceMap().get(this)._debugID - ); - } else { - nextChildMapping = ReactTransitionChildMapping.getChildMapping( - nextProps.children - ); - } + var nextChildMapping = ReactTransitionChildMapping.getChildMapping( + nextProps.children + ); var prevChildMapping = this.state.children; this.setState({ @@ -129,17 +120,9 @@ class ReactTransitionGroup extends React.Component { delete this.currentlyTransitioningKeys[key]; - var currentChildMapping; - if (__DEV__) { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ReactAddonsDOMDependencies.getReactInstanceMap().get(this)._debugID - ); - } else { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children - ); - } + var currentChildMapping = ReactTransitionChildMapping.getChildMapping( + this.props.children + ); if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) { // This was removed before it had fully appeared. Remove it. @@ -169,17 +152,9 @@ class ReactTransitionGroup extends React.Component { delete this.currentlyTransitioningKeys[key]; - var currentChildMapping; - if (__DEV__) { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ReactAddonsDOMDependencies.getReactInstanceMap().get(this)._debugID - ); - } else { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children - ); - } + var currentChildMapping = ReactTransitionChildMapping.getChildMapping( + this.props.children + ); if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) { // This was removed before it had fully entered. Remove it. @@ -210,17 +185,9 @@ class ReactTransitionGroup extends React.Component { delete this.currentlyTransitioningKeys[key]; - var currentChildMapping; - if (__DEV__) { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children, - ReactAddonsDOMDependencies.getReactInstanceMap().get(this)._debugID - ); - } else { - currentChildMapping = ReactTransitionChildMapping.getChildMapping( - this.props.children - ); - } + var currentChildMapping = ReactTransitionChildMapping.getChildMapping( + this.props.children + ); if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) { // This entered again before it fully left. Add it again. diff --git a/src/addons/transitions/__tests__/ReactTransitionGroup-test.js b/src/addons/transitions/__tests__/ReactTransitionGroup-test.js index 12555a98fd0b3..14d171391752c 100644 --- a/src/addons/transitions/__tests__/ReactTransitionGroup-test.js +++ b/src/addons/transitions/__tests__/ReactTransitionGroup-test.js @@ -20,10 +20,6 @@ var ReactTransitionGroup; describe('ReactTransitionGroup', () => { var container; - function normalizeCodeLocInfo(str) { - return str && str.replace(/\(at .+?:\d+\)/g, '(at **)'); - } - beforeEach(() => { React = require('React'); ReactDOM = require('ReactDOM'); @@ -296,7 +292,7 @@ describe('ReactTransitionGroup', () => { ]); }); - it('should warn for duplicated keys with component stack info', () => { + it('should warn for duplicated keys', () => { spyOn(console, 'error'); class Component extends React.Component { @@ -315,13 +311,11 @@ describe('ReactTransitionGroup', () => { 'Child keys must be unique; when two children share a key, ' + 'only the first child will be used.' ); - expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe( + 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.\n' + - ' in ReactTransitionGroup (at **)\n' + - ' in Component (at **)' + 'only the first child will be used.' ); }); }); diff --git a/src/umd/ReactDOMUMDEntry.js b/src/umd/ReactDOMUMDEntry.js index 59daf4bef9c61..03a0318a10503 100644 --- a/src/umd/ReactDOMUMDEntry.js +++ b/src/umd/ReactDOMUMDEntry.js @@ -11,24 +11,24 @@ 'use strict'; +var React = require('React'); var ReactDOM = require('ReactDOM'); -var ReactDOMUMDEntry = Object.assign({ - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { - ReactInstanceMap: require('ReactInstanceMap'), - }, -}, ReactDOM); +var ReactDOMUMDEntry = ReactDOM; if (__DEV__) { - Object.assign( - ReactDOMUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - { - // ReactPerf and ReactTestUtils currently only work with the DOM renderer - // so we expose them from here, but only in DEV mode. - ReactPerf: require('ReactPerf'), - ReactTestUtils: require('ReactTestUtils'), - } - ); + ReactDOMUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { + // ReactPerf and ReactTestUtils currently only work with the DOM renderer + // so we expose them from here, but only in DEV mode. + ReactPerf: require('ReactPerf'), + ReactTestUtils: require('ReactTestUtils'), + }; +} + +// 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 index ad05b565c932e..c59e62e731ea9 100644 --- a/src/umd/ReactWithAddonsUMDEntry.js +++ b/src/umd/ReactWithAddonsUMDEntry.js @@ -15,6 +15,7 @@ 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('ReactCurrentOwner'), }, diff --git a/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js b/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js index 2aa7b886b544b..f4c06de045e18 100644 --- a/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js +++ b/src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js @@ -9,24 +9,28 @@ * @providesModule ReactAddonsDOMDependenciesUMDShim */ -/* globals ReactDOM */ - 'use strict'; -exports.getReactDOM = function() { +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.getReactInstanceMap = function() { - return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInstanceMap; -}; +exports.getReactDOM = getReactDOM; if (__DEV__) { exports.getReactPerf = function() { - return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf; + return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf; }; exports.getReactTestUtils = function() { - return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils; + return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils; }; }