Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4337c1c006 | ||
|
|
170a8b21b6 | ||
|
|
6948842cf8 | ||
|
|
056ac56b52 | ||
|
|
1fb5c123b8 | ||
|
|
790e2446ab | ||
|
|
037717685a | ||
|
|
6d50a9d090 | ||
|
|
f75f8b48a2 | ||
|
|
880587366d | ||
|
|
e614e69657 | ||
|
|
7559722a86 | ||
|
|
7e405d458d | ||
|
|
4890779729 | ||
|
|
f46a80ae11 | ||
|
|
0a4c7c5651 | ||
|
|
993ca533b4 | ||
|
|
40c52de960 | ||
|
|
6eca8eff08 |
@@ -101,7 +101,7 @@ jobs:
|
||||
- *restore_node_modules
|
||||
- run: node ./scripts/tasks/flow-ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test:
|
||||
yarn_test-stable:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=stable --ci
|
||||
- run: yarn test-stable --ci
|
||||
|
||||
yarn_test:
|
||||
docker: *docker
|
||||
@@ -120,79 +120,79 @@ jobs:
|
||||
- *restore_node_modules
|
||||
- run: yarn test --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_www:
|
||||
yarn_test-classic:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-classic --ci
|
||||
- run: yarn test-classic --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_www_variant:
|
||||
yarn_test-classic_variant:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-classic --variant --ci
|
||||
- run: yarn test-classic --variant --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_prod_www:
|
||||
yarn_test-classic_prod:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-classic --prod --ci
|
||||
- run: yarn test-classic --prod --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
|
||||
yarn_test-classic_prod_variant:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-classic --prod --variant --ci
|
||||
- run: yarn test-classic --prod --variant --ci
|
||||
|
||||
yarn_test_www:
|
||||
yarn_test-www:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-modern --ci
|
||||
- run: yarn test-www --ci
|
||||
|
||||
yarn_test_www_variant:
|
||||
yarn_test-www_variant:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-modern --variant --ci
|
||||
- run: yarn test-www --variant --ci
|
||||
|
||||
yarn_test_prod_www:
|
||||
yarn_test-www_prod:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-modern --prod --ci
|
||||
- run: yarn test-www --prod --ci
|
||||
|
||||
yarn_test_prod_www_variant:
|
||||
yarn_test-www_prod_variant:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=www-modern --prod --variant --ci
|
||||
- run: yarn test-www --prod --variant --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_persistent:
|
||||
yarn_test-stable_persistent:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
@@ -200,9 +200,9 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=stable --persistent --ci
|
||||
- run: yarn test-stable --persistent --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_prod:
|
||||
yarn_test-stable_prod:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
@@ -210,7 +210,7 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=stable --prod --ci
|
||||
- run: yarn test-stable --prod --ci
|
||||
|
||||
yarn_test_prod:
|
||||
docker: *docker
|
||||
@@ -219,7 +219,7 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=experimental --prod --ci
|
||||
- run: yarn test --prod --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_build:
|
||||
docker: *docker
|
||||
@@ -316,7 +316,7 @@ jobs:
|
||||
root: packages/react-devtools-scheduling-profiler
|
||||
paths:
|
||||
- dist
|
||||
|
||||
|
||||
deploy_devtools_scheduling_profiler:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
@@ -389,7 +389,7 @@ jobs:
|
||||
command: yarn lint-build
|
||||
- run: scripts/circleci/check_minified_errors.sh
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_build:
|
||||
yarn_test-stable_build:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
@@ -397,7 +397,7 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace: *attach_workspace
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=stable --build --ci
|
||||
- run: yarn test-stable --build --ci
|
||||
|
||||
yarn_test_build:
|
||||
docker: *docker
|
||||
@@ -407,7 +407,7 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace: *attach_workspace
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=experimental --build --ci
|
||||
- run: yarn test --build --ci
|
||||
|
||||
yarn_test_build_devtools:
|
||||
docker: *docker
|
||||
@@ -447,7 +447,7 @@ jobs:
|
||||
FUZZ_TEST_SEED=$RANDOM yarn test fuzz --ci
|
||||
FUZZ_TEST_SEED=$RANDOM yarn test --prod fuzz --ci
|
||||
|
||||
RELEASE_CHANNEL_stable_yarn_test_build_prod:
|
||||
yarn_test-stable_build_prod:
|
||||
docker: *docker
|
||||
environment: *environment
|
||||
parallelism: *TEST_PARALLELISM
|
||||
@@ -455,7 +455,7 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace: *attach_workspace
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=stable --build --prod --ci
|
||||
- run: yarn test-stable --build --prod --ci
|
||||
|
||||
yarn_test_build_prod:
|
||||
docker: *docker
|
||||
@@ -465,7 +465,7 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace: *attach_workspace
|
||||
- *restore_node_modules
|
||||
- run: yarn test --release-channel=experimental --build --prod --ci
|
||||
- run: yarn test --build --prod --ci
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
@@ -478,25 +478,25 @@ workflows:
|
||||
- yarn_flow:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test:
|
||||
- yarn_test-stable:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_prod:
|
||||
- yarn_test-stable_prod:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_persistent:
|
||||
- yarn_test-stable_persistent:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_www:
|
||||
- yarn_test-classic:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_www_variant:
|
||||
- yarn_test-classic_variant:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_prod_www:
|
||||
- yarn_test-classic_prod:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
|
||||
- yarn_test-classic_prod_variant:
|
||||
requires:
|
||||
- setup
|
||||
- RELEASE_CHANNEL_stable_yarn_build:
|
||||
@@ -511,10 +511,10 @@ workflows:
|
||||
- RELEASE_CHANNEL_stable_yarn_lint_build:
|
||||
requires:
|
||||
- RELEASE_CHANNEL_stable_yarn_build
|
||||
- RELEASE_CHANNEL_stable_yarn_test_build:
|
||||
- yarn_test-stable_build:
|
||||
requires:
|
||||
- RELEASE_CHANNEL_stable_yarn_build
|
||||
- RELEASE_CHANNEL_stable_yarn_test_build_prod:
|
||||
- yarn_test-stable_build_prod:
|
||||
requires:
|
||||
- RELEASE_CHANNEL_stable_yarn_build
|
||||
- RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
|
||||
@@ -530,16 +530,16 @@ workflows:
|
||||
- yarn_test_prod:
|
||||
requires:
|
||||
- setup
|
||||
- yarn_test_www:
|
||||
- yarn_test-www:
|
||||
requires:
|
||||
- setup
|
||||
- yarn_test_www_variant:
|
||||
- yarn_test-www_variant:
|
||||
requires:
|
||||
- setup
|
||||
- yarn_test_prod_www:
|
||||
- yarn_test-www_prod:
|
||||
requires:
|
||||
- setup
|
||||
- yarn_test_prod_www_variant:
|
||||
- yarn_test-www_prod_variant:
|
||||
requires:
|
||||
- setup
|
||||
- yarn_build:
|
||||
|
||||
@@ -9,6 +9,7 @@ build/
|
||||
coverage/
|
||||
fixtures/
|
||||
scripts/bench/benchmarks/**/*.js
|
||||
old_major_packages/
|
||||
|
||||
# React repository clone
|
||||
scripts/bench/remote-repo/
|
||||
@@ -20,4 +21,4 @@ packages/react-devtools-extensions/shared/build
|
||||
packages/react-devtools-inline/dist
|
||||
packages/react-devtools-shell/dist
|
||||
packages/react-devtools-scheduling-profiler/dist
|
||||
packages/react-devtools-scheduling-profiler/static
|
||||
packages/react-devtools-scheduling-profiler/static
|
||||
|
||||
@@ -201,9 +201,11 @@ module.exports = {
|
||||
spyOnDev: true,
|
||||
spyOnDevAndProd: true,
|
||||
spyOnProd: true,
|
||||
__PROFILE__: true,
|
||||
__UMD__: true,
|
||||
__EXPERIMENTAL__: true,
|
||||
__EXTENSION__: true,
|
||||
__PROFILE__: true,
|
||||
__TEST__: true,
|
||||
__UMD__: true,
|
||||
__VARIANT__: true,
|
||||
gate: true,
|
||||
trustedTypes: true,
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -8,7 +8,7 @@
|
||||
2. Run `yarn` in the repository root.
|
||||
3. If you've fixed a bug or added code that should be tested, add tests!
|
||||
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
|
||||
5. Run `yarn test-prod` to test in the production environment. It supports the same options as `yarn test`.
|
||||
5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`.
|
||||
6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect".
|
||||
7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
|
||||
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
|
||||
|
||||
@@ -1218,7 +1218,7 @@ Each of these changes will continue to work as before with a new warning until t
|
||||
- Shallow renderer now returns the rendered output from `render()`. ([@simonewebdesign](https://github.com/simonewebdesign) in [#5411](https://github.com/facebook/react/pull/5411))
|
||||
- React no longer depends on ES5 *shams* for `Object.create` and `Object.freeze` in older environments. It still, however, requires ES5 *shims* in those environments. ([@dgreensp](https://github.com/dgreensp) in [#4959](https://github.com/facebook/react/pull/4959))
|
||||
- React DOM now allows `data-` attributes with names that start with numbers. ([@nLight](https://github.com/nLight) in [#5216](https://github.com/facebook/react/pull/5216))
|
||||
- React DOM adds a new `suppressContentEditableWarning` prop for components like [Draft.js](https://facebook.github.io/draft-js/) that intentionally manage `contentEditable` children with React. ([@mxstbr](https://github.com/mxstbr) in [#6112](https://github.com/facebook/react/pull/6112))
|
||||
- React DOM adds a new `suppressContentEditableWarning` prop for components like [Draft.js](https://draftjs.org/) that intentionally manage `contentEditable` children with React. ([@mxstbr](https://github.com/mxstbr) in [#6112](https://github.com/facebook/react/pull/6112))
|
||||
- React improves the performance for `createClass()` on complex specs. ([@sophiebits](https://github.com/sophiebits) in [#5550](https://github.com/facebook/react/pull/5550))
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@ Right now, we use a purple outline to call out cases where the assigned property
|
||||
---
|
||||
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
You can find the guide for how to do things in a CRA [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).
|
||||
You can find the guide for how to do things in a CRA [here](https://github.com/facebook/create-react-app/blob/master/packages/cra-template/template/README.md).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// This is a custom Jest transformer turning style imports into empty objects.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
// https://jestjs.io/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process() {
|
||||
|
||||
@@ -4,7 +4,7 @@ const path = require('path');
|
||||
const camelcase = require('camelcase');
|
||||
|
||||
// This is a custom Jest transformer turning file imports into filenames.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
// https://jestjs.io/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process(src, filename) {
|
||||
|
||||
12
fixtures/legacy-jsx-runtimes/README.md
Normal file
12
fixtures/legacy-jsx-runtimes/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Legacy JSX Runtimes
|
||||
|
||||
This is an internal testing fixture for the special JSX runtime versions released for 0.14, 15, and 16.
|
||||
|
||||
They are checked into the corresponding `react-*/cjs/*` folders.
|
||||
|
||||
Run the full regression suite:
|
||||
|
||||
```
|
||||
yarn
|
||||
yarn test
|
||||
```
|
||||
12
fixtures/legacy-jsx-runtimes/babel.config.js
Normal file
12
fixtures/legacy-jsx-runtimes/babel.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
[
|
||||
'@babel/react',
|
||||
{
|
||||
runtime: 'automatic',
|
||||
development: process.env.BABEL_ENV === 'development',
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: ['@babel/plugin-transform-modules-commonjs'],
|
||||
};
|
||||
63
fixtures/legacy-jsx-runtimes/lint-runtimes.js
Normal file
63
fixtures/legacy-jsx-runtimes/lint-runtimes.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const {ESLint} = require('eslint');
|
||||
|
||||
function getESLintInstance(format) {
|
||||
return new ESLint({
|
||||
useEslintrc: false,
|
||||
overrideConfigFile:
|
||||
__dirname + `../../../scripts/rollup/validate/eslintrc.${format}.js`,
|
||||
ignore: false,
|
||||
});
|
||||
}
|
||||
|
||||
const esLints = {
|
||||
cjs: getESLintInstance('cjs'),
|
||||
};
|
||||
|
||||
// Performs sanity checks on bundles *built* by Rollup.
|
||||
// Helps catch Rollup regressions.
|
||||
async function lint(folder) {
|
||||
console.log(`Linting ` + folder);
|
||||
const eslint = esLints.cjs;
|
||||
|
||||
const results = await eslint.lintFiles([
|
||||
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.development.js',
|
||||
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.production.min.js',
|
||||
__dirname + '/' + folder + '/cjs/react-jsx-runtime.development.js',
|
||||
__dirname + '/' + folder + '/cjs/react-jsx-runtime.production.min.js',
|
||||
]);
|
||||
if (
|
||||
results.some(result => result.errorCount > 0 || result.warningCount > 0)
|
||||
) {
|
||||
process.exitCode = 1;
|
||||
console.log(`Failed`);
|
||||
const formatter = await eslint.loadFormatter('stylish');
|
||||
const resultText = formatter.format(results);
|
||||
console.log(resultText);
|
||||
}
|
||||
}
|
||||
|
||||
async function lintEverything() {
|
||||
console.log(`Linting known bundles...`);
|
||||
await lint('react-14');
|
||||
await lint('react-15');
|
||||
await lint('react-16');
|
||||
await lint('react-17');
|
||||
}
|
||||
|
||||
lintEverything().catch(error => {
|
||||
process.exitCode = 1;
|
||||
console.error(error);
|
||||
});
|
||||
19
fixtures/legacy-jsx-runtimes/package.json
Normal file
19
fixtures/legacy-jsx-runtimes/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
|
||||
"@babel/preset-react": "^7.10.4",
|
||||
"jest": "^26.5.3"
|
||||
},
|
||||
"jest": {
|
||||
"setupFilesAfterEnv": ["./setupTests.js"]
|
||||
},
|
||||
"scripts": {
|
||||
"install-all": "cd react-14 && yarn && cd ../react-15 && yarn && cd ../react-16 && yarn && cd ../react-17 && yarn && cd ..",
|
||||
"lint": "node lint-runtimes.js",
|
||||
"pretest": "yarn install-all && yarn lint",
|
||||
"test-jsxdev-dev": "BABEL_ENV=development NODE_ENV=development jest",
|
||||
"test-jsx-dev": "BABEL_ENV=production NODE_ENV=development jest",
|
||||
"test-jsx-prod": "BABEL_ENV=production NODE_ENV=production jest",
|
||||
"test": "yarn test-jsxdev-dev && yarn test-jsx-dev && yarn test-jsx-prod"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,861 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-dev-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
|
||||
var jsxDEV$1 = jsxWithValidation ;
|
||||
|
||||
exports.jsxDEV = jsxDEV$1;
|
||||
})();
|
||||
}
|
||||
9
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
9
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-dev-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
|
||||
@@ -0,0 +1,883 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
{
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
// even with the prod transform. This means that jsxDEV is purely
|
||||
// opt-in behavior for better messages but that we won't stop
|
||||
// giving you warnings if you use production apis.
|
||||
|
||||
function jsxWithValidationStatic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, true);
|
||||
}
|
||||
}
|
||||
function jsxWithValidationDynamic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
||||
// for now we can ship identical prod functions
|
||||
|
||||
var jsxs = jsxWithValidationStatic ;
|
||||
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
})();
|
||||
}
|
||||
10
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
10
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=require("react/lib/ReactCurrentOwner"),n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
||||
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
||||
7
fixtures/legacy-jsx-runtimes/react-14/jsx-dev-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-14/jsx-dev-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-14/jsx-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-14/jsx-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-runtime.development.js');
|
||||
}
|
||||
6
fixtures/legacy-jsx-runtimes/react-14/package.json
Normal file
6
fixtures/legacy-jsx-runtimes/react-14/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"react": "0.14",
|
||||
"react-dom": "0.14"
|
||||
}
|
||||
}
|
||||
780
fixtures/legacy-jsx-runtimes/react-14/react-14.test.js
Normal file
780
fixtures/legacy-jsx-runtimes/react-14/react-14.test.js
Normal file
@@ -0,0 +1,780 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
// These tests are based on ReactJSXElement-test,
|
||||
// ReactJSXElementValidator-test, ReactComponent-test,
|
||||
// and ReactElementJSX-test.
|
||||
|
||||
jest.mock('react/jsx-runtime', () => require('./jsx-runtime'), {virtual: true});
|
||||
jest.mock('react/jsx-dev-runtime', () => require('./jsx-dev-runtime'), {
|
||||
virtual: true,
|
||||
});
|
||||
|
||||
let React = require('react');
|
||||
let ReactDOM = require('react-dom');
|
||||
let ReactTestUtils = {
|
||||
renderIntoDocument(el) {
|
||||
const container = document.createElement('div');
|
||||
return ReactDOM.render(el, container);
|
||||
},
|
||||
};
|
||||
let PropTypes = React.PropTypes;
|
||||
let Component = class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
};
|
||||
let RequiredPropComponent = class extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
};
|
||||
RequiredPropComponent.displayName = 'RequiredPropComponent';
|
||||
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
|
||||
|
||||
it('works', () => {
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<h1>hello</h1>, container);
|
||||
expect(container.textContent).toBe('hello');
|
||||
});
|
||||
|
||||
it('returns a complete element according to spec', () => {
|
||||
const element = <Component />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a lower-case to be passed as the string type', () => {
|
||||
const element = <div />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a string to be passed as the type', () => {
|
||||
const TagName = 'div';
|
||||
const element = <TagName />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('returns an immutable element', () => {
|
||||
const element = <Component />;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
expect(() => (element.type = 'div')).toThrow();
|
||||
} else {
|
||||
expect(() => (element.type = 'div')).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not reuse the object that is spread into props', () => {
|
||||
const config = {foo: 1};
|
||||
const element = <Component {...config} />;
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
expect(element.props.foo).toBe(1);
|
||||
});
|
||||
|
||||
it('extracts key and ref from the rest of the props', () => {
|
||||
const element = <Component key="12" ref="34" foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe('34');
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('coerces the key to a string', () => {
|
||||
const element = <Component key={12} foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop', () => {
|
||||
const a = 1;
|
||||
const element = <Component children="text">{a}</Component>;
|
||||
expect(element.props.children).toBe(a);
|
||||
});
|
||||
|
||||
it('does not override children if no JSX children are provided', () => {
|
||||
const element = <Component children="text" />;
|
||||
expect(element.props.children).toBe('text');
|
||||
});
|
||||
|
||||
it('overrides children if null is provided as a JSX child', () => {
|
||||
const element = <Component children="text">{null}</Component>;
|
||||
expect(element.props.children).toBe(null);
|
||||
});
|
||||
|
||||
it('overrides children if undefined is provided as an argument', () => {
|
||||
const element = <Component children="text">{undefined}</Component>;
|
||||
expect(element.props.children).toBe(undefined);
|
||||
|
||||
const element2 = React.cloneElement(
|
||||
<Component children="text" />,
|
||||
{},
|
||||
undefined
|
||||
);
|
||||
expect(element2.props.children).toBe(undefined);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop in an array', () => {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
const c = 3;
|
||||
const element = (
|
||||
<Component>
|
||||
{a}
|
||||
{b}
|
||||
{c}
|
||||
</Component>
|
||||
);
|
||||
expect(element.props.children).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('allows static methods to be called using the type property', () => {
|
||||
class StaticMethodComponent {
|
||||
static someStaticMethod() {
|
||||
return 'someReturnValue';
|
||||
}
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
const element = <StaticMethodComponent />;
|
||||
expect(element.type.someStaticMethod()).toBe('someReturnValue');
|
||||
});
|
||||
|
||||
it('identifies valid elements', () => {
|
||||
expect(React.isValidElement(<div />)).toEqual(true);
|
||||
expect(React.isValidElement(<Component />)).toEqual(true);
|
||||
|
||||
expect(React.isValidElement(null)).toEqual(false);
|
||||
expect(React.isValidElement(true)).toEqual(false);
|
||||
expect(React.isValidElement({})).toEqual(false);
|
||||
expect(React.isValidElement('string')).toEqual(false);
|
||||
expect(React.isValidElement(Component)).toEqual(false);
|
||||
expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
|
||||
});
|
||||
|
||||
it('is indistinguishable from a plain object', () => {
|
||||
const element = <div className="foo" />;
|
||||
const object = {};
|
||||
expect(element.constructor).toBe(object.constructor);
|
||||
});
|
||||
|
||||
it('should use default prop value when removing a prop', () => {
|
||||
Component.defaultProps = {fruit: 'persimmon'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Component fruit="mango" />, container);
|
||||
expect(instance.props.fruit).toBe('mango');
|
||||
|
||||
ReactDOM.render(<Component />, container);
|
||||
expect(instance.props.fruit).toBe('persimmon');
|
||||
});
|
||||
|
||||
it('should normalize props with default values', () => {
|
||||
class NormalizingComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NormalizingComponent.defaultProps = {prop: 'testKey'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<NormalizingComponent />, container);
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
const inst2 = ReactDOM.render(
|
||||
<NormalizingComponent prop={null} />,
|
||||
container
|
||||
);
|
||||
expect(inst2.props.prop).toBe(null);
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements in children position', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component />, <Component />]}</Component>
|
||||
)
|
||||
).toErrorDev('Each child in a list should have a unique "key" prop.', {
|
||||
withoutStack: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements with owner info', () => {
|
||||
class InnerComponent extends React.Component {
|
||||
render() {
|
||||
return <Component>{this.props.childSet}</Component>;
|
||||
}
|
||||
}
|
||||
|
||||
class ComponentWrapper extends React.Component {
|
||||
render() {
|
||||
return <InnerComponent childSet={[<Component />, <Component />]} />;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<ComponentWrapper />)
|
||||
).toErrorDev(
|
||||
'Each child in a list should have a unique "key" prop.' +
|
||||
'\n\nCheck the render method of `InnerComponent`. ' +
|
||||
'It was passed a child from ComponentWrapper. ',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for arrays of elements with keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for iterable elements with keys', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {
|
||||
value: done ? undefined : <Component key={'#' + i} />,
|
||||
done: done,
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn for numeric keys in entry iterable as a child', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {value: done ? undefined : [i, <Component />], done: done};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
iterable.entries = iterable['@@iterator'];
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn when the element is directly as children', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>
|
||||
<Component />
|
||||
<Component />
|
||||
</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn when the child array contains non-elements', () => {
|
||||
void (<Component>{[{}, {}]}</Component>);
|
||||
});
|
||||
|
||||
it('should give context for PropType errors in nested components.', () => {
|
||||
// In this test, we're making sure that if a proptype error is found in a
|
||||
// component, we give a small hint as to which parent instantiated that
|
||||
// component as per warnings about key usage in ReactElementValidator.
|
||||
function MyComp({color}) {
|
||||
return <div>My color is {color}</div>;
|
||||
}
|
||||
MyComp.propTypes = {
|
||||
color: PropTypes.string,
|
||||
};
|
||||
class ParentComp extends React.Component {
|
||||
render() {
|
||||
return <MyComp color={123} />;
|
||||
}
|
||||
}
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<ParentComp />)
|
||||
).toErrorDev(
|
||||
'Warning: Failed prop type: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('gives a helpful error when passing null, undefined, or boolean', () => {
|
||||
const Undefined = undefined;
|
||||
const Null = null;
|
||||
const True = true;
|
||||
const Div = 'div';
|
||||
expect(
|
||||
() => void (<Undefined />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<Null />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: null.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<True />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: boolean.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
// No error expected
|
||||
void (<Div />);
|
||||
});
|
||||
|
||||
it('should check default prop values', () => {
|
||||
RequiredPropComponent.defaultProps = {prop: null};
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />)
|
||||
).toErrorDev(
|
||||
'Warning: Failed prop type: Required prop `prop` was not specified in ' +
|
||||
'`RequiredPropComponent`.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid prop types', () => {
|
||||
// Since there is no prevalidation step for ES6 classes, there is no hook
|
||||
// for us to issue a warning earlier than element creation when the error
|
||||
// actually occurs. Since this step is skipped in production, we should just
|
||||
// warn instead of throwing for this case.
|
||||
class NullPropTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullPropTypeComponent.propTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
|
||||
'function, usually from the `prop-types` package,',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
xit('should warn on invalid context types', () => {
|
||||
class NullContextTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullContextTypeComponent.contextTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullContextTypeComponent: type `prop` is invalid; it must ' +
|
||||
'be a function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if getDefaultProps is specified on the class', () => {
|
||||
class GetDefaultPropsComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
GetDefaultPropsComponent.getDefaultProps = () => ({
|
||||
prop: 'foo',
|
||||
});
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />)
|
||||
).toErrorDev(
|
||||
'getDefaultProps is only used on classic React.createClass definitions.' +
|
||||
' Use a static property named `defaultProps` instead.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if component declares PropTypes instead of propTypes', () => {
|
||||
class MisspelledPropTypesComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
MisspelledPropTypesComponent.PropTypes = {
|
||||
prop: PropTypes.string,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<MisspelledPropTypesComponent prop="hi" />
|
||||
)
|
||||
).toErrorDev(
|
||||
'Warning: Component MisspelledPropTypesComponent declared `PropTypes` ' +
|
||||
'instead of `propTypes`. Did you misspell the property assignment?',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments with illegal attributes', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <React.Fragment a={1}>hello</React.Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid prop `a` supplied to `React.Fragment`. React.Fragment ' +
|
||||
'can only have `key` and `children` props.'
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments with refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment
|
||||
ref={bar => {
|
||||
this.foo = bar;
|
||||
}}>
|
||||
hello
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid attribute `ref` supplied to `React.Fragment`.'
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('does not warn for fragments of multiple elements without keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span>1</span>
|
||||
<span>2</span>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments of multiple elements with same key', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span key="a">1</span>
|
||||
<span key="a">2</span>
|
||||
<span key="b">3</span>
|
||||
</>
|
||||
)
|
||||
).toErrorDev('Encountered two children with the same key, `a`.', {
|
||||
withoutStack: true,
|
||||
});
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('does not call lazy initializers eagerly', () => {
|
||||
let didCall = false;
|
||||
const Lazy = React.lazy(() => {
|
||||
didCall = true;
|
||||
return {then() {}};
|
||||
});
|
||||
<Lazy />;
|
||||
expect(didCall).toBe(false);
|
||||
});
|
||||
|
||||
it('supports classic refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <div className="foo" ref="inner" />;
|
||||
}
|
||||
}
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Foo />, container);
|
||||
expect(instance.refs.inner.className).toBe('foo');
|
||||
});
|
||||
|
||||
it('should support refs on owned components', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref="inner" />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref="outer">
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.refs.inner.getObject()).toEqual(innerObj);
|
||||
expect(this.refs.outer.getObject()).toEqual(outerObj);
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
});
|
||||
|
||||
it('should support callback-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = (
|
||||
<Wrapper object={innerObj} ref={c => (this.innerRef = c)} />
|
||||
);
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={c => (this.outerRef = c)}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('should support object-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.innerRef = React.createRef();
|
||||
this.outerRef = React.createRef();
|
||||
}
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref={this.innerRef} />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={this.outerRef}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.current.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.current.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support new-style refs with mixed-up owners', () => {
|
||||
class Wrapper extends React.Component {
|
||||
getTitle = () => {
|
||||
return this.props.title;
|
||||
};
|
||||
|
||||
render() {
|
||||
return this.props.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
getInner = () => {
|
||||
// (With old-style refs, it's impossible to get a ref to this div
|
||||
// because Wrapper is the current owner when this function is called.)
|
||||
return <div className="inner" ref={c => (this.innerRef = c)} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Wrapper
|
||||
title="wrapper"
|
||||
ref={c => (this.wrapperRef = c)}
|
||||
getContent={this.getInner}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Check .props.title to make sure we got the right elements back
|
||||
expect(this.wrapperRef.getTitle()).toBe('wrapper');
|
||||
expect(this.innerRef.className).toBe('inner');
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should warn when `key` is being accessed on composite element', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.key} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child key="0" />
|
||||
<Child key="1" />
|
||||
<Child key="2" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() =>
|
||||
ReactDOM.render(<Parent />, container)
|
||||
).toErrorDev(
|
||||
'Child: `key` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when `ref` is being accessed', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.ref} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child ref="childElement" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() =>
|
||||
ReactDOM.render(<Parent />, container)
|
||||
).toErrorDev(
|
||||
'Child: `ref` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
// Note: no warning before 16.
|
||||
it('should NOT warn when owner and self are different for string refs', () => {
|
||||
class ClassWithRenderProp extends React.Component {
|
||||
render() {
|
||||
return this.props.children();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassParent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<ClassWithRenderProp>{() => <div ref="myRef" />}</ClassWithRenderProp>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<ClassParent />, container);
|
||||
});
|
||||
285
fixtures/legacy-jsx-runtimes/react-14/yarn.lock
Normal file
285
fixtures/legacy-jsx-runtimes/react-14/yarn.lock
Normal file
@@ -0,0 +1,285 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
acorn@^5.2.1:
|
||||
version "5.7.4"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
|
||||
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==
|
||||
|
||||
amdefine@>=0.0.4:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
|
||||
integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=
|
||||
|
||||
asap@~2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
|
||||
|
||||
ast-types@0.9.6:
|
||||
version "0.9.6"
|
||||
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9"
|
||||
integrity sha1-ECyenpAF0+fjgpvwxPok7oYu6bk=
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
|
||||
base62@^1.1.0:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.yarnpkg.com/base62/-/base62-1.2.8.tgz#1264cb0fb848d875792877479dbe8bae6bae3428"
|
||||
integrity sha512-V6YHUbjLxN1ymqNLb1DPHoU1CpfdL7d2YTIp5W3U4hhoG4hhxNmsFDs66M9EXxBiSEke5Bt5dwdfMwwZF70iLA==
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
commander@^2.5.0:
|
||||
version "2.20.3"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
|
||||
|
||||
commoner@^0.10.1:
|
||||
version "0.10.8"
|
||||
resolved "https://registry.yarnpkg.com/commoner/-/commoner-0.10.8.tgz#34fc3672cd24393e8bb47e70caa0293811f4f2c5"
|
||||
integrity sha1-NPw2cs0kOT6LtH5wyqApOBH08sU=
|
||||
dependencies:
|
||||
commander "^2.5.0"
|
||||
detective "^4.3.1"
|
||||
glob "^5.0.15"
|
||||
graceful-fs "^4.1.2"
|
||||
iconv-lite "^0.4.5"
|
||||
mkdirp "^0.5.0"
|
||||
private "^0.1.6"
|
||||
q "^1.1.2"
|
||||
recast "^0.11.17"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
|
||||
core-js@^1.0.0:
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||
integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
|
||||
|
||||
defined@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
|
||||
integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=
|
||||
|
||||
detective@^4.3.1:
|
||||
version "4.7.1"
|
||||
resolved "https://registry.yarnpkg.com/detective/-/detective-4.7.1.tgz#0eca7314338442febb6d65da54c10bb1c82b246e"
|
||||
integrity sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==
|
||||
dependencies:
|
||||
acorn "^5.2.1"
|
||||
defined "^1.0.0"
|
||||
|
||||
envify@^3.0.0:
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/envify/-/envify-3.4.1.tgz#d7122329e8df1688ba771b12501917c9ce5cbce8"
|
||||
integrity sha1-1xIjKejfFoi6dxsSUBkXyc5cvOg=
|
||||
dependencies:
|
||||
jstransform "^11.0.3"
|
||||
through "~2.3.4"
|
||||
|
||||
esprima-fb@^15001.1.0-dev-harmony-fb:
|
||||
version "15001.1.0-dev-harmony-fb"
|
||||
resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1.0-dev-harmony-fb.tgz#30a947303c6b8d5e955bee2b99b1d233206a6901"
|
||||
integrity sha1-MKlHMDxrjV6VW+4rmbHSMyBqaQE=
|
||||
|
||||
esprima@~3.1.0:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
|
||||
integrity sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=
|
||||
|
||||
fbjs@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.6.1.tgz#9636b7705f5ba9684d44b72f78321254afc860f7"
|
||||
integrity sha1-lja3cF9bqWhNRLcveDISVK/IYPc=
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
loose-envify "^1.0.0"
|
||||
promise "^7.0.3"
|
||||
ua-parser-js "^0.7.9"
|
||||
whatwg-fetch "^0.9.0"
|
||||
|
||||
glob@^5.0.15:
|
||||
version "5.0.15"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
|
||||
integrity sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=
|
||||
dependencies:
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "2 || 3"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
graceful-fs@^4.1.2:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
|
||||
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
|
||||
|
||||
iconv-lite@^0.4.5:
|
||||
version "0.4.24"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
|
||||
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
|
||||
dependencies:
|
||||
safer-buffer ">= 2.1.2 < 3"
|
||||
|
||||
inflight@^1.0.4:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
|
||||
dependencies:
|
||||
once "^1.3.0"
|
||||
wrappy "1"
|
||||
|
||||
inherits@2:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||
|
||||
jstransform@^11.0.3:
|
||||
version "11.0.3"
|
||||
resolved "https://registry.yarnpkg.com/jstransform/-/jstransform-11.0.3.tgz#09a78993e0ae4d4ef4487f6155a91f6190cb4223"
|
||||
integrity sha1-CaeJk+CuTU70SH9hVakfYZDLQiM=
|
||||
dependencies:
|
||||
base62 "^1.1.0"
|
||||
commoner "^0.10.1"
|
||||
esprima-fb "^15001.1.0-dev-harmony-fb"
|
||||
object-assign "^2.0.0"
|
||||
source-map "^0.4.2"
|
||||
|
||||
loose-envify@^1.0.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
dependencies:
|
||||
js-tokens "^3.0.0 || ^4.0.0"
|
||||
|
||||
"minimatch@2 || 3":
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimist@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
|
||||
mkdirp@^0.5.0:
|
||||
version "0.5.5"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
|
||||
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
|
||||
dependencies:
|
||||
minimist "^1.2.5"
|
||||
|
||||
object-assign@^2.0.0:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa"
|
||||
integrity sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=
|
||||
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
path-is-absolute@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
||||
|
||||
private@^0.1.6, private@~0.1.5:
|
||||
version "0.1.8"
|
||||
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
||||
integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==
|
||||
|
||||
promise@^7.0.3:
|
||||
version "7.3.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
||||
integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
q@^1.1.2:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
|
||||
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
|
||||
|
||||
react-dom@0.14:
|
||||
version "0.14.9"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-0.14.9.tgz#05064a3dcf0fb1880a3b2bfc9d58c55d8d9f6293"
|
||||
integrity sha1-BQZKPc8PsYgKOyv8nVjFXY2fYpM=
|
||||
|
||||
react@0.14:
|
||||
version "0.14.9"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-0.14.9.tgz#9110a6497c49d44ba1c0edd317aec29c2e0d91d1"
|
||||
integrity sha1-kRCmSXxJ1EuhwO3TF67CnC4NkdE=
|
||||
dependencies:
|
||||
envify "^3.0.0"
|
||||
fbjs "^0.6.1"
|
||||
|
||||
recast@^0.11.17:
|
||||
version "0.11.23"
|
||||
resolved "https://registry.yarnpkg.com/recast/-/recast-0.11.23.tgz#451fd3004ab1e4df9b4e4b66376b2a21912462d3"
|
||||
integrity sha1-RR/TAEqx5N+bTktmN2sqIZEkYtM=
|
||||
dependencies:
|
||||
ast-types "0.9.6"
|
||||
esprima "~3.1.0"
|
||||
private "~0.1.5"
|
||||
source-map "~0.5.0"
|
||||
|
||||
"safer-buffer@>= 2.1.2 < 3":
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
source-map@^0.4.2:
|
||||
version "0.4.4"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
|
||||
integrity sha1-66T12pwNyZneaAMti092FzZSA2s=
|
||||
dependencies:
|
||||
amdefine ">=0.0.4"
|
||||
|
||||
source-map@~0.5.0:
|
||||
version "0.5.7"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
|
||||
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
|
||||
|
||||
through@~2.3.4:
|
||||
version "2.3.8"
|
||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||
|
||||
ua-parser-js@^0.7.9:
|
||||
version "0.7.22"
|
||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.22.tgz#960df60a5f911ea8f1c818f3747b99c6e177eae3"
|
||||
integrity sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==
|
||||
|
||||
whatwg-fetch@^0.9.0:
|
||||
version "0.9.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-0.9.0.tgz#0e3684c6cb9995b43efc9df03e4c365d95fd9cc0"
|
||||
integrity sha1-DjaExsuZlbQ+/J3wPkw2XZX9nMA=
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
||||
@@ -0,0 +1,866 @@
|
||||
/** @license React v15.7.0
|
||||
* react-jsx-dev-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
if (currentlyValidatingElement) {
|
||||
stack += ReactComponentTreeHook.getCurrentStackAddendum(currentlyValidatingElement)
|
||||
}
|
||||
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
|
||||
var jsxDEV$1 = jsxWithValidation ;
|
||||
|
||||
exports.jsxDEV = jsxDEV$1;
|
||||
})();
|
||||
}
|
||||
9
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
9
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @license React v15.7.0
|
||||
* react-jsx-dev-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
|
||||
@@ -0,0 +1,888 @@
|
||||
/** @license React v15.7.0
|
||||
* react-jsx-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
if (currentlyValidatingElement) {
|
||||
stack += ReactComponentTreeHook.getCurrentStackAddendum(currentlyValidatingElement)
|
||||
}
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
{
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
// even with the prod transform. This means that jsxDEV is purely
|
||||
// opt-in behavior for better messages but that we won't stop
|
||||
// giving you warnings if you use production apis.
|
||||
|
||||
function jsxWithValidationStatic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, true);
|
||||
}
|
||||
}
|
||||
function jsxWithValidationDynamic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
||||
// for now we can ship identical prod functions
|
||||
|
||||
var jsxs = jsxWithValidationStatic ;
|
||||
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
})();
|
||||
}
|
||||
10
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
10
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @license React v15.7.0
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=require("react/lib/ReactCurrentOwner"),n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
||||
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
||||
7
fixtures/legacy-jsx-runtimes/react-15/jsx-dev-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-15/jsx-dev-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-15/jsx-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-15/jsx-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-runtime.development.js');
|
||||
}
|
||||
6
fixtures/legacy-jsx-runtimes/react-15/package.json
Normal file
6
fixtures/legacy-jsx-runtimes/react-15/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"react": "15",
|
||||
"react-dom": "15"
|
||||
}
|
||||
}
|
||||
775
fixtures/legacy-jsx-runtimes/react-15/react-15.test.js
Normal file
775
fixtures/legacy-jsx-runtimes/react-15/react-15.test.js
Normal file
@@ -0,0 +1,775 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
// These tests are based on ReactJSXElement-test,
|
||||
// ReactJSXElementValidator-test, ReactComponent-test,
|
||||
// and ReactElementJSX-test.
|
||||
|
||||
jest.mock('react/jsx-runtime', () => require('./jsx-runtime'), {virtual: true});
|
||||
jest.mock('react/jsx-dev-runtime', () => require('./jsx-dev-runtime'), {
|
||||
virtual: true,
|
||||
});
|
||||
|
||||
let React = require('react');
|
||||
let ReactDOM = require('react-dom');
|
||||
let ReactTestUtils = {
|
||||
renderIntoDocument(el) {
|
||||
const container = document.createElement('div');
|
||||
return ReactDOM.render(el, container);
|
||||
},
|
||||
};
|
||||
let PropTypes = require('prop-types');
|
||||
let Component = class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
};
|
||||
let RequiredPropComponent = class extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
};
|
||||
RequiredPropComponent.displayName = 'RequiredPropComponent';
|
||||
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
|
||||
|
||||
it('works', () => {
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<h1>hello</h1>, container);
|
||||
expect(container.textContent).toBe('hello');
|
||||
});
|
||||
|
||||
it('returns a complete element according to spec', () => {
|
||||
const element = <Component />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a lower-case to be passed as the string type', () => {
|
||||
const element = <div />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a string to be passed as the type', () => {
|
||||
const TagName = 'div';
|
||||
const element = <TagName />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('returns an immutable element', () => {
|
||||
const element = <Component />;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
expect(() => (element.type = 'div')).toThrow();
|
||||
} else {
|
||||
expect(() => (element.type = 'div')).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not reuse the object that is spread into props', () => {
|
||||
const config = {foo: 1};
|
||||
const element = <Component {...config} />;
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
expect(element.props.foo).toBe(1);
|
||||
});
|
||||
|
||||
it('extracts key and ref from the rest of the props', () => {
|
||||
const element = <Component key="12" ref="34" foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe('34');
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('coerces the key to a string', () => {
|
||||
const element = <Component key={12} foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop', () => {
|
||||
const a = 1;
|
||||
const element = <Component children="text">{a}</Component>;
|
||||
expect(element.props.children).toBe(a);
|
||||
});
|
||||
|
||||
it('does not override children if no JSX children are provided', () => {
|
||||
const element = <Component children="text" />;
|
||||
expect(element.props.children).toBe('text');
|
||||
});
|
||||
|
||||
it('overrides children if null is provided as a JSX child', () => {
|
||||
const element = <Component children="text">{null}</Component>;
|
||||
expect(element.props.children).toBe(null);
|
||||
});
|
||||
|
||||
it('overrides children if undefined is provided as an argument', () => {
|
||||
const element = <Component children="text">{undefined}</Component>;
|
||||
expect(element.props.children).toBe(undefined);
|
||||
|
||||
const element2 = React.cloneElement(
|
||||
<Component children="text" />,
|
||||
{},
|
||||
undefined
|
||||
);
|
||||
expect(element2.props.children).toBe(undefined);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop in an array', () => {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
const c = 3;
|
||||
const element = (
|
||||
<Component>
|
||||
{a}
|
||||
{b}
|
||||
{c}
|
||||
</Component>
|
||||
);
|
||||
expect(element.props.children).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('allows static methods to be called using the type property', () => {
|
||||
class StaticMethodComponent {
|
||||
static someStaticMethod() {
|
||||
return 'someReturnValue';
|
||||
}
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
const element = <StaticMethodComponent />;
|
||||
expect(element.type.someStaticMethod()).toBe('someReturnValue');
|
||||
});
|
||||
|
||||
it('identifies valid elements', () => {
|
||||
expect(React.isValidElement(<div />)).toEqual(true);
|
||||
expect(React.isValidElement(<Component />)).toEqual(true);
|
||||
|
||||
expect(React.isValidElement(null)).toEqual(false);
|
||||
expect(React.isValidElement(true)).toEqual(false);
|
||||
expect(React.isValidElement({})).toEqual(false);
|
||||
expect(React.isValidElement('string')).toEqual(false);
|
||||
expect(React.isValidElement(Component)).toEqual(false);
|
||||
expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
|
||||
});
|
||||
|
||||
it('is indistinguishable from a plain object', () => {
|
||||
const element = <div className="foo" />;
|
||||
const object = {};
|
||||
expect(element.constructor).toBe(object.constructor);
|
||||
});
|
||||
|
||||
it('should use default prop value when removing a prop', () => {
|
||||
Component.defaultProps = {fruit: 'persimmon'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Component fruit="mango" />, container);
|
||||
expect(instance.props.fruit).toBe('mango');
|
||||
|
||||
ReactDOM.render(<Component />, container);
|
||||
expect(instance.props.fruit).toBe('persimmon');
|
||||
});
|
||||
|
||||
it('should normalize props with default values', () => {
|
||||
class NormalizingComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NormalizingComponent.defaultProps = {prop: 'testKey'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<NormalizingComponent />, container);
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
const inst2 = ReactDOM.render(
|
||||
<NormalizingComponent prop={null} />,
|
||||
container
|
||||
);
|
||||
expect(inst2.props.prop).toBe(null);
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements in children position', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component />, <Component />]}</Component>
|
||||
)
|
||||
).toErrorDev('Each child in a list should have a unique "key" prop.');
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements with owner info', () => {
|
||||
class InnerComponent extends React.Component {
|
||||
render() {
|
||||
return <Component>{this.props.childSet}</Component>;
|
||||
}
|
||||
}
|
||||
|
||||
class ComponentWrapper extends React.Component {
|
||||
render() {
|
||||
return <InnerComponent childSet={[<Component />, <Component />]} />;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<ComponentWrapper />)
|
||||
).toErrorDev(
|
||||
'Each child in a list should have a unique "key" prop.' +
|
||||
'\n\nCheck the render method of `InnerComponent`. ' +
|
||||
'It was passed a child from ComponentWrapper. '
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for arrays of elements with keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for iterable elements with keys', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {
|
||||
value: done ? undefined : <Component key={'#' + i} />,
|
||||
done: done,
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn for numeric keys in entry iterable as a child', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {value: done ? undefined : [i, <Component />], done: done};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
iterable.entries = iterable['@@iterator'];
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn when the element is directly as children', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>
|
||||
<Component />
|
||||
<Component />
|
||||
</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn when the child array contains non-elements', () => {
|
||||
void (<Component>{[{}, {}]}</Component>);
|
||||
});
|
||||
|
||||
it('should give context for PropType errors in nested components.', () => {
|
||||
// In this test, we're making sure that if a proptype error is found in a
|
||||
// component, we give a small hint as to which parent instantiated that
|
||||
// component as per warnings about key usage in ReactElementValidator.
|
||||
function MyComp({color}) {
|
||||
return <div>My color is {color}</div>;
|
||||
}
|
||||
MyComp.propTypes = {
|
||||
color: PropTypes.string,
|
||||
};
|
||||
class ParentComp extends React.Component {
|
||||
render() {
|
||||
return <MyComp color={123} />;
|
||||
}
|
||||
}
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<ParentComp />)).toErrorDev(
|
||||
'Warning: Failed prop type: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`.\n' +
|
||||
' in MyComp (at **)\n' +
|
||||
' in ParentComp (at **)'
|
||||
);
|
||||
});
|
||||
|
||||
it('gives a helpful error when passing null, undefined, or boolean', () => {
|
||||
const Undefined = undefined;
|
||||
const Null = null;
|
||||
const True = true;
|
||||
const Div = 'div';
|
||||
expect(
|
||||
() => void (<Undefined />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<Null />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: null.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<True />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: boolean.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
// No error expected
|
||||
void (<Div />);
|
||||
});
|
||||
|
||||
it('should check default prop values', () => {
|
||||
RequiredPropComponent.defaultProps = {prop: null};
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />)
|
||||
).toErrorDev(
|
||||
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
|
||||
'`RequiredPropComponent`, but its value is `null`.\n' +
|
||||
' in RequiredPropComponent (at **)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid prop types', () => {
|
||||
// Since there is no prevalidation step for ES6 classes, there is no hook
|
||||
// for us to issue a warning earlier than element creation when the error
|
||||
// actually occurs. Since this step is skipped in production, we should just
|
||||
// warn instead of throwing for this case.
|
||||
class NullPropTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullPropTypeComponent.propTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
|
||||
'function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
xit('should warn on invalid context types', () => {
|
||||
class NullContextTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullContextTypeComponent.contextTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullContextTypeComponent: type `prop` is invalid; it must ' +
|
||||
'be a function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if getDefaultProps is specified on the class', () => {
|
||||
class GetDefaultPropsComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
GetDefaultPropsComponent.getDefaultProps = () => ({
|
||||
prop: 'foo',
|
||||
});
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />)
|
||||
).toErrorDev(
|
||||
'getDefaultProps is only used on classic React.createClass definitions.' +
|
||||
' Use a static property named `defaultProps` instead.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if component declares PropTypes instead of propTypes', () => {
|
||||
class MisspelledPropTypesComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
MisspelledPropTypesComponent.PropTypes = {
|
||||
prop: PropTypes.string,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<MisspelledPropTypesComponent prop="hi" />
|
||||
)
|
||||
).toErrorDev(
|
||||
'Warning: Component MisspelledPropTypesComponent declared `PropTypes` ' +
|
||||
'instead of `propTypes`. Did you misspell the property assignment?',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments with illegal attributes', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <React.Fragment a={1}>hello</React.Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid prop `a` supplied to `React.Fragment`. React.Fragment ' +
|
||||
'can only have `key` and `children` props.'
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments with refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment
|
||||
ref={bar => {
|
||||
this.foo = bar;
|
||||
}}>
|
||||
hello
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid attribute `ref` supplied to `React.Fragment`.'
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('does not warn for fragments of multiple elements without keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span>1</span>
|
||||
<span>2</span>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('warns for fragments of multiple elements with same key', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span key="a">1</span>
|
||||
<span key="a">2</span>
|
||||
<span key="b">3</span>
|
||||
</>
|
||||
)
|
||||
).toErrorDev('Encountered two children with the same key, `a`.', {
|
||||
withoutStack: true,
|
||||
});
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('does not call lazy initializers eagerly', () => {
|
||||
let didCall = false;
|
||||
const Lazy = React.lazy(() => {
|
||||
didCall = true;
|
||||
return {then() {}};
|
||||
});
|
||||
<Lazy />;
|
||||
expect(didCall).toBe(false);
|
||||
});
|
||||
|
||||
it('supports classic refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <div className="foo" ref="inner" />;
|
||||
}
|
||||
}
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Foo />, container);
|
||||
expect(instance.refs.inner.className).toBe('foo');
|
||||
});
|
||||
|
||||
it('should support refs on owned components', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref="inner" />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref="outer">
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.refs.inner.getObject()).toEqual(innerObj);
|
||||
expect(this.refs.outer.getObject()).toEqual(outerObj);
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
});
|
||||
|
||||
it('should support callback-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = (
|
||||
<Wrapper object={innerObj} ref={c => (this.innerRef = c)} />
|
||||
);
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={c => (this.outerRef = c)}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
// Not supported.
|
||||
xit('should support object-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.innerRef = React.createRef();
|
||||
this.outerRef = React.createRef();
|
||||
}
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref={this.innerRef} />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={this.outerRef}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.current.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.current.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support new-style refs with mixed-up owners', () => {
|
||||
class Wrapper extends React.Component {
|
||||
getTitle = () => {
|
||||
return this.props.title;
|
||||
};
|
||||
|
||||
render() {
|
||||
return this.props.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
getInner = () => {
|
||||
// (With old-style refs, it's impossible to get a ref to this div
|
||||
// because Wrapper is the current owner when this function is called.)
|
||||
return <div className="inner" ref={c => (this.innerRef = c)} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Wrapper
|
||||
title="wrapper"
|
||||
ref={c => (this.wrapperRef = c)}
|
||||
getContent={this.getInner}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Check .props.title to make sure we got the right elements back
|
||||
expect(this.wrapperRef.getTitle()).toBe('wrapper');
|
||||
expect(this.innerRef.className).toBe('inner');
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should warn when `key` is being accessed on composite element', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.key} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child key="0" />
|
||||
<Child key="1" />
|
||||
<Child key="2" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() =>
|
||||
ReactDOM.render(<Parent />, container)
|
||||
).toErrorDev(
|
||||
'Child: `key` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when `ref` is being accessed', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.ref} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child ref="childElement" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() =>
|
||||
ReactDOM.render(<Parent />, container)
|
||||
).toErrorDev(
|
||||
'Child: `ref` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
// Note: no warning before 16.
|
||||
it('should NOT warn when owner and self are different for string refs', () => {
|
||||
class ClassWithRenderProp extends React.Component {
|
||||
render() {
|
||||
return this.props.children();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassParent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<ClassWithRenderProp>{() => <div ref="myRef" />}</ClassWithRenderProp>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<ClassParent />, container);
|
||||
});
|
||||
149
fixtures/legacy-jsx-runtimes/react-15/yarn.lock
Normal file
149
fixtures/legacy-jsx-runtimes/react-15/yarn.lock
Normal file
@@ -0,0 +1,149 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
asap@~2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
|
||||
|
||||
core-js@^1.0.0:
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||
integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
|
||||
|
||||
create-react-class@^15.6.0:
|
||||
version "15.6.3"
|
||||
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.3.tgz#2d73237fb3f970ae6ebe011a9e66f46dbca80036"
|
||||
integrity sha512-M+/3Q6E6DLO6Yx3OwrWjwHBnvfXXYA7W+dFjt/ZDBemHO1DDZhsalX/NUtnTYclN6GfnBDRh4qRHjcDHmlJBJg==
|
||||
dependencies:
|
||||
fbjs "^0.8.9"
|
||||
loose-envify "^1.3.1"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
encoding@^0.1.11:
|
||||
version "0.1.13"
|
||||
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
|
||||
integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==
|
||||
dependencies:
|
||||
iconv-lite "^0.6.2"
|
||||
|
||||
fbjs@^0.8.9:
|
||||
version "0.8.17"
|
||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
|
||||
integrity sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
isomorphic-fetch "^2.1.1"
|
||||
loose-envify "^1.0.0"
|
||||
object-assign "^4.1.0"
|
||||
promise "^7.1.1"
|
||||
setimmediate "^1.0.5"
|
||||
ua-parser-js "^0.7.18"
|
||||
|
||||
iconv-lite@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01"
|
||||
integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==
|
||||
dependencies:
|
||||
safer-buffer ">= 2.1.2 < 3.0.0"
|
||||
|
||||
is-stream@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
|
||||
|
||||
isomorphic-fetch@^2.1.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
|
||||
integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=
|
||||
dependencies:
|
||||
node-fetch "^1.0.1"
|
||||
whatwg-fetch ">=0.10.0"
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||
|
||||
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
dependencies:
|
||||
js-tokens "^3.0.0 || ^4.0.0"
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||
integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==
|
||||
dependencies:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
object-assign@^4.1.0, object-assign@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
|
||||
promise@^7.1.1:
|
||||
version "7.3.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
||||
integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
prop-types@^15.5.10:
|
||||
version "15.7.2"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
|
||||
dependencies:
|
||||
loose-envify "^1.4.0"
|
||||
object-assign "^4.1.1"
|
||||
react-is "^16.8.1"
|
||||
|
||||
react-dom@15:
|
||||
version "15.6.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730"
|
||||
integrity sha1-Qc+t9pO3V/rycIRDodH9WgK+9zA=
|
||||
dependencies:
|
||||
fbjs "^0.8.9"
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.0"
|
||||
prop-types "^15.5.10"
|
||||
|
||||
react-is@^16.8.1:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
|
||||
|
||||
react@15:
|
||||
version "15.6.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-15.6.2.tgz#dba0434ab439cfe82f108f0f511663908179aa72"
|
||||
integrity sha1-26BDSrQ5z+gvEI8PURZjkIF5qnI=
|
||||
dependencies:
|
||||
create-react-class "^15.6.0"
|
||||
fbjs "^0.8.9"
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.0"
|
||||
prop-types "^15.5.10"
|
||||
|
||||
"safer-buffer@>= 2.1.2 < 3.0.0":
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
|
||||
|
||||
ua-parser-js@^0.7.18:
|
||||
version "0.7.22"
|
||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.22.tgz#960df60a5f911ea8f1c818f3747b99c6e177eae3"
|
||||
integrity sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==
|
||||
|
||||
whatwg-fetch@>=0.10.0:
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.4.1.tgz#e5f871572d6879663fa5674c8f833f15a8425ab3"
|
||||
integrity sha512-sofZVzE1wKwO+EYPbWfiwzaKovWiZXf4coEzjGP9b2GBVgQRLQUZ2QcuPpQExGDAW5GItpEm6Tl4OU5mywnAoQ==
|
||||
@@ -0,0 +1,889 @@
|
||||
/** @license React v16.14.0
|
||||
* react-jsx-dev-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
var stack = '';
|
||||
|
||||
if (currentlyValidatingElement) {
|
||||
var name = getComponentName(currentlyValidatingElement.type);
|
||||
var owner = currentlyValidatingElement._owner;
|
||||
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
||||
}
|
||||
|
||||
stack += ReactDebugCurrentFrame.getStackAddendum();
|
||||
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
var loggedTypeFailures = {};
|
||||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
||||
{
|
||||
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
||||
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
||||
|
||||
if (!didWarnAboutStringRefs[componentName]) {
|
||||
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
||||
|
||||
didWarnAboutStringRefs[componentName] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
warnIfStringRefCannotBeAutoConverted(config, self);
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
||||
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
|
||||
var jsxDEV$1 = jsxWithValidation ;
|
||||
|
||||
exports.jsxDEV = jsxDEV$1;
|
||||
})();
|
||||
}
|
||||
9
fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
9
fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @license React v16.14.0
|
||||
* react-jsx-dev-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
|
||||
@@ -0,0 +1,911 @@
|
||||
/** @license React v16.14.0
|
||||
* react-jsx-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
var stack = '';
|
||||
|
||||
if (currentlyValidatingElement) {
|
||||
var name = getComponentName(currentlyValidatingElement.type);
|
||||
var owner = currentlyValidatingElement._owner;
|
||||
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
||||
}
|
||||
|
||||
stack += ReactDebugCurrentFrame.getStackAddendum();
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var loggedTypeFailures = {};
|
||||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
{
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
||||
{
|
||||
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
||||
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
||||
|
||||
if (!didWarnAboutStringRefs[componentName]) {
|
||||
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
||||
|
||||
didWarnAboutStringRefs[componentName] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
warnIfStringRefCannotBeAutoConverted(config, self);
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
||||
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
// even with the prod transform. This means that jsxDEV is purely
|
||||
// opt-in behavior for better messages but that we won't stop
|
||||
// giving you warnings if you use production apis.
|
||||
|
||||
function jsxWithValidationStatic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, true);
|
||||
}
|
||||
}
|
||||
function jsxWithValidationDynamic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
||||
// for now we can ship identical prod functions
|
||||
|
||||
var jsxs = jsxWithValidationStatic ;
|
||||
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
})();
|
||||
}
|
||||
10
fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
10
fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @license React v16.14.0
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
||||
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
||||
7
fixtures/legacy-jsx-runtimes/react-16/jsx-dev-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-16/jsx-dev-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-16/jsx-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-16/jsx-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-16/package.json
Normal file
7
fixtures/legacy-jsx-runtimes/react-16/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "16",
|
||||
"react-dom": "16"
|
||||
}
|
||||
}
|
||||
773
fixtures/legacy-jsx-runtimes/react-16/react-16.test.js
Normal file
773
fixtures/legacy-jsx-runtimes/react-16/react-16.test.js
Normal file
@@ -0,0 +1,773 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
// These tests are based on ReactJSXElement-test,
|
||||
// ReactJSXElementValidator-test, ReactComponent-test,
|
||||
// and ReactElementJSX-test.
|
||||
|
||||
jest.mock('react/jsx-runtime', () => require('./jsx-runtime'), {virtual: true});
|
||||
jest.mock('react/jsx-dev-runtime', () => require('./jsx-dev-runtime'), {
|
||||
virtual: true,
|
||||
});
|
||||
|
||||
let React = require('react');
|
||||
let ReactDOM = require('react-dom');
|
||||
let ReactTestUtils = {
|
||||
renderIntoDocument(el) {
|
||||
const container = document.createElement('div');
|
||||
return ReactDOM.render(el, container);
|
||||
},
|
||||
};
|
||||
let PropTypes = require('prop-types');
|
||||
let Component = class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
};
|
||||
let RequiredPropComponent = class extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
};
|
||||
RequiredPropComponent.displayName = 'RequiredPropComponent';
|
||||
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
|
||||
|
||||
it('works', () => {
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<h1>hello</h1>, container);
|
||||
expect(container.textContent).toBe('hello');
|
||||
});
|
||||
|
||||
it('returns a complete element according to spec', () => {
|
||||
const element = <Component />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a lower-case to be passed as the string type', () => {
|
||||
const element = <div />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a string to be passed as the type', () => {
|
||||
const TagName = 'div';
|
||||
const element = <TagName />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('returns an immutable element', () => {
|
||||
const element = <Component />;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
expect(() => (element.type = 'div')).toThrow();
|
||||
} else {
|
||||
expect(() => (element.type = 'div')).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not reuse the object that is spread into props', () => {
|
||||
const config = {foo: 1};
|
||||
const element = <Component {...config} />;
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
expect(element.props.foo).toBe(1);
|
||||
});
|
||||
|
||||
it('extracts key and ref from the rest of the props', () => {
|
||||
const element = <Component key="12" ref="34" foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe('34');
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('coerces the key to a string', () => {
|
||||
const element = <Component key={12} foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop', () => {
|
||||
const a = 1;
|
||||
const element = <Component children="text">{a}</Component>;
|
||||
expect(element.props.children).toBe(a);
|
||||
});
|
||||
|
||||
it('does not override children if no JSX children are provided', () => {
|
||||
const element = <Component children="text" />;
|
||||
expect(element.props.children).toBe('text');
|
||||
});
|
||||
|
||||
it('overrides children if null is provided as a JSX child', () => {
|
||||
const element = <Component children="text">{null}</Component>;
|
||||
expect(element.props.children).toBe(null);
|
||||
});
|
||||
|
||||
it('overrides children if undefined is provided as an argument', () => {
|
||||
const element = <Component children="text">{undefined}</Component>;
|
||||
expect(element.props.children).toBe(undefined);
|
||||
|
||||
const element2 = React.cloneElement(
|
||||
<Component children="text" />,
|
||||
{},
|
||||
undefined
|
||||
);
|
||||
expect(element2.props.children).toBe(undefined);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop in an array', () => {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
const c = 3;
|
||||
const element = (
|
||||
<Component>
|
||||
{a}
|
||||
{b}
|
||||
{c}
|
||||
</Component>
|
||||
);
|
||||
expect(element.props.children).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('allows static methods to be called using the type property', () => {
|
||||
class StaticMethodComponent {
|
||||
static someStaticMethod() {
|
||||
return 'someReturnValue';
|
||||
}
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
const element = <StaticMethodComponent />;
|
||||
expect(element.type.someStaticMethod()).toBe('someReturnValue');
|
||||
});
|
||||
|
||||
it('identifies valid elements', () => {
|
||||
expect(React.isValidElement(<div />)).toEqual(true);
|
||||
expect(React.isValidElement(<Component />)).toEqual(true);
|
||||
|
||||
expect(React.isValidElement(null)).toEqual(false);
|
||||
expect(React.isValidElement(true)).toEqual(false);
|
||||
expect(React.isValidElement({})).toEqual(false);
|
||||
expect(React.isValidElement('string')).toEqual(false);
|
||||
expect(React.isValidElement(Component)).toEqual(false);
|
||||
expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
|
||||
});
|
||||
|
||||
it('is indistinguishable from a plain object', () => {
|
||||
const element = <div className="foo" />;
|
||||
const object = {};
|
||||
expect(element.constructor).toBe(object.constructor);
|
||||
});
|
||||
|
||||
it('should use default prop value when removing a prop', () => {
|
||||
Component.defaultProps = {fruit: 'persimmon'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Component fruit="mango" />, container);
|
||||
expect(instance.props.fruit).toBe('mango');
|
||||
|
||||
ReactDOM.render(<Component />, container);
|
||||
expect(instance.props.fruit).toBe('persimmon');
|
||||
});
|
||||
|
||||
it('should normalize props with default values', () => {
|
||||
class NormalizingComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NormalizingComponent.defaultProps = {prop: 'testKey'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<NormalizingComponent />, container);
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
const inst2 = ReactDOM.render(
|
||||
<NormalizingComponent prop={null} />,
|
||||
container
|
||||
);
|
||||
expect(inst2.props.prop).toBe(null);
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements in children position', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component />, <Component />]}</Component>
|
||||
)
|
||||
).toErrorDev('Each child in a list should have a unique "key" prop.');
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements with owner info', () => {
|
||||
class InnerComponent extends React.Component {
|
||||
render() {
|
||||
return <Component>{this.props.childSet}</Component>;
|
||||
}
|
||||
}
|
||||
|
||||
class ComponentWrapper extends React.Component {
|
||||
render() {
|
||||
return <InnerComponent childSet={[<Component />, <Component />]} />;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<ComponentWrapper />)
|
||||
).toErrorDev(
|
||||
'Each child in a list should have a unique "key" prop.' +
|
||||
'\n\nCheck the render method of `InnerComponent`. ' +
|
||||
'It was passed a child from ComponentWrapper. '
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for arrays of elements with keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for iterable elements with keys', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {
|
||||
value: done ? undefined : <Component key={'#' + i} />,
|
||||
done: done,
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn for numeric keys in entry iterable as a child', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {value: done ? undefined : [i, <Component />], done: done};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
iterable.entries = iterable['@@iterator'];
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn when the element is directly as children', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>
|
||||
<Component />
|
||||
<Component />
|
||||
</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn when the child array contains non-elements', () => {
|
||||
void (<Component>{[{}, {}]}</Component>);
|
||||
});
|
||||
|
||||
it('should give context for PropType errors in nested components.', () => {
|
||||
// In this test, we're making sure that if a proptype error is found in a
|
||||
// component, we give a small hint as to which parent instantiated that
|
||||
// component as per warnings about key usage in ReactElementValidator.
|
||||
function MyComp({color}) {
|
||||
return <div>My color is {color}</div>;
|
||||
}
|
||||
MyComp.propTypes = {
|
||||
color: PropTypes.string,
|
||||
};
|
||||
class ParentComp extends React.Component {
|
||||
render() {
|
||||
return <MyComp color={123} />;
|
||||
}
|
||||
}
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<ParentComp />)).toErrorDev(
|
||||
'Warning: Failed prop type: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`.\n' +
|
||||
' in MyComp (at **)\n' +
|
||||
' in ParentComp (at **)'
|
||||
);
|
||||
});
|
||||
|
||||
it('gives a helpful error when passing null, undefined, or boolean', () => {
|
||||
const Undefined = undefined;
|
||||
const Null = null;
|
||||
const True = true;
|
||||
const Div = 'div';
|
||||
expect(
|
||||
() => void (<Undefined />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<Null />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: null.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<True />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: boolean.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
// No error expected
|
||||
void (<Div />);
|
||||
});
|
||||
|
||||
it('should check default prop values', () => {
|
||||
RequiredPropComponent.defaultProps = {prop: null};
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />)
|
||||
).toErrorDev(
|
||||
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
|
||||
'`RequiredPropComponent`, but its value is `null`.\n' +
|
||||
' in RequiredPropComponent (at **)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid prop types', () => {
|
||||
// Since there is no prevalidation step for ES6 classes, there is no hook
|
||||
// for us to issue a warning earlier than element creation when the error
|
||||
// actually occurs. Since this step is skipped in production, we should just
|
||||
// warn instead of throwing for this case.
|
||||
class NullPropTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullPropTypeComponent.propTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
|
||||
'function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid context types', () => {
|
||||
class NullContextTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullContextTypeComponent.contextTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullContextTypeComponent: context type `prop` is invalid; it must ' +
|
||||
'be a function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if getDefaultProps is specified on the class', () => {
|
||||
class GetDefaultPropsComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
GetDefaultPropsComponent.getDefaultProps = () => ({
|
||||
prop: 'foo',
|
||||
});
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />)
|
||||
).toErrorDev(
|
||||
'getDefaultProps is only used on classic React.createClass definitions.' +
|
||||
' Use a static property named `defaultProps` instead.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if component declares PropTypes instead of propTypes', () => {
|
||||
class MisspelledPropTypesComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
MisspelledPropTypesComponent.PropTypes = {
|
||||
prop: PropTypes.string,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<MisspelledPropTypesComponent prop="hi" />
|
||||
)
|
||||
).toErrorDev(
|
||||
'Warning: Component MisspelledPropTypesComponent declared `PropTypes` ' +
|
||||
'instead of `propTypes`. Did you misspell the property assignment?',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments with illegal attributes', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <React.Fragment a={1}>hello</React.Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid prop `a` supplied to `React.Fragment`. React.Fragment ' +
|
||||
'can only have `key` and `children` props.'
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments with refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment
|
||||
ref={bar => {
|
||||
this.foo = bar;
|
||||
}}>
|
||||
hello
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid attribute `ref` supplied to `React.Fragment`.'
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for fragments of multiple elements without keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span>1</span>
|
||||
<span>2</span>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments of multiple elements with same key', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span key="a">1</span>
|
||||
<span key="a">2</span>
|
||||
<span key="b">3</span>
|
||||
</>
|
||||
)
|
||||
).toErrorDev('Encountered two children with the same key, `a`.', {
|
||||
withoutStack: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not call lazy initializers eagerly', () => {
|
||||
let didCall = false;
|
||||
const Lazy = React.lazy(() => {
|
||||
didCall = true;
|
||||
return {then() {}};
|
||||
});
|
||||
<Lazy />;
|
||||
expect(didCall).toBe(false);
|
||||
});
|
||||
|
||||
it('supports classic refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <div className="foo" ref="inner" />;
|
||||
}
|
||||
}
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Foo />, container);
|
||||
expect(instance.refs.inner.className).toBe('foo');
|
||||
});
|
||||
|
||||
it('should support refs on owned components', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref="inner" />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref="outer">
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.refs.inner.getObject()).toEqual(innerObj);
|
||||
expect(this.refs.outer.getObject()).toEqual(outerObj);
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
});
|
||||
|
||||
it('should support callback-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = (
|
||||
<Wrapper object={innerObj} ref={c => (this.innerRef = c)} />
|
||||
);
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={c => (this.outerRef = c)}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support object-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.innerRef = React.createRef();
|
||||
this.outerRef = React.createRef();
|
||||
}
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref={this.innerRef} />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={this.outerRef}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.current.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.current.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support new-style refs with mixed-up owners', () => {
|
||||
class Wrapper extends React.Component {
|
||||
getTitle = () => {
|
||||
return this.props.title;
|
||||
};
|
||||
|
||||
render() {
|
||||
return this.props.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
getInner = () => {
|
||||
// (With old-style refs, it's impossible to get a ref to this div
|
||||
// because Wrapper is the current owner when this function is called.)
|
||||
return <div className="inner" ref={c => (this.innerRef = c)} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Wrapper
|
||||
title="wrapper"
|
||||
ref={c => (this.wrapperRef = c)}
|
||||
getContent={this.getInner}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Check .props.title to make sure we got the right elements back
|
||||
expect(this.wrapperRef.getTitle()).toBe('wrapper');
|
||||
expect(this.innerRef.className).toBe('inner');
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should warn when `key` is being accessed on composite element', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.key} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child key="0" />
|
||||
<Child key="1" />
|
||||
<Child key="2" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() => ReactDOM.render(<Parent />, container)).toErrorDev(
|
||||
'Child: `key` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when `ref` is being accessed', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.ref} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child ref="childElement" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() => ReactDOM.render(<Parent />, container)).toErrorDev(
|
||||
'Child: `ref` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when owner and self are different for string refs', () => {
|
||||
class ClassWithRenderProp extends React.Component {
|
||||
render() {
|
||||
return this.props.children();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassParent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<ClassWithRenderProp>{() => <div ref="myRef" />}</ClassWithRenderProp>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
if (process.env.BABEL_ENV === 'development') {
|
||||
expect(() => ReactDOM.render(<ClassParent />, container)).toErrorDev([
|
||||
'Warning: Component "ClassWithRenderProp" contains the string ref "myRef". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'This case cannot be automatically converted to an arrow function. ' +
|
||||
'We ask you to manually fix this case by using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref',
|
||||
]);
|
||||
} else {
|
||||
ReactDOM.render(<ClassParent />, container);
|
||||
}
|
||||
});
|
||||
61
fixtures/legacy-jsx-runtimes/react-16/yarn.lock
Normal file
61
fixtures/legacy-jsx-runtimes/react-16/yarn.lock
Normal file
@@ -0,0 +1,61 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||
|
||||
loose-envify@^1.1.0, loose-envify@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
dependencies:
|
||||
js-tokens "^3.0.0 || ^4.0.0"
|
||||
|
||||
object-assign@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
|
||||
prop-types@^15.6.2, prop-types@^15.7.2:
|
||||
version "15.7.2"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
|
||||
dependencies:
|
||||
loose-envify "^1.4.0"
|
||||
object-assign "^4.1.1"
|
||||
react-is "^16.8.1"
|
||||
|
||||
react-dom@16:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f"
|
||||
integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.19.1"
|
||||
|
||||
react-is@^16.8.1:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
|
||||
|
||||
react@16:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"
|
||||
integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
|
||||
scheduler@^0.19.1:
|
||||
version "0.19.1"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
|
||||
integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
File diff suppressed because it is too large
Load Diff
9
fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
9
fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @license React v17.0.0-rc.3
|
||||
* react-jsx-dev-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("object-assign");require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
|
||||
File diff suppressed because it is too large
Load Diff
10
fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
10
fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @license React v17.0.0-rc.3
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("object-assign");var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
||||
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
||||
7
fixtures/legacy-jsx-runtimes/react-17/jsx-dev-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-17/jsx-dev-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-17/jsx-runtime.js
vendored
Normal file
7
fixtures/legacy-jsx-runtimes/react-17/jsx-runtime.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-runtime.development.js');
|
||||
}
|
||||
7
fixtures/legacy-jsx-runtimes/react-17/package.json
Normal file
7
fixtures/legacy-jsx-runtimes/react-17/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "17.0.0-rc.3",
|
||||
"react-dom": "17.0.0-rc.3"
|
||||
}
|
||||
}
|
||||
773
fixtures/legacy-jsx-runtimes/react-17/react-17.test.js
Normal file
773
fixtures/legacy-jsx-runtimes/react-17/react-17.test.js
Normal file
@@ -0,0 +1,773 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
// These tests are based on ReactJSXElement-test,
|
||||
// ReactJSXElementValidator-test, ReactComponent-test,
|
||||
// and ReactElementJSX-test.
|
||||
|
||||
jest.mock('react/jsx-runtime', () => require('./jsx-runtime'), {virtual: true});
|
||||
jest.mock('react/jsx-dev-runtime', () => require('./jsx-dev-runtime'), {
|
||||
virtual: true,
|
||||
});
|
||||
|
||||
let React = require('react');
|
||||
let ReactDOM = require('react-dom');
|
||||
let ReactTestUtils = {
|
||||
renderIntoDocument(el) {
|
||||
const container = document.createElement('div');
|
||||
return ReactDOM.render(el, container);
|
||||
},
|
||||
};
|
||||
let PropTypes = require('prop-types');
|
||||
let Component = class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
};
|
||||
let RequiredPropComponent = class extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
};
|
||||
RequiredPropComponent.displayName = 'RequiredPropComponent';
|
||||
RequiredPropComponent.propTypes = {prop: PropTypes.string.isRequired};
|
||||
|
||||
it('works', () => {
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<h1>hello</h1>, container);
|
||||
expect(container.textContent).toBe('hello');
|
||||
});
|
||||
|
||||
it('returns a complete element according to spec', () => {
|
||||
const element = <Component />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a lower-case to be passed as the string type', () => {
|
||||
const element = <div />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('allows a string to be passed as the type', () => {
|
||||
const TagName = 'div';
|
||||
const element = <TagName />;
|
||||
expect(element.type).toBe('div');
|
||||
expect(element.key).toBe(null);
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('returns an immutable element', () => {
|
||||
const element = <Component />;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
expect(() => (element.type = 'div')).toThrow();
|
||||
} else {
|
||||
expect(() => (element.type = 'div')).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not reuse the object that is spread into props', () => {
|
||||
const config = {foo: 1};
|
||||
const element = <Component {...config} />;
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
expect(element.props.foo).toBe(1);
|
||||
});
|
||||
|
||||
it('extracts key and ref from the rest of the props', () => {
|
||||
const element = <Component key="12" ref="34" foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe('34');
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('coerces the key to a string', () => {
|
||||
const element = <Component key={12} foo="56" />;
|
||||
expect(element.type).toBe(Component);
|
||||
expect(element.key).toBe('12');
|
||||
expect(element.ref).toBe(null);
|
||||
const expectation = {foo: '56'};
|
||||
Object.freeze(expectation);
|
||||
expect(element.props).toEqual(expectation);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop', () => {
|
||||
const a = 1;
|
||||
const element = <Component children="text">{a}</Component>;
|
||||
expect(element.props.children).toBe(a);
|
||||
});
|
||||
|
||||
it('does not override children if no JSX children are provided', () => {
|
||||
const element = <Component children="text" />;
|
||||
expect(element.props.children).toBe('text');
|
||||
});
|
||||
|
||||
it('overrides children if null is provided as a JSX child', () => {
|
||||
const element = <Component children="text">{null}</Component>;
|
||||
expect(element.props.children).toBe(null);
|
||||
});
|
||||
|
||||
it('overrides children if undefined is provided as an argument', () => {
|
||||
const element = <Component children="text">{undefined}</Component>;
|
||||
expect(element.props.children).toBe(undefined);
|
||||
|
||||
const element2 = React.cloneElement(
|
||||
<Component children="text" />,
|
||||
{},
|
||||
undefined
|
||||
);
|
||||
expect(element2.props.children).toBe(undefined);
|
||||
});
|
||||
|
||||
it('merges JSX children onto the children prop in an array', () => {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
const c = 3;
|
||||
const element = (
|
||||
<Component>
|
||||
{a}
|
||||
{b}
|
||||
{c}
|
||||
</Component>
|
||||
);
|
||||
expect(element.props.children).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('allows static methods to be called using the type property', () => {
|
||||
class StaticMethodComponent {
|
||||
static someStaticMethod() {
|
||||
return 'someReturnValue';
|
||||
}
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
const element = <StaticMethodComponent />;
|
||||
expect(element.type.someStaticMethod()).toBe('someReturnValue');
|
||||
});
|
||||
|
||||
it('identifies valid elements', () => {
|
||||
expect(React.isValidElement(<div />)).toEqual(true);
|
||||
expect(React.isValidElement(<Component />)).toEqual(true);
|
||||
|
||||
expect(React.isValidElement(null)).toEqual(false);
|
||||
expect(React.isValidElement(true)).toEqual(false);
|
||||
expect(React.isValidElement({})).toEqual(false);
|
||||
expect(React.isValidElement('string')).toEqual(false);
|
||||
expect(React.isValidElement(Component)).toEqual(false);
|
||||
expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
|
||||
});
|
||||
|
||||
it('is indistinguishable from a plain object', () => {
|
||||
const element = <div className="foo" />;
|
||||
const object = {};
|
||||
expect(element.constructor).toBe(object.constructor);
|
||||
});
|
||||
|
||||
it('should use default prop value when removing a prop', () => {
|
||||
Component.defaultProps = {fruit: 'persimmon'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Component fruit="mango" />, container);
|
||||
expect(instance.props.fruit).toBe('mango');
|
||||
|
||||
ReactDOM.render(<Component />, container);
|
||||
expect(instance.props.fruit).toBe('persimmon');
|
||||
});
|
||||
|
||||
it('should normalize props with default values', () => {
|
||||
class NormalizingComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NormalizingComponent.defaultProps = {prop: 'testKey'};
|
||||
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<NormalizingComponent />, container);
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
const inst2 = ReactDOM.render(
|
||||
<NormalizingComponent prop={null} />,
|
||||
container
|
||||
);
|
||||
expect(inst2.props.prop).toBe(null);
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements in children position', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component />, <Component />]}</Component>
|
||||
)
|
||||
).toErrorDev('Each child in a list should have a unique "key" prop.');
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements with owner info', () => {
|
||||
class InnerComponent extends React.Component {
|
||||
render() {
|
||||
return <Component>{this.props.childSet}</Component>;
|
||||
}
|
||||
}
|
||||
|
||||
class ComponentWrapper extends React.Component {
|
||||
render() {
|
||||
return <InnerComponent childSet={[<Component />, <Component />]} />;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<ComponentWrapper />)
|
||||
).toErrorDev(
|
||||
'Each child in a list should have a unique "key" prop.' +
|
||||
'\n\nCheck the render method of `InnerComponent`. ' +
|
||||
'It was passed a child from ComponentWrapper. '
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for arrays of elements with keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for iterable elements with keys', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {
|
||||
value: done ? undefined : <Component key={'#' + i} />,
|
||||
done: done,
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn for numeric keys in entry iterable as a child', () => {
|
||||
const iterable = {
|
||||
'@@iterator': function() {
|
||||
let i = 0;
|
||||
return {
|
||||
next: function() {
|
||||
const done = ++i > 2;
|
||||
return {value: done ? undefined : [i, <Component />], done: done};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
iterable.entries = iterable['@@iterator'];
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component>{iterable}</Component>);
|
||||
});
|
||||
|
||||
it('does not warn when the element is directly as children', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<Component>
|
||||
<Component />
|
||||
<Component />
|
||||
</Component>
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn when the child array contains non-elements', () => {
|
||||
void (<Component>{[{}, {}]}</Component>);
|
||||
});
|
||||
|
||||
it('should give context for PropType errors in nested components.', () => {
|
||||
// In this test, we're making sure that if a proptype error is found in a
|
||||
// component, we give a small hint as to which parent instantiated that
|
||||
// component as per warnings about key usage in ReactElementValidator.
|
||||
function MyComp({color}) {
|
||||
return <div>My color is {color}</div>;
|
||||
}
|
||||
MyComp.propTypes = {
|
||||
color: PropTypes.string,
|
||||
};
|
||||
class ParentComp extends React.Component {
|
||||
render() {
|
||||
return <MyComp color={123} />;
|
||||
}
|
||||
}
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<ParentComp />)).toErrorDev(
|
||||
'Warning: Failed prop type: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`.\n' +
|
||||
' in fn (at **)\n' + // Jest/Node issue
|
||||
' in ParentComp (at **)'
|
||||
);
|
||||
});
|
||||
|
||||
it('gives a helpful error when passing null, undefined, or boolean', () => {
|
||||
const Undefined = undefined;
|
||||
const Null = null;
|
||||
const True = true;
|
||||
const Div = 'div';
|
||||
expect(
|
||||
() => void (<Undefined />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<Null />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: null.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
expect(
|
||||
() => void (<True />)
|
||||
).toErrorDev(
|
||||
'Warning: React.jsx: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: boolean.' +
|
||||
(process.env.BABEL_ENV === 'development'
|
||||
? '\n\nCheck your code at **.'
|
||||
: ''),
|
||||
{withoutStack: true}
|
||||
);
|
||||
// No error expected
|
||||
void (<Div />);
|
||||
});
|
||||
|
||||
it('should check default prop values', () => {
|
||||
RequiredPropComponent.defaultProps = {prop: null};
|
||||
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />)
|
||||
).toErrorDev(
|
||||
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
|
||||
'`RequiredPropComponent`, but its value is `null`.\n' +
|
||||
' in construct (at **)' // Jest/Node issue
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid prop types', () => {
|
||||
// Since there is no prevalidation step for ES6 classes, there is no hook
|
||||
// for us to issue a warning earlier than element creation when the error
|
||||
// actually occurs. Since this step is skipped in production, we should just
|
||||
// warn instead of throwing for this case.
|
||||
class NullPropTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullPropTypeComponent.propTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
|
||||
'function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn on invalid context types', () => {
|
||||
class NullContextTypeComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
NullContextTypeComponent.contextTypes = {
|
||||
prop: null,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />)
|
||||
).toErrorDev(
|
||||
'NullContextTypeComponent: context type `prop` is invalid; it must ' +
|
||||
'be a function, usually from the `prop-types` package,'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if getDefaultProps is specified on the class', () => {
|
||||
class GetDefaultPropsComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
GetDefaultPropsComponent.getDefaultProps = () => ({
|
||||
prop: 'foo',
|
||||
});
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />)
|
||||
).toErrorDev(
|
||||
'getDefaultProps is only used on classic React.createClass definitions.' +
|
||||
' Use a static property named `defaultProps` instead.',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if component declares PropTypes instead of propTypes', () => {
|
||||
class MisspelledPropTypesComponent extends React.Component {
|
||||
render() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
MisspelledPropTypesComponent.PropTypes = {
|
||||
prop: PropTypes.string,
|
||||
};
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<MisspelledPropTypesComponent prop="hi" />
|
||||
)
|
||||
).toErrorDev(
|
||||
'Warning: Component MisspelledPropTypesComponent declared `PropTypes` ' +
|
||||
'instead of `propTypes`. Did you misspell the property assignment?',
|
||||
{withoutStack: true}
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments with illegal attributes', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <React.Fragment a={1}>hello</React.Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid prop `a` supplied to `React.Fragment`. React.Fragment ' +
|
||||
'can only have `key` and `children` props.'
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments with refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment
|
||||
ref={bar => {
|
||||
this.foo = bar;
|
||||
}}>
|
||||
hello
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
expect(() => ReactTestUtils.renderIntoDocument(<Foo />)).toErrorDev(
|
||||
'Invalid attribute `ref` supplied to `React.Fragment`.'
|
||||
);
|
||||
});
|
||||
|
||||
it('does not warn for fragments of multiple elements without keys', () => {
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span>1</span>
|
||||
<span>2</span>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
it('warns for fragments of multiple elements with same key', () => {
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(
|
||||
<>
|
||||
<span key="a">1</span>
|
||||
<span key="a">2</span>
|
||||
<span key="b">3</span>
|
||||
</>
|
||||
)
|
||||
).toErrorDev('Encountered two children with the same key, `a`.', {
|
||||
withoutStack: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not call lazy initializers eagerly', () => {
|
||||
let didCall = false;
|
||||
const Lazy = React.lazy(() => {
|
||||
didCall = true;
|
||||
return {then() {}};
|
||||
});
|
||||
<Lazy />;
|
||||
expect(didCall).toBe(false);
|
||||
});
|
||||
|
||||
it('supports classic refs', () => {
|
||||
class Foo extends React.Component {
|
||||
render() {
|
||||
return <div className="foo" ref="inner" />;
|
||||
}
|
||||
}
|
||||
const container = document.createElement('div');
|
||||
const instance = ReactDOM.render(<Foo />, container);
|
||||
expect(instance.refs.inner.className).toBe('foo');
|
||||
});
|
||||
|
||||
it('should support refs on owned components', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref="inner" />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref="outer">
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.refs.inner.getObject()).toEqual(innerObj);
|
||||
expect(this.refs.outer.getObject()).toEqual(outerObj);
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
});
|
||||
|
||||
it('should support callback-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const inner = (
|
||||
<Wrapper object={innerObj} ref={c => (this.innerRef = c)} />
|
||||
);
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={c => (this.outerRef = c)}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support object-style refs', () => {
|
||||
const innerObj = {};
|
||||
const outerObj = {};
|
||||
|
||||
class Wrapper extends React.Component {
|
||||
getObject = () => {
|
||||
return this.props.object;
|
||||
};
|
||||
|
||||
render() {
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.innerRef = React.createRef();
|
||||
this.outerRef = React.createRef();
|
||||
}
|
||||
render() {
|
||||
const inner = <Wrapper object={innerObj} ref={this.innerRef} />;
|
||||
const outer = (
|
||||
<Wrapper object={outerObj} ref={this.outerRef}>
|
||||
{inner}
|
||||
</Wrapper>
|
||||
);
|
||||
return outer;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
expect(this.innerRef.current.getObject()).toEqual(innerObj);
|
||||
expect(this.outerRef.current.getObject()).toEqual(outerObj);
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should support new-style refs with mixed-up owners', () => {
|
||||
class Wrapper extends React.Component {
|
||||
getTitle = () => {
|
||||
return this.props.title;
|
||||
};
|
||||
|
||||
render() {
|
||||
return this.props.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false;
|
||||
|
||||
class Component extends React.Component {
|
||||
getInner = () => {
|
||||
// (With old-style refs, it's impossible to get a ref to this div
|
||||
// because Wrapper is the current owner when this function is called.)
|
||||
return <div className="inner" ref={c => (this.innerRef = c)} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Wrapper
|
||||
title="wrapper"
|
||||
ref={c => (this.wrapperRef = c)}
|
||||
getContent={this.getInner}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Check .props.title to make sure we got the right elements back
|
||||
expect(this.wrapperRef.getTitle()).toBe('wrapper');
|
||||
expect(this.innerRef.className).toBe('inner');
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(mounted).toBe(true);
|
||||
});
|
||||
|
||||
it('should warn when `key` is being accessed on composite element', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.key} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child key="0" />
|
||||
<Child key="1" />
|
||||
<Child key="2" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() => ReactDOM.render(<Parent />, container)).toErrorDev(
|
||||
'Child: `key` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when `ref` is being accessed', () => {
|
||||
const container = document.createElement('div');
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
return <div> {this.props.ref} </div>;
|
||||
}
|
||||
}
|
||||
class Parent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Child ref="childElement" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(() => ReactDOM.render(<Parent />, container)).toErrorDev(
|
||||
'Child: `ref` is not a prop. Trying to access it will result ' +
|
||||
'in `undefined` being returned. If you need to access the same ' +
|
||||
'value within the child component, you should pass it as a different ' +
|
||||
'prop. (https://reactjs.org/link/special-props)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn when owner and self are different for string refs', () => {
|
||||
class ClassWithRenderProp extends React.Component {
|
||||
render() {
|
||||
return this.props.children();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassParent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<ClassWithRenderProp>{() => <div ref="myRef" />}</ClassWithRenderProp>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
if (process.env.BABEL_ENV === 'development') {
|
||||
expect(() => ReactDOM.render(<ClassParent />, container)).toErrorDev([
|
||||
'Warning: Component "ClassWithRenderProp" contains the string ref "myRef". ' +
|
||||
'Support for string refs will be removed in a future major release. ' +
|
||||
'This case cannot be automatically converted to an arrow function. ' +
|
||||
'We ask you to manually fix this case by using useRef() or createRef() instead. ' +
|
||||
'Learn more about using refs safely here: ' +
|
||||
'https://reactjs.org/link/strict-mode-string-ref',
|
||||
]);
|
||||
} else {
|
||||
ReactDOM.render(<ClassParent />, container);
|
||||
}
|
||||
});
|
||||
59
fixtures/legacy-jsx-runtimes/react-17/yarn.lock
Normal file
59
fixtures/legacy-jsx-runtimes/react-17/yarn.lock
Normal file
@@ -0,0 +1,59 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
|
||||
|
||||
loose-envify@^1.1.0, loose-envify@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
dependencies:
|
||||
js-tokens "^3.0.0 || ^4.0.0"
|
||||
|
||||
object-assign@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
|
||||
prop-types@^15.7.2:
|
||||
version "15.7.2"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
|
||||
dependencies:
|
||||
loose-envify "^1.4.0"
|
||||
object-assign "^4.1.1"
|
||||
react-is "^16.8.1"
|
||||
|
||||
react-dom@17.0.0-rc.3:
|
||||
version "17.0.0-rc.3"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.0-rc.3.tgz#6254f82c62ed569a2a90dcf1c7b71d4d8d951744"
|
||||
integrity sha512-rrmZ91kdXBaCVomiNUQ1WvEClb5GcmxewGurd3FnsXKJBOhFdlkGbT5MY5ZQkMXH5xnIvs5ZEEB2iBr2ZqKiqg==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
scheduler "0.20.0-rc.3"
|
||||
|
||||
react-is@^16.8.1:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
|
||||
|
||||
react@17.0.0-rc.3:
|
||||
version "17.0.0-rc.3"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-17.0.0-rc.3.tgz#ccb426b0146a8c10ee92c2a72d9d813a16a55806"
|
||||
integrity sha512-b1vEcXBmlN2Bu+k57jq2ytEo5p28g5fdRfc02JRdnvGZKKphvlUnAfsrUHiOmUtL/6wvFIusi2zxp8t60fihfw==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
scheduler@0.20.0-rc.3:
|
||||
version "0.20.0-rc.3"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.0-rc.3.tgz#ce616ebdd4073f5026718960d7e2d0928788c626"
|
||||
integrity sha512-rPwhSgPKhRqximLHdl+oJ/8HVcMS2vyZlH74OQHqKbH04ONgKNkJ13DZLPdFSYFos8FUj6+PduO9+OoRaG6QWQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
318
fixtures/legacy-jsx-runtimes/setupTests.js
Normal file
318
fixtures/legacy-jsx-runtimes/setupTests.js
Normal file
@@ -0,0 +1,318 @@
|
||||
'use strict';
|
||||
|
||||
// This is mostly copypasta from toWarnDev.js matchers
|
||||
// that we use in the main repo Jest configuration.
|
||||
|
||||
const expect = global.expect;
|
||||
|
||||
const jestDiff = require('jest-diff').default;
|
||||
const util = require('util');
|
||||
|
||||
function shouldIgnoreConsoleError(format, args) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof format === 'string') {
|
||||
if (format.indexOf('Error: Uncaught [') === 0) {
|
||||
// This looks like an uncaught error from invokeGuardedCallback() wrapper
|
||||
// in development that is reported by jsdom. Ignore because it's noisy.
|
||||
return true;
|
||||
}
|
||||
if (format.indexOf('The above error occurred') === 0) {
|
||||
// This looks like an error addendum from ReactFiberErrorLogger.
|
||||
// Ignore it too.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
format != null &&
|
||||
typeof format.message === 'string' &&
|
||||
typeof format.stack === 'string' &&
|
||||
args.length === 0
|
||||
) {
|
||||
// In production, ReactFiberErrorLogger logs error objects directly.
|
||||
// They are noisy too so we'll try to ignore them.
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
format.indexOf(
|
||||
'act(...) is not supported in production builds of React'
|
||||
) === 0
|
||||
) {
|
||||
// We don't yet support act() for prod builds, and warn for it.
|
||||
// But we'd like to use act() ourselves for prod builds.
|
||||
// Let's ignore the warning and #yolo.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Looks legit
|
||||
return false;
|
||||
}
|
||||
|
||||
function normalizeCodeLocInfo(str) {
|
||||
if (typeof str !== 'string') {
|
||||
return str;
|
||||
}
|
||||
// This special case exists only for the special source location in
|
||||
// ReactElementValidator. That will go away if we remove source locations.
|
||||
str = str.replace(/Check your code at .+?:\d+/g, 'Check your code at **');
|
||||
// V8 format:
|
||||
// at Component (/path/filename.js:123:45)
|
||||
// React format:
|
||||
// in Component (at filename.js:123)
|
||||
return str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) {
|
||||
return '\n in ' + name + ' (at **)';
|
||||
});
|
||||
}
|
||||
|
||||
const createMatcherFor = (consoleMethod, matcherName) =>
|
||||
function matcher(callback, expectedMessages, options = {}) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// Warn about incorrect usage of matcher.
|
||||
if (typeof expectedMessages === 'string') {
|
||||
expectedMessages = [expectedMessages];
|
||||
} else if (!Array.isArray(expectedMessages)) {
|
||||
throw Error(
|
||||
`${matcherName}() requires a parameter of type string or an array of strings ` +
|
||||
`but was given ${typeof expectedMessages}.`
|
||||
);
|
||||
}
|
||||
if (
|
||||
options != null &&
|
||||
(typeof options !== 'object' || Array.isArray(options))
|
||||
) {
|
||||
throw new Error(
|
||||
`${matcherName}() second argument, when present, should be an object. ` +
|
||||
'Did you forget to wrap the messages into an array?'
|
||||
);
|
||||
}
|
||||
if (arguments.length > 3) {
|
||||
// `matcher` comes from Jest, so it's more than 2 in practice
|
||||
throw new Error(
|
||||
`${matcherName}() received more than two arguments. ` +
|
||||
'Did you forget to wrap the messages into an array?'
|
||||
);
|
||||
}
|
||||
|
||||
const withoutStack = options.withoutStack;
|
||||
const logAllErrors = options.logAllErrors;
|
||||
const warningsWithoutComponentStack = [];
|
||||
const warningsWithComponentStack = [];
|
||||
const unexpectedWarnings = [];
|
||||
|
||||
let lastWarningWithMismatchingFormat = null;
|
||||
let lastWarningWithExtraComponentStack = null;
|
||||
|
||||
// Catch errors thrown by the callback,
|
||||
// But only rethrow them if all test expectations have been satisfied.
|
||||
// Otherwise an Error in the callback can mask a failed expectation,
|
||||
// and result in a test that passes when it shouldn't.
|
||||
let caughtError;
|
||||
|
||||
const isLikelyAComponentStack = message =>
|
||||
typeof message === 'string' &&
|
||||
(message.includes('\n in ') || message.includes('\n at '));
|
||||
|
||||
const consoleSpy = (format, ...args) => {
|
||||
// Ignore uncaught errors reported by jsdom
|
||||
// and React addendums because they're too noisy.
|
||||
if (
|
||||
!logAllErrors &&
|
||||
consoleMethod === 'error' &&
|
||||
shouldIgnoreConsoleError(format, args)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = util.format(format, ...args);
|
||||
const normalizedMessage = normalizeCodeLocInfo(message);
|
||||
|
||||
// Remember if the number of %s interpolations
|
||||
// doesn't match the number of arguments.
|
||||
// We'll fail the test if it happens.
|
||||
let argIndex = 0;
|
||||
format.replace(/%s/g, () => argIndex++);
|
||||
if (argIndex !== args.length) {
|
||||
lastWarningWithMismatchingFormat = {
|
||||
format,
|
||||
args,
|
||||
expectedArgCount: argIndex,
|
||||
};
|
||||
}
|
||||
|
||||
// Protect against accidentally passing a component stack
|
||||
// to warning() which already injects the component stack.
|
||||
if (
|
||||
args.length >= 2 &&
|
||||
isLikelyAComponentStack(args[args.length - 1]) &&
|
||||
isLikelyAComponentStack(args[args.length - 2])
|
||||
) {
|
||||
lastWarningWithExtraComponentStack = {
|
||||
format,
|
||||
};
|
||||
}
|
||||
|
||||
for (let index = 0; index < expectedMessages.length; index++) {
|
||||
const expectedMessage = expectedMessages[index];
|
||||
if (
|
||||
normalizedMessage === expectedMessage ||
|
||||
normalizedMessage.includes(expectedMessage)
|
||||
) {
|
||||
if (isLikelyAComponentStack(normalizedMessage)) {
|
||||
warningsWithComponentStack.push(normalizedMessage);
|
||||
} else {
|
||||
warningsWithoutComponentStack.push(normalizedMessage);
|
||||
}
|
||||
expectedMessages.splice(index, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let errorMessage;
|
||||
if (expectedMessages.length === 0) {
|
||||
errorMessage =
|
||||
'Unexpected warning recorded: ' +
|
||||
this.utils.printReceived(normalizedMessage);
|
||||
} else if (expectedMessages.length === 1) {
|
||||
errorMessage =
|
||||
'Unexpected warning recorded: ' +
|
||||
jestDiff(expectedMessages[0], normalizedMessage);
|
||||
} else {
|
||||
errorMessage =
|
||||
'Unexpected warning recorded: ' +
|
||||
jestDiff(expectedMessages, [normalizedMessage]);
|
||||
}
|
||||
|
||||
// Record the call stack for unexpected warnings.
|
||||
// We don't throw an Error here though,
|
||||
// Because it might be suppressed by ReactFiberScheduler.
|
||||
unexpectedWarnings.push(new Error(errorMessage));
|
||||
};
|
||||
|
||||
// TODO Decide whether we need to support nested toWarn* expectations.
|
||||
// If we don't need it, add a check here to see if this is already our spy,
|
||||
// And throw an error.
|
||||
const originalMethod = console[consoleMethod];
|
||||
|
||||
// Avoid using Jest's built-in spy since it can't be removed.
|
||||
console[consoleMethod] = consoleSpy;
|
||||
|
||||
try {
|
||||
callback();
|
||||
} catch (error) {
|
||||
caughtError = error;
|
||||
} finally {
|
||||
// Restore the unspied method so that unexpected errors fail tests.
|
||||
console[consoleMethod] = originalMethod;
|
||||
|
||||
// Any unexpected Errors thrown by the callback should fail the test.
|
||||
// This should take precedence since unexpected errors could block warnings.
|
||||
if (caughtError) {
|
||||
throw caughtError;
|
||||
}
|
||||
|
||||
// Any unexpected warnings should be treated as a failure.
|
||||
if (unexpectedWarnings.length > 0) {
|
||||
return {
|
||||
message: () => unexpectedWarnings[0].stack,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Any remaining messages indicate a failed expectations.
|
||||
if (expectedMessages.length > 0) {
|
||||
return {
|
||||
message: () =>
|
||||
`Expected warning was not recorded:\n ${this.utils.printReceived(
|
||||
expectedMessages[0]
|
||||
)}`,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof withoutStack === 'number') {
|
||||
// We're expecting a particular number of warnings without stacks.
|
||||
if (withoutStack !== warningsWithoutComponentStack.length) {
|
||||
return {
|
||||
message: () =>
|
||||
`Expected ${withoutStack} warnings without a component stack but received ${warningsWithoutComponentStack.length}:\n` +
|
||||
warningsWithoutComponentStack.map(warning =>
|
||||
this.utils.printReceived(warning)
|
||||
),
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
} else if (withoutStack === true) {
|
||||
// We're expecting that all warnings won't have the stack.
|
||||
// If some warnings have it, it's an error.
|
||||
if (warningsWithComponentStack.length > 0) {
|
||||
return {
|
||||
message: () =>
|
||||
`Received warning unexpectedly includes a component stack:\n ${this.utils.printReceived(
|
||||
warningsWithComponentStack[0]
|
||||
)}\nIf this warning intentionally includes the component stack, remove ` +
|
||||
`{withoutStack: true} from the ${matcherName}() call. If you have a mix of ` +
|
||||
`warnings with and without stack in one ${matcherName}() call, pass ` +
|
||||
`{withoutStack: N} where N is the number of warnings without stacks.`,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
} else if (withoutStack === false || withoutStack === undefined) {
|
||||
// We're expecting that all warnings *do* have the stack (default).
|
||||
// If some warnings don't have it, it's an error.
|
||||
if (warningsWithoutComponentStack.length > 0) {
|
||||
return {
|
||||
message: () =>
|
||||
`Received warning unexpectedly does not include a component stack:\n ${this.utils.printReceived(
|
||||
warningsWithoutComponentStack[0]
|
||||
)}\nIf this warning intentionally omits the component stack, add ` +
|
||||
`{withoutStack: true} to the ${matcherName} call.`,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
throw Error(
|
||||
`The second argument for ${matcherName}(), when specified, must be an object. It may have a ` +
|
||||
`property called "withoutStack" whose value may be undefined, boolean, or a number. ` +
|
||||
`Instead received ${typeof withoutStack}.`
|
||||
);
|
||||
}
|
||||
|
||||
if (lastWarningWithMismatchingFormat !== null) {
|
||||
return {
|
||||
message: () =>
|
||||
`Received ${
|
||||
lastWarningWithMismatchingFormat.args.length
|
||||
} arguments for a message with ${
|
||||
lastWarningWithMismatchingFormat.expectedArgCount
|
||||
} placeholders:\n ${this.utils.printReceived(
|
||||
lastWarningWithMismatchingFormat.format
|
||||
)}`,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (lastWarningWithExtraComponentStack !== null) {
|
||||
return {
|
||||
message: () =>
|
||||
`Received more than one component stack for a warning:\n ${this.utils.printReceived(
|
||||
lastWarningWithExtraComponentStack.format
|
||||
)}\nDid you accidentally pass a stack to warning() as the last argument? ` +
|
||||
`Don't forget warning() already injects the component stack automatically.`,
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {pass: true};
|
||||
}
|
||||
} else {
|
||||
// Any uncaught errors or warnings should fail tests in production mode.
|
||||
callback();
|
||||
|
||||
return {pass: true};
|
||||
}
|
||||
};
|
||||
|
||||
expect.extend({
|
||||
toWarnDev: createMatcherFor('warn', 'toWarnDev'),
|
||||
toErrorDev: createMatcherFor('error', 'toErrorDev'),
|
||||
});
|
||||
3780
fixtures/legacy-jsx-runtimes/yarn.lock
Normal file
3780
fixtures/legacy-jsx-runtimes/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
31
old_major_packages/14/react-dom/LICENSE
Normal file
31
old_major_packages/14/react-dom/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-2015, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
old_major_packages/14/react-dom/PATENTS
Normal file
33
old_major_packages/14/react-dom/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
54
old_major_packages/14/react-dom/README.md
Normal file
54
old_major_packages/14/react-dom/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# `react-dom`
|
||||
|
||||
This package serves as the entry point of the DOM-related rendering paths. It is intended to be paired with the isomorphic React, which will be shipped as `react` to npm.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install react react-dom
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### In the browser
|
||||
|
||||
```js
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
class MyComponent extends React.Component {
|
||||
render() {
|
||||
return <div>Hello World</div>;
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(<MyComponent />, node);
|
||||
```
|
||||
|
||||
### On the server
|
||||
|
||||
```js
|
||||
var React = require('react');
|
||||
var ReactDOMServer = require('react-dom/server');
|
||||
|
||||
class MyComponent extends React.Component {
|
||||
render() {
|
||||
return <div>Hello World</div>;
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOMServer.renderToString(<MyComponent />);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `react-dom`
|
||||
|
||||
- `findDOMNode`
|
||||
- `render`
|
||||
- `unmountComponentAtNode`
|
||||
|
||||
### `react-dom/server`
|
||||
|
||||
- `renderToString`
|
||||
- `renderToStaticMarkup`
|
||||
42
old_major_packages/14/react-dom/dist/react-dom-server.js
vendored
Normal file
42
old_major_packages/14/react-dom/dist/react-dom-server.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* ReactDOMServer v0.14.10
|
||||
*
|
||||
* Copyright 2013-2015, 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.
|
||||
*
|
||||
*/
|
||||
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
;(function(f) {
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = f(require('react'));
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(['react'], f);
|
||||
|
||||
// <script>
|
||||
} else {
|
||||
var g;
|
||||
if (typeof window !== "undefined") {
|
||||
g = window;
|
||||
} else if (typeof global !== "undefined") {
|
||||
g = global;
|
||||
} else if (typeof self !== "undefined") {
|
||||
g = self;
|
||||
} else {
|
||||
// works providing we're not in "use strict";
|
||||
// needed for Java 8 Nashorn
|
||||
// see https://github.com/facebook/react/issues/3037
|
||||
g = this;
|
||||
}
|
||||
g.ReactDOMServer = f(g.React);
|
||||
}
|
||||
|
||||
})(function(React) {
|
||||
return React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
});
|
||||
12
old_major_packages/14/react-dom/dist/react-dom-server.min.js
vendored
Normal file
12
old_major_packages/14/react-dom/dist/react-dom-server.min.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* ReactDOMServer v0.14.10
|
||||
*
|
||||
* Copyright 2013-2015, 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.
|
||||
*
|
||||
*/
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOMServer=e(f.React)}}(function(e){return e.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});
|
||||
42
old_major_packages/14/react-dom/dist/react-dom.js
vendored
Normal file
42
old_major_packages/14/react-dom/dist/react-dom.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* ReactDOM v0.14.10
|
||||
*
|
||||
* Copyright 2013-2015, 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.
|
||||
*
|
||||
*/
|
||||
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
;(function(f) {
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = f(require('react'));
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(['react'], f);
|
||||
|
||||
// <script>
|
||||
} else {
|
||||
var g;
|
||||
if (typeof window !== "undefined") {
|
||||
g = window;
|
||||
} else if (typeof global !== "undefined") {
|
||||
g = global;
|
||||
} else if (typeof self !== "undefined") {
|
||||
g = self;
|
||||
} else {
|
||||
// works providing we're not in "use strict";
|
||||
// needed for Java 8 Nashorn
|
||||
// see https://github.com/facebook/react/issues/3037
|
||||
g = this;
|
||||
}
|
||||
g.ReactDOM = f(g.React);
|
||||
}
|
||||
|
||||
})(function(React) {
|
||||
return React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
});
|
||||
12
old_major_packages/14/react-dom/dist/react-dom.min.js
vendored
Normal file
12
old_major_packages/14/react-dom/dist/react-dom.min.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* ReactDOM v0.14.10
|
||||
*
|
||||
* Copyright 2013-2015, 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.
|
||||
*
|
||||
*/
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOM=e(f.React)}}(function(e){return e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});
|
||||
3
old_major_packages/14/react-dom/index.js
vendored
Normal file
3
old_major_packages/14/react-dom/index.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('react/lib/ReactDOM');
|
||||
27
old_major_packages/14/react-dom/package.json
Normal file
27
old_major_packages/14/react-dom/package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"bugs": {
|
||||
"url": "https://github.com/facebook/react/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "React package for working with the DOM.",
|
||||
"homepage": "https://facebook.github.io/react/",
|
||||
"keywords": [
|
||||
"react"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "index.js",
|
||||
"name": "react-dom",
|
||||
"peerDependencies": {
|
||||
"react": "^0.14.10"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/facebook/react.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"version": "0.14.10"
|
||||
}
|
||||
3
old_major_packages/14/react-dom/server.js
vendored
Normal file
3
old_major_packages/14/react-dom/server.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('react/lib/ReactDOMServer');
|
||||
31
old_major_packages/14/react/LICENSE
Normal file
31
old_major_packages/14/react/LICENSE
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD License
|
||||
|
||||
For React software
|
||||
|
||||
Copyright (c) 2013-2015, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
33
old_major_packages/14/react/PATENTS
Normal file
33
old_major_packages/14/react/PATENTS
Normal file
@@ -0,0 +1,33 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the React software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
|
||||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
(subject to the termination provision below) license under any Necessary
|
||||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
transfer the Software. For avoidance of doubt, no license is granted under
|
||||
Facebook's rights in any patent claims that are infringed by (i) modifications
|
||||
to the Software made by you or any third party or (ii) the Software in
|
||||
combination with any software or other technology.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
|
||||
directly or indirectly, or take a direct financial interest in, any Patent
|
||||
Assertion: (i) against Facebook or any of its subsidiaries or corporate
|
||||
affiliates, (ii) against any party if such Patent Assertion arises in whole or
|
||||
in part from any software, technology, product or service of Facebook or any of
|
||||
its subsidiaries or corporate affiliates, or (iii) against any party relating
|
||||
to the Software. Notwithstanding the foregoing, if Facebook or any of its
|
||||
subsidiaries or corporate affiliates files a lawsuit alleging patent
|
||||
infringement against you in the first instance, and you respond by filing a
|
||||
patent infringement counterclaim in that lawsuit against that party that is
|
||||
unrelated to the Software, the license granted hereunder will not terminate
|
||||
under section (i) of this paragraph due to such counterclaim.
|
||||
|
||||
A "Necessary Claim" is a claim of a patent owned by Facebook that is
|
||||
necessarily infringed by the Software standing alone.
|
||||
|
||||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
|
||||
or contributory infringement or inducement to infringe any patent, including a
|
||||
cross-claim or counterclaim.
|
||||
23
old_major_packages/14/react/README.md
Normal file
23
old_major_packages/14/react/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# react
|
||||
|
||||
An npm package to get you immediate access to [React](https://facebook.github.io/react/),
|
||||
without also requiring the JSX transformer. This is especially useful for cases where you
|
||||
want to [`browserify`](https://github.com/substack/node-browserify) your module using
|
||||
`React`.
|
||||
|
||||
**Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages.
|
||||
|
||||
To use React in production mode, set the environment variable `NODE_ENV` to `production`. A minifier that performs dead-code elimination such as [UglifyJS](https://github.com/mishoo/UglifyJS2) is recommended to completely remove the extra code present in development mode.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```js
|
||||
var React = require('react');
|
||||
|
||||
// Addons are in separate packages:
|
||||
var createFragment = require('react-addons-create-fragment');
|
||||
var immutabilityHelpers = require('react-addons-update');
|
||||
var CSSTransitionGroup = require('react-addons-css-transition-group');
|
||||
```
|
||||
|
||||
For a complete list of addons visit the [addons documentation page](https://facebook.github.io/react/docs/addons.html).
|
||||
13
old_major_packages/14/react/addons.js
Normal file
13
old_major_packages/14/react/addons.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
warning(
|
||||
false,
|
||||
// Require examples in this string must be split to prevent React's
|
||||
// build tools from mistaking them for real requires.
|
||||
// Otherwise the build tools will attempt to build a 'react-addons-{addon}' module.
|
||||
'require' + "('react/addons') is deprecated. " +
|
||||
'Access using require' + "('react-addons-{addon}') instead."
|
||||
);
|
||||
|
||||
module.exports = require('./lib/ReactWithAddons');
|
||||
@@ -0,0 +1,861 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-dev-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
|
||||
var jsxDEV$1 = jsxWithValidation ;
|
||||
|
||||
exports.jsxDEV = jsxDEV$1;
|
||||
})();
|
||||
}
|
||||
9
old_major_packages/14/react/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
9
old_major_packages/14/react/cjs/react-jsx-dev-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-dev-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';require("react");exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var a=Symbol.for;exports.Fragment=a("react.fragment")}exports.jsxDEV=void 0;
|
||||
883
old_major_packages/14/react/cjs/react-jsx-runtime.development.js
Normal file
883
old_major_packages/14/react/cjs/react-jsx-runtime.development.js
Normal file
@@ -0,0 +1,883 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-runtime.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
exports.Fragment = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
exports.Fragment = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||||
|
||||
if (typeof maybeIterator === 'function') {
|
||||
return maybeIterator;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function error(format) {
|
||||
{
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
printWarning('error', format, args);
|
||||
}
|
||||
}
|
||||
|
||||
function printWarning(level, format, args) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
{
|
||||
var stack = '';
|
||||
|
||||
if (stack !== '') {
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
|
||||
var argsWithFormat = args.map(function (item) {
|
||||
return '' + item;
|
||||
}); // Careful: RN currently depends on this prefix
|
||||
|
||||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
|
||||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
||||
function describeComponentFrame (name, source, ownerName) {
|
||||
var sourceInfo = '';
|
||||
|
||||
if (source) {
|
||||
var path = source.fileName;
|
||||
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
||||
|
||||
{
|
||||
// In DEV, include code for a common special case:
|
||||
// prefer "folder/index.js" instead of just "index.js".
|
||||
if (/^index\./.test(fileName)) {
|
||||
var match = path.match(BEFORE_SLASH_RE);
|
||||
|
||||
if (match) {
|
||||
var pathBeforeSlash = match[1];
|
||||
|
||||
if (pathBeforeSlash) {
|
||||
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
||||
fileName = folderName + '/' + fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
||||
} else if (ownerName) {
|
||||
sourceInfo = ' (created by ' + ownerName + ')';
|
||||
}
|
||||
|
||||
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
||||
}
|
||||
|
||||
var Resolved = 1;
|
||||
function refineResolvedLazyComponent(lazyComponent) {
|
||||
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
||||
}
|
||||
|
||||
function getWrappedName(outerType, innerType, wrapperName) {
|
||||
var functionName = innerType.displayName || innerType.name || '';
|
||||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||||
}
|
||||
|
||||
function getComponentName(type) {
|
||||
if (type == null) {
|
||||
// Host root, text node or just invalid type.
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
if (typeof type.tag === 'number') {
|
||||
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case exports.Fragment:
|
||||
return 'Fragment';
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'Portal';
|
||||
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return 'Suspense';
|
||||
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return 'SuspenseList';
|
||||
}
|
||||
|
||||
if (typeof type === 'object') {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
return getWrappedName(type, type.render, 'ForwardRef');
|
||||
|
||||
case REACT_MEMO_TYPE:
|
||||
return getComponentName(type.type);
|
||||
|
||||
case REACT_BLOCK_TYPE:
|
||||
return getComponentName(type.render);
|
||||
|
||||
case REACT_LAZY_TYPE:
|
||||
{
|
||||
var thenable = type;
|
||||
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
||||
|
||||
if (resolvedThenable) {
|
||||
return getComponentName(resolvedThenable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var loggedTypeFailures = {};
|
||||
var currentlyValidatingElement = null;
|
||||
|
||||
function setCurrentlyValidatingElement(element) {
|
||||
{
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||||
{
|
||||
// $FlowFixMe This is okay but Flow doesn't know it.
|
||||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (has(typeSpecs, typeSpecName)) {
|
||||
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
||||
// fail the render phase where it didn't fail before. So we log it.
|
||||
// After these have been cleaned up, we'll let them throw.
|
||||
|
||||
try {
|
||||
// This is intentionally an invariant that gets caught. It's the same
|
||||
// behavior as without this statement except with a better message.
|
||||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||||
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
||||
err.name = 'Invariant Violation';
|
||||
throw err;
|
||||
}
|
||||
|
||||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
} catch (ex) {
|
||||
error$1 = ex;
|
||||
}
|
||||
|
||||
if (error$1 && !(error$1 instanceof Error)) {
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
|
||||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error$1.message] = true;
|
||||
setCurrentlyValidatingElement(element);
|
||||
|
||||
error('Failed %s type: %s', location, error$1.message);
|
||||
|
||||
setCurrentlyValidatingElement(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var didWarnAboutStringRefs;
|
||||
|
||||
{
|
||||
didWarnAboutStringRefs = {};
|
||||
}
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'ref')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.ref !== undefined;
|
||||
}
|
||||
|
||||
function hasValidKey(config) {
|
||||
{
|
||||
if (hasOwnProperty.call(config, 'key')) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
||||
|
||||
if (getter && getter.isReactWarning) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config.key !== undefined;
|
||||
}
|
||||
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingKey = function () {
|
||||
if (!specialPropKeyWarningShown) {
|
||||
specialPropKeyWarningShown = true;
|
||||
|
||||
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, 'key', {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defineRefPropWarningGetter(props, displayName) {
|
||||
{
|
||||
var warnAboutAccessingRef = function () {
|
||||
if (!specialPropRefWarningShown) {
|
||||
specialPropRefWarningShown = true;
|
||||
|
||||
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
||||
}
|
||||
};
|
||||
|
||||
warnAboutAccessingRef.isReactWarning = true;
|
||||
Object.defineProperty(props, 'ref', {
|
||||
get: warnAboutAccessingRef,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Factory method to create a new React element. This no longer adheres to
|
||||
* the class pattern, so do not use new to call it. Also, instanceof check
|
||||
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
||||
* if something is a React Element.
|
||||
*
|
||||
* @param {*} type
|
||||
* @param {*} props
|
||||
* @param {*} key
|
||||
* @param {string|object} ref
|
||||
* @param {*} owner
|
||||
* @param {*} self A *temporary* helper to detect places where `this` is
|
||||
* different from the `owner` when React.createElement is called, so that we
|
||||
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
||||
* functions, and as long as `this` and owner are the same, there will be no
|
||||
* change in behavior.
|
||||
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
||||
* indicating filename, line number, and/or other information.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
key: key,
|
||||
ref: ref,
|
||||
props: props,
|
||||
// Record the component responsible for creating this element.
|
||||
_owner: owner
|
||||
};
|
||||
|
||||
{
|
||||
// The validation flag is currently mutative. We put it on
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
// include every environment we run tests in), so the test framework
|
||||
// ignores it.
|
||||
|
||||
Object.defineProperty(element._store, 'validated', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false
|
||||
}); // self and source are DEV only properties.
|
||||
|
||||
Object.defineProperty(element, '_self', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: self
|
||||
}); // Two elements created in two different places should be considered
|
||||
// equal for testing purposes and therefore we hide it from enumeration.
|
||||
|
||||
Object.defineProperty(element, '_source', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: source
|
||||
});
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(element.props);
|
||||
Object.freeze(element);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
/**
|
||||
* https://github.com/reactjs/rfcs/pull/107
|
||||
* @param {*} type
|
||||
* @param {object} props
|
||||
* @param {string} key
|
||||
*/
|
||||
|
||||
function jsxDEV(type, config, maybeKey, source, self) {
|
||||
{
|
||||
var propName; // Reserved names are extracted
|
||||
|
||||
var props = {};
|
||||
var key = null;
|
||||
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
||||
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
||||
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
||||
// but as an intermediary step, we will use jsxDEV for everything except
|
||||
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
||||
// key is explicitly declared to be undefined or not.
|
||||
|
||||
if (maybeKey !== undefined) {
|
||||
key = '' + maybeKey;
|
||||
}
|
||||
|
||||
if (hasValidKey(config)) {
|
||||
key = '' + config.key;
|
||||
}
|
||||
|
||||
if (hasValidRef(config)) {
|
||||
ref = config.ref;
|
||||
} // Remaining properties are added to a new props object
|
||||
|
||||
|
||||
for (propName in config) {
|
||||
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||||
props[propName] = config[propName];
|
||||
}
|
||||
} // Resolve default props
|
||||
|
||||
|
||||
if (type && type.defaultProps) {
|
||||
var defaultProps = type.defaultProps;
|
||||
|
||||
for (propName in defaultProps) {
|
||||
if (props[propName] === undefined) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key || ref) {
|
||||
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
||||
|
||||
if (key) {
|
||||
defineKeyPropWarningGetter(props, displayName);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
defineRefPropWarningGetter(props, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
||||
}
|
||||
}
|
||||
|
||||
var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
|
||||
|
||||
function setCurrentlyValidatingElement$1(element) {
|
||||
currentlyValidatingElement = element;
|
||||
}
|
||||
|
||||
var propTypesMisspellWarningShown;
|
||||
|
||||
{
|
||||
propTypesMisspellWarningShown = false;
|
||||
}
|
||||
/**
|
||||
* Verifies the object is a ReactElement.
|
||||
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
||||
* @param {?object} object
|
||||
* @return {boolean} True if `object` is a ReactElement.
|
||||
* @final
|
||||
*/
|
||||
|
||||
function isValidElement(object) {
|
||||
{
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
{
|
||||
if (ReactCurrentOwner$1.current) {
|
||||
var name = ReactCurrentOwner$1.current.getName();
|
||||
|
||||
if (name) {
|
||||
return '\n\nCheck the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceInfoErrorAddendum(source) {
|
||||
{
|
||||
if (source !== undefined) {
|
||||
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
||||
var lineNumber = source.lineNumber;
|
||||
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if there's no key explicitly set on dynamic arrays of children or
|
||||
* object keys are not valid. This allows us to keep track of children between
|
||||
* updates.
|
||||
*/
|
||||
|
||||
|
||||
var ownerHasKeyUseWarning = {};
|
||||
|
||||
function getCurrentComponentErrorInfo(parentType) {
|
||||
{
|
||||
var info = getDeclarationErrorAddendum();
|
||||
|
||||
if (!info) {
|
||||
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
||||
|
||||
if (parentName) {
|
||||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Warn if the element doesn't have an explicit key assigned to it.
|
||||
* This element is in an array. The array could grow and shrink or be
|
||||
* reordered. All children that haven't already been validated are required to
|
||||
* have a "key" property assigned to it. Error statuses are cached so a warning
|
||||
* will only be shown once.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactElement} element Element that requires a key.
|
||||
* @param {*} parentType element's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateExplicitKey(element, parentType) {
|
||||
{
|
||||
if (!element._store || element._store.validated || element.key != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element._store.validated = true;
|
||||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||||
|
||||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
||||
// property, it may be the creator of the child that's responsible for
|
||||
// assigning it a key.
|
||||
|
||||
var childOwner = '';
|
||||
|
||||
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
||||
// Give the component that originally created this child.
|
||||
childOwner = " It was passed a child from " + element._owner.getName() + ".";
|
||||
}
|
||||
|
||||
setCurrentlyValidatingElement$1(element);
|
||||
|
||||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that every element either is passed in a static location, in an
|
||||
* array with an explicit keys property defined, or in an object literal
|
||||
* with valid key property.
|
||||
*
|
||||
* @internal
|
||||
* @param {ReactNode} node Statically passed child of any type.
|
||||
* @param {*} parentType node's parent's type.
|
||||
*/
|
||||
|
||||
|
||||
function validateChildKeys(node, parentType) {
|
||||
{
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
var child = node[i];
|
||||
|
||||
if (isValidElement(child)) {
|
||||
validateExplicitKey(child, parentType);
|
||||
}
|
||||
}
|
||||
} else if (isValidElement(node)) {
|
||||
// This element was passed in a valid location.
|
||||
if (node._store) {
|
||||
node._store.validated = true;
|
||||
}
|
||||
} else if (node) {
|
||||
var iteratorFn = getIteratorFn(node);
|
||||
|
||||
if (typeof iteratorFn === 'function') {
|
||||
// Entry iterators used to provide implicit keys,
|
||||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given an element, validate that its props follow the propTypes definition,
|
||||
* provided by the type.
|
||||
*
|
||||
* @param {ReactElement} element
|
||||
*/
|
||||
|
||||
|
||||
function validatePropTypes(element) {
|
||||
{
|
||||
var type = element.type;
|
||||
|
||||
if (type === null || type === undefined || typeof type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var propTypes;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
||||
// Inner props are checked in the reconciler.
|
||||
type.$$typeof === REACT_MEMO_TYPE)) {
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (propTypes) {
|
||||
// Intentionally inside to avoid triggering lazy initializers:
|
||||
var name = getComponentName(type);
|
||||
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
||||
|
||||
var _name = getComponentName(type);
|
||||
|
||||
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
||||
}
|
||||
|
||||
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
||||
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a fragment, validate that it can only be provided with fragment props
|
||||
* @param {ReactElement} fragment
|
||||
*/
|
||||
|
||||
|
||||
function validateFragmentProps(fragment) {
|
||||
{
|
||||
var keys = Object.keys(fragment.props);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragment.ref !== null) {
|
||||
setCurrentlyValidatingElement$1(fragment);
|
||||
|
||||
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
||||
|
||||
setCurrentlyValidatingElement$1(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
||||
{
|
||||
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
||||
// succeed and there will likely be errors in render.
|
||||
|
||||
if (!validType) {
|
||||
var info = '';
|
||||
|
||||
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
||||
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(source);
|
||||
|
||||
if (sourceInfo) {
|
||||
info += sourceInfo;
|
||||
} else {
|
||||
info += getDeclarationErrorAddendum();
|
||||
}
|
||||
|
||||
var typeString;
|
||||
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||||
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
||||
info = ' Did you accidentally export a JSX literal instead of a component?';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
||||
// TODO: Drop this when these are no longer allowed as the type argument.
|
||||
|
||||
if (element == null) {
|
||||
return element;
|
||||
} // Skip key warning if the type isn't valid since our key validation logic
|
||||
// doesn't expect a non-string/function type and can throw confusing errors.
|
||||
// We don't want exception behavior to differ between dev and prod.
|
||||
// (Rendering will throw with a helpful message and as soon as the type is
|
||||
// fixed, the key warnings will appear.)
|
||||
|
||||
|
||||
if (validType) {
|
||||
var children = props.children;
|
||||
|
||||
if (children !== undefined) {
|
||||
if (isStaticChildren) {
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
validateChildKeys(children[i], type);
|
||||
}
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(children);
|
||||
}
|
||||
} else {
|
||||
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
||||
}
|
||||
} else {
|
||||
validateChildKeys(children, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === exports.Fragment) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
} // These two functions exist to still get child warnings in dev
|
||||
// even with the prod transform. This means that jsxDEV is purely
|
||||
// opt-in behavior for better messages but that we won't stop
|
||||
// giving you warnings if you use production apis.
|
||||
|
||||
function jsxWithValidationStatic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, true);
|
||||
}
|
||||
}
|
||||
function jsxWithValidationDynamic(type, props, key) {
|
||||
{
|
||||
return jsxWithValidation(type, props, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
||||
// for now we can ship identical prod functions
|
||||
|
||||
var jsxs = jsxWithValidationStatic ;
|
||||
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
})();
|
||||
}
|
||||
10
old_major_packages/14/react/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
10
old_major_packages/14/react/cjs/react-jsx-runtime.production.min.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @license React v0.14.10
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';var f=require("react"),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=require("react/lib/ReactCurrentOwner"),n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
||||
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
||||
20775
old_major_packages/14/react/dist/react-with-addons.js
vendored
Normal file
20775
old_major_packages/14/react/dist/react-with-addons.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
old_major_packages/14/react/dist/react-with-addons.min.js
vendored
Normal file
16
old_major_packages/14/react/dist/react-with-addons.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
18812
old_major_packages/14/react/dist/react.js
vendored
Normal file
18812
old_major_packages/14/react/dist/react.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
old_major_packages/14/react/dist/react.min.js
vendored
Normal file
16
old_major_packages/14/react/dist/react.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
old_major_packages/14/react/jsx-dev-runtime.js
Normal file
7
old_major_packages/14/react/jsx-dev-runtime.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
|
||||
}
|
||||
7
old_major_packages/14/react/jsx-runtime.js
Normal file
7
old_major_packages/14/react/jsx-runtime.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-jsx-runtime.development.js');
|
||||
}
|
||||
36
old_major_packages/14/react/lib/AutoFocusUtils.js
Normal file
36
old_major_packages/14/react/lib/AutoFocusUtils.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 AutoFocusUtils
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactMount = require('./ReactMount');
|
||||
|
||||
var findDOMNode = require('./findDOMNode');
|
||||
var focusNode = require('fbjs/lib/focusNode');
|
||||
|
||||
var Mixin = {
|
||||
componentDidMount: function () {
|
||||
if (this.props.autoFocus) {
|
||||
focusNode(findDOMNode(this));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var AutoFocusUtils = {
|
||||
Mixin: Mixin,
|
||||
|
||||
focusDOMComponent: function () {
|
||||
focusNode(ReactMount.getNode(this._rootNodeID));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AutoFocusUtils;
|
||||
405
old_major_packages/14/react/lib/BeforeInputEventPlugin.js
Normal file
405
old_major_packages/14/react/lib/BeforeInputEventPlugin.js
Normal file
@@ -0,0 +1,405 @@
|
||||
/**
|
||||
* Copyright 2013-2015 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 BeforeInputEventPlugin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require('./EventConstants');
|
||||
var EventPropagators = require('./EventPropagators');
|
||||
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
var FallbackCompositionState = require('./FallbackCompositionState');
|
||||
var SyntheticCompositionEvent = require('./SyntheticCompositionEvent');
|
||||
var SyntheticInputEvent = require('./SyntheticInputEvent');
|
||||
|
||||
var keyOf = require('fbjs/lib/keyOf');
|
||||
|
||||
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
|
||||
var START_KEYCODE = 229;
|
||||
|
||||
var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window;
|
||||
|
||||
var documentMode = null;
|
||||
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
|
||||
documentMode = document.documentMode;
|
||||
}
|
||||
|
||||
// Webkit offers a very useful `textInput` event that can be used to
|
||||
// directly represent `beforeInput`. The IE `textinput` event is not as
|
||||
// useful, so we don't use it.
|
||||
var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto();
|
||||
|
||||
// In IE9+, we have access to composition events, but the data supplied
|
||||
// by the native compositionend event may be incorrect. Japanese ideographic
|
||||
// spaces, for instance (\u3000) are not recorded correctly.
|
||||
var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
|
||||
|
||||
/**
|
||||
* Opera <= 12 includes TextEvent in window, but does not fire
|
||||
* text input events. Rely on keypress instead.
|
||||
*/
|
||||
function isPresto() {
|
||||
var opera = window.opera;
|
||||
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
|
||||
}
|
||||
|
||||
var SPACEBAR_CODE = 32;
|
||||
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
|
||||
// Events and their corresponding property names.
|
||||
var eventTypes = {
|
||||
beforeInput: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({ onBeforeInput: null }),
|
||||
captured: keyOf({ onBeforeInputCapture: null })
|
||||
},
|
||||
dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste]
|
||||
},
|
||||
compositionEnd: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({ onCompositionEnd: null }),
|
||||
captured: keyOf({ onCompositionEndCapture: null })
|
||||
},
|
||||
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
|
||||
},
|
||||
compositionStart: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({ onCompositionStart: null }),
|
||||
captured: keyOf({ onCompositionStartCapture: null })
|
||||
},
|
||||
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
|
||||
},
|
||||
compositionUpdate: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({ onCompositionUpdate: null }),
|
||||
captured: keyOf({ onCompositionUpdateCapture: null })
|
||||
},
|
||||
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
|
||||
}
|
||||
};
|
||||
|
||||
// Track whether we've ever handled a keypress on the space key.
|
||||
var hasSpaceKeypress = false;
|
||||
|
||||
/**
|
||||
* Return whether a native keypress event is assumed to be a command.
|
||||
* This is required because Firefox fires `keypress` events for key commands
|
||||
* (cut, copy, select-all, etc.) even though no character is inserted.
|
||||
*/
|
||||
function isKeypressCommand(nativeEvent) {
|
||||
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
|
||||
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
|
||||
!(nativeEvent.ctrlKey && nativeEvent.altKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate native top level events into event types.
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @return {object}
|
||||
*/
|
||||
function getCompositionEventType(topLevelType) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topCompositionStart:
|
||||
return eventTypes.compositionStart;
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return eventTypes.compositionEnd;
|
||||
case topLevelTypes.topCompositionUpdate:
|
||||
return eventTypes.compositionUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does our fallback best-guess model think this event signifies that
|
||||
* composition has begun?
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @param {object} nativeEvent
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isFallbackCompositionStart(topLevelType, nativeEvent) {
|
||||
return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does our fallback mode think that this event is the end of composition?
|
||||
*
|
||||
* @param {string} topLevelType
|
||||
* @param {object} nativeEvent
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topKeyUp:
|
||||
// Command keys insert or clear IME input.
|
||||
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
|
||||
case topLevelTypes.topKeyDown:
|
||||
// Expect IME keyCode on each keydown. If we get any other
|
||||
// code we must have exited earlier.
|
||||
return nativeEvent.keyCode !== START_KEYCODE;
|
||||
case topLevelTypes.topKeyPress:
|
||||
case topLevelTypes.topMouseDown:
|
||||
case topLevelTypes.topBlur:
|
||||
// Events are not possible without cancelling IME.
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Input Tools provides composition data via a CustomEvent,
|
||||
* with the `data` property populated in the `detail` object. If this
|
||||
* is available on the event object, use it. If not, this is a plain
|
||||
* composition event and we have nothing special to extract.
|
||||
*
|
||||
* @param {object} nativeEvent
|
||||
* @return {?string}
|
||||
*/
|
||||
function getDataFromCustomEvent(nativeEvent) {
|
||||
var detail = nativeEvent.detail;
|
||||
if (typeof detail === 'object' && 'data' in detail) {
|
||||
return detail.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Track the current IME composition fallback object, if any.
|
||||
var currentComposition = null;
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?object} A SyntheticCompositionEvent.
|
||||
*/
|
||||
function extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
var eventType;
|
||||
var fallbackData;
|
||||
|
||||
if (canUseCompositionEvent) {
|
||||
eventType = getCompositionEventType(topLevelType);
|
||||
} else if (!currentComposition) {
|
||||
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
|
||||
eventType = eventTypes.compositionStart;
|
||||
}
|
||||
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
|
||||
eventType = eventTypes.compositionEnd;
|
||||
}
|
||||
|
||||
if (!eventType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useFallbackCompositionData) {
|
||||
// The current composition is stored statically and must not be
|
||||
// overwritten while composition continues.
|
||||
if (!currentComposition && eventType === eventTypes.compositionStart) {
|
||||
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
|
||||
} else if (eventType === eventTypes.compositionEnd) {
|
||||
if (currentComposition) {
|
||||
fallbackData = currentComposition.getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var event = SyntheticCompositionEvent.getPooled(eventType, topLevelTargetID, nativeEvent, nativeEventTarget);
|
||||
|
||||
if (fallbackData) {
|
||||
// Inject data generated from fallback path into the synthetic event.
|
||||
// This matches the property of native CompositionEventInterface.
|
||||
event.data = fallbackData;
|
||||
} else {
|
||||
var customData = getDataFromCustomEvent(nativeEvent);
|
||||
if (customData !== null) {
|
||||
event.data = customData;
|
||||
}
|
||||
}
|
||||
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?string} The string corresponding to this `beforeInput` event.
|
||||
*/
|
||||
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return getDataFromCustomEvent(nativeEvent);
|
||||
case topLevelTypes.topKeyPress:
|
||||
/**
|
||||
* If native `textInput` events are available, our goal is to make
|
||||
* use of them. However, there is a special case: the spacebar key.
|
||||
* In Webkit, preventing default on a spacebar `textInput` event
|
||||
* cancels character insertion, but it *also* causes the browser
|
||||
* to fall back to its default spacebar behavior of scrolling the
|
||||
* page.
|
||||
*
|
||||
* Tracking at:
|
||||
* https://code.google.com/p/chromium/issues/detail?id=355103
|
||||
*
|
||||
* To avoid this issue, use the keypress event as if no `textInput`
|
||||
* event is available.
|
||||
*/
|
||||
var which = nativeEvent.which;
|
||||
if (which !== SPACEBAR_CODE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
hasSpaceKeypress = true;
|
||||
return SPACEBAR_CHAR;
|
||||
|
||||
case topLevelTypes.topTextInput:
|
||||
// Record the characters to be added to the DOM.
|
||||
var chars = nativeEvent.data;
|
||||
|
||||
// If it's a spacebar character, assume that we have already handled
|
||||
// it at the keypress level and bail immediately. Android Chrome
|
||||
// doesn't give us keycodes, so we need to blacklist it.
|
||||
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return chars;
|
||||
|
||||
default:
|
||||
// For other native event types, do nothing.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For browsers that do not provide the `textInput` event, extract the
|
||||
* appropriate string to use for SyntheticInputEvent.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?string} The fallback string for this `beforeInput` event.
|
||||
*/
|
||||
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
|
||||
// If we are currently composing (IME) and using a fallback to do so,
|
||||
// try to extract the composed characters from the fallback object.
|
||||
if (currentComposition) {
|
||||
if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) {
|
||||
var chars = currentComposition.getData();
|
||||
FallbackCompositionState.release(currentComposition);
|
||||
currentComposition = null;
|
||||
return chars;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (topLevelType) {
|
||||
case topLevelTypes.topPaste:
|
||||
// If a paste event occurs after a keypress, throw out the input
|
||||
// chars. Paste events should not lead to BeforeInput events.
|
||||
return null;
|
||||
case topLevelTypes.topKeyPress:
|
||||
/**
|
||||
* As of v27, Firefox may fire keypress events even when no character
|
||||
* will be inserted. A few possibilities:
|
||||
*
|
||||
* - `which` is `0`. Arrow keys, Esc key, etc.
|
||||
*
|
||||
* - `which` is the pressed key code, but no char is available.
|
||||
* Ex: 'AltGr + d` in Polish. There is no modified character for
|
||||
* this key combination and no character is inserted into the
|
||||
* document, but FF fires the keypress for char code `100` anyway.
|
||||
* No `input` event will occur.
|
||||
*
|
||||
* - `which` is the pressed key code, but a command combination is
|
||||
* being used. Ex: `Cmd+C`. No character is inserted, and no
|
||||
* `input` event will occur.
|
||||
*/
|
||||
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
|
||||
return String.fromCharCode(nativeEvent.which);
|
||||
}
|
||||
return null;
|
||||
case topLevelTypes.topCompositionEnd:
|
||||
return useFallbackCompositionData ? null : nativeEvent.data;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
|
||||
* `textInput` or fallback behavior.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {?object} A SyntheticInputEvent.
|
||||
*/
|
||||
function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
var chars;
|
||||
|
||||
if (canUseTextInputEvent) {
|
||||
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
|
||||
} else {
|
||||
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
|
||||
}
|
||||
|
||||
// If no characters are being inserted, no BeforeInput event should
|
||||
// be fired.
|
||||
if (!chars) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget);
|
||||
|
||||
event.data = chars;
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an `onBeforeInput` event to match
|
||||
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
|
||||
*
|
||||
* This event plugin is based on the native `textInput` event
|
||||
* available in Chrome, Safari, Opera, and IE. This event fires after
|
||||
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
|
||||
*
|
||||
* `beforeInput` is spec'd but not implemented in any browsers, and
|
||||
* the `input` event does not provide any useful information about what has
|
||||
* actually been added, contrary to the spec. Thus, `textInput` is the best
|
||||
* available event to identify the characters that have actually been inserted
|
||||
* into the target node.
|
||||
*
|
||||
* This plugin is also responsible for emitting `composition` events, thus
|
||||
* allowing us to share composition fallback code for both `beforeInput` and
|
||||
* `composition` event types.
|
||||
*/
|
||||
var BeforeInputEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
return [extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget)];
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = BeforeInputEventPlugin;
|
||||
139
old_major_packages/14/react/lib/CSSProperty.js
Normal file
139
old_major_packages/14/react/lib/CSSProperty.js
Normal file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 CSSProperty
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* CSS properties which accept numbers but are not in units of "px".
|
||||
*/
|
||||
var isUnitlessNumber = {
|
||||
animationIterationCount: true,
|
||||
boxFlex: true,
|
||||
boxFlexGroup: true,
|
||||
boxOrdinalGroup: true,
|
||||
columnCount: true,
|
||||
flex: true,
|
||||
flexGrow: true,
|
||||
flexPositive: true,
|
||||
flexShrink: true,
|
||||
flexNegative: true,
|
||||
flexOrder: true,
|
||||
fontWeight: true,
|
||||
lineClamp: true,
|
||||
lineHeight: true,
|
||||
opacity: true,
|
||||
order: true,
|
||||
orphans: true,
|
||||
tabSize: true,
|
||||
widows: true,
|
||||
zIndex: true,
|
||||
zoom: true,
|
||||
|
||||
// SVG-related properties
|
||||
fillOpacity: true,
|
||||
stopOpacity: true,
|
||||
strokeDashoffset: true,
|
||||
strokeOpacity: true,
|
||||
strokeWidth: true
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
||||
* @param {string} key style name, eg: transitionDuration
|
||||
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
||||
* WebkitTransitionDuration
|
||||
*/
|
||||
function prefixKey(prefix, key) {
|
||||
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Support style names that may come passed in prefixed by adding permutations
|
||||
* of vendor prefixes.
|
||||
*/
|
||||
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
||||
|
||||
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
||||
// infinite loop, because it iterates over the newly added props too.
|
||||
Object.keys(isUnitlessNumber).forEach(function (prop) {
|
||||
prefixes.forEach(function (prefix) {
|
||||
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
||||
* doesn't like doing that with shorthand properties so for the properties that
|
||||
* IE8 breaks on, which are listed here, we instead unset each of the
|
||||
* individual properties. See http://bugs.jquery.com/ticket/12385.
|
||||
* The 4-value 'clock' properties like margin, padding, border-width seem to
|
||||
* behave without any problems. Curiously, list-style works too without any
|
||||
* special prodding.
|
||||
*/
|
||||
var shorthandPropertyExpansions = {
|
||||
background: {
|
||||
backgroundAttachment: true,
|
||||
backgroundColor: true,
|
||||
backgroundImage: true,
|
||||
backgroundPositionX: true,
|
||||
backgroundPositionY: true,
|
||||
backgroundRepeat: true
|
||||
},
|
||||
backgroundPosition: {
|
||||
backgroundPositionX: true,
|
||||
backgroundPositionY: true
|
||||
},
|
||||
border: {
|
||||
borderWidth: true,
|
||||
borderStyle: true,
|
||||
borderColor: true
|
||||
},
|
||||
borderBottom: {
|
||||
borderBottomWidth: true,
|
||||
borderBottomStyle: true,
|
||||
borderBottomColor: true
|
||||
},
|
||||
borderLeft: {
|
||||
borderLeftWidth: true,
|
||||
borderLeftStyle: true,
|
||||
borderLeftColor: true
|
||||
},
|
||||
borderRight: {
|
||||
borderRightWidth: true,
|
||||
borderRightStyle: true,
|
||||
borderRightColor: true
|
||||
},
|
||||
borderTop: {
|
||||
borderTopWidth: true,
|
||||
borderTopStyle: true,
|
||||
borderTopColor: true
|
||||
},
|
||||
font: {
|
||||
fontStyle: true,
|
||||
fontVariant: true,
|
||||
fontWeight: true,
|
||||
fontSize: true,
|
||||
lineHeight: true,
|
||||
fontFamily: true
|
||||
},
|
||||
outline: {
|
||||
outlineWidth: true,
|
||||
outlineStyle: true,
|
||||
outlineColor: true
|
||||
}
|
||||
};
|
||||
|
||||
var CSSProperty = {
|
||||
isUnitlessNumber: isUnitlessNumber,
|
||||
shorthandPropertyExpansions: shorthandPropertyExpansions
|
||||
};
|
||||
|
||||
module.exports = CSSProperty;
|
||||
175
old_major_packages/14/react/lib/CSSPropertyOperations.js
Normal file
175
old_major_packages/14/react/lib/CSSPropertyOperations.js
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 CSSPropertyOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var CSSProperty = require('./CSSProperty');
|
||||
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
var ReactPerf = require('./ReactPerf');
|
||||
|
||||
var camelizeStyleName = require('fbjs/lib/camelizeStyleName');
|
||||
var dangerousStyleValue = require('./dangerousStyleValue');
|
||||
var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');
|
||||
var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var processStyleName = memoizeStringOnly(function (styleName) {
|
||||
return hyphenateStyleName(styleName);
|
||||
});
|
||||
|
||||
var hasShorthandPropertyBug = false;
|
||||
var styleFloatAccessor = 'cssFloat';
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
var tempStyle = document.createElement('div').style;
|
||||
try {
|
||||
// IE8 throws "Invalid argument." if resetting shorthand style properties.
|
||||
tempStyle.font = '';
|
||||
} catch (e) {
|
||||
hasShorthandPropertyBug = true;
|
||||
}
|
||||
// IE8 only supports accessing cssFloat (standard) as styleFloat
|
||||
if (document.documentElement.style.cssFloat === undefined) {
|
||||
styleFloatAccessor = 'styleFloat';
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// 'msTransform' is correct, but the other prefixes should be capitalized
|
||||
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
||||
|
||||
// style values shouldn't contain a semicolon
|
||||
var badStyleValueWithSemicolonPattern = /;\s*$/;
|
||||
|
||||
var warnedStyleNames = {};
|
||||
var warnedStyleValues = {};
|
||||
|
||||
var warnHyphenatedStyleName = function (name) {
|
||||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleNames[name] = true;
|
||||
process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported style property %s. Did you mean %s?', name, camelizeStyleName(name)) : undefined;
|
||||
};
|
||||
|
||||
var warnBadVendoredStyleName = function (name) {
|
||||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleNames[name] = true;
|
||||
process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)) : undefined;
|
||||
};
|
||||
|
||||
var warnStyleValueWithSemicolon = function (name, value) {
|
||||
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedStyleValues[value] = true;
|
||||
process.env.NODE_ENV !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon. ' + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')) : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
*/
|
||||
var warnValidStyle = function (name, value) {
|
||||
if (name.indexOf('-') > -1) {
|
||||
warnHyphenatedStyleName(name);
|
||||
} else if (badVendoredStyleNamePattern.test(name)) {
|
||||
warnBadVendoredStyleName(name);
|
||||
} else if (badStyleValueWithSemicolonPattern.test(value)) {
|
||||
warnStyleValueWithSemicolon(name, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for dealing with CSS properties.
|
||||
*/
|
||||
var CSSPropertyOperations = {
|
||||
|
||||
/**
|
||||
* Serializes a mapping of style properties for use as inline styles:
|
||||
*
|
||||
* > createMarkupForStyles({width: '200px', height: 0})
|
||||
* "width:200px;height:0;"
|
||||
*
|
||||
* Undefined values are ignored so that declarative programming is easier.
|
||||
* The result should be HTML-escaped before insertion into the DOM.
|
||||
*
|
||||
* @param {object} styles
|
||||
* @return {?string}
|
||||
*/
|
||||
createMarkupForStyles: function (styles) {
|
||||
var serialized = '';
|
||||
for (var styleName in styles) {
|
||||
if (!styles.hasOwnProperty(styleName)) {
|
||||
continue;
|
||||
}
|
||||
var styleValue = styles[styleName];
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warnValidStyle(styleName, styleValue);
|
||||
}
|
||||
if (styleValue != null) {
|
||||
serialized += processStyleName(styleName) + ':';
|
||||
serialized += dangerousStyleValue(styleName, styleValue) + ';';
|
||||
}
|
||||
}
|
||||
return serialized || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the value for multiple styles on a node. If a value is specified as
|
||||
* '' (empty string), the corresponding style property will be unset.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {object} styles
|
||||
*/
|
||||
setValueForStyles: function (node, styles) {
|
||||
var style = node.style;
|
||||
for (var styleName in styles) {
|
||||
if (!styles.hasOwnProperty(styleName)) {
|
||||
continue;
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warnValidStyle(styleName, styles[styleName]);
|
||||
}
|
||||
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
|
||||
if (styleName === 'float') {
|
||||
styleName = styleFloatAccessor;
|
||||
}
|
||||
if (styleValue) {
|
||||
style[styleName] = styleValue;
|
||||
} else {
|
||||
var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName];
|
||||
if (expansion) {
|
||||
// Shorthand property that IE8 won't like unsetting, so unset each
|
||||
// component to placate it
|
||||
for (var individualStyleName in expansion) {
|
||||
style[individualStyleName] = '';
|
||||
}
|
||||
} else {
|
||||
style[styleName] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ReactPerf.measureMethods(CSSPropertyOperations, 'CSSPropertyOperations', {
|
||||
setValueForStyles: 'setValueForStyles'
|
||||
});
|
||||
|
||||
module.exports = CSSPropertyOperations;
|
||||
93
old_major_packages/14/react/lib/CallbackQueue.js
Normal file
93
old_major_packages/14/react/lib/CallbackQueue.js
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 CallbackQueue
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var PooledClass = require('./PooledClass');
|
||||
|
||||
var assign = require('./Object.assign');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
/**
|
||||
* A specialized pseudo-event module to help keep track of components waiting to
|
||||
* be notified when their DOM representations are available for use.
|
||||
*
|
||||
* This implements `PooledClass`, so you should never need to instantiate this.
|
||||
* Instead, use `CallbackQueue.getPooled()`.
|
||||
*
|
||||
* @class ReactMountReady
|
||||
* @implements PooledClass
|
||||
* @internal
|
||||
*/
|
||||
function CallbackQueue() {
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
}
|
||||
|
||||
assign(CallbackQueue.prototype, {
|
||||
|
||||
/**
|
||||
* Enqueues a callback to be invoked when `notifyAll` is invoked.
|
||||
*
|
||||
* @param {function} callback Invoked when `notifyAll` is invoked.
|
||||
* @param {?object} context Context to call `callback` with.
|
||||
* @internal
|
||||
*/
|
||||
enqueue: function (callback, context) {
|
||||
this._callbacks = this._callbacks || [];
|
||||
this._contexts = this._contexts || [];
|
||||
this._callbacks.push(callback);
|
||||
this._contexts.push(context);
|
||||
},
|
||||
|
||||
/**
|
||||
* Invokes all enqueued callbacks and clears the queue. This is invoked after
|
||||
* the DOM representation of a component has been created or updated.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
notifyAll: function () {
|
||||
var callbacks = this._callbacks;
|
||||
var contexts = this._contexts;
|
||||
if (callbacks) {
|
||||
!(callbacks.length === contexts.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Mismatched list of contexts in callback queue') : invariant(false) : undefined;
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
callbacks[i].call(contexts[i]);
|
||||
}
|
||||
callbacks.length = 0;
|
||||
contexts.length = 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the internal queue.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
reset: function () {
|
||||
this._callbacks = null;
|
||||
this._contexts = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* `PooledClass` looks for this.
|
||||
*/
|
||||
destructor: function () {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
PooledClass.addPoolingTo(CallbackQueue);
|
||||
|
||||
module.exports = CallbackQueue;
|
||||
321
old_major_packages/14/react/lib/ChangeEventPlugin.js
Normal file
321
old_major_packages/14/react/lib/ChangeEventPlugin.js
Normal file
@@ -0,0 +1,321 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 ChangeEventPlugin
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require('./EventConstants');
|
||||
var EventPluginHub = require('./EventPluginHub');
|
||||
var EventPropagators = require('./EventPropagators');
|
||||
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
var ReactUpdates = require('./ReactUpdates');
|
||||
var SyntheticEvent = require('./SyntheticEvent');
|
||||
|
||||
var getEventTarget = require('./getEventTarget');
|
||||
var isEventSupported = require('./isEventSupported');
|
||||
var isTextInputElement = require('./isTextInputElement');
|
||||
var keyOf = require('fbjs/lib/keyOf');
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
|
||||
var eventTypes = {
|
||||
change: {
|
||||
phasedRegistrationNames: {
|
||||
bubbled: keyOf({ onChange: null }),
|
||||
captured: keyOf({ onChangeCapture: null })
|
||||
},
|
||||
dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* For IE shims
|
||||
*/
|
||||
var activeElement = null;
|
||||
var activeElementID = null;
|
||||
var activeElementValue = null;
|
||||
var activeElementValueProp = null;
|
||||
|
||||
/**
|
||||
* SECTION: handle `change` event
|
||||
*/
|
||||
function shouldUseChangeEvent(elem) {
|
||||
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
|
||||
return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
|
||||
}
|
||||
|
||||
var doesChangeEventBubble = false;
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
// See `handleChange` comment below
|
||||
doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
|
||||
}
|
||||
|
||||
function manualDispatchChangeEvent(nativeEvent) {
|
||||
var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent, getEventTarget(nativeEvent));
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
|
||||
// If change and propertychange bubbled, we'd just bind to it like all the
|
||||
// other events and have it go through ReactBrowserEventEmitter. Since it
|
||||
// doesn't, we manually listen for the events and so we have to enqueue and
|
||||
// process the abstract event manually.
|
||||
//
|
||||
// Batching is necessary here in order to ensure that all event handlers run
|
||||
// before the next rerender (including event handlers attached to ancestor
|
||||
// elements instead of directly on the input). Without this, controlled
|
||||
// components don't work properly in conjunction with event bubbling because
|
||||
// the component is rerendered and the value reverted before all the event
|
||||
// handlers can run. See https://github.com/facebook/react/issues/708.
|
||||
ReactUpdates.batchedUpdates(runEventInBatch, event);
|
||||
}
|
||||
|
||||
function runEventInBatch(event) {
|
||||
EventPluginHub.enqueueEvents(event);
|
||||
EventPluginHub.processEventQueue(false);
|
||||
}
|
||||
|
||||
function startWatchingForChangeEventIE8(target, targetID) {
|
||||
activeElement = target;
|
||||
activeElementID = targetID;
|
||||
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
|
||||
}
|
||||
|
||||
function stopWatchingForChangeEventIE8() {
|
||||
if (!activeElement) {
|
||||
return;
|
||||
}
|
||||
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
|
||||
activeElement = null;
|
||||
activeElementID = null;
|
||||
}
|
||||
|
||||
function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topChange) {
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topFocus) {
|
||||
// stopWatching() should be a noop here but we call it just in case we
|
||||
// missed a blur event somehow.
|
||||
stopWatchingForChangeEventIE8();
|
||||
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
|
||||
} else if (topLevelType === topLevelTypes.topBlur) {
|
||||
stopWatchingForChangeEventIE8();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SECTION: handle `input` event
|
||||
*/
|
||||
var isInputEventSupported = false;
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
// IE9 claims to support the input event but fails to trigger it when
|
||||
// deleting text, so we ignore its input events
|
||||
isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
||||
* set on the active element.
|
||||
*/
|
||||
var newValueProp = {
|
||||
get: function () {
|
||||
return activeElementValueProp.get.call(this);
|
||||
},
|
||||
set: function (val) {
|
||||
// Cast to a string so we can do equality checks.
|
||||
activeElementValue = '' + val;
|
||||
activeElementValueProp.set.call(this, val);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* (For old IE.) Starts tracking propertychange events on the passed-in element
|
||||
* and override the value property so that we can distinguish user events from
|
||||
* value changes in JS.
|
||||
*/
|
||||
function startWatchingForValueChange(target, targetID) {
|
||||
activeElement = target;
|
||||
activeElementID = targetID;
|
||||
activeElementValue = target.value;
|
||||
activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
|
||||
|
||||
// Not guarded in a canDefineProperty check: IE8 supports defineProperty only
|
||||
// on DOM elements
|
||||
Object.defineProperty(activeElement, 'value', newValueProp);
|
||||
activeElement.attachEvent('onpropertychange', handlePropertyChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Removes the event listeners from the currently-tracked element,
|
||||
* if any exists.
|
||||
*/
|
||||
function stopWatchingForValueChange() {
|
||||
if (!activeElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// delete restores the original property definition
|
||||
delete activeElement.value;
|
||||
activeElement.detachEvent('onpropertychange', handlePropertyChange);
|
||||
|
||||
activeElement = null;
|
||||
activeElementID = null;
|
||||
activeElementValue = null;
|
||||
activeElementValueProp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* (For old IE.) Handles a propertychange event, sending a `change` event if
|
||||
* the value of the active element has changed.
|
||||
*/
|
||||
function handlePropertyChange(nativeEvent) {
|
||||
if (nativeEvent.propertyName !== 'value') {
|
||||
return;
|
||||
}
|
||||
var value = nativeEvent.srcElement.value;
|
||||
if (value === activeElementValue) {
|
||||
return;
|
||||
}
|
||||
activeElementValue = value;
|
||||
|
||||
manualDispatchChangeEvent(nativeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a `change` event should be fired, returns the target's ID.
|
||||
*/
|
||||
function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topInput) {
|
||||
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
|
||||
// what we want so fall through here and trigger an abstract event
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
|
||||
// For IE8 and IE9.
|
||||
function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topFocus) {
|
||||
// In IE8, we can capture almost all .value changes by adding a
|
||||
// propertychange handler and looking for events with propertyName
|
||||
// equal to 'value'
|
||||
// In IE9, propertychange fires for most input events but is buggy and
|
||||
// doesn't fire when text is deleted, but conveniently, selectionchange
|
||||
// appears to fire in all of the remaining cases so we catch those and
|
||||
// forward the event if the value has changed
|
||||
// In either case, we don't want to call the event handler if the value
|
||||
// is changed from JS so we redefine a setter for `.value` that updates
|
||||
// our activeElementValue variable, allowing us to ignore those changes
|
||||
//
|
||||
// stopWatching() should be a noop here but we call it just in case we
|
||||
// missed a blur event somehow.
|
||||
stopWatchingForValueChange();
|
||||
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
|
||||
} else if (topLevelType === topLevelTypes.topBlur) {
|
||||
stopWatchingForValueChange();
|
||||
}
|
||||
}
|
||||
|
||||
// For IE8 and IE9.
|
||||
function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
|
||||
// On the selectionchange event, the target is just document which isn't
|
||||
// helpful for us so just check activeElement instead.
|
||||
//
|
||||
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
|
||||
// propertychange on the first input event after setting `value` from a
|
||||
// script and fires only keydown, keypress, keyup. Catching keyup usually
|
||||
// gets it and catching keydown lets us fire an event for the first
|
||||
// keystroke if user does a key repeat (it'll be a little delayed: right
|
||||
// before the second keystroke). Other input methods (e.g., paste) seem to
|
||||
// fire selectionchange normally.
|
||||
if (activeElement && activeElement.value !== activeElementValue) {
|
||||
activeElementValue = activeElement.value;
|
||||
return activeElementID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SECTION: handle `click` event
|
||||
*/
|
||||
function shouldUseClickEvent(elem) {
|
||||
// Use the `click` event to detect changes to checkbox and radio inputs.
|
||||
// This approach works across all browsers, whereas `change` does not fire
|
||||
// until `blur` in IE8.
|
||||
return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
|
||||
}
|
||||
|
||||
function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
||||
if (topLevelType === topLevelTypes.topClick) {
|
||||
return topLevelTargetID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This plugin creates an `onChange` event that normalizes change events
|
||||
* across form elements. This event fires at a time when it's possible to
|
||||
* change the element's value without seeing a flicker.
|
||||
*
|
||||
* Supported elements are:
|
||||
* - input (see `isTextInputElement`)
|
||||
* - textarea
|
||||
* - select
|
||||
*/
|
||||
var ChangeEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
|
||||
var getTargetIDFunc, handleEventFunc;
|
||||
if (shouldUseChangeEvent(topLevelTarget)) {
|
||||
if (doesChangeEventBubble) {
|
||||
getTargetIDFunc = getTargetIDForChangeEvent;
|
||||
} else {
|
||||
handleEventFunc = handleEventsForChangeEventIE8;
|
||||
}
|
||||
} else if (isTextInputElement(topLevelTarget)) {
|
||||
if (isInputEventSupported) {
|
||||
getTargetIDFunc = getTargetIDForInputEvent;
|
||||
} else {
|
||||
getTargetIDFunc = getTargetIDForInputEventIE;
|
||||
handleEventFunc = handleEventsForInputEventIE;
|
||||
}
|
||||
} else if (shouldUseClickEvent(topLevelTarget)) {
|
||||
getTargetIDFunc = getTargetIDForClickEvent;
|
||||
}
|
||||
|
||||
if (getTargetIDFunc) {
|
||||
var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID);
|
||||
if (targetID) {
|
||||
var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent, nativeEventTarget);
|
||||
event.type = 'change';
|
||||
EventPropagators.accumulateTwoPhaseDispatches(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
if (handleEventFunc) {
|
||||
handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ChangeEventPlugin;
|
||||
23
old_major_packages/14/react/lib/ClientReactRootIndex.js
Normal file
23
old_major_packages/14/react/lib/ClientReactRootIndex.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 ClientReactRootIndex
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var nextReactRootIndex = 0;
|
||||
|
||||
var ClientReactRootIndex = {
|
||||
createReactRootIndex: function () {
|
||||
return nextReactRootIndex++;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ClientReactRootIndex;
|
||||
129
old_major_packages/14/react/lib/DOMChildrenOperations.js
Normal file
129
old_major_packages/14/react/lib/DOMChildrenOperations.js
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 DOMChildrenOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Danger = require('./Danger');
|
||||
var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
|
||||
var ReactPerf = require('./ReactPerf');
|
||||
|
||||
var setInnerHTML = require('./setInnerHTML');
|
||||
var setTextContent = require('./setTextContent');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
/**
|
||||
* Inserts `childNode` as a child of `parentNode` at the `index`.
|
||||
*
|
||||
* @param {DOMElement} parentNode Parent node in which to insert.
|
||||
* @param {DOMElement} childNode Child node to insert.
|
||||
* @param {number} index Index at which to insert the child.
|
||||
* @internal
|
||||
*/
|
||||
function insertChildAt(parentNode, childNode, index) {
|
||||
// By exploiting arrays returning `undefined` for an undefined index, we can
|
||||
// rely exclusively on `insertBefore(node, null)` instead of also using
|
||||
// `appendChild(node)`. However, using `undefined` is not allowed by all
|
||||
// browsers so we must replace it with `null`.
|
||||
|
||||
// fix render order error in safari
|
||||
// IE8 will throw error when index out of list size.
|
||||
var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
|
||||
|
||||
parentNode.insertBefore(childNode, beforeChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for updating with DOM children.
|
||||
*/
|
||||
var DOMChildrenOperations = {
|
||||
|
||||
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
||||
|
||||
updateTextContent: setTextContent,
|
||||
|
||||
/**
|
||||
* Updates a component's children by processing a series of updates. The
|
||||
* update configurations are each expected to have a `parentNode` property.
|
||||
*
|
||||
* @param {array<object>} updates List of update configurations.
|
||||
* @param {array<string>} markupList List of markup strings.
|
||||
* @internal
|
||||
*/
|
||||
processUpdates: function (updates, markupList) {
|
||||
var update;
|
||||
// Mapping from parent IDs to initial child orderings.
|
||||
var initialChildren = null;
|
||||
// List of children that will be moved or removed.
|
||||
var updatedChildren = null;
|
||||
|
||||
for (var i = 0; i < updates.length; i++) {
|
||||
update = updates[i];
|
||||
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
||||
var updatedIndex = update.fromIndex;
|
||||
var updatedChild = update.parentNode.childNodes[updatedIndex];
|
||||
var parentID = update.parentID;
|
||||
|
||||
!updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined;
|
||||
|
||||
initialChildren = initialChildren || {};
|
||||
initialChildren[parentID] = initialChildren[parentID] || [];
|
||||
initialChildren[parentID][updatedIndex] = updatedChild;
|
||||
|
||||
updatedChildren = updatedChildren || [];
|
||||
updatedChildren.push(updatedChild);
|
||||
}
|
||||
}
|
||||
|
||||
var renderedMarkup;
|
||||
// markupList is either a list of markup or just a list of elements
|
||||
if (markupList.length && typeof markupList[0] === 'string') {
|
||||
renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
|
||||
} else {
|
||||
renderedMarkup = markupList;
|
||||
}
|
||||
|
||||
// Remove updated children first so that `toIndex` is consistent.
|
||||
if (updatedChildren) {
|
||||
for (var j = 0; j < updatedChildren.length; j++) {
|
||||
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var k = 0; k < updates.length; k++) {
|
||||
update = updates[k];
|
||||
switch (update.type) {
|
||||
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
||||
insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
||||
insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.SET_MARKUP:
|
||||
setInnerHTML(update.parentNode, update.content);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
||||
setTextContent(update.parentNode, update.content);
|
||||
break;
|
||||
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
||||
// Already removed by the for-loop above.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', {
|
||||
updateTextContent: 'updateTextContent'
|
||||
});
|
||||
|
||||
module.exports = DOMChildrenOperations;
|
||||
234
old_major_packages/14/react/lib/DOMProperty.js
Normal file
234
old_major_packages/14/react/lib/DOMProperty.js
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 DOMProperty
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
function checkMask(value, bitmask) {
|
||||
return (value & bitmask) === bitmask;
|
||||
}
|
||||
|
||||
var DOMPropertyInjection = {
|
||||
/**
|
||||
* Mapping from normalized, camelcased property names to a configuration that
|
||||
* specifies how the associated DOM property should be accessed or rendered.
|
||||
*/
|
||||
MUST_USE_ATTRIBUTE: 0x1,
|
||||
MUST_USE_PROPERTY: 0x2,
|
||||
HAS_SIDE_EFFECTS: 0x4,
|
||||
HAS_BOOLEAN_VALUE: 0x8,
|
||||
HAS_NUMERIC_VALUE: 0x10,
|
||||
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
|
||||
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
|
||||
|
||||
/**
|
||||
* Inject some specialized knowledge about the DOM. This takes a config object
|
||||
* with the following properties:
|
||||
*
|
||||
* isCustomAttribute: function that given an attribute name will return true
|
||||
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
|
||||
* attributes where it's impossible to enumerate all of the possible
|
||||
* attribute names,
|
||||
*
|
||||
* Properties: object mapping DOM property name to one of the
|
||||
* DOMPropertyInjection constants or null. If your attribute isn't in here,
|
||||
* it won't get written to the DOM.
|
||||
*
|
||||
* DOMAttributeNames: object mapping React attribute name to the DOM
|
||||
* attribute name. Attribute names not specified use the **lowercase**
|
||||
* normalized name.
|
||||
*
|
||||
* DOMAttributeNamespaces: object mapping React attribute name to the DOM
|
||||
* attribute namespace URL. (Attribute names not specified use no namespace.)
|
||||
*
|
||||
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
|
||||
* Property names not specified use the normalized name.
|
||||
*
|
||||
* DOMMutationMethods: Properties that require special mutation methods. If
|
||||
* `value` is undefined, the mutation method should unset the property.
|
||||
*
|
||||
* @param {object} domPropertyConfig the config as described above.
|
||||
*/
|
||||
injectDOMPropertyConfig: function (domPropertyConfig) {
|
||||
var Injection = DOMPropertyInjection;
|
||||
var Properties = domPropertyConfig.Properties || {};
|
||||
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
|
||||
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
|
||||
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
|
||||
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
|
||||
|
||||
if (domPropertyConfig.isCustomAttribute) {
|
||||
DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
|
||||
}
|
||||
|
||||
for (var propName in Properties) {
|
||||
!!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(false) : undefined;
|
||||
|
||||
var lowerCased = propName.toLowerCase();
|
||||
var propConfig = Properties[propName];
|
||||
|
||||
var propertyInfo = {
|
||||
attributeName: lowerCased,
|
||||
attributeNamespace: null,
|
||||
propertyName: propName,
|
||||
mutationMethod: null,
|
||||
|
||||
mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE),
|
||||
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
|
||||
hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
|
||||
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
|
||||
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
|
||||
hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE),
|
||||
hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
|
||||
};
|
||||
|
||||
!(!propertyInfo.mustUseAttribute || !propertyInfo.mustUseProperty) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(false) : undefined;
|
||||
!(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : undefined;
|
||||
!(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
DOMProperty.getPossibleStandardName[lowerCased] = propName;
|
||||
}
|
||||
|
||||
if (DOMAttributeNames.hasOwnProperty(propName)) {
|
||||
var attributeName = DOMAttributeNames[propName];
|
||||
propertyInfo.attributeName = attributeName;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
DOMProperty.getPossibleStandardName[attributeName] = propName;
|
||||
}
|
||||
}
|
||||
|
||||
if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
|
||||
propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
|
||||
}
|
||||
|
||||
if (DOMPropertyNames.hasOwnProperty(propName)) {
|
||||
propertyInfo.propertyName = DOMPropertyNames[propName];
|
||||
}
|
||||
|
||||
if (DOMMutationMethods.hasOwnProperty(propName)) {
|
||||
propertyInfo.mutationMethod = DOMMutationMethods[propName];
|
||||
}
|
||||
|
||||
DOMProperty.properties[propName] = propertyInfo;
|
||||
}
|
||||
}
|
||||
};
|
||||
var defaultValueCache = {};
|
||||
|
||||
/**
|
||||
* DOMProperty exports lookup objects that can be used like functions:
|
||||
*
|
||||
* > DOMProperty.isValid['id']
|
||||
* true
|
||||
* > DOMProperty.isValid['foobar']
|
||||
* undefined
|
||||
*
|
||||
* Although this may be confusing, it performs better in general.
|
||||
*
|
||||
* @see http://jsperf.com/key-exists
|
||||
* @see http://jsperf.com/key-missing
|
||||
*/
|
||||
var DOMProperty = {
|
||||
|
||||
ID_ATTRIBUTE_NAME: 'data-reactid',
|
||||
|
||||
/**
|
||||
* Map from property "standard name" to an object with info about how to set
|
||||
* the property in the DOM. Each object contains:
|
||||
*
|
||||
* attributeName:
|
||||
* Used when rendering markup or with `*Attribute()`.
|
||||
* attributeNamespace
|
||||
* propertyName:
|
||||
* Used on DOM node instances. (This includes properties that mutate due to
|
||||
* external factors.)
|
||||
* mutationMethod:
|
||||
* If non-null, used instead of the property or `setAttribute()` after
|
||||
* initial render.
|
||||
* mustUseAttribute:
|
||||
* Whether the property must be accessed and mutated using `*Attribute()`.
|
||||
* (This includes anything that fails `<propName> in <element>`.)
|
||||
* mustUseProperty:
|
||||
* Whether the property must be accessed and mutated as an object property.
|
||||
* hasSideEffects:
|
||||
* Whether or not setting a value causes side effects such as triggering
|
||||
* resources to be loaded or text selection changes. If true, we read from
|
||||
* the DOM before updating to ensure that the value is only set if it has
|
||||
* changed.
|
||||
* hasBooleanValue:
|
||||
* Whether the property should be removed when set to a falsey value.
|
||||
* hasNumericValue:
|
||||
* Whether the property must be numeric or parse as a numeric and should be
|
||||
* removed when set to a falsey value.
|
||||
* hasPositiveNumericValue:
|
||||
* Whether the property must be positive numeric or parse as a positive
|
||||
* numeric and should be removed when set to a falsey value.
|
||||
* hasOverloadedBooleanValue:
|
||||
* Whether the property can be used as a flag as well as with a value.
|
||||
* Removed when strictly equal to false; present without a value when
|
||||
* strictly equal to true; present with a value otherwise.
|
||||
*/
|
||||
properties: {},
|
||||
|
||||
/**
|
||||
* Mapping from lowercase property names to the properly cased version, used
|
||||
* to warn in the case of missing properties. Available only in __DEV__.
|
||||
* @type {Object}
|
||||
*/
|
||||
getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null,
|
||||
|
||||
/**
|
||||
* All of the isCustomAttribute() functions that have been injected.
|
||||
*/
|
||||
_isCustomAttributeFunctions: [],
|
||||
|
||||
/**
|
||||
* Checks whether a property name is a custom attribute.
|
||||
* @method
|
||||
*/
|
||||
isCustomAttribute: function (attributeName) {
|
||||
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
|
||||
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
|
||||
if (isCustomAttributeFn(attributeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the default property value for a DOM property (i.e., not an
|
||||
* attribute). Most default values are '' or false, but not all. Worse yet,
|
||||
* some (in particular, `type`) vary depending on the type of element.
|
||||
*
|
||||
* TODO: Is it better to grab all the possible properties when creating an
|
||||
* element to avoid having to create the same element twice?
|
||||
*/
|
||||
getDefaultValueForProperty: function (nodeName, prop) {
|
||||
var nodeDefaults = defaultValueCache[nodeName];
|
||||
var testElement;
|
||||
if (!nodeDefaults) {
|
||||
defaultValueCache[nodeName] = nodeDefaults = {};
|
||||
}
|
||||
if (!(prop in nodeDefaults)) {
|
||||
testElement = document.createElement(nodeName);
|
||||
nodeDefaults[prop] = testElement[prop];
|
||||
}
|
||||
return nodeDefaults[prop];
|
||||
},
|
||||
|
||||
injection: DOMPropertyInjection
|
||||
};
|
||||
|
||||
module.exports = DOMProperty;
|
||||
225
old_major_packages/14/react/lib/DOMPropertyOperations.js
Normal file
225
old_major_packages/14/react/lib/DOMPropertyOperations.js
Normal file
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 DOMPropertyOperations
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var DOMProperty = require('./DOMProperty');
|
||||
var ReactPerf = require('./ReactPerf');
|
||||
|
||||
var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
// Simplified subset
|
||||
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
|
||||
var illegalAttributeNameCache = {};
|
||||
var validatedAttributeNameCache = {};
|
||||
|
||||
function isAttributeNameSafe(attributeName) {
|
||||
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
|
||||
return true;
|
||||
}
|
||||
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
|
||||
return false;
|
||||
}
|
||||
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
||||
validatedAttributeNameCache[attributeName] = true;
|
||||
return true;
|
||||
}
|
||||
illegalAttributeNameCache[attributeName] = true;
|
||||
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
function shouldIgnoreValue(propertyInfo, value) {
|
||||
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var reactProps = {
|
||||
children: true,
|
||||
dangerouslySetInnerHTML: true,
|
||||
key: true,
|
||||
ref: true
|
||||
};
|
||||
var warnedProperties = {};
|
||||
|
||||
var warnUnknownProperty = function (name) {
|
||||
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedProperties[name] = true;
|
||||
var lowerCasedName = name.toLowerCase();
|
||||
|
||||
// data-* attributes should be lowercase; suggest the lowercase version
|
||||
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
||||
|
||||
// For now, only warn when we have a suggested correction. This prevents
|
||||
// logging too much when using transferPropsTo.
|
||||
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations for dealing with DOM properties.
|
||||
*/
|
||||
var DOMPropertyOperations = {
|
||||
|
||||
/**
|
||||
* Creates markup for the ID property.
|
||||
*
|
||||
* @param {string} id Unescaped ID.
|
||||
* @return {string} Markup string.
|
||||
*/
|
||||
createMarkupForID: function (id) {
|
||||
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
|
||||
},
|
||||
|
||||
setAttributeForID: function (node, id) {
|
||||
node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates markup for a property.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
* @return {?string} Markup string, or null if the property was invalid.
|
||||
*/
|
||||
createMarkupForProperty: function (name, value) {
|
||||
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
||||
if (propertyInfo) {
|
||||
if (shouldIgnoreValue(propertyInfo, value)) {
|
||||
return '';
|
||||
}
|
||||
var attributeName = propertyInfo.attributeName;
|
||||
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
||||
return attributeName + '=""';
|
||||
}
|
||||
return attributeName + '=' + quoteAttributeValueForBrowser(value);
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
return name + '=' + quoteAttributeValueForBrowser(value);
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates markup for a custom property.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
* @return {string} Markup string, or empty string if the property was invalid.
|
||||
*/
|
||||
createMarkupForCustomAttribute: function (name, value) {
|
||||
if (!isAttributeNameSafe(name) || value == null) {
|
||||
return '';
|
||||
}
|
||||
return name + '=' + quoteAttributeValueForBrowser(value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the value for a property on a node.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
*/
|
||||
setValueForProperty: function (node, name, value) {
|
||||
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
||||
if (propertyInfo) {
|
||||
var mutationMethod = propertyInfo.mutationMethod;
|
||||
if (mutationMethod) {
|
||||
mutationMethod(node, value);
|
||||
} else if (shouldIgnoreValue(propertyInfo, value)) {
|
||||
this.deleteValueForProperty(node, name);
|
||||
} else if (propertyInfo.mustUseAttribute) {
|
||||
var attributeName = propertyInfo.attributeName;
|
||||
var namespace = propertyInfo.attributeNamespace;
|
||||
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
||||
// ('' + value) makes it output the correct toString()-value.
|
||||
if (namespace) {
|
||||
node.setAttributeNS(namespace, attributeName, '' + value);
|
||||
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
||||
node.setAttribute(attributeName, '');
|
||||
} else {
|
||||
node.setAttribute(attributeName, '' + value);
|
||||
}
|
||||
} else {
|
||||
var propName = propertyInfo.propertyName;
|
||||
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
||||
// property type before comparing; only `value` does and is string.
|
||||
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
|
||||
// Contrary to `setAttribute`, object properties are properly
|
||||
// `toString`ed by IE8/9.
|
||||
node[propName] = value;
|
||||
}
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
},
|
||||
|
||||
setValueForAttribute: function (node, name, value) {
|
||||
if (!isAttributeNameSafe(name)) {
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
node.setAttribute(name, '' + value);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes the value for a property on a node.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {string} name
|
||||
*/
|
||||
deleteValueForProperty: function (node, name) {
|
||||
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
||||
if (propertyInfo) {
|
||||
var mutationMethod = propertyInfo.mutationMethod;
|
||||
if (mutationMethod) {
|
||||
mutationMethod(node, undefined);
|
||||
} else if (propertyInfo.mustUseAttribute) {
|
||||
node.removeAttribute(propertyInfo.attributeName);
|
||||
} else {
|
||||
var propName = propertyInfo.propertyName;
|
||||
var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
|
||||
if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) {
|
||||
node[propName] = defaultValue;
|
||||
}
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
node.removeAttribute(name);
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
|
||||
setValueForProperty: 'setValueForProperty',
|
||||
setValueForAttribute: 'setValueForAttribute',
|
||||
deleteValueForProperty: 'deleteValueForProperty'
|
||||
});
|
||||
|
||||
module.exports = DOMPropertyOperations;
|
||||
145
old_major_packages/14/react/lib/Danger.js
Normal file
145
old_major_packages/14/react/lib/Danger.js
Normal file
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 Danger
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
|
||||
var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
||||
var emptyFunction = require('fbjs/lib/emptyFunction');
|
||||
var getMarkupWrap = require('fbjs/lib/getMarkupWrap');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
|
||||
var RESULT_INDEX_ATTR = 'data-danger-index';
|
||||
|
||||
/**
|
||||
* Extracts the `nodeName` from a string of markup.
|
||||
*
|
||||
* NOTE: Extracting the `nodeName` does not require a regular expression match
|
||||
* because we make assumptions about React-generated markup (i.e. there are no
|
||||
* spaces surrounding the opening tag and there is at least one attribute).
|
||||
*
|
||||
* @param {string} markup String of markup.
|
||||
* @return {string} Node name of the supplied markup.
|
||||
* @see http://jsperf.com/extract-nodename
|
||||
*/
|
||||
function getNodeName(markup) {
|
||||
return markup.substring(1, markup.indexOf(' '));
|
||||
}
|
||||
|
||||
var Danger = {
|
||||
|
||||
/**
|
||||
* Renders markup into an array of nodes. The markup is expected to render
|
||||
* into a list of root nodes. Also, the length of `resultList` and
|
||||
* `markupList` should be the same.
|
||||
*
|
||||
* @param {array<string>} markupList List of markup strings to render.
|
||||
* @return {array<DOMElement>} List of rendered nodes.
|
||||
* @internal
|
||||
*/
|
||||
dangerouslyRenderMarkup: function (markupList) {
|
||||
!ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined;
|
||||
var nodeName;
|
||||
var markupByNodeName = {};
|
||||
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
|
||||
for (var i = 0; i < markupList.length; i++) {
|
||||
!markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
|
||||
nodeName = getNodeName(markupList[i]);
|
||||
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
||||
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
||||
markupByNodeName[nodeName][i] = markupList[i];
|
||||
}
|
||||
var resultList = [];
|
||||
var resultListAssignmentCount = 0;
|
||||
for (nodeName in markupByNodeName) {
|
||||
if (!markupByNodeName.hasOwnProperty(nodeName)) {
|
||||
continue;
|
||||
}
|
||||
var markupListByNodeName = markupByNodeName[nodeName];
|
||||
|
||||
// This for-in loop skips the holes of the sparse array. The order of
|
||||
// iteration should follow the order of assignment, which happens to match
|
||||
// numerical index order, but we don't rely on that.
|
||||
var resultIndex;
|
||||
for (resultIndex in markupListByNodeName) {
|
||||
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
|
||||
var markup = markupListByNodeName[resultIndex];
|
||||
|
||||
// Push the requested markup with an additional RESULT_INDEX_ATTR
|
||||
// attribute. If the markup does not start with a < character, it
|
||||
// will be discarded below (with an appropriate console.error).
|
||||
markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP,
|
||||
// This index will be parsed back out below.
|
||||
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" ');
|
||||
}
|
||||
}
|
||||
|
||||
// Render each group of markup with similar wrapping `nodeName`.
|
||||
var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags.
|
||||
);
|
||||
|
||||
for (var j = 0; j < renderNodes.length; ++j) {
|
||||
var renderNode = renderNodes[j];
|
||||
if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
||||
|
||||
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
||||
renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
||||
|
||||
!!resultList.hasOwnProperty(resultIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
|
||||
|
||||
resultList[resultIndex] = renderNode;
|
||||
|
||||
// This should match resultList.length and markupList.length when
|
||||
// we're done.
|
||||
resultListAssignmentCount += 1;
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
console.error('Danger: Discarding unexpected node:', renderNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Although resultList was populated out of order, it should now be a dense
|
||||
// array.
|
||||
!(resultListAssignmentCount === resultList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
|
||||
|
||||
!(resultList.length === markupList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
|
||||
|
||||
return resultList;
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces a node with a string of markup at its current position within its
|
||||
* parent. The markup must render into a single root node.
|
||||
*
|
||||
* @param {DOMElement} oldChild Child node to replace.
|
||||
* @param {string} markup Markup to render in place of the child node.
|
||||
* @internal
|
||||
*/
|
||||
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
||||
!ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
|
||||
!markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
|
||||
!(oldChild.tagName.toLowerCase() !== 'html') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined;
|
||||
|
||||
var newChild;
|
||||
if (typeof markup === 'string') {
|
||||
newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
||||
} else {
|
||||
newChild = markup;
|
||||
}
|
||||
oldChild.parentNode.replaceChild(newChild, oldChild);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = Danger;
|
||||
27
old_major_packages/14/react/lib/DefaultEventPluginOrder.js
Normal file
27
old_major_packages/14/react/lib/DefaultEventPluginOrder.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 DefaultEventPluginOrder
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var keyOf = require('fbjs/lib/keyOf');
|
||||
|
||||
/**
|
||||
* Module that is injectable into `EventPluginHub`, that specifies a
|
||||
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
|
||||
* plugins, without having to package every one of them. This is better than
|
||||
* having plugins be ordered in the same order that they are injected because
|
||||
* that ordering would be influenced by the packaging order.
|
||||
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
|
||||
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
|
||||
*/
|
||||
var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })];
|
||||
|
||||
module.exports = DefaultEventPluginOrder;
|
||||
124
old_major_packages/14/react/lib/EnterLeaveEventPlugin.js
Normal file
124
old_major_packages/14/react/lib/EnterLeaveEventPlugin.js
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EnterLeaveEventPlugin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require('./EventConstants');
|
||||
var EventPropagators = require('./EventPropagators');
|
||||
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
|
||||
|
||||
var ReactMount = require('./ReactMount');
|
||||
var keyOf = require('fbjs/lib/keyOf');
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
||||
|
||||
var eventTypes = {
|
||||
mouseEnter: {
|
||||
registrationName: keyOf({ onMouseEnter: null }),
|
||||
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
|
||||
},
|
||||
mouseLeave: {
|
||||
registrationName: keyOf({ onMouseLeave: null }),
|
||||
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
|
||||
}
|
||||
};
|
||||
|
||||
var extractedEvents = [null, null];
|
||||
|
||||
var EnterLeaveEventPlugin = {
|
||||
|
||||
eventTypes: eventTypes,
|
||||
|
||||
/**
|
||||
* For almost every interaction we care about, there will be both a top-level
|
||||
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
|
||||
* we do not extract duplicate events. However, moving the mouse into the
|
||||
* browser from outside will not fire a `mouseout` event. In this case, we use
|
||||
* the `mouseover` top-level event.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @see {EventPluginHub.extractEvents}
|
||||
*/
|
||||
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
||||
return null;
|
||||
}
|
||||
if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
|
||||
// Must not be a mouse in or mouse out - ignoring.
|
||||
return null;
|
||||
}
|
||||
|
||||
var win;
|
||||
if (topLevelTarget.window === topLevelTarget) {
|
||||
// `topLevelTarget` is probably a window object.
|
||||
win = topLevelTarget;
|
||||
} else {
|
||||
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
||||
var doc = topLevelTarget.ownerDocument;
|
||||
if (doc) {
|
||||
win = doc.defaultView || doc.parentWindow;
|
||||
} else {
|
||||
win = window;
|
||||
}
|
||||
}
|
||||
|
||||
var from;
|
||||
var to;
|
||||
var fromID = '';
|
||||
var toID = '';
|
||||
if (topLevelType === topLevelTypes.topMouseOut) {
|
||||
from = topLevelTarget;
|
||||
fromID = topLevelTargetID;
|
||||
to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement);
|
||||
if (to) {
|
||||
toID = ReactMount.getID(to);
|
||||
} else {
|
||||
to = win;
|
||||
}
|
||||
to = to || win;
|
||||
} else {
|
||||
from = win;
|
||||
to = topLevelTarget;
|
||||
toID = topLevelTargetID;
|
||||
}
|
||||
|
||||
if (from === to) {
|
||||
// Nothing pertains to our managed components.
|
||||
return null;
|
||||
}
|
||||
|
||||
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
|
||||
leave.type = 'mouseleave';
|
||||
leave.target = from;
|
||||
leave.relatedTarget = to;
|
||||
|
||||
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
|
||||
enter.type = 'mouseenter';
|
||||
enter.target = to;
|
||||
enter.relatedTarget = from;
|
||||
|
||||
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
|
||||
|
||||
extractedEvents[0] = leave;
|
||||
extractedEvents[1] = enter;
|
||||
|
||||
return extractedEvents;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = EnterLeaveEventPlugin;
|
||||
92
old_major_packages/14/react/lib/EventConstants.js
Normal file
92
old_major_packages/14/react/lib/EventConstants.js
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EventConstants
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var keyMirror = require('fbjs/lib/keyMirror');
|
||||
|
||||
var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
||||
|
||||
/**
|
||||
* Types of raw signals from the browser caught at the top level.
|
||||
*/
|
||||
var topLevelTypes = keyMirror({
|
||||
topAbort: null,
|
||||
topBlur: null,
|
||||
topCanPlay: null,
|
||||
topCanPlayThrough: null,
|
||||
topChange: null,
|
||||
topClick: null,
|
||||
topCompositionEnd: null,
|
||||
topCompositionStart: null,
|
||||
topCompositionUpdate: null,
|
||||
topContextMenu: null,
|
||||
topCopy: null,
|
||||
topCut: null,
|
||||
topDoubleClick: null,
|
||||
topDrag: null,
|
||||
topDragEnd: null,
|
||||
topDragEnter: null,
|
||||
topDragExit: null,
|
||||
topDragLeave: null,
|
||||
topDragOver: null,
|
||||
topDragStart: null,
|
||||
topDrop: null,
|
||||
topDurationChange: null,
|
||||
topEmptied: null,
|
||||
topEncrypted: null,
|
||||
topEnded: null,
|
||||
topError: null,
|
||||
topFocus: null,
|
||||
topInput: null,
|
||||
topKeyDown: null,
|
||||
topKeyPress: null,
|
||||
topKeyUp: null,
|
||||
topLoad: null,
|
||||
topLoadedData: null,
|
||||
topLoadedMetadata: null,
|
||||
topLoadStart: null,
|
||||
topMouseDown: null,
|
||||
topMouseMove: null,
|
||||
topMouseOut: null,
|
||||
topMouseOver: null,
|
||||
topMouseUp: null,
|
||||
topPaste: null,
|
||||
topPause: null,
|
||||
topPlay: null,
|
||||
topPlaying: null,
|
||||
topProgress: null,
|
||||
topRateChange: null,
|
||||
topReset: null,
|
||||
topScroll: null,
|
||||
topSeeked: null,
|
||||
topSeeking: null,
|
||||
topSelectionChange: null,
|
||||
topStalled: null,
|
||||
topSubmit: null,
|
||||
topSuspend: null,
|
||||
topTextInput: null,
|
||||
topTimeUpdate: null,
|
||||
topTouchCancel: null,
|
||||
topTouchEnd: null,
|
||||
topTouchMove: null,
|
||||
topTouchStart: null,
|
||||
topVolumeChange: null,
|
||||
topWaiting: null,
|
||||
topWheel: null
|
||||
});
|
||||
|
||||
var EventConstants = {
|
||||
topLevelTypes: topLevelTypes,
|
||||
PropagationPhases: PropagationPhases
|
||||
};
|
||||
|
||||
module.exports = EventConstants;
|
||||
279
old_major_packages/14/react/lib/EventPluginHub.js
Normal file
279
old_major_packages/14/react/lib/EventPluginHub.js
Normal file
@@ -0,0 +1,279 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EventPluginHub
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventPluginRegistry = require('./EventPluginRegistry');
|
||||
var EventPluginUtils = require('./EventPluginUtils');
|
||||
var ReactErrorUtils = require('./ReactErrorUtils');
|
||||
|
||||
var accumulateInto = require('./accumulateInto');
|
||||
var forEachAccumulated = require('./forEachAccumulated');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
/**
|
||||
* Internal store for event listeners
|
||||
*/
|
||||
var listenerBank = {};
|
||||
|
||||
/**
|
||||
* Internal queue of events that have accumulated their dispatches and are
|
||||
* waiting to have their dispatches executed.
|
||||
*/
|
||||
var eventQueue = null;
|
||||
|
||||
/**
|
||||
* Dispatches an event and releases it back into the pool, unless persistent.
|
||||
*
|
||||
* @param {?object} event Synthetic event to be dispatched.
|
||||
* @param {boolean} simulated If the event is simulated (changes exn behavior)
|
||||
* @private
|
||||
*/
|
||||
var executeDispatchesAndRelease = function (event, simulated) {
|
||||
if (event) {
|
||||
EventPluginUtils.executeDispatchesInOrder(event, simulated);
|
||||
|
||||
if (!event.isPersistent()) {
|
||||
event.constructor.release(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
var executeDispatchesAndReleaseSimulated = function (e) {
|
||||
return executeDispatchesAndRelease(e, true);
|
||||
};
|
||||
var executeDispatchesAndReleaseTopLevel = function (e) {
|
||||
return executeDispatchesAndRelease(e, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
||||
* hierarchy given ids of the logical DOM elements involved.
|
||||
*/
|
||||
var InstanceHandle = null;
|
||||
|
||||
function validateInstanceHandle() {
|
||||
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
|
||||
process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a unified interface for event plugins to be installed and configured.
|
||||
*
|
||||
* Event plugins can implement the following properties:
|
||||
*
|
||||
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
|
||||
* Required. When a top-level event is fired, this method is expected to
|
||||
* extract synthetic events that will in turn be queued and dispatched.
|
||||
*
|
||||
* `eventTypes` {object}
|
||||
* Optional, plugins that fire events must publish a mapping of registration
|
||||
* names that are used to register listeners. Values of this mapping must
|
||||
* be objects that contain `registrationName` or `phasedRegistrationNames`.
|
||||
*
|
||||
* `executeDispatch` {function(object, function, string)}
|
||||
* Optional, allows plugins to override how an event gets dispatched. By
|
||||
* default, the listener is simply invoked.
|
||||
*
|
||||
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
var EventPluginHub = {
|
||||
|
||||
/**
|
||||
* Methods for injecting dependencies.
|
||||
*/
|
||||
injection: {
|
||||
|
||||
/**
|
||||
* @param {object} InjectedMount
|
||||
* @public
|
||||
*/
|
||||
injectMount: EventPluginUtils.injection.injectMount,
|
||||
|
||||
/**
|
||||
* @param {object} InjectedInstanceHandle
|
||||
* @public
|
||||
*/
|
||||
injectInstanceHandle: function (InjectedInstanceHandle) {
|
||||
InstanceHandle = InjectedInstanceHandle;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateInstanceHandle();
|
||||
}
|
||||
},
|
||||
|
||||
getInstanceHandle: function () {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateInstanceHandle();
|
||||
}
|
||||
return InstanceHandle;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {array} InjectedEventPluginOrder
|
||||
* @public
|
||||
*/
|
||||
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
|
||||
|
||||
/**
|
||||
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
|
||||
*/
|
||||
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
|
||||
|
||||
},
|
||||
|
||||
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
||||
|
||||
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
||||
|
||||
/**
|
||||
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
* @param {?function} listener The callback to store.
|
||||
*/
|
||||
putListener: function (id, registrationName, listener) {
|
||||
!(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
|
||||
|
||||
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
||||
bankForRegistrationName[id] = listener;
|
||||
|
||||
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
||||
if (PluginModule && PluginModule.didPutListener) {
|
||||
PluginModule.didPutListener(id, registrationName, listener);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
* @return {?function} The stored callback.
|
||||
*/
|
||||
getListener: function (id, registrationName) {
|
||||
var bankForRegistrationName = listenerBank[registrationName];
|
||||
return bankForRegistrationName && bankForRegistrationName[id];
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a listener from the registration bank.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
||||
*/
|
||||
deleteListener: function (id, registrationName) {
|
||||
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
||||
if (PluginModule && PluginModule.willDeleteListener) {
|
||||
PluginModule.willDeleteListener(id, registrationName);
|
||||
}
|
||||
|
||||
var bankForRegistrationName = listenerBank[registrationName];
|
||||
// TODO: This should never be null -- when is it?
|
||||
if (bankForRegistrationName) {
|
||||
delete bankForRegistrationName[id];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes all listeners for the DOM element with the supplied ID.
|
||||
*
|
||||
* @param {string} id ID of the DOM element.
|
||||
*/
|
||||
deleteAllListeners: function (id) {
|
||||
for (var registrationName in listenerBank) {
|
||||
if (!listenerBank[registrationName][id]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
||||
if (PluginModule && PluginModule.willDeleteListener) {
|
||||
PluginModule.willDeleteListener(id, registrationName);
|
||||
}
|
||||
|
||||
delete listenerBank[registrationName][id];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Allows registered plugins an opportunity to extract events from top-level
|
||||
* native browser events.
|
||||
*
|
||||
* @param {string} topLevelType Record from `EventConstants`.
|
||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
||||
* @param {object} nativeEvent Native browser event.
|
||||
* @return {*} An accumulation of synthetic events.
|
||||
* @internal
|
||||
*/
|
||||
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
||||
var events;
|
||||
var plugins = EventPluginRegistry.plugins;
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
// Not every plugin in the ordering may be loaded at runtime.
|
||||
var possiblePlugin = plugins[i];
|
||||
if (possiblePlugin) {
|
||||
var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
|
||||
if (extractedEvents) {
|
||||
events = accumulateInto(events, extractedEvents);
|
||||
}
|
||||
}
|
||||
}
|
||||
return events;
|
||||
},
|
||||
|
||||
/**
|
||||
* Enqueues a synthetic event that should be dispatched when
|
||||
* `processEventQueue` is invoked.
|
||||
*
|
||||
* @param {*} events An accumulation of synthetic events.
|
||||
* @internal
|
||||
*/
|
||||
enqueueEvents: function (events) {
|
||||
if (events) {
|
||||
eventQueue = accumulateInto(eventQueue, events);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Dispatches all synthetic events on the event queue.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
processEventQueue: function (simulated) {
|
||||
// Set `eventQueue` to null before processing it so that we can tell if more
|
||||
// events get enqueued while processing.
|
||||
var processingEventQueue = eventQueue;
|
||||
eventQueue = null;
|
||||
if (simulated) {
|
||||
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
|
||||
} else {
|
||||
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
|
||||
}
|
||||
!!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined;
|
||||
// This would be a good time to rethrow if any of the event handlers threw.
|
||||
ReactErrorUtils.rethrowCaughtError();
|
||||
},
|
||||
|
||||
/**
|
||||
* These are needed for tests only. Do not use!
|
||||
*/
|
||||
__purge: function () {
|
||||
listenerBank = {};
|
||||
},
|
||||
|
||||
__getListenerBank: function () {
|
||||
return listenerBank;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = EventPluginHub;
|
||||
220
old_major_packages/14/react/lib/EventPluginRegistry.js
Normal file
220
old_major_packages/14/react/lib/EventPluginRegistry.js
Normal file
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EventPluginRegistry
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
/**
|
||||
* Injectable ordering of event plugins.
|
||||
*/
|
||||
var EventPluginOrder = null;
|
||||
|
||||
/**
|
||||
* Injectable mapping from names to event plugin modules.
|
||||
*/
|
||||
var namesToPlugins = {};
|
||||
|
||||
/**
|
||||
* Recomputes the plugin list using the injected plugins and plugin ordering.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function recomputePluginOrdering() {
|
||||
if (!EventPluginOrder) {
|
||||
// Wait until an `EventPluginOrder` is injected.
|
||||
return;
|
||||
}
|
||||
for (var pluginName in namesToPlugins) {
|
||||
var PluginModule = namesToPlugins[pluginName];
|
||||
var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
||||
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
|
||||
if (EventPluginRegistry.plugins[pluginIndex]) {
|
||||
continue;
|
||||
}
|
||||
!PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
|
||||
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
||||
var publishedEvents = PluginModule.eventTypes;
|
||||
for (var eventName in publishedEvents) {
|
||||
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes an event so that it can be dispatched by the supplied plugin.
|
||||
*
|
||||
* @param {object} dispatchConfig Dispatch configuration for the event.
|
||||
* @param {object} PluginModule Plugin publishing the event.
|
||||
* @return {boolean} True if the event was successfully published.
|
||||
* @private
|
||||
*/
|
||||
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
||||
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
|
||||
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
||||
|
||||
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
||||
if (phasedRegistrationNames) {
|
||||
for (var phaseName in phasedRegistrationNames) {
|
||||
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
|
||||
var phasedRegistrationName = phasedRegistrationNames[phaseName];
|
||||
publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (dispatchConfig.registrationName) {
|
||||
publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes a registration name that is used to identify dispatched events and
|
||||
* can be used with `EventPluginHub.putListener` to register listeners.
|
||||
*
|
||||
* @param {string} registrationName Registration name to add.
|
||||
* @param {object} PluginModule Plugin publishing the event.
|
||||
* @private
|
||||
*/
|
||||
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
||||
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
|
||||
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
||||
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers plugins so that they can extract and dispatch events.
|
||||
*
|
||||
* @see {EventPluginHub}
|
||||
*/
|
||||
var EventPluginRegistry = {
|
||||
|
||||
/**
|
||||
* Ordered list of injected plugins.
|
||||
*/
|
||||
plugins: [],
|
||||
|
||||
/**
|
||||
* Mapping from event name to dispatch config
|
||||
*/
|
||||
eventNameDispatchConfigs: {},
|
||||
|
||||
/**
|
||||
* Mapping from registration name to plugin module
|
||||
*/
|
||||
registrationNameModules: {},
|
||||
|
||||
/**
|
||||
* Mapping from registration name to event name
|
||||
*/
|
||||
registrationNameDependencies: {},
|
||||
|
||||
/**
|
||||
* Injects an ordering of plugins (by plugin name). This allows the ordering
|
||||
* to be decoupled from injection of the actual plugins so that ordering is
|
||||
* always deterministic regardless of packaging, on-the-fly injection, etc.
|
||||
*
|
||||
* @param {array} InjectedEventPluginOrder
|
||||
* @internal
|
||||
* @see {EventPluginHub.injection.injectEventPluginOrder}
|
||||
*/
|
||||
injectEventPluginOrder: function (InjectedEventPluginOrder) {
|
||||
!!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
|
||||
// Clone the ordering so it cannot be dynamically mutated.
|
||||
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
||||
recomputePluginOrdering();
|
||||
},
|
||||
|
||||
/**
|
||||
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
|
||||
* in the ordering injected by `injectEventPluginOrder`.
|
||||
*
|
||||
* Plugins can be injected as part of page initialization or on-the-fly.
|
||||
*
|
||||
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
|
||||
* @internal
|
||||
* @see {EventPluginHub.injection.injectEventPluginsByName}
|
||||
*/
|
||||
injectEventPluginsByName: function (injectedNamesToPlugins) {
|
||||
var isOrderingDirty = false;
|
||||
for (var pluginName in injectedNamesToPlugins) {
|
||||
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
|
||||
continue;
|
||||
}
|
||||
var PluginModule = injectedNamesToPlugins[pluginName];
|
||||
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
|
||||
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
|
||||
namesToPlugins[pluginName] = PluginModule;
|
||||
isOrderingDirty = true;
|
||||
}
|
||||
}
|
||||
if (isOrderingDirty) {
|
||||
recomputePluginOrdering();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Looks up the plugin for the supplied event.
|
||||
*
|
||||
* @param {object} event A synthetic event.
|
||||
* @return {?object} The plugin that created the supplied event.
|
||||
* @internal
|
||||
*/
|
||||
getPluginModuleForEvent: function (event) {
|
||||
var dispatchConfig = event.dispatchConfig;
|
||||
if (dispatchConfig.registrationName) {
|
||||
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
|
||||
}
|
||||
for (var phase in dispatchConfig.phasedRegistrationNames) {
|
||||
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
|
||||
continue;
|
||||
}
|
||||
var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
|
||||
if (PluginModule) {
|
||||
return PluginModule;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Exposed for unit testing.
|
||||
* @private
|
||||
*/
|
||||
_resetEventPlugins: function () {
|
||||
EventPluginOrder = null;
|
||||
for (var pluginName in namesToPlugins) {
|
||||
if (namesToPlugins.hasOwnProperty(pluginName)) {
|
||||
delete namesToPlugins[pluginName];
|
||||
}
|
||||
}
|
||||
EventPluginRegistry.plugins.length = 0;
|
||||
|
||||
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
|
||||
for (var eventName in eventNameDispatchConfigs) {
|
||||
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
|
||||
delete eventNameDispatchConfigs[eventName];
|
||||
}
|
||||
}
|
||||
|
||||
var registrationNameModules = EventPluginRegistry.registrationNameModules;
|
||||
for (var registrationName in registrationNameModules) {
|
||||
if (registrationNameModules.hasOwnProperty(registrationName)) {
|
||||
delete registrationNameModules[registrationName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = EventPluginRegistry;
|
||||
202
old_major_packages/14/react/lib/EventPluginUtils.js
Normal file
202
old_major_packages/14/react/lib/EventPluginUtils.js
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EventPluginUtils
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require('./EventConstants');
|
||||
var ReactErrorUtils = require('./ReactErrorUtils');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
/**
|
||||
* Injected dependencies:
|
||||
*/
|
||||
|
||||
/**
|
||||
* - `Mount`: [required] Module that can convert between React dom IDs and
|
||||
* actual node references.
|
||||
*/
|
||||
var injection = {
|
||||
Mount: null,
|
||||
injectMount: function (InjectedMount) {
|
||||
injection.Mount = InjectedMount;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
process.env.NODE_ENV !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var topLevelTypes = EventConstants.topLevelTypes;
|
||||
|
||||
function isEndish(topLevelType) {
|
||||
return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
|
||||
}
|
||||
|
||||
function isMoveish(topLevelType) {
|
||||
return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
|
||||
}
|
||||
function isStartish(topLevelType) {
|
||||
return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
|
||||
}
|
||||
|
||||
var validateEventDispatches;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateEventDispatches = function (event) {
|
||||
var dispatchListeners = event._dispatchListeners;
|
||||
var dispatchIDs = event._dispatchIDs;
|
||||
|
||||
var listenersIsArr = Array.isArray(dispatchListeners);
|
||||
var idsIsArr = Array.isArray(dispatchIDs);
|
||||
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
|
||||
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
||||
|
||||
process.env.NODE_ENV !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the event to the listener.
|
||||
* @param {SyntheticEvent} event SyntheticEvent to handle
|
||||
* @param {boolean} simulated If the event is simulated (changes exn behavior)
|
||||
* @param {function} listener Application-level callback
|
||||
* @param {string} domID DOM id to pass to the callback.
|
||||
*/
|
||||
function executeDispatch(event, simulated, listener, domID) {
|
||||
var type = event.type || 'unknown-event';
|
||||
event.currentTarget = injection.Mount.getNode(domID);
|
||||
if (simulated) {
|
||||
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID);
|
||||
} else {
|
||||
ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID);
|
||||
}
|
||||
event.currentTarget = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard/simple iteration through an event's collected dispatches.
|
||||
*/
|
||||
function executeDispatchesInOrder(event, simulated) {
|
||||
var dispatchListeners = event._dispatchListeners;
|
||||
var dispatchIDs = event._dispatchIDs;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateEventDispatches(event);
|
||||
}
|
||||
if (Array.isArray(dispatchListeners)) {
|
||||
for (var i = 0; i < dispatchListeners.length; i++) {
|
||||
if (event.isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
// Listeners and IDs are two parallel arrays that are always in sync.
|
||||
executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]);
|
||||
}
|
||||
} else if (dispatchListeners) {
|
||||
executeDispatch(event, simulated, dispatchListeners, dispatchIDs);
|
||||
}
|
||||
event._dispatchListeners = null;
|
||||
event._dispatchIDs = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard/simple iteration through an event's collected dispatches, but stops
|
||||
* at the first dispatch execution returning true, and returns that id.
|
||||
*
|
||||
* @return {?string} id of the first dispatch execution who's listener returns
|
||||
* true, or null if no listener returned true.
|
||||
*/
|
||||
function executeDispatchesInOrderStopAtTrueImpl(event) {
|
||||
var dispatchListeners = event._dispatchListeners;
|
||||
var dispatchIDs = event._dispatchIDs;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateEventDispatches(event);
|
||||
}
|
||||
if (Array.isArray(dispatchListeners)) {
|
||||
for (var i = 0; i < dispatchListeners.length; i++) {
|
||||
if (event.isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
// Listeners and IDs are two parallel arrays that are always in sync.
|
||||
if (dispatchListeners[i](event, dispatchIDs[i])) {
|
||||
return dispatchIDs[i];
|
||||
}
|
||||
}
|
||||
} else if (dispatchListeners) {
|
||||
if (dispatchListeners(event, dispatchIDs)) {
|
||||
return dispatchIDs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see executeDispatchesInOrderStopAtTrueImpl
|
||||
*/
|
||||
function executeDispatchesInOrderStopAtTrue(event) {
|
||||
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
||||
event._dispatchIDs = null;
|
||||
event._dispatchListeners = null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execution of a "direct" dispatch - there must be at most one dispatch
|
||||
* accumulated on the event or it is considered an error. It doesn't really make
|
||||
* sense for an event with multiple dispatches (bubbled) to keep track of the
|
||||
* return values at each dispatch execution, but it does tend to make sense when
|
||||
* dealing with "direct" dispatches.
|
||||
*
|
||||
* @return {*} The return value of executing the single dispatch.
|
||||
*/
|
||||
function executeDirectDispatch(event) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
validateEventDispatches(event);
|
||||
}
|
||||
var dispatchListener = event._dispatchListeners;
|
||||
var dispatchID = event._dispatchIDs;
|
||||
!!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
|
||||
var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
|
||||
event._dispatchListeners = null;
|
||||
event._dispatchIDs = null;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SyntheticEvent} event
|
||||
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
|
||||
*/
|
||||
function hasDispatches(event) {
|
||||
return !!event._dispatchListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* General utilities that are useful in creating custom Event Plugins.
|
||||
*/
|
||||
var EventPluginUtils = {
|
||||
isEndish: isEndish,
|
||||
isMoveish: isMoveish,
|
||||
isStartish: isStartish,
|
||||
|
||||
executeDirectDispatch: executeDirectDispatch,
|
||||
executeDispatchesInOrder: executeDispatchesInOrder,
|
||||
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
|
||||
hasDispatches: hasDispatches,
|
||||
|
||||
getNode: function (id) {
|
||||
return injection.Mount.getNode(id);
|
||||
},
|
||||
getID: function (node) {
|
||||
return injection.Mount.getID(node);
|
||||
},
|
||||
|
||||
injection: injection
|
||||
};
|
||||
|
||||
module.exports = EventPluginUtils;
|
||||
135
old_major_packages/14/react/lib/EventPropagators.js
Normal file
135
old_major_packages/14/react/lib/EventPropagators.js
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 EventPropagators
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var EventConstants = require('./EventConstants');
|
||||
var EventPluginHub = require('./EventPluginHub');
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var accumulateInto = require('./accumulateInto');
|
||||
var forEachAccumulated = require('./forEachAccumulated');
|
||||
|
||||
var PropagationPhases = EventConstants.PropagationPhases;
|
||||
var getListener = EventPluginHub.getListener;
|
||||
|
||||
/**
|
||||
* Some event types have a notion of different registration names for different
|
||||
* "phases" of propagation. This finds listeners by a given phase.
|
||||
*/
|
||||
function listenerAtPhase(id, event, propagationPhase) {
|
||||
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
||||
return getListener(id, registrationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
|
||||
* here, allows us to not have to bind or create functions for each event.
|
||||
* Mutating the event's members allows us to not have to create a wrapping
|
||||
* "dispatch" object that pairs the event with the listener.
|
||||
*/
|
||||
function accumulateDirectionalDispatches(domID, upwards, event) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
process.env.NODE_ENV !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined;
|
||||
}
|
||||
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
||||
var listener = listenerAtPhase(domID, event, phase);
|
||||
if (listener) {
|
||||
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
||||
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect dispatches (must be entirely collected before dispatching - see unit
|
||||
* tests). Lazily allocate the array to conserve memory. We must loop through
|
||||
* each event and perform the traversal for each one. We cannot perform a
|
||||
* single traversal for the entire collection of events because each event may
|
||||
* have a different target.
|
||||
*/
|
||||
function accumulateTwoPhaseDispatchesSingle(event) {
|
||||
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
|
||||
*/
|
||||
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
||||
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accumulates without regard to direction, does not look for phased
|
||||
* registration names. Same as `accumulateDirectDispatchesSingle` but without
|
||||
* requiring that the `dispatchMarker` be the same as the dispatched ID.
|
||||
*/
|
||||
function accumulateDispatches(id, ignoredDirection, event) {
|
||||
if (event && event.dispatchConfig.registrationName) {
|
||||
var registrationName = event.dispatchConfig.registrationName;
|
||||
var listener = getListener(id, registrationName);
|
||||
if (listener) {
|
||||
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
||||
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accumulates dispatches on an `SyntheticEvent`, but only for the
|
||||
* `dispatchMarker`.
|
||||
* @param {SyntheticEvent} event
|
||||
*/
|
||||
function accumulateDirectDispatchesSingle(event) {
|
||||
if (event && event.dispatchConfig.registrationName) {
|
||||
accumulateDispatches(event.dispatchMarker, null, event);
|
||||
}
|
||||
}
|
||||
|
||||
function accumulateTwoPhaseDispatches(events) {
|
||||
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
||||
}
|
||||
|
||||
function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
||||
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
||||
}
|
||||
|
||||
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
||||
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter);
|
||||
}
|
||||
|
||||
function accumulateDirectDispatches(events) {
|
||||
forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
||||
}
|
||||
|
||||
/**
|
||||
* A small set of propagation patterns, each of which will accept a small amount
|
||||
* of information, and generate a set of "dispatch ready event objects" - which
|
||||
* are sets of events that have already been annotated with a set of dispatched
|
||||
* listener functions/ids. The API is designed this way to discourage these
|
||||
* propagation strategies from actually executing the dispatches, since we
|
||||
* always want to collect the entire set of dispatches before executing event a
|
||||
* single one.
|
||||
*
|
||||
* @constructor EventPropagators
|
||||
*/
|
||||
var EventPropagators = {
|
||||
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
|
||||
accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
|
||||
accumulateDirectDispatches: accumulateDirectDispatches,
|
||||
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
||||
};
|
||||
|
||||
module.exports = EventPropagators;
|
||||
95
old_major_packages/14/react/lib/FallbackCompositionState.js
Normal file
95
old_major_packages/14/react/lib/FallbackCompositionState.js
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 FallbackCompositionState
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var PooledClass = require('./PooledClass');
|
||||
|
||||
var assign = require('./Object.assign');
|
||||
var getTextContentAccessor = require('./getTextContentAccessor');
|
||||
|
||||
/**
|
||||
* This helper class stores information about text content of a target node,
|
||||
* allowing comparison of content before and after a given event.
|
||||
*
|
||||
* Identify the node where selection currently begins, then observe
|
||||
* both its text content and its current position in the DOM. Since the
|
||||
* browser may natively replace the target node during composition, we can
|
||||
* use its position to find its replacement.
|
||||
*
|
||||
* @param {DOMEventTarget} root
|
||||
*/
|
||||
function FallbackCompositionState(root) {
|
||||
this._root = root;
|
||||
this._startText = this.getText();
|
||||
this._fallbackText = null;
|
||||
}
|
||||
|
||||
assign(FallbackCompositionState.prototype, {
|
||||
destructor: function () {
|
||||
this._root = null;
|
||||
this._startText = null;
|
||||
this._fallbackText = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get current text of input.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getText: function () {
|
||||
if ('value' in this._root) {
|
||||
return this._root.value;
|
||||
}
|
||||
return this._root[getTextContentAccessor()];
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine the differing substring between the initially stored
|
||||
* text content and the current content.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getData: function () {
|
||||
if (this._fallbackText) {
|
||||
return this._fallbackText;
|
||||
}
|
||||
|
||||
var start;
|
||||
var startValue = this._startText;
|
||||
var startLength = startValue.length;
|
||||
var end;
|
||||
var endValue = this.getText();
|
||||
var endLength = endValue.length;
|
||||
|
||||
for (start = 0; start < startLength; start++) {
|
||||
if (startValue[start] !== endValue[start]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var minEnd = startLength - start;
|
||||
for (end = 1; end <= minEnd; end++) {
|
||||
if (startValue[startLength - end] !== endValue[endLength - end]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var sliceTail = end > 1 ? 1 - end : undefined;
|
||||
this._fallbackText = endValue.slice(start, sliceTail);
|
||||
return this._fallbackText;
|
||||
}
|
||||
});
|
||||
|
||||
PooledClass.addPoolingTo(FallbackCompositionState);
|
||||
|
||||
module.exports = FallbackCompositionState;
|
||||
230
old_major_packages/14/react/lib/HTMLDOMPropertyConfig.js
Normal file
230
old_major_packages/14/react/lib/HTMLDOMPropertyConfig.js
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 HTMLDOMPropertyConfig
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var DOMProperty = require('./DOMProperty');
|
||||
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
|
||||
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
||||
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
|
||||
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
|
||||
var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
|
||||
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
|
||||
var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
|
||||
var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
|
||||
|
||||
var hasSVG;
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
var implementation = document.implementation;
|
||||
hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
|
||||
}
|
||||
|
||||
var HTMLDOMPropertyConfig = {
|
||||
isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/),
|
||||
Properties: {
|
||||
/**
|
||||
* Standard Properties
|
||||
*/
|
||||
accept: null,
|
||||
acceptCharset: null,
|
||||
accessKey: null,
|
||||
action: null,
|
||||
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
allowTransparency: MUST_USE_ATTRIBUTE,
|
||||
alt: null,
|
||||
async: HAS_BOOLEAN_VALUE,
|
||||
autoComplete: null,
|
||||
// autoFocus is polyfilled/normalized by AutoFocusUtils
|
||||
// autoFocus: HAS_BOOLEAN_VALUE,
|
||||
autoPlay: HAS_BOOLEAN_VALUE,
|
||||
capture: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
cellPadding: null,
|
||||
cellSpacing: null,
|
||||
charSet: MUST_USE_ATTRIBUTE,
|
||||
challenge: MUST_USE_ATTRIBUTE,
|
||||
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
classID: MUST_USE_ATTRIBUTE,
|
||||
// To set className on SVG elements, it's necessary to use .setAttribute;
|
||||
// this works on HTML elements too in all browsers except IE8. Conveniently,
|
||||
// IE8 doesn't support SVG and so we can simply use the attribute in
|
||||
// browsers that support SVG and the property in browsers that don't,
|
||||
// regardless of whether the element is HTML or SVG.
|
||||
className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
|
||||
cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
||||
colSpan: null,
|
||||
content: null,
|
||||
contentEditable: null,
|
||||
contextMenu: MUST_USE_ATTRIBUTE,
|
||||
controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
coords: null,
|
||||
crossOrigin: null,
|
||||
data: null, // For `<object />` acts as `src`.
|
||||
dateTime: MUST_USE_ATTRIBUTE,
|
||||
'default': HAS_BOOLEAN_VALUE,
|
||||
defer: HAS_BOOLEAN_VALUE,
|
||||
dir: null,
|
||||
disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
download: HAS_OVERLOADED_BOOLEAN_VALUE,
|
||||
draggable: null,
|
||||
encType: null,
|
||||
form: MUST_USE_ATTRIBUTE,
|
||||
formAction: MUST_USE_ATTRIBUTE,
|
||||
formEncType: MUST_USE_ATTRIBUTE,
|
||||
formMethod: MUST_USE_ATTRIBUTE,
|
||||
formNoValidate: HAS_BOOLEAN_VALUE,
|
||||
formTarget: MUST_USE_ATTRIBUTE,
|
||||
frameBorder: MUST_USE_ATTRIBUTE,
|
||||
headers: null,
|
||||
height: MUST_USE_ATTRIBUTE,
|
||||
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
high: null,
|
||||
href: null,
|
||||
hrefLang: null,
|
||||
htmlFor: null,
|
||||
httpEquiv: null,
|
||||
icon: null,
|
||||
id: MUST_USE_PROPERTY,
|
||||
inputMode: MUST_USE_ATTRIBUTE,
|
||||
integrity: null,
|
||||
is: MUST_USE_ATTRIBUTE,
|
||||
keyParams: MUST_USE_ATTRIBUTE,
|
||||
keyType: MUST_USE_ATTRIBUTE,
|
||||
kind: null,
|
||||
label: null,
|
||||
lang: null,
|
||||
list: MUST_USE_ATTRIBUTE,
|
||||
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
low: null,
|
||||
manifest: MUST_USE_ATTRIBUTE,
|
||||
marginHeight: null,
|
||||
marginWidth: null,
|
||||
max: null,
|
||||
maxLength: MUST_USE_ATTRIBUTE,
|
||||
media: MUST_USE_ATTRIBUTE,
|
||||
mediaGroup: null,
|
||||
method: null,
|
||||
min: null,
|
||||
minLength: MUST_USE_ATTRIBUTE,
|
||||
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
name: null,
|
||||
nonce: MUST_USE_ATTRIBUTE,
|
||||
noValidate: HAS_BOOLEAN_VALUE,
|
||||
open: HAS_BOOLEAN_VALUE,
|
||||
optimum: null,
|
||||
pattern: null,
|
||||
placeholder: null,
|
||||
poster: null,
|
||||
preload: null,
|
||||
radioGroup: null,
|
||||
readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
rel: null,
|
||||
required: HAS_BOOLEAN_VALUE,
|
||||
reversed: HAS_BOOLEAN_VALUE,
|
||||
role: MUST_USE_ATTRIBUTE,
|
||||
rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
||||
rowSpan: null,
|
||||
sandbox: null,
|
||||
scope: null,
|
||||
scoped: HAS_BOOLEAN_VALUE,
|
||||
scrolling: null,
|
||||
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
shape: null,
|
||||
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
||||
sizes: MUST_USE_ATTRIBUTE,
|
||||
span: HAS_POSITIVE_NUMERIC_VALUE,
|
||||
spellCheck: null,
|
||||
src: null,
|
||||
srcDoc: MUST_USE_PROPERTY,
|
||||
srcLang: null,
|
||||
srcSet: MUST_USE_ATTRIBUTE,
|
||||
start: HAS_NUMERIC_VALUE,
|
||||
step: null,
|
||||
style: null,
|
||||
summary: null,
|
||||
tabIndex: null,
|
||||
target: null,
|
||||
title: null,
|
||||
type: null,
|
||||
useMap: null,
|
||||
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
|
||||
width: MUST_USE_ATTRIBUTE,
|
||||
wmode: MUST_USE_ATTRIBUTE,
|
||||
wrap: null,
|
||||
|
||||
/**
|
||||
* RDFa Properties
|
||||
*/
|
||||
about: MUST_USE_ATTRIBUTE,
|
||||
datatype: MUST_USE_ATTRIBUTE,
|
||||
inlist: MUST_USE_ATTRIBUTE,
|
||||
prefix: MUST_USE_ATTRIBUTE,
|
||||
// property is also supported for OpenGraph in meta tags.
|
||||
property: MUST_USE_ATTRIBUTE,
|
||||
resource: MUST_USE_ATTRIBUTE,
|
||||
'typeof': MUST_USE_ATTRIBUTE,
|
||||
vocab: MUST_USE_ATTRIBUTE,
|
||||
|
||||
/**
|
||||
* Non-standard Properties
|
||||
*/
|
||||
// autoCapitalize and autoCorrect are supported in Mobile Safari for
|
||||
// keyboard hints.
|
||||
autoCapitalize: MUST_USE_ATTRIBUTE,
|
||||
autoCorrect: MUST_USE_ATTRIBUTE,
|
||||
// autoSave allows WebKit/Blink to persist values of input fields on page reloads
|
||||
autoSave: null,
|
||||
// color is for Safari mask-icon link
|
||||
color: null,
|
||||
// itemProp, itemScope, itemType are for
|
||||
// Microdata support. See http://schema.org/docs/gs.html
|
||||
itemProp: MUST_USE_ATTRIBUTE,
|
||||
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
||||
itemType: MUST_USE_ATTRIBUTE,
|
||||
// itemID and itemRef are for Microdata support as well but
|
||||
// only specified in the the WHATWG spec document. See
|
||||
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
|
||||
itemID: MUST_USE_ATTRIBUTE,
|
||||
itemRef: MUST_USE_ATTRIBUTE,
|
||||
// results show looking glass icon and recent searches on input
|
||||
// search fields in WebKit/Blink
|
||||
results: null,
|
||||
// IE-only attribute that specifies security restrictions on an iframe
|
||||
// as an alternative to the sandbox attribute on IE<10
|
||||
security: MUST_USE_ATTRIBUTE,
|
||||
// IE-only attribute that controls focus behavior
|
||||
unselectable: MUST_USE_ATTRIBUTE
|
||||
},
|
||||
DOMAttributeNames: {
|
||||
acceptCharset: 'accept-charset',
|
||||
className: 'class',
|
||||
htmlFor: 'for',
|
||||
httpEquiv: 'http-equiv'
|
||||
},
|
||||
DOMPropertyNames: {
|
||||
autoComplete: 'autocomplete',
|
||||
autoFocus: 'autofocus',
|
||||
autoPlay: 'autoplay',
|
||||
autoSave: 'autosave',
|
||||
// `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
|
||||
// http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
|
||||
encType: 'encoding',
|
||||
hrefLang: 'hreflang',
|
||||
radioGroup: 'radiogroup',
|
||||
spellCheck: 'spellcheck',
|
||||
srcDoc: 'srcdoc',
|
||||
srcSet: 'srcset'
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = HTMLDOMPropertyConfig;
|
||||
36
old_major_packages/14/react/lib/LinkedStateMixin.js
Normal file
36
old_major_packages/14/react/lib/LinkedStateMixin.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 LinkedStateMixin
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactLink = require('./ReactLink');
|
||||
var ReactStateSetters = require('./ReactStateSetters');
|
||||
|
||||
/**
|
||||
* A simple mixin around ReactLink.forState().
|
||||
*/
|
||||
var LinkedStateMixin = {
|
||||
/**
|
||||
* Create a ReactLink that's linked to part of this component's state. The
|
||||
* ReactLink will have the current value of this.state[key] and will call
|
||||
* setState() when a change is requested.
|
||||
*
|
||||
* @param {string} key state key to update. Note: you may want to use keyOf()
|
||||
* if you're using Google Closure Compiler advanced mode.
|
||||
* @return {ReactLink} ReactLink instance linking to the state.
|
||||
*/
|
||||
linkState: function (key) {
|
||||
return new ReactLink(this.state[key], ReactStateSetters.createStateKeySetter(this, key));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = LinkedStateMixin;
|
||||
134
old_major_packages/14/react/lib/LinkedValueUtils.js
Normal file
134
old_major_packages/14/react/lib/LinkedValueUtils.js
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 LinkedValueUtils
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactPropTypes = require('./ReactPropTypes');
|
||||
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
|
||||
var hasReadOnlyValue = {
|
||||
'button': true,
|
||||
'checkbox': true,
|
||||
'image': true,
|
||||
'hidden': true,
|
||||
'radio': true,
|
||||
'reset': true,
|
||||
'submit': true
|
||||
};
|
||||
|
||||
function _assertSingleLink(inputProps) {
|
||||
!(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use ' + 'checkedLink, you probably don\'t want to use valueLink and vice versa.') : invariant(false) : undefined;
|
||||
}
|
||||
function _assertValueLink(inputProps) {
|
||||
_assertSingleLink(inputProps);
|
||||
!(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want ' + 'to use value or onChange, you probably don\'t want to use valueLink.') : invariant(false) : undefined;
|
||||
}
|
||||
|
||||
function _assertCheckedLink(inputProps) {
|
||||
_assertSingleLink(inputProps);
|
||||
!(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event. ' + 'If you want to use checked or onChange, you probably don\'t want to ' + 'use checkedLink') : invariant(false) : undefined;
|
||||
}
|
||||
|
||||
var propTypes = {
|
||||
value: function (props, propName, componentName) {
|
||||
if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
|
||||
return null;
|
||||
}
|
||||
return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
|
||||
},
|
||||
checked: function (props, propName, componentName) {
|
||||
if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
|
||||
return null;
|
||||
}
|
||||
return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
|
||||
},
|
||||
onChange: ReactPropTypes.func
|
||||
};
|
||||
|
||||
var loggedTypeFailures = {};
|
||||
function getDeclarationErrorAddendum(owner) {
|
||||
if (owner) {
|
||||
var name = owner.getName();
|
||||
if (name) {
|
||||
return ' Check the render method of `' + name + '`.';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a linked `value` attribute for controlled forms. You should not use
|
||||
* this outside of the ReactDOM controlled form components.
|
||||
*/
|
||||
var LinkedValueUtils = {
|
||||
checkPropTypes: function (tagName, props, owner) {
|
||||
for (var propName in propTypes) {
|
||||
if (propTypes.hasOwnProperty(propName)) {
|
||||
var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
||||
}
|
||||
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error.message] = true;
|
||||
|
||||
var addendum = getDeclarationErrorAddendum(owner);
|
||||
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed form propType: %s%s', error.message, addendum) : undefined;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @return {*} current value of the input either from value prop or link.
|
||||
*/
|
||||
getValue: function (inputProps) {
|
||||
if (inputProps.valueLink) {
|
||||
_assertValueLink(inputProps);
|
||||
return inputProps.valueLink.value;
|
||||
}
|
||||
return inputProps.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @return {*} current checked status of the input either from checked prop
|
||||
* or link.
|
||||
*/
|
||||
getChecked: function (inputProps) {
|
||||
if (inputProps.checkedLink) {
|
||||
_assertCheckedLink(inputProps);
|
||||
return inputProps.checkedLink.value;
|
||||
}
|
||||
return inputProps.checked;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} inputProps Props for form component
|
||||
* @param {SyntheticEvent} event change event to handle
|
||||
*/
|
||||
executeOnChange: function (inputProps, event) {
|
||||
if (inputProps.valueLink) {
|
||||
_assertValueLink(inputProps);
|
||||
return inputProps.valueLink.requestChange(event.target.value);
|
||||
} else if (inputProps.checkedLink) {
|
||||
_assertCheckedLink(inputProps);
|
||||
return inputProps.checkedLink.requestChange(event.target.checked);
|
||||
} else if (inputProps.onChange) {
|
||||
return inputProps.onChange.call(undefined, event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = LinkedValueUtils;
|
||||
118
old_major_packages/14/react/lib/MetaMatchers.js
Normal file
118
old_major_packages/14/react/lib/MetaMatchers.js
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright 2015, 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 MetaMatchers
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* This modules adds a jasmine matcher toEqualSpecsIn that can be used to
|
||||
* compare the specs in two different "describe" functions and their result.
|
||||
* It can be used to test a test.
|
||||
*/
|
||||
|
||||
function getRunnerWithResults(describeFunction) {
|
||||
if (describeFunction._cachedRunner) {
|
||||
// Cached result of execution. This is a convenience way to test against
|
||||
// the same authorative function multiple times.
|
||||
return describeFunction._cachedRunner;
|
||||
}
|
||||
// Patch the current global environment.
|
||||
var env = new jasmine.Env();
|
||||
// Execute the tests synchronously.
|
||||
env.updateInterval = 0;
|
||||
var outerGetEnv = jasmine.getEnv;
|
||||
jasmine.getEnv = function () {
|
||||
return env;
|
||||
};
|
||||
// TODO: Bring over matchers from the existing environment.
|
||||
var runner = env.currentRunner();
|
||||
try {
|
||||
env.describe('', describeFunction);
|
||||
env.execute();
|
||||
} finally {
|
||||
// Restore the environment.
|
||||
jasmine.getEnv = outerGetEnv;
|
||||
}
|
||||
describeFunction._cachedRunner = runner;
|
||||
return runner;
|
||||
}
|
||||
|
||||
function compareSpec(actual, expected) {
|
||||
if (actual.results().totalCount !== expected.results().totalCount) {
|
||||
return 'Expected ' + expected.results().totalCount + ' expects, ' + 'but got ' + actual.results().totalCount + ':' + actual.getFullName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function includesDescription(specs, description, startIndex) {
|
||||
for (var i = startIndex; i < specs.length; i++) {
|
||||
if (specs[i].description === description) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function compareSpecs(actualSpecs, expectedSpecs) {
|
||||
for (var i = 0; i < actualSpecs.length && i < expectedSpecs.length; i++) {
|
||||
var actual = actualSpecs[i];
|
||||
var expected = expectedSpecs[i];
|
||||
if (actual.description === expected.description) {
|
||||
var errorMessage = compareSpec(actual, expected);
|
||||
if (errorMessage) {
|
||||
return errorMessage;
|
||||
}
|
||||
continue;
|
||||
} else if (includesDescription(actualSpecs, expected.description, i)) {
|
||||
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
||||
} else {
|
||||
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
||||
}
|
||||
}
|
||||
if (i < actualSpecs.length) {
|
||||
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
||||
}
|
||||
if (i < expectedSpecs.length) {
|
||||
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function compareDescription(a, b) {
|
||||
if (a.description === b.description) {
|
||||
return 0;
|
||||
}
|
||||
return a.description < b.description ? -1 : 1;
|
||||
}
|
||||
|
||||
function compareRunners(actual, expected) {
|
||||
return compareSpecs(actual.specs().sort(compareDescription), expected.specs().sort(compareDescription));
|
||||
}
|
||||
|
||||
var MetaMatchers = {
|
||||
toEqualSpecsIn: function (expectedDescribeFunction) {
|
||||
var actualDescribeFunction = this.actual;
|
||||
if (typeof actualDescribeFunction !== 'function') {
|
||||
throw Error('toEqualSpecsIn() should be used on a describe function');
|
||||
}
|
||||
if (typeof expectedDescribeFunction !== 'function') {
|
||||
throw Error('toEqualSpecsIn() should be passed a describe function');
|
||||
}
|
||||
var actual = getRunnerWithResults(actualDescribeFunction);
|
||||
var expected = getRunnerWithResults(expectedDescribeFunction);
|
||||
var errorMessage = compareRunners(actual, expected);
|
||||
this.message = function () {
|
||||
return [errorMessage, 'The specs are equal. Expected them to be different.'];
|
||||
};
|
||||
return !errorMessage;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MetaMatchers;
|
||||
47
old_major_packages/14/react/lib/Object.assign.js
Normal file
47
old_major_packages/14/react/lib/Object.assign.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2014-2015, 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 Object.assign
|
||||
*/
|
||||
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
||||
|
||||
'use strict';
|
||||
|
||||
function assign(target, sources) {
|
||||
if (target == null) {
|
||||
throw new TypeError('Object.assign target cannot be null or undefined');
|
||||
}
|
||||
|
||||
var to = Object(target);
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
||||
var nextSource = arguments[nextIndex];
|
||||
if (nextSource == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var from = Object(nextSource);
|
||||
|
||||
// We don't currently support accessors nor proxies. Therefore this
|
||||
// copy cannot throw. If we ever supported this then we must handle
|
||||
// exceptions and side-effects. We don't support symbols so they won't
|
||||
// be transferred.
|
||||
|
||||
for (var key in from) {
|
||||
if (hasOwnProperty.call(from, key)) {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
module.exports = assign;
|
||||
453
old_major_packages/14/react/lib/OrderedMap.js
Normal file
453
old_major_packages/14/react/lib/OrderedMap.js
Normal file
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 OrderedMap
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require('./Object.assign');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
var PREFIX = 'key:';
|
||||
|
||||
/**
|
||||
* Utility to extract a backing object from an initialization `Array`, allowing
|
||||
* the caller to assist in resolving the unique ID for each entry via the
|
||||
* `keyExtractor` callback. The `keyExtractor` must extract non-empty strings or
|
||||
* numbers.
|
||||
* @param {Array<Object!>} arr Array of items.
|
||||
* @param {function} keyExtractor Extracts a unique key from each item.
|
||||
* @return {Object} Map from unique key to originating value that the key was
|
||||
* extracted from.
|
||||
* @throws Exception if the initialization array has duplicate extracted keys.
|
||||
*/
|
||||
function extractObjectFromArray(arr, keyExtractor) {
|
||||
var normalizedObj = {};
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var item = arr[i];
|
||||
var key = keyExtractor(item);
|
||||
assertValidPublicKey(key);
|
||||
var normalizedKey = PREFIX + key;
|
||||
!!(normalizedKey in normalizedObj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap: IDs returned by the key extraction function must be unique.') : invariant(false) : undefined;
|
||||
normalizedObj[normalizedKey] = item;
|
||||
}
|
||||
return normalizedObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class for mappings with ordering. This class is to be used in an
|
||||
* immutable manner. A `OrderedMap` is very much like the native JavaScript
|
||||
* object, where keys map to values via the `get()` function. Also, like the
|
||||
* native JavaScript object, there is an ordering associated with the mapping.
|
||||
* This class is helpful because it eliminates many of the pitfalls that come
|
||||
* with the native JavaScript ordered mappings. Specifically, there are
|
||||
* inconsistencies with numeric keys in some JavaScript implementations
|
||||
* (enumeration ordering). This class protects against those pitfalls and
|
||||
* provides functional utilities for dealing with these `OrderedMap`s.
|
||||
*
|
||||
* - TODO:
|
||||
* - orderedMergeExclusive: Merges mutually exclusive `OrderedMap`s.
|
||||
* - mapReverse().
|
||||
*
|
||||
* @class {OrderedMap}
|
||||
* @constructor {OrderedMap}
|
||||
* @param {Object} normalizedObj Object that is known to be a defensive copy of
|
||||
* caller supplied data. We require a defensive copy to guard against callers
|
||||
* mutating. It is also assumed that the keys of `normalizedObj` have been
|
||||
* normalized and do not contain any numeric-appearing strings.
|
||||
* @param {number} computedLength The precomputed length of `_normalizedObj`
|
||||
* keys.
|
||||
* @private
|
||||
*/
|
||||
function OrderedMapImpl(normalizedObj, computedLength) {
|
||||
this._normalizedObj = normalizedObj;
|
||||
this._computedPositions = null;
|
||||
this.length = computedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a "public" key - that is, one that the public facing API supplies.
|
||||
* The key is then normalized for internal storage. In order to be considered
|
||||
* valid, all keys must be non-empty, defined, non-null strings or numbers.
|
||||
*
|
||||
* @param {string?} key Validates that the key is suitable for use in a
|
||||
* `OrderedMap`.
|
||||
* @throws Error if key is not appropriate for use in `OrderedMap`.
|
||||
*/
|
||||
function assertValidPublicKey(key) {
|
||||
!(key !== '' && (typeof key === 'string' || typeof key === 'number')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap: Key must be non-empty, non-null string or number.') : invariant(false) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that arguments to range operations are within the correct limits.
|
||||
*
|
||||
* @param {number} start Start of range.
|
||||
* @param {number} length Length of range.
|
||||
* @param {number} actualLen Actual length of range that should not be
|
||||
* exceeded.
|
||||
* @throws Error if range arguments are out of bounds.
|
||||
*/
|
||||
function assertValidRangeIndices(start, length, actualLen) {
|
||||
!(typeof start === 'number' && typeof length === 'number' && length >= 0 && start >= 0 && start + length <= actualLen) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap: `mapRange` and `forEachRange` expect non-negative start and ' + 'length arguments within the bounds of the instance.') : invariant(false) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two "normalized" objects (objects who's key have been normalized) into
|
||||
* a `OrderedMap`.
|
||||
*
|
||||
* @param {Object} a Object of key value pairs.
|
||||
* @param {Object} b Object of key value pairs.
|
||||
* @return {OrderedMap} new `OrderedMap` that results in merging `a` and `b`.
|
||||
*/
|
||||
function _fromNormalizedObjects(a, b) {
|
||||
// Second optional, both must be plain JavaScript objects.
|
||||
!(a && a.constructor === Object && (!b || b.constructor === Object)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap: Corrupted instance of OrderedMap detected.') : invariant(false) : undefined;
|
||||
|
||||
var newSet = {};
|
||||
var length = 0;
|
||||
var key;
|
||||
for (key in a) {
|
||||
if (a.hasOwnProperty(key)) {
|
||||
newSet[key] = a[key];
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
||||
for (key in b) {
|
||||
if (b.hasOwnProperty(key)) {
|
||||
// Increment length if not already added via first object (a)
|
||||
if (!(key in newSet)) {
|
||||
length++;
|
||||
}
|
||||
newSet[key] = b[key];
|
||||
}
|
||||
}
|
||||
return new OrderedMapImpl(newSet, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods for `OrderedMap` instances.
|
||||
*
|
||||
* @lends OrderedMap.prototype
|
||||
* TODO: Make this data structure lazy, unify with LazyArray.
|
||||
* TODO: Unify this with ImmutableObject - it is to be used immutably.
|
||||
* TODO: If so, consider providing `fromObject` API.
|
||||
* TODO: Create faster implementation of merging/mapping from original Array,
|
||||
* without having to first create an object - simply for the sake of merging.
|
||||
*/
|
||||
var OrderedMapMethods = {
|
||||
|
||||
/**
|
||||
* Returns whether or not a given key is present in the map.
|
||||
*
|
||||
* @param {string} key Valid string key to lookup membership for.
|
||||
* @return {boolean} Whether or not `key` is a member of the map.
|
||||
* @throws Error if provided known invalid key.
|
||||
*/
|
||||
has: function (key) {
|
||||
assertValidPublicKey(key);
|
||||
var normalizedKey = PREFIX + key;
|
||||
return normalizedKey in this._normalizedObj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the object for a given key, or `undefined` if not present. To
|
||||
* distinguish an undefined entry vs not being in the set, use `has()`.
|
||||
*
|
||||
* @param {string} key String key to lookup the value for.
|
||||
* @return {Object?} Object at key `key`, or undefined if not in map.
|
||||
* @throws Error if provided known invalid key.
|
||||
*/
|
||||
get: function (key) {
|
||||
assertValidPublicKey(key);
|
||||
var normalizedKey = PREFIX + key;
|
||||
return this.has(key) ? this._normalizedObj[normalizedKey] : undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Merges, appending new keys to the end of the ordering. Keys in `orderedMap`
|
||||
* that are redundant with `this`, maintain the same ordering index that they
|
||||
* had in `this`. This is how standard JavaScript object merging would work.
|
||||
* If you wish to prepend a `OrderedMap` to the beginning of another
|
||||
* `OrderedMap` then simply reverse the order of operation. This is the analog
|
||||
* to `merge(x, y)`.
|
||||
*
|
||||
* @param {OrderedMap} orderedMap OrderedMap to merge onto the end.
|
||||
* @return {OrderedMap} New OrderedMap that represents the result of the
|
||||
* merge.
|
||||
*/
|
||||
merge: function (orderedMap) {
|
||||
!(orderedMap instanceof OrderedMapImpl) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.merge(...): Expected an OrderedMap instance.') : invariant(false) : undefined;
|
||||
return _fromNormalizedObjects(this._normalizedObj, orderedMap._normalizedObj);
|
||||
},
|
||||
|
||||
/**
|
||||
* Functional map API. Returns a new `OrderedMap`.
|
||||
*
|
||||
* @param {Function} cb Callback to invoke for each item.
|
||||
* @param {Object?=} context Context to invoke callback from.
|
||||
* @return {OrderedMap} OrderedMap that results from mapping.
|
||||
*/
|
||||
map: function (cb, context) {
|
||||
return this.mapRange(cb, 0, this.length, context);
|
||||
},
|
||||
|
||||
/**
|
||||
* The callback `cb` is invoked with the arguments (item, key,
|
||||
* indexInOriginal).
|
||||
*
|
||||
* @param {Function} cb Determines result for each item.
|
||||
* @param {number} start Start index of map range.
|
||||
* @param {end} length End index of map range.
|
||||
* @param {*!?} context Context of callback invocation.
|
||||
* @return {OrderedMap} OrderedMap resulting from mapping the range.
|
||||
*/
|
||||
mapRange: function (cb, start, length, context) {
|
||||
var thisSet = this._normalizedObj;
|
||||
var newSet = {};
|
||||
var i = 0;
|
||||
assertValidRangeIndices(start, length, this.length);
|
||||
var end = start + length - 1;
|
||||
for (var key in thisSet) {
|
||||
if (thisSet.hasOwnProperty(key)) {
|
||||
if (i >= start) {
|
||||
if (i > end) {
|
||||
break;
|
||||
}
|
||||
var item = thisSet[key];
|
||||
newSet[key] = cb.call(context, item, key.substr(PREFIX.length), i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return new OrderedMapImpl(newSet, length);
|
||||
},
|
||||
|
||||
/**
|
||||
* Function filter API. Returns new `OrderedMap`.
|
||||
*
|
||||
* @param {Function} cb Callback to invoke for each item.
|
||||
* @param {Object?=} context Context to invoke callback from.
|
||||
* @return {OrderedMap} OrderedMap that results from filtering.
|
||||
*/
|
||||
filter: function (cb, context) {
|
||||
return this.filterRange(cb, 0, this.length, context);
|
||||
},
|
||||
|
||||
/**
|
||||
* The callback `cb` is invoked with the arguments (item, key,
|
||||
* indexInOriginal).
|
||||
*
|
||||
* @param {Function} cb Returns true if item should be in result.
|
||||
* @param {number} start Start index of filter range.
|
||||
* @param {number} length End index of map range.
|
||||
* @param {*!?} context Context of callback invocation.
|
||||
* @return {OrderedMap} OrderedMap resulting from filtering the range.
|
||||
*/
|
||||
filterRange: function (cb, start, length, context) {
|
||||
var newSet = {};
|
||||
var newSetLength = 0;
|
||||
this.forEachRange(function (item, key, originalIndex) {
|
||||
if (cb.call(context, item, key, originalIndex)) {
|
||||
var normalizedKey = PREFIX + key;
|
||||
newSet[normalizedKey] = item;
|
||||
newSetLength++;
|
||||
}
|
||||
}, start, length);
|
||||
return new OrderedMapImpl(newSet, newSetLength);
|
||||
},
|
||||
|
||||
forEach: function (cb, context) {
|
||||
this.forEachRange(cb, 0, this.length, context);
|
||||
},
|
||||
|
||||
forEachRange: function (cb, start, length, context) {
|
||||
assertValidRangeIndices(start, length, this.length);
|
||||
var thisSet = this._normalizedObj;
|
||||
var i = 0;
|
||||
var end = start + length - 1;
|
||||
for (var key in thisSet) {
|
||||
if (thisSet.hasOwnProperty(key)) {
|
||||
if (i >= start) {
|
||||
if (i > end) {
|
||||
break;
|
||||
}
|
||||
var item = thisSet[key];
|
||||
cb.call(context, item, key.substr(PREFIX.length), i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Even though `mapRange`/`forEachKeyRange` allow zero length mappings, we'll
|
||||
* impose an additional restriction here that the length of mapping be greater
|
||||
* than zero - the only reason is that there are many ways to express length
|
||||
* zero in terms of two keys and that is confusing.
|
||||
*/
|
||||
mapKeyRange: function (cb, startKey, endKey, context) {
|
||||
var startIndex = this.indexOfKey(startKey);
|
||||
var endIndex = this.indexOfKey(endKey);
|
||||
!(startIndex !== undefined && endIndex !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mapKeyRange must be given keys that are present.') : invariant(false) : undefined;
|
||||
!(endIndex >= startIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.mapKeyRange(...): `endKey` must not come before `startIndex`.') : invariant(false) : undefined;
|
||||
return this.mapRange(cb, startIndex, endIndex - startIndex + 1, context);
|
||||
},
|
||||
|
||||
forEachKeyRange: function (cb, startKey, endKey, context) {
|
||||
var startIndex = this.indexOfKey(startKey);
|
||||
var endIndex = this.indexOfKey(endKey);
|
||||
!(startIndex !== undefined && endIndex !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'forEachKeyRange must be given keys that are present.') : invariant(false) : undefined;
|
||||
!(endIndex >= startIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.forEachKeyRange(...): `endKey` must not come before ' + '`startIndex`.') : invariant(false) : undefined;
|
||||
this.forEachRange(cb, startIndex, endIndex - startIndex + 1, context);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} pos Index to search for key at.
|
||||
* @return {string|undefined} Either the key at index `pos` or undefined if
|
||||
* not in map.
|
||||
*/
|
||||
keyAtIndex: function (pos) {
|
||||
var computedPositions = this._getOrComputePositions();
|
||||
var keyAtPos = computedPositions.keyByIndex[pos];
|
||||
return keyAtPos ? keyAtPos.substr(PREFIX.length) : undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key String key from which to find the next key.
|
||||
* @return {string|undefined} Either the next key, or undefined if there is no
|
||||
* next key.
|
||||
* @throws Error if `key` is not in this `OrderedMap`.
|
||||
*/
|
||||
keyAfter: function (key) {
|
||||
return this.nthKeyAfter(key, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key String key from which to find the preceding key.
|
||||
* @return {string|undefined} Either the preceding key, or undefined if there
|
||||
* is no preceding.key.
|
||||
* @throws Error if `key` is not in this `OrderedMap`.
|
||||
*/
|
||||
keyBefore: function (key) {
|
||||
return this.nthKeyBefore(key, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key String key from which to find a following key.
|
||||
* @param {number} n Distance to scan forward after `key`.
|
||||
* @return {string|undefined} Either the nth key after `key`, or undefined if
|
||||
* there is no next key.
|
||||
* @throws Error if `key` is not in this `OrderedMap`.
|
||||
*/
|
||||
nthKeyAfter: function (key, n) {
|
||||
var curIndex = this.indexOfKey(key);
|
||||
!(curIndex !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.nthKeyAfter: The key `%s` does not exist in this instance.', key) : invariant(false) : undefined;
|
||||
return this.keyAtIndex(curIndex + n);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key String key from which to find a preceding key.
|
||||
* @param {number} n Distance to scan backwards before `key`.
|
||||
* @return {string|undefined} Either the nth key before `key`, or undefined if
|
||||
* there is no previous key.
|
||||
* @throws Error if `key` is not in this `OrderedMap`.
|
||||
*/
|
||||
nthKeyBefore: function (key, n) {
|
||||
return this.nthKeyAfter(key, -n);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} key Key to find the index of.
|
||||
* @return {number|undefined} Index of the provided key, or `undefined` if the
|
||||
* key is not found.
|
||||
*/
|
||||
indexOfKey: function (key) {
|
||||
assertValidPublicKey(key);
|
||||
var normalizedKey = PREFIX + key;
|
||||
var computedPositions = this._getOrComputePositions();
|
||||
var computedPosition = computedPositions.indexByKey[normalizedKey];
|
||||
// Just writing it this way to make it clear this is intentional.
|
||||
return computedPosition === undefined ? undefined : computedPosition;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Array} An ordered array of this object's values.
|
||||
*/
|
||||
toArray: function () {
|
||||
var result = [];
|
||||
var thisSet = this._normalizedObj;
|
||||
for (var key in thisSet) {
|
||||
if (thisSet.hasOwnProperty(key)) {
|
||||
result.push(thisSet[key]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the key at a given position, or indicates via `undefined` that that
|
||||
* position does not exist in the `OrderedMap`. It is appropriate to return
|
||||
* undefined, indicating that the key doesn't exist in the `OrderedMap`
|
||||
* because `undefined` is not ever a valid `OrderedMap` key.
|
||||
*
|
||||
* @private
|
||||
* @return {string?} Name of the item at position `pos`, or `undefined` if
|
||||
* there is no item at that position.
|
||||
*/
|
||||
_getOrComputePositions: function () {
|
||||
// TODO: Entertain computing this at construction time in some less
|
||||
// performance critical paths.
|
||||
var computedPositions = this._computedPositions;
|
||||
if (!computedPositions) {
|
||||
this._computePositions();
|
||||
}
|
||||
return this._computedPositions;
|
||||
},
|
||||
|
||||
/**
|
||||
* Precomputes the index/key mapping for future lookup. Since `OrderedMap`s
|
||||
* are immutable, there is only ever a need to perform this once.
|
||||
* @private
|
||||
*/
|
||||
_computePositions: function () {
|
||||
this._computedPositions = {
|
||||
keyByIndex: {},
|
||||
indexByKey: {}
|
||||
};
|
||||
var keyByIndex = this._computedPositions.keyByIndex;
|
||||
var indexByKey = this._computedPositions.indexByKey;
|
||||
var index = 0;
|
||||
var thisSet = this._normalizedObj;
|
||||
for (var key in thisSet) {
|
||||
if (thisSet.hasOwnProperty(key)) {
|
||||
keyByIndex[index] = key;
|
||||
indexByKey[key] = index;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assign(OrderedMapImpl.prototype, OrderedMapMethods);
|
||||
|
||||
var OrderedMap = {
|
||||
from: function (orderedMap) {
|
||||
!(orderedMap instanceof OrderedMapImpl) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.from(...): Expected an OrderedMap instance.') : invariant(false) : undefined;
|
||||
return _fromNormalizedObjects(orderedMap._normalizedObj, null);
|
||||
},
|
||||
|
||||
fromArray: function (arr, keyExtractor) {
|
||||
!Array.isArray(arr) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.fromArray(...): First argument must be an array.') : invariant(false) : undefined;
|
||||
!(typeof keyExtractor === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'OrderedMap.fromArray(...): Second argument must be a function used ' + 'to determine the unique key for each entry.') : invariant(false) : undefined;
|
||||
return new OrderedMapImpl(extractObjectFromArray(arr, keyExtractor), arr.length);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = OrderedMap;
|
||||
119
old_major_packages/14/react/lib/PooledClass.js
Normal file
119
old_major_packages/14/react/lib/PooledClass.js
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* Copyright 2013-2015, 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 PooledClass
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
/**
|
||||
* Static poolers. Several custom versions for each potential number of
|
||||
* arguments. A completely generic pooler is easy to implement, but would
|
||||
* require accessing the `arguments` object. In each of these, `this` refers to
|
||||
* the Class itself, not an instance. If any others are needed, simply add them
|
||||
* here, or in their own files.
|
||||
*/
|
||||
var oneArgumentPooler = function (copyFieldsFrom) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, copyFieldsFrom);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(copyFieldsFrom);
|
||||
}
|
||||
};
|
||||
|
||||
var twoArgumentPooler = function (a1, a2) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(a1, a2);
|
||||
}
|
||||
};
|
||||
|
||||
var threeArgumentPooler = function (a1, a2, a3) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(a1, a2, a3);
|
||||
}
|
||||
};
|
||||
|
||||
var fourArgumentPooler = function (a1, a2, a3, a4) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3, a4);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(a1, a2, a3, a4);
|
||||
}
|
||||
};
|
||||
|
||||
var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
|
||||
var Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3, a4, a5);
|
||||
return instance;
|
||||
} else {
|
||||
return new Klass(a1, a2, a3, a4, a5);
|
||||
}
|
||||
};
|
||||
|
||||
var standardReleaser = function (instance) {
|
||||
var Klass = this;
|
||||
!(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined;
|
||||
instance.destructor();
|
||||
if (Klass.instancePool.length < Klass.poolSize) {
|
||||
Klass.instancePool.push(instance);
|
||||
}
|
||||
};
|
||||
|
||||
var DEFAULT_POOL_SIZE = 10;
|
||||
var DEFAULT_POOLER = oneArgumentPooler;
|
||||
|
||||
/**
|
||||
* Augments `CopyConstructor` to be a poolable class, augmenting only the class
|
||||
* itself (statically) not adding any prototypical fields. Any CopyConstructor
|
||||
* you give this may have a `poolSize` property, and will look for a
|
||||
* prototypical `destructor` on instances (optional).
|
||||
*
|
||||
* @param {Function} CopyConstructor Constructor that can be used to reset.
|
||||
* @param {Function} pooler Customizable pooler.
|
||||
*/
|
||||
var addPoolingTo = function (CopyConstructor, pooler) {
|
||||
var NewKlass = CopyConstructor;
|
||||
NewKlass.instancePool = [];
|
||||
NewKlass.getPooled = pooler || DEFAULT_POOLER;
|
||||
if (!NewKlass.poolSize) {
|
||||
NewKlass.poolSize = DEFAULT_POOL_SIZE;
|
||||
}
|
||||
NewKlass.release = standardReleaser;
|
||||
return NewKlass;
|
||||
};
|
||||
|
||||
var PooledClass = {
|
||||
addPoolingTo: addPoolingTo,
|
||||
oneArgumentPooler: oneArgumentPooler,
|
||||
twoArgumentPooler: twoArgumentPooler,
|
||||
threeArgumentPooler: threeArgumentPooler,
|
||||
fourArgumentPooler: fourArgumentPooler,
|
||||
fiveArgumentPooler: fiveArgumentPooler
|
||||
};
|
||||
|
||||
module.exports = PooledClass;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user