UNPKG

12.1 kBJavaScriptView Raw
1/** @license React v16.9.0-rc.0
2 * react-test-renderer-shallow.production.min.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';var k=require("object-assign"),l=require("react"),m=require("react-is"),n=require("prop-types/checkPropTypes");function p(a){for(var b=a.message,d="https://reactjs.org/docs/error-decoder.html?invariant="+b,c=1;c<arguments.length;c++)d+="&args[]="+encodeURIComponent(arguments[c]);a.message="Minified React error #"+b+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ";return a}
11var q=/^(.*)[\\\/]/,r="function"===typeof Symbol&&Symbol.for,t=r?Symbol.for("react.portal"):60106,u=r?Symbol.for("react.fragment"):60107,v=r?Symbol.for("react.strict_mode"):60108,w=r?Symbol.for("react.profiler"):60114,x=r?Symbol.for("react.provider"):60109,y=r?Symbol.for("react.context"):60110,z=r?Symbol.for("react.forward_ref"):60112,A=r?Symbol.for("react.suspense"):60113,B=r?Symbol.for("react.suspense_list"):60120,C=r?Symbol.for("react.memo"):60115,D=r?Symbol.for("react.lazy"):60116;
12function E(a){if(null==a)return null;if("function"===typeof a)return a.displayName||a.name||null;if("string"===typeof a)return a;switch(a){case u:return"Fragment";case t:return"Portal";case w:return"Profiler";case v:return"StrictMode";case A:return"Suspense";case B:return"SuspenseList"}if("object"===typeof a)switch(a.$$typeof){case y:return"Context.Consumer";case x:return"Context.Provider";case z:var b=a.render;b=b.displayName||b.name||"";return a.displayName||(""!==b?"ForwardRef("+b+")":"ForwardRef");
13case C:return E(a.type);case D:if(a=1===a._status?a._result:null)return E(a)}return null}function F(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var G=Object.prototype.hasOwnProperty;function H(a,b){if(F(a,b))return!0;if("object"!==typeof a||null===a||"object"!==typeof b||null===b)return!1;var d=Object.keys(a),c=Object.keys(b);if(d.length!==c.length)return!1;for(c=0;c<d.length;c++)if(!G.call(b,d[c])||!F(a[d[c]],b[d[c]]))return!1;return!0}var I=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
14I.hasOwnProperty("ReactCurrentDispatcher")||(I.ReactCurrentDispatcher={current:null});I.hasOwnProperty("ReactCurrentBatchConfig")||(I.ReactCurrentBatchConfig={suspense:null});function J(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}
15var K=I.ReactCurrentDispatcher,L={},M=function(){function a(b){J(this,a);this._renderer=b;this._callbacks=[]}a.prototype._enqueueCallback=function(b,a){"function"===typeof b&&a&&this._callbacks.push({callback:b,publicInstance:a})};a.prototype._invokeCallbacks=function(){var b=this._callbacks;this._callbacks=[];b.forEach(function(b){b.callback.call(b.publicInstance)})};a.prototype.isMounted=function(){return!!this._renderer._element};a.prototype.enqueueForceUpdate=function(b,a){this._enqueueCallback(a,
16b);this._renderer._forcedUpdate=!0;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueReplaceState=function(b,a,c){this._enqueueCallback(c,b);this._renderer._newState=a;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueSetState=function(b,a,c){this._enqueueCallback(c,b);c=this._renderer._newState||b.state;"function"===typeof a&&(a=a.call(b,c,b.props));null!==a&&void 0!==a&&(this._renderer._newState=k({},c,a),this._renderer.render(this._renderer._element,
17this._renderer._context))};return a}();function N(){return{memoizedState:null,queue:null,next:null}}function O(a,b){return"function"===typeof b?b(a):b}
18var R=function(){function a(){J(this,a);this._reset()}a.prototype._reset=function(){this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new M(this);this._dispatcher=this._createDispatcher();this._firstWorkInProgressHook=this._workInProgressHook=null;this._didScheduleRenderPhaseUpdate=this._isReRender=!1;this._renderPhaseUpdates=null;this._numberOfReRenders=0};a.prototype._validateCurrentlyRenderingComponent=function(){if(!this._rendering||
19this._instance)throw p(Error(321));};a.prototype._createDispatcher=function(){function b(){c._validateCurrentlyRenderingComponent()}function a(b,a,d){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();var f=c._workInProgressHook;if(c._isReRender){d=f.queue;a=d.dispatch;if(0<c._numberOfReRenders){if(null!==c._renderPhaseUpdates){var e=c._renderPhaseUpdates.get(d);if(void 0!==e){c._renderPhaseUpdates.delete(d);d=f.memoizedState;do d=b(d,e.action),e=e.next;while(null!==e);f.memoizedState=
20d;return[d,a]}}return[f.memoizedState,a]}e=f.memoizedState;var g=d.first;if(null!==g){do e=b(e,g.action),g=g.next;while(null!==g);d.first=null;f.memoizedState=e}return[e,a]}b=b===O?"function"===typeof a?a():a:void 0!==d?d(a):a;f.memoizedState=b;b=f.queue={first:null,dispatch:null};b=b.dispatch=c._dispatchAction.bind(c,b);return[f.memoizedState,b]}var c=this;return{readContext:function(b){return b._currentValue},useCallback:function(b){return b},useContext:function(b){c._validateCurrentlyRenderingComponent();
21return b._currentValue},useDebugValue:b,useEffect:b,useImperativeHandle:b,useLayoutEffect:b,useMemo:function(b,a){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();a=void 0!==a?a:null;if(null!==c._workInProgressHook&&null!==c._workInProgressHook.memoizedState){var d=c._workInProgressHook.memoizedState,f=d[1];if(null!==a){a:if(null===f)f=!1;else{for(var e=0;e<f.length&&e<a.length;e++)if(!F(a[e],f[e])){f=!1;break a}f=!0}if(f)return d[0]}}b=b();c._workInProgressHook.memoizedState=
22[b,a];return b},useReducer:a,useRef:function(b){c._validateCurrentlyRenderingComponent();c._createWorkInProgressHook();var a=c._workInProgressHook.memoizedState;return null===a?(b={current:b},c._workInProgressHook.memoizedState=b):a},useState:function(b){return a(O,b)},useResponder:function(b,a){return{props:a,responder:b}}}};a.prototype._dispatchAction=function(b,a){if(!(25>this._numberOfReRenders))throw p(Error(301));if(this._rendering){this._didScheduleRenderPhaseUpdate=!0;a={action:a,next:null};
23var c=this._renderPhaseUpdates;null===c&&(this._renderPhaseUpdates=c=new Map);var d=c.get(b);if(void 0===d)c.set(b,a);else{for(b=d;null!==b.next;)b=b.next;b.next=a}}else{a={action:a,next:null};c=b.first;if(null===c)b.first=a;else{for(;null!==c.next;)c=c.next;c.next=a}this.render(this._element,this._context)}};a.prototype._createWorkInProgressHook=function(){null===this._workInProgressHook?null===this._firstWorkInProgressHook?(this._isReRender=!1,this._firstWorkInProgressHook=this._workInProgressHook=
24N()):(this._isReRender=!0,this._workInProgressHook=this._firstWorkInProgressHook):null===this._workInProgressHook.next?(this._isReRender=!1,this._workInProgressHook=this._workInProgressHook.next=N()):(this._isReRender=!0,this._workInProgressHook=this._workInProgressHook.next);return this._workInProgressHook};a.prototype._finishHooks=function(b,a){this._didScheduleRenderPhaseUpdate?(this._didScheduleRenderPhaseUpdate=!1,this._numberOfReRenders+=1,this._workInProgressHook=null,this._rendering=!1,this.render(b,
25a)):(this._renderPhaseUpdates=this._workInProgressHook=null,this._numberOfReRenders=0)};a.prototype.getMountedInstance=function(){return this._instance};a.prototype.getRenderOutput=function(){return this._rendered};a.prototype.render=function(b){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:L;if(!l.isValidElement(b))throw p(Error(12),"function"===typeof b?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":"");if("string"===typeof b.type)throw p(Error(13),
26b.type);if(!m.isForwardRef(b)&&"function"!==typeof b.type&&!m.isMemo(b.type))throw p(Error(249),Array.isArray(b.type)?"array":null===b.type?"null":typeof b.type);if(!this._rendering){null!=this._element&&this._element.type!==b.type&&this._reset();var c=m.isMemo(b.type)?b.type.type:b.type,f=this._element;this._rendering=!0;this._element=b;var e;if((e=c.contextTypes)&&a){var g={},h;for(h in e)g[h]=a[h];e=g}else e=L;this._context=e;m.isMemo(b.type)&&c.propTypes&&(P=b,n(c.propTypes,b.props,"prop",E(c),
27Q));if(this._instance)this._updateClassComponent(c,b,this._context);else if(c.prototype&&c.prototype.isReactComponent)this._instance=new c(b.props,this._context,this._updater),"function"===typeof c.getDerivedStateFromProps&&(a=c.getDerivedStateFromProps.call(null,b.props,this._instance.state),null!=a&&(this._instance.state=k({},this._instance.state,a))),c.contextTypes&&(P=b,a=(a=this._instance)&&a.constructor,n(c.contextTypes,this._context,"context",c.displayName||a&&a.displayName||c.name||a&&a.name||
28null,Q),P=null),this._mountClassComponent(c,b,this._context);else if(e=!0,m.isMemo(b.type)&&null!==f&&(b.type.compare||H)(f.props,b.props)&&(e=!1),e){f=K.current;K.current=this._dispatcher;try{if(c.$$typeof===m.ForwardRef){if("function"!==typeof c.render)throw p(Error(322),typeof c.render);this._rendered=c.render.call(void 0,b.props,b.ref)}else this._rendered=c(b.props,this._context)}finally{K.current=f}this._finishHooks(b,a)}this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};
29a.prototype.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._reset()};a.prototype._mountClassComponent=function(a,d,c){this._instance.context=c;this._instance.props=d.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)d=this._newState,"function"!==typeof a.getDerivedStateFromProps&&
30"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),d!==this._newState&&(this._instance.state=this._newState||L);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(a,d,c){d=d.props;var b=this._instance.state||L,e=this._instance.props;e!==d&&"function"!==typeof a.getDerivedStateFromProps&&
31"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(d,c),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(d,c));var g=this._newState||b;if("function"===typeof a.getDerivedStateFromProps){var h=a.getDerivedStateFromProps.call(null,d,g);null!=h&&(g=k({},g,h))}h=!0;this._forcedUpdate?(h=!0,this._forcedUpdate=!1):"function"===
32typeof this._instance.shouldComponentUpdate?h=!!this._instance.shouldComponentUpdate(d,g,c):a.prototype&&a.prototype.isPureReactComponent&&(h=!H(e,d)||!H(b,g));h&&"function"!==typeof a.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(d,g,c),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(d,g,c));this._instance.context=
33c;this._instance.props=d;this._instance.state=g;this._newState=null;h&&(this._rendered=this._instance.render())};return a}();R.createRenderer=function(){return new R};var P=null;function S(a){if(null==a)return"#empty";if("string"===typeof a||"number"===typeof a)return"#text";if("string"===typeof a.type)return a.type;a=m.isMemo(a.type)?a.type.type:a.type;return a.displayName||a.name||"Unknown"}
34function Q(){var a="";if(P){var b=S(P),d=P._owner,c=P._source;d=d&&E(d.type);var f="";c?f=" (at "+c.fileName.replace(q,"")+":"+c.lineNumber+")":d&&(f=" (created by "+d+")");a+="\n in "+(b||"Unknown")+f}return a}var T={default:R},U=T&&R||T;module.exports=U.default||U;