diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/react-dom/cjs/react-dom-test-utils.development.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/react-dom/cjs/react-dom-test-utils.development.js')
-rw-r--r-- | node_modules/react-dom/cjs/react-dom-test-utils.development.js | 745 |
1 files changed, 256 insertions, 489 deletions
diff --git a/node_modules/react-dom/cjs/react-dom-test-utils.development.js b/node_modules/react-dom/cjs/react-dom-test-utils.development.js index 47890324e..7296e0eab 100644 --- a/node_modules/react-dom/cjs/react-dom-test-utils.development.js +++ b/node_modules/react-dom/cjs/react-dom-test-utils.development.js @@ -1,4 +1,4 @@ -/** @license React v16.0.0 +/** @license React v16.2.0 * react-dom-test-utils.development.js * * Copyright (c) 2013-present, Facebook, Inc. @@ -6,210 +6,28 @@ * 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() { +if (process.env.NODE_ENV !== "production") { + (function() { 'use strict'; var _assign = require('object-assign'); -var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); -var react = require('react'); -var reactDom = require('react-dom'); +var React = require('react'); +var ReactDOM = require('react-dom'); var invariant = require('fbjs/lib/invariant'); var warning = require('fbjs/lib/warning'); var emptyFunction = require('fbjs/lib/emptyFunction'); +var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); /** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule reactProdInvariant - * - */ - -/** - * Generate a mapping of standard vendor prefixes using the defined style property and event name. - * - * @param {string} styleProp - * @param {string} eventName - * @returns {object} - */ -function makePrefixMap(styleProp, eventName) { - var prefixes = {}; - - prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); - prefixes['Webkit' + styleProp] = 'webkit' + eventName; - prefixes['Moz' + styleProp] = 'moz' + eventName; - prefixes['ms' + styleProp] = 'MS' + eventName; - prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); - - return prefixes; -} - -/** - * A list of event names to a configurable list of vendor prefixes. - */ -var vendorPrefixes = { - animationend: makePrefixMap('Animation', 'AnimationEnd'), - animationiteration: makePrefixMap('Animation', 'AnimationIteration'), - animationstart: makePrefixMap('Animation', 'AnimationStart'), - transitionend: makePrefixMap('Transition', 'TransitionEnd') -}; - -/** - * Event names that have already been detected and prefixed (if applicable). - */ -var prefixedEventNames = {}; - -/** - * Element to check for prefixes on. - */ -var style = {}; - -/** - * Bootstrap if a DOM exists. - */ -if (ExecutionEnvironment.canUseDOM) { - style = document.createElement('div').style; - - // On some platforms, in particular some releases of Android 4.x, - // the un-prefixed "animation" and "transition" properties are defined on the - // style object but the events that fire will still be prefixed, so we need - // to check if the un-prefixed events are usable, and if not remove them from the map. - if (!('AnimationEvent' in window)) { - delete vendorPrefixes.animationend.animation; - delete vendorPrefixes.animationiteration.animation; - delete vendorPrefixes.animationstart.animation; - } - - // Same as above - if (!('TransitionEvent' in window)) { - delete vendorPrefixes.transitionend.transition; - } -} - -/** - * Attempts to determine the correct vendor prefixed event name. - * - * @param {string} eventName - * @returns {string} - */ -function getVendorPrefixedEventName(eventName) { - if (prefixedEventNames[eventName]) { - return prefixedEventNames[eventName]; - } else if (!vendorPrefixes[eventName]) { - return eventName; - } - - var prefixMap = vendorPrefixes[eventName]; - - for (var styleProp in prefixMap) { - if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { - return prefixedEventNames[eventName] = prefixMap[styleProp]; - } - } - - return ''; -} - -var getVendorPrefixedEventName_1 = getVendorPrefixedEventName; - -/** - * Types of raw signals from the browser caught at the top level. - * - * For events like 'submit' which don't consistently bubble (which we - * trap at a lower node than `document`), binding at `document` would - * cause duplicate events so we don't include them here. - */ -var topLevelTypes$1 = { - topAbort: 'abort', - topAnimationEnd: getVendorPrefixedEventName_1('animationend') || 'animationend', - topAnimationIteration: getVendorPrefixedEventName_1('animationiteration') || 'animationiteration', - topAnimationStart: getVendorPrefixedEventName_1('animationstart') || 'animationstart', - topBlur: 'blur', - topCancel: 'cancel', - topCanPlay: 'canplay', - topCanPlayThrough: 'canplaythrough', - topChange: 'change', - topClick: 'click', - topClose: 'close', - topCompositionEnd: 'compositionend', - topCompositionStart: 'compositionstart', - topCompositionUpdate: 'compositionupdate', - topContextMenu: 'contextmenu', - topCopy: 'copy', - topCut: 'cut', - topDoubleClick: 'dblclick', - topDrag: 'drag', - topDragEnd: 'dragend', - topDragEnter: 'dragenter', - topDragExit: 'dragexit', - topDragLeave: 'dragleave', - topDragOver: 'dragover', - topDragStart: 'dragstart', - topDrop: 'drop', - topDurationChange: 'durationchange', - topEmptied: 'emptied', - topEncrypted: 'encrypted', - topEnded: 'ended', - topError: 'error', - topFocus: 'focus', - topInput: 'input', - topKeyDown: 'keydown', - topKeyPress: 'keypress', - topKeyUp: 'keyup', - topLoadedData: 'loadeddata', - topLoad: 'load', - topLoadedMetadata: 'loadedmetadata', - topLoadStart: 'loadstart', - topMouseDown: 'mousedown', - topMouseMove: 'mousemove', - topMouseOut: 'mouseout', - topMouseOver: 'mouseover', - topMouseUp: 'mouseup', - topPaste: 'paste', - topPause: 'pause', - topPlay: 'play', - topPlaying: 'playing', - topProgress: 'progress', - topRateChange: 'ratechange', - topScroll: 'scroll', - topSeeked: 'seeked', - topSeeking: 'seeking', - topSelectionChange: 'selectionchange', - topStalled: 'stalled', - topSuspend: 'suspend', - topTextInput: 'textInput', - topTimeUpdate: 'timeupdate', - topToggle: 'toggle', - topTouchCancel: 'touchcancel', - topTouchEnd: 'touchend', - topTouchMove: 'touchmove', - topTouchStart: 'touchstart', - topTransitionEnd: getVendorPrefixedEventName_1('transitionend') || 'transitionend', - topVolumeChange: 'volumechange', - topWaiting: 'waiting', - topWheel: 'wheel' -}; - -var BrowserEventConstants = { - topLevelTypes: topLevelTypes$1 -}; - -var BrowserEventConstants_1 = BrowserEventConstants; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule ReactInstanceMap + * WARNING: DO NOT manually require this module. + * This is a replacement for `invariant(...)` used by the error code system + * and will _only_ be required by the corresponding babel pass. + * It always throws. */ /** @@ -217,148 +35,48 @@ var BrowserEventConstants_1 = BrowserEventConstants; * instance (key) and the internal representation (value). This allows public * methods to accept the user facing instance as an argument and map them back * to internal methods. - */ - -// TODO: Replace this with ES6: var ReactInstanceMap = new Map(); - -var ReactInstanceMap = { - /** - * This API should be called `delete` but we'd have to make sure to always - * transform these to strings for IE support. When this transform is fully - * supported we can rename it. - */ - remove: function (key) { - key._reactInternalFiber = undefined; - }, - - get: function (key) { - return key._reactInternalFiber; - }, - - has: function (key) { - return key._reactInternalFiber !== undefined; - }, - - set: function (key, value) { - key._reactInternalFiber = value; - } -}; - -var ReactInstanceMap_1 = ReactInstanceMap; - -var ReactInternals = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - -var ReactGlobalSharedState = { - ReactCurrentOwner: ReactInternals.ReactCurrentOwner -}; - -{ - _assign(ReactGlobalSharedState, { - ReactComponentTreeHook: ReactInternals.ReactComponentTreeHook, - ReactDebugCurrentFrame: ReactInternals.ReactDebugCurrentFrame - }); -} - -var ReactGlobalSharedState_1 = ReactGlobalSharedState; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. * - * @providesModule getComponentName - * + * Note that this module is currently shared and assumed to be stateless. + * If this becomes an actual Map, that will break. */ -function getComponentName(instanceOrFiber) { - if (typeof instanceOrFiber.getName === 'function') { - // Stack reconciler - var instance = instanceOrFiber; - return instance.getName(); - } - if (typeof instanceOrFiber.tag === 'number') { - // Fiber reconciler - var fiber = instanceOrFiber; - var type = fiber.type; - - if (typeof type === 'string') { - return type; - } - if (typeof type === 'function') { - return type.displayName || type.name; - } - } - return null; -} - -var getComponentName_1 = getComponentName; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule ReactTypeOfWork - * - */ - -var ReactTypeOfWork = { - IndeterminateComponent: 0, // Before we know whether it is functional or class - FunctionalComponent: 1, - ClassComponent: 2, - HostRoot: 3, // Root of a host tree. Could be nested inside another node. - HostPortal: 4, // A subtree. Could be an entry point to a different renderer. - HostComponent: 5, - HostText: 6, - CoroutineComponent: 7, - CoroutineHandlerPhase: 8, - YieldComponent: 9, - Fragment: 10 -}; - /** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule ReactTypeOfSideEffect - * + * This API should be called `delete` but we'd have to make sure to always + * transform these to strings for IE support. When this transform is fully + * supported we can rename it. */ -var ReactTypeOfSideEffect = { - // Don't change these two values: - NoEffect: 0, // 0b00000000 - PerformedWork: 1, // 0b00000001 - // You can change the rest (and add more). - Placement: 2, // 0b00000010 - Update: 4, // 0b00000100 - PlacementAndUpdate: 6, // 0b00000110 - Deletion: 8, // 0b00001000 - ContentReset: 16, // 0b00010000 - Callback: 32, // 0b00100000 - Err: 64, // 0b01000000 - Ref: 128 }; -var ReactCurrentOwner = ReactGlobalSharedState_1.ReactCurrentOwner; - - - - -{ - var warning$1 = warning; +function get(key) { + return key._reactInternalFiber; } -var ClassComponent$1 = ReactTypeOfWork.ClassComponent; -var HostComponent$1 = ReactTypeOfWork.HostComponent; -var HostRoot = ReactTypeOfWork.HostRoot; -var HostPortal = ReactTypeOfWork.HostPortal; -var HostText$1 = ReactTypeOfWork.HostText; - -var NoEffect = ReactTypeOfSideEffect.NoEffect; -var Placement = ReactTypeOfSideEffect.Placement; +var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +var ReactCurrentOwner = ReactInternals.ReactCurrentOwner; +var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame; + +// Before we know whether it is functional or class +var FunctionalComponent = 1; +var ClassComponent = 2; +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + // A subtree. Could be an entry point to a different renderer. +var HostComponent = 5; +var HostText = 6; + +// Don't change these two values: +var NoEffect = 0; // 0b00000000 + // 0b00000001 + +// You can change the rest (and add more). +var Placement = 2; // 0b00000010 + // 0b00000100 + // 0b00000110 + // 0b00001000 + // 0b00010000 + // 0b00100000 + // 0b01000000 + // 0b10000000 var MOUNTING = 1; var MOUNTED = 2; @@ -392,27 +110,10 @@ function isFiberMountedImpl(fiber) { // that has been unmounted. return UNMOUNTED; } -var isFiberMounted = function (fiber) { - return isFiberMountedImpl(fiber) === MOUNTED; -}; -var isMounted = function (component) { - { - var owner = ReactCurrentOwner.current; - if (owner !== null && owner.tag === ClassComponent$1) { - var ownerFiber = owner; - var instance = ownerFiber.stateNode; - warning$1(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName_1(ownerFiber) || 'A component'); - instance._warnedAboutRefsInRender = true; - } - } - var fiber = ReactInstanceMap_1.get(component); - if (!fiber) { - return false; - } - return isFiberMountedImpl(fiber) === MOUNTED; -}; + + function assertIsMounted(fiber) { !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; @@ -529,90 +230,13 @@ function findCurrentFiberUsingSlowPath(fiber) { // Otherwise B has to be current branch. return alternate; } -var findCurrentFiberUsingSlowPath_1 = findCurrentFiberUsingSlowPath; - -var findCurrentHostFiber = function (parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - if (!currentParent) { - return null; - } - - // Next we'll drill down this component to find the first HostComponent/Text. - var node = currentParent; - while (true) { - if (node.tag === HostComponent$1 || node.tag === HostText$1) { - return node; - } else if (node.child) { - node.child['return'] = node; - node = node.child; - continue; - } - if (node === currentParent) { - return null; - } - while (!node.sibling) { - if (!node['return'] || node['return'] === currentParent) { - return null; - } - node = node['return']; - } - node.sibling['return'] = node['return']; - node = node.sibling; - } - // Flow needs the return null here, but ESLint complains about it. - // eslint-disable-next-line no-unreachable - return null; -}; -var findCurrentHostFiberWithNoPortals = function (parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - if (!currentParent) { - return null; - } - - // Next we'll drill down this component to find the first HostComponent/Text. - var node = currentParent; - while (true) { - if (node.tag === HostComponent$1 || node.tag === HostText$1) { - return node; - } else if (node.child && node.tag !== HostPortal) { - node.child['return'] = node; - node = node.child; - continue; - } - if (node === currentParent) { - return null; - } - while (!node.sibling) { - if (!node['return'] || node['return'] === currentParent) { - return null; - } - node = node['return']; - } - node.sibling['return'] = node['return']; - node = node.sibling; - } - // Flow needs the return null here, but ESLint complains about it. - // eslint-disable-next-line no-unreachable - return null; -}; - -var ReactFiberTreeReflection = { - isFiberMounted: isFiberMounted, - isMounted: isMounted, - findCurrentFiberUsingSlowPath: findCurrentFiberUsingSlowPath_1, - findCurrentHostFiber: findCurrentHostFiber, - findCurrentHostFiberWithNoPortals: findCurrentHostFiberWithNoPortals -}; +/* eslint valid-typeof: 0 */ var didWarnForAddedNewProperty = false; var isProxySupported = typeof Proxy === 'function'; var EVENT_POOL_SIZE = 10; -{ - var warning$2 = warning; -} - var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; /** @@ -792,9 +416,9 @@ SyntheticEvent.augmentClass = function (Class, Interface) { }; /** Proxying after everything set on SyntheticEvent - * to resolve Proxy issue on some WebKit browsers - * in which some Event properties are set to undefined (GH#10010) - */ + * to resolve Proxy issue on some WebKit browsers + * in which some Event properties are set to undefined (GH#10010) + */ { if (isProxySupported) { /*eslint-disable no-func-assign */ @@ -806,7 +430,7 @@ SyntheticEvent.augmentClass = function (Class, Interface) { return new Proxy(constructor.apply(that, args), { set: function (target, prop, value) { if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { - warning$2(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); + warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); didWarnForAddedNewProperty = true; } target[prop] = value; @@ -821,15 +445,13 @@ SyntheticEvent.augmentClass = function (Class, Interface) { addEventPoolingTo(SyntheticEvent); -var SyntheticEvent_1 = SyntheticEvent; - /** - * Helper to nullify syntheticEvent instance properties when destructing - * - * @param {String} propName - * @param {?object} getVal - * @return {object} defineProperty object - */ + * Helper to nullify syntheticEvent instance properties when destructing + * + * @param {String} propName + * @param {?object} getVal + * @return {object} defineProperty object + */ function getPooledWarningPropertyDefinition(propName, getVal) { var isFunction = typeof getVal === 'function'; return { @@ -853,7 +475,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { function warn(action, result) { var warningCondition = false; - warning$2(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); + warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); } } @@ -882,8 +504,177 @@ function addEventPoolingTo(EventConstructor) { EventConstructor.release = releasePooledEvent; } -var findDOMNode = reactDom.findDOMNode; -var _ReactDOM$__SECRET_IN = reactDom.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +var SyntheticEvent$1 = SyntheticEvent; + +/** + * Generate a mapping of standard vendor prefixes using the defined style property and event name. + * + * @param {string} styleProp + * @param {string} eventName + * @returns {object} + */ +function makePrefixMap(styleProp, eventName) { + var prefixes = {}; + + prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); + prefixes['Webkit' + styleProp] = 'webkit' + eventName; + prefixes['Moz' + styleProp] = 'moz' + eventName; + prefixes['ms' + styleProp] = 'MS' + eventName; + prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); + + return prefixes; +} + +/** + * A list of event names to a configurable list of vendor prefixes. + */ +var vendorPrefixes = { + animationend: makePrefixMap('Animation', 'AnimationEnd'), + animationiteration: makePrefixMap('Animation', 'AnimationIteration'), + animationstart: makePrefixMap('Animation', 'AnimationStart'), + transitionend: makePrefixMap('Transition', 'TransitionEnd') +}; + +/** + * Event names that have already been detected and prefixed (if applicable). + */ +var prefixedEventNames = {}; + +/** + * Element to check for prefixes on. + */ +var style = {}; + +/** + * Bootstrap if a DOM exists. + */ +if (ExecutionEnvironment.canUseDOM) { + style = document.createElement('div').style; + + // On some platforms, in particular some releases of Android 4.x, + // the un-prefixed "animation" and "transition" properties are defined on the + // style object but the events that fire will still be prefixed, so we need + // to check if the un-prefixed events are usable, and if not remove them from the map. + if (!('AnimationEvent' in window)) { + delete vendorPrefixes.animationend.animation; + delete vendorPrefixes.animationiteration.animation; + delete vendorPrefixes.animationstart.animation; + } + + // Same as above + if (!('TransitionEvent' in window)) { + delete vendorPrefixes.transitionend.transition; + } +} + +/** + * Attempts to determine the correct vendor prefixed event name. + * + * @param {string} eventName + * @returns {string} + */ +function getVendorPrefixedEventName(eventName) { + if (prefixedEventNames[eventName]) { + return prefixedEventNames[eventName]; + } else if (!vendorPrefixes[eventName]) { + return eventName; + } + + var prefixMap = vendorPrefixes[eventName]; + + for (var styleProp in prefixMap) { + if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { + return prefixedEventNames[eventName] = prefixMap[styleProp]; + } + } + + return ''; +} + +/** + * Types of raw signals from the browser caught at the top level. + * + * For events like 'submit' which don't consistently bubble (which we + * trap at a lower node than `document`), binding at `document` would + * cause duplicate events so we don't include them here. + */ +var topLevelTypes$1 = { + topAbort: 'abort', + topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend', + topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration', + topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart', + topBlur: 'blur', + topCancel: 'cancel', + topCanPlay: 'canplay', + topCanPlayThrough: 'canplaythrough', + topChange: 'change', + topClick: 'click', + topClose: 'close', + topCompositionEnd: 'compositionend', + topCompositionStart: 'compositionstart', + topCompositionUpdate: 'compositionupdate', + topContextMenu: 'contextmenu', + topCopy: 'copy', + topCut: 'cut', + topDoubleClick: 'dblclick', + topDrag: 'drag', + topDragEnd: 'dragend', + topDragEnter: 'dragenter', + topDragExit: 'dragexit', + topDragLeave: 'dragleave', + topDragOver: 'dragover', + topDragStart: 'dragstart', + topDrop: 'drop', + topDurationChange: 'durationchange', + topEmptied: 'emptied', + topEncrypted: 'encrypted', + topEnded: 'ended', + topError: 'error', + topFocus: 'focus', + topInput: 'input', + topKeyDown: 'keydown', + topKeyPress: 'keypress', + topKeyUp: 'keyup', + topLoadedData: 'loadeddata', + topLoad: 'load', + topLoadedMetadata: 'loadedmetadata', + topLoadStart: 'loadstart', + topMouseDown: 'mousedown', + topMouseMove: 'mousemove', + topMouseOut: 'mouseout', + topMouseOver: 'mouseover', + topMouseUp: 'mouseup', + topPaste: 'paste', + topPause: 'pause', + topPlay: 'play', + topPlaying: 'playing', + topProgress: 'progress', + topRateChange: 'ratechange', + topScroll: 'scroll', + topSeeked: 'seeked', + topSeeking: 'seeking', + topSelectionChange: 'selectionchange', + topStalled: 'stalled', + topSuspend: 'suspend', + topTextInput: 'textInput', + topTimeUpdate: 'timeupdate', + topToggle: 'toggle', + topTouchCancel: 'touchcancel', + topTouchEnd: 'touchend', + topTouchMove: 'touchmove', + topTouchStart: 'touchstart', + topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend', + topVolumeChange: 'volumechange', + topWaiting: 'waiting', + topWheel: 'wheel' +}; + +var BrowserEventConstants = { + topLevelTypes: topLevelTypes$1 +}; + +var findDOMNode = ReactDOM.findDOMNode; +var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; var EventPluginHub = _ReactDOM$__SECRET_IN.EventPluginHub; var EventPluginRegistry = _ReactDOM$__SECRET_IN.EventPluginRegistry; var EventPropagators = _ReactDOM$__SECRET_IN.EventPropagators; @@ -892,12 +683,7 @@ var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree; var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener; -var topLevelTypes = BrowserEventConstants_1.topLevelTypes; -var ClassComponent = ReactTypeOfWork.ClassComponent; -var FunctionalComponent = ReactTypeOfWork.FunctionalComponent; -var HostComponent = ReactTypeOfWork.HostComponent; -var HostText = ReactTypeOfWork.HostText; - +var topLevelTypes = BrowserEventConstants.topLevelTypes; function Event(suffix) {} @@ -905,33 +691,11 @@ function Event(suffix) {} * @class ReactTestUtils */ -function findAllInRenderedStackTreeInternal(inst, test) { - if (!inst || !inst.getPublicInstance) { - return []; - } - var publicInst = inst.getPublicInstance(); - var ret = test(publicInst) ? [publicInst] : []; - var currentElement = inst._currentElement; - if (ReactTestUtils.isDOMComponent(publicInst)) { - var renderedChildren = inst._renderedChildren; - var key; - for (key in renderedChildren) { - if (!renderedChildren.hasOwnProperty(key)) { - continue; - } - ret = ret.concat(findAllInRenderedStackTreeInternal(renderedChildren[key], test)); - } - } else if (react.isValidElement(currentElement) && typeof currentElement.type === 'function') { - ret = ret.concat(findAllInRenderedStackTreeInternal(inst._renderedComponent, test)); - } - return ret; -} - function findAllInRenderedFiberTreeInternal(fiber, test) { if (!fiber) { return []; } - var currentParent = ReactFiberTreeReflection.findCurrentFiberUsingSlowPath(fiber); + var currentParent = findCurrentFiberUsingSlowPath(fiber); if (!currentParent) { return []; } @@ -966,7 +730,7 @@ function findAllInRenderedFiberTreeInternal(fiber, test) { /** * Utilities for making it easy to test React components. * - * See https://facebook.github.io/react/docs/test-utils.html + * See https://reactjs.org/docs/test-utils.html * * Todo: Support the entire DOM.scry query syntax. For now, these simple * utilities will suffice for testing purposes. @@ -980,15 +744,15 @@ var ReactTestUtils = { // clean up, so we're going to stop honoring the name of this method // (and probably rename it eventually) if no problems arise. // document.documentElement.appendChild(div); - return reactDom.render(element, div); + return ReactDOM.render(element, div); }, isElement: function (element) { - return react.isValidElement(element); + return React.isValidElement(element); }, isElementOfType: function (inst, convenienceConstructor) { - return react.isValidElement(inst) && inst.type === convenienceConstructor; + return React.isValidElement(inst) && inst.type === convenienceConstructor; }, isDOMComponent: function (inst) { @@ -996,7 +760,7 @@ var ReactTestUtils = { }, isDOMComponentElement: function (inst) { - return !!(inst && react.isValidElement(inst) && !!inst.tagName); + return !!(inst && React.isValidElement(inst) && !!inst.tagName); }, isCompositeComponent: function (inst) { @@ -1012,10 +776,8 @@ var ReactTestUtils = { if (!ReactTestUtils.isCompositeComponent(inst)) { return false; } - var internalInstance = ReactInstanceMap_1.get(inst); - var constructor = typeof internalInstance.tag === 'number' ? internalInstance.type // Fiber reconciler - : internalInstance._currentElement.type; // Stack reconciler - + var internalInstance = get(inst); + var constructor = internalInstance.type; return constructor === type; }, @@ -1024,12 +786,8 @@ var ReactTestUtils = { return []; } !ReactTestUtils.isCompositeComponent(inst) ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : void 0; - var internalInstance = ReactInstanceMap_1.get(inst); - if (internalInstance && typeof internalInstance.tag === 'number') { - return findAllInRenderedFiberTreeInternal(internalInstance, test); - } else { - return findAllInRenderedStackTreeInternal(internalInstance, test); - } + var internalInstance = get(inst); + return findAllInRenderedFiberTreeInternal(internalInstance, test); }, /** @@ -1139,7 +897,7 @@ var ReactTestUtils = { mockTagName = mockTagName || module.mockTagName || 'div'; module.prototype.render.mockImplementation(function () { - return react.createElement(mockTagName, null, this.props.children); + return React.createElement(mockTagName, null, this.props.children); }); return this; @@ -1188,7 +946,7 @@ var ReactTestUtils = { */ function makeSimulator(eventType) { return function (domNode, eventData) { - !!react.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0; + !!React.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0; !!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead.') : void 0; var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType]; @@ -1200,7 +958,7 @@ function makeSimulator(eventType) { // We don't use SyntheticEvent.getPooled in order to not have to worry about // properly destroying any properties assigned from `eventData` upon release var targetInst = ReactDOMComponentTree.getInstanceFromNode(domNode); - var event = new SyntheticEvent_1(dispatchConfig, targetInst, fakeNativeEvent, domNode); + var event = new SyntheticEvent$1(dispatchConfig, targetInst, fakeNativeEvent, domNode); // Since we aren't using pooling, always persist the event. This will make // sure it's marked and won't warn when setting additional properties. @@ -1213,7 +971,7 @@ function makeSimulator(eventType) { EventPropagators.accumulateDirectDispatches(event); } - reactDom.unstable_batchedUpdates(function () { + ReactDOM.unstable_batchedUpdates(function () { // Normally extractEvent enqueues a state restore, but we'll just always // do that since we we're by-passing it here. ReactControlledComponent.enqueueStateRestore(domNode); @@ -1290,9 +1048,18 @@ Object.keys(topLevelTypes).forEach(function (eventType) { ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType); }); -var ReactTestUtilsEntry = ReactTestUtils; -module.exports = ReactTestUtilsEntry; -})(); +var ReactTestUtils$2 = Object.freeze({ + default: ReactTestUtils +}); + +var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2; + +// TODO: decide on the top-level export form. +// This is hacky but makes it work with both Rollup and Jest. +var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3; + +module.exports = testUtils; + })(); } |