react-dom
Version:
React package for working with the DOM.
31 lines (30 loc) • 12 kB
JavaScript
/** @license React vundefined
* react-dom-test-utils.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.
*/
(function(){'use strict';(function(f,r){"object"===typeof exports&&"undefined"!==typeof module?r(exports,require("react-dom")):"function"===typeof define&&define.amd?define(["exports","react","react-dom"],r):(f=f||self,r(f.ReactTestUtils={},f.React,f.ReactDOM))})(this,function(f,r,D){function q(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
function L(a){var b=a,c=a;if(a.alternate)for(;b.return;)b=b.return;else{a=b;do b=a,0!==(b.flags&2050)&&(c=b.return),a=b.return;while(a)}return 3===b.tag?c:null}function M(a){if(L(a)!==a)throw Error(q(188));}function W(a){var b=a.alternate;if(!b){b=L(a);if(null===b)throw Error(q(188));return b!==a?null:a}for(var c=a,d=b;;){var g=c.return;if(null===g)break;var h=g.alternate;if(null===h){d=g.return;if(null!==d){c=d;continue}break}if(g.child===h.child){for(h=g.child;h;){if(h===c)return M(g),a;if(h===
d)return M(g),b;h=h.sibling}throw Error(q(188));}if(c.return!==d.return)c=g,d=h;else{for(var e=!1,m=g.child;m;){if(m===c){e=!0;c=g;d=h;break}if(m===d){e=!0;d=g;c=h;break}m=m.sibling}if(!e){for(m=h.child;m;){if(m===c){e=!0;c=h;d=g;break}if(m===d){e=!0;d=h;c=g;break}m=m.sibling}if(!e)throw Error(q(189));}}if(c.alternate!==d)throw Error(q(190));}if(3!==c.tag)throw Error(q(188));return c.stateNode.current===c?a:b}function E(a){var b=a.keyCode;"charCode"in a?(a=a.charCode,0===a&&13===b&&(a=13)):a=b;10===
a&&(a=13);return 32<=a||13===a?a:0}function y(){return!0}function N(){return!1}function l(a){function b(c,b,g,h,e){this._reactName=c;this._targetInst=g;this.type=b;this.nativeEvent=h;this.target=e;this.currentTarget=null;for(var d in a)a.hasOwnProperty(d)&&(c=a[d],this[d]=c?c(h):h[d]);this.isDefaultPrevented=(null!=h.defaultPrevented?h.defaultPrevented:!1===h.returnValue)?y:N;this.isPropagationStopped=N;return this}k(b.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;
a&&(a.preventDefault?a.preventDefault():"unknown"!==typeof a.returnValue&&(a.returnValue=!1),this.isDefaultPrevented=y)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():"unknown"!==typeof a.cancelBubble&&(a.cancelBubble=!0),this.isPropagationStopped=y)},persist:function(){},isPersistent:y});return b}function X(a){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(a):(a=Y[a])?!!b[a]:!1}function F(a){return X}function Z(a,b,c,d,g,h,e,f,k){w=
!1;z=null;aa.apply(ba,arguments)}function ca(a,b,c,d,g,h,e,f,k){Z.apply(this,arguments);if(w){if(w){var m=z;w=!1;z=null}else throw Error(q(198));A||(A=!0,G=m)}}function da(a){}function ea(a,b){if(!a)return[];a=W(a);if(!a)return[];for(var c=a,d=[];;){if(5===c.tag||6===c.tag||1===c.tag||0===c.tag){var g=c.stateNode;b(g)&&d.push(g)}if(c.child)c.child.return=c,c=c.child;else{if(c===a)return d;for(;!c.sibling;){if(!c.return||c.return===a)return d;c=c.return}c.sibling.return=c.return;c=c.sibling}}}function u(a,
b){if(a&&!a._reactInternals){var c=""+a;a=H(a)?"an array":a&&1===a.nodeType&&a.tagName?"a DOM node":"[object Object]"===c?"object with keys {"+Object.keys(a).join(", ")+"}":c;throw Error(q(286,b,a));}}function B(a){return!(!a||1!==a.nodeType||!a.tagName)}function I(a){return B(a)?!1:null!=a&&"function"===typeof a.render&&"function"===typeof a.setState}function O(a,b){return I(a)?a._reactInternals.type===b:!1}function C(a,b){u(a,"findAllInRenderedTree");return a?ea(a._reactInternals,b):[]}function P(a,
b){u(a,"scryRenderedDOMComponentsWithClass");return C(a,function(a){if(B(a)){var c=a.className;"string"!==typeof c&&(c=a.getAttribute("class")||"");var g=c.split(/\s+/);if(!H(b)){if(void 0===b)throw Error(q(11));b=b.split(/\s+/)}return b.every(function(a){return-1!==g.indexOf(a)})}return!1})}function Q(a,b){u(a,"scryRenderedDOMComponentsWithTag");return C(a,function(a){return B(a)&&a.tagName.toUpperCase()===b.toUpperCase()})}function R(a,b){u(a,"scryRenderedComponentsWithType");return C(a,function(a){return O(a,
b)})}function S(a,b,c){var d=a.type||"unknown-event";a.currentTarget=fa(c);ca(d,b,void 0,a);a.currentTarget=null}function T(a,b,c){for(var d=[];a;){d.push(a);do a=a.return;while(a&&5!==a.tag);a=a?a:null}for(a=d.length;0<a--;)b(d[a],"captured",c);for(a=0;a<d.length;a++)b(d[a],"bubbled",c)}function U(a,b){var c=a.stateNode;if(!c)return null;var d=ha(c);if(!d)return null;c=d[b];a:switch(b){case "onClick":case "onClickCapture":case "onDoubleClick":case "onDoubleClickCapture":case "onMouseDown":case "onMouseDownCapture":case "onMouseMove":case "onMouseMoveCapture":case "onMouseUp":case "onMouseUpCapture":case "onMouseEnter":(d=
!d.disabled)||(a=a.type,d=!("button"===a||"input"===a||"select"===a||"textarea"===a));a=!d;break a;default:a=!1}if(a)return null;if(c&&"function"!==typeof c)throw Error(q(231,b,typeof c));return c}function ia(a,b,c){a&&c&&c._reactName&&(b=U(a,c._reactName))&&(null==c._dispatchListeners&&(c._dispatchListeners=[]),null==c._dispatchInstances&&(c._dispatchInstances=[]),c._dispatchListeners.push(b),c._dispatchInstances.push(a))}function ja(a,b,c){var d=c._reactName;"captured"===b&&(d+="Capture");if(b=
U(a,d))null==c._dispatchListeners&&(c._dispatchListeners=[]),null==c._dispatchInstances&&(c._dispatchInstances=[]),c._dispatchListeners.push(b),c._dispatchInstances.push(a)}function ka(a){return function(b,c){if(r.isValidElement(b))throw Error(q(228));if(I(b))throw Error(q(229));var d="on"+a[0].toUpperCase()+a.slice(1),g=new da;g.target=b;g.type=a.toLowerCase();var f=la(b),e=new ma(d,g.type,f,g,b);e.persist();k(e,c);na.has(a)?e&&e._reactName&&ia(e._targetInst,null,e):e&&e._reactName&&T(e._targetInst,
ja,e);D.unstable_batchedUpdates(function(){oa(b);if(e){var a=e._dispatchListeners,c=e._dispatchInstances;if(H(a))for(var d=0;d<a.length&&!e.isPropagationStopped();d++)S(e,a[d],c[d]);else a&&S(e,a,c);e._dispatchListeners=null;e._dispatchInstances=null;e.isPersistent()||e.constructor.release(e)}if(A)throw a=G,A=!1,G=null,a;});pa()}}var k=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign,t={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,
isTrusted:0},ma=l(t),v=k({},t,{view:0,detail:0});l(v);var J,K,x,n=k({},v,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:F,button:0,buttons:0,relatedTarget:function(a){return void 0===a.relatedTarget?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){if("movementX"in a)return a.movementX;a!==x&&(x&&"mousemove"===a.type?(J=a.screenX-x.screenX,K=a.screenY-x.screenY):K=J=0,x=a);return J},movementY:function(a){return"movementY"in
a?a.movementY:K}});l(n);var p=k({},n,{dataTransfer:0});l(p);p=k({},v,{relatedTarget:0});l(p);p=k({},t,{animationName:0,elapsedTime:0,pseudoElement:0});l(p);p=k({},t,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}});l(p);p=k({},t,{data:0});l(p);var qa={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ra=
{8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Y={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};p=k({},v,{key:function(a){if(a.key){var b=
qa[a.key]||a.key;if("Unidentified"!==b)return b}return"keypress"===a.type?(a=E(a),13===a?"Enter":String.fromCharCode(a)):"keydown"===a.type||"keyup"===a.type?ra[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:F,charCode:function(a){return"keypress"===a.type?E(a):0},keyCode:function(a){return"keydown"===a.type||"keyup"===a.type?a.keyCode:0},which:function(a){return"keypress"===a.type?E(a):"keydown"===a.type||"keyup"===a.type?
a.keyCode:0}});l(p);p=k({},n,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0});l(p);v=k({},v,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:F});l(v);t=k({},t,{propertyName:0,elapsedTime:0,pseudoElement:0});l(t);n=k({},n,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:
"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0});l(n);var aa=function(a,b,c,d,f,h,e,k,l){var g=Array.prototype.slice.call(arguments,3);try{b.apply(c,g)}catch(sa){this.onError(sa)}},w=!1,z=null,A=!1,G=null,ba={onError:function(a){w=!0;z=a}},H=Array.isArray;n=D.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;var la=n[0],fa=n[1],ha=n[2],oa=n[3],pa=n[4],ta=n[5],ua=r.unstable_act,V={},na=new Set(["mouseEnter","mouseLeave","pointerEnter","pointerLeave"]),va="blur cancel click close contextMenu copy cut auxClick doubleClick dragEnd dragStart drop focus input invalid keyDown keyPress keyUp mouseDown mouseUp paste pause play pointerCancel pointerDown pointerUp rateChange reset seeked submit touchCancel touchEnd touchStart volumeChange drag dragEnter dragExit dragLeave dragOver mouseMove mouseOut mouseOver pointerMove pointerOut pointerOver scroll toggle touchMove wheel abort animationEnd animationIteration animationStart canPlay canPlayThrough durationChange emptied encrypted ended error gotPointerCapture load loadedData loadedMetadata loadStart lostPointerCapture playing progress seeking stalled suspend timeUpdate transitionEnd waiting mouseEnter mouseLeave pointerEnter pointerLeave change select beforeInput compositionEnd compositionStart compositionUpdate".split(" ");
(function(){va.forEach(function(a){V[a]=ka(a)})})();f.Simulate=V;f.act=function(a){return ua(function(){return ta(a)})};f.findAllInRenderedTree=C;f.findRenderedComponentWithType=function(a,b){u(a,"findRenderedComponentWithType");a=R(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+a.length+") for componentType:"+b);return a[0]};f.findRenderedDOMComponentWithClass=function(a,b){u(a,"findRenderedDOMComponentWithClass");a=P(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+
a.length+") for class:"+b);return a[0]};f.findRenderedDOMComponentWithTag=function(a,b){u(a,"findRenderedDOMComponentWithTag");a=Q(a,b);if(1!==a.length)throw Error("Did not find exactly one match (found: "+a.length+") for tag:"+b);return a[0]};f.isCompositeComponent=I;f.isCompositeComponentWithType=O;f.isDOMComponent=B;f.isDOMComponentElement=function(a){return!!(a&&r.isValidElement(a)&&a.tagName)};f.isElement=function(a){return r.isValidElement(a)};f.isElementOfType=function(a,b){return r.isValidElement(a)&&
a.type===b};f.mockComponent=function(a,b){b=b||a.mockTagName||"div";a.prototype.render.mockImplementation(function(){return r.createElement(b,null,this.props.children)});return this};f.nativeTouchData=function(a,b){return{touches:[{pageX:a,pageY:b}]}};f.renderIntoDocument=function(a){var b=document.createElement("div");return D.render(a,b)};f.scryRenderedComponentsWithType=R;f.scryRenderedDOMComponentsWithClass=P;f.scryRenderedDOMComponentsWithTag=Q;f.traverseTwoPhase=T});
})();