You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

react-dom.js 609KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232
  1. /** @license React v16.3.2
  2. * react-dom.development.js
  3. *
  4. * Copyright (c) 2013-present, Facebook, Inc.
  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. 'use strict';
  10. (function (global, factory) {
  11. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
  12. typeof define === 'function' && define.amd ? define(['react'], factory) :
  13. (global.ReactDOM = factory(global.React));
  14. }(this, (function (React) { 'use strict';
  15. /**
  16. * Copyright (c) 2013-present, Facebook, Inc.
  17. *
  18. * This source code is licensed under the MIT license found in the
  19. * LICENSE file in the root directory of this source tree.
  20. *
  21. */
  22. /**
  23. * Use invariant() to assert state which your program assumes to be true.
  24. *
  25. * Provide sprintf-style format (only %s is supported) and arguments
  26. * to provide information about what broke and what you were
  27. * expecting.
  28. *
  29. * The invariant message will be stripped in production, but the invariant
  30. * will remain to ensure logic does not differ in production.
  31. */
  32. var validateFormat = function validateFormat(format) {};
  33. {
  34. validateFormat = function validateFormat(format) {
  35. if (format === undefined) {
  36. throw new Error('invariant requires an error message argument');
  37. }
  38. };
  39. }
  40. function invariant(condition, format, a, b, c, d, e, f) {
  41. validateFormat(format);
  42. if (!condition) {
  43. var error;
  44. if (format === undefined) {
  45. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  46. } else {
  47. var args = [a, b, c, d, e, f];
  48. var argIndex = 0;
  49. error = new Error(format.replace(/%s/g, function () {
  50. return args[argIndex++];
  51. }));
  52. error.name = 'Invariant Violation';
  53. }
  54. error.framesToPop = 1; // we don't care about invariant's own frame
  55. throw error;
  56. }
  57. }
  58. var invariant_1 = invariant;
  59. // Relying on the `invariant()` implementation lets us
  60. // have preserve the format and params in the www builds.
  61. !React ? invariant_1(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0;
  62. var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) {
  63. this._hasCaughtError = false;
  64. this._caughtError = null;
  65. var funcArgs = Array.prototype.slice.call(arguments, 3);
  66. try {
  67. func.apply(context, funcArgs);
  68. } catch (error) {
  69. this._caughtError = error;
  70. this._hasCaughtError = true;
  71. }
  72. };
  73. {
  74. // In DEV mode, we swap out invokeGuardedCallback for a special version
  75. // that plays more nicely with the browser's DevTools. The idea is to preserve
  76. // "Pause on exceptions" behavior. Because React wraps all user-provided
  77. // functions in invokeGuardedCallback, and the production version of
  78. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  79. // like caught exceptions, and the DevTools won't pause unless the developer
  80. // takes the extra step of enabling pause on caught exceptions. This is
  81. // untintuitive, though, because even though React has caught the error, from
  82. // the developer's perspective, the error is uncaught.
  83. //
  84. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  85. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  86. // DOM node, and call the user-provided callback from inside an event handler
  87. // for that fake event. If the callback throws, the error is "captured" using
  88. // a global event handler. But because the error happens in a different
  89. // event loop context, it does not interrupt the normal program flow.
  90. // Effectively, this gives us try-catch behavior without actually using
  91. // try-catch. Neat!
  92. // Check that the browser supports the APIs we need to implement our special
  93. // DEV version of invokeGuardedCallback
  94. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  95. var fakeNode = document.createElement('react');
  96. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  97. // If document doesn't exist we know for sure we will crash in this method
  98. // when we call document.createEvent(). However this can cause confusing
  99. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  100. // So we preemptively throw with a better message instead.
  101. !(typeof document !== 'undefined') ? invariant_1(false, 'The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.') : void 0;
  102. var evt = document.createEvent('Event');
  103. // Keeps track of whether the user-provided callback threw an error. We
  104. // set this to true at the beginning, then set it to false right after
  105. // calling the function. If the function errors, `didError` will never be
  106. // set to false. This strategy works even if the browser is flaky and
  107. // fails to call our global error handler, because it doesn't rely on
  108. // the error event at all.
  109. var didError = true;
  110. // Create an event handler for our fake event. We will synchronously
  111. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  112. // call the user-provided callback.
  113. var funcArgs = Array.prototype.slice.call(arguments, 3);
  114. function callCallback() {
  115. // We immediately remove the callback from event listeners so that
  116. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  117. // nested call would trigger the fake event handlers of any call higher
  118. // in the stack.
  119. fakeNode.removeEventListener(evtType, callCallback, false);
  120. func.apply(context, funcArgs);
  121. didError = false;
  122. }
  123. // Create a global error event handler. We use this to capture the value
  124. // that was thrown. It's possible that this error handler will fire more
  125. // than once; for example, if non-React code also calls `dispatchEvent`
  126. // and a handler for that event throws. We should be resilient to most of
  127. // those cases. Even if our error event handler fires more than once, the
  128. // last error event is always used. If the callback actually does error,
  129. // we know that the last error event is the correct one, because it's not
  130. // possible for anything else to have happened in between our callback
  131. // erroring and the code that follows the `dispatchEvent` call below. If
  132. // the callback doesn't error, but the error event was fired, we know to
  133. // ignore it because `didError` will be false, as described above.
  134. var error = void 0;
  135. // Use this to track whether the error event is ever called.
  136. var didSetError = false;
  137. var isCrossOriginError = false;
  138. function onError(event) {
  139. error = event.error;
  140. didSetError = true;
  141. if (error === null && event.colno === 0 && event.lineno === 0) {
  142. isCrossOriginError = true;
  143. }
  144. }
  145. // Create a fake event type.
  146. var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
  147. // Attach our event handlers
  148. window.addEventListener('error', onError);
  149. fakeNode.addEventListener(evtType, callCallback, false);
  150. // Synchronously dispatch our fake event. If the user-provided function
  151. // errors, it will trigger our global error handler.
  152. evt.initEvent(evtType, false, false);
  153. fakeNode.dispatchEvent(evt);
  154. if (didError) {
  155. if (!didSetError) {
  156. // The callback errored, but the error event never fired.
  157. error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
  158. } else if (isCrossOriginError) {
  159. error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
  160. }
  161. this._hasCaughtError = true;
  162. this._caughtError = error;
  163. } else {
  164. this._hasCaughtError = false;
  165. this._caughtError = null;
  166. }
  167. // Remove our event listeners
  168. window.removeEventListener('error', onError);
  169. };
  170. invokeGuardedCallback = invokeGuardedCallbackDev;
  171. }
  172. }
  173. var invokeGuardedCallback$1 = invokeGuardedCallback;
  174. var ReactErrorUtils = {
  175. // Used by Fiber to simulate a try-catch.
  176. _caughtError: null,
  177. _hasCaughtError: false,
  178. // Used by event system to capture/rethrow the first error.
  179. _rethrowError: null,
  180. _hasRethrowError: false,
  181. /**
  182. * Call a function while guarding against errors that happens within it.
  183. * Returns an error if it throws, otherwise null.
  184. *
  185. * In production, this is implemented using a try-catch. The reason we don't
  186. * use a try-catch directly is so that we can swap out a different
  187. * implementation in DEV mode.
  188. *
  189. * @param {String} name of the guard to use for logging or debugging
  190. * @param {Function} func The function to invoke
  191. * @param {*} context The context to use when calling the function
  192. * @param {...*} args Arguments for function
  193. */
  194. invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) {
  195. invokeGuardedCallback$1.apply(ReactErrorUtils, arguments);
  196. },
  197. /**
  198. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  199. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  200. * TODO: See if _caughtError and _rethrowError can be unified.
  201. *
  202. * @param {String} name of the guard to use for logging or debugging
  203. * @param {Function} func The function to invoke
  204. * @param {*} context The context to use when calling the function
  205. * @param {...*} args Arguments for function
  206. */
  207. invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) {
  208. ReactErrorUtils.invokeGuardedCallback.apply(this, arguments);
  209. if (ReactErrorUtils.hasCaughtError()) {
  210. var error = ReactErrorUtils.clearCaughtError();
  211. if (!ReactErrorUtils._hasRethrowError) {
  212. ReactErrorUtils._hasRethrowError = true;
  213. ReactErrorUtils._rethrowError = error;
  214. }
  215. }
  216. },
  217. /**
  218. * During execution of guarded functions we will capture the first error which
  219. * we will rethrow to be handled by the top level error handler.
  220. */
  221. rethrowCaughtError: function () {
  222. return rethrowCaughtError.apply(ReactErrorUtils, arguments);
  223. },
  224. hasCaughtError: function () {
  225. return ReactErrorUtils._hasCaughtError;
  226. },
  227. clearCaughtError: function () {
  228. if (ReactErrorUtils._hasCaughtError) {
  229. var error = ReactErrorUtils._caughtError;
  230. ReactErrorUtils._caughtError = null;
  231. ReactErrorUtils._hasCaughtError = false;
  232. return error;
  233. } else {
  234. invariant_1(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.');
  235. }
  236. }
  237. };
  238. var rethrowCaughtError = function () {
  239. if (ReactErrorUtils._hasRethrowError) {
  240. var error = ReactErrorUtils._rethrowError;
  241. ReactErrorUtils._rethrowError = null;
  242. ReactErrorUtils._hasRethrowError = false;
  243. throw error;
  244. }
  245. };
  246. /**
  247. * Injectable ordering of event plugins.
  248. */
  249. var eventPluginOrder = null;
  250. /**
  251. * Injectable mapping from names to event plugin modules.
  252. */
  253. var namesToPlugins = {};
  254. /**
  255. * Recomputes the plugin list using the injected plugins and plugin ordering.
  256. *
  257. * @private
  258. */
  259. function recomputePluginOrdering() {
  260. if (!eventPluginOrder) {
  261. // Wait until an `eventPluginOrder` is injected.
  262. return;
  263. }
  264. for (var pluginName in namesToPlugins) {
  265. var pluginModule = namesToPlugins[pluginName];
  266. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  267. !(pluginIndex > -1) ? invariant_1(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0;
  268. if (plugins[pluginIndex]) {
  269. continue;
  270. }
  271. !pluginModule.extractEvents ? invariant_1(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0;
  272. plugins[pluginIndex] = pluginModule;
  273. var publishedEvents = pluginModule.eventTypes;
  274. for (var eventName in publishedEvents) {
  275. !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant_1(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0;
  276. }
  277. }
  278. }
  279. /**
  280. * Publishes an event so that it can be dispatched by the supplied plugin.
  281. *
  282. * @param {object} dispatchConfig Dispatch configuration for the event.
  283. * @param {object} PluginModule Plugin publishing the event.
  284. * @return {boolean} True if the event was successfully published.
  285. * @private
  286. */
  287. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  288. !!eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant_1(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0;
  289. eventNameDispatchConfigs[eventName] = dispatchConfig;
  290. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  291. if (phasedRegistrationNames) {
  292. for (var phaseName in phasedRegistrationNames) {
  293. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  294. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  295. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  296. }
  297. }
  298. return true;
  299. } else if (dispatchConfig.registrationName) {
  300. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  301. return true;
  302. }
  303. return false;
  304. }
  305. /**
  306. * Publishes a registration name that is used to identify dispatched events.
  307. *
  308. * @param {string} registrationName Registration name to add.
  309. * @param {object} PluginModule Plugin publishing the event.
  310. * @private
  311. */
  312. function publishRegistrationName(registrationName, pluginModule, eventName) {
  313. !!registrationNameModules[registrationName] ? invariant_1(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0;
  314. registrationNameModules[registrationName] = pluginModule;
  315. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  316. {
  317. var lowerCasedName = registrationName.toLowerCase();
  318. possibleRegistrationNames[lowerCasedName] = registrationName;
  319. if (registrationName === 'onDoubleClick') {
  320. possibleRegistrationNames.ondblclick = registrationName;
  321. }
  322. }
  323. }
  324. /**
  325. * Registers plugins so that they can extract and dispatch events.
  326. *
  327. * @see {EventPluginHub}
  328. */
  329. /**
  330. * Ordered list of injected plugins.
  331. */
  332. var plugins = [];
  333. /**
  334. * Mapping from event name to dispatch config
  335. */
  336. var eventNameDispatchConfigs = {};
  337. /**
  338. * Mapping from registration name to plugin module
  339. */
  340. var registrationNameModules = {};
  341. /**
  342. * Mapping from registration name to event name
  343. */
  344. var registrationNameDependencies = {};
  345. /**
  346. * Mapping from lowercase registration names to the properly cased version,
  347. * used to warn in the case of missing event handlers. Available
  348. * only in true.
  349. * @type {Object}
  350. */
  351. var possibleRegistrationNames = {};
  352. // Trust the developer to only use possibleRegistrationNames in true
  353. /**
  354. * Injects an ordering of plugins (by plugin name). This allows the ordering
  355. * to be decoupled from injection of the actual plugins so that ordering is
  356. * always deterministic regardless of packaging, on-the-fly injection, etc.
  357. *
  358. * @param {array} InjectedEventPluginOrder
  359. * @internal
  360. * @see {EventPluginHub.injection.injectEventPluginOrder}
  361. */
  362. function injectEventPluginOrder(injectedEventPluginOrder) {
  363. !!eventPluginOrder ? invariant_1(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0;
  364. // Clone the ordering so it cannot be dynamically mutated.
  365. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  366. recomputePluginOrdering();
  367. }
  368. /**
  369. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  370. * in the ordering injected by `injectEventPluginOrder`.
  371. *
  372. * Plugins can be injected as part of page initialization or on-the-fly.
  373. *
  374. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  375. * @internal
  376. * @see {EventPluginHub.injection.injectEventPluginsByName}
  377. */
  378. function injectEventPluginsByName(injectedNamesToPlugins) {
  379. var isOrderingDirty = false;
  380. for (var pluginName in injectedNamesToPlugins) {
  381. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  382. continue;
  383. }
  384. var pluginModule = injectedNamesToPlugins[pluginName];
  385. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  386. !!namesToPlugins[pluginName] ? invariant_1(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : void 0;
  387. namesToPlugins[pluginName] = pluginModule;
  388. isOrderingDirty = true;
  389. }
  390. }
  391. if (isOrderingDirty) {
  392. recomputePluginOrdering();
  393. }
  394. }
  395. var EventPluginRegistry = Object.freeze({
  396. plugins: plugins,
  397. eventNameDispatchConfigs: eventNameDispatchConfigs,
  398. registrationNameModules: registrationNameModules,
  399. registrationNameDependencies: registrationNameDependencies,
  400. possibleRegistrationNames: possibleRegistrationNames,
  401. injectEventPluginOrder: injectEventPluginOrder,
  402. injectEventPluginsByName: injectEventPluginsByName
  403. });
  404. /**
  405. * Copyright (c) 2013-present, Facebook, Inc.
  406. *
  407. * This source code is licensed under the MIT license found in the
  408. * LICENSE file in the root directory of this source tree.
  409. *
  410. *
  411. */
  412. function makeEmptyFunction(arg) {
  413. return function () {
  414. return arg;
  415. };
  416. }
  417. /**
  418. * This function accepts and discards inputs; it has no side effects. This is
  419. * primarily useful idiomatically for overridable function endpoints which
  420. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  421. */
  422. var emptyFunction = function emptyFunction() {};
  423. emptyFunction.thatReturns = makeEmptyFunction;
  424. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  425. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  426. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  427. emptyFunction.thatReturnsThis = function () {
  428. return this;
  429. };
  430. emptyFunction.thatReturnsArgument = function (arg) {
  431. return arg;
  432. };
  433. var emptyFunction_1 = emptyFunction;
  434. /**
  435. * Copyright (c) 2014-present, Facebook, Inc.
  436. *
  437. * This source code is licensed under the MIT license found in the
  438. * LICENSE file in the root directory of this source tree.
  439. *
  440. */
  441. /**
  442. * Similar to invariant but only logs a warning if the condition is not met.
  443. * This can be used to log issues in development environments in critical
  444. * paths. Removing the logging code for production environments will keep the
  445. * same logic and follow the same code paths.
  446. */
  447. var warning = emptyFunction_1;
  448. {
  449. var printWarning = function printWarning(format) {
  450. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  451. args[_key - 1] = arguments[_key];
  452. }
  453. var argIndex = 0;
  454. var message = 'Warning: ' + format.replace(/%s/g, function () {
  455. return args[argIndex++];
  456. });
  457. if (typeof console !== 'undefined') {
  458. console.error(message);
  459. }
  460. try {
  461. // --- Welcome to debugging React ---
  462. // This error was thrown as a convenience so that you can use this stack
  463. // to find the callsite that caused this warning to fire.
  464. throw new Error(message);
  465. } catch (x) {}
  466. };
  467. warning = function warning(condition, format) {
  468. if (format === undefined) {
  469. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  470. }
  471. if (format.indexOf('Failed Composite propType: ') === 0) {
  472. return; // Ignore CompositeComponent proptype check.
  473. }
  474. if (!condition) {
  475. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  476. args[_key2 - 2] = arguments[_key2];
  477. }
  478. printWarning.apply(undefined, [format].concat(args));
  479. }
  480. };
  481. }
  482. var warning_1 = warning;
  483. var getFiberCurrentPropsFromNode = null;
  484. var getInstanceFromNode = null;
  485. var getNodeFromInstance = null;
  486. var injection$1 = {
  487. injectComponentTree: function (Injected) {
  488. getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode;
  489. getInstanceFromNode = Injected.getInstanceFromNode;
  490. getNodeFromInstance = Injected.getNodeFromInstance;
  491. {
  492. !(getNodeFromInstance && getInstanceFromNode) ? warning_1(false, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
  493. }
  494. }
  495. };
  496. var validateEventDispatches = void 0;
  497. {
  498. validateEventDispatches = function (event) {
  499. var dispatchListeners = event._dispatchListeners;
  500. var dispatchInstances = event._dispatchInstances;
  501. var listenersIsArr = Array.isArray(dispatchListeners);
  502. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  503. var instancesIsArr = Array.isArray(dispatchInstances);
  504. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  505. !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warning_1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
  506. };
  507. }
  508. /**
  509. * Dispatch the event to the listener.
  510. * @param {SyntheticEvent} event SyntheticEvent to handle
  511. * @param {boolean} simulated If the event is simulated (changes exn behavior)
  512. * @param {function} listener Application-level callback
  513. * @param {*} inst Internal component instance
  514. */
  515. function executeDispatch(event, simulated, listener, inst) {
  516. var type = event.type || 'unknown-event';
  517. event.currentTarget = getNodeFromInstance(inst);
  518. ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  519. event.currentTarget = null;
  520. }
  521. /**
  522. * Standard/simple iteration through an event's collected dispatches.
  523. */
  524. function executeDispatchesInOrder(event, simulated) {
  525. var dispatchListeners = event._dispatchListeners;
  526. var dispatchInstances = event._dispatchInstances;
  527. {
  528. validateEventDispatches(event);
  529. }
  530. if (Array.isArray(dispatchListeners)) {
  531. for (var i = 0; i < dispatchListeners.length; i++) {
  532. if (event.isPropagationStopped()) {
  533. break;
  534. }
  535. // Listeners and Instances are two parallel arrays that are always in sync.
  536. executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
  537. }
  538. } else if (dispatchListeners) {
  539. executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
  540. }
  541. event._dispatchListeners = null;
  542. event._dispatchInstances = null;
  543. }
  544. /**
  545. * @see executeDispatchesInOrderStopAtTrueImpl
  546. */
  547. /**
  548. * Execution of a "direct" dispatch - there must be at most one dispatch
  549. * accumulated on the event or it is considered an error. It doesn't really make
  550. * sense for an event with multiple dispatches (bubbled) to keep track of the
  551. * return values at each dispatch execution, but it does tend to make sense when
  552. * dealing with "direct" dispatches.
  553. *
  554. * @return {*} The return value of executing the single dispatch.
  555. */
  556. /**
  557. * @param {SyntheticEvent} event
  558. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  559. */
  560. /**
  561. * Accumulates items that must not be null or undefined into the first one. This
  562. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  563. * API cleanness. Since `current` can be null before being passed in and not
  564. * null after this function, make sure to assign it back to `current`:
  565. *
  566. * `a = accumulateInto(a, b);`
  567. *
  568. * This API should be sparingly used. Try `accumulate` for something cleaner.
  569. *
  570. * @return {*|array<*>} An accumulation of items.
  571. */
  572. function accumulateInto(current, next) {
  573. !(next != null) ? invariant_1(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0;
  574. if (current == null) {
  575. return next;
  576. }
  577. // Both are not empty. Warning: Never call x.concat(y) when you are not
  578. // certain that x is an Array (x could be a string with concat method).
  579. if (Array.isArray(current)) {
  580. if (Array.isArray(next)) {
  581. current.push.apply(current, next);
  582. return current;
  583. }
  584. current.push(next);
  585. return current;
  586. }
  587. if (Array.isArray(next)) {
  588. // A bit too dangerous to mutate `next`.
  589. return [current].concat(next);
  590. }
  591. return [current, next];
  592. }
  593. /**
  594. * @param {array} arr an "accumulation" of items which is either an Array or
  595. * a single item. Useful when paired with the `accumulate` module. This is a
  596. * simple utility that allows us to reason about a collection of items, but
  597. * handling the case when there is exactly one item (and we do not need to
  598. * allocate an array).
  599. * @param {function} cb Callback invoked with each element or a collection.
  600. * @param {?} [scope] Scope used as `this` in a callback.
  601. */
  602. function forEachAccumulated(arr, cb, scope) {
  603. if (Array.isArray(arr)) {
  604. arr.forEach(cb, scope);
  605. } else if (arr) {
  606. cb.call(scope, arr);
  607. }
  608. }
  609. /**
  610. * Internal queue of events that have accumulated their dispatches and are
  611. * waiting to have their dispatches executed.
  612. */
  613. var eventQueue = null;
  614. /**
  615. * Dispatches an event and releases it back into the pool, unless persistent.
  616. *
  617. * @param {?object} event Synthetic event to be dispatched.
  618. * @param {boolean} simulated If the event is simulated (changes exn behavior)
  619. * @private
  620. */
  621. var executeDispatchesAndRelease = function (event, simulated) {
  622. if (event) {
  623. executeDispatchesInOrder(event, simulated);
  624. if (!event.isPersistent()) {
  625. event.constructor.release(event);
  626. }
  627. }
  628. };
  629. var executeDispatchesAndReleaseSimulated = function (e) {
  630. return executeDispatchesAndRelease(e, true);
  631. };
  632. var executeDispatchesAndReleaseTopLevel = function (e) {
  633. return executeDispatchesAndRelease(e, false);
  634. };
  635. function isInteractive(tag) {
  636. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  637. }
  638. function shouldPreventMouseEvent(name, type, props) {
  639. switch (name) {
  640. case 'onClick':
  641. case 'onClickCapture':
  642. case 'onDoubleClick':
  643. case 'onDoubleClickCapture':
  644. case 'onMouseDown':
  645. case 'onMouseDownCapture':
  646. case 'onMouseMove':
  647. case 'onMouseMoveCapture':
  648. case 'onMouseUp':
  649. case 'onMouseUpCapture':
  650. return !!(props.disabled && isInteractive(type));
  651. default:
  652. return false;
  653. }
  654. }
  655. /**
  656. * This is a unified interface for event plugins to be installed and configured.
  657. *
  658. * Event plugins can implement the following properties:
  659. *
  660. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  661. * Required. When a top-level event is fired, this method is expected to
  662. * extract synthetic events that will in turn be queued and dispatched.
  663. *
  664. * `eventTypes` {object}
  665. * Optional, plugins that fire events must publish a mapping of registration
  666. * names that are used to register listeners. Values of this mapping must
  667. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  668. *
  669. * `executeDispatch` {function(object, function, string)}
  670. * Optional, allows plugins to override how an event gets dispatched. By
  671. * default, the listener is simply invoked.
  672. *
  673. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  674. *
  675. * @public
  676. */
  677. /**
  678. * Methods for injecting dependencies.
  679. */
  680. var injection = {
  681. /**
  682. * @param {array} InjectedEventPluginOrder
  683. * @public
  684. */
  685. injectEventPluginOrder: injectEventPluginOrder,
  686. /**
  687. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  688. */
  689. injectEventPluginsByName: injectEventPluginsByName
  690. };
  691. /**
  692. * @param {object} inst The instance, which is the source of events.
  693. * @param {string} registrationName Name of listener (e.g. `onClick`).
  694. * @return {?function} The stored callback.
  695. */
  696. function getListener(inst, registrationName) {
  697. var listener = void 0;
  698. // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  699. // live here; needs to be moved to a better place soon
  700. var stateNode = inst.stateNode;
  701. if (!stateNode) {
  702. // Work in progress (ex: onload events in incremental mode).
  703. return null;
  704. }
  705. var props = getFiberCurrentPropsFromNode(stateNode);
  706. if (!props) {
  707. // Work in progress.
  708. return null;
  709. }
  710. listener = props[registrationName];
  711. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  712. return null;
  713. }
  714. !(!listener || typeof listener === 'function') ? invariant_1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0;
  715. return listener;
  716. }
  717. /**
  718. * Allows registered plugins an opportunity to extract events from top-level
  719. * native browser events.
  720. *
  721. * @return {*} An accumulation of synthetic events.
  722. * @internal
  723. */
  724. function extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  725. var events = null;
  726. for (var i = 0; i < plugins.length; i++) {
  727. // Not every plugin in the ordering may be loaded at runtime.
  728. var possiblePlugin = plugins[i];
  729. if (possiblePlugin) {
  730. var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  731. if (extractedEvents) {
  732. events = accumulateInto(events, extractedEvents);
  733. }
  734. }
  735. }
  736. return events;
  737. }
  738. function runEventsInBatch(events, simulated) {
  739. if (events !== null) {
  740. eventQueue = accumulateInto(eventQueue, events);
  741. }
  742. // Set `eventQueue` to null before processing it so that we can tell if more
  743. // events get enqueued while processing.
  744. var processingEventQueue = eventQueue;
  745. eventQueue = null;
  746. if (!processingEventQueue) {
  747. return;
  748. }
  749. if (simulated) {
  750. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
  751. } else {
  752. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  753. }
  754. !!eventQueue ? invariant_1(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0;
  755. // This would be a good time to rethrow if any of the event handlers threw.
  756. ReactErrorUtils.rethrowCaughtError();
  757. }
  758. function runExtractedEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  759. var events = extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  760. runEventsInBatch(events, false);
  761. }
  762. var EventPluginHub = Object.freeze({
  763. injection: injection,
  764. getListener: getListener,
  765. runEventsInBatch: runEventsInBatch,
  766. runExtractedEventsInBatch: runExtractedEventsInBatch
  767. });
  768. var IndeterminateComponent = 0; // Before we know whether it is functional or class
  769. var FunctionalComponent = 1;
  770. var ClassComponent = 2;
  771. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  772. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  773. var HostComponent = 5;
  774. var HostText = 6;
  775. var CallComponent = 7;
  776. var CallHandlerPhase = 8;
  777. var ReturnComponent = 9;
  778. var Fragment = 10;
  779. var Mode = 11;
  780. var ContextConsumer = 12;
  781. var ContextProvider = 13;
  782. var ForwardRef = 14;
  783. var randomKey = Math.random().toString(36).slice(2);
  784. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  785. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  786. function precacheFiberNode$1(hostInst, node) {
  787. node[internalInstanceKey] = hostInst;
  788. }
  789. /**
  790. * Given a DOM node, return the closest ReactDOMComponent or
  791. * ReactDOMTextComponent instance ancestor.
  792. */
  793. function getClosestInstanceFromNode(node) {
  794. if (node[internalInstanceKey]) {
  795. return node[internalInstanceKey];
  796. }
  797. while (!node[internalInstanceKey]) {
  798. if (node.parentNode) {
  799. node = node.parentNode;
  800. } else {
  801. // Top of the tree. This node must not be part of a React tree (or is
  802. // unmounted, potentially).
  803. return null;
  804. }
  805. }
  806. var inst = node[internalInstanceKey];
  807. if (inst.tag === HostComponent || inst.tag === HostText) {
  808. // In Fiber, this will always be the deepest root.
  809. return inst;
  810. }
  811. return null;
  812. }
  813. /**
  814. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  815. * instance, or null if the node was not rendered by this React.
  816. */
  817. function getInstanceFromNode$1(node) {
  818. var inst = node[internalInstanceKey];
  819. if (inst) {
  820. if (inst.tag === HostComponent || inst.tag === HostText) {
  821. return inst;
  822. } else {
  823. return null;
  824. }
  825. }
  826. return null;
  827. }
  828. /**
  829. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  830. * DOM node.
  831. */
  832. function getNodeFromInstance$1(inst) {
  833. if (inst.tag === HostComponent || inst.tag === HostText) {
  834. // In Fiber this, is just the state node right now. We assume it will be
  835. // a host component or host text.
  836. return inst.stateNode;
  837. }
  838. // Without this first invariant, passing a non-DOM-component triggers the next
  839. // invariant for a missing parent, which is super confusing.
  840. invariant_1(false, 'getNodeFromInstance: Invalid argument.');
  841. }
  842. function getFiberCurrentPropsFromNode$1(node) {
  843. return node[internalEventHandlersKey] || null;
  844. }
  845. function updateFiberProps$1(node, props) {
  846. node[internalEventHandlersKey] = props;
  847. }
  848. var ReactDOMComponentTree = Object.freeze({
  849. precacheFiberNode: precacheFiberNode$1,
  850. getClosestInstanceFromNode: getClosestInstanceFromNode,
  851. getInstanceFromNode: getInstanceFromNode$1,
  852. getNodeFromInstance: getNodeFromInstance$1,
  853. getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode$1,
  854. updateFiberProps: updateFiberProps$1
  855. });
  856. function getParent(inst) {
  857. do {
  858. inst = inst['return'];
  859. // TODO: If this is a HostRoot we might want to bail out.
  860. // That is depending on if we want nested subtrees (layers) to bubble
  861. // events to their parent. We could also go through parentNode on the
  862. // host node but that wouldn't work for React Native and doesn't let us
  863. // do the portal feature.
  864. } while (inst && inst.tag !== HostComponent);
  865. if (inst) {
  866. return inst;
  867. }
  868. return null;
  869. }
  870. /**
  871. * Return the lowest common ancestor of A and B, or null if they are in
  872. * different trees.
  873. */
  874. function getLowestCommonAncestor(instA, instB) {
  875. var depthA = 0;
  876. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  877. depthA++;
  878. }
  879. var depthB = 0;
  880. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  881. depthB++;
  882. }
  883. // If A is deeper, crawl up.
  884. while (depthA - depthB > 0) {
  885. instA = getParent(instA);
  886. depthA--;
  887. }
  888. // If B is deeper, crawl up.
  889. while (depthB - depthA > 0) {
  890. instB = getParent(instB);
  891. depthB--;
  892. }
  893. // Walk in lockstep until we find a match.
  894. var depth = depthA;
  895. while (depth--) {
  896. if (instA === instB || instA === instB.alternate) {
  897. return instA;
  898. }
  899. instA = getParent(instA);
  900. instB = getParent(instB);
  901. }
  902. return null;
  903. }
  904. /**
  905. * Return if A is an ancestor of B.
  906. */
  907. /**
  908. * Return the parent instance of the passed-in instance.
  909. */
  910. function getParentInstance(inst) {
  911. return getParent(inst);
  912. }
  913. /**
  914. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  915. */
  916. function traverseTwoPhase(inst, fn, arg) {
  917. var path = [];
  918. while (inst) {
  919. path.push(inst);
  920. inst = getParent(inst);
  921. }
  922. var i = void 0;
  923. for (i = path.length; i-- > 0;) {
  924. fn(path[i], 'captured', arg);
  925. }
  926. for (i = 0; i < path.length; i++) {
  927. fn(path[i], 'bubbled', arg);
  928. }
  929. }
  930. /**
  931. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  932. * should would receive a `mouseEnter` or `mouseLeave` event.
  933. *
  934. * Does not invoke the callback on the nearest common ancestor because nothing
  935. * "entered" or "left" that element.
  936. */
  937. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  938. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  939. var pathFrom = [];
  940. while (true) {
  941. if (!from) {
  942. break;
  943. }
  944. if (from === common) {
  945. break;
  946. }
  947. var alternate = from.alternate;
  948. if (alternate !== null && alternate === common) {
  949. break;
  950. }
  951. pathFrom.push(from);
  952. from = getParent(from);
  953. }
  954. var pathTo = [];
  955. while (true) {
  956. if (!to) {
  957. break;
  958. }
  959. if (to === common) {
  960. break;
  961. }
  962. var _alternate = to.alternate;
  963. if (_alternate !== null && _alternate === common) {
  964. break;
  965. }
  966. pathTo.push(to);
  967. to = getParent(to);
  968. }
  969. for (var i = 0; i < pathFrom.length; i++) {
  970. fn(pathFrom[i], 'bubbled', argFrom);
  971. }
  972. for (var _i = pathTo.length; _i-- > 0;) {
  973. fn(pathTo[_i], 'captured', argTo);
  974. }
  975. }
  976. /**
  977. * Some event types have a notion of different registration names for different
  978. * "phases" of propagation. This finds listeners by a given phase.
  979. */
  980. function listenerAtPhase(inst, event, propagationPhase) {
  981. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  982. return getListener(inst, registrationName);
  983. }
  984. /**
  985. * A small set of propagation patterns, each of which will accept a small amount
  986. * of information, and generate a set of "dispatch ready event objects" - which
  987. * are sets of events that have already been annotated with a set of dispatched
  988. * listener functions/ids. The API is designed this way to discourage these
  989. * propagation strategies from actually executing the dispatches, since we
  990. * always want to collect the entire set of dispatches before executing even a
  991. * single one.
  992. */
  993. /**
  994. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  995. * here, allows us to not have to bind or create functions for each event.
  996. * Mutating the event's members allows us to not have to create a wrapping
  997. * "dispatch" object that pairs the event with the listener.
  998. */
  999. function accumulateDirectionalDispatches(inst, phase, event) {
  1000. {
  1001. !inst ? warning_1(false, 'Dispatching inst must not be null') : void 0;
  1002. }
  1003. var listener = listenerAtPhase(inst, event, phase);
  1004. if (listener) {
  1005. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1006. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1007. }
  1008. }
  1009. /**
  1010. * Collect dispatches (must be entirely collected before dispatching - see unit
  1011. * tests). Lazily allocate the array to conserve memory. We must loop through
  1012. * each event and perform the traversal for each one. We cannot perform a
  1013. * single traversal for the entire collection of events because each event may
  1014. * have a different target.
  1015. */
  1016. function accumulateTwoPhaseDispatchesSingle(event) {
  1017. if (event && event.dispatchConfig.phasedRegistrationNames) {
  1018. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  1019. }
  1020. }
  1021. /**
  1022. * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
  1023. */
  1024. function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
  1025. if (event && event.dispatchConfig.phasedRegistrationNames) {
  1026. var targetInst = event._targetInst;
  1027. var parentInst = targetInst ? getParentInstance(targetInst) : null;
  1028. traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
  1029. }
  1030. }
  1031. /**
  1032. * Accumulates without regard to direction, does not look for phased
  1033. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  1034. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  1035. */
  1036. function accumulateDispatches(inst, ignoredDirection, event) {
  1037. if (inst && event && event.dispatchConfig.registrationName) {
  1038. var registrationName = event.dispatchConfig.registrationName;
  1039. var listener = getListener(inst, registrationName);
  1040. if (listener) {
  1041. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1042. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1043. }
  1044. }
  1045. }
  1046. /**
  1047. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  1048. * `dispatchMarker`.
  1049. * @param {SyntheticEvent} event
  1050. */
  1051. function accumulateDirectDispatchesSingle(event) {
  1052. if (event && event.dispatchConfig.registrationName) {
  1053. accumulateDispatches(event._targetInst, null, event);
  1054. }
  1055. }
  1056. function accumulateTwoPhaseDispatches(events) {
  1057. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  1058. }
  1059. function accumulateTwoPhaseDispatchesSkipTarget(events) {
  1060. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
  1061. }
  1062. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  1063. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  1064. }
  1065. function accumulateDirectDispatches(events) {
  1066. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  1067. }
  1068. var EventPropagators = Object.freeze({
  1069. accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
  1070. accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
  1071. accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches,
  1072. accumulateDirectDispatches: accumulateDirectDispatches
  1073. });
  1074. /**
  1075. * Copyright (c) 2013-present, Facebook, Inc.
  1076. *
  1077. * This source code is licensed under the MIT license found in the
  1078. * LICENSE file in the root directory of this source tree.
  1079. *
  1080. */
  1081. var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  1082. /**
  1083. * Simple, lightweight module assisting with the detection and context of
  1084. * Worker. Helps avoid circular dependencies and allows code to reason about
  1085. * whether or not they are in a Worker, even if they never include the main
  1086. * `ReactWorker` dependency.
  1087. */
  1088. var ExecutionEnvironment = {
  1089. canUseDOM: canUseDOM,
  1090. canUseWorkers: typeof Worker !== 'undefined',
  1091. canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
  1092. canUseViewport: canUseDOM && !!window.screen,
  1093. isInWorker: !canUseDOM // For now, this is true - might change in the future.
  1094. };
  1095. var ExecutionEnvironment_1 = ExecutionEnvironment;
  1096. var contentKey = null;
  1097. /**
  1098. * Gets the key used to access text content on a DOM node.
  1099. *
  1100. * @return {?string} Key used to access text content.
  1101. * @internal
  1102. */
  1103. function getTextContentAccessor() {
  1104. if (!contentKey && ExecutionEnvironment_1.canUseDOM) {
  1105. // Prefer textContent to innerText because many browsers support both but
  1106. // SVG <text> elements don't support innerText even when <div> does.
  1107. contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
  1108. }
  1109. return contentKey;
  1110. }
  1111. /**
  1112. * This helper object stores information about text content of a target node,
  1113. * allowing comparison of content before and after a given event.
  1114. *
  1115. * Identify the node where selection currently begins, then observe
  1116. * both its text content and its current position in the DOM. Since the
  1117. * browser may natively replace the target node during composition, we can
  1118. * use its position to find its replacement.
  1119. *
  1120. *
  1121. */
  1122. var compositionState = {
  1123. _root: null,
  1124. _startText: null,
  1125. _fallbackText: null
  1126. };
  1127. function initialize(nativeEventTarget) {
  1128. compositionState._root = nativeEventTarget;
  1129. compositionState._startText = getText();
  1130. return true;
  1131. }
  1132. function reset() {
  1133. compositionState._root = null;
  1134. compositionState._startText = null;
  1135. compositionState._fallbackText = null;
  1136. }
  1137. function getData() {
  1138. if (compositionState._fallbackText) {
  1139. return compositionState._fallbackText;
  1140. }
  1141. var start = void 0;
  1142. var startValue = compositionState._startText;
  1143. var startLength = startValue.length;
  1144. var end = void 0;
  1145. var endValue = getText();
  1146. var endLength = endValue.length;
  1147. for (start = 0; start < startLength; start++) {
  1148. if (startValue[start] !== endValue[start]) {
  1149. break;
  1150. }
  1151. }
  1152. var minEnd = startLength - start;
  1153. for (end = 1; end <= minEnd; end++) {
  1154. if (startValue[startLength - end] !== endValue[endLength - end]) {
  1155. break;
  1156. }
  1157. }
  1158. var sliceTail = end > 1 ? 1 - end : undefined;
  1159. compositionState._fallbackText = endValue.slice(start, sliceTail);
  1160. return compositionState._fallbackText;
  1161. }
  1162. function getText() {
  1163. if ('value' in compositionState._root) {
  1164. return compositionState._root.value;
  1165. }
  1166. return compositionState._root[getTextContentAccessor()];
  1167. }
  1168. var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  1169. var _assign = ReactInternals.assign;
  1170. /* eslint valid-typeof: 0 */
  1171. var didWarnForAddedNewProperty = false;
  1172. var EVENT_POOL_SIZE = 10;
  1173. var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
  1174. /**
  1175. * @interface Event
  1176. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  1177. */
  1178. var EventInterface = {
  1179. type: null,
  1180. target: null,
  1181. // currentTarget is set when dispatching; no use in copying it here
  1182. currentTarget: emptyFunction_1.thatReturnsNull,
  1183. eventPhase: null,
  1184. bubbles: null,
  1185. cancelable: null,
  1186. timeStamp: function (event) {
  1187. return event.timeStamp || Date.now();
  1188. },
  1189. defaultPrevented: null,
  1190. isTrusted: null
  1191. };
  1192. /**
  1193. * Synthetic events are dispatched by event plugins, typically in response to a
  1194. * top-level event delegation handler.
  1195. *
  1196. * These systems should generally use pooling to reduce the frequency of garbage
  1197. * collection. The system should check `isPersistent` to determine whether the
  1198. * event should be released into the pool after being dispatched. Users that
  1199. * need a persisted event should invoke `persist`.
  1200. *
  1201. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  1202. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  1203. * DOM interface; custom application-specific events can also subclass this.
  1204. *
  1205. * @param {object} dispatchConfig Configuration used to dispatch this event.
  1206. * @param {*} targetInst Marker identifying the event target.
  1207. * @param {object} nativeEvent Native browser event.
  1208. * @param {DOMEventTarget} nativeEventTarget Target node.
  1209. */
  1210. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  1211. {
  1212. // these have a getter/setter for warnings
  1213. delete this.nativeEvent;
  1214. delete this.preventDefault;
  1215. delete this.stopPropagation;
  1216. }
  1217. this.dispatchConfig = dispatchConfig;
  1218. this._targetInst = targetInst;
  1219. this.nativeEvent = nativeEvent;
  1220. var Interface = this.constructor.Interface;
  1221. for (var propName in Interface) {
  1222. if (!Interface.hasOwnProperty(propName)) {
  1223. continue;
  1224. }
  1225. {
  1226. delete this[propName]; // this has a getter/setter for warnings
  1227. }
  1228. var normalize = Interface[propName];
  1229. if (normalize) {
  1230. this[propName] = normalize(nativeEvent);
  1231. } else {
  1232. if (propName === 'target') {
  1233. this.target = nativeEventTarget;
  1234. } else {
  1235. this[propName] = nativeEvent[propName];
  1236. }
  1237. }
  1238. }
  1239. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  1240. if (defaultPrevented) {
  1241. this.isDefaultPrevented = emptyFunction_1.thatReturnsTrue;
  1242. } else {
  1243. this.isDefaultPrevented = emptyFunction_1.thatReturnsFalse;
  1244. }
  1245. this.isPropagationStopped = emptyFunction_1.thatReturnsFalse;
  1246. return this;
  1247. }
  1248. _assign(SyntheticEvent.prototype, {
  1249. preventDefault: function () {
  1250. this.defaultPrevented = true;
  1251. var event = this.nativeEvent;
  1252. if (!event) {
  1253. return;
  1254. }
  1255. if (event.preventDefault) {
  1256. event.preventDefault();
  1257. } else if (typeof event.returnValue !== 'unknown') {
  1258. event.returnValue = false;
  1259. }
  1260. this.isDefaultPrevented = emptyFunction_1.thatReturnsTrue;
  1261. },
  1262. stopPropagation: function () {
  1263. var event = this.nativeEvent;
  1264. if (!event) {
  1265. return;
  1266. }
  1267. if (event.stopPropagation) {
  1268. event.stopPropagation();
  1269. } else if (typeof event.cancelBubble !== 'unknown') {
  1270. // The ChangeEventPlugin registers a "propertychange" event for
  1271. // IE. This event does not support bubbling or cancelling, and
  1272. // any references to cancelBubble throw "Member not found". A
  1273. // typeof check of "unknown" circumvents this issue (and is also
  1274. // IE specific).
  1275. event.cancelBubble = true;
  1276. }
  1277. this.isPropagationStopped = emptyFunction_1.thatReturnsTrue;
  1278. },
  1279. /**
  1280. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  1281. * them back into the pool. This allows a way to hold onto a reference that
  1282. * won't be added back into the pool.
  1283. */
  1284. persist: function () {
  1285. this.isPersistent = emptyFunction_1.thatReturnsTrue;
  1286. },
  1287. /**
  1288. * Checks if this event should be released back into the pool.
  1289. *
  1290. * @return {boolean} True if this should not be released, false otherwise.
  1291. */
  1292. isPersistent: emptyFunction_1.thatReturnsFalse,
  1293. /**
  1294. * `PooledClass` looks for `destructor` on each instance it releases.
  1295. */
  1296. destructor: function () {
  1297. var Interface = this.constructor.Interface;
  1298. for (var propName in Interface) {
  1299. {
  1300. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  1301. }
  1302. }
  1303. for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
  1304. this[shouldBeReleasedProperties[i]] = null;
  1305. }
  1306. {
  1307. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  1308. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction_1));
  1309. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction_1));
  1310. }
  1311. }
  1312. });
  1313. SyntheticEvent.Interface = EventInterface;
  1314. /**
  1315. * Helper to reduce boilerplate when creating subclasses.
  1316. */
  1317. SyntheticEvent.extend = function (Interface) {
  1318. var Super = this;
  1319. var E = function () {};
  1320. E.prototype = Super.prototype;
  1321. var prototype = new E();
  1322. function Class() {
  1323. return Super.apply(this, arguments);
  1324. }
  1325. _assign(prototype, Class.prototype);
  1326. Class.prototype = prototype;
  1327. Class.prototype.constructor = Class;
  1328. Class.Interface = _assign({}, Super.Interface, Interface);
  1329. Class.extend = Super.extend;
  1330. addEventPoolingTo(Class);
  1331. return Class;
  1332. };
  1333. /** Proxying after everything set on SyntheticEvent
  1334. * to resolve Proxy issue on some WebKit browsers
  1335. * in which some Event properties are set to undefined (GH#10010)
  1336. */
  1337. {
  1338. var isProxySupported = typeof Proxy === 'function' &&
  1339. // https://github.com/facebook/react/issues/12011
  1340. !Object.isSealed(new Proxy({}, {}));
  1341. if (isProxySupported) {
  1342. /*eslint-disable no-func-assign */
  1343. SyntheticEvent = new Proxy(SyntheticEvent, {
  1344. construct: function (target, args) {
  1345. return this.apply(target, Object.create(target.prototype), args);
  1346. },
  1347. apply: function (constructor, that, args) {
  1348. return new Proxy(constructor.apply(that, args), {
  1349. set: function (target, prop, value) {
  1350. if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
  1351. !(didWarnForAddedNewProperty || target.isPersistent()) ? warning_1(false, "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.') : void 0;
  1352. didWarnForAddedNewProperty = true;
  1353. }
  1354. target[prop] = value;
  1355. return true;
  1356. }
  1357. });
  1358. }
  1359. });
  1360. /*eslint-enable no-func-assign */
  1361. }
  1362. }
  1363. addEventPoolingTo(SyntheticEvent);
  1364. /**
  1365. * Helper to nullify syntheticEvent instance properties when destructing
  1366. *
  1367. * @param {String} propName
  1368. * @param {?object} getVal
  1369. * @return {object} defineProperty object
  1370. */
  1371. function getPooledWarningPropertyDefinition(propName, getVal) {
  1372. var isFunction = typeof getVal === 'function';
  1373. return {
  1374. configurable: true,
  1375. set: set,
  1376. get: get
  1377. };
  1378. function set(val) {
  1379. var action = isFunction ? 'setting the method' : 'setting the property';
  1380. warn(action, 'This is effectively a no-op');
  1381. return val;
  1382. }
  1383. function get() {
  1384. var action = isFunction ? 'accessing the method' : 'accessing the property';
  1385. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  1386. warn(action, result);
  1387. return getVal;
  1388. }
  1389. function warn(action, result) {
  1390. var warningCondition = false;
  1391. !warningCondition ? warning_1(false, "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) : void 0;
  1392. }
  1393. }
  1394. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  1395. var EventConstructor = this;
  1396. if (EventConstructor.eventPool.length) {
  1397. var instance = EventConstructor.eventPool.pop();
  1398. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  1399. return instance;
  1400. }
  1401. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  1402. }
  1403. function releasePooledEvent(event) {
  1404. var EventConstructor = this;
  1405. !(event instanceof EventConstructor) ? invariant_1(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
  1406. event.destructor();
  1407. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  1408. EventConstructor.eventPool.push(event);
  1409. }
  1410. }
  1411. function addEventPoolingTo(EventConstructor) {
  1412. EventConstructor.eventPool = [];
  1413. EventConstructor.getPooled = getPooledEvent;
  1414. EventConstructor.release = releasePooledEvent;
  1415. }
  1416. var SyntheticEvent$1 = SyntheticEvent;
  1417. /**
  1418. * @interface Event
  1419. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  1420. */
  1421. var SyntheticCompositionEvent = SyntheticEvent$1.extend({
  1422. data: null
  1423. });
  1424. /**
  1425. * @interface Event
  1426. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  1427. * /#events-inputevents
  1428. */
  1429. var SyntheticInputEvent = SyntheticEvent$1.extend({
  1430. data: null
  1431. });
  1432. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  1433. var START_KEYCODE = 229;
  1434. var canUseCompositionEvent = ExecutionEnvironment_1.canUseDOM && 'CompositionEvent' in window;
  1435. var documentMode = null;
  1436. if (ExecutionEnvironment_1.canUseDOM && 'documentMode' in document) {
  1437. documentMode = document.documentMode;
  1438. }
  1439. // Webkit offers a very useful `textInput` event that can be used to
  1440. // directly represent `beforeInput`. The IE `textinput` event is not as
  1441. // useful, so we don't use it.
  1442. var canUseTextInputEvent = ExecutionEnvironment_1.canUseDOM && 'TextEvent' in window && !documentMode;
  1443. // In IE9+, we have access to composition events, but the data supplied
  1444. // by the native compositionend event may be incorrect. Japanese ideographic
  1445. // spaces, for instance (\u3000) are not recorded correctly.
  1446. var useFallbackCompositionData = ExecutionEnvironment_1.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  1447. var SPACEBAR_CODE = 32;
  1448. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
  1449. // Events and their corresponding property names.
  1450. var eventTypes = {
  1451. beforeInput: {
  1452. phasedRegistrationNames: {
  1453. bubbled: 'onBeforeInput',
  1454. captured: 'onBeforeInputCapture'
  1455. },
  1456. dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste']
  1457. },
  1458. compositionEnd: {
  1459. phasedRegistrationNames: {
  1460. bubbled: 'onCompositionEnd',
  1461. captured: 'onCompositionEndCapture'
  1462. },
  1463. dependencies: ['topBlur', 'topCompositionEnd', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
  1464. },
  1465. compositionStart: {
  1466. phasedRegistrationNames: {
  1467. bubbled: 'onCompositionStart',
  1468. captured: 'onCompositionStartCapture'
  1469. },
  1470. dependencies: ['topBlur', 'topCompositionStart', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
  1471. },
  1472. compositionUpdate: {
  1473. phasedRegistrationNames: {
  1474. bubbled: 'onCompositionUpdate',
  1475. captured: 'onCompositionUpdateCapture'
  1476. },
  1477. dependencies: ['topBlur', 'topCompositionUpdate', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
  1478. }
  1479. };
  1480. // Track whether we've ever handled a keypress on the space key.
  1481. var hasSpaceKeypress = false;
  1482. /**
  1483. * Return whether a native keypress event is assumed to be a command.
  1484. * This is required because Firefox fires `keypress` events for key commands
  1485. * (cut, copy, select-all, etc.) even though no character is inserted.
  1486. */
  1487. function isKeypressCommand(nativeEvent) {
  1488. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
  1489. // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  1490. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  1491. }
  1492. /**
  1493. * Translate native top level events into event types.
  1494. *
  1495. * @param {string} topLevelType
  1496. * @return {object}
  1497. */
  1498. function getCompositionEventType(topLevelType) {
  1499. switch (topLevelType) {
  1500. case 'topCompositionStart':
  1501. return eventTypes.compositionStart;
  1502. case 'topCompositionEnd':
  1503. return eventTypes.compositionEnd;
  1504. case 'topCompositionUpdate':
  1505. return eventTypes.compositionUpdate;
  1506. }
  1507. }
  1508. /**
  1509. * Does our fallback best-guess model think this event signifies that
  1510. * composition has begun?
  1511. *
  1512. * @param {string} topLevelType
  1513. * @param {object} nativeEvent
  1514. * @return {boolean}
  1515. */
  1516. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  1517. return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE;
  1518. }
  1519. /**
  1520. * Does our fallback mode think that this event is the end of composition?
  1521. *
  1522. * @param {string} topLevelType
  1523. * @param {object} nativeEvent
  1524. * @return {boolean}
  1525. */
  1526. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  1527. switch (topLevelType) {
  1528. case 'topKeyUp':
  1529. // Command keys insert or clear IME input.
  1530. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  1531. case 'topKeyDown':
  1532. // Expect IME keyCode on each keydown. If we get any other
  1533. // code we must have exited earlier.
  1534. return nativeEvent.keyCode !== START_KEYCODE;
  1535. case 'topKeyPress':
  1536. case 'topMouseDown':
  1537. case 'topBlur':
  1538. // Events are not possible without cancelling IME.
  1539. return true;
  1540. default:
  1541. return false;
  1542. }
  1543. }
  1544. /**
  1545. * Google Input Tools provides composition data via a CustomEvent,
  1546. * with the `data` property populated in the `detail` object. If this
  1547. * is available on the event object, use it. If not, this is a plain
  1548. * composition event and we have nothing special to extract.
  1549. *
  1550. * @param {object} nativeEvent
  1551. * @return {?string}
  1552. */
  1553. function getDataFromCustomEvent(nativeEvent) {
  1554. var detail = nativeEvent.detail;
  1555. if (typeof detail === 'object' && 'data' in detail) {
  1556. return detail.data;
  1557. }
  1558. return null;
  1559. }
  1560. // Track the current IME composition status, if any.
  1561. var isComposing = false;
  1562. /**
  1563. * @return {?object} A SyntheticCompositionEvent.
  1564. */
  1565. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1566. var eventType = void 0;
  1567. var fallbackData = void 0;
  1568. if (canUseCompositionEvent) {
  1569. eventType = getCompositionEventType(topLevelType);
  1570. } else if (!isComposing) {
  1571. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  1572. eventType = eventTypes.compositionStart;
  1573. }
  1574. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  1575. eventType = eventTypes.compositionEnd;
  1576. }
  1577. if (!eventType) {
  1578. return null;
  1579. }
  1580. if (useFallbackCompositionData) {
  1581. // The current composition is stored statically and must not be
  1582. // overwritten while composition continues.
  1583. if (!isComposing && eventType === eventTypes.compositionStart) {
  1584. isComposing = initialize(nativeEventTarget);
  1585. } else if (eventType === eventTypes.compositionEnd) {
  1586. if (isComposing) {
  1587. fallbackData = getData();
  1588. }
  1589. }
  1590. }
  1591. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  1592. if (fallbackData) {
  1593. // Inject data generated from fallback path into the synthetic event.
  1594. // This matches the property of native CompositionEventInterface.
  1595. event.data = fallbackData;
  1596. } else {
  1597. var customData = getDataFromCustomEvent(nativeEvent);
  1598. if (customData !== null) {
  1599. event.data = customData;
  1600. }
  1601. }
  1602. accumulateTwoPhaseDispatches(event);
  1603. return event;
  1604. }
  1605. /**
  1606. * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`.
  1607. * @param {object} nativeEvent Native browser event.
  1608. * @return {?string} The string corresponding to this `beforeInput` event.
  1609. */
  1610. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  1611. switch (topLevelType) {
  1612. case 'topCompositionEnd':
  1613. return getDataFromCustomEvent(nativeEvent);
  1614. case 'topKeyPress':
  1615. /**
  1616. * If native `textInput` events are available, our goal is to make
  1617. * use of them. However, there is a special case: the spacebar key.
  1618. * In Webkit, preventing default on a spacebar `textInput` event
  1619. * cancels character insertion, but it *also* causes the browser
  1620. * to fall back to its default spacebar behavior of scrolling the
  1621. * page.
  1622. *
  1623. * Tracking at:
  1624. * https://code.google.com/p/chromium/issues/detail?id=355103
  1625. *
  1626. * To avoid this issue, use the keypress event as if no `textInput`
  1627. * event is available.
  1628. */
  1629. var which = nativeEvent.which;
  1630. if (which !== SPACEBAR_CODE) {
  1631. return null;
  1632. }
  1633. hasSpaceKeypress = true;
  1634. return SPACEBAR_CHAR;
  1635. case 'topTextInput':
  1636. // Record the characters to be added to the DOM.
  1637. var chars = nativeEvent.data;
  1638. // If it's a spacebar character, assume that we have already handled
  1639. // it at the keypress level and bail immediately. Android Chrome
  1640. // doesn't give us keycodes, so we need to blacklist it.
  1641. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  1642. return null;
  1643. }
  1644. return chars;
  1645. default:
  1646. // For other native event types, do nothing.
  1647. return null;
  1648. }
  1649. }
  1650. /**
  1651. * For browsers that do not provide the `textInput` event, extract the
  1652. * appropriate string to use for SyntheticInputEvent.
  1653. *
  1654. * @param {string} topLevelType Record from `BrowserEventConstants`.
  1655. * @param {object} nativeEvent Native browser event.
  1656. * @return {?string} The fallback string for this `beforeInput` event.
  1657. */
  1658. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  1659. // If we are currently composing (IME) and using a fallback to do so,
  1660. // try to extract the composed characters from the fallback object.
  1661. // If composition event is available, we extract a string only at
  1662. // compositionevent, otherwise extract it at fallback events.
  1663. if (isComposing) {
  1664. if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  1665. var chars = getData();
  1666. reset();
  1667. isComposing = false;
  1668. return chars;
  1669. }
  1670. return null;
  1671. }
  1672. switch (topLevelType) {
  1673. case 'topPaste':
  1674. // If a paste event occurs after a keypress, throw out the input
  1675. // chars. Paste events should not lead to BeforeInput events.
  1676. return null;
  1677. case 'topKeyPress':
  1678. /**
  1679. * As of v27, Firefox may fire keypress events even when no character
  1680. * will be inserted. A few possibilities:
  1681. *
  1682. * - `which` is `0`. Arrow keys, Esc key, etc.
  1683. *
  1684. * - `which` is the pressed key code, but no char is available.
  1685. * Ex: 'AltGr + d` in Polish. There is no modified character for
  1686. * this key combination and no character is inserted into the
  1687. * document, but FF fires the keypress for char code `100` anyway.
  1688. * No `input` event will occur.
  1689. *
  1690. * - `which` is the pressed key code, but a command combination is
  1691. * being used. Ex: `Cmd+C`. No character is inserted, and no
  1692. * `input` event will occur.
  1693. */
  1694. if (!isKeypressCommand(nativeEvent)) {
  1695. // IE fires the `keypress` event when a user types an emoji via
  1696. // Touch keyboard of Windows. In such a case, the `char` property
  1697. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  1698. // is 2, the property `which` does not represent an emoji correctly.
  1699. // In such a case, we directly return the `char` property instead of
  1700. // using `which`.
  1701. if (nativeEvent.char && nativeEvent.char.length > 1) {
  1702. return nativeEvent.char;
  1703. } else if (nativeEvent.which) {
  1704. return String.fromCharCode(nativeEvent.which);
  1705. }
  1706. }
  1707. return null;
  1708. case 'topCompositionEnd':
  1709. return useFallbackCompositionData ? null : nativeEvent.data;
  1710. default:
  1711. return null;
  1712. }
  1713. }
  1714. /**
  1715. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  1716. * `textInput` or fallback behavior.
  1717. *
  1718. * @return {?object} A SyntheticInputEvent.
  1719. */
  1720. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1721. var chars = void 0;
  1722. if (canUseTextInputEvent) {
  1723. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  1724. } else {
  1725. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  1726. }
  1727. // If no characters are being inserted, no BeforeInput event should
  1728. // be fired.
  1729. if (!chars) {
  1730. return null;
  1731. }
  1732. var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  1733. event.data = chars;
  1734. accumulateTwoPhaseDispatches(event);
  1735. return event;
  1736. }
  1737. /**
  1738. * Create an `onBeforeInput` event to match
  1739. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  1740. *
  1741. * This event plugin is based on the native `textInput` event
  1742. * available in Chrome, Safari, Opera, and IE. This event fires after
  1743. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  1744. *
  1745. * `beforeInput` is spec'd but not implemented in any browsers, and
  1746. * the `input` event does not provide any useful information about what has
  1747. * actually been added, contrary to the spec. Thus, `textInput` is the best
  1748. * available event to identify the characters that have actually been inserted
  1749. * into the target node.
  1750. *
  1751. * This plugin is also responsible for emitting `composition` events, thus
  1752. * allowing us to share composition fallback code for both `beforeInput` and
  1753. * `composition` event types.
  1754. */
  1755. var BeforeInputEventPlugin = {
  1756. eventTypes: eventTypes,
  1757. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1758. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  1759. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  1760. if (composition === null) {
  1761. return beforeInput;
  1762. }
  1763. if (beforeInput === null) {
  1764. return composition;
  1765. }
  1766. return [composition, beforeInput];
  1767. }
  1768. };
  1769. // Use to restore controlled state after a change event has fired.
  1770. var fiberHostComponent = null;
  1771. var ReactControlledComponentInjection = {
  1772. injectFiberControlledHostComponent: function (hostComponentImpl) {
  1773. // The fiber implementation doesn't use dynamic dispatch so we need to
  1774. // inject the implementation.
  1775. fiberHostComponent = hostComponentImpl;
  1776. }
  1777. };
  1778. var restoreTarget = null;
  1779. var restoreQueue = null;
  1780. function restoreStateOfTarget(target) {
  1781. // We perform this translation at the end of the event loop so that we
  1782. // always receive the correct fiber here
  1783. var internalInstance = getInstanceFromNode(target);
  1784. if (!internalInstance) {
  1785. // Unmounted
  1786. return;
  1787. }
  1788. !(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function') ? invariant_1(false, 'Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  1789. var props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
  1790. fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props);
  1791. }
  1792. var injection$2 = ReactControlledComponentInjection;
  1793. function enqueueStateRestore(target) {
  1794. if (restoreTarget) {
  1795. if (restoreQueue) {
  1796. restoreQueue.push(target);
  1797. } else {
  1798. restoreQueue = [target];
  1799. }
  1800. } else {
  1801. restoreTarget = target;
  1802. }
  1803. }
  1804. function needsStateRestore() {
  1805. return restoreTarget !== null || restoreQueue !== null;
  1806. }
  1807. function restoreStateIfNeeded() {
  1808. if (!restoreTarget) {
  1809. return;
  1810. }
  1811. var target = restoreTarget;
  1812. var queuedTargets = restoreQueue;
  1813. restoreTarget = null;
  1814. restoreQueue = null;
  1815. restoreStateOfTarget(target);
  1816. if (queuedTargets) {
  1817. for (var i = 0; i < queuedTargets.length; i++) {
  1818. restoreStateOfTarget(queuedTargets[i]);
  1819. }
  1820. }
  1821. }
  1822. var ReactControlledComponent = Object.freeze({
  1823. injection: injection$2,
  1824. enqueueStateRestore: enqueueStateRestore,
  1825. needsStateRestore: needsStateRestore,
  1826. restoreStateIfNeeded: restoreStateIfNeeded
  1827. });
  1828. // Used as a way to call batchedUpdates when we don't have a reference to
  1829. // the renderer. Such as when we're dispatching events or if third party
  1830. // libraries need to call batchedUpdates. Eventually, this API will go away when
  1831. // everything is batched by default. We'll then have a similar API to opt-out of
  1832. // scheduled work and instead do synchronous work.
  1833. // Defaults
  1834. var _batchedUpdates = function (fn, bookkeeping) {
  1835. return fn(bookkeeping);
  1836. };
  1837. var _interactiveUpdates = function (fn, a, b) {
  1838. return fn(a, b);
  1839. };
  1840. var _flushInteractiveUpdates = function () {};
  1841. var isBatching = false;
  1842. function batchedUpdates(fn, bookkeeping) {
  1843. if (isBatching) {
  1844. // If we are currently inside another batch, we need to wait until it
  1845. // fully completes before restoring state.
  1846. return fn(bookkeeping);
  1847. }
  1848. isBatching = true;
  1849. try {
  1850. return _batchedUpdates(fn, bookkeeping);
  1851. } finally {
  1852. // Here we wait until all updates have propagated, which is important
  1853. // when using controlled components within layers:
  1854. // https://github.com/facebook/react/issues/1698
  1855. // Then we restore state of any controlled component.
  1856. isBatching = false;
  1857. var controlledComponentsHavePendingUpdates = needsStateRestore();
  1858. if (controlledComponentsHavePendingUpdates) {
  1859. // If a controlled event was fired, we may need to restore the state of
  1860. // the DOM node back to the controlled value. This is necessary when React
  1861. // bails out of the update without touching the DOM.
  1862. _flushInteractiveUpdates();
  1863. restoreStateIfNeeded();
  1864. }
  1865. }
  1866. }
  1867. function interactiveUpdates(fn, a, b) {
  1868. return _interactiveUpdates(fn, a, b);
  1869. }
  1870. var injection$3 = {
  1871. injectRenderer: function (renderer) {
  1872. _batchedUpdates = renderer.batchedUpdates;
  1873. _interactiveUpdates = renderer.interactiveUpdates;
  1874. _flushInteractiveUpdates = renderer.flushInteractiveUpdates;
  1875. }
  1876. };
  1877. /**
  1878. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  1879. */
  1880. var supportedInputTypes = {
  1881. color: true,
  1882. date: true,
  1883. datetime: true,
  1884. 'datetime-local': true,
  1885. email: true,
  1886. month: true,
  1887. number: true,
  1888. password: true,
  1889. range: true,
  1890. search: true,
  1891. tel: true,
  1892. text: true,
  1893. time: true,
  1894. url: true,
  1895. week: true
  1896. };
  1897. function isTextInputElement(elem) {
  1898. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  1899. if (nodeName === 'input') {
  1900. return !!supportedInputTypes[elem.type];
  1901. }
  1902. if (nodeName === 'textarea') {
  1903. return true;
  1904. }
  1905. return false;
  1906. }
  1907. /**
  1908. * HTML nodeType values that represent the type of the node
  1909. */
  1910. var ELEMENT_NODE = 1;
  1911. var TEXT_NODE = 3;
  1912. var COMMENT_NODE = 8;
  1913. var DOCUMENT_NODE = 9;
  1914. var DOCUMENT_FRAGMENT_NODE = 11;
  1915. /**
  1916. * Gets the target node from a native browser event by accounting for
  1917. * inconsistencies in browser DOM APIs.
  1918. *
  1919. * @param {object} nativeEvent Native browser event.
  1920. * @return {DOMEventTarget} Target node.
  1921. */
  1922. function getEventTarget(nativeEvent) {
  1923. var target = nativeEvent.target || window;
  1924. // Normalize SVG <use> element events #4963
  1925. if (target.correspondingUseElement) {
  1926. target = target.correspondingUseElement;
  1927. }
  1928. // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  1929. // @see http://www.quirksmode.org/js/events_properties.html
  1930. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  1931. }
  1932. /**
  1933. * Checks if an event is supported in the current execution environment.
  1934. *
  1935. * NOTE: This will not work correctly for non-generic events such as `change`,
  1936. * `reset`, `load`, `error`, and `select`.
  1937. *
  1938. * Borrows from Modernizr.
  1939. *
  1940. * @param {string} eventNameSuffix Event name, e.g. "click".
  1941. * @param {?boolean} capture Check if the capture phase is supported.
  1942. * @return {boolean} True if the event is supported.
  1943. * @internal
  1944. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  1945. */
  1946. function isEventSupported(eventNameSuffix, capture) {
  1947. if (!ExecutionEnvironment_1.canUseDOM || capture && !('addEventListener' in document)) {
  1948. return false;
  1949. }
  1950. var eventName = 'on' + eventNameSuffix;
  1951. var isSupported = eventName in document;
  1952. if (!isSupported) {
  1953. var element = document.createElement('div');
  1954. element.setAttribute(eventName, 'return;');
  1955. isSupported = typeof element[eventName] === 'function';
  1956. }
  1957. return isSupported;
  1958. }
  1959. function isCheckable(elem) {
  1960. var type = elem.type;
  1961. var nodeName = elem.nodeName;
  1962. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  1963. }
  1964. function getTracker(node) {
  1965. return node._valueTracker;
  1966. }
  1967. function detachTracker(node) {
  1968. node._valueTracker = null;
  1969. }
  1970. function getValueFromNode(node) {
  1971. var value = '';
  1972. if (!node) {
  1973. return value;
  1974. }
  1975. if (isCheckable(node)) {
  1976. value = node.checked ? 'true' : 'false';
  1977. } else {
  1978. value = node.value;
  1979. }
  1980. return value;
  1981. }
  1982. function trackValueOnNode(node) {
  1983. var valueField = isCheckable(node) ? 'checked' : 'value';
  1984. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  1985. var currentValue = '' + node[valueField];
  1986. // if someone has already defined a value or Safari, then bail
  1987. // and don't track value will cause over reporting of changes,
  1988. // but it's better then a hard failure
  1989. // (needed for certain tests that spyOn input values and Safari)
  1990. if (node.hasOwnProperty(valueField) || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  1991. return;
  1992. }
  1993. Object.defineProperty(node, valueField, {
  1994. configurable: true,
  1995. get: function () {
  1996. return descriptor.get.call(this);
  1997. },
  1998. set: function (value) {
  1999. currentValue = '' + value;
  2000. descriptor.set.call(this, value);
  2001. }
  2002. });
  2003. // We could've passed this the first time
  2004. // but it triggers a bug in IE11 and Edge 14/15.
  2005. // Calling defineProperty() again should be equivalent.
  2006. // https://github.com/facebook/react/issues/11768
  2007. Object.defineProperty(node, valueField, {
  2008. enumerable: descriptor.enumerable
  2009. });
  2010. var tracker = {
  2011. getValue: function () {
  2012. return currentValue;
  2013. },
  2014. setValue: function (value) {
  2015. currentValue = '' + value;
  2016. },
  2017. stopTracking: function () {
  2018. detachTracker(node);
  2019. delete node[valueField];
  2020. }
  2021. };
  2022. return tracker;
  2023. }
  2024. function track(node) {
  2025. if (getTracker(node)) {
  2026. return;
  2027. }
  2028. // TODO: Once it's just Fiber we can move this to node._wrapperState
  2029. node._valueTracker = trackValueOnNode(node);
  2030. }
  2031. function updateValueIfChanged(node) {
  2032. if (!node) {
  2033. return false;
  2034. }
  2035. var tracker = getTracker(node);
  2036. // if there is no tracker at this point it's unlikely
  2037. // that trying again will succeed
  2038. if (!tracker) {
  2039. return true;
  2040. }
  2041. var lastValue = tracker.getValue();
  2042. var nextValue = getValueFromNode(node);
  2043. if (nextValue !== lastValue) {
  2044. tracker.setValue(nextValue);
  2045. return true;
  2046. }
  2047. return false;
  2048. }
  2049. var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  2050. var ReactCurrentOwner = ReactInternals$1.ReactCurrentOwner;
  2051. var ReactDebugCurrentFrame = ReactInternals$1.ReactDebugCurrentFrame;
  2052. var describeComponentFrame = function (name, source, ownerName) {
  2053. return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
  2054. };
  2055. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  2056. // nor polyfill, then a plain number is used for performance.
  2057. var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
  2058. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
  2059. var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
  2060. var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
  2061. var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
  2062. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
  2063. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol['for']('react.strict_mode') : 0xeacc;
  2064. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol['for']('react.provider') : 0xeacd;
  2065. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol['for']('react.context') : 0xeace;
  2066. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol['for']('react.async_mode') : 0xeacf;
  2067. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol['for']('react.forward_ref') : 0xead0;
  2068. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  2069. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  2070. function getIteratorFn(maybeIterable) {
  2071. if (maybeIterable === null || typeof maybeIterable === 'undefined') {
  2072. return null;
  2073. }
  2074. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  2075. if (typeof maybeIterator === 'function') {
  2076. return maybeIterator;
  2077. }
  2078. return null;
  2079. }
  2080. function getComponentName(fiber) {
  2081. var type = fiber.type;
  2082. if (typeof type === 'function') {
  2083. return type.displayName || type.name;
  2084. }
  2085. if (typeof type === 'string') {
  2086. return type;
  2087. }
  2088. switch (type) {
  2089. case REACT_FRAGMENT_TYPE:
  2090. return 'ReactFragment';
  2091. case REACT_PORTAL_TYPE:
  2092. return 'ReactPortal';
  2093. case REACT_CALL_TYPE:
  2094. return 'ReactCall';
  2095. case REACT_RETURN_TYPE:
  2096. return 'ReactReturn';
  2097. }
  2098. if (typeof type === 'object' && type !== null) {
  2099. switch (type.$$typeof) {
  2100. case REACT_FORWARD_REF_TYPE:
  2101. var functionName = type.render.displayName || type.render.name || '';
  2102. return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
  2103. }
  2104. }
  2105. return null;
  2106. }
  2107. function describeFiber(fiber) {
  2108. switch (fiber.tag) {
  2109. case IndeterminateComponent:
  2110. case FunctionalComponent:
  2111. case ClassComponent:
  2112. case HostComponent:
  2113. var owner = fiber._debugOwner;
  2114. var source = fiber._debugSource;
  2115. var name = getComponentName(fiber);
  2116. var ownerName = null;
  2117. if (owner) {
  2118. ownerName = getComponentName(owner);
  2119. }
  2120. return describeComponentFrame(name, source, ownerName);
  2121. default:
  2122. return '';
  2123. }
  2124. }
  2125. // This function can only be called with a work-in-progress fiber and
  2126. // only during begin or complete phase. Do not call it under any other
  2127. // circumstances.
  2128. function getStackAddendumByWorkInProgressFiber(workInProgress) {
  2129. var info = '';
  2130. var node = workInProgress;
  2131. do {
  2132. info += describeFiber(node);
  2133. // Otherwise this return pointer might point to the wrong tree:
  2134. node = node['return'];
  2135. } while (node);
  2136. return info;
  2137. }
  2138. function getCurrentFiberOwnerName$1() {
  2139. {
  2140. var fiber = ReactDebugCurrentFiber.current;
  2141. if (fiber === null) {
  2142. return null;
  2143. }
  2144. var owner = fiber._debugOwner;
  2145. if (owner !== null && typeof owner !== 'undefined') {
  2146. return getComponentName(owner);
  2147. }
  2148. }
  2149. return null;
  2150. }
  2151. function getCurrentFiberStackAddendum$1() {
  2152. {
  2153. var fiber = ReactDebugCurrentFiber.current;
  2154. if (fiber === null) {
  2155. return null;
  2156. }
  2157. // Safe because if current fiber exists, we are reconciling,
  2158. // and it is guaranteed to be the work-in-progress version.
  2159. return getStackAddendumByWorkInProgressFiber(fiber);
  2160. }
  2161. return null;
  2162. }
  2163. function resetCurrentFiber() {
  2164. ReactDebugCurrentFrame.getCurrentStack = null;
  2165. ReactDebugCurrentFiber.current = null;
  2166. ReactDebugCurrentFiber.phase = null;
  2167. }
  2168. function setCurrentFiber(fiber) {
  2169. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackAddendum$1;
  2170. ReactDebugCurrentFiber.current = fiber;
  2171. ReactDebugCurrentFiber.phase = null;
  2172. }
  2173. function setCurrentPhase(phase) {
  2174. ReactDebugCurrentFiber.phase = phase;
  2175. }
  2176. var ReactDebugCurrentFiber = {
  2177. current: null,
  2178. phase: null,
  2179. resetCurrentFiber: resetCurrentFiber,
  2180. setCurrentFiber: setCurrentFiber,
  2181. setCurrentPhase: setCurrentPhase,
  2182. getCurrentFiberOwnerName: getCurrentFiberOwnerName$1,
  2183. getCurrentFiberStackAddendum: getCurrentFiberStackAddendum$1
  2184. };
  2185. // A reserved attribute.
  2186. // It is handled by React separately and shouldn't be written to the DOM.
  2187. var RESERVED = 0;
  2188. // A simple string attribute.
  2189. // Attributes that aren't in the whitelist are presumed to have this type.
  2190. var STRING = 1;
  2191. // A string attribute that accepts booleans in React. In HTML, these are called
  2192. // "enumerated" attributes with "true" and "false" as possible values.
  2193. // When true, it should be set to a "true" string.
  2194. // When false, it should be set to a "false" string.
  2195. var BOOLEANISH_STRING = 2;
  2196. // A real boolean attribute.
  2197. // When true, it should be present (set either to an empty string or its name).
  2198. // When false, it should be omitted.
  2199. var BOOLEAN = 3;
  2200. // An attribute that can be used as a flag as well as with a value.
  2201. // When true, it should be present (set either to an empty string or its name).
  2202. // When false, it should be omitted.
  2203. // For any other value, should be present with that value.
  2204. var OVERLOADED_BOOLEAN = 4;
  2205. // An attribute that must be numeric or parse as a numeric.
  2206. // When falsy, it should be removed.
  2207. var NUMERIC = 5;
  2208. // An attribute that must be positive numeric or parse as a positive numeric.
  2209. // When falsy, it should be removed.
  2210. var POSITIVE_NUMERIC = 6;
  2211. /* eslint-disable max-len */
  2212. var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
  2213. /* eslint-enable max-len */
  2214. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
  2215. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  2216. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  2217. var illegalAttributeNameCache = {};
  2218. var validatedAttributeNameCache = {};
  2219. function isAttributeNameSafe(attributeName) {
  2220. if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
  2221. return true;
  2222. }
  2223. if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
  2224. return false;
  2225. }
  2226. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  2227. validatedAttributeNameCache[attributeName] = true;
  2228. return true;
  2229. }
  2230. illegalAttributeNameCache[attributeName] = true;
  2231. {
  2232. warning_1(false, 'Invalid attribute name: `%s`', attributeName);
  2233. }
  2234. return false;
  2235. }
  2236. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  2237. if (propertyInfo !== null) {
  2238. return propertyInfo.type === RESERVED;
  2239. }
  2240. if (isCustomComponentTag) {
  2241. return false;
  2242. }
  2243. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  2244. return true;
  2245. }
  2246. return false;
  2247. }
  2248. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  2249. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  2250. return false;
  2251. }
  2252. switch (typeof value) {
  2253. case 'function':
  2254. // $FlowIssue symbol is perfectly valid here
  2255. case 'symbol':
  2256. // eslint-disable-line
  2257. return true;
  2258. case 'boolean':
  2259. {
  2260. if (isCustomComponentTag) {
  2261. return false;
  2262. }
  2263. if (propertyInfo !== null) {
  2264. return !propertyInfo.acceptsBooleans;
  2265. } else {
  2266. var prefix = name.toLowerCase().slice(0, 5);
  2267. return prefix !== 'data-' && prefix !== 'aria-';
  2268. }
  2269. }
  2270. default:
  2271. return false;
  2272. }
  2273. }
  2274. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  2275. if (value === null || typeof value === 'undefined') {
  2276. return true;
  2277. }
  2278. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  2279. return true;
  2280. }
  2281. if (propertyInfo !== null) {
  2282. switch (propertyInfo.type) {
  2283. case BOOLEAN:
  2284. return !value;
  2285. case OVERLOADED_BOOLEAN:
  2286. return value === false;
  2287. case NUMERIC:
  2288. return isNaN(value);
  2289. case POSITIVE_NUMERIC:
  2290. return isNaN(value) || value < 1;
  2291. }
  2292. }
  2293. return false;
  2294. }
  2295. function getPropertyInfo(name) {
  2296. return properties.hasOwnProperty(name) ? properties[name] : null;
  2297. }
  2298. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace) {
  2299. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  2300. this.attributeName = attributeName;
  2301. this.attributeNamespace = attributeNamespace;
  2302. this.mustUseProperty = mustUseProperty;
  2303. this.propertyName = name;
  2304. this.type = type;
  2305. }
  2306. // When adding attributes to this list, be sure to also add them to
  2307. // the `possibleStandardNames` module to ensure casing and incorrect
  2308. // name warnings.
  2309. var properties = {};
  2310. // These props are reserved by React. They shouldn't be written to the DOM.
  2311. ['children', 'dangerouslySetInnerHTML',
  2312. // TODO: This prevents the assignment of defaultValue to regular
  2313. // elements (not just inputs). Now that ReactDOMInput assigns to the
  2314. // defaultValue property -- do we need this?
  2315. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
  2316. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  2317. name, // attributeName
  2318. null);
  2319. });
  2320. // A few React string attributes have a different name.
  2321. // This is a mapping from React prop names to the attribute names.
  2322. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  2323. var name = _ref[0],
  2324. attributeName = _ref[1];
  2325. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2326. attributeName, // attributeName
  2327. null);
  2328. });
  2329. // These are "enumerated" HTML attributes that accept "true" and "false".
  2330. // In React, we let users pass `true` and `false` even though technically
  2331. // these aren't boolean attributes (they are coerced to strings).
  2332. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  2333. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  2334. name.toLowerCase(), // attributeName
  2335. null);
  2336. });
  2337. // These are "enumerated" SVG attributes that accept "true" and "false".
  2338. // In React, we let users pass `true` and `false` even though technically
  2339. // these aren't boolean attributes (they are coerced to strings).
  2340. // Since these are SVG attributes, their attribute names are case-sensitive.
  2341. ['autoReverse', 'externalResourcesRequired', 'preserveAlpha'].forEach(function (name) {
  2342. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  2343. name, // attributeName
  2344. null);
  2345. });
  2346. // These are HTML boolean attributes.
  2347. ['allowFullScreen', 'async',
  2348. // Note: there is a special case that prevents it from being written to the DOM
  2349. // on the client side because the browsers are inconsistent. Instead we call focus().
  2350. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
  2351. // Microdata
  2352. 'itemScope'].forEach(function (name) {
  2353. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  2354. name.toLowerCase(), // attributeName
  2355. null);
  2356. });
  2357. // These are the few React props that we set as DOM properties
  2358. // rather than attributes. These are all booleans.
  2359. ['checked',
  2360. // Note: `option.selected` is not updated if `select.multiple` is
  2361. // disabled with `removeAttribute`. We have special logic for handling this.
  2362. 'multiple', 'muted', 'selected'].forEach(function (name) {
  2363. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  2364. name.toLowerCase(), // attributeName
  2365. null);
  2366. });
  2367. // These are HTML attributes that are "overloaded booleans": they behave like
  2368. // booleans, but can also accept a string value.
  2369. ['capture', 'download'].forEach(function (name) {
  2370. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  2371. name.toLowerCase(), // attributeName
  2372. null);
  2373. });
  2374. // These are HTML attributes that must be positive numbers.
  2375. ['cols', 'rows', 'size', 'span'].forEach(function (name) {
  2376. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  2377. name.toLowerCase(), // attributeName
  2378. null);
  2379. });
  2380. // These are HTML attributes that must be numbers.
  2381. ['rowSpan', 'start'].forEach(function (name) {
  2382. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  2383. name.toLowerCase(), // attributeName
  2384. null);
  2385. });
  2386. var CAMELIZE = /[\-\:]([a-z])/g;
  2387. var capitalize = function (token) {
  2388. return token[1].toUpperCase();
  2389. };
  2390. // This is a list of all SVG attributes that need special casing, namespacing,
  2391. // or boolean value assignment. Regular attributes that just accept strings
  2392. // and have the same names are omitted, just like in the HTML whitelist.
  2393. // Some of these attributes can be hard to find. This list was created by
  2394. // scrapping the MDN documentation.
  2395. ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) {
  2396. var name = attributeName.replace(CAMELIZE, capitalize);
  2397. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2398. attributeName, null);
  2399. });
  2400. // String SVG attributes with the xlink namespace.
  2401. ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
  2402. var name = attributeName.replace(CAMELIZE, capitalize);
  2403. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2404. attributeName, 'http://www.w3.org/1999/xlink');
  2405. });
  2406. // String SVG attributes with the xml namespace.
  2407. ['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
  2408. var name = attributeName.replace(CAMELIZE, capitalize);
  2409. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2410. attributeName, 'http://www.w3.org/XML/1998/namespace');
  2411. });
  2412. // Special case: this attribute exists both in HTML and SVG.
  2413. // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
  2414. // its React `tabIndex` name, like we do for attributes that exist only in HTML.
  2415. properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
  2416. 'tabindex', // attributeName
  2417. null);
  2418. /**
  2419. * Get the value for a property on a node. Only used in DEV for SSR validation.
  2420. * The "expected" argument is used as a hint of what the expected value is.
  2421. * Some properties have multiple equivalent values.
  2422. */
  2423. function getValueForProperty(node, name, expected, propertyInfo) {
  2424. {
  2425. if (propertyInfo.mustUseProperty) {
  2426. var propertyName = propertyInfo.propertyName;
  2427. return node[propertyName];
  2428. } else {
  2429. var attributeName = propertyInfo.attributeName;
  2430. var stringValue = null;
  2431. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  2432. if (node.hasAttribute(attributeName)) {
  2433. var value = node.getAttribute(attributeName);
  2434. if (value === '') {
  2435. return true;
  2436. }
  2437. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2438. return value;
  2439. }
  2440. if (value === '' + expected) {
  2441. return expected;
  2442. }
  2443. return value;
  2444. }
  2445. } else if (node.hasAttribute(attributeName)) {
  2446. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2447. // We had an attribute but shouldn't have had one, so read it
  2448. // for the error message.
  2449. return node.getAttribute(attributeName);
  2450. }
  2451. if (propertyInfo.type === BOOLEAN) {
  2452. // If this was a boolean, it doesn't matter what the value is
  2453. // the fact that we have it is the same as the expected.
  2454. return expected;
  2455. }
  2456. // Even if this property uses a namespace we use getAttribute
  2457. // because we assume its namespaced name is the same as our config.
  2458. // To use getAttributeNS we need the local name which we don't have
  2459. // in our config atm.
  2460. stringValue = node.getAttribute(attributeName);
  2461. }
  2462. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2463. return stringValue === null ? expected : stringValue;
  2464. } else if (stringValue === '' + expected) {
  2465. return expected;
  2466. } else {
  2467. return stringValue;
  2468. }
  2469. }
  2470. }
  2471. }
  2472. /**
  2473. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  2474. * The third argument is used as a hint of what the expected value is. Some
  2475. * attributes have multiple equivalent values.
  2476. */
  2477. function getValueForAttribute(node, name, expected) {
  2478. {
  2479. if (!isAttributeNameSafe(name)) {
  2480. return;
  2481. }
  2482. if (!node.hasAttribute(name)) {
  2483. return expected === undefined ? undefined : null;
  2484. }
  2485. var value = node.getAttribute(name);
  2486. if (value === '' + expected) {
  2487. return expected;
  2488. }
  2489. return value;
  2490. }
  2491. }
  2492. /**
  2493. * Sets the value for a property on a node.
  2494. *
  2495. * @param {DOMElement} node
  2496. * @param {string} name
  2497. * @param {*} value
  2498. */
  2499. function setValueForProperty(node, name, value, isCustomComponentTag) {
  2500. var propertyInfo = getPropertyInfo(name);
  2501. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  2502. return;
  2503. }
  2504. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  2505. value = null;
  2506. }
  2507. // If the prop isn't in the special list, treat it as a simple attribute.
  2508. if (isCustomComponentTag || propertyInfo === null) {
  2509. if (isAttributeNameSafe(name)) {
  2510. var _attributeName = name;
  2511. if (value === null) {
  2512. node.removeAttribute(_attributeName);
  2513. } else {
  2514. node.setAttribute(_attributeName, '' + value);
  2515. }
  2516. }
  2517. return;
  2518. }
  2519. var mustUseProperty = propertyInfo.mustUseProperty;
  2520. if (mustUseProperty) {
  2521. var propertyName = propertyInfo.propertyName;
  2522. if (value === null) {
  2523. var type = propertyInfo.type;
  2524. node[propertyName] = type === BOOLEAN ? false : '';
  2525. } else {
  2526. // Contrary to `setAttribute`, object properties are properly
  2527. // `toString`ed by IE8/9.
  2528. node[propertyName] = value;
  2529. }
  2530. return;
  2531. }
  2532. // The rest are treated as attributes with special cases.
  2533. var attributeName = propertyInfo.attributeName,
  2534. attributeNamespace = propertyInfo.attributeNamespace;
  2535. if (value === null) {
  2536. node.removeAttribute(attributeName);
  2537. } else {
  2538. var _type = propertyInfo.type;
  2539. var attributeValue = void 0;
  2540. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  2541. attributeValue = '';
  2542. } else {
  2543. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  2544. // ('' + value) makes it output the correct toString()-value.
  2545. attributeValue = '' + value;
  2546. }
  2547. if (attributeNamespace) {
  2548. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  2549. } else {
  2550. node.setAttribute(attributeName, attributeValue);
  2551. }
  2552. }
  2553. }
  2554. /**
  2555. * Copyright (c) 2013-present, Facebook, Inc.
  2556. *
  2557. * This source code is licensed under the MIT license found in the
  2558. * LICENSE file in the root directory of this source tree.
  2559. */
  2560. var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  2561. var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
  2562. /**
  2563. * Copyright (c) 2013-present, Facebook, Inc.
  2564. *
  2565. * This source code is licensed under the MIT license found in the
  2566. * LICENSE file in the root directory of this source tree.
  2567. */
  2568. {
  2569. var invariant$2 = invariant_1;
  2570. var warning$2 = warning_1;
  2571. var ReactPropTypesSecret = ReactPropTypesSecret_1;
  2572. var loggedTypeFailures = {};
  2573. }
  2574. /**
  2575. * Assert that the values match with the type specs.
  2576. * Error messages are memorized and will only be shown once.
  2577. *
  2578. * @param {object} typeSpecs Map of name to a ReactPropType
  2579. * @param {object} values Runtime values that need to be type-checked
  2580. * @param {string} location e.g. "prop", "context", "child context"
  2581. * @param {string} componentName Name of the component for error messages.
  2582. * @param {?Function} getStack Returns the component stack.
  2583. * @private
  2584. */
  2585. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  2586. {
  2587. for (var typeSpecName in typeSpecs) {
  2588. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  2589. var error;
  2590. // Prop type validation may throw. In case they do, we don't want to
  2591. // fail the render phase where it didn't fail before. So we log it.
  2592. // After these have been cleaned up, we'll let them throw.
  2593. try {
  2594. // This is intentionally an invariant that gets caught. It's the same
  2595. // behavior as without this statement except with a better message.
  2596. invariant$2(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
  2597. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  2598. } catch (ex) {
  2599. error = ex;
  2600. }
  2601. warning$2(!error || error instanceof 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);
  2602. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  2603. // Only monitor this failure once because there tends to be a lot of the
  2604. // same error.
  2605. loggedTypeFailures[error.message] = true;
  2606. var stack = getStack ? getStack() : '';
  2607. warning$2(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
  2608. }
  2609. }
  2610. }
  2611. }
  2612. }
  2613. var checkPropTypes_1 = checkPropTypes;
  2614. var ReactControlledValuePropTypes = {
  2615. checkPropTypes: null
  2616. };
  2617. {
  2618. var hasReadOnlyValue = {
  2619. button: true,
  2620. checkbox: true,
  2621. image: true,
  2622. hidden: true,
  2623. radio: true,
  2624. reset: true,
  2625. submit: true
  2626. };
  2627. var propTypes = {
  2628. value: function (props, propName, componentName) {
  2629. if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
  2630. return null;
  2631. }
  2632. 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`.');
  2633. },
  2634. checked: function (props, propName, componentName) {
  2635. if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
  2636. return null;
  2637. }
  2638. 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`.');
  2639. }
  2640. };
  2641. /**
  2642. * Provide a linked `value` attribute for controlled forms. You should not use
  2643. * this outside of the ReactDOM controlled form components.
  2644. */
  2645. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props, getStack) {
  2646. checkPropTypes_1(propTypes, props, 'prop', tagName, getStack);
  2647. };
  2648. }
  2649. // TODO: direct imports like some-package/src/* are bad. Fix me.
  2650. var getCurrentFiberOwnerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName;
  2651. var getCurrentFiberStackAddendum = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  2652. var didWarnValueDefaultValue = false;
  2653. var didWarnCheckedDefaultChecked = false;
  2654. var didWarnControlledToUncontrolled = false;
  2655. var didWarnUncontrolledToControlled = false;
  2656. function isControlled(props) {
  2657. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  2658. return usesChecked ? props.checked != null : props.value != null;
  2659. }
  2660. /**
  2661. * Implements an <input> host component that allows setting these optional
  2662. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  2663. *
  2664. * If `checked` or `value` are not supplied (or null/undefined), user actions
  2665. * that affect the checked state or value will trigger updates to the element.
  2666. *
  2667. * If they are supplied (and not null/undefined), the rendered element will not
  2668. * trigger updates to the element. Instead, the props must change in order for
  2669. * the rendered element to be updated.
  2670. *
  2671. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  2672. * with an empty value (or `defaultValue`).
  2673. *
  2674. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  2675. */
  2676. function getHostProps(element, props) {
  2677. var node = element;
  2678. var checked = props.checked;
  2679. var hostProps = _assign({}, props, {
  2680. defaultChecked: undefined,
  2681. defaultValue: undefined,
  2682. value: undefined,
  2683. checked: checked != null ? checked : node._wrapperState.initialChecked
  2684. });
  2685. return hostProps;
  2686. }
  2687. function initWrapperState(element, props) {
  2688. {
  2689. ReactControlledValuePropTypes.checkPropTypes('input', props, getCurrentFiberStackAddendum);
  2690. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  2691. warning_1(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName() || 'A component', props.type);
  2692. didWarnCheckedDefaultChecked = true;
  2693. }
  2694. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  2695. warning_1(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName() || 'A component', props.type);
  2696. didWarnValueDefaultValue = true;
  2697. }
  2698. }
  2699. var node = element;
  2700. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  2701. node._wrapperState = {
  2702. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  2703. initialValue: getSafeValue(props.value != null ? props.value : defaultValue),
  2704. controlled: isControlled(props)
  2705. };
  2706. }
  2707. function updateChecked(element, props) {
  2708. var node = element;
  2709. var checked = props.checked;
  2710. if (checked != null) {
  2711. setValueForProperty(node, 'checked', checked, false);
  2712. }
  2713. }
  2714. function updateWrapper(element, props) {
  2715. var node = element;
  2716. {
  2717. var _controlled = isControlled(props);
  2718. if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
  2719. warning_1(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum());
  2720. didWarnUncontrolledToControlled = true;
  2721. }
  2722. if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
  2723. warning_1(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum());
  2724. didWarnControlledToUncontrolled = true;
  2725. }
  2726. }
  2727. updateChecked(element, props);
  2728. var value = getSafeValue(props.value);
  2729. if (value != null) {
  2730. if (props.type === 'number') {
  2731. if (value === 0 && node.value === '' ||
  2732. // eslint-disable-next-line
  2733. node.value != value) {
  2734. node.value = '' + value;
  2735. }
  2736. } else if (node.value !== '' + value) {
  2737. node.value = '' + value;
  2738. }
  2739. }
  2740. if (props.hasOwnProperty('value')) {
  2741. setDefaultValue(node, props.type, value);
  2742. } else if (props.hasOwnProperty('defaultValue')) {
  2743. setDefaultValue(node, props.type, getSafeValue(props.defaultValue));
  2744. }
  2745. if (props.checked == null && props.defaultChecked != null) {
  2746. node.defaultChecked = !!props.defaultChecked;
  2747. }
  2748. }
  2749. function postMountWrapper(element, props) {
  2750. var node = element;
  2751. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  2752. // Do not assign value if it is already set. This prevents user text input
  2753. // from being lost during SSR hydration.
  2754. if (node.value === '') {
  2755. node.value = '' + node._wrapperState.initialValue;
  2756. }
  2757. // value must be assigned before defaultValue. This fixes an issue where the
  2758. // visually displayed value of date inputs disappears on mobile Safari and Chrome:
  2759. // https://github.com/facebook/react/issues/7233
  2760. node.defaultValue = '' + node._wrapperState.initialValue;
  2761. }
  2762. // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  2763. // this is needed to work around a chrome bug where setting defaultChecked
  2764. // will sometimes influence the value of checked (even after detachment).
  2765. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  2766. // We need to temporarily unset name to avoid disrupting radio button groups.
  2767. var name = node.name;
  2768. if (name !== '') {
  2769. node.name = '';
  2770. }
  2771. node.defaultChecked = !node.defaultChecked;
  2772. node.defaultChecked = !node.defaultChecked;
  2773. if (name !== '') {
  2774. node.name = name;
  2775. }
  2776. }
  2777. function restoreControlledState(element, props) {
  2778. var node = element;
  2779. updateWrapper(node, props);
  2780. updateNamedCousins(node, props);
  2781. }
  2782. function updateNamedCousins(rootNode, props) {
  2783. var name = props.name;
  2784. if (props.type === 'radio' && name != null) {
  2785. var queryRoot = rootNode;
  2786. while (queryRoot.parentNode) {
  2787. queryRoot = queryRoot.parentNode;
  2788. }
  2789. // If `rootNode.form` was non-null, then we could try `form.elements`,
  2790. // but that sometimes behaves strangely in IE8. We could also try using
  2791. // `form.getElementsByName`, but that will only return direct children
  2792. // and won't include inputs that use the HTML5 `form=` attribute. Since
  2793. // the input might not even be in a form. It might not even be in the
  2794. // document. Let's just use the local `querySelectorAll` to ensure we don't
  2795. // miss anything.
  2796. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  2797. for (var i = 0; i < group.length; i++) {
  2798. var otherNode = group[i];
  2799. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  2800. continue;
  2801. }
  2802. // This will throw if radio buttons rendered by different copies of React
  2803. // and the same name are rendered into the same form (same as #1939).
  2804. // That's probably okay; we don't support it just as we don't support
  2805. // mixing React radio buttons with non-React ones.
  2806. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  2807. !otherProps ? invariant_1(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : void 0;
  2808. // We need update the tracked value on the named cousin since the value
  2809. // was changed but the input saw no event or value set
  2810. updateValueIfChanged(otherNode);
  2811. // If this is a controlled radio button group, forcing the input that
  2812. // was previously checked to update will cause it to be come re-checked
  2813. // as appropriate.
  2814. updateWrapper(otherNode, otherProps);
  2815. }
  2816. }
  2817. }
  2818. // In Chrome, assigning defaultValue to certain input types triggers input validation.
  2819. // For number inputs, the display value loses trailing decimal points. For email inputs,
  2820. // Chrome raises "The specified value <x> is not a valid email address".
  2821. //
  2822. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  2823. // when the user is inputting text
  2824. //
  2825. // https://github.com/facebook/react/issues/7253
  2826. function setDefaultValue(node, type, value) {
  2827. if (
  2828. // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  2829. type !== 'number' || node.ownerDocument.activeElement !== node) {
  2830. if (value == null) {
  2831. node.defaultValue = '' + node._wrapperState.initialValue;
  2832. } else if (node.defaultValue !== '' + value) {
  2833. node.defaultValue = '' + value;
  2834. }
  2835. }
  2836. }
  2837. function getSafeValue(value) {
  2838. switch (typeof value) {
  2839. case 'boolean':
  2840. case 'number':
  2841. case 'object':
  2842. case 'string':
  2843. case 'undefined':
  2844. return value;
  2845. default:
  2846. // function, symbol are assigned as empty strings
  2847. return '';
  2848. }
  2849. }
  2850. var eventTypes$1 = {
  2851. change: {
  2852. phasedRegistrationNames: {
  2853. bubbled: 'onChange',
  2854. captured: 'onChangeCapture'
  2855. },
  2856. dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange']
  2857. }
  2858. };
  2859. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  2860. var event = SyntheticEvent$1.getPooled(eventTypes$1.change, inst, nativeEvent, target);
  2861. event.type = 'change';
  2862. // Flag this event loop as needing state restore.
  2863. enqueueStateRestore(target);
  2864. accumulateTwoPhaseDispatches(event);
  2865. return event;
  2866. }
  2867. /**
  2868. * For IE shims
  2869. */
  2870. var activeElement = null;
  2871. var activeElementInst = null;
  2872. /**
  2873. * SECTION: handle `change` event
  2874. */
  2875. function shouldUseChangeEvent(elem) {
  2876. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  2877. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  2878. }
  2879. function manualDispatchChangeEvent(nativeEvent) {
  2880. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent));
  2881. // If change and propertychange bubbled, we'd just bind to it like all the
  2882. // other events and have it go through ReactBrowserEventEmitter. Since it
  2883. // doesn't, we manually listen for the events and so we have to enqueue and
  2884. // process the abstract event manually.
  2885. //
  2886. // Batching is necessary here in order to ensure that all event handlers run
  2887. // before the next rerender (including event handlers attached to ancestor
  2888. // elements instead of directly on the input). Without this, controlled
  2889. // components don't work properly in conjunction with event bubbling because
  2890. // the component is rerendered and the value reverted before all the event
  2891. // handlers can run. See https://github.com/facebook/react/issues/708.
  2892. batchedUpdates(runEventInBatch, event);
  2893. }
  2894. function runEventInBatch(event) {
  2895. runEventsInBatch(event, false);
  2896. }
  2897. function getInstIfValueChanged(targetInst) {
  2898. var targetNode = getNodeFromInstance$1(targetInst);
  2899. if (updateValueIfChanged(targetNode)) {
  2900. return targetInst;
  2901. }
  2902. }
  2903. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  2904. if (topLevelType === 'topChange') {
  2905. return targetInst;
  2906. }
  2907. }
  2908. /**
  2909. * SECTION: handle `input` event
  2910. */
  2911. var isInputEventSupported = false;
  2912. if (ExecutionEnvironment_1.canUseDOM) {
  2913. // IE9 claims to support the input event but fails to trigger it when
  2914. // deleting text, so we ignore its input events.
  2915. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  2916. }
  2917. /**
  2918. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  2919. * and override the value property so that we can distinguish user events from
  2920. * value changes in JS.
  2921. */
  2922. function startWatchingForValueChange(target, targetInst) {
  2923. activeElement = target;
  2924. activeElementInst = targetInst;
  2925. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  2926. }
  2927. /**
  2928. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  2929. * if any exists.
  2930. */
  2931. function stopWatchingForValueChange() {
  2932. if (!activeElement) {
  2933. return;
  2934. }
  2935. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  2936. activeElement = null;
  2937. activeElementInst = null;
  2938. }
  2939. /**
  2940. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  2941. * the value of the active element has changed.
  2942. */
  2943. function handlePropertyChange(nativeEvent) {
  2944. if (nativeEvent.propertyName !== 'value') {
  2945. return;
  2946. }
  2947. if (getInstIfValueChanged(activeElementInst)) {
  2948. manualDispatchChangeEvent(nativeEvent);
  2949. }
  2950. }
  2951. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  2952. if (topLevelType === 'topFocus') {
  2953. // In IE9, propertychange fires for most input events but is buggy and
  2954. // doesn't fire when text is deleted, but conveniently, selectionchange
  2955. // appears to fire in all of the remaining cases so we catch those and
  2956. // forward the event if the value has changed
  2957. // In either case, we don't want to call the event handler if the value
  2958. // is changed from JS so we redefine a setter for `.value` that updates
  2959. // our activeElementValue variable, allowing us to ignore those changes
  2960. //
  2961. // stopWatching() should be a noop here but we call it just in case we
  2962. // missed a blur event somehow.
  2963. stopWatchingForValueChange();
  2964. startWatchingForValueChange(target, targetInst);
  2965. } else if (topLevelType === 'topBlur') {
  2966. stopWatchingForValueChange();
  2967. }
  2968. }
  2969. // For IE8 and IE9.
  2970. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  2971. if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') {
  2972. // On the selectionchange event, the target is just document which isn't
  2973. // helpful for us so just check activeElement instead.
  2974. //
  2975. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  2976. // propertychange on the first input event after setting `value` from a
  2977. // script and fires only keydown, keypress, keyup. Catching keyup usually
  2978. // gets it and catching keydown lets us fire an event for the first
  2979. // keystroke if user does a key repeat (it'll be a little delayed: right
  2980. // before the second keystroke). Other input methods (e.g., paste) seem to
  2981. // fire selectionchange normally.
  2982. return getInstIfValueChanged(activeElementInst);
  2983. }
  2984. }
  2985. /**
  2986. * SECTION: handle `click` event
  2987. */
  2988. function shouldUseClickEvent(elem) {
  2989. // Use the `click` event to detect changes to checkbox and radio inputs.
  2990. // This approach works across all browsers, whereas `change` does not fire
  2991. // until `blur` in IE8.
  2992. var nodeName = elem.nodeName;
  2993. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  2994. }
  2995. function getTargetInstForClickEvent(topLevelType, targetInst) {
  2996. if (topLevelType === 'topClick') {
  2997. return getInstIfValueChanged(targetInst);
  2998. }
  2999. }
  3000. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  3001. if (topLevelType === 'topInput' || topLevelType === 'topChange') {
  3002. return getInstIfValueChanged(targetInst);
  3003. }
  3004. }
  3005. function handleControlledInputBlur(inst, node) {
  3006. // TODO: In IE, inst is occasionally null. Why?
  3007. if (inst == null) {
  3008. return;
  3009. }
  3010. // Fiber and ReactDOM keep wrapper state in separate places
  3011. var state = inst._wrapperState || node._wrapperState;
  3012. if (!state || !state.controlled || node.type !== 'number') {
  3013. return;
  3014. }
  3015. // If controlled, assign the value attribute to the current value on blur
  3016. setDefaultValue(node, 'number', node.value);
  3017. }
  3018. /**
  3019. * This plugin creates an `onChange` event that normalizes change events
  3020. * across form elements. This event fires at a time when it's possible to
  3021. * change the element's value without seeing a flicker.
  3022. *
  3023. * Supported elements are:
  3024. * - input (see `isTextInputElement`)
  3025. * - textarea
  3026. * - select
  3027. */
  3028. var ChangeEventPlugin = {
  3029. eventTypes: eventTypes$1,
  3030. _isInputEventSupported: isInputEventSupported,
  3031. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3032. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  3033. var getTargetInstFunc = void 0,
  3034. handleEventFunc = void 0;
  3035. if (shouldUseChangeEvent(targetNode)) {
  3036. getTargetInstFunc = getTargetInstForChangeEvent;
  3037. } else if (isTextInputElement(targetNode)) {
  3038. if (isInputEventSupported) {
  3039. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  3040. } else {
  3041. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  3042. handleEventFunc = handleEventsForInputEventPolyfill;
  3043. }
  3044. } else if (shouldUseClickEvent(targetNode)) {
  3045. getTargetInstFunc = getTargetInstForClickEvent;
  3046. }
  3047. if (getTargetInstFunc) {
  3048. var inst = getTargetInstFunc(topLevelType, targetInst);
  3049. if (inst) {
  3050. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  3051. return event;
  3052. }
  3053. }
  3054. if (handleEventFunc) {
  3055. handleEventFunc(topLevelType, targetNode, targetInst);
  3056. }
  3057. // When blurring, set the value attribute for number inputs
  3058. if (topLevelType === 'topBlur') {
  3059. handleControlledInputBlur(targetInst, targetNode);
  3060. }
  3061. }
  3062. };
  3063. /**
  3064. * Module that is injectable into `EventPluginHub`, that specifies a
  3065. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  3066. * plugins, without having to package every one of them. This is better than
  3067. * having plugins be ordered in the same order that they are injected because
  3068. * that ordering would be influenced by the packaging order.
  3069. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  3070. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  3071. */
  3072. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  3073. var SyntheticUIEvent = SyntheticEvent$1.extend({
  3074. view: null,
  3075. detail: null
  3076. });
  3077. /**
  3078. * Translation from modifier key to the associated property in the event.
  3079. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  3080. */
  3081. var modifierKeyToProp = {
  3082. Alt: 'altKey',
  3083. Control: 'ctrlKey',
  3084. Meta: 'metaKey',
  3085. Shift: 'shiftKey'
  3086. };
  3087. // IE8 does not implement getModifierState so we simply map it to the only
  3088. // modifier keys exposed by the event itself, does not support Lock-keys.
  3089. // Currently, all major browsers except Chrome seems to support Lock-keys.
  3090. function modifierStateGetter(keyArg) {
  3091. var syntheticEvent = this;
  3092. var nativeEvent = syntheticEvent.nativeEvent;
  3093. if (nativeEvent.getModifierState) {
  3094. return nativeEvent.getModifierState(keyArg);
  3095. }
  3096. var keyProp = modifierKeyToProp[keyArg];
  3097. return keyProp ? !!nativeEvent[keyProp] : false;
  3098. }
  3099. function getEventModifierState(nativeEvent) {
  3100. return modifierStateGetter;
  3101. }
  3102. /**
  3103. * @interface MouseEvent
  3104. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3105. */
  3106. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  3107. screenX: null,
  3108. screenY: null,
  3109. clientX: null,
  3110. clientY: null,
  3111. pageX: null,
  3112. pageY: null,
  3113. ctrlKey: null,
  3114. shiftKey: null,
  3115. altKey: null,
  3116. metaKey: null,
  3117. getModifierState: getEventModifierState,
  3118. button: null,
  3119. buttons: null,
  3120. relatedTarget: function (event) {
  3121. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  3122. }
  3123. });
  3124. var eventTypes$2 = {
  3125. mouseEnter: {
  3126. registrationName: 'onMouseEnter',
  3127. dependencies: ['topMouseOut', 'topMouseOver']
  3128. },
  3129. mouseLeave: {
  3130. registrationName: 'onMouseLeave',
  3131. dependencies: ['topMouseOut', 'topMouseOver']
  3132. }
  3133. };
  3134. var EnterLeaveEventPlugin = {
  3135. eventTypes: eventTypes$2,
  3136. /**
  3137. * For almost every interaction we care about, there will be both a top-level
  3138. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  3139. * we do not extract duplicate events. However, moving the mouse into the
  3140. * browser from outside will not fire a `mouseout` event. In this case, we use
  3141. * the `mouseover` top-level event.
  3142. */
  3143. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3144. if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  3145. return null;
  3146. }
  3147. if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') {
  3148. // Must not be a mouse in or mouse out - ignoring.
  3149. return null;
  3150. }
  3151. var win = void 0;
  3152. if (nativeEventTarget.window === nativeEventTarget) {
  3153. // `nativeEventTarget` is probably a window object.
  3154. win = nativeEventTarget;
  3155. } else {
  3156. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  3157. var doc = nativeEventTarget.ownerDocument;
  3158. if (doc) {
  3159. win = doc.defaultView || doc.parentWindow;
  3160. } else {
  3161. win = window;
  3162. }
  3163. }
  3164. var from = void 0;
  3165. var to = void 0;
  3166. if (topLevelType === 'topMouseOut') {
  3167. from = targetInst;
  3168. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  3169. to = related ? getClosestInstanceFromNode(related) : null;
  3170. } else {
  3171. // Moving to a node from outside the window.
  3172. from = null;
  3173. to = targetInst;
  3174. }
  3175. if (from === to) {
  3176. // Nothing pertains to our managed components.
  3177. return null;
  3178. }
  3179. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  3180. var toNode = to == null ? win : getNodeFromInstance$1(to);
  3181. var leave = SyntheticMouseEvent.getPooled(eventTypes$2.mouseLeave, from, nativeEvent, nativeEventTarget);
  3182. leave.type = 'mouseleave';
  3183. leave.target = fromNode;
  3184. leave.relatedTarget = toNode;
  3185. var enter = SyntheticMouseEvent.getPooled(eventTypes$2.mouseEnter, to, nativeEvent, nativeEventTarget);
  3186. enter.type = 'mouseenter';
  3187. enter.target = toNode;
  3188. enter.relatedTarget = fromNode;
  3189. accumulateEnterLeaveDispatches(leave, enter, from, to);
  3190. return [leave, enter];
  3191. }
  3192. };
  3193. /**
  3194. * Copyright (c) 2013-present, Facebook, Inc.
  3195. *
  3196. * This source code is licensed under the MIT license found in the
  3197. * LICENSE file in the root directory of this source tree.
  3198. *
  3199. * @typechecks
  3200. */
  3201. /* eslint-disable fb-www/typeof-undefined */
  3202. /**
  3203. * Same as document.activeElement but wraps in a try-catch block. In IE it is
  3204. * not safe to call document.activeElement if there is nothing focused.
  3205. *
  3206. * The activeElement will be null only if the document or document body is not
  3207. * yet defined.
  3208. *
  3209. * @param {?DOMDocument} doc Defaults to current document.
  3210. * @return {?DOMElement}
  3211. */
  3212. function getActiveElement(doc) /*?DOMElement*/{
  3213. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  3214. if (typeof doc === 'undefined') {
  3215. return null;
  3216. }
  3217. try {
  3218. return doc.activeElement || doc.body;
  3219. } catch (e) {
  3220. return doc.body;
  3221. }
  3222. }
  3223. var getActiveElement_1 = getActiveElement;
  3224. /**
  3225. * Copyright (c) 2013-present, Facebook, Inc.
  3226. *
  3227. * This source code is licensed under the MIT license found in the
  3228. * LICENSE file in the root directory of this source tree.
  3229. *
  3230. * @typechecks
  3231. *
  3232. */
  3233. /*eslint-disable no-self-compare */
  3234. var hasOwnProperty = Object.prototype.hasOwnProperty;
  3235. /**
  3236. * inlined Object.is polyfill to avoid requiring consumers ship their own
  3237. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  3238. */
  3239. function is(x, y) {
  3240. // SameValue algorithm
  3241. if (x === y) {
  3242. // Steps 1-5, 7-10
  3243. // Steps 6.b-6.e: +0 != -0
  3244. // Added the nonzero y check to make Flow happy, but it is redundant
  3245. return x !== 0 || y !== 0 || 1 / x === 1 / y;
  3246. } else {
  3247. // Step 6.a: NaN == NaN
  3248. return x !== x && y !== y;
  3249. }
  3250. }
  3251. /**
  3252. * Performs equality by iterating through keys on an object and returning false
  3253. * when any key has values which are not strictly equal between the arguments.
  3254. * Returns true when the values of all keys are strictly equal.
  3255. */
  3256. function shallowEqual(objA, objB) {
  3257. if (is(objA, objB)) {
  3258. return true;
  3259. }
  3260. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  3261. return false;
  3262. }
  3263. var keysA = Object.keys(objA);
  3264. var keysB = Object.keys(objB);
  3265. if (keysA.length !== keysB.length) {
  3266. return false;
  3267. }
  3268. // Test for A's keys different from B.
  3269. for (var i = 0; i < keysA.length; i++) {
  3270. if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
  3271. return false;
  3272. }
  3273. }
  3274. return true;
  3275. }
  3276. var shallowEqual_1 = shallowEqual;
  3277. /**
  3278. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3279. * instance (key) and the internal representation (value). This allows public
  3280. * methods to accept the user facing instance as an argument and map them back
  3281. * to internal methods.
  3282. *
  3283. * Note that this module is currently shared and assumed to be stateless.
  3284. * If this becomes an actual Map, that will break.
  3285. */
  3286. /**
  3287. * This API should be called `delete` but we'd have to make sure to always
  3288. * transform these to strings for IE support. When this transform is fully
  3289. * supported we can rename it.
  3290. */
  3291. function get(key) {
  3292. return key._reactInternalFiber;
  3293. }
  3294. function has(key) {
  3295. return key._reactInternalFiber !== undefined;
  3296. }
  3297. function set(key, value) {
  3298. key._reactInternalFiber = value;
  3299. }
  3300. // Don't change these two values. They're used by React Dev Tools.
  3301. var NoEffect = /* */0;
  3302. var PerformedWork = /* */1;
  3303. // You can change the rest (and add more).
  3304. var Placement = /* */2;
  3305. var Update = /* */4;
  3306. var PlacementAndUpdate = /* */6;
  3307. var Deletion = /* */8;
  3308. var ContentReset = /* */16;
  3309. var Callback = /* */32;
  3310. var DidCapture = /* */64;
  3311. var Ref = /* */128;
  3312. var ErrLog = /* */256;
  3313. var Snapshot = /* */2048;
  3314. // Union of all host effects
  3315. var HostEffectMask = /* */2559;
  3316. var Incomplete = /* */512;
  3317. var ShouldCapture = /* */1024;
  3318. var MOUNTING = 1;
  3319. var MOUNTED = 2;
  3320. var UNMOUNTED = 3;
  3321. function isFiberMountedImpl(fiber) {
  3322. var node = fiber;
  3323. if (!fiber.alternate) {
  3324. // If there is no alternate, this might be a new tree that isn't inserted
  3325. // yet. If it is, then it will have a pending insertion effect on it.
  3326. if ((node.effectTag & Placement) !== NoEffect) {
  3327. return MOUNTING;
  3328. }
  3329. while (node['return']) {
  3330. node = node['return'];
  3331. if ((node.effectTag & Placement) !== NoEffect) {
  3332. return MOUNTING;
  3333. }
  3334. }
  3335. } else {
  3336. while (node['return']) {
  3337. node = node['return'];
  3338. }
  3339. }
  3340. if (node.tag === HostRoot) {
  3341. // TODO: Check if this was a nested HostRoot when used with
  3342. // renderContainerIntoSubtree.
  3343. return MOUNTED;
  3344. }
  3345. // If we didn't hit the root, that means that we're in an disconnected tree
  3346. // that has been unmounted.
  3347. return UNMOUNTED;
  3348. }
  3349. function isFiberMounted(fiber) {
  3350. return isFiberMountedImpl(fiber) === MOUNTED;
  3351. }
  3352. function isMounted(component) {
  3353. {
  3354. var owner = ReactCurrentOwner.current;
  3355. if (owner !== null && owner.tag === ClassComponent) {
  3356. var ownerFiber = owner;
  3357. var instance = ownerFiber.stateNode;
  3358. !instance._warnedAboutRefsInRender ? warning_1(false, '%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(ownerFiber) || 'A component') : void 0;
  3359. instance._warnedAboutRefsInRender = true;
  3360. }
  3361. }
  3362. var fiber = get(component);
  3363. if (!fiber) {
  3364. return false;
  3365. }
  3366. return isFiberMountedImpl(fiber) === MOUNTED;
  3367. }
  3368. function assertIsMounted(fiber) {
  3369. !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
  3370. }
  3371. function findCurrentFiberUsingSlowPath(fiber) {
  3372. var alternate = fiber.alternate;
  3373. if (!alternate) {
  3374. // If there is no alternate, then we only need to check if it is mounted.
  3375. var state = isFiberMountedImpl(fiber);
  3376. !(state !== UNMOUNTED) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
  3377. if (state === MOUNTING) {
  3378. return null;
  3379. }
  3380. return fiber;
  3381. }
  3382. // If we have two possible branches, we'll walk backwards up to the root
  3383. // to see what path the root points to. On the way we may hit one of the
  3384. // special cases and we'll deal with them.
  3385. var a = fiber;
  3386. var b = alternate;
  3387. while (true) {
  3388. var parentA = a['return'];
  3389. var parentB = parentA ? parentA.alternate : null;
  3390. if (!parentA || !parentB) {
  3391. // We're at the root.
  3392. break;
  3393. }
  3394. // If both copies of the parent fiber point to the same child, we can
  3395. // assume that the child is current. This happens when we bailout on low
  3396. // priority: the bailed out fiber's child reuses the current child.
  3397. if (parentA.child === parentB.child) {
  3398. var child = parentA.child;
  3399. while (child) {
  3400. if (child === a) {
  3401. // We've determined that A is the current branch.
  3402. assertIsMounted(parentA);
  3403. return fiber;
  3404. }
  3405. if (child === b) {
  3406. // We've determined that B is the current branch.
  3407. assertIsMounted(parentA);
  3408. return alternate;
  3409. }
  3410. child = child.sibling;
  3411. }
  3412. // We should never have an alternate for any mounting node. So the only
  3413. // way this could possibly happen is if this was unmounted, if at all.
  3414. invariant_1(false, 'Unable to find node on an unmounted component.');
  3415. }
  3416. if (a['return'] !== b['return']) {
  3417. // The return pointer of A and the return pointer of B point to different
  3418. // fibers. We assume that return pointers never criss-cross, so A must
  3419. // belong to the child set of A.return, and B must belong to the child
  3420. // set of B.return.
  3421. a = parentA;
  3422. b = parentB;
  3423. } else {
  3424. // The return pointers point to the same fiber. We'll have to use the
  3425. // default, slow path: scan the child sets of each parent alternate to see
  3426. // which child belongs to which set.
  3427. //
  3428. // Search parent A's child set
  3429. var didFindChild = false;
  3430. var _child = parentA.child;
  3431. while (_child) {
  3432. if (_child === a) {
  3433. didFindChild = true;
  3434. a = parentA;
  3435. b = parentB;
  3436. break;
  3437. }
  3438. if (_child === b) {
  3439. didFindChild = true;
  3440. b = parentA;
  3441. a = parentB;
  3442. break;
  3443. }
  3444. _child = _child.sibling;
  3445. }
  3446. if (!didFindChild) {
  3447. // Search parent B's child set
  3448. _child = parentB.child;
  3449. while (_child) {
  3450. if (_child === a) {
  3451. didFindChild = true;
  3452. a = parentB;
  3453. b = parentA;
  3454. break;
  3455. }
  3456. if (_child === b) {
  3457. didFindChild = true;
  3458. b = parentB;
  3459. a = parentA;
  3460. break;
  3461. }
  3462. _child = _child.sibling;
  3463. }
  3464. !didFindChild ? invariant_1(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
  3465. }
  3466. }
  3467. !(a.alternate === b) ? invariant_1(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  3468. }
  3469. // If the root is not a host container, we're in a disconnected tree. I.e.
  3470. // unmounted.
  3471. !(a.tag === HostRoot) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
  3472. if (a.stateNode.current === a) {
  3473. // We've determined that A is the current branch.
  3474. return fiber;
  3475. }
  3476. // Otherwise B has to be current branch.
  3477. return alternate;
  3478. }
  3479. function findCurrentHostFiber(parent) {
  3480. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3481. if (!currentParent) {
  3482. return null;
  3483. }
  3484. // Next we'll drill down this component to find the first HostComponent/Text.
  3485. var node = currentParent;
  3486. while (true) {
  3487. if (node.tag === HostComponent || node.tag === HostText) {
  3488. return node;
  3489. } else if (node.child) {
  3490. node.child['return'] = node;
  3491. node = node.child;
  3492. continue;
  3493. }
  3494. if (node === currentParent) {
  3495. return null;
  3496. }
  3497. while (!node.sibling) {
  3498. if (!node['return'] || node['return'] === currentParent) {
  3499. return null;
  3500. }
  3501. node = node['return'];
  3502. }
  3503. node.sibling['return'] = node['return'];
  3504. node = node.sibling;
  3505. }
  3506. // Flow needs the return null here, but ESLint complains about it.
  3507. // eslint-disable-next-line no-unreachable
  3508. return null;
  3509. }
  3510. function findCurrentHostFiberWithNoPortals(parent) {
  3511. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3512. if (!currentParent) {
  3513. return null;
  3514. }
  3515. // Next we'll drill down this component to find the first HostComponent/Text.
  3516. var node = currentParent;
  3517. while (true) {
  3518. if (node.tag === HostComponent || node.tag === HostText) {
  3519. return node;
  3520. } else if (node.child && node.tag !== HostPortal) {
  3521. node.child['return'] = node;
  3522. node = node.child;
  3523. continue;
  3524. }
  3525. if (node === currentParent) {
  3526. return null;
  3527. }
  3528. while (!node.sibling) {
  3529. if (!node['return'] || node['return'] === currentParent) {
  3530. return null;
  3531. }
  3532. node = node['return'];
  3533. }
  3534. node.sibling['return'] = node['return'];
  3535. node = node.sibling;
  3536. }
  3537. // Flow needs the return null here, but ESLint complains about it.
  3538. // eslint-disable-next-line no-unreachable
  3539. return null;
  3540. }
  3541. function addEventBubbleListener(element, eventType, listener) {
  3542. element.addEventListener(eventType, listener, false);
  3543. }
  3544. function addEventCaptureListener(element, eventType, listener) {
  3545. element.addEventListener(eventType, listener, true);
  3546. }
  3547. /**
  3548. * @interface Event
  3549. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  3550. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  3551. */
  3552. var SyntheticAnimationEvent = SyntheticEvent$1.extend({
  3553. animationName: null,
  3554. elapsedTime: null,
  3555. pseudoElement: null
  3556. });
  3557. /**
  3558. * @interface Event
  3559. * @see http://www.w3.org/TR/clipboard-apis/
  3560. */
  3561. var SyntheticClipboardEvent = SyntheticEvent$1.extend({
  3562. clipboardData: function (event) {
  3563. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  3564. }
  3565. });
  3566. /**
  3567. * @interface FocusEvent
  3568. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3569. */
  3570. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  3571. relatedTarget: null
  3572. });
  3573. /**
  3574. * `charCode` represents the actual "character code" and is safe to use with
  3575. * `String.fromCharCode`. As such, only keys that correspond to printable
  3576. * characters produce a valid `charCode`, the only exception to this is Enter.
  3577. * The Tab-key is considered non-printable and does not have a `charCode`,
  3578. * presumably because it does not produce a tab-character in browsers.
  3579. *
  3580. * @param {object} nativeEvent Native browser event.
  3581. * @return {number} Normalized `charCode` property.
  3582. */
  3583. function getEventCharCode(nativeEvent) {
  3584. var charCode = void 0;
  3585. var keyCode = nativeEvent.keyCode;
  3586. if ('charCode' in nativeEvent) {
  3587. charCode = nativeEvent.charCode;
  3588. // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  3589. if (charCode === 0 && keyCode === 13) {
  3590. charCode = 13;
  3591. }
  3592. } else {
  3593. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  3594. charCode = keyCode;
  3595. }
  3596. // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  3597. // report Enter as charCode 10 when ctrl is pressed.
  3598. if (charCode === 10) {
  3599. charCode = 13;
  3600. }
  3601. // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  3602. // Must not discard the (non-)printable Enter-key.
  3603. if (charCode >= 32 || charCode === 13) {
  3604. return charCode;
  3605. }
  3606. return 0;
  3607. }
  3608. /**
  3609. * Normalization of deprecated HTML5 `key` values
  3610. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  3611. */
  3612. var normalizeKey = {
  3613. Esc: 'Escape',
  3614. Spacebar: ' ',
  3615. Left: 'ArrowLeft',
  3616. Up: 'ArrowUp',
  3617. Right: 'ArrowRight',
  3618. Down: 'ArrowDown',
  3619. Del: 'Delete',
  3620. Win: 'OS',
  3621. Menu: 'ContextMenu',
  3622. Apps: 'ContextMenu',
  3623. Scroll: 'ScrollLock',
  3624. MozPrintableKey: 'Unidentified'
  3625. };
  3626. /**
  3627. * Translation from legacy `keyCode` to HTML5 `key`
  3628. * Only special keys supported, all others depend on keyboard layout or browser
  3629. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  3630. */
  3631. var translateToKey = {
  3632. '8': 'Backspace',
  3633. '9': 'Tab',
  3634. '12': 'Clear',
  3635. '13': 'Enter',
  3636. '16': 'Shift',
  3637. '17': 'Control',
  3638. '18': 'Alt',
  3639. '19': 'Pause',
  3640. '20': 'CapsLock',
  3641. '27': 'Escape',
  3642. '32': ' ',
  3643. '33': 'PageUp',
  3644. '34': 'PageDown',
  3645. '35': 'End',
  3646. '36': 'Home',
  3647. '37': 'ArrowLeft',
  3648. '38': 'ArrowUp',
  3649. '39': 'ArrowRight',
  3650. '40': 'ArrowDown',
  3651. '45': 'Insert',
  3652. '46': 'Delete',
  3653. '112': 'F1',
  3654. '113': 'F2',
  3655. '114': 'F3',
  3656. '115': 'F4',
  3657. '116': 'F5',
  3658. '117': 'F6',
  3659. '118': 'F7',
  3660. '119': 'F8',
  3661. '120': 'F9',
  3662. '121': 'F10',
  3663. '122': 'F11',
  3664. '123': 'F12',
  3665. '144': 'NumLock',
  3666. '145': 'ScrollLock',
  3667. '224': 'Meta'
  3668. };
  3669. /**
  3670. * @param {object} nativeEvent Native browser event.
  3671. * @return {string} Normalized `key` property.
  3672. */
  3673. function getEventKey(nativeEvent) {
  3674. if (nativeEvent.key) {
  3675. // Normalize inconsistent values reported by browsers due to
  3676. // implementations of a working draft specification.
  3677. // FireFox implements `key` but returns `MozPrintableKey` for all
  3678. // printable characters (normalized to `Unidentified`), ignore it.
  3679. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  3680. if (key !== 'Unidentified') {
  3681. return key;
  3682. }
  3683. }
  3684. // Browser does not implement `key`, polyfill as much of it as we can.
  3685. if (nativeEvent.type === 'keypress') {
  3686. var charCode = getEventCharCode(nativeEvent);
  3687. // The enter-key is technically both printable and non-printable and can
  3688. // thus be captured by `keypress`, no other non-printable key should.
  3689. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  3690. }
  3691. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  3692. // While user keyboard layout determines the actual meaning of each
  3693. // `keyCode` value, almost all function keys have a universal value.
  3694. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  3695. }
  3696. return '';
  3697. }
  3698. /**
  3699. * @interface KeyboardEvent
  3700. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3701. */
  3702. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  3703. key: getEventKey,
  3704. location: null,
  3705. ctrlKey: null,
  3706. shiftKey: null,
  3707. altKey: null,
  3708. metaKey: null,
  3709. repeat: null,
  3710. locale: null,
  3711. getModifierState: getEventModifierState,
  3712. // Legacy Interface
  3713. charCode: function (event) {
  3714. // `charCode` is the result of a KeyPress event and represents the value of
  3715. // the actual printable character.
  3716. // KeyPress is deprecated, but its replacement is not yet final and not
  3717. // implemented in any major browser. Only KeyPress has charCode.
  3718. if (event.type === 'keypress') {
  3719. return getEventCharCode(event);
  3720. }
  3721. return 0;
  3722. },
  3723. keyCode: function (event) {
  3724. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  3725. // physical keyboard key.
  3726. // The actual meaning of the value depends on the users' keyboard layout
  3727. // which cannot be detected. Assuming that it is a US keyboard layout
  3728. // provides a surprisingly accurate mapping for US and European users.
  3729. // Due to this, it is left to the user to implement at this time.
  3730. if (event.type === 'keydown' || event.type === 'keyup') {
  3731. return event.keyCode;
  3732. }
  3733. return 0;
  3734. },
  3735. which: function (event) {
  3736. // `which` is an alias for either `keyCode` or `charCode` depending on the
  3737. // type of the event.
  3738. if (event.type === 'keypress') {
  3739. return getEventCharCode(event);
  3740. }
  3741. if (event.type === 'keydown' || event.type === 'keyup') {
  3742. return event.keyCode;
  3743. }
  3744. return 0;
  3745. }
  3746. });
  3747. /**
  3748. * @interface DragEvent
  3749. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3750. */
  3751. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  3752. dataTransfer: null
  3753. });
  3754. /**
  3755. * @interface TouchEvent
  3756. * @see http://www.w3.org/TR/touch-events/
  3757. */
  3758. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  3759. touches: null,
  3760. targetTouches: null,
  3761. changedTouches: null,
  3762. altKey: null,
  3763. metaKey: null,
  3764. ctrlKey: null,
  3765. shiftKey: null,
  3766. getModifierState: getEventModifierState
  3767. });
  3768. /**
  3769. * @interface Event
  3770. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  3771. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  3772. */
  3773. var SyntheticTransitionEvent = SyntheticEvent$1.extend({
  3774. propertyName: null,
  3775. elapsedTime: null,
  3776. pseudoElement: null
  3777. });
  3778. /**
  3779. * @interface WheelEvent
  3780. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3781. */
  3782. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  3783. deltaX: function (event) {
  3784. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  3785. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  3786. },
  3787. deltaY: function (event) {
  3788. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  3789. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  3790. 'wheelDelta' in event ? -event.wheelDelta : 0;
  3791. },
  3792. deltaZ: null,
  3793. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  3794. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  3795. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  3796. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  3797. deltaMode: null
  3798. });
  3799. /**
  3800. * Turns
  3801. * ['abort', ...]
  3802. * into
  3803. * eventTypes = {
  3804. * 'abort': {
  3805. * phasedRegistrationNames: {
  3806. * bubbled: 'onAbort',
  3807. * captured: 'onAbortCapture',
  3808. * },
  3809. * dependencies: ['topAbort'],
  3810. * },
  3811. * ...
  3812. * };
  3813. * topLevelEventsToDispatchConfig = {
  3814. * 'topAbort': { sameConfig }
  3815. * };
  3816. */
  3817. var interactiveEventTypeNames = ['blur', 'cancel', 'click', 'close', 'contextMenu', 'copy', 'cut', 'doubleClick', 'dragEnd', 'dragStart', 'drop', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'mouseDown', 'mouseUp', 'paste', 'pause', 'play', 'rateChange', 'reset', 'seeked', 'submit', 'touchCancel', 'touchEnd', 'touchStart', 'volumeChange'];
  3818. var nonInteractiveEventTypeNames = ['abort', 'animationEnd', 'animationIteration', 'animationStart', 'canPlay', 'canPlayThrough', 'drag', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'mouseMove', 'mouseOut', 'mouseOver', 'playing', 'progress', 'scroll', 'seeking', 'stalled', 'suspend', 'timeUpdate', 'toggle', 'touchMove', 'transitionEnd', 'waiting', 'wheel'];
  3819. var eventTypes$4 = {};
  3820. var topLevelEventsToDispatchConfig = {};
  3821. function addEventTypeNameToConfig(event, isInteractive) {
  3822. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  3823. var onEvent = 'on' + capitalizedEvent;
  3824. var topEvent = 'top' + capitalizedEvent;
  3825. var type = {
  3826. phasedRegistrationNames: {
  3827. bubbled: onEvent,
  3828. captured: onEvent + 'Capture'
  3829. },
  3830. dependencies: [topEvent],
  3831. isInteractive: isInteractive
  3832. };
  3833. eventTypes$4[event] = type;
  3834. topLevelEventsToDispatchConfig[topEvent] = type;
  3835. }
  3836. interactiveEventTypeNames.forEach(function (eventTypeName) {
  3837. addEventTypeNameToConfig(eventTypeName, true);
  3838. });
  3839. nonInteractiveEventTypeNames.forEach(function (eventTypeName) {
  3840. addEventTypeNameToConfig(eventTypeName, false);
  3841. });
  3842. // Only used in DEV for exhaustiveness validation.
  3843. var knownHTMLTopLevelTypes = ['topAbort', 'topCancel', 'topCanPlay', 'topCanPlayThrough', 'topClose', 'topDurationChange', 'topEmptied', 'topEncrypted', 'topEnded', 'topError', 'topInput', 'topInvalid', 'topLoad', 'topLoadedData', 'topLoadedMetadata', 'topLoadStart', 'topPause', 'topPlay', 'topPlaying', 'topProgress', 'topRateChange', 'topReset', 'topSeeked', 'topSeeking', 'topStalled', 'topSubmit', 'topSuspend', 'topTimeUpdate', 'topToggle', 'topVolumeChange', 'topWaiting'];
  3844. var SimpleEventPlugin = {
  3845. eventTypes: eventTypes$4,
  3846. isInteractiveTopLevelEventType: function (topLevelType) {
  3847. var config = topLevelEventsToDispatchConfig[topLevelType];
  3848. return config !== undefined && config.isInteractive === true;
  3849. },
  3850. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3851. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  3852. if (!dispatchConfig) {
  3853. return null;
  3854. }
  3855. var EventConstructor = void 0;
  3856. switch (topLevelType) {
  3857. case 'topKeyPress':
  3858. // Firefox creates a keypress event for function keys too. This removes
  3859. // the unwanted keypress events. Enter is however both printable and
  3860. // non-printable. One would expect Tab to be as well (but it isn't).
  3861. if (getEventCharCode(nativeEvent) === 0) {
  3862. return null;
  3863. }
  3864. /* falls through */
  3865. case 'topKeyDown':
  3866. case 'topKeyUp':
  3867. EventConstructor = SyntheticKeyboardEvent;
  3868. break;
  3869. case 'topBlur':
  3870. case 'topFocus':
  3871. EventConstructor = SyntheticFocusEvent;
  3872. break;
  3873. case 'topClick':
  3874. // Firefox creates a click event on right mouse clicks. This removes the
  3875. // unwanted click events.
  3876. if (nativeEvent.button === 2) {
  3877. return null;
  3878. }
  3879. /* falls through */
  3880. case 'topDoubleClick':
  3881. case 'topMouseDown':
  3882. case 'topMouseMove':
  3883. case 'topMouseUp':
  3884. // TODO: Disabled elements should not respond to mouse events
  3885. /* falls through */
  3886. case 'topMouseOut':
  3887. case 'topMouseOver':
  3888. case 'topContextMenu':
  3889. EventConstructor = SyntheticMouseEvent;
  3890. break;
  3891. case 'topDrag':
  3892. case 'topDragEnd':
  3893. case 'topDragEnter':
  3894. case 'topDragExit':
  3895. case 'topDragLeave':
  3896. case 'topDragOver':
  3897. case 'topDragStart':
  3898. case 'topDrop':
  3899. EventConstructor = SyntheticDragEvent;
  3900. break;
  3901. case 'topTouchCancel':
  3902. case 'topTouchEnd':
  3903. case 'topTouchMove':
  3904. case 'topTouchStart':
  3905. EventConstructor = SyntheticTouchEvent;
  3906. break;
  3907. case 'topAnimationEnd':
  3908. case 'topAnimationIteration':
  3909. case 'topAnimationStart':
  3910. EventConstructor = SyntheticAnimationEvent;
  3911. break;
  3912. case 'topTransitionEnd':
  3913. EventConstructor = SyntheticTransitionEvent;
  3914. break;
  3915. case 'topScroll':
  3916. EventConstructor = SyntheticUIEvent;
  3917. break;
  3918. case 'topWheel':
  3919. EventConstructor = SyntheticWheelEvent;
  3920. break;
  3921. case 'topCopy':
  3922. case 'topCut':
  3923. case 'topPaste':
  3924. EventConstructor = SyntheticClipboardEvent;
  3925. break;
  3926. default:
  3927. {
  3928. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  3929. warning_1(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  3930. }
  3931. }
  3932. // HTML Events
  3933. // @see http://www.w3.org/TR/html5/index.html#events-0
  3934. EventConstructor = SyntheticEvent$1;
  3935. break;
  3936. }
  3937. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  3938. accumulateTwoPhaseDispatches(event);
  3939. return event;
  3940. }
  3941. };
  3942. var isInteractiveTopLevelEventType = SimpleEventPlugin.isInteractiveTopLevelEventType;
  3943. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  3944. var callbackBookkeepingPool = [];
  3945. /**
  3946. * Find the deepest React component completely containing the root of the
  3947. * passed-in instance (for use when entire React trees are nested within each
  3948. * other). If React trees are not nested, returns null.
  3949. */
  3950. function findRootContainerNode(inst) {
  3951. // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  3952. // traversal, but caching is difficult to do correctly without using a
  3953. // mutation observer to listen for all DOM changes.
  3954. while (inst['return']) {
  3955. inst = inst['return'];
  3956. }
  3957. if (inst.tag !== HostRoot) {
  3958. // This can happen if we're in a detached tree.
  3959. return null;
  3960. }
  3961. return inst.stateNode.containerInfo;
  3962. }
  3963. // Used to store ancestor hierarchy in top level callback
  3964. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) {
  3965. if (callbackBookkeepingPool.length) {
  3966. var instance = callbackBookkeepingPool.pop();
  3967. instance.topLevelType = topLevelType;
  3968. instance.nativeEvent = nativeEvent;
  3969. instance.targetInst = targetInst;
  3970. return instance;
  3971. }
  3972. return {
  3973. topLevelType: topLevelType,
  3974. nativeEvent: nativeEvent,
  3975. targetInst: targetInst,
  3976. ancestors: []
  3977. };
  3978. }
  3979. function releaseTopLevelCallbackBookKeeping(instance) {
  3980. instance.topLevelType = null;
  3981. instance.nativeEvent = null;
  3982. instance.targetInst = null;
  3983. instance.ancestors.length = 0;
  3984. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  3985. callbackBookkeepingPool.push(instance);
  3986. }
  3987. }
  3988. function handleTopLevel(bookKeeping) {
  3989. var targetInst = bookKeeping.targetInst;
  3990. // Loop through the hierarchy, in case there's any nested components.
  3991. // It's important that we build the array of ancestors before calling any
  3992. // event handlers, because event handlers can modify the DOM, leading to
  3993. // inconsistencies with ReactMount's node cache. See #1105.
  3994. var ancestor = targetInst;
  3995. do {
  3996. if (!ancestor) {
  3997. bookKeeping.ancestors.push(ancestor);
  3998. break;
  3999. }
  4000. var root = findRootContainerNode(ancestor);
  4001. if (!root) {
  4002. break;
  4003. }
  4004. bookKeeping.ancestors.push(ancestor);
  4005. ancestor = getClosestInstanceFromNode(root);
  4006. } while (ancestor);
  4007. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  4008. targetInst = bookKeeping.ancestors[i];
  4009. runExtractedEventsInBatch(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
  4010. }
  4011. }
  4012. // TODO: can we stop exporting these?
  4013. var _enabled = true;
  4014. function setEnabled(enabled) {
  4015. _enabled = !!enabled;
  4016. }
  4017. function isEnabled() {
  4018. return _enabled;
  4019. }
  4020. /**
  4021. * Traps top-level events by using event bubbling.
  4022. *
  4023. * @param {string} topLevelType Record from `BrowserEventConstants`.
  4024. * @param {string} handlerBaseName Event name (e.g. "click").
  4025. * @param {object} element Element on which to attach listener.
  4026. * @return {?object} An object with a remove function which will forcefully
  4027. * remove the listener.
  4028. * @internal
  4029. */
  4030. function trapBubbledEvent(topLevelType, handlerBaseName, element) {
  4031. if (!element) {
  4032. return null;
  4033. }
  4034. var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent;
  4035. addEventBubbleListener(element, handlerBaseName,
  4036. // Check if interactive and wrap in interactiveUpdates
  4037. dispatch.bind(null, topLevelType));
  4038. }
  4039. /**
  4040. * Traps a top-level event by using event capturing.
  4041. *
  4042. * @param {string} topLevelType Record from `BrowserEventConstants`.
  4043. * @param {string} handlerBaseName Event name (e.g. "click").
  4044. * @param {object} element Element on which to attach listener.
  4045. * @return {?object} An object with a remove function which will forcefully
  4046. * remove the listener.
  4047. * @internal
  4048. */
  4049. function trapCapturedEvent(topLevelType, handlerBaseName, element) {
  4050. if (!element) {
  4051. return null;
  4052. }
  4053. var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent;
  4054. addEventCaptureListener(element, handlerBaseName,
  4055. // Check if interactive and wrap in interactiveUpdates
  4056. dispatch.bind(null, topLevelType));
  4057. }
  4058. function dispatchInteractiveEvent(topLevelType, nativeEvent) {
  4059. interactiveUpdates(dispatchEvent, topLevelType, nativeEvent);
  4060. }
  4061. function dispatchEvent(topLevelType, nativeEvent) {
  4062. if (!_enabled) {
  4063. return;
  4064. }
  4065. var nativeEventTarget = getEventTarget(nativeEvent);
  4066. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  4067. if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
  4068. // If we get an event (ex: img onload) before committing that
  4069. // component's mount, ignore it for now (that is, treat it as if it was an
  4070. // event on a non-React tree). We might also consider queueing events and
  4071. // dispatching them after the mount.
  4072. targetInst = null;
  4073. }
  4074. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
  4075. try {
  4076. // Event queue being processed in the same cycle allows
  4077. // `preventDefault`.
  4078. batchedUpdates(handleTopLevel, bookKeeping);
  4079. } finally {
  4080. releaseTopLevelCallbackBookKeeping(bookKeeping);
  4081. }
  4082. }
  4083. var ReactDOMEventListener = Object.freeze({
  4084. get _enabled () { return _enabled; },
  4085. setEnabled: setEnabled,
  4086. isEnabled: isEnabled,
  4087. trapBubbledEvent: trapBubbledEvent,
  4088. trapCapturedEvent: trapCapturedEvent,
  4089. dispatchEvent: dispatchEvent
  4090. });
  4091. /**
  4092. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  4093. *
  4094. * @param {string} styleProp
  4095. * @param {string} eventName
  4096. * @returns {object}
  4097. */
  4098. function makePrefixMap(styleProp, eventName) {
  4099. var prefixes = {};
  4100. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  4101. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  4102. prefixes['Moz' + styleProp] = 'moz' + eventName;
  4103. prefixes['ms' + styleProp] = 'MS' + eventName;
  4104. prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
  4105. return prefixes;
  4106. }
  4107. /**
  4108. * A list of event names to a configurable list of vendor prefixes.
  4109. */
  4110. var vendorPrefixes = {
  4111. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  4112. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  4113. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  4114. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  4115. };
  4116. /**
  4117. * Event names that have already been detected and prefixed (if applicable).
  4118. */
  4119. var prefixedEventNames = {};
  4120. /**
  4121. * Element to check for prefixes on.
  4122. */
  4123. var style = {};
  4124. /**
  4125. * Bootstrap if a DOM exists.
  4126. */
  4127. if (ExecutionEnvironment_1.canUseDOM) {
  4128. style = document.createElement('div').style;
  4129. // On some platforms, in particular some releases of Android 4.x,
  4130. // the un-prefixed "animation" and "transition" properties are defined on the
  4131. // style object but the events that fire will still be prefixed, so we need
  4132. // to check if the un-prefixed events are usable, and if not remove them from the map.
  4133. if (!('AnimationEvent' in window)) {
  4134. delete vendorPrefixes.animationend.animation;
  4135. delete vendorPrefixes.animationiteration.animation;
  4136. delete vendorPrefixes.animationstart.animation;
  4137. }
  4138. // Same as above
  4139. if (!('TransitionEvent' in window)) {
  4140. delete vendorPrefixes.transitionend.transition;
  4141. }
  4142. }
  4143. /**
  4144. * Attempts to determine the correct vendor prefixed event name.
  4145. *
  4146. * @param {string} eventName
  4147. * @returns {string}
  4148. */
  4149. function getVendorPrefixedEventName(eventName) {
  4150. if (prefixedEventNames[eventName]) {
  4151. return prefixedEventNames[eventName];
  4152. } else if (!vendorPrefixes[eventName]) {
  4153. return eventName;
  4154. }
  4155. var prefixMap = vendorPrefixes[eventName];
  4156. for (var styleProp in prefixMap) {
  4157. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  4158. return prefixedEventNames[eventName] = prefixMap[styleProp];
  4159. }
  4160. }
  4161. return eventName;
  4162. }
  4163. /**
  4164. * Types of raw signals from the browser caught at the top level.
  4165. *
  4166. * For events like 'submit' or audio/video events which don't consistently
  4167. * bubble (which we trap at a lower node than `document`), binding
  4168. * at `document` would cause duplicate events so we don't include them here.
  4169. */
  4170. var topLevelTypes = {
  4171. topAnimationEnd: getVendorPrefixedEventName('animationend'),
  4172. topAnimationIteration: getVendorPrefixedEventName('animationiteration'),
  4173. topAnimationStart: getVendorPrefixedEventName('animationstart'),
  4174. topBlur: 'blur',
  4175. topCancel: 'cancel',
  4176. topChange: 'change',
  4177. topClick: 'click',
  4178. topClose: 'close',
  4179. topCompositionEnd: 'compositionend',
  4180. topCompositionStart: 'compositionstart',
  4181. topCompositionUpdate: 'compositionupdate',
  4182. topContextMenu: 'contextmenu',
  4183. topCopy: 'copy',
  4184. topCut: 'cut',
  4185. topDoubleClick: 'dblclick',
  4186. topDrag: 'drag',
  4187. topDragEnd: 'dragend',
  4188. topDragEnter: 'dragenter',
  4189. topDragExit: 'dragexit',
  4190. topDragLeave: 'dragleave',
  4191. topDragOver: 'dragover',
  4192. topDragStart: 'dragstart',
  4193. topDrop: 'drop',
  4194. topFocus: 'focus',
  4195. topInput: 'input',
  4196. topKeyDown: 'keydown',
  4197. topKeyPress: 'keypress',
  4198. topKeyUp: 'keyup',
  4199. topLoad: 'load',
  4200. topLoadStart: 'loadstart',
  4201. topMouseDown: 'mousedown',
  4202. topMouseMove: 'mousemove',
  4203. topMouseOut: 'mouseout',
  4204. topMouseOver: 'mouseover',
  4205. topMouseUp: 'mouseup',
  4206. topPaste: 'paste',
  4207. topScroll: 'scroll',
  4208. topSelectionChange: 'selectionchange',
  4209. topTextInput: 'textInput',
  4210. topToggle: 'toggle',
  4211. topTouchCancel: 'touchcancel',
  4212. topTouchEnd: 'touchend',
  4213. topTouchMove: 'touchmove',
  4214. topTouchStart: 'touchstart',
  4215. topTransitionEnd: getVendorPrefixedEventName('transitionend'),
  4216. topWheel: 'wheel'
  4217. };
  4218. // There are so many media events, it makes sense to just
  4219. // maintain a list of them. Note these aren't technically
  4220. // "top-level" since they don't bubble. We should come up
  4221. // with a better naming convention if we come to refactoring
  4222. // the event system.
  4223. var mediaEventTypes = {
  4224. topAbort: 'abort',
  4225. topCanPlay: 'canplay',
  4226. topCanPlayThrough: 'canplaythrough',
  4227. topDurationChange: 'durationchange',
  4228. topEmptied: 'emptied',
  4229. topEncrypted: 'encrypted',
  4230. topEnded: 'ended',
  4231. topError: 'error',
  4232. topLoadedData: 'loadeddata',
  4233. topLoadedMetadata: 'loadedmetadata',
  4234. topLoadStart: 'loadstart',
  4235. topPause: 'pause',
  4236. topPlay: 'play',
  4237. topPlaying: 'playing',
  4238. topProgress: 'progress',
  4239. topRateChange: 'ratechange',
  4240. topSeeked: 'seeked',
  4241. topSeeking: 'seeking',
  4242. topStalled: 'stalled',
  4243. topSuspend: 'suspend',
  4244. topTimeUpdate: 'timeupdate',
  4245. topVolumeChange: 'volumechange',
  4246. topWaiting: 'waiting'
  4247. };
  4248. /**
  4249. * Summary of `ReactBrowserEventEmitter` event handling:
  4250. *
  4251. * - Top-level delegation is used to trap most native browser events. This
  4252. * may only occur in the main thread and is the responsibility of
  4253. * ReactDOMEventListener, which is injected and can therefore support
  4254. * pluggable event sources. This is the only work that occurs in the main
  4255. * thread.
  4256. *
  4257. * - We normalize and de-duplicate events to account for browser quirks. This
  4258. * may be done in the worker thread.
  4259. *
  4260. * - Forward these native events (with the associated top-level type used to
  4261. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  4262. * to extract any synthetic events.
  4263. *
  4264. * - The `EventPluginHub` will then process each event by annotating them with
  4265. * "dispatches", a sequence of listeners and IDs that care about that event.
  4266. *
  4267. * - The `EventPluginHub` then dispatches the events.
  4268. *
  4269. * Overview of React and the event system:
  4270. *
  4271. * +------------+ .
  4272. * | DOM | .
  4273. * +------------+ .
  4274. * | .
  4275. * v .
  4276. * +------------+ .
  4277. * | ReactEvent | .
  4278. * | Listener | .
  4279. * +------------+ . +-----------+
  4280. * | . +--------+|SimpleEvent|
  4281. * | . | |Plugin |
  4282. * +-----|------+ . v +-----------+
  4283. * | | | . +--------------+ +------------+
  4284. * | +-----------.--->|EventPluginHub| | Event |
  4285. * | | . | | +-----------+ | Propagators|
  4286. * | ReactEvent | . | | |TapEvent | |------------|
  4287. * | Emitter | . | |<---+|Plugin | |other plugin|
  4288. * | | . | | +-----------+ | utilities |
  4289. * | +-----------.--->| | +------------+
  4290. * | | | . +--------------+
  4291. * +-----|------+ . ^ +-----------+
  4292. * | . | |Enter/Leave|
  4293. * + . +-------+|Plugin |
  4294. * +-------------+ . +-----------+
  4295. * | application | .
  4296. * |-------------| .
  4297. * | | .
  4298. * | | .
  4299. * +-------------+ .
  4300. * .
  4301. * React Core . General Purpose Event Plugin System
  4302. */
  4303. var alreadyListeningTo = {};
  4304. var reactTopListenersCounter = 0;
  4305. /**
  4306. * To ensure no conflicts with other potential React instances on the page
  4307. */
  4308. var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2);
  4309. function getListeningForDocument(mountAt) {
  4310. // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
  4311. // directly.
  4312. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
  4313. mountAt[topListenersIDKey] = reactTopListenersCounter++;
  4314. alreadyListeningTo[mountAt[topListenersIDKey]] = {};
  4315. }
  4316. return alreadyListeningTo[mountAt[topListenersIDKey]];
  4317. }
  4318. /**
  4319. * We listen for bubbled touch events on the document object.
  4320. *
  4321. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  4322. * mounting `onmousemove` events at some node that was not the document
  4323. * element. The symptoms were that if your mouse is not moving over something
  4324. * contained within that mount point (for example on the background) the
  4325. * top-level listeners for `onmousemove` won't be called. However, if you
  4326. * register the `mousemove` on the document object, then it will of course
  4327. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  4328. * top-level listeners to the document object only, at least for these
  4329. * movement types of events and possibly all events.
  4330. *
  4331. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  4332. *
  4333. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  4334. * they bubble to document.
  4335. *
  4336. * @param {string} registrationName Name of listener (e.g. `onClick`).
  4337. * @param {object} contentDocumentHandle Document which owns the container
  4338. */
  4339. function listenTo(registrationName, contentDocumentHandle) {
  4340. var mountAt = contentDocumentHandle;
  4341. var isListening = getListeningForDocument(mountAt);
  4342. var dependencies = registrationNameDependencies[registrationName];
  4343. for (var i = 0; i < dependencies.length; i++) {
  4344. var dependency = dependencies[i];
  4345. if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
  4346. if (dependency === 'topScroll') {
  4347. trapCapturedEvent('topScroll', 'scroll', mountAt);
  4348. } else if (dependency === 'topFocus' || dependency === 'topBlur') {
  4349. trapCapturedEvent('topFocus', 'focus', mountAt);
  4350. trapCapturedEvent('topBlur', 'blur', mountAt);
  4351. // to make sure blur and focus event listeners are only attached once
  4352. isListening.topBlur = true;
  4353. isListening.topFocus = true;
  4354. } else if (dependency === 'topCancel') {
  4355. if (isEventSupported('cancel', true)) {
  4356. trapCapturedEvent('topCancel', 'cancel', mountAt);
  4357. }
  4358. isListening.topCancel = true;
  4359. } else if (dependency === 'topClose') {
  4360. if (isEventSupported('close', true)) {
  4361. trapCapturedEvent('topClose', 'close', mountAt);
  4362. }
  4363. isListening.topClose = true;
  4364. } else if (topLevelTypes.hasOwnProperty(dependency)) {
  4365. trapBubbledEvent(dependency, topLevelTypes[dependency], mountAt);
  4366. }
  4367. isListening[dependency] = true;
  4368. }
  4369. }
  4370. }
  4371. function isListeningToAllDependencies(registrationName, mountAt) {
  4372. var isListening = getListeningForDocument(mountAt);
  4373. var dependencies = registrationNameDependencies[registrationName];
  4374. for (var i = 0; i < dependencies.length; i++) {
  4375. var dependency = dependencies[i];
  4376. if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
  4377. return false;
  4378. }
  4379. }
  4380. return true;
  4381. }
  4382. /**
  4383. * Copyright (c) 2013-present, Facebook, Inc.
  4384. *
  4385. * This source code is licensed under the MIT license found in the
  4386. * LICENSE file in the root directory of this source tree.
  4387. *
  4388. * @typechecks
  4389. */
  4390. /**
  4391. * @param {*} object The object to check.
  4392. * @return {boolean} Whether or not the object is a DOM node.
  4393. */
  4394. function isNode(object) {
  4395. var doc = object ? object.ownerDocument || object : document;
  4396. var defaultView = doc.defaultView || window;
  4397. return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
  4398. }
  4399. var isNode_1 = isNode;
  4400. /**
  4401. * Copyright (c) 2013-present, Facebook, Inc.
  4402. *
  4403. * This source code is licensed under the MIT license found in the
  4404. * LICENSE file in the root directory of this source tree.
  4405. *
  4406. * @typechecks
  4407. */
  4408. /**
  4409. * @param {*} object The object to check.
  4410. * @return {boolean} Whether or not the object is a DOM text node.
  4411. */
  4412. function isTextNode(object) {
  4413. return isNode_1(object) && object.nodeType == 3;
  4414. }
  4415. var isTextNode_1 = isTextNode;
  4416. /**
  4417. * Copyright (c) 2013-present, Facebook, Inc.
  4418. *
  4419. * This source code is licensed under the MIT license found in the
  4420. * LICENSE file in the root directory of this source tree.
  4421. *
  4422. *
  4423. */
  4424. /*eslint-disable no-bitwise */
  4425. /**
  4426. * Checks if a given DOM node contains or is another DOM node.
  4427. */
  4428. function containsNode(outerNode, innerNode) {
  4429. if (!outerNode || !innerNode) {
  4430. return false;
  4431. } else if (outerNode === innerNode) {
  4432. return true;
  4433. } else if (isTextNode_1(outerNode)) {
  4434. return false;
  4435. } else if (isTextNode_1(innerNode)) {
  4436. return containsNode(outerNode, innerNode.parentNode);
  4437. } else if ('contains' in outerNode) {
  4438. return outerNode.contains(innerNode);
  4439. } else if (outerNode.compareDocumentPosition) {
  4440. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  4441. } else {
  4442. return false;
  4443. }
  4444. }
  4445. var containsNode_1 = containsNode;
  4446. /**
  4447. * Given any node return the first leaf node without children.
  4448. *
  4449. * @param {DOMElement|DOMTextNode} node
  4450. * @return {DOMElement|DOMTextNode}
  4451. */
  4452. function getLeafNode(node) {
  4453. while (node && node.firstChild) {
  4454. node = node.firstChild;
  4455. }
  4456. return node;
  4457. }
  4458. /**
  4459. * Get the next sibling within a container. This will walk up the
  4460. * DOM if a node's siblings have been exhausted.
  4461. *
  4462. * @param {DOMElement|DOMTextNode} node
  4463. * @return {?DOMElement|DOMTextNode}
  4464. */
  4465. function getSiblingNode(node) {
  4466. while (node) {
  4467. if (node.nextSibling) {
  4468. return node.nextSibling;
  4469. }
  4470. node = node.parentNode;
  4471. }
  4472. }
  4473. /**
  4474. * Get object describing the nodes which contain characters at offset.
  4475. *
  4476. * @param {DOMElement|DOMTextNode} root
  4477. * @param {number} offset
  4478. * @return {?object}
  4479. */
  4480. function getNodeForCharacterOffset(root, offset) {
  4481. var node = getLeafNode(root);
  4482. var nodeStart = 0;
  4483. var nodeEnd = 0;
  4484. while (node) {
  4485. if (node.nodeType === TEXT_NODE) {
  4486. nodeEnd = nodeStart + node.textContent.length;
  4487. if (nodeStart <= offset && nodeEnd >= offset) {
  4488. return {
  4489. node: node,
  4490. offset: offset - nodeStart
  4491. };
  4492. }
  4493. nodeStart = nodeEnd;
  4494. }
  4495. node = getLeafNode(getSiblingNode(node));
  4496. }
  4497. }
  4498. /**
  4499. * @param {DOMElement} outerNode
  4500. * @return {?object}
  4501. */
  4502. function getOffsets(outerNode) {
  4503. var selection = window.getSelection && window.getSelection();
  4504. if (!selection || selection.rangeCount === 0) {
  4505. return null;
  4506. }
  4507. var anchorNode = selection.anchorNode,
  4508. anchorOffset = selection.anchorOffset,
  4509. focusNode = selection.focusNode,
  4510. focusOffset = selection.focusOffset;
  4511. // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  4512. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  4513. // expose properties, triggering a "Permission denied error" if any of its
  4514. // properties are accessed. The only seemingly possible way to avoid erroring
  4515. // is to access a property that typically works for non-anonymous divs and
  4516. // catch any error that may otherwise arise. See
  4517. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  4518. try {
  4519. /* eslint-disable no-unused-expressions */
  4520. anchorNode.nodeType;
  4521. focusNode.nodeType;
  4522. /* eslint-enable no-unused-expressions */
  4523. } catch (e) {
  4524. return null;
  4525. }
  4526. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  4527. }
  4528. /**
  4529. * Returns {start, end} where `start` is the character/codepoint index of
  4530. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  4531. * `end` is the index of (focusNode, focusOffset).
  4532. *
  4533. * Returns null if you pass in garbage input but we should probably just crash.
  4534. *
  4535. * Exported only for testing.
  4536. */
  4537. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  4538. var length = 0;
  4539. var start = -1;
  4540. var end = -1;
  4541. var indexWithinAnchor = 0;
  4542. var indexWithinFocus = 0;
  4543. var node = outerNode;
  4544. var parentNode = null;
  4545. outer: while (true) {
  4546. var next = null;
  4547. while (true) {
  4548. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  4549. start = length + anchorOffset;
  4550. }
  4551. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  4552. end = length + focusOffset;
  4553. }
  4554. if (node.nodeType === TEXT_NODE) {
  4555. length += node.nodeValue.length;
  4556. }
  4557. if ((next = node.firstChild) === null) {
  4558. break;
  4559. }
  4560. // Moving from `node` to its first child `next`.
  4561. parentNode = node;
  4562. node = next;
  4563. }
  4564. while (true) {
  4565. if (node === outerNode) {
  4566. // If `outerNode` has children, this is always the second time visiting
  4567. // it. If it has no children, this is still the first loop, and the only
  4568. // valid selection is anchorNode and focusNode both equal to this node
  4569. // and both offsets 0, in which case we will have handled above.
  4570. break outer;
  4571. }
  4572. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  4573. start = length;
  4574. }
  4575. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  4576. end = length;
  4577. }
  4578. if ((next = node.nextSibling) !== null) {
  4579. break;
  4580. }
  4581. node = parentNode;
  4582. parentNode = node.parentNode;
  4583. }
  4584. // Moving from `node` to its next sibling `next`.
  4585. node = next;
  4586. }
  4587. if (start === -1 || end === -1) {
  4588. // This should never happen. (Would happen if the anchor/focus nodes aren't
  4589. // actually inside the passed-in node.)
  4590. return null;
  4591. }
  4592. return {
  4593. start: start,
  4594. end: end
  4595. };
  4596. }
  4597. /**
  4598. * In modern non-IE browsers, we can support both forward and backward
  4599. * selections.
  4600. *
  4601. * Note: IE10+ supports the Selection object, but it does not support
  4602. * the `extend` method, which means that even in modern IE, it's not possible
  4603. * to programmatically create a backward selection. Thus, for all IE
  4604. * versions, we use the old IE API to create our selections.
  4605. *
  4606. * @param {DOMElement|DOMTextNode} node
  4607. * @param {object} offsets
  4608. */
  4609. function setOffsets(node, offsets) {
  4610. if (!window.getSelection) {
  4611. return;
  4612. }
  4613. var selection = window.getSelection();
  4614. var length = node[getTextContentAccessor()].length;
  4615. var start = Math.min(offsets.start, length);
  4616. var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
  4617. // IE 11 uses modern selection, but doesn't support the extend method.
  4618. // Flip backward selections, so we can set with a single range.
  4619. if (!selection.extend && start > end) {
  4620. var temp = end;
  4621. end = start;
  4622. start = temp;
  4623. }
  4624. var startMarker = getNodeForCharacterOffset(node, start);
  4625. var endMarker = getNodeForCharacterOffset(node, end);
  4626. if (startMarker && endMarker) {
  4627. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  4628. return;
  4629. }
  4630. var range = document.createRange();
  4631. range.setStart(startMarker.node, startMarker.offset);
  4632. selection.removeAllRanges();
  4633. if (start > end) {
  4634. selection.addRange(range);
  4635. selection.extend(endMarker.node, endMarker.offset);
  4636. } else {
  4637. range.setEnd(endMarker.node, endMarker.offset);
  4638. selection.addRange(range);
  4639. }
  4640. }
  4641. }
  4642. function isInDocument(node) {
  4643. return containsNode_1(document.documentElement, node);
  4644. }
  4645. /**
  4646. * @ReactInputSelection: React input selection module. Based on Selection.js,
  4647. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  4648. * assume buttons have range selections allowed).
  4649. * Input selection module for React.
  4650. */
  4651. function hasSelectionCapabilities(elem) {
  4652. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  4653. return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
  4654. }
  4655. function getSelectionInformation() {
  4656. var focusedElem = getActiveElement_1();
  4657. return {
  4658. focusedElem: focusedElem,
  4659. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection$1(focusedElem) : null
  4660. };
  4661. }
  4662. /**
  4663. * @restoreSelection: If any selection information was potentially lost,
  4664. * restore it. This is useful when performing operations that could remove dom
  4665. * nodes and place them back in, resulting in focus being lost.
  4666. */
  4667. function restoreSelection(priorSelectionInformation) {
  4668. var curFocusedElem = getActiveElement_1();
  4669. var priorFocusedElem = priorSelectionInformation.focusedElem;
  4670. var priorSelectionRange = priorSelectionInformation.selectionRange;
  4671. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  4672. if (hasSelectionCapabilities(priorFocusedElem)) {
  4673. setSelection(priorFocusedElem, priorSelectionRange);
  4674. }
  4675. // Focusing a node can change the scroll position, which is undesirable
  4676. var ancestors = [];
  4677. var ancestor = priorFocusedElem;
  4678. while (ancestor = ancestor.parentNode) {
  4679. if (ancestor.nodeType === ELEMENT_NODE) {
  4680. ancestors.push({
  4681. element: ancestor,
  4682. left: ancestor.scrollLeft,
  4683. top: ancestor.scrollTop
  4684. });
  4685. }
  4686. }
  4687. priorFocusedElem.focus();
  4688. for (var i = 0; i < ancestors.length; i++) {
  4689. var info = ancestors[i];
  4690. info.element.scrollLeft = info.left;
  4691. info.element.scrollTop = info.top;
  4692. }
  4693. }
  4694. }
  4695. /**
  4696. * @getSelection: Gets the selection bounds of a focused textarea, input or
  4697. * contentEditable node.
  4698. * -@input: Look up selection bounds of this input
  4699. * -@return {start: selectionStart, end: selectionEnd}
  4700. */
  4701. function getSelection$1(input) {
  4702. var selection = void 0;
  4703. if ('selectionStart' in input) {
  4704. // Modern browser with input or textarea.
  4705. selection = {
  4706. start: input.selectionStart,
  4707. end: input.selectionEnd
  4708. };
  4709. } else {
  4710. // Content editable or old IE textarea.
  4711. selection = getOffsets(input);
  4712. }
  4713. return selection || { start: 0, end: 0 };
  4714. }
  4715. /**
  4716. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  4717. * the input.
  4718. * -@input Set selection bounds of this input or textarea
  4719. * -@offsets Object of same form that is returned from get*
  4720. */
  4721. function setSelection(input, offsets) {
  4722. var start = offsets.start,
  4723. end = offsets.end;
  4724. if (end === undefined) {
  4725. end = start;
  4726. }
  4727. if ('selectionStart' in input) {
  4728. input.selectionStart = start;
  4729. input.selectionEnd = Math.min(end, input.value.length);
  4730. } else {
  4731. setOffsets(input, offsets);
  4732. }
  4733. }
  4734. var skipSelectionChangeEvent = ExecutionEnvironment_1.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  4735. var eventTypes$3 = {
  4736. select: {
  4737. phasedRegistrationNames: {
  4738. bubbled: 'onSelect',
  4739. captured: 'onSelectCapture'
  4740. },
  4741. dependencies: ['topBlur', 'topContextMenu', 'topFocus', 'topKeyDown', 'topKeyUp', 'topMouseDown', 'topMouseUp', 'topSelectionChange']
  4742. }
  4743. };
  4744. var activeElement$1 = null;
  4745. var activeElementInst$1 = null;
  4746. var lastSelection = null;
  4747. var mouseDown = false;
  4748. /**
  4749. * Get an object which is a unique representation of the current selection.
  4750. *
  4751. * The return value will not be consistent across nodes or browsers, but
  4752. * two identical selections on the same node will return identical objects.
  4753. *
  4754. * @param {DOMElement} node
  4755. * @return {object}
  4756. */
  4757. function getSelection(node) {
  4758. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  4759. return {
  4760. start: node.selectionStart,
  4761. end: node.selectionEnd
  4762. };
  4763. } else if (window.getSelection) {
  4764. var selection = window.getSelection();
  4765. return {
  4766. anchorNode: selection.anchorNode,
  4767. anchorOffset: selection.anchorOffset,
  4768. focusNode: selection.focusNode,
  4769. focusOffset: selection.focusOffset
  4770. };
  4771. }
  4772. }
  4773. /**
  4774. * Poll selection to see whether it's changed.
  4775. *
  4776. * @param {object} nativeEvent
  4777. * @return {?SyntheticEvent}
  4778. */
  4779. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  4780. // Ensure we have the right element, and that the user is not dragging a
  4781. // selection (this matches native `select` event behavior). In HTML5, select
  4782. // fires only on input and textarea thus if there's no focused element we
  4783. // won't dispatch.
  4784. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement_1()) {
  4785. return null;
  4786. }
  4787. // Only fire when selection has actually changed.
  4788. var currentSelection = getSelection(activeElement$1);
  4789. if (!lastSelection || !shallowEqual_1(lastSelection, currentSelection)) {
  4790. lastSelection = currentSelection;
  4791. var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  4792. syntheticEvent.type = 'select';
  4793. syntheticEvent.target = activeElement$1;
  4794. accumulateTwoPhaseDispatches(syntheticEvent);
  4795. return syntheticEvent;
  4796. }
  4797. return null;
  4798. }
  4799. /**
  4800. * This plugin creates an `onSelect` event that normalizes select events
  4801. * across form elements.
  4802. *
  4803. * Supported elements are:
  4804. * - input (see `isTextInputElement`)
  4805. * - textarea
  4806. * - contentEditable
  4807. *
  4808. * This differs from native browser implementations in the following ways:
  4809. * - Fires on contentEditable fields as well as inputs.
  4810. * - Fires for collapsed selection.
  4811. * - Fires after user input.
  4812. */
  4813. var SelectEventPlugin = {
  4814. eventTypes: eventTypes$3,
  4815. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  4816. var doc = nativeEventTarget.window === nativeEventTarget ? nativeEventTarget.document : nativeEventTarget.nodeType === DOCUMENT_NODE ? nativeEventTarget : nativeEventTarget.ownerDocument;
  4817. // Track whether all listeners exists for this plugin. If none exist, we do
  4818. // not extract events. See #3639.
  4819. if (!doc || !isListeningToAllDependencies('onSelect', doc)) {
  4820. return null;
  4821. }
  4822. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  4823. switch (topLevelType) {
  4824. // Track the input node that has focus.
  4825. case 'topFocus':
  4826. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  4827. activeElement$1 = targetNode;
  4828. activeElementInst$1 = targetInst;
  4829. lastSelection = null;
  4830. }
  4831. break;
  4832. case 'topBlur':
  4833. activeElement$1 = null;
  4834. activeElementInst$1 = null;
  4835. lastSelection = null;
  4836. break;
  4837. // Don't fire the event while the user is dragging. This matches the
  4838. // semantics of the native select event.
  4839. case 'topMouseDown':
  4840. mouseDown = true;
  4841. break;
  4842. case 'topContextMenu':
  4843. case 'topMouseUp':
  4844. mouseDown = false;
  4845. return constructSelectEvent(nativeEvent, nativeEventTarget);
  4846. // Chrome and IE fire non-standard event when selection is changed (and
  4847. // sometimes when it hasn't). IE's event fires out of order with respect
  4848. // to key and input events on deletion, so we discard it.
  4849. //
  4850. // Firefox doesn't support selectionchange, so check selection status
  4851. // after each key entry. The selection changes after keydown and before
  4852. // keyup, but we check on keydown as well in the case of holding down a
  4853. // key, when multiple keydown events are fired but only one keyup is.
  4854. // This is also our approach for IE handling, for the reason above.
  4855. case 'topSelectionChange':
  4856. if (skipSelectionChangeEvent) {
  4857. break;
  4858. }
  4859. // falls through
  4860. case 'topKeyDown':
  4861. case 'topKeyUp':
  4862. return constructSelectEvent(nativeEvent, nativeEventTarget);
  4863. }
  4864. return null;
  4865. }
  4866. };
  4867. /**
  4868. * Inject modules for resolving DOM hierarchy and plugin ordering.
  4869. */
  4870. injection.injectEventPluginOrder(DOMEventPluginOrder);
  4871. injection$1.injectComponentTree(ReactDOMComponentTree);
  4872. /**
  4873. * Some important event plugins included by default (without having to require
  4874. * them).
  4875. */
  4876. injection.injectEventPluginsByName({
  4877. SimpleEventPlugin: SimpleEventPlugin,
  4878. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  4879. ChangeEventPlugin: ChangeEventPlugin,
  4880. SelectEventPlugin: SelectEventPlugin,
  4881. BeforeInputEventPlugin: BeforeInputEventPlugin
  4882. });
  4883. /**
  4884. * Copyright (c) 2013-present, Facebook, Inc.
  4885. *
  4886. * This source code is licensed under the MIT license found in the
  4887. * LICENSE file in the root directory of this source tree.
  4888. *
  4889. */
  4890. var emptyObject = {};
  4891. {
  4892. Object.freeze(emptyObject);
  4893. }
  4894. var emptyObject_1 = emptyObject;
  4895. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  4896. // Math.pow(2, 30) - 1
  4897. // 0b111111111111111111111111111111
  4898. var MAX_SIGNED_31_BIT_INT = 1073741823;
  4899. // TODO: Use an opaque type once ESLint et al support the syntax
  4900. var NoWork = 0;
  4901. var Sync = 1;
  4902. var Never = MAX_SIGNED_31_BIT_INT;
  4903. var UNIT_SIZE = 10;
  4904. var MAGIC_NUMBER_OFFSET = 2;
  4905. // 1 unit of expiration time represents 10ms.
  4906. function msToExpirationTime(ms) {
  4907. // Always add an offset so that we don't clash with the magic number for NoWork.
  4908. return (ms / UNIT_SIZE | 0) + MAGIC_NUMBER_OFFSET;
  4909. }
  4910. function expirationTimeToMs(expirationTime) {
  4911. return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE;
  4912. }
  4913. function ceiling(num, precision) {
  4914. return ((num / precision | 0) + 1) * precision;
  4915. }
  4916. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  4917. return ceiling(currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  4918. }
  4919. var NoContext = 0;
  4920. var AsyncMode = 1;
  4921. var StrictMode = 2;
  4922. var hasBadMapPolyfill = void 0;
  4923. {
  4924. hasBadMapPolyfill = false;
  4925. try {
  4926. var nonExtensibleObject = Object.preventExtensions({});
  4927. var testMap = new Map([[nonExtensibleObject, null]]);
  4928. var testSet = new Set([nonExtensibleObject]);
  4929. // This is necessary for Rollup to not consider these unused.
  4930. // https://github.com/rollup/rollup/issues/1771
  4931. // TODO: we can remove these if Rollup fixes the bug.
  4932. testMap.set(0, 0);
  4933. testSet.add(0);
  4934. } catch (e) {
  4935. // TODO: Consider warning about bad polyfills
  4936. hasBadMapPolyfill = true;
  4937. }
  4938. }
  4939. // A Fiber is work on a Component that needs to be done or was done. There can
  4940. // be more than one per component.
  4941. var debugCounter = void 0;
  4942. {
  4943. debugCounter = 1;
  4944. }
  4945. function FiberNode(tag, pendingProps, key, mode) {
  4946. // Instance
  4947. this.tag = tag;
  4948. this.key = key;
  4949. this.type = null;
  4950. this.stateNode = null;
  4951. // Fiber
  4952. this['return'] = null;
  4953. this.child = null;
  4954. this.sibling = null;
  4955. this.index = 0;
  4956. this.ref = null;
  4957. this.pendingProps = pendingProps;
  4958. this.memoizedProps = null;
  4959. this.updateQueue = null;
  4960. this.memoizedState = null;
  4961. this.mode = mode;
  4962. // Effects
  4963. this.effectTag = NoEffect;
  4964. this.nextEffect = null;
  4965. this.firstEffect = null;
  4966. this.lastEffect = null;
  4967. this.expirationTime = NoWork;
  4968. this.alternate = null;
  4969. {
  4970. this._debugID = debugCounter++;
  4971. this._debugSource = null;
  4972. this._debugOwner = null;
  4973. this._debugIsCurrentlyTiming = false;
  4974. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  4975. Object.preventExtensions(this);
  4976. }
  4977. }
  4978. }
  4979. // This is a constructor function, rather than a POJO constructor, still
  4980. // please ensure we do the following:
  4981. // 1) Nobody should add any instance methods on this. Instance methods can be
  4982. // more difficult to predict when they get optimized and they are almost
  4983. // never inlined properly in static compilers.
  4984. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  4985. // always know when it is a fiber.
  4986. // 3) We might want to experiment with using numeric keys since they are easier
  4987. // to optimize in a non-JIT environment.
  4988. // 4) We can easily go from a constructor to a createFiber object literal if that
  4989. // is faster.
  4990. // 5) It should be easy to port this to a C struct and keep a C implementation
  4991. // compatible.
  4992. var createFiber = function (tag, pendingProps, key, mode) {
  4993. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  4994. return new FiberNode(tag, pendingProps, key, mode);
  4995. };
  4996. function shouldConstruct(Component) {
  4997. return !!(Component.prototype && Component.prototype.isReactComponent);
  4998. }
  4999. // This is used to create an alternate fiber to do work on.
  5000. function createWorkInProgress(current, pendingProps, expirationTime) {
  5001. var workInProgress = current.alternate;
  5002. if (workInProgress === null) {
  5003. // We use a double buffering pooling technique because we know that we'll
  5004. // only ever need at most two versions of a tree. We pool the "other" unused
  5005. // node that we're free to reuse. This is lazily created to avoid allocating
  5006. // extra objects for things that are never updated. It also allow us to
  5007. // reclaim the extra memory if needed.
  5008. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  5009. workInProgress.type = current.type;
  5010. workInProgress.stateNode = current.stateNode;
  5011. {
  5012. // DEV-only fields
  5013. workInProgress._debugID = current._debugID;
  5014. workInProgress._debugSource = current._debugSource;
  5015. workInProgress._debugOwner = current._debugOwner;
  5016. }
  5017. workInProgress.alternate = current;
  5018. current.alternate = workInProgress;
  5019. } else {
  5020. workInProgress.pendingProps = pendingProps;
  5021. // We already have an alternate.
  5022. // Reset the effect tag.
  5023. workInProgress.effectTag = NoEffect;
  5024. // The effect list is no longer valid.
  5025. workInProgress.nextEffect = null;
  5026. workInProgress.firstEffect = null;
  5027. workInProgress.lastEffect = null;
  5028. }
  5029. workInProgress.expirationTime = expirationTime;
  5030. workInProgress.child = current.child;
  5031. workInProgress.memoizedProps = current.memoizedProps;
  5032. workInProgress.memoizedState = current.memoizedState;
  5033. workInProgress.updateQueue = current.updateQueue;
  5034. // These will be overridden during the parent's reconciliation
  5035. workInProgress.sibling = current.sibling;
  5036. workInProgress.index = current.index;
  5037. workInProgress.ref = current.ref;
  5038. return workInProgress;
  5039. }
  5040. function createHostRootFiber(isAsync) {
  5041. var mode = isAsync ? AsyncMode | StrictMode : NoContext;
  5042. return createFiber(HostRoot, null, null, mode);
  5043. }
  5044. function createFiberFromElement(element, mode, expirationTime) {
  5045. var owner = null;
  5046. {
  5047. owner = element._owner;
  5048. }
  5049. var fiber = void 0;
  5050. var type = element.type;
  5051. var key = element.key;
  5052. var pendingProps = element.props;
  5053. var fiberTag = void 0;
  5054. if (typeof type === 'function') {
  5055. fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent;
  5056. } else if (typeof type === 'string') {
  5057. fiberTag = HostComponent;
  5058. } else {
  5059. switch (type) {
  5060. case REACT_FRAGMENT_TYPE:
  5061. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  5062. case REACT_ASYNC_MODE_TYPE:
  5063. fiberTag = Mode;
  5064. mode |= AsyncMode | StrictMode;
  5065. break;
  5066. case REACT_STRICT_MODE_TYPE:
  5067. fiberTag = Mode;
  5068. mode |= StrictMode;
  5069. break;
  5070. case REACT_CALL_TYPE:
  5071. fiberTag = CallComponent;
  5072. break;
  5073. case REACT_RETURN_TYPE:
  5074. fiberTag = ReturnComponent;
  5075. break;
  5076. default:
  5077. {
  5078. if (typeof type === 'object' && type !== null) {
  5079. switch (type.$$typeof) {
  5080. case REACT_PROVIDER_TYPE:
  5081. fiberTag = ContextProvider;
  5082. break;
  5083. case REACT_CONTEXT_TYPE:
  5084. // This is a consumer
  5085. fiberTag = ContextConsumer;
  5086. break;
  5087. case REACT_FORWARD_REF_TYPE:
  5088. fiberTag = ForwardRef;
  5089. break;
  5090. default:
  5091. if (typeof type.tag === 'number') {
  5092. // Currently assumed to be a continuation and therefore is a
  5093. // fiber already.
  5094. // TODO: The yield system is currently broken for updates in
  5095. // some cases. The reified yield stores a fiber, but we don't
  5096. // know which fiber that is; the current or a workInProgress?
  5097. // When the continuation gets rendered here we don't know if we
  5098. // can reuse that fiber or if we need to clone it. There is
  5099. // probably a clever way to restructure this.
  5100. fiber = type;
  5101. fiber.pendingProps = pendingProps;
  5102. fiber.expirationTime = expirationTime;
  5103. return fiber;
  5104. } else {
  5105. throwOnInvalidElementType(type, owner);
  5106. }
  5107. break;
  5108. }
  5109. } else {
  5110. throwOnInvalidElementType(type, owner);
  5111. }
  5112. }
  5113. }
  5114. }
  5115. fiber = createFiber(fiberTag, pendingProps, key, mode);
  5116. fiber.type = type;
  5117. fiber.expirationTime = expirationTime;
  5118. {
  5119. fiber._debugSource = element._source;
  5120. fiber._debugOwner = element._owner;
  5121. }
  5122. return fiber;
  5123. }
  5124. function throwOnInvalidElementType(type, owner) {
  5125. var info = '';
  5126. {
  5127. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  5128. 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.';
  5129. }
  5130. var ownerName = owner ? getComponentName(owner) : null;
  5131. if (ownerName) {
  5132. info += '\n\nCheck the render method of `' + ownerName + '`.';
  5133. }
  5134. }
  5135. invariant_1(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info);
  5136. }
  5137. function createFiberFromFragment(elements, mode, expirationTime, key) {
  5138. var fiber = createFiber(Fragment, elements, key, mode);
  5139. fiber.expirationTime = expirationTime;
  5140. return fiber;
  5141. }
  5142. function createFiberFromText(content, mode, expirationTime) {
  5143. var fiber = createFiber(HostText, content, null, mode);
  5144. fiber.expirationTime = expirationTime;
  5145. return fiber;
  5146. }
  5147. function createFiberFromHostInstanceForDeletion() {
  5148. var fiber = createFiber(HostComponent, null, null, NoContext);
  5149. fiber.type = 'DELETED';
  5150. return fiber;
  5151. }
  5152. function createFiberFromPortal(portal, mode, expirationTime) {
  5153. var pendingProps = portal.children !== null ? portal.children : [];
  5154. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  5155. fiber.expirationTime = expirationTime;
  5156. fiber.stateNode = {
  5157. containerInfo: portal.containerInfo,
  5158. pendingChildren: null, // Used by persistent updates
  5159. implementation: portal.implementation
  5160. };
  5161. return fiber;
  5162. }
  5163. // Used for stashing WIP properties to replay failed work in DEV.
  5164. function assignFiberPropertiesInDEV(target, source) {
  5165. if (target === null) {
  5166. // This Fiber's initial properties will always be overwritten.
  5167. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  5168. target = createFiber(IndeterminateComponent, null, null, NoContext);
  5169. }
  5170. // This is intentionally written as a list of all properties.
  5171. // We tried to use Object.assign() instead but this is called in
  5172. // the hottest path, and Object.assign() was too slow:
  5173. // https://github.com/facebook/react/issues/12502
  5174. // This code is DEV-only so size is not a concern.
  5175. target.tag = source.tag;
  5176. target.key = source.key;
  5177. target.type = source.type;
  5178. target.stateNode = source.stateNode;
  5179. target['return'] = source['return'];
  5180. target.child = source.child;
  5181. target.sibling = source.sibling;
  5182. target.index = source.index;
  5183. target.ref = source.ref;
  5184. target.pendingProps = source.pendingProps;
  5185. target.memoizedProps = source.memoizedProps;
  5186. target.updateQueue = source.updateQueue;
  5187. target.memoizedState = source.memoizedState;
  5188. target.mode = source.mode;
  5189. target.effectTag = source.effectTag;
  5190. target.nextEffect = source.nextEffect;
  5191. target.firstEffect = source.firstEffect;
  5192. target.lastEffect = source.lastEffect;
  5193. target.expirationTime = source.expirationTime;
  5194. target.alternate = source.alternate;
  5195. target._debugID = source._debugID;
  5196. target._debugSource = source._debugSource;
  5197. target._debugOwner = source._debugOwner;
  5198. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  5199. return target;
  5200. }
  5201. // TODO: This should be lifted into the renderer.
  5202. function createFiberRoot(containerInfo, isAsync, hydrate) {
  5203. // Cyclic construction. This cheats the type system right now because
  5204. // stateNode is any.
  5205. var uninitializedFiber = createHostRootFiber(isAsync);
  5206. var root = {
  5207. current: uninitializedFiber,
  5208. containerInfo: containerInfo,
  5209. pendingChildren: null,
  5210. pendingCommitExpirationTime: NoWork,
  5211. finishedWork: null,
  5212. context: null,
  5213. pendingContext: null,
  5214. hydrate: hydrate,
  5215. remainingExpirationTime: NoWork,
  5216. firstBatch: null,
  5217. nextScheduledRoot: null
  5218. };
  5219. uninitializedFiber.stateNode = root;
  5220. return root;
  5221. }
  5222. var onCommitFiberRoot = null;
  5223. var onCommitFiberUnmount = null;
  5224. var hasLoggedError = false;
  5225. function catchErrors(fn) {
  5226. return function (arg) {
  5227. try {
  5228. return fn(arg);
  5229. } catch (err) {
  5230. if (true && !hasLoggedError) {
  5231. hasLoggedError = true;
  5232. warning_1(false, 'React DevTools encountered an error: %s', err);
  5233. }
  5234. }
  5235. };
  5236. }
  5237. function injectInternals(internals) {
  5238. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  5239. // No DevTools
  5240. return false;
  5241. }
  5242. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  5243. if (hook.isDisabled) {
  5244. // This isn't a real property on the hook, but it can be set to opt out
  5245. // of DevTools integration and associated warnings and logs.
  5246. // https://github.com/facebook/react/issues/3877
  5247. return true;
  5248. }
  5249. if (!hook.supportsFiber) {
  5250. {
  5251. warning_1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
  5252. }
  5253. // DevTools exists, even though it doesn't support Fiber.
  5254. return true;
  5255. }
  5256. try {
  5257. var rendererID = hook.inject(internals);
  5258. // We have successfully injected, so now it is safe to set up hooks.
  5259. onCommitFiberRoot = catchErrors(function (root) {
  5260. return hook.onCommitFiberRoot(rendererID, root);
  5261. });
  5262. onCommitFiberUnmount = catchErrors(function (fiber) {
  5263. return hook.onCommitFiberUnmount(rendererID, fiber);
  5264. });
  5265. } catch (err) {
  5266. // Catch all errors because it is unsafe to throw during initialization.
  5267. {
  5268. warning_1(false, 'React DevTools encountered an error: %s.', err);
  5269. }
  5270. }
  5271. // DevTools exists
  5272. return true;
  5273. }
  5274. function onCommitRoot(root) {
  5275. if (typeof onCommitFiberRoot === 'function') {
  5276. onCommitFiberRoot(root);
  5277. }
  5278. }
  5279. function onCommitUnmount(fiber) {
  5280. if (typeof onCommitFiberUnmount === 'function') {
  5281. onCommitFiberUnmount(fiber);
  5282. }
  5283. }
  5284. /**
  5285. * Forked from fbjs/warning:
  5286. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  5287. *
  5288. * Only change is we use console.warn instead of console.error,
  5289. * and do nothing when 'console' is not supported.
  5290. * This really simplifies the code.
  5291. * ---
  5292. * Similar to invariant but only logs a warning if the condition is not met.
  5293. * This can be used to log issues in development environments in critical
  5294. * paths. Removing the logging code for production environments will keep the
  5295. * same logic and follow the same code paths.
  5296. */
  5297. var lowPriorityWarning = function () {};
  5298. {
  5299. var printWarning$1 = function (format) {
  5300. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5301. args[_key - 1] = arguments[_key];
  5302. }
  5303. var argIndex = 0;
  5304. var message = 'Warning: ' + format.replace(/%s/g, function () {
  5305. return args[argIndex++];
  5306. });
  5307. if (typeof console !== 'undefined') {
  5308. console.warn(message);
  5309. }
  5310. try {
  5311. // --- Welcome to debugging React ---
  5312. // This error was thrown as a convenience so that you can use this stack
  5313. // to find the callsite that caused this warning to fire.
  5314. throw new Error(message);
  5315. } catch (x) {}
  5316. };
  5317. lowPriorityWarning = function (condition, format) {
  5318. if (format === undefined) {
  5319. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  5320. }
  5321. if (!condition) {
  5322. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  5323. args[_key2 - 2] = arguments[_key2];
  5324. }
  5325. printWarning$1.apply(undefined, [format].concat(args));
  5326. }
  5327. };
  5328. }
  5329. var lowPriorityWarning$1 = lowPriorityWarning;
  5330. var ReactStrictModeWarnings = {
  5331. discardPendingWarnings: function () {},
  5332. flushPendingDeprecationWarnings: function () {},
  5333. flushPendingUnsafeLifecycleWarnings: function () {},
  5334. recordDeprecationWarnings: function (fiber, instance) {},
  5335. recordUnsafeLifecycleWarnings: function (fiber, instance) {}
  5336. };
  5337. {
  5338. var LIFECYCLE_SUGGESTIONS = {
  5339. UNSAFE_componentWillMount: 'componentDidMount',
  5340. UNSAFE_componentWillReceiveProps: 'static getDerivedStateFromProps',
  5341. UNSAFE_componentWillUpdate: 'componentDidUpdate'
  5342. };
  5343. var pendingComponentWillMountWarnings = [];
  5344. var pendingComponentWillReceivePropsWarnings = [];
  5345. var pendingComponentWillUpdateWarnings = [];
  5346. var pendingUnsafeLifecycleWarnings = new Map();
  5347. // Tracks components we have already warned about.
  5348. var didWarnAboutDeprecatedLifecycles = new Set();
  5349. var didWarnAboutUnsafeLifecycles = new Set();
  5350. var setToSortedString = function (set) {
  5351. var array = [];
  5352. set.forEach(function (value) {
  5353. array.push(value);
  5354. });
  5355. return array.sort().join(', ');
  5356. };
  5357. ReactStrictModeWarnings.discardPendingWarnings = function () {
  5358. pendingComponentWillMountWarnings = [];
  5359. pendingComponentWillReceivePropsWarnings = [];
  5360. pendingComponentWillUpdateWarnings = [];
  5361. pendingUnsafeLifecycleWarnings = new Map();
  5362. };
  5363. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  5364. pendingUnsafeLifecycleWarnings.forEach(function (lifecycleWarningsMap, strictRoot) {
  5365. var lifecyclesWarningMesages = [];
  5366. Object.keys(lifecycleWarningsMap).forEach(function (lifecycle) {
  5367. var lifecycleWarnings = lifecycleWarningsMap[lifecycle];
  5368. if (lifecycleWarnings.length > 0) {
  5369. var componentNames = new Set();
  5370. lifecycleWarnings.forEach(function (fiber) {
  5371. componentNames.add(getComponentName(fiber) || 'Component');
  5372. didWarnAboutUnsafeLifecycles.add(fiber.type);
  5373. });
  5374. var formatted = lifecycle.replace('UNSAFE_', '');
  5375. var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
  5376. var sortedComponentNames = setToSortedString(componentNames);
  5377. lifecyclesWarningMesages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames));
  5378. }
  5379. });
  5380. if (lifecyclesWarningMesages.length > 0) {
  5381. var strictRootComponentStack = getStackAddendumByWorkInProgressFiber(strictRoot);
  5382. warning_1(false, 'Unsafe lifecycle methods were found within a strict-mode tree:%s' + '\n\n%s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, lifecyclesWarningMesages.join('\n\n'));
  5383. }
  5384. });
  5385. pendingUnsafeLifecycleWarnings = new Map();
  5386. };
  5387. var getStrictRoot = function (fiber) {
  5388. var maybeStrictRoot = null;
  5389. while (fiber !== null) {
  5390. if (fiber.mode & StrictMode) {
  5391. maybeStrictRoot = fiber;
  5392. }
  5393. fiber = fiber['return'];
  5394. }
  5395. return maybeStrictRoot;
  5396. };
  5397. ReactStrictModeWarnings.flushPendingDeprecationWarnings = function () {
  5398. if (pendingComponentWillMountWarnings.length > 0) {
  5399. var uniqueNames = new Set();
  5400. pendingComponentWillMountWarnings.forEach(function (fiber) {
  5401. uniqueNames.add(getComponentName(fiber) || 'Component');
  5402. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  5403. });
  5404. var sortedNames = setToSortedString(uniqueNames);
  5405. lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames);
  5406. pendingComponentWillMountWarnings = [];
  5407. }
  5408. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  5409. var _uniqueNames = new Set();
  5410. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  5411. _uniqueNames.add(getComponentName(fiber) || 'Component');
  5412. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  5413. });
  5414. var _sortedNames = setToSortedString(_uniqueNames);
  5415. lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames);
  5416. pendingComponentWillReceivePropsWarnings = [];
  5417. }
  5418. if (pendingComponentWillUpdateWarnings.length > 0) {
  5419. var _uniqueNames2 = new Set();
  5420. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  5421. _uniqueNames2.add(getComponentName(fiber) || 'Component');
  5422. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  5423. });
  5424. var _sortedNames2 = setToSortedString(_uniqueNames2);
  5425. lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2);
  5426. pendingComponentWillUpdateWarnings = [];
  5427. }
  5428. };
  5429. ReactStrictModeWarnings.recordDeprecationWarnings = function (fiber, instance) {
  5430. // Dedup strategy: Warn once per component.
  5431. if (didWarnAboutDeprecatedLifecycles.has(fiber.type)) {
  5432. return;
  5433. }
  5434. // Don't warn about react-lifecycles-compat polyfilled components.
  5435. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  5436. pendingComponentWillMountWarnings.push(fiber);
  5437. }
  5438. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  5439. pendingComponentWillReceivePropsWarnings.push(fiber);
  5440. }
  5441. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  5442. pendingComponentWillUpdateWarnings.push(fiber);
  5443. }
  5444. };
  5445. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  5446. var strictRoot = getStrictRoot(fiber);
  5447. // Dedup strategy: Warn once per component.
  5448. // This is difficult to track any other way since component names
  5449. // are often vague and are likely to collide between 3rd party libraries.
  5450. // An expand property is probably okay to use here since it's DEV-only,
  5451. // and will only be set in the event of serious warnings.
  5452. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  5453. return;
  5454. }
  5455. // Don't warn about react-lifecycles-compat polyfilled components.
  5456. // Note that it is sufficient to check for the presence of a
  5457. // single lifecycle, componentWillMount, with the polyfill flag.
  5458. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning === true) {
  5459. return;
  5460. }
  5461. var warningsForRoot = void 0;
  5462. if (!pendingUnsafeLifecycleWarnings.has(strictRoot)) {
  5463. warningsForRoot = {
  5464. UNSAFE_componentWillMount: [],
  5465. UNSAFE_componentWillReceiveProps: [],
  5466. UNSAFE_componentWillUpdate: []
  5467. };
  5468. pendingUnsafeLifecycleWarnings.set(strictRoot, warningsForRoot);
  5469. } else {
  5470. warningsForRoot = pendingUnsafeLifecycleWarnings.get(strictRoot);
  5471. }
  5472. var unsafeLifecycles = [];
  5473. if (typeof instance.componentWillMount === 'function' || typeof instance.UNSAFE_componentWillMount === 'function') {
  5474. unsafeLifecycles.push('UNSAFE_componentWillMount');
  5475. }
  5476. if (typeof instance.componentWillReceiveProps === 'function' || typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  5477. unsafeLifecycles.push('UNSAFE_componentWillReceiveProps');
  5478. }
  5479. if (typeof instance.componentWillUpdate === 'function' || typeof instance.UNSAFE_componentWillUpdate === 'function') {
  5480. unsafeLifecycles.push('UNSAFE_componentWillUpdate');
  5481. }
  5482. if (unsafeLifecycles.length > 0) {
  5483. unsafeLifecycles.forEach(function (lifecycle) {
  5484. warningsForRoot[lifecycle].push(fiber);
  5485. });
  5486. }
  5487. };
  5488. }
  5489. // Exports ReactDOM.createRoot
  5490. var enableUserTimingAPI = true;
  5491. // Mutating mode (React DOM, React ART, React Native):
  5492. var enableMutatingReconciler = true;
  5493. // Experimental noop mode (currently unused):
  5494. var enableNoopReconciler = false;
  5495. // Experimental persistent mode (Fabric):
  5496. var enablePersistentReconciler = false;
  5497. // Experimental error-boundary API that can recover from errors within a single
  5498. // render phase
  5499. var enableGetDerivedStateFromCatch = false;
  5500. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  5501. var debugRenderPhaseSideEffects = false;
  5502. // In some cases, StrictMode should also double-render lifecycles.
  5503. // This can be confusing for tests though,
  5504. // And it can be bad for performance in production.
  5505. // This feature flag can be used to control the behavior:
  5506. var debugRenderPhaseSideEffectsForStrictMode = true;
  5507. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  5508. // replay the begin phase of a failed component inside invokeGuardedCallback.
  5509. var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
  5510. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  5511. var warnAboutDeprecatedLifecycles = false;
  5512. var alwaysUseRequestIdleCallbackPolyfill = false;
  5513. // Only used in www builds.
  5514. // Prefix measurements so that it's possible to filter them.
  5515. // Longer prefixes are hard to read in DevTools.
  5516. var reactEmoji = '\u269B';
  5517. var warningEmoji = '\u26D4';
  5518. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
  5519. // Keep track of current fiber so that we know the path to unwind on pause.
  5520. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  5521. var currentFiber = null;
  5522. // If we're in the middle of user code, which fiber and method is it?
  5523. // Reusing `currentFiber` would be confusing for this because user code fiber
  5524. // can change during commit phase too, but we don't need to unwind it (since
  5525. // lifecycles in the commit phase don't resemble a tree).
  5526. var currentPhase = null;
  5527. var currentPhaseFiber = null;
  5528. // Did lifecycle hook schedule an update? This is often a performance problem,
  5529. // so we will keep track of it, and include it in the report.
  5530. // Track commits caused by cascading updates.
  5531. var isCommitting = false;
  5532. var hasScheduledUpdateInCurrentCommit = false;
  5533. var hasScheduledUpdateInCurrentPhase = false;
  5534. var commitCountInCurrentWorkLoop = 0;
  5535. var effectCountInCurrentCommit = 0;
  5536. var isWaitingForCallback = false;
  5537. // During commits, we only show a measurement once per method name
  5538. // to avoid stretch the commit phase with measurement overhead.
  5539. var labelsInCurrentCommit = new Set();
  5540. var formatMarkName = function (markName) {
  5541. return reactEmoji + ' ' + markName;
  5542. };
  5543. var formatLabel = function (label, warning) {
  5544. var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
  5545. var suffix = warning ? ' Warning: ' + warning : '';
  5546. return '' + prefix + label + suffix;
  5547. };
  5548. var beginMark = function (markName) {
  5549. performance.mark(formatMarkName(markName));
  5550. };
  5551. var clearMark = function (markName) {
  5552. performance.clearMarks(formatMarkName(markName));
  5553. };
  5554. var endMark = function (label, markName, warning) {
  5555. var formattedMarkName = formatMarkName(markName);
  5556. var formattedLabel = formatLabel(label, warning);
  5557. try {
  5558. performance.measure(formattedLabel, formattedMarkName);
  5559. } catch (err) {}
  5560. // If previous mark was missing for some reason, this will throw.
  5561. // This could only happen if React crashed in an unexpected place earlier.
  5562. // Don't pile on with more errors.
  5563. // Clear marks immediately to avoid growing buffer.
  5564. performance.clearMarks(formattedMarkName);
  5565. performance.clearMeasures(formattedLabel);
  5566. };
  5567. var getFiberMarkName = function (label, debugID) {
  5568. return label + ' (#' + debugID + ')';
  5569. };
  5570. var getFiberLabel = function (componentName, isMounted, phase) {
  5571. if (phase === null) {
  5572. // These are composite component total time measurements.
  5573. return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
  5574. } else {
  5575. // Composite component methods.
  5576. return componentName + '.' + phase;
  5577. }
  5578. };
  5579. var beginFiberMark = function (fiber, phase) {
  5580. var componentName = getComponentName(fiber) || 'Unknown';
  5581. var debugID = fiber._debugID;
  5582. var isMounted = fiber.alternate !== null;
  5583. var label = getFiberLabel(componentName, isMounted, phase);
  5584. if (isCommitting && labelsInCurrentCommit.has(label)) {
  5585. // During the commit phase, we don't show duplicate labels because
  5586. // there is a fixed overhead for every measurement, and we don't
  5587. // want to stretch the commit phase beyond necessary.
  5588. return false;
  5589. }
  5590. labelsInCurrentCommit.add(label);
  5591. var markName = getFiberMarkName(label, debugID);
  5592. beginMark(markName);
  5593. return true;
  5594. };
  5595. var clearFiberMark = function (fiber, phase) {
  5596. var componentName = getComponentName(fiber) || 'Unknown';
  5597. var debugID = fiber._debugID;
  5598. var isMounted = fiber.alternate !== null;
  5599. var label = getFiberLabel(componentName, isMounted, phase);
  5600. var markName = getFiberMarkName(label, debugID);
  5601. clearMark(markName);
  5602. };
  5603. var endFiberMark = function (fiber, phase, warning) {
  5604. var componentName = getComponentName(fiber) || 'Unknown';
  5605. var debugID = fiber._debugID;
  5606. var isMounted = fiber.alternate !== null;
  5607. var label = getFiberLabel(componentName, isMounted, phase);
  5608. var markName = getFiberMarkName(label, debugID);
  5609. endMark(label, markName, warning);
  5610. };
  5611. var shouldIgnoreFiber = function (fiber) {
  5612. // Host components should be skipped in the timeline.
  5613. // We could check typeof fiber.type, but does this work with RN?
  5614. switch (fiber.tag) {
  5615. case HostRoot:
  5616. case HostComponent:
  5617. case HostText:
  5618. case HostPortal:
  5619. case CallComponent:
  5620. case ReturnComponent:
  5621. case Fragment:
  5622. case ContextProvider:
  5623. case ContextConsumer:
  5624. case Mode:
  5625. return true;
  5626. default:
  5627. return false;
  5628. }
  5629. };
  5630. var clearPendingPhaseMeasurement = function () {
  5631. if (currentPhase !== null && currentPhaseFiber !== null) {
  5632. clearFiberMark(currentPhaseFiber, currentPhase);
  5633. }
  5634. currentPhaseFiber = null;
  5635. currentPhase = null;
  5636. hasScheduledUpdateInCurrentPhase = false;
  5637. };
  5638. var pauseTimers = function () {
  5639. // Stops all currently active measurements so that they can be resumed
  5640. // if we continue in a later deferred loop from the same unit of work.
  5641. var fiber = currentFiber;
  5642. while (fiber) {
  5643. if (fiber._debugIsCurrentlyTiming) {
  5644. endFiberMark(fiber, null, null);
  5645. }
  5646. fiber = fiber['return'];
  5647. }
  5648. };
  5649. var resumeTimersRecursively = function (fiber) {
  5650. if (fiber['return'] !== null) {
  5651. resumeTimersRecursively(fiber['return']);
  5652. }
  5653. if (fiber._debugIsCurrentlyTiming) {
  5654. beginFiberMark(fiber, null);
  5655. }
  5656. };
  5657. var resumeTimers = function () {
  5658. // Resumes all measurements that were active during the last deferred loop.
  5659. if (currentFiber !== null) {
  5660. resumeTimersRecursively(currentFiber);
  5661. }
  5662. };
  5663. function recordEffect() {
  5664. if (enableUserTimingAPI) {
  5665. effectCountInCurrentCommit++;
  5666. }
  5667. }
  5668. function recordScheduleUpdate() {
  5669. if (enableUserTimingAPI) {
  5670. if (isCommitting) {
  5671. hasScheduledUpdateInCurrentCommit = true;
  5672. }
  5673. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  5674. hasScheduledUpdateInCurrentPhase = true;
  5675. }
  5676. }
  5677. }
  5678. function startRequestCallbackTimer() {
  5679. if (enableUserTimingAPI) {
  5680. if (supportsUserTiming && !isWaitingForCallback) {
  5681. isWaitingForCallback = true;
  5682. beginMark('(Waiting for async callback...)');
  5683. }
  5684. }
  5685. }
  5686. function stopRequestCallbackTimer(didExpire, expirationTime) {
  5687. if (enableUserTimingAPI) {
  5688. if (supportsUserTiming) {
  5689. isWaitingForCallback = false;
  5690. var warning = didExpire ? 'React was blocked by main thread' : null;
  5691. endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning);
  5692. }
  5693. }
  5694. }
  5695. function startWorkTimer(fiber) {
  5696. if (enableUserTimingAPI) {
  5697. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  5698. return;
  5699. }
  5700. // If we pause, this is the fiber to unwind from.
  5701. currentFiber = fiber;
  5702. if (!beginFiberMark(fiber, null)) {
  5703. return;
  5704. }
  5705. fiber._debugIsCurrentlyTiming = true;
  5706. }
  5707. }
  5708. function cancelWorkTimer(fiber) {
  5709. if (enableUserTimingAPI) {
  5710. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  5711. return;
  5712. }
  5713. // Remember we shouldn't complete measurement for this fiber.
  5714. // Otherwise flamechart will be deep even for small updates.
  5715. fiber._debugIsCurrentlyTiming = false;
  5716. clearFiberMark(fiber, null);
  5717. }
  5718. }
  5719. function stopWorkTimer(fiber) {
  5720. if (enableUserTimingAPI) {
  5721. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  5722. return;
  5723. }
  5724. // If we pause, its parent is the fiber to unwind from.
  5725. currentFiber = fiber['return'];
  5726. if (!fiber._debugIsCurrentlyTiming) {
  5727. return;
  5728. }
  5729. fiber._debugIsCurrentlyTiming = false;
  5730. endFiberMark(fiber, null, null);
  5731. }
  5732. }
  5733. function stopFailedWorkTimer(fiber) {
  5734. if (enableUserTimingAPI) {
  5735. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  5736. return;
  5737. }
  5738. // If we pause, its parent is the fiber to unwind from.
  5739. currentFiber = fiber['return'];
  5740. if (!fiber._debugIsCurrentlyTiming) {
  5741. return;
  5742. }
  5743. fiber._debugIsCurrentlyTiming = false;
  5744. var warning = 'An error was thrown inside this error boundary';
  5745. endFiberMark(fiber, null, warning);
  5746. }
  5747. }
  5748. function startPhaseTimer(fiber, phase) {
  5749. if (enableUserTimingAPI) {
  5750. if (!supportsUserTiming) {
  5751. return;
  5752. }
  5753. clearPendingPhaseMeasurement();
  5754. if (!beginFiberMark(fiber, phase)) {
  5755. return;
  5756. }
  5757. currentPhaseFiber = fiber;
  5758. currentPhase = phase;
  5759. }
  5760. }
  5761. function stopPhaseTimer() {
  5762. if (enableUserTimingAPI) {
  5763. if (!supportsUserTiming) {
  5764. return;
  5765. }
  5766. if (currentPhase !== null && currentPhaseFiber !== null) {
  5767. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  5768. endFiberMark(currentPhaseFiber, currentPhase, warning);
  5769. }
  5770. currentPhase = null;
  5771. currentPhaseFiber = null;
  5772. }
  5773. }
  5774. function startWorkLoopTimer(nextUnitOfWork) {
  5775. if (enableUserTimingAPI) {
  5776. currentFiber = nextUnitOfWork;
  5777. if (!supportsUserTiming) {
  5778. return;
  5779. }
  5780. commitCountInCurrentWorkLoop = 0;
  5781. // This is top level call.
  5782. // Any other measurements are performed within.
  5783. beginMark('(React Tree Reconciliation)');
  5784. // Resume any measurements that were in progress during the last loop.
  5785. resumeTimers();
  5786. }
  5787. }
  5788. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  5789. if (enableUserTimingAPI) {
  5790. if (!supportsUserTiming) {
  5791. return;
  5792. }
  5793. var warning = null;
  5794. if (interruptedBy !== null) {
  5795. if (interruptedBy.tag === HostRoot) {
  5796. warning = 'A top-level update interrupted the previous render';
  5797. } else {
  5798. var componentName = getComponentName(interruptedBy) || 'Unknown';
  5799. warning = 'An update to ' + componentName + ' interrupted the previous render';
  5800. }
  5801. } else if (commitCountInCurrentWorkLoop > 1) {
  5802. warning = 'There were cascading updates';
  5803. }
  5804. commitCountInCurrentWorkLoop = 0;
  5805. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
  5806. // Pause any measurements until the next loop.
  5807. pauseTimers();
  5808. endMark(label, '(React Tree Reconciliation)', warning);
  5809. }
  5810. }
  5811. function startCommitTimer() {
  5812. if (enableUserTimingAPI) {
  5813. if (!supportsUserTiming) {
  5814. return;
  5815. }
  5816. isCommitting = true;
  5817. hasScheduledUpdateInCurrentCommit = false;
  5818. labelsInCurrentCommit.clear();
  5819. beginMark('(Committing Changes)');
  5820. }
  5821. }
  5822. function stopCommitTimer() {
  5823. if (enableUserTimingAPI) {
  5824. if (!supportsUserTiming) {
  5825. return;
  5826. }
  5827. var warning = null;
  5828. if (hasScheduledUpdateInCurrentCommit) {
  5829. warning = 'Lifecycle hook scheduled a cascading update';
  5830. } else if (commitCountInCurrentWorkLoop > 0) {
  5831. warning = 'Caused by a cascading update in earlier commit';
  5832. }
  5833. hasScheduledUpdateInCurrentCommit = false;
  5834. commitCountInCurrentWorkLoop++;
  5835. isCommitting = false;
  5836. labelsInCurrentCommit.clear();
  5837. endMark('(Committing Changes)', '(Committing Changes)', warning);
  5838. }
  5839. }
  5840. function startCommitSnapshotEffectsTimer() {
  5841. if (enableUserTimingAPI) {
  5842. if (!supportsUserTiming) {
  5843. return;
  5844. }
  5845. effectCountInCurrentCommit = 0;
  5846. beginMark('(Committing Snapshot Effects)');
  5847. }
  5848. }
  5849. function stopCommitSnapshotEffectsTimer() {
  5850. if (enableUserTimingAPI) {
  5851. if (!supportsUserTiming) {
  5852. return;
  5853. }
  5854. var count = effectCountInCurrentCommit;
  5855. effectCountInCurrentCommit = 0;
  5856. endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
  5857. }
  5858. }
  5859. function startCommitHostEffectsTimer() {
  5860. if (enableUserTimingAPI) {
  5861. if (!supportsUserTiming) {
  5862. return;
  5863. }
  5864. effectCountInCurrentCommit = 0;
  5865. beginMark('(Committing Host Effects)');
  5866. }
  5867. }
  5868. function stopCommitHostEffectsTimer() {
  5869. if (enableUserTimingAPI) {
  5870. if (!supportsUserTiming) {
  5871. return;
  5872. }
  5873. var count = effectCountInCurrentCommit;
  5874. effectCountInCurrentCommit = 0;
  5875. endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
  5876. }
  5877. }
  5878. function startCommitLifeCyclesTimer() {
  5879. if (enableUserTimingAPI) {
  5880. if (!supportsUserTiming) {
  5881. return;
  5882. }
  5883. effectCountInCurrentCommit = 0;
  5884. beginMark('(Calling Lifecycle Methods)');
  5885. }
  5886. }
  5887. function stopCommitLifeCyclesTimer() {
  5888. if (enableUserTimingAPI) {
  5889. if (!supportsUserTiming) {
  5890. return;
  5891. }
  5892. var count = effectCountInCurrentCommit;
  5893. effectCountInCurrentCommit = 0;
  5894. endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
  5895. }
  5896. }
  5897. var didWarnUpdateInsideUpdate = void 0;
  5898. {
  5899. didWarnUpdateInsideUpdate = false;
  5900. }
  5901. // Callbacks are not validated until invocation
  5902. // Singly linked-list of updates. When an update is scheduled, it is added to
  5903. // the queue of the current fiber and the work-in-progress fiber. The two queues
  5904. // are separate but they share a persistent structure.
  5905. //
  5906. // During reconciliation, updates are removed from the work-in-progress fiber,
  5907. // but they remain on the current fiber. That ensures that if a work-in-progress
  5908. // is aborted, the aborted updates are recovered by cloning from current.
  5909. //
  5910. // The work-in-progress queue is always a subset of the current queue.
  5911. //
  5912. // When the tree is committed, the work-in-progress becomes the current.
  5913. function createUpdateQueue(baseState) {
  5914. var queue = {
  5915. baseState: baseState,
  5916. expirationTime: NoWork,
  5917. first: null,
  5918. last: null,
  5919. callbackList: null,
  5920. hasForceUpdate: false,
  5921. isInitialized: false,
  5922. capturedValues: null
  5923. };
  5924. {
  5925. queue.isProcessing = false;
  5926. }
  5927. return queue;
  5928. }
  5929. function insertUpdateIntoQueue(queue, update) {
  5930. // Append the update to the end of the list.
  5931. if (queue.last === null) {
  5932. // Queue is empty
  5933. queue.first = queue.last = update;
  5934. } else {
  5935. queue.last.next = update;
  5936. queue.last = update;
  5937. }
  5938. if (queue.expirationTime === NoWork || queue.expirationTime > update.expirationTime) {
  5939. queue.expirationTime = update.expirationTime;
  5940. }
  5941. }
  5942. var q1 = void 0;
  5943. var q2 = void 0;
  5944. function ensureUpdateQueues(fiber) {
  5945. q1 = q2 = null;
  5946. // We'll have at least one and at most two distinct update queues.
  5947. var alternateFiber = fiber.alternate;
  5948. var queue1 = fiber.updateQueue;
  5949. if (queue1 === null) {
  5950. // TODO: We don't know what the base state will be until we begin work.
  5951. // It depends on which fiber is the next current. Initialize with an empty
  5952. // base state, then set to the memoizedState when rendering. Not super
  5953. // happy with this approach.
  5954. queue1 = fiber.updateQueue = createUpdateQueue(null);
  5955. }
  5956. var queue2 = void 0;
  5957. if (alternateFiber !== null) {
  5958. queue2 = alternateFiber.updateQueue;
  5959. if (queue2 === null) {
  5960. queue2 = alternateFiber.updateQueue = createUpdateQueue(null);
  5961. }
  5962. } else {
  5963. queue2 = null;
  5964. }
  5965. queue2 = queue2 !== queue1 ? queue2 : null;
  5966. // Use module variables instead of returning a tuple
  5967. q1 = queue1;
  5968. q2 = queue2;
  5969. }
  5970. function insertUpdateIntoFiber(fiber, update) {
  5971. ensureUpdateQueues(fiber);
  5972. var queue1 = q1;
  5973. var queue2 = q2;
  5974. // Warn if an update is scheduled from inside an updater function.
  5975. {
  5976. if ((queue1.isProcessing || queue2 !== null && queue2.isProcessing) && !didWarnUpdateInsideUpdate) {
  5977. warning_1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
  5978. didWarnUpdateInsideUpdate = true;
  5979. }
  5980. }
  5981. // If there's only one queue, add the update to that queue and exit.
  5982. if (queue2 === null) {
  5983. insertUpdateIntoQueue(queue1, update);
  5984. return;
  5985. }
  5986. // If either queue is empty, we need to add to both queues.
  5987. if (queue1.last === null || queue2.last === null) {
  5988. insertUpdateIntoQueue(queue1, update);
  5989. insertUpdateIntoQueue(queue2, update);
  5990. return;
  5991. }
  5992. // If both lists are not empty, the last update is the same for both lists
  5993. // because of structural sharing. So, we should only append to one of
  5994. // the lists.
  5995. insertUpdateIntoQueue(queue1, update);
  5996. // But we still need to update the `last` pointer of queue2.
  5997. queue2.last = update;
  5998. }
  5999. function getUpdateExpirationTime(fiber) {
  6000. switch (fiber.tag) {
  6001. case HostRoot:
  6002. case ClassComponent:
  6003. var updateQueue = fiber.updateQueue;
  6004. if (updateQueue === null) {
  6005. return NoWork;
  6006. }
  6007. return updateQueue.expirationTime;
  6008. default:
  6009. return NoWork;
  6010. }
  6011. }
  6012. function getStateFromUpdate(update, instance, prevState, props) {
  6013. var partialState = update.partialState;
  6014. if (typeof partialState === 'function') {
  6015. return partialState.call(instance, prevState, props);
  6016. } else {
  6017. return partialState;
  6018. }
  6019. }
  6020. function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) {
  6021. if (current !== null && current.updateQueue === queue) {
  6022. // We need to create a work-in-progress queue, by cloning the current queue.
  6023. var currentQueue = queue;
  6024. queue = workInProgress.updateQueue = {
  6025. baseState: currentQueue.baseState,
  6026. expirationTime: currentQueue.expirationTime,
  6027. first: currentQueue.first,
  6028. last: currentQueue.last,
  6029. isInitialized: currentQueue.isInitialized,
  6030. capturedValues: currentQueue.capturedValues,
  6031. // These fields are no longer valid because they were already committed.
  6032. // Reset them.
  6033. callbackList: null,
  6034. hasForceUpdate: false
  6035. };
  6036. }
  6037. {
  6038. // Set this flag so we can warn if setState is called inside the update
  6039. // function of another setState.
  6040. queue.isProcessing = true;
  6041. }
  6042. // Reset the remaining expiration time. If we skip over any updates, we'll
  6043. // increase this accordingly.
  6044. queue.expirationTime = NoWork;
  6045. // TODO: We don't know what the base state will be until we begin work.
  6046. // It depends on which fiber is the next current. Initialize with an empty
  6047. // base state, then set to the memoizedState when rendering. Not super
  6048. // happy with this approach.
  6049. var state = void 0;
  6050. if (queue.isInitialized) {
  6051. state = queue.baseState;
  6052. } else {
  6053. state = queue.baseState = workInProgress.memoizedState;
  6054. queue.isInitialized = true;
  6055. }
  6056. var dontMutatePrevState = true;
  6057. var update = queue.first;
  6058. var didSkip = false;
  6059. while (update !== null) {
  6060. var updateExpirationTime = update.expirationTime;
  6061. if (updateExpirationTime > renderExpirationTime) {
  6062. // This update does not have sufficient priority. Skip it.
  6063. var remainingExpirationTime = queue.expirationTime;
  6064. if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) {
  6065. // Update the remaining expiration time.
  6066. queue.expirationTime = updateExpirationTime;
  6067. }
  6068. if (!didSkip) {
  6069. didSkip = true;
  6070. queue.baseState = state;
  6071. }
  6072. // Continue to the next update.
  6073. update = update.next;
  6074. continue;
  6075. }
  6076. // This update does have sufficient priority.
  6077. // If no previous updates were skipped, drop this update from the queue by
  6078. // advancing the head of the list.
  6079. if (!didSkip) {
  6080. queue.first = update.next;
  6081. if (queue.first === null) {
  6082. queue.last = null;
  6083. }
  6084. }
  6085. // Invoke setState callback an extra time to help detect side-effects.
  6086. // Ignore the return value in this case.
  6087. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  6088. getStateFromUpdate(update, instance, state, props);
  6089. }
  6090. // Process the update
  6091. var _partialState = void 0;
  6092. if (update.isReplace) {
  6093. state = getStateFromUpdate(update, instance, state, props);
  6094. dontMutatePrevState = true;
  6095. } else {
  6096. _partialState = getStateFromUpdate(update, instance, state, props);
  6097. if (_partialState) {
  6098. if (dontMutatePrevState) {
  6099. // $FlowFixMe: Idk how to type this properly.
  6100. state = _assign({}, state, _partialState);
  6101. } else {
  6102. state = _assign(state, _partialState);
  6103. }
  6104. dontMutatePrevState = false;
  6105. }
  6106. }
  6107. if (update.isForced) {
  6108. queue.hasForceUpdate = true;
  6109. }
  6110. if (update.callback !== null) {
  6111. // Append to list of callbacks.
  6112. var _callbackList = queue.callbackList;
  6113. if (_callbackList === null) {
  6114. _callbackList = queue.callbackList = [];
  6115. }
  6116. _callbackList.push(update);
  6117. }
  6118. if (update.capturedValue !== null) {
  6119. var _capturedValues = queue.capturedValues;
  6120. if (_capturedValues === null) {
  6121. queue.capturedValues = [update.capturedValue];
  6122. } else {
  6123. _capturedValues.push(update.capturedValue);
  6124. }
  6125. }
  6126. update = update.next;
  6127. }
  6128. if (queue.callbackList !== null) {
  6129. workInProgress.effectTag |= Callback;
  6130. } else if (queue.first === null && !queue.hasForceUpdate && queue.capturedValues === null) {
  6131. // The queue is empty. We can reset it.
  6132. workInProgress.updateQueue = null;
  6133. }
  6134. if (!didSkip) {
  6135. didSkip = true;
  6136. queue.baseState = state;
  6137. }
  6138. {
  6139. // No longer processing.
  6140. queue.isProcessing = false;
  6141. }
  6142. return state;
  6143. }
  6144. function commitCallbacks(queue, context) {
  6145. var callbackList = queue.callbackList;
  6146. if (callbackList === null) {
  6147. return;
  6148. }
  6149. // Set the list to null to make sure they don't get called more than once.
  6150. queue.callbackList = null;
  6151. for (var i = 0; i < callbackList.length; i++) {
  6152. var update = callbackList[i];
  6153. var _callback = update.callback;
  6154. // This update might be processed again. Clear the callback so it's only
  6155. // called once.
  6156. update.callback = null;
  6157. !(typeof _callback === 'function') ? invariant_1(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback) : void 0;
  6158. _callback.call(context);
  6159. }
  6160. }
  6161. var fakeInternalInstance = {};
  6162. var isArray = Array.isArray;
  6163. var didWarnAboutStateAssignmentForComponent = void 0;
  6164. var didWarnAboutUndefinedDerivedState = void 0;
  6165. var didWarnAboutUninitializedState = void 0;
  6166. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
  6167. var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
  6168. var warnOnInvalidCallback$1 = void 0;
  6169. {
  6170. didWarnAboutStateAssignmentForComponent = new Set();
  6171. didWarnAboutUndefinedDerivedState = new Set();
  6172. didWarnAboutUninitializedState = new Set();
  6173. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  6174. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  6175. var didWarnOnInvalidCallback = new Set();
  6176. warnOnInvalidCallback$1 = function (callback, callerName) {
  6177. if (callback === null || typeof callback === 'function') {
  6178. return;
  6179. }
  6180. var key = callerName + '_' + callback;
  6181. if (!didWarnOnInvalidCallback.has(key)) {
  6182. didWarnOnInvalidCallback.add(key);
  6183. warning_1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  6184. }
  6185. };
  6186. // This is so gross but it's at least non-critical and can be removed if
  6187. // it causes problems. This is meant to give a nicer error message for
  6188. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  6189. // ...)) which otherwise throws a "_processChildContext is not a function"
  6190. // exception.
  6191. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  6192. enumerable: false,
  6193. value: function () {
  6194. invariant_1(false, '_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn\'t supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).');
  6195. }
  6196. });
  6197. Object.freeze(fakeInternalInstance);
  6198. }
  6199. function callGetDerivedStateFromCatch(ctor, capturedValues) {
  6200. var resultState = {};
  6201. for (var i = 0; i < capturedValues.length; i++) {
  6202. var capturedValue = capturedValues[i];
  6203. var error = capturedValue.value;
  6204. var partialState = ctor.getDerivedStateFromCatch.call(null, error);
  6205. if (partialState !== null && partialState !== undefined) {
  6206. _assign(resultState, partialState);
  6207. }
  6208. }
  6209. return resultState;
  6210. }
  6211. var ReactFiberClassComponent = function (legacyContext, scheduleWork, computeExpirationForFiber, memoizeProps, memoizeState) {
  6212. var cacheContext = legacyContext.cacheContext,
  6213. getMaskedContext = legacyContext.getMaskedContext,
  6214. getUnmaskedContext = legacyContext.getUnmaskedContext,
  6215. isContextConsumer = legacyContext.isContextConsumer,
  6216. hasContextChanged = legacyContext.hasContextChanged;
  6217. // Class component state updater
  6218. var updater = {
  6219. isMounted: isMounted,
  6220. enqueueSetState: function (instance, partialState, callback) {
  6221. var fiber = get(instance);
  6222. callback = callback === undefined ? null : callback;
  6223. {
  6224. warnOnInvalidCallback$1(callback, 'setState');
  6225. }
  6226. var expirationTime = computeExpirationForFiber(fiber);
  6227. var update = {
  6228. expirationTime: expirationTime,
  6229. partialState: partialState,
  6230. callback: callback,
  6231. isReplace: false,
  6232. isForced: false,
  6233. capturedValue: null,
  6234. next: null
  6235. };
  6236. insertUpdateIntoFiber(fiber, update);
  6237. scheduleWork(fiber, expirationTime);
  6238. },
  6239. enqueueReplaceState: function (instance, state, callback) {
  6240. var fiber = get(instance);
  6241. callback = callback === undefined ? null : callback;
  6242. {
  6243. warnOnInvalidCallback$1(callback, 'replaceState');
  6244. }
  6245. var expirationTime = computeExpirationForFiber(fiber);
  6246. var update = {
  6247. expirationTime: expirationTime,
  6248. partialState: state,
  6249. callback: callback,
  6250. isReplace: true,
  6251. isForced: false,
  6252. capturedValue: null,
  6253. next: null
  6254. };
  6255. insertUpdateIntoFiber(fiber, update);
  6256. scheduleWork(fiber, expirationTime);
  6257. },
  6258. enqueueForceUpdate: function (instance, callback) {
  6259. var fiber = get(instance);
  6260. callback = callback === undefined ? null : callback;
  6261. {
  6262. warnOnInvalidCallback$1(callback, 'forceUpdate');
  6263. }
  6264. var expirationTime = computeExpirationForFiber(fiber);
  6265. var update = {
  6266. expirationTime: expirationTime,
  6267. partialState: null,
  6268. callback: callback,
  6269. isReplace: false,
  6270. isForced: true,
  6271. capturedValue: null,
  6272. next: null
  6273. };
  6274. insertUpdateIntoFiber(fiber, update);
  6275. scheduleWork(fiber, expirationTime);
  6276. }
  6277. };
  6278. function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
  6279. if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
  6280. // If the workInProgress already has an Update effect, return true
  6281. return true;
  6282. }
  6283. var instance = workInProgress.stateNode;
  6284. var ctor = workInProgress.type;
  6285. if (typeof instance.shouldComponentUpdate === 'function') {
  6286. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  6287. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
  6288. stopPhaseTimer();
  6289. {
  6290. !(shouldUpdate !== undefined) ? warning_1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component') : void 0;
  6291. }
  6292. return shouldUpdate;
  6293. }
  6294. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  6295. return !shallowEqual_1(oldProps, newProps) || !shallowEqual_1(oldState, newState);
  6296. }
  6297. return true;
  6298. }
  6299. function checkClassInstance(workInProgress) {
  6300. var instance = workInProgress.stateNode;
  6301. var type = workInProgress.type;
  6302. {
  6303. var name = getComponentName(workInProgress) || 'Component';
  6304. var renderPresent = instance.render;
  6305. if (!renderPresent) {
  6306. if (type.prototype && typeof type.prototype.render === 'function') {
  6307. warning_1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  6308. } else {
  6309. warning_1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  6310. }
  6311. }
  6312. var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
  6313. !noGetInitialStateOnES6 ? warning_1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
  6314. var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
  6315. !noGetDefaultPropsOnES6 ? warning_1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
  6316. var noInstancePropTypes = !instance.propTypes;
  6317. !noInstancePropTypes ? warning_1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
  6318. var noInstanceContextTypes = !instance.contextTypes;
  6319. !noInstanceContextTypes ? warning_1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
  6320. var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
  6321. !noComponentShouldUpdate ? warning_1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
  6322. if (type.prototype && type.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  6323. warning_1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(workInProgress) || 'A pure component');
  6324. }
  6325. var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
  6326. !noComponentDidUnmount ? warning_1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
  6327. var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
  6328. !noComponentDidReceiveProps ? warning_1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
  6329. var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
  6330. !noComponentWillRecieveProps ? warning_1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
  6331. var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
  6332. !noUnsafeComponentWillRecieveProps ? warning_1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
  6333. var hasMutatedProps = instance.props !== workInProgress.pendingProps;
  6334. !(instance.props === undefined || !hasMutatedProps) ? warning_1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
  6335. var noInstanceDefaultProps = !instance.defaultProps;
  6336. !noInstanceDefaultProps ? warning_1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
  6337. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type)) {
  6338. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type);
  6339. warning_1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(workInProgress));
  6340. }
  6341. var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
  6342. !noInstanceGetDerivedStateFromProps ? warning_1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  6343. var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function';
  6344. !noInstanceGetDerivedStateFromCatch ? warning_1(false, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  6345. var noStaticGetSnapshotBeforeUpdate = typeof type.getSnapshotBeforeUpdate !== 'function';
  6346. !noStaticGetSnapshotBeforeUpdate ? warning_1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
  6347. var _state = instance.state;
  6348. if (_state && (typeof _state !== 'object' || isArray(_state))) {
  6349. warning_1(false, '%s.state: must be set to an object or null', name);
  6350. }
  6351. if (typeof instance.getChildContext === 'function') {
  6352. !(typeof type.childContextTypes === 'object') ? warning_1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
  6353. }
  6354. }
  6355. }
  6356. function resetInputPointers(workInProgress, instance) {
  6357. instance.props = workInProgress.memoizedProps;
  6358. instance.state = workInProgress.memoizedState;
  6359. }
  6360. function adoptClassInstance(workInProgress, instance) {
  6361. instance.updater = updater;
  6362. workInProgress.stateNode = instance;
  6363. // The instance needs access to the fiber so that it can schedule updates
  6364. set(instance, workInProgress);
  6365. {
  6366. instance._reactInternalInstance = fakeInternalInstance;
  6367. }
  6368. }
  6369. function constructClassInstance(workInProgress, props) {
  6370. var ctor = workInProgress.type;
  6371. var unmaskedContext = getUnmaskedContext(workInProgress);
  6372. var needsContext = isContextConsumer(workInProgress);
  6373. var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject_1;
  6374. // Instantiate twice to help detect side-effects.
  6375. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  6376. new ctor(props, context); // eslint-disable-line no-new
  6377. }
  6378. var instance = new ctor(props, context);
  6379. var state = instance.state !== null && instance.state !== undefined ? instance.state : null;
  6380. adoptClassInstance(workInProgress, instance);
  6381. {
  6382. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  6383. var componentName = getComponentName(workInProgress) || 'Component';
  6384. if (!didWarnAboutUninitializedState.has(componentName)) {
  6385. didWarnAboutUninitializedState.add(componentName);
  6386. warning_1(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, instance.state === null ? 'null' : 'undefined');
  6387. }
  6388. }
  6389. // If new component APIs are defined, "unsafe" lifecycles won't be called.
  6390. // Warn about these lifecycles if they are present.
  6391. // Don't warn about react-lifecycles-compat polyfilled methods though.
  6392. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  6393. var foundWillMountName = null;
  6394. var foundWillReceivePropsName = null;
  6395. var foundWillUpdateName = null;
  6396. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  6397. foundWillMountName = 'componentWillMount';
  6398. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  6399. foundWillMountName = 'UNSAFE_componentWillMount';
  6400. }
  6401. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  6402. foundWillReceivePropsName = 'componentWillReceiveProps';
  6403. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  6404. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  6405. }
  6406. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  6407. foundWillUpdateName = 'componentWillUpdate';
  6408. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  6409. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  6410. }
  6411. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  6412. var _componentName = getComponentName(workInProgress) || 'Component';
  6413. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  6414. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  6415. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  6416. warning_1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
  6417. }
  6418. }
  6419. }
  6420. }
  6421. workInProgress.memoizedState = state;
  6422. var partialState = callGetDerivedStateFromProps(workInProgress, instance, props, state);
  6423. if (partialState !== null && partialState !== undefined) {
  6424. // Render-phase updates (like this) should not be added to the update queue,
  6425. // So that multiple render passes do not enqueue multiple updates.
  6426. // Instead, just synchronously merge the returned state into the instance.
  6427. workInProgress.memoizedState = _assign({}, workInProgress.memoizedState, partialState);
  6428. }
  6429. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  6430. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  6431. if (needsContext) {
  6432. cacheContext(workInProgress, unmaskedContext, context);
  6433. }
  6434. return instance;
  6435. }
  6436. function callComponentWillMount(workInProgress, instance) {
  6437. startPhaseTimer(workInProgress, 'componentWillMount');
  6438. var oldState = instance.state;
  6439. if (typeof instance.componentWillMount === 'function') {
  6440. instance.componentWillMount();
  6441. }
  6442. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  6443. instance.UNSAFE_componentWillMount();
  6444. }
  6445. stopPhaseTimer();
  6446. if (oldState !== instance.state) {
  6447. {
  6448. warning_1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress) || 'Component');
  6449. }
  6450. updater.enqueueReplaceState(instance, instance.state, null);
  6451. }
  6452. }
  6453. function callComponentWillReceiveProps(workInProgress, instance, newProps, newContext) {
  6454. var oldState = instance.state;
  6455. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  6456. if (typeof instance.componentWillReceiveProps === 'function') {
  6457. instance.componentWillReceiveProps(newProps, newContext);
  6458. }
  6459. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  6460. instance.UNSAFE_componentWillReceiveProps(newProps, newContext);
  6461. }
  6462. stopPhaseTimer();
  6463. if (instance.state !== oldState) {
  6464. {
  6465. var componentName = getComponentName(workInProgress) || 'Component';
  6466. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  6467. didWarnAboutStateAssignmentForComponent.add(componentName);
  6468. warning_1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  6469. }
  6470. }
  6471. updater.enqueueReplaceState(instance, instance.state, null);
  6472. }
  6473. }
  6474. function callGetDerivedStateFromProps(workInProgress, instance, nextProps, prevState) {
  6475. var type = workInProgress.type;
  6476. if (typeof type.getDerivedStateFromProps === 'function') {
  6477. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  6478. // Invoke method an extra time to help detect side-effects.
  6479. type.getDerivedStateFromProps.call(null, nextProps, prevState);
  6480. }
  6481. var partialState = type.getDerivedStateFromProps.call(null, nextProps, prevState);
  6482. {
  6483. if (partialState === undefined) {
  6484. var componentName = getComponentName(workInProgress) || 'Component';
  6485. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  6486. didWarnAboutUndefinedDerivedState.add(componentName);
  6487. warning_1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  6488. }
  6489. }
  6490. }
  6491. return partialState;
  6492. }
  6493. }
  6494. // Invokes the mount life-cycles on a previously never rendered instance.
  6495. function mountClassInstance(workInProgress, renderExpirationTime) {
  6496. var ctor = workInProgress.type;
  6497. var current = workInProgress.alternate;
  6498. {
  6499. checkClassInstance(workInProgress);
  6500. }
  6501. var instance = workInProgress.stateNode;
  6502. var props = workInProgress.pendingProps;
  6503. var unmaskedContext = getUnmaskedContext(workInProgress);
  6504. instance.props = props;
  6505. instance.state = workInProgress.memoizedState;
  6506. instance.refs = emptyObject_1;
  6507. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  6508. {
  6509. if (workInProgress.mode & StrictMode) {
  6510. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  6511. }
  6512. if (warnAboutDeprecatedLifecycles) {
  6513. ReactStrictModeWarnings.recordDeprecationWarnings(workInProgress, instance);
  6514. }
  6515. }
  6516. // In order to support react-lifecycles-compat polyfilled components,
  6517. // Unsafe lifecycles should not be invoked for components using the new APIs.
  6518. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  6519. callComponentWillMount(workInProgress, instance);
  6520. // If we had additional state updates during this life-cycle, let's
  6521. // process them now.
  6522. var updateQueue = workInProgress.updateQueue;
  6523. if (updateQueue !== null) {
  6524. instance.state = processUpdateQueue(current, workInProgress, updateQueue, instance, props, renderExpirationTime);
  6525. }
  6526. }
  6527. if (typeof instance.componentDidMount === 'function') {
  6528. workInProgress.effectTag |= Update;
  6529. }
  6530. }
  6531. function resumeMountClassInstance(workInProgress, renderExpirationTime) {
  6532. var ctor = workInProgress.type;
  6533. var instance = workInProgress.stateNode;
  6534. resetInputPointers(workInProgress, instance);
  6535. var oldProps = workInProgress.memoizedProps;
  6536. var newProps = workInProgress.pendingProps;
  6537. var oldContext = instance.context;
  6538. var newUnmaskedContext = getUnmaskedContext(workInProgress);
  6539. var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
  6540. var hasNewLifecycles = typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  6541. // Note: During these life-cycles, instance.props/instance.state are what
  6542. // ever the previously attempted to render - not the "current". However,
  6543. // during componentDidUpdate we pass the "current" props.
  6544. // In order to support react-lifecycles-compat polyfilled components,
  6545. // Unsafe lifecycles should not be invoked for components using the new APIs.
  6546. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  6547. if (oldProps !== newProps || oldContext !== newContext) {
  6548. callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
  6549. }
  6550. }
  6551. // Compute the next state using the memoized state and the update queue.
  6552. var oldState = workInProgress.memoizedState;
  6553. // TODO: Previous state can be null.
  6554. var newState = void 0;
  6555. var derivedStateFromCatch = void 0;
  6556. if (workInProgress.updateQueue !== null) {
  6557. newState = processUpdateQueue(null, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
  6558. var updateQueue = workInProgress.updateQueue;
  6559. if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
  6560. var capturedValues = updateQueue.capturedValues;
  6561. // Don't remove these from the update queue yet. We need them in
  6562. // finishClassComponent. Do the reset there.
  6563. // TODO: This is awkward. Refactor class components.
  6564. // updateQueue.capturedValues = null;
  6565. derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
  6566. }
  6567. } else {
  6568. newState = oldState;
  6569. }
  6570. var derivedStateFromProps = void 0;
  6571. if (oldProps !== newProps) {
  6572. // The prevState parameter should be the partially updated state.
  6573. // Otherwise, spreading state in return values could override updates.
  6574. derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
  6575. }
  6576. if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
  6577. // Render-phase updates (like this) should not be added to the update queue,
  6578. // So that multiple render passes do not enqueue multiple updates.
  6579. // Instead, just synchronously merge the returned state into the instance.
  6580. newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
  6581. // Update the base state of the update queue.
  6582. // FIXME: This is getting ridiculous. Refactor plz!
  6583. var _updateQueue = workInProgress.updateQueue;
  6584. if (_updateQueue !== null) {
  6585. _updateQueue.baseState = _assign({}, _updateQueue.baseState, derivedStateFromProps);
  6586. }
  6587. }
  6588. if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
  6589. // Render-phase updates (like this) should not be added to the update queue,
  6590. // So that multiple render passes do not enqueue multiple updates.
  6591. // Instead, just synchronously merge the returned state into the instance.
  6592. newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign({}, newState, derivedStateFromCatch);
  6593. // Update the base state of the update queue.
  6594. // FIXME: This is getting ridiculous. Refactor plz!
  6595. var _updateQueue2 = workInProgress.updateQueue;
  6596. if (_updateQueue2 !== null) {
  6597. _updateQueue2.baseState = _assign({}, _updateQueue2.baseState, derivedStateFromCatch);
  6598. }
  6599. }
  6600. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) {
  6601. // If an update was already in progress, we should schedule an Update
  6602. // effect even though we're bailing out, so that cWU/cDU are called.
  6603. if (typeof instance.componentDidMount === 'function') {
  6604. workInProgress.effectTag |= Update;
  6605. }
  6606. return false;
  6607. }
  6608. var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
  6609. if (shouldUpdate) {
  6610. // In order to support react-lifecycles-compat polyfilled components,
  6611. // Unsafe lifecycles should not be invoked for components using the new APIs.
  6612. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  6613. startPhaseTimer(workInProgress, 'componentWillMount');
  6614. if (typeof instance.componentWillMount === 'function') {
  6615. instance.componentWillMount();
  6616. }
  6617. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  6618. instance.UNSAFE_componentWillMount();
  6619. }
  6620. stopPhaseTimer();
  6621. }
  6622. if (typeof instance.componentDidMount === 'function') {
  6623. workInProgress.effectTag |= Update;
  6624. }
  6625. } else {
  6626. // If an update was already in progress, we should schedule an Update
  6627. // effect even though we're bailing out, so that cWU/cDU are called.
  6628. if (typeof instance.componentDidMount === 'function') {
  6629. workInProgress.effectTag |= Update;
  6630. }
  6631. // If shouldComponentUpdate returned false, we should still update the
  6632. // memoized props/state to indicate that this work can be reused.
  6633. memoizeProps(workInProgress, newProps);
  6634. memoizeState(workInProgress, newState);
  6635. }
  6636. // Update the existing instance's state, props, and context pointers even
  6637. // if shouldComponentUpdate returns false.
  6638. instance.props = newProps;
  6639. instance.state = newState;
  6640. instance.context = newContext;
  6641. return shouldUpdate;
  6642. }
  6643. // Invokes the update life-cycles and returns false if it shouldn't rerender.
  6644. function updateClassInstance(current, workInProgress, renderExpirationTime) {
  6645. var ctor = workInProgress.type;
  6646. var instance = workInProgress.stateNode;
  6647. resetInputPointers(workInProgress, instance);
  6648. var oldProps = workInProgress.memoizedProps;
  6649. var newProps = workInProgress.pendingProps;
  6650. var oldContext = instance.context;
  6651. var newUnmaskedContext = getUnmaskedContext(workInProgress);
  6652. var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
  6653. var hasNewLifecycles = typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  6654. // Note: During these life-cycles, instance.props/instance.state are what
  6655. // ever the previously attempted to render - not the "current". However,
  6656. // during componentDidUpdate we pass the "current" props.
  6657. // In order to support react-lifecycles-compat polyfilled components,
  6658. // Unsafe lifecycles should not be invoked for components using the new APIs.
  6659. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  6660. if (oldProps !== newProps || oldContext !== newContext) {
  6661. callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
  6662. }
  6663. }
  6664. // Compute the next state using the memoized state and the update queue.
  6665. var oldState = workInProgress.memoizedState;
  6666. // TODO: Previous state can be null.
  6667. var newState = void 0;
  6668. var derivedStateFromCatch = void 0;
  6669. if (workInProgress.updateQueue !== null) {
  6670. newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
  6671. var updateQueue = workInProgress.updateQueue;
  6672. if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
  6673. var capturedValues = updateQueue.capturedValues;
  6674. // Don't remove these from the update queue yet. We need them in
  6675. // finishClassComponent. Do the reset there.
  6676. // TODO: This is awkward. Refactor class components.
  6677. // updateQueue.capturedValues = null;
  6678. derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
  6679. }
  6680. } else {
  6681. newState = oldState;
  6682. }
  6683. var derivedStateFromProps = void 0;
  6684. if (oldProps !== newProps) {
  6685. // The prevState parameter should be the partially updated state.
  6686. // Otherwise, spreading state in return values could override updates.
  6687. derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
  6688. }
  6689. if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
  6690. // Render-phase updates (like this) should not be added to the update queue,
  6691. // So that multiple render passes do not enqueue multiple updates.
  6692. // Instead, just synchronously merge the returned state into the instance.
  6693. newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
  6694. // Update the base state of the update queue.
  6695. // FIXME: This is getting ridiculous. Refactor plz!
  6696. var _updateQueue3 = workInProgress.updateQueue;
  6697. if (_updateQueue3 !== null) {
  6698. _updateQueue3.baseState = _assign({}, _updateQueue3.baseState, derivedStateFromProps);
  6699. }
  6700. }
  6701. if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
  6702. // Render-phase updates (like this) should not be added to the update queue,
  6703. // So that multiple render passes do not enqueue multiple updates.
  6704. // Instead, just synchronously merge the returned state into the instance.
  6705. newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign({}, newState, derivedStateFromCatch);
  6706. // Update the base state of the update queue.
  6707. // FIXME: This is getting ridiculous. Refactor plz!
  6708. var _updateQueue4 = workInProgress.updateQueue;
  6709. if (_updateQueue4 !== null) {
  6710. _updateQueue4.baseState = _assign({}, _updateQueue4.baseState, derivedStateFromCatch);
  6711. }
  6712. }
  6713. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) {
  6714. // If an update was already in progress, we should schedule an Update
  6715. // effect even though we're bailing out, so that cWU/cDU are called.
  6716. if (typeof instance.componentDidUpdate === 'function') {
  6717. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  6718. workInProgress.effectTag |= Update;
  6719. }
  6720. }
  6721. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  6722. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  6723. workInProgress.effectTag |= Snapshot;
  6724. }
  6725. }
  6726. return false;
  6727. }
  6728. var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
  6729. if (shouldUpdate) {
  6730. // In order to support react-lifecycles-compat polyfilled components,
  6731. // Unsafe lifecycles should not be invoked for components using the new APIs.
  6732. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  6733. startPhaseTimer(workInProgress, 'componentWillUpdate');
  6734. if (typeof instance.componentWillUpdate === 'function') {
  6735. instance.componentWillUpdate(newProps, newState, newContext);
  6736. }
  6737. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  6738. instance.UNSAFE_componentWillUpdate(newProps, newState, newContext);
  6739. }
  6740. stopPhaseTimer();
  6741. }
  6742. if (typeof instance.componentDidUpdate === 'function') {
  6743. workInProgress.effectTag |= Update;
  6744. }
  6745. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  6746. workInProgress.effectTag |= Snapshot;
  6747. }
  6748. } else {
  6749. // If an update was already in progress, we should schedule an Update
  6750. // effect even though we're bailing out, so that cWU/cDU are called.
  6751. if (typeof instance.componentDidUpdate === 'function') {
  6752. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  6753. workInProgress.effectTag |= Update;
  6754. }
  6755. }
  6756. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  6757. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  6758. workInProgress.effectTag |= Snapshot;
  6759. }
  6760. }
  6761. // If shouldComponentUpdate returned false, we should still update the
  6762. // memoized props/state to indicate that this work can be reused.
  6763. memoizeProps(workInProgress, newProps);
  6764. memoizeState(workInProgress, newState);
  6765. }
  6766. // Update the existing instance's state, props, and context pointers even
  6767. // if shouldComponentUpdate returns false.
  6768. instance.props = newProps;
  6769. instance.state = newState;
  6770. instance.context = newContext;
  6771. return shouldUpdate;
  6772. }
  6773. return {
  6774. adoptClassInstance: adoptClassInstance,
  6775. callGetDerivedStateFromProps: callGetDerivedStateFromProps,
  6776. constructClassInstance: constructClassInstance,
  6777. mountClassInstance: mountClassInstance,
  6778. resumeMountClassInstance: resumeMountClassInstance,
  6779. updateClassInstance: updateClassInstance
  6780. };
  6781. };
  6782. var getCurrentFiberStackAddendum$2 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  6783. var didWarnAboutMaps = void 0;
  6784. var didWarnAboutStringRefInStrictMode = void 0;
  6785. var ownerHasKeyUseWarning = void 0;
  6786. var ownerHasFunctionTypeWarning = void 0;
  6787. var warnForMissingKey = function (child) {};
  6788. {
  6789. didWarnAboutMaps = false;
  6790. didWarnAboutStringRefInStrictMode = {};
  6791. /**
  6792. * Warn if there's no key explicitly set on dynamic arrays of children or
  6793. * object keys are not valid. This allows us to keep track of children between
  6794. * updates.
  6795. */
  6796. ownerHasKeyUseWarning = {};
  6797. ownerHasFunctionTypeWarning = {};
  6798. warnForMissingKey = function (child) {
  6799. if (child === null || typeof child !== 'object') {
  6800. return;
  6801. }
  6802. if (!child._store || child._store.validated || child.key != null) {
  6803. return;
  6804. }
  6805. !(typeof child._store === 'object') ? invariant_1(false, 'React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  6806. child._store.validated = true;
  6807. var currentComponentErrorInfo = 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + (getCurrentFiberStackAddendum$2() || '');
  6808. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  6809. return;
  6810. }
  6811. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  6812. warning_1(false, 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.%s', getCurrentFiberStackAddendum$2());
  6813. };
  6814. }
  6815. var isArray$1 = Array.isArray;
  6816. function coerceRef(returnFiber, current, element) {
  6817. var mixedRef = element.ref;
  6818. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  6819. {
  6820. if (returnFiber.mode & StrictMode) {
  6821. var componentName = getComponentName(returnFiber) || 'Component';
  6822. if (!didWarnAboutStringRefInStrictMode[componentName]) {
  6823. warning_1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackAddendumByWorkInProgressFiber(returnFiber));
  6824. didWarnAboutStringRefInStrictMode[componentName] = true;
  6825. }
  6826. }
  6827. }
  6828. if (element._owner) {
  6829. var owner = element._owner;
  6830. var inst = void 0;
  6831. if (owner) {
  6832. var ownerFiber = owner;
  6833. !(ownerFiber.tag === ClassComponent) ? invariant_1(false, 'Stateless function components cannot have refs.') : void 0;
  6834. inst = ownerFiber.stateNode;
  6835. }
  6836. !inst ? invariant_1(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0;
  6837. var stringRef = '' + mixedRef;
  6838. // Check if previous string ref matches new string ref
  6839. if (current !== null && current.ref !== null && current.ref._stringRef === stringRef) {
  6840. return current.ref;
  6841. }
  6842. var ref = function (value) {
  6843. var refs = inst.refs === emptyObject_1 ? inst.refs = {} : inst.refs;
  6844. if (value === null) {
  6845. delete refs[stringRef];
  6846. } else {
  6847. refs[stringRef] = value;
  6848. }
  6849. };
  6850. ref._stringRef = stringRef;
  6851. return ref;
  6852. } else {
  6853. !(typeof mixedRef === 'string') ? invariant_1(false, 'Expected ref to be a function or a string.') : void 0;
  6854. !element._owner ? invariant_1(false, 'Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.', mixedRef) : void 0;
  6855. }
  6856. }
  6857. return mixedRef;
  6858. }
  6859. function throwOnInvalidObjectType(returnFiber, newChild) {
  6860. if (returnFiber.type !== 'textarea') {
  6861. var addendum = '';
  6862. {
  6863. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + (getCurrentFiberStackAddendum$2() || '');
  6864. }
  6865. invariant_1(false, 'Objects are not valid as a React child (found: %s).%s', Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild, addendum);
  6866. }
  6867. }
  6868. function warnOnFunctionType() {
  6869. var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + (getCurrentFiberStackAddendum$2() || '');
  6870. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  6871. return;
  6872. }
  6873. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  6874. warning_1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.%s', getCurrentFiberStackAddendum$2() || '');
  6875. }
  6876. // This wrapper function exists because I expect to clone the code in each path
  6877. // to be able to optimize each path individually by branching early. This needs
  6878. // a compiler or we can do it manually. Helpers that don't need this branching
  6879. // live outside of this function.
  6880. function ChildReconciler(shouldTrackSideEffects) {
  6881. function deleteChild(returnFiber, childToDelete) {
  6882. if (!shouldTrackSideEffects) {
  6883. // Noop.
  6884. return;
  6885. }
  6886. // Deletions are added in reversed order so we add it to the front.
  6887. // At this point, the return fiber's effect list is empty except for
  6888. // deletions, so we can just append the deletion to the list. The remaining
  6889. // effects aren't added until the complete phase. Once we implement
  6890. // resuming, this may not be true.
  6891. var last = returnFiber.lastEffect;
  6892. if (last !== null) {
  6893. last.nextEffect = childToDelete;
  6894. returnFiber.lastEffect = childToDelete;
  6895. } else {
  6896. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  6897. }
  6898. childToDelete.nextEffect = null;
  6899. childToDelete.effectTag = Deletion;
  6900. }
  6901. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  6902. if (!shouldTrackSideEffects) {
  6903. // Noop.
  6904. return null;
  6905. }
  6906. // TODO: For the shouldClone case, this could be micro-optimized a bit by
  6907. // assuming that after the first child we've already added everything.
  6908. var childToDelete = currentFirstChild;
  6909. while (childToDelete !== null) {
  6910. deleteChild(returnFiber, childToDelete);
  6911. childToDelete = childToDelete.sibling;
  6912. }
  6913. return null;
  6914. }
  6915. function mapRemainingChildren(returnFiber, currentFirstChild) {
  6916. // Add the remaining children to a temporary map so that we can find them by
  6917. // keys quickly. Implicit (null) keys get added to this set with their index
  6918. var existingChildren = new Map();
  6919. var existingChild = currentFirstChild;
  6920. while (existingChild !== null) {
  6921. if (existingChild.key !== null) {
  6922. existingChildren.set(existingChild.key, existingChild);
  6923. } else {
  6924. existingChildren.set(existingChild.index, existingChild);
  6925. }
  6926. existingChild = existingChild.sibling;
  6927. }
  6928. return existingChildren;
  6929. }
  6930. function useFiber(fiber, pendingProps, expirationTime) {
  6931. // We currently set sibling to null and index to 0 here because it is easy
  6932. // to forget to do before returning it. E.g. for the single child case.
  6933. var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
  6934. clone.index = 0;
  6935. clone.sibling = null;
  6936. return clone;
  6937. }
  6938. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  6939. newFiber.index = newIndex;
  6940. if (!shouldTrackSideEffects) {
  6941. // Noop.
  6942. return lastPlacedIndex;
  6943. }
  6944. var current = newFiber.alternate;
  6945. if (current !== null) {
  6946. var oldIndex = current.index;
  6947. if (oldIndex < lastPlacedIndex) {
  6948. // This is a move.
  6949. newFiber.effectTag = Placement;
  6950. return lastPlacedIndex;
  6951. } else {
  6952. // This item can stay in place.
  6953. return oldIndex;
  6954. }
  6955. } else {
  6956. // This is an insertion.
  6957. newFiber.effectTag = Placement;
  6958. return lastPlacedIndex;
  6959. }
  6960. }
  6961. function placeSingleChild(newFiber) {
  6962. // This is simpler for the single child case. We only need to do a
  6963. // placement for inserting new children.
  6964. if (shouldTrackSideEffects && newFiber.alternate === null) {
  6965. newFiber.effectTag = Placement;
  6966. }
  6967. return newFiber;
  6968. }
  6969. function updateTextNode(returnFiber, current, textContent, expirationTime) {
  6970. if (current === null || current.tag !== HostText) {
  6971. // Insert
  6972. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  6973. created['return'] = returnFiber;
  6974. return created;
  6975. } else {
  6976. // Update
  6977. var existing = useFiber(current, textContent, expirationTime);
  6978. existing['return'] = returnFiber;
  6979. return existing;
  6980. }
  6981. }
  6982. function updateElement(returnFiber, current, element, expirationTime) {
  6983. if (current !== null && current.type === element.type) {
  6984. // Move based on index
  6985. var existing = useFiber(current, element.props, expirationTime);
  6986. existing.ref = coerceRef(returnFiber, current, element);
  6987. existing['return'] = returnFiber;
  6988. {
  6989. existing._debugSource = element._source;
  6990. existing._debugOwner = element._owner;
  6991. }
  6992. return existing;
  6993. } else {
  6994. // Insert
  6995. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  6996. created.ref = coerceRef(returnFiber, current, element);
  6997. created['return'] = returnFiber;
  6998. return created;
  6999. }
  7000. }
  7001. function updatePortal(returnFiber, current, portal, expirationTime) {
  7002. if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
  7003. // Insert
  7004. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  7005. created['return'] = returnFiber;
  7006. return created;
  7007. } else {
  7008. // Update
  7009. var existing = useFiber(current, portal.children || [], expirationTime);
  7010. existing['return'] = returnFiber;
  7011. return existing;
  7012. }
  7013. }
  7014. function updateFragment(returnFiber, current, fragment, expirationTime, key) {
  7015. if (current === null || current.tag !== Fragment) {
  7016. // Insert
  7017. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  7018. created['return'] = returnFiber;
  7019. return created;
  7020. } else {
  7021. // Update
  7022. var existing = useFiber(current, fragment, expirationTime);
  7023. existing['return'] = returnFiber;
  7024. return existing;
  7025. }
  7026. }
  7027. function createChild(returnFiber, newChild, expirationTime) {
  7028. if (typeof newChild === 'string' || typeof newChild === 'number') {
  7029. // Text nodes don't have keys. If the previous node is implicitly keyed
  7030. // we can continue to replace it without aborting even if it is not a text
  7031. // node.
  7032. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  7033. created['return'] = returnFiber;
  7034. return created;
  7035. }
  7036. if (typeof newChild === 'object' && newChild !== null) {
  7037. switch (newChild.$$typeof) {
  7038. case REACT_ELEMENT_TYPE:
  7039. {
  7040. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  7041. _created.ref = coerceRef(returnFiber, null, newChild);
  7042. _created['return'] = returnFiber;
  7043. return _created;
  7044. }
  7045. case REACT_PORTAL_TYPE:
  7046. {
  7047. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  7048. _created2['return'] = returnFiber;
  7049. return _created2;
  7050. }
  7051. }
  7052. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  7053. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  7054. _created3['return'] = returnFiber;
  7055. return _created3;
  7056. }
  7057. throwOnInvalidObjectType(returnFiber, newChild);
  7058. }
  7059. {
  7060. if (typeof newChild === 'function') {
  7061. warnOnFunctionType();
  7062. }
  7063. }
  7064. return null;
  7065. }
  7066. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  7067. // Update the fiber if the keys match, otherwise return null.
  7068. var key = oldFiber !== null ? oldFiber.key : null;
  7069. if (typeof newChild === 'string' || typeof newChild === 'number') {
  7070. // Text nodes don't have keys. If the previous node is implicitly keyed
  7071. // we can continue to replace it without aborting even if it is not a text
  7072. // node.
  7073. if (key !== null) {
  7074. return null;
  7075. }
  7076. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  7077. }
  7078. if (typeof newChild === 'object' && newChild !== null) {
  7079. switch (newChild.$$typeof) {
  7080. case REACT_ELEMENT_TYPE:
  7081. {
  7082. if (newChild.key === key) {
  7083. if (newChild.type === REACT_FRAGMENT_TYPE) {
  7084. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  7085. }
  7086. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  7087. } else {
  7088. return null;
  7089. }
  7090. }
  7091. case REACT_PORTAL_TYPE:
  7092. {
  7093. if (newChild.key === key) {
  7094. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  7095. } else {
  7096. return null;
  7097. }
  7098. }
  7099. }
  7100. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  7101. if (key !== null) {
  7102. return null;
  7103. }
  7104. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  7105. }
  7106. throwOnInvalidObjectType(returnFiber, newChild);
  7107. }
  7108. {
  7109. if (typeof newChild === 'function') {
  7110. warnOnFunctionType();
  7111. }
  7112. }
  7113. return null;
  7114. }
  7115. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  7116. if (typeof newChild === 'string' || typeof newChild === 'number') {
  7117. // Text nodes don't have keys, so we neither have to check the old nor
  7118. // new node for the key. If both are text nodes, they match.
  7119. var matchedFiber = existingChildren.get(newIdx) || null;
  7120. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  7121. }
  7122. if (typeof newChild === 'object' && newChild !== null) {
  7123. switch (newChild.$$typeof) {
  7124. case REACT_ELEMENT_TYPE:
  7125. {
  7126. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  7127. if (newChild.type === REACT_FRAGMENT_TYPE) {
  7128. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  7129. }
  7130. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  7131. }
  7132. case REACT_PORTAL_TYPE:
  7133. {
  7134. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  7135. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  7136. }
  7137. }
  7138. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  7139. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  7140. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  7141. }
  7142. throwOnInvalidObjectType(returnFiber, newChild);
  7143. }
  7144. {
  7145. if (typeof newChild === 'function') {
  7146. warnOnFunctionType();
  7147. }
  7148. }
  7149. return null;
  7150. }
  7151. /**
  7152. * Warns if there is a duplicate or missing key
  7153. */
  7154. function warnOnInvalidKey(child, knownKeys) {
  7155. {
  7156. if (typeof child !== 'object' || child === null) {
  7157. return knownKeys;
  7158. }
  7159. switch (child.$$typeof) {
  7160. case REACT_ELEMENT_TYPE:
  7161. case REACT_PORTAL_TYPE:
  7162. warnForMissingKey(child);
  7163. var key = child.key;
  7164. if (typeof key !== 'string') {
  7165. break;
  7166. }
  7167. if (knownKeys === null) {
  7168. knownKeys = new Set();
  7169. knownKeys.add(key);
  7170. break;
  7171. }
  7172. if (!knownKeys.has(key)) {
  7173. knownKeys.add(key);
  7174. break;
  7175. }
  7176. warning_1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());
  7177. break;
  7178. default:
  7179. break;
  7180. }
  7181. }
  7182. return knownKeys;
  7183. }
  7184. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  7185. // This algorithm can't optimize by searching from boths ends since we
  7186. // don't have backpointers on fibers. I'm trying to see how far we can get
  7187. // with that model. If it ends up not being worth the tradeoffs, we can
  7188. // add it later.
  7189. // Even with a two ended optimization, we'd want to optimize for the case
  7190. // where there are few changes and brute force the comparison instead of
  7191. // going for the Map. It'd like to explore hitting that path first in
  7192. // forward-only mode and only go for the Map once we notice that we need
  7193. // lots of look ahead. This doesn't handle reversal as well as two ended
  7194. // search but that's unusual. Besides, for the two ended optimization to
  7195. // work on Iterables, we'd need to copy the whole set.
  7196. // In this first iteration, we'll just live with hitting the bad case
  7197. // (adding everything to a Map) in for every insert/move.
  7198. // If you change this code, also update reconcileChildrenIterator() which
  7199. // uses the same algorithm.
  7200. {
  7201. // First, validate keys.
  7202. var knownKeys = null;
  7203. for (var i = 0; i < newChildren.length; i++) {
  7204. var child = newChildren[i];
  7205. knownKeys = warnOnInvalidKey(child, knownKeys);
  7206. }
  7207. }
  7208. var resultingFirstChild = null;
  7209. var previousNewFiber = null;
  7210. var oldFiber = currentFirstChild;
  7211. var lastPlacedIndex = 0;
  7212. var newIdx = 0;
  7213. var nextOldFiber = null;
  7214. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  7215. if (oldFiber.index > newIdx) {
  7216. nextOldFiber = oldFiber;
  7217. oldFiber = null;
  7218. } else {
  7219. nextOldFiber = oldFiber.sibling;
  7220. }
  7221. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  7222. if (newFiber === null) {
  7223. // TODO: This breaks on empty slots like null children. That's
  7224. // unfortunate because it triggers the slow path all the time. We need
  7225. // a better way to communicate whether this was a miss or null,
  7226. // boolean, undefined, etc.
  7227. if (oldFiber === null) {
  7228. oldFiber = nextOldFiber;
  7229. }
  7230. break;
  7231. }
  7232. if (shouldTrackSideEffects) {
  7233. if (oldFiber && newFiber.alternate === null) {
  7234. // We matched the slot, but we didn't reuse the existing fiber, so we
  7235. // need to delete the existing child.
  7236. deleteChild(returnFiber, oldFiber);
  7237. }
  7238. }
  7239. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  7240. if (previousNewFiber === null) {
  7241. // TODO: Move out of the loop. This only happens for the first run.
  7242. resultingFirstChild = newFiber;
  7243. } else {
  7244. // TODO: Defer siblings if we're not at the right index for this slot.
  7245. // I.e. if we had null values before, then we want to defer this
  7246. // for each null value. However, we also don't want to call updateSlot
  7247. // with the previous one.
  7248. previousNewFiber.sibling = newFiber;
  7249. }
  7250. previousNewFiber = newFiber;
  7251. oldFiber = nextOldFiber;
  7252. }
  7253. if (newIdx === newChildren.length) {
  7254. // We've reached the end of the new children. We can delete the rest.
  7255. deleteRemainingChildren(returnFiber, oldFiber);
  7256. return resultingFirstChild;
  7257. }
  7258. if (oldFiber === null) {
  7259. // If we don't have any more existing children we can choose a fast path
  7260. // since the rest will all be insertions.
  7261. for (; newIdx < newChildren.length; newIdx++) {
  7262. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  7263. if (!_newFiber) {
  7264. continue;
  7265. }
  7266. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  7267. if (previousNewFiber === null) {
  7268. // TODO: Move out of the loop. This only happens for the first run.
  7269. resultingFirstChild = _newFiber;
  7270. } else {
  7271. previousNewFiber.sibling = _newFiber;
  7272. }
  7273. previousNewFiber = _newFiber;
  7274. }
  7275. return resultingFirstChild;
  7276. }
  7277. // Add all children to a key map for quick lookups.
  7278. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  7279. // Keep scanning and use the map to restore deleted items as moves.
  7280. for (; newIdx < newChildren.length; newIdx++) {
  7281. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  7282. if (_newFiber2) {
  7283. if (shouldTrackSideEffects) {
  7284. if (_newFiber2.alternate !== null) {
  7285. // The new fiber is a work in progress, but if there exists a
  7286. // current, that means that we reused the fiber. We need to delete
  7287. // it from the child list so that we don't add it to the deletion
  7288. // list.
  7289. existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);
  7290. }
  7291. }
  7292. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  7293. if (previousNewFiber === null) {
  7294. resultingFirstChild = _newFiber2;
  7295. } else {
  7296. previousNewFiber.sibling = _newFiber2;
  7297. }
  7298. previousNewFiber = _newFiber2;
  7299. }
  7300. }
  7301. if (shouldTrackSideEffects) {
  7302. // Any existing children that weren't consumed above were deleted. We need
  7303. // to add them to the deletion list.
  7304. existingChildren.forEach(function (child) {
  7305. return deleteChild(returnFiber, child);
  7306. });
  7307. }
  7308. return resultingFirstChild;
  7309. }
  7310. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  7311. // This is the same implementation as reconcileChildrenArray(),
  7312. // but using the iterator instead.
  7313. var iteratorFn = getIteratorFn(newChildrenIterable);
  7314. !(typeof iteratorFn === 'function') ? invariant_1(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  7315. {
  7316. // Warn about using Maps as children
  7317. if (typeof newChildrenIterable.entries === 'function') {
  7318. var possibleMap = newChildrenIterable;
  7319. if (possibleMap.entries === iteratorFn) {
  7320. !didWarnAboutMaps ? warning_1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;
  7321. didWarnAboutMaps = true;
  7322. }
  7323. }
  7324. // First, validate keys.
  7325. // We'll get a different iterator later for the main pass.
  7326. var _newChildren = iteratorFn.call(newChildrenIterable);
  7327. if (_newChildren) {
  7328. var knownKeys = null;
  7329. var _step = _newChildren.next();
  7330. for (; !_step.done; _step = _newChildren.next()) {
  7331. var child = _step.value;
  7332. knownKeys = warnOnInvalidKey(child, knownKeys);
  7333. }
  7334. }
  7335. }
  7336. var newChildren = iteratorFn.call(newChildrenIterable);
  7337. !(newChildren != null) ? invariant_1(false, 'An iterable object provided no iterator.') : void 0;
  7338. var resultingFirstChild = null;
  7339. var previousNewFiber = null;
  7340. var oldFiber = currentFirstChild;
  7341. var lastPlacedIndex = 0;
  7342. var newIdx = 0;
  7343. var nextOldFiber = null;
  7344. var step = newChildren.next();
  7345. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  7346. if (oldFiber.index > newIdx) {
  7347. nextOldFiber = oldFiber;
  7348. oldFiber = null;
  7349. } else {
  7350. nextOldFiber = oldFiber.sibling;
  7351. }
  7352. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  7353. if (newFiber === null) {
  7354. // TODO: This breaks on empty slots like null children. That's
  7355. // unfortunate because it triggers the slow path all the time. We need
  7356. // a better way to communicate whether this was a miss or null,
  7357. // boolean, undefined, etc.
  7358. if (!oldFiber) {
  7359. oldFiber = nextOldFiber;
  7360. }
  7361. break;
  7362. }
  7363. if (shouldTrackSideEffects) {
  7364. if (oldFiber && newFiber.alternate === null) {
  7365. // We matched the slot, but we didn't reuse the existing fiber, so we
  7366. // need to delete the existing child.
  7367. deleteChild(returnFiber, oldFiber);
  7368. }
  7369. }
  7370. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  7371. if (previousNewFiber === null) {
  7372. // TODO: Move out of the loop. This only happens for the first run.
  7373. resultingFirstChild = newFiber;
  7374. } else {
  7375. // TODO: Defer siblings if we're not at the right index for this slot.
  7376. // I.e. if we had null values before, then we want to defer this
  7377. // for each null value. However, we also don't want to call updateSlot
  7378. // with the previous one.
  7379. previousNewFiber.sibling = newFiber;
  7380. }
  7381. previousNewFiber = newFiber;
  7382. oldFiber = nextOldFiber;
  7383. }
  7384. if (step.done) {
  7385. // We've reached the end of the new children. We can delete the rest.
  7386. deleteRemainingChildren(returnFiber, oldFiber);
  7387. return resultingFirstChild;
  7388. }
  7389. if (oldFiber === null) {
  7390. // If we don't have any more existing children we can choose a fast path
  7391. // since the rest will all be insertions.
  7392. for (; !step.done; newIdx++, step = newChildren.next()) {
  7393. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  7394. if (_newFiber3 === null) {
  7395. continue;
  7396. }
  7397. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  7398. if (previousNewFiber === null) {
  7399. // TODO: Move out of the loop. This only happens for the first run.
  7400. resultingFirstChild = _newFiber3;
  7401. } else {
  7402. previousNewFiber.sibling = _newFiber3;
  7403. }
  7404. previousNewFiber = _newFiber3;
  7405. }
  7406. return resultingFirstChild;
  7407. }
  7408. // Add all children to a key map for quick lookups.
  7409. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  7410. // Keep scanning and use the map to restore deleted items as moves.
  7411. for (; !step.done; newIdx++, step = newChildren.next()) {
  7412. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  7413. if (_newFiber4 !== null) {
  7414. if (shouldTrackSideEffects) {
  7415. if (_newFiber4.alternate !== null) {
  7416. // The new fiber is a work in progress, but if there exists a
  7417. // current, that means that we reused the fiber. We need to delete
  7418. // it from the child list so that we don't add it to the deletion
  7419. // list.
  7420. existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);
  7421. }
  7422. }
  7423. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  7424. if (previousNewFiber === null) {
  7425. resultingFirstChild = _newFiber4;
  7426. } else {
  7427. previousNewFiber.sibling = _newFiber4;
  7428. }
  7429. previousNewFiber = _newFiber4;
  7430. }
  7431. }
  7432. if (shouldTrackSideEffects) {
  7433. // Any existing children that weren't consumed above were deleted. We need
  7434. // to add them to the deletion list.
  7435. existingChildren.forEach(function (child) {
  7436. return deleteChild(returnFiber, child);
  7437. });
  7438. }
  7439. return resultingFirstChild;
  7440. }
  7441. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  7442. // There's no need to check for keys on text nodes since we don't have a
  7443. // way to define them.
  7444. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  7445. // We already have an existing node so let's just update it and delete
  7446. // the rest.
  7447. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  7448. var existing = useFiber(currentFirstChild, textContent, expirationTime);
  7449. existing['return'] = returnFiber;
  7450. return existing;
  7451. }
  7452. // The existing first child is not a text node so we need to create one
  7453. // and delete the existing ones.
  7454. deleteRemainingChildren(returnFiber, currentFirstChild);
  7455. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  7456. created['return'] = returnFiber;
  7457. return created;
  7458. }
  7459. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  7460. var key = element.key;
  7461. var child = currentFirstChild;
  7462. while (child !== null) {
  7463. // TODO: If key === null and child.key === null, then this only applies to
  7464. // the first item in the list.
  7465. if (child.key === key) {
  7466. if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {
  7467. deleteRemainingChildren(returnFiber, child.sibling);
  7468. var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
  7469. existing.ref = coerceRef(returnFiber, child, element);
  7470. existing['return'] = returnFiber;
  7471. {
  7472. existing._debugSource = element._source;
  7473. existing._debugOwner = element._owner;
  7474. }
  7475. return existing;
  7476. } else {
  7477. deleteRemainingChildren(returnFiber, child);
  7478. break;
  7479. }
  7480. } else {
  7481. deleteChild(returnFiber, child);
  7482. }
  7483. child = child.sibling;
  7484. }
  7485. if (element.type === REACT_FRAGMENT_TYPE) {
  7486. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  7487. created['return'] = returnFiber;
  7488. return created;
  7489. } else {
  7490. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  7491. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  7492. _created4['return'] = returnFiber;
  7493. return _created4;
  7494. }
  7495. }
  7496. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  7497. var key = portal.key;
  7498. var child = currentFirstChild;
  7499. while (child !== null) {
  7500. // TODO: If key === null and child.key === null, then this only applies to
  7501. // the first item in the list.
  7502. if (child.key === key) {
  7503. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  7504. deleteRemainingChildren(returnFiber, child.sibling);
  7505. var existing = useFiber(child, portal.children || [], expirationTime);
  7506. existing['return'] = returnFiber;
  7507. return existing;
  7508. } else {
  7509. deleteRemainingChildren(returnFiber, child);
  7510. break;
  7511. }
  7512. } else {
  7513. deleteChild(returnFiber, child);
  7514. }
  7515. child = child.sibling;
  7516. }
  7517. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  7518. created['return'] = returnFiber;
  7519. return created;
  7520. }
  7521. // This API will tag the children with the side-effect of the reconciliation
  7522. // itself. They will be added to the side-effect list as we pass through the
  7523. // children and the parent.
  7524. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  7525. // This function is not recursive.
  7526. // If the top level item is an array, we treat it as a set of children,
  7527. // not as a fragment. Nested arrays on the other hand will be treated as
  7528. // fragment nodes. Recursion happens at the normal flow.
  7529. // Handle top level unkeyed fragments as if they were arrays.
  7530. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  7531. // We treat the ambiguous cases above the same.
  7532. if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
  7533. newChild = newChild.props.children;
  7534. }
  7535. // Handle object types
  7536. var isObject = typeof newChild === 'object' && newChild !== null;
  7537. if (isObject) {
  7538. switch (newChild.$$typeof) {
  7539. case REACT_ELEMENT_TYPE:
  7540. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  7541. case REACT_PORTAL_TYPE:
  7542. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  7543. }
  7544. }
  7545. if (typeof newChild === 'string' || typeof newChild === 'number') {
  7546. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  7547. }
  7548. if (isArray$1(newChild)) {
  7549. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  7550. }
  7551. if (getIteratorFn(newChild)) {
  7552. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  7553. }
  7554. if (isObject) {
  7555. throwOnInvalidObjectType(returnFiber, newChild);
  7556. }
  7557. {
  7558. if (typeof newChild === 'function') {
  7559. warnOnFunctionType();
  7560. }
  7561. }
  7562. if (typeof newChild === 'undefined') {
  7563. // If the new child is undefined, and the return fiber is a composite
  7564. // component, throw an error. If Fiber return types are disabled,
  7565. // we already threw above.
  7566. switch (returnFiber.tag) {
  7567. case ClassComponent:
  7568. {
  7569. {
  7570. var instance = returnFiber.stateNode;
  7571. if (instance.render._isMockFunction) {
  7572. // We allow auto-mocks to proceed as if they're returning null.
  7573. break;
  7574. }
  7575. }
  7576. }
  7577. // Intentionally fall through to the next case, which handles both
  7578. // functions and classes
  7579. // eslint-disable-next-lined no-fallthrough
  7580. case FunctionalComponent:
  7581. {
  7582. var Component = returnFiber.type;
  7583. invariant_1(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');
  7584. }
  7585. }
  7586. }
  7587. // Remaining cases are all treated as empty.
  7588. return deleteRemainingChildren(returnFiber, currentFirstChild);
  7589. }
  7590. return reconcileChildFibers;
  7591. }
  7592. var reconcileChildFibers = ChildReconciler(true);
  7593. var mountChildFibers = ChildReconciler(false);
  7594. function cloneChildFibers(current, workInProgress) {
  7595. !(current === null || workInProgress.child === current.child) ? invariant_1(false, 'Resuming work not yet implemented.') : void 0;
  7596. if (workInProgress.child === null) {
  7597. return;
  7598. }
  7599. var currentChild = workInProgress.child;
  7600. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  7601. workInProgress.child = newChild;
  7602. newChild['return'] = workInProgress;
  7603. while (currentChild.sibling !== null) {
  7604. currentChild = currentChild.sibling;
  7605. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  7606. newChild['return'] = workInProgress;
  7607. }
  7608. newChild.sibling = null;
  7609. }
  7610. var didWarnAboutBadClass = void 0;
  7611. var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0;
  7612. var didWarnAboutStatelessRefs = void 0;
  7613. {
  7614. didWarnAboutBadClass = {};
  7615. didWarnAboutGetDerivedStateOnFunctionalComponent = {};
  7616. didWarnAboutStatelessRefs = {};
  7617. }
  7618. var ReactFiberBeginWork = function (config, hostContext, legacyContext, newContext, hydrationContext, scheduleWork, computeExpirationForFiber) {
  7619. var shouldSetTextContent = config.shouldSetTextContent,
  7620. shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree;
  7621. var pushHostContext = hostContext.pushHostContext,
  7622. pushHostContainer = hostContext.pushHostContainer;
  7623. var pushProvider = newContext.pushProvider;
  7624. var getMaskedContext = legacyContext.getMaskedContext,
  7625. getUnmaskedContext = legacyContext.getUnmaskedContext,
  7626. hasLegacyContextChanged = legacyContext.hasContextChanged,
  7627. pushLegacyContextProvider = legacyContext.pushContextProvider,
  7628. pushTopLevelContextObject = legacyContext.pushTopLevelContextObject,
  7629. invalidateContextProvider = legacyContext.invalidateContextProvider;
  7630. var enterHydrationState = hydrationContext.enterHydrationState,
  7631. resetHydrationState = hydrationContext.resetHydrationState,
  7632. tryToClaimNextHydratableInstance = hydrationContext.tryToClaimNextHydratableInstance;
  7633. var _ReactFiberClassCompo = ReactFiberClassComponent(legacyContext, scheduleWork, computeExpirationForFiber, memoizeProps, memoizeState),
  7634. adoptClassInstance = _ReactFiberClassCompo.adoptClassInstance,
  7635. callGetDerivedStateFromProps = _ReactFiberClassCompo.callGetDerivedStateFromProps,
  7636. constructClassInstance = _ReactFiberClassCompo.constructClassInstance,
  7637. mountClassInstance = _ReactFiberClassCompo.mountClassInstance,
  7638. resumeMountClassInstance = _ReactFiberClassCompo.resumeMountClassInstance,
  7639. updateClassInstance = _ReactFiberClassCompo.updateClassInstance;
  7640. // TODO: Remove this and use reconcileChildrenAtExpirationTime directly.
  7641. function reconcileChildren(current, workInProgress, nextChildren) {
  7642. reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, workInProgress.expirationTime);
  7643. }
  7644. function reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime) {
  7645. if (current === null) {
  7646. // If this is a fresh new component that hasn't been rendered yet, we
  7647. // won't update its child set by applying minimal side-effects. Instead,
  7648. // we will add them all to the child before it gets rendered. That means
  7649. // we can optimize this reconciliation pass by not tracking side-effects.
  7650. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  7651. } else {
  7652. // If the current child is the same as the work in progress, it means that
  7653. // we haven't yet started any work on these children. Therefore, we use
  7654. // the clone algorithm to create a copy of all the current children.
  7655. // If we had any progressed work already, that is invalid at this point so
  7656. // let's throw it out.
  7657. workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
  7658. }
  7659. }
  7660. function updateForwardRef(current, workInProgress) {
  7661. var render = workInProgress.type.render;
  7662. var nextChildren = render(workInProgress.pendingProps, workInProgress.ref);
  7663. reconcileChildren(current, workInProgress, nextChildren);
  7664. memoizeProps(workInProgress, nextChildren);
  7665. return workInProgress.child;
  7666. }
  7667. function updateFragment(current, workInProgress) {
  7668. var nextChildren = workInProgress.pendingProps;
  7669. if (hasLegacyContextChanged()) {
  7670. // Normally we can bail out on props equality but if context has changed
  7671. // we don't do the bailout and we have to reuse existing props instead.
  7672. } else if (workInProgress.memoizedProps === nextChildren) {
  7673. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7674. }
  7675. reconcileChildren(current, workInProgress, nextChildren);
  7676. memoizeProps(workInProgress, nextChildren);
  7677. return workInProgress.child;
  7678. }
  7679. function updateMode(current, workInProgress) {
  7680. var nextChildren = workInProgress.pendingProps.children;
  7681. if (hasLegacyContextChanged()) {
  7682. // Normally we can bail out on props equality but if context has changed
  7683. // we don't do the bailout and we have to reuse existing props instead.
  7684. } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
  7685. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7686. }
  7687. reconcileChildren(current, workInProgress, nextChildren);
  7688. memoizeProps(workInProgress, nextChildren);
  7689. return workInProgress.child;
  7690. }
  7691. function markRef(current, workInProgress) {
  7692. var ref = workInProgress.ref;
  7693. if (current === null && ref !== null || current !== null && current.ref !== ref) {
  7694. // Schedule a Ref effect
  7695. workInProgress.effectTag |= Ref;
  7696. }
  7697. }
  7698. function updateFunctionalComponent(current, workInProgress) {
  7699. var fn = workInProgress.type;
  7700. var nextProps = workInProgress.pendingProps;
  7701. if (hasLegacyContextChanged()) {
  7702. // Normally we can bail out on props equality but if context has changed
  7703. // we don't do the bailout and we have to reuse existing props instead.
  7704. } else {
  7705. if (workInProgress.memoizedProps === nextProps) {
  7706. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7707. }
  7708. // TODO: consider bringing fn.shouldComponentUpdate() back.
  7709. // It used to be here.
  7710. }
  7711. var unmaskedContext = getUnmaskedContext(workInProgress);
  7712. var context = getMaskedContext(workInProgress, unmaskedContext);
  7713. var nextChildren = void 0;
  7714. {
  7715. ReactCurrentOwner.current = workInProgress;
  7716. ReactDebugCurrentFiber.setCurrentPhase('render');
  7717. nextChildren = fn(nextProps, context);
  7718. ReactDebugCurrentFiber.setCurrentPhase(null);
  7719. }
  7720. // React DevTools reads this flag.
  7721. workInProgress.effectTag |= PerformedWork;
  7722. reconcileChildren(current, workInProgress, nextChildren);
  7723. memoizeProps(workInProgress, nextProps);
  7724. return workInProgress.child;
  7725. }
  7726. function updateClassComponent(current, workInProgress, renderExpirationTime) {
  7727. // Push context providers early to prevent context stack mismatches.
  7728. // During mounting we don't know the child context yet as the instance doesn't exist.
  7729. // We will invalidate the child context in finishClassComponent() right after rendering.
  7730. var hasContext = pushLegacyContextProvider(workInProgress);
  7731. var shouldUpdate = void 0;
  7732. if (current === null) {
  7733. if (workInProgress.stateNode === null) {
  7734. // In the initial pass we might need to construct the instance.
  7735. constructClassInstance(workInProgress, workInProgress.pendingProps);
  7736. mountClassInstance(workInProgress, renderExpirationTime);
  7737. shouldUpdate = true;
  7738. } else {
  7739. // In a resume, we'll already have an instance we can reuse.
  7740. shouldUpdate = resumeMountClassInstance(workInProgress, renderExpirationTime);
  7741. }
  7742. } else {
  7743. shouldUpdate = updateClassInstance(current, workInProgress, renderExpirationTime);
  7744. }
  7745. // We processed the update queue inside updateClassInstance. It may have
  7746. // included some errors that were dispatched during the commit phase.
  7747. // TODO: Refactor class components so this is less awkward.
  7748. var didCaptureError = false;
  7749. var updateQueue = workInProgress.updateQueue;
  7750. if (updateQueue !== null && updateQueue.capturedValues !== null) {
  7751. shouldUpdate = true;
  7752. didCaptureError = true;
  7753. }
  7754. return finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime);
  7755. }
  7756. function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime) {
  7757. // Refs should update even if shouldComponentUpdate returns false
  7758. markRef(current, workInProgress);
  7759. if (!shouldUpdate && !didCaptureError) {
  7760. // Context providers should defer to sCU for rendering
  7761. if (hasContext) {
  7762. invalidateContextProvider(workInProgress, false);
  7763. }
  7764. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7765. }
  7766. var ctor = workInProgress.type;
  7767. var instance = workInProgress.stateNode;
  7768. // Rerender
  7769. ReactCurrentOwner.current = workInProgress;
  7770. var nextChildren = void 0;
  7771. if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) {
  7772. // If we captured an error, but getDerivedStateFrom catch is not defined,
  7773. // unmount all the children. componentDidCatch will schedule an update to
  7774. // re-render a fallback. This is temporary until we migrate everyone to
  7775. // the new API.
  7776. // TODO: Warn in a future release.
  7777. nextChildren = null;
  7778. } else {
  7779. {
  7780. ReactDebugCurrentFiber.setCurrentPhase('render');
  7781. nextChildren = instance.render();
  7782. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  7783. instance.render();
  7784. }
  7785. ReactDebugCurrentFiber.setCurrentPhase(null);
  7786. }
  7787. }
  7788. // React DevTools reads this flag.
  7789. workInProgress.effectTag |= PerformedWork;
  7790. if (didCaptureError) {
  7791. // If we're recovering from an error, reconcile twice: first to delete
  7792. // all the existing children.
  7793. reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime);
  7794. workInProgress.child = null;
  7795. // Now we can continue reconciling like normal. This has the effect of
  7796. // remounting all children regardless of whether their their
  7797. // identity matches.
  7798. }
  7799. reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime);
  7800. // Memoize props and state using the values we just used to render.
  7801. // TODO: Restructure so we never read values from the instance.
  7802. memoizeState(workInProgress, instance.state);
  7803. memoizeProps(workInProgress, instance.props);
  7804. // The context might have changed so we need to recalculate it.
  7805. if (hasContext) {
  7806. invalidateContextProvider(workInProgress, true);
  7807. }
  7808. return workInProgress.child;
  7809. }
  7810. function pushHostRootContext(workInProgress) {
  7811. var root = workInProgress.stateNode;
  7812. if (root.pendingContext) {
  7813. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  7814. } else if (root.context) {
  7815. // Should always be set
  7816. pushTopLevelContextObject(workInProgress, root.context, false);
  7817. }
  7818. pushHostContainer(workInProgress, root.containerInfo);
  7819. }
  7820. function updateHostRoot(current, workInProgress, renderExpirationTime) {
  7821. pushHostRootContext(workInProgress);
  7822. var updateQueue = workInProgress.updateQueue;
  7823. if (updateQueue !== null) {
  7824. var prevState = workInProgress.memoizedState;
  7825. var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
  7826. memoizeState(workInProgress, state);
  7827. updateQueue = workInProgress.updateQueue;
  7828. var element = void 0;
  7829. if (updateQueue !== null && updateQueue.capturedValues !== null) {
  7830. // There's an uncaught error. Unmount the whole root.
  7831. element = null;
  7832. } else if (prevState === state) {
  7833. // If the state is the same as before, that's a bailout because we had
  7834. // no work that expires at this time.
  7835. resetHydrationState();
  7836. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7837. } else {
  7838. element = state.element;
  7839. }
  7840. var root = workInProgress.stateNode;
  7841. if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
  7842. // If we don't have any current children this might be the first pass.
  7843. // We always try to hydrate. If this isn't a hydration pass there won't
  7844. // be any children to hydrate which is effectively the same thing as
  7845. // not hydrating.
  7846. // This is a bit of a hack. We track the host root as a placement to
  7847. // know that we're currently in a mounting state. That way isMounted
  7848. // works as expected. We must reset this before committing.
  7849. // TODO: Delete this when we delete isMounted and findDOMNode.
  7850. workInProgress.effectTag |= Placement;
  7851. // Ensure that children mount into this root without tracking
  7852. // side-effects. This ensures that we don't store Placement effects on
  7853. // nodes that will be hydrated.
  7854. workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
  7855. } else {
  7856. // Otherwise reset hydration state in case we aborted and resumed another
  7857. // root.
  7858. resetHydrationState();
  7859. reconcileChildren(current, workInProgress, element);
  7860. }
  7861. memoizeState(workInProgress, state);
  7862. return workInProgress.child;
  7863. }
  7864. resetHydrationState();
  7865. // If there is no update queue, that's a bailout because the root has no props.
  7866. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7867. }
  7868. function updateHostComponent(current, workInProgress, renderExpirationTime) {
  7869. pushHostContext(workInProgress);
  7870. if (current === null) {
  7871. tryToClaimNextHydratableInstance(workInProgress);
  7872. }
  7873. var type = workInProgress.type;
  7874. var memoizedProps = workInProgress.memoizedProps;
  7875. var nextProps = workInProgress.pendingProps;
  7876. var prevProps = current !== null ? current.memoizedProps : null;
  7877. if (hasLegacyContextChanged()) {
  7878. // Normally we can bail out on props equality but if context has changed
  7879. // we don't do the bailout and we have to reuse existing props instead.
  7880. } else if (memoizedProps === nextProps) {
  7881. var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
  7882. if (isHidden) {
  7883. // Before bailing out, make sure we've deprioritized a hidden component.
  7884. workInProgress.expirationTime = Never;
  7885. }
  7886. if (!isHidden || renderExpirationTime !== Never) {
  7887. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  7888. }
  7889. // If we're rendering a hidden node at hidden priority, don't bailout. The
  7890. // parent is complete, but the children may not be.
  7891. }
  7892. var nextChildren = nextProps.children;
  7893. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  7894. if (isDirectTextChild) {
  7895. // We special case a direct text child of a host node. This is a common
  7896. // case. We won't handle it as a reified child. We will instead handle
  7897. // this in the host environment that also have access to this prop. That
  7898. // avoids allocating another HostText fiber and traversing it.
  7899. nextChildren = null;
  7900. } else if (prevProps && shouldSetTextContent(type, prevProps)) {
  7901. // If we're switching from a direct text child to a normal child, or to
  7902. // empty, we need to schedule the text content to be reset.
  7903. workInProgress.effectTag |= ContentReset;
  7904. }
  7905. markRef(current, workInProgress);
  7906. // Check the host config to see if the children are offscreen/hidden.
  7907. if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
  7908. // Down-prioritize the children.
  7909. workInProgress.expirationTime = Never;
  7910. // Bailout and come back to this fiber later.
  7911. workInProgress.memoizedProps = nextProps;
  7912. return null;
  7913. }
  7914. reconcileChildren(current, workInProgress, nextChildren);
  7915. memoizeProps(workInProgress, nextProps);
  7916. return workInProgress.child;
  7917. }
  7918. function updateHostText(current, workInProgress) {
  7919. if (current === null) {
  7920. tryToClaimNextHydratableInstance(workInProgress);
  7921. }
  7922. var nextProps = workInProgress.pendingProps;
  7923. memoizeProps(workInProgress, nextProps);
  7924. // Nothing to do here. This is terminal. We'll do the completion step
  7925. // immediately after.
  7926. return null;
  7927. }
  7928. function mountIndeterminateComponent(current, workInProgress, renderExpirationTime) {
  7929. !(current === null) ? invariant_1(false, 'An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  7930. var fn = workInProgress.type;
  7931. var props = workInProgress.pendingProps;
  7932. var unmaskedContext = getUnmaskedContext(workInProgress);
  7933. var context = getMaskedContext(workInProgress, unmaskedContext);
  7934. var value = void 0;
  7935. {
  7936. if (fn.prototype && typeof fn.prototype.render === 'function') {
  7937. var componentName = getComponentName(workInProgress) || 'Unknown';
  7938. if (!didWarnAboutBadClass[componentName]) {
  7939. warning_1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
  7940. didWarnAboutBadClass[componentName] = true;
  7941. }
  7942. }
  7943. ReactCurrentOwner.current = workInProgress;
  7944. value = fn(props, context);
  7945. }
  7946. // React DevTools reads this flag.
  7947. workInProgress.effectTag |= PerformedWork;
  7948. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  7949. var Component = workInProgress.type;
  7950. // Proceed under the assumption that this is a class instance
  7951. workInProgress.tag = ClassComponent;
  7952. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  7953. if (typeof Component.getDerivedStateFromProps === 'function') {
  7954. var partialState = callGetDerivedStateFromProps(workInProgress, value, props, workInProgress.memoizedState);
  7955. if (partialState !== null && partialState !== undefined) {
  7956. workInProgress.memoizedState = _assign({}, workInProgress.memoizedState, partialState);
  7957. }
  7958. }
  7959. // Push context providers early to prevent context stack mismatches.
  7960. // During mounting we don't know the child context yet as the instance doesn't exist.
  7961. // We will invalidate the child context in finishClassComponent() right after rendering.
  7962. var hasContext = pushLegacyContextProvider(workInProgress);
  7963. adoptClassInstance(workInProgress, value);
  7964. mountClassInstance(workInProgress, renderExpirationTime);
  7965. return finishClassComponent(current, workInProgress, true, hasContext, false, renderExpirationTime);
  7966. } else {
  7967. // Proceed under the assumption that this is a functional component
  7968. workInProgress.tag = FunctionalComponent;
  7969. {
  7970. var _Component = workInProgress.type;
  7971. if (_Component) {
  7972. !!_Component.childContextTypes ? warning_1(false, '%s(...): childContextTypes cannot be defined on a functional component.', _Component.displayName || _Component.name || 'Component') : void 0;
  7973. }
  7974. if (workInProgress.ref !== null) {
  7975. var info = '';
  7976. var ownerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName();
  7977. if (ownerName) {
  7978. info += '\n\nCheck the render method of `' + ownerName + '`.';
  7979. }
  7980. var warningKey = ownerName || workInProgress._debugID || '';
  7981. var debugSource = workInProgress._debugSource;
  7982. if (debugSource) {
  7983. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  7984. }
  7985. if (!didWarnAboutStatelessRefs[warningKey]) {
  7986. didWarnAboutStatelessRefs[warningKey] = true;
  7987. warning_1(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s%s', info, ReactDebugCurrentFiber.getCurrentFiberStackAddendum());
  7988. }
  7989. }
  7990. if (typeof fn.getDerivedStateFromProps === 'function') {
  7991. var _componentName = getComponentName(workInProgress) || 'Unknown';
  7992. if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) {
  7993. warning_1(false, '%s: Stateless functional components do not support getDerivedStateFromProps.', _componentName);
  7994. didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName] = true;
  7995. }
  7996. }
  7997. }
  7998. reconcileChildren(current, workInProgress, value);
  7999. memoizeProps(workInProgress, props);
  8000. return workInProgress.child;
  8001. }
  8002. }
  8003. function updateCallComponent(current, workInProgress, renderExpirationTime) {
  8004. var nextProps = workInProgress.pendingProps;
  8005. if (hasLegacyContextChanged()) {
  8006. // Normally we can bail out on props equality but if context has changed
  8007. // we don't do the bailout and we have to reuse existing props instead.
  8008. } else if (workInProgress.memoizedProps === nextProps) {
  8009. nextProps = workInProgress.memoizedProps;
  8010. // TODO: When bailing out, we might need to return the stateNode instead
  8011. // of the child. To check it for work.
  8012. // return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8013. }
  8014. var nextChildren = nextProps.children;
  8015. // The following is a fork of reconcileChildrenAtExpirationTime but using
  8016. // stateNode to store the child.
  8017. if (current === null) {
  8018. workInProgress.stateNode = mountChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
  8019. } else {
  8020. workInProgress.stateNode = reconcileChildFibers(workInProgress, current.stateNode, nextChildren, renderExpirationTime);
  8021. }
  8022. memoizeProps(workInProgress, nextProps);
  8023. // This doesn't take arbitrary time so we could synchronously just begin
  8024. // eagerly do the work of workInProgress.child as an optimization.
  8025. return workInProgress.stateNode;
  8026. }
  8027. function updatePortalComponent(current, workInProgress, renderExpirationTime) {
  8028. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  8029. var nextChildren = workInProgress.pendingProps;
  8030. if (hasLegacyContextChanged()) {
  8031. // Normally we can bail out on props equality but if context has changed
  8032. // we don't do the bailout and we have to reuse existing props instead.
  8033. } else if (workInProgress.memoizedProps === nextChildren) {
  8034. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8035. }
  8036. if (current === null) {
  8037. // Portals are special because we don't append the children during mount
  8038. // but at commit. Therefore we need to track insertions which the normal
  8039. // flow doesn't do during mount. This doesn't happen at the root because
  8040. // the root always starts with a "current" with a null child.
  8041. // TODO: Consider unifying this with how the root works.
  8042. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  8043. memoizeProps(workInProgress, nextChildren);
  8044. } else {
  8045. reconcileChildren(current, workInProgress, nextChildren);
  8046. memoizeProps(workInProgress, nextChildren);
  8047. }
  8048. return workInProgress.child;
  8049. }
  8050. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  8051. var fiber = workInProgress.child;
  8052. if (fiber !== null) {
  8053. // Set the return pointer of the child to the work-in-progress fiber.
  8054. fiber['return'] = workInProgress;
  8055. }
  8056. while (fiber !== null) {
  8057. var nextFiber = void 0;
  8058. // Visit this fiber.
  8059. switch (fiber.tag) {
  8060. case ContextConsumer:
  8061. // Check if the context matches.
  8062. var observedBits = fiber.stateNode | 0;
  8063. if (fiber.type === context && (observedBits & changedBits) !== 0) {
  8064. // Update the expiration time of all the ancestors, including
  8065. // the alternates.
  8066. var node = fiber;
  8067. while (node !== null) {
  8068. var alternate = node.alternate;
  8069. if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) {
  8070. node.expirationTime = renderExpirationTime;
  8071. if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
  8072. alternate.expirationTime = renderExpirationTime;
  8073. }
  8074. } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
  8075. alternate.expirationTime = renderExpirationTime;
  8076. } else {
  8077. // Neither alternate was updated, which means the rest of the
  8078. // ancestor path already has sufficient priority.
  8079. break;
  8080. }
  8081. node = node['return'];
  8082. }
  8083. // Don't scan deeper than a matching consumer. When we render the
  8084. // consumer, we'll continue scanning from that point. This way the
  8085. // scanning work is time-sliced.
  8086. nextFiber = null;
  8087. } else {
  8088. // Traverse down.
  8089. nextFiber = fiber.child;
  8090. }
  8091. break;
  8092. case ContextProvider:
  8093. // Don't scan deeper if this is a matching provider
  8094. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  8095. break;
  8096. default:
  8097. // Traverse down.
  8098. nextFiber = fiber.child;
  8099. break;
  8100. }
  8101. if (nextFiber !== null) {
  8102. // Set the return pointer of the child to the work-in-progress fiber.
  8103. nextFiber['return'] = fiber;
  8104. } else {
  8105. // No child. Traverse to next sibling.
  8106. nextFiber = fiber;
  8107. while (nextFiber !== null) {
  8108. if (nextFiber === workInProgress) {
  8109. // We're back to the root of this subtree. Exit.
  8110. nextFiber = null;
  8111. break;
  8112. }
  8113. var sibling = nextFiber.sibling;
  8114. if (sibling !== null) {
  8115. nextFiber = sibling;
  8116. break;
  8117. }
  8118. // No more siblings. Traverse up.
  8119. nextFiber = nextFiber['return'];
  8120. }
  8121. }
  8122. fiber = nextFiber;
  8123. }
  8124. }
  8125. function updateContextProvider(current, workInProgress, renderExpirationTime) {
  8126. var providerType = workInProgress.type;
  8127. var context = providerType._context;
  8128. var newProps = workInProgress.pendingProps;
  8129. var oldProps = workInProgress.memoizedProps;
  8130. if (hasLegacyContextChanged()) {
  8131. // Normally we can bail out on props equality but if context has changed
  8132. // we don't do the bailout and we have to reuse existing props instead.
  8133. } else if (oldProps === newProps) {
  8134. workInProgress.stateNode = 0;
  8135. pushProvider(workInProgress);
  8136. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8137. }
  8138. var newValue = newProps.value;
  8139. workInProgress.memoizedProps = newProps;
  8140. var changedBits = void 0;
  8141. if (oldProps === null) {
  8142. // Initial render
  8143. changedBits = MAX_SIGNED_31_BIT_INT;
  8144. } else {
  8145. if (oldProps.value === newProps.value) {
  8146. // No change. Bailout early if children are the same.
  8147. if (oldProps.children === newProps.children) {
  8148. workInProgress.stateNode = 0;
  8149. pushProvider(workInProgress);
  8150. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8151. }
  8152. changedBits = 0;
  8153. } else {
  8154. var oldValue = oldProps.value;
  8155. // Use Object.is to compare the new context value to the old value.
  8156. // Inlined Object.is polyfill.
  8157. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  8158. if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare
  8159. ) {
  8160. // No change. Bailout early if children are the same.
  8161. if (oldProps.children === newProps.children) {
  8162. workInProgress.stateNode = 0;
  8163. pushProvider(workInProgress);
  8164. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8165. }
  8166. changedBits = 0;
  8167. } else {
  8168. changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  8169. {
  8170. !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning_1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
  8171. }
  8172. changedBits |= 0;
  8173. if (changedBits === 0) {
  8174. // No change. Bailout early if children are the same.
  8175. if (oldProps.children === newProps.children) {
  8176. workInProgress.stateNode = 0;
  8177. pushProvider(workInProgress);
  8178. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8179. }
  8180. } else {
  8181. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  8182. }
  8183. }
  8184. }
  8185. }
  8186. workInProgress.stateNode = changedBits;
  8187. pushProvider(workInProgress);
  8188. var newChildren = newProps.children;
  8189. reconcileChildren(current, workInProgress, newChildren);
  8190. return workInProgress.child;
  8191. }
  8192. function updateContextConsumer(current, workInProgress, renderExpirationTime) {
  8193. var context = workInProgress.type;
  8194. var newProps = workInProgress.pendingProps;
  8195. var oldProps = workInProgress.memoizedProps;
  8196. var newValue = context._currentValue;
  8197. var changedBits = context._changedBits;
  8198. if (hasLegacyContextChanged()) {
  8199. // Normally we can bail out on props equality but if context has changed
  8200. // we don't do the bailout and we have to reuse existing props instead.
  8201. } else if (changedBits === 0 && oldProps === newProps) {
  8202. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8203. }
  8204. workInProgress.memoizedProps = newProps;
  8205. var observedBits = newProps.unstable_observedBits;
  8206. if (observedBits === undefined || observedBits === null) {
  8207. // Subscribe to all changes by default
  8208. observedBits = MAX_SIGNED_31_BIT_INT;
  8209. }
  8210. // Store the observedBits on the fiber's stateNode for quick access.
  8211. workInProgress.stateNode = observedBits;
  8212. if ((changedBits & observedBits) !== 0) {
  8213. // Context change propagation stops at matching consumers, for time-
  8214. // slicing. Continue the propagation here.
  8215. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  8216. } else if (oldProps === newProps) {
  8217. // Skip over a memoized parent with a bitmask bailout even
  8218. // if we began working on it because of a deeper matching child.
  8219. return bailoutOnAlreadyFinishedWork(current, workInProgress);
  8220. }
  8221. // There is no bailout on `children` equality because we expect people
  8222. // to often pass a bound method as a child, but it may reference
  8223. // `this.state` or `this.props` (and thus needs to re-render on `setState`).
  8224. var render = newProps.children;
  8225. {
  8226. !(typeof render === 'function') ? warning_1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
  8227. }
  8228. var newChildren = render(newValue);
  8229. reconcileChildren(current, workInProgress, newChildren);
  8230. return workInProgress.child;
  8231. }
  8232. /*
  8233. function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) {
  8234. let child = firstChild;
  8235. do {
  8236. // Ensure that the first and last effect of the parent corresponds
  8237. // to the children's first and last effect.
  8238. if (!returnFiber.firstEffect) {
  8239. returnFiber.firstEffect = child.firstEffect;
  8240. }
  8241. if (child.lastEffect) {
  8242. if (returnFiber.lastEffect) {
  8243. returnFiber.lastEffect.nextEffect = child.firstEffect;
  8244. }
  8245. returnFiber.lastEffect = child.lastEffect;
  8246. }
  8247. } while (child = child.sibling);
  8248. }
  8249. */
  8250. function bailoutOnAlreadyFinishedWork(current, workInProgress) {
  8251. cancelWorkTimer(workInProgress);
  8252. // TODO: We should ideally be able to bail out early if the children have no
  8253. // more work to do. However, since we don't have a separation of this
  8254. // Fiber's priority and its children yet - we don't know without doing lots
  8255. // of the same work we do anyway. Once we have that separation we can just
  8256. // bail out here if the children has no more work at this priority level.
  8257. // if (workInProgress.priorityOfChildren <= priorityLevel) {
  8258. // // If there are side-effects in these children that have not yet been
  8259. // // committed we need to ensure that they get properly transferred up.
  8260. // if (current && current.child !== workInProgress.child) {
  8261. // reuseChildrenEffects(workInProgress, child);
  8262. // }
  8263. // return null;
  8264. // }
  8265. cloneChildFibers(current, workInProgress);
  8266. return workInProgress.child;
  8267. }
  8268. function bailoutOnLowPriority(current, workInProgress) {
  8269. cancelWorkTimer(workInProgress);
  8270. // TODO: Handle HostComponent tags here as well and call pushHostContext()?
  8271. // See PR 8590 discussion for context
  8272. switch (workInProgress.tag) {
  8273. case HostRoot:
  8274. pushHostRootContext(workInProgress);
  8275. break;
  8276. case ClassComponent:
  8277. pushLegacyContextProvider(workInProgress);
  8278. break;
  8279. case HostPortal:
  8280. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  8281. break;
  8282. case ContextProvider:
  8283. pushProvider(workInProgress);
  8284. break;
  8285. }
  8286. // TODO: What if this is currently in progress?
  8287. // How can that happen? How is this not being cloned?
  8288. return null;
  8289. }
  8290. // TODO: Delete memoizeProps/State and move to reconcile/bailout instead
  8291. function memoizeProps(workInProgress, nextProps) {
  8292. workInProgress.memoizedProps = nextProps;
  8293. }
  8294. function memoizeState(workInProgress, nextState) {
  8295. workInProgress.memoizedState = nextState;
  8296. // Don't reset the updateQueue, in case there are pending updates. Resetting
  8297. // is handled by processUpdateQueue.
  8298. }
  8299. function beginWork(current, workInProgress, renderExpirationTime) {
  8300. if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) {
  8301. return bailoutOnLowPriority(current, workInProgress);
  8302. }
  8303. switch (workInProgress.tag) {
  8304. case IndeterminateComponent:
  8305. return mountIndeterminateComponent(current, workInProgress, renderExpirationTime);
  8306. case FunctionalComponent:
  8307. return updateFunctionalComponent(current, workInProgress);
  8308. case ClassComponent:
  8309. return updateClassComponent(current, workInProgress, renderExpirationTime);
  8310. case HostRoot:
  8311. return updateHostRoot(current, workInProgress, renderExpirationTime);
  8312. case HostComponent:
  8313. return updateHostComponent(current, workInProgress, renderExpirationTime);
  8314. case HostText:
  8315. return updateHostText(current, workInProgress);
  8316. case CallHandlerPhase:
  8317. // This is a restart. Reset the tag to the initial phase.
  8318. workInProgress.tag = CallComponent;
  8319. // Intentionally fall through since this is now the same.
  8320. case CallComponent:
  8321. return updateCallComponent(current, workInProgress, renderExpirationTime);
  8322. case ReturnComponent:
  8323. // A return component is just a placeholder, we can just run through the
  8324. // next one immediately.
  8325. return null;
  8326. case HostPortal:
  8327. return updatePortalComponent(current, workInProgress, renderExpirationTime);
  8328. case ForwardRef:
  8329. return updateForwardRef(current, workInProgress);
  8330. case Fragment:
  8331. return updateFragment(current, workInProgress);
  8332. case Mode:
  8333. return updateMode(current, workInProgress);
  8334. case ContextProvider:
  8335. return updateContextProvider(current, workInProgress, renderExpirationTime);
  8336. case ContextConsumer:
  8337. return updateContextConsumer(current, workInProgress, renderExpirationTime);
  8338. default:
  8339. invariant_1(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
  8340. }
  8341. }
  8342. return {
  8343. beginWork: beginWork
  8344. };
  8345. };
  8346. var ReactFiberCompleteWork = function (config, hostContext, legacyContext, newContext, hydrationContext) {
  8347. var createInstance = config.createInstance,
  8348. createTextInstance = config.createTextInstance,
  8349. appendInitialChild = config.appendInitialChild,
  8350. finalizeInitialChildren = config.finalizeInitialChildren,
  8351. prepareUpdate = config.prepareUpdate,
  8352. mutation = config.mutation,
  8353. persistence = config.persistence;
  8354. var getRootHostContainer = hostContext.getRootHostContainer,
  8355. popHostContext = hostContext.popHostContext,
  8356. getHostContext = hostContext.getHostContext,
  8357. popHostContainer = hostContext.popHostContainer;
  8358. var popLegacyContextProvider = legacyContext.popContextProvider,
  8359. popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject;
  8360. var popProvider = newContext.popProvider;
  8361. var prepareToHydrateHostInstance = hydrationContext.prepareToHydrateHostInstance,
  8362. prepareToHydrateHostTextInstance = hydrationContext.prepareToHydrateHostTextInstance,
  8363. popHydrationState = hydrationContext.popHydrationState;
  8364. function markUpdate(workInProgress) {
  8365. // Tag the fiber with an update effect. This turns a Placement into
  8366. // a PlacementAndUpdate.
  8367. workInProgress.effectTag |= Update;
  8368. }
  8369. function markRef(workInProgress) {
  8370. workInProgress.effectTag |= Ref;
  8371. }
  8372. function appendAllReturns(returns, workInProgress) {
  8373. var node = workInProgress.stateNode;
  8374. if (node) {
  8375. node['return'] = workInProgress;
  8376. }
  8377. while (node !== null) {
  8378. if (node.tag === HostComponent || node.tag === HostText || node.tag === HostPortal) {
  8379. invariant_1(false, 'A call cannot have host component children.');
  8380. } else if (node.tag === ReturnComponent) {
  8381. returns.push(node.pendingProps.value);
  8382. } else if (node.child !== null) {
  8383. node.child['return'] = node;
  8384. node = node.child;
  8385. continue;
  8386. }
  8387. while (node.sibling === null) {
  8388. if (node['return'] === null || node['return'] === workInProgress) {
  8389. return;
  8390. }
  8391. node = node['return'];
  8392. }
  8393. node.sibling['return'] = node['return'];
  8394. node = node.sibling;
  8395. }
  8396. }
  8397. function moveCallToHandlerPhase(current, workInProgress, renderExpirationTime) {
  8398. var props = workInProgress.memoizedProps;
  8399. !props ? invariant_1(false, 'Should be resolved by now. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8400. // First step of the call has completed. Now we need to do the second.
  8401. // TODO: It would be nice to have a multi stage call represented by a
  8402. // single component, or at least tail call optimize nested ones. Currently
  8403. // that requires additional fields that we don't want to add to the fiber.
  8404. // So this requires nested handlers.
  8405. // Note: This doesn't mutate the alternate node. I don't think it needs to
  8406. // since this stage is reset for every pass.
  8407. workInProgress.tag = CallHandlerPhase;
  8408. // Build up the returns.
  8409. // TODO: Compare this to a generator or opaque helpers like Children.
  8410. var returns = [];
  8411. appendAllReturns(returns, workInProgress);
  8412. var fn = props.handler;
  8413. var childProps = props.props;
  8414. var nextChildren = fn(childProps, returns);
  8415. var currentFirstChild = current !== null ? current.child : null;
  8416. workInProgress.child = reconcileChildFibers(workInProgress, currentFirstChild, nextChildren, renderExpirationTime);
  8417. return workInProgress.child;
  8418. }
  8419. function appendAllChildren(parent, workInProgress) {
  8420. // We only have the top Fiber that was created but we need recurse down its
  8421. // children to find all the terminal nodes.
  8422. var node = workInProgress.child;
  8423. while (node !== null) {
  8424. if (node.tag === HostComponent || node.tag === HostText) {
  8425. appendInitialChild(parent, node.stateNode);
  8426. } else if (node.tag === HostPortal) {
  8427. // If we have a portal child, then we don't want to traverse
  8428. // down its children. Instead, we'll get insertions from each child in
  8429. // the portal directly.
  8430. } else if (node.child !== null) {
  8431. node.child['return'] = node;
  8432. node = node.child;
  8433. continue;
  8434. }
  8435. if (node === workInProgress) {
  8436. return;
  8437. }
  8438. while (node.sibling === null) {
  8439. if (node['return'] === null || node['return'] === workInProgress) {
  8440. return;
  8441. }
  8442. node = node['return'];
  8443. }
  8444. node.sibling['return'] = node['return'];
  8445. node = node.sibling;
  8446. }
  8447. }
  8448. var updateHostContainer = void 0;
  8449. var updateHostComponent = void 0;
  8450. var updateHostText = void 0;
  8451. if (mutation) {
  8452. if (enableMutatingReconciler) {
  8453. // Mutation mode
  8454. updateHostContainer = function (workInProgress) {
  8455. // Noop
  8456. };
  8457. updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) {
  8458. // TODO: Type this specific to this type of component.
  8459. workInProgress.updateQueue = updatePayload;
  8460. // If the update payload indicates that there is a change or if there
  8461. // is a new ref we mark this as an update. All the work is done in commitWork.
  8462. if (updatePayload) {
  8463. markUpdate(workInProgress);
  8464. }
  8465. };
  8466. updateHostText = function (current, workInProgress, oldText, newText) {
  8467. // If the text differs, mark it as an update. All the work in done in commitWork.
  8468. if (oldText !== newText) {
  8469. markUpdate(workInProgress);
  8470. }
  8471. };
  8472. } else {
  8473. invariant_1(false, 'Mutating reconciler is disabled.');
  8474. }
  8475. } else if (persistence) {
  8476. if (enablePersistentReconciler) {
  8477. // Persistent host tree mode
  8478. var cloneInstance = persistence.cloneInstance,
  8479. createContainerChildSet = persistence.createContainerChildSet,
  8480. appendChildToContainerChildSet = persistence.appendChildToContainerChildSet,
  8481. finalizeContainerChildren = persistence.finalizeContainerChildren;
  8482. // An unfortunate fork of appendAllChildren because we have two different parent types.
  8483. var appendAllChildrenToContainer = function (containerChildSet, workInProgress) {
  8484. // We only have the top Fiber that was created but we need recurse down its
  8485. // children to find all the terminal nodes.
  8486. var node = workInProgress.child;
  8487. while (node !== null) {
  8488. if (node.tag === HostComponent || node.tag === HostText) {
  8489. appendChildToContainerChildSet(containerChildSet, node.stateNode);
  8490. } else if (node.tag === HostPortal) {
  8491. // If we have a portal child, then we don't want to traverse
  8492. // down its children. Instead, we'll get insertions from each child in
  8493. // the portal directly.
  8494. } else if (node.child !== null) {
  8495. node.child['return'] = node;
  8496. node = node.child;
  8497. continue;
  8498. }
  8499. if (node === workInProgress) {
  8500. return;
  8501. }
  8502. while (node.sibling === null) {
  8503. if (node['return'] === null || node['return'] === workInProgress) {
  8504. return;
  8505. }
  8506. node = node['return'];
  8507. }
  8508. node.sibling['return'] = node['return'];
  8509. node = node.sibling;
  8510. }
  8511. };
  8512. updateHostContainer = function (workInProgress) {
  8513. var portalOrRoot = workInProgress.stateNode;
  8514. var childrenUnchanged = workInProgress.firstEffect === null;
  8515. if (childrenUnchanged) {
  8516. // No changes, just reuse the existing instance.
  8517. } else {
  8518. var container = portalOrRoot.containerInfo;
  8519. var newChildSet = createContainerChildSet(container);
  8520. // If children might have changed, we have to add them all to the set.
  8521. appendAllChildrenToContainer(newChildSet, workInProgress);
  8522. portalOrRoot.pendingChildren = newChildSet;
  8523. // Schedule an update on the container to swap out the container.
  8524. markUpdate(workInProgress);
  8525. finalizeContainerChildren(container, newChildSet);
  8526. }
  8527. };
  8528. updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) {
  8529. // If there are no effects associated with this node, then none of our children had any updates.
  8530. // This guarantees that we can reuse all of them.
  8531. var childrenUnchanged = workInProgress.firstEffect === null;
  8532. var currentInstance = current.stateNode;
  8533. if (childrenUnchanged && updatePayload === null) {
  8534. // No changes, just reuse the existing instance.
  8535. // Note that this might release a previous clone.
  8536. workInProgress.stateNode = currentInstance;
  8537. } else {
  8538. var recyclableInstance = workInProgress.stateNode;
  8539. var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
  8540. if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
  8541. markUpdate(workInProgress);
  8542. }
  8543. workInProgress.stateNode = newInstance;
  8544. if (childrenUnchanged) {
  8545. // If there are no other effects in this tree, we need to flag this node as having one.
  8546. // Even though we're not going to use it for anything.
  8547. // Otherwise parents won't know that there are new children to propagate upwards.
  8548. markUpdate(workInProgress);
  8549. } else {
  8550. // If children might have changed, we have to add them all to the set.
  8551. appendAllChildren(newInstance, workInProgress);
  8552. }
  8553. }
  8554. };
  8555. updateHostText = function (current, workInProgress, oldText, newText) {
  8556. if (oldText !== newText) {
  8557. // If the text content differs, we'll create a new text instance for it.
  8558. var rootContainerInstance = getRootHostContainer();
  8559. var currentHostContext = getHostContext();
  8560. workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
  8561. // We'll have to mark it as having an effect, even though we won't use the effect for anything.
  8562. // This lets the parents know that at least one of their children has changed.
  8563. markUpdate(workInProgress);
  8564. }
  8565. };
  8566. } else {
  8567. invariant_1(false, 'Persistent reconciler is disabled.');
  8568. }
  8569. } else {
  8570. if (enableNoopReconciler) {
  8571. // No host operations
  8572. updateHostContainer = function (workInProgress) {
  8573. // Noop
  8574. };
  8575. updateHostComponent = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) {
  8576. // Noop
  8577. };
  8578. updateHostText = function (current, workInProgress, oldText, newText) {
  8579. // Noop
  8580. };
  8581. } else {
  8582. invariant_1(false, 'Noop reconciler is disabled.');
  8583. }
  8584. }
  8585. function completeWork(current, workInProgress, renderExpirationTime) {
  8586. var newProps = workInProgress.pendingProps;
  8587. switch (workInProgress.tag) {
  8588. case FunctionalComponent:
  8589. return null;
  8590. case ClassComponent:
  8591. {
  8592. // We are leaving this subtree, so pop context if any.
  8593. popLegacyContextProvider(workInProgress);
  8594. // If this component caught an error, schedule an error log effect.
  8595. var instance = workInProgress.stateNode;
  8596. var updateQueue = workInProgress.updateQueue;
  8597. if (updateQueue !== null && updateQueue.capturedValues !== null) {
  8598. workInProgress.effectTag &= ~DidCapture;
  8599. if (typeof instance.componentDidCatch === 'function') {
  8600. workInProgress.effectTag |= ErrLog;
  8601. } else {
  8602. // Normally we clear this in the commit phase, but since we did not
  8603. // schedule an effect, we need to reset it here.
  8604. updateQueue.capturedValues = null;
  8605. }
  8606. }
  8607. return null;
  8608. }
  8609. case HostRoot:
  8610. {
  8611. popHostContainer(workInProgress);
  8612. popTopLevelLegacyContextObject(workInProgress);
  8613. var fiberRoot = workInProgress.stateNode;
  8614. if (fiberRoot.pendingContext) {
  8615. fiberRoot.context = fiberRoot.pendingContext;
  8616. fiberRoot.pendingContext = null;
  8617. }
  8618. if (current === null || current.child === null) {
  8619. // If we hydrated, pop so that we can delete any remaining children
  8620. // that weren't hydrated.
  8621. popHydrationState(workInProgress);
  8622. // This resets the hacky state to fix isMounted before committing.
  8623. // TODO: Delete this when we delete isMounted and findDOMNode.
  8624. workInProgress.effectTag &= ~Placement;
  8625. }
  8626. updateHostContainer(workInProgress);
  8627. var _updateQueue = workInProgress.updateQueue;
  8628. if (_updateQueue !== null && _updateQueue.capturedValues !== null) {
  8629. workInProgress.effectTag |= ErrLog;
  8630. }
  8631. return null;
  8632. }
  8633. case HostComponent:
  8634. {
  8635. popHostContext(workInProgress);
  8636. var rootContainerInstance = getRootHostContainer();
  8637. var type = workInProgress.type;
  8638. if (current !== null && workInProgress.stateNode != null) {
  8639. // If we have an alternate, that means this is an update and we need to
  8640. // schedule a side-effect to do the updates.
  8641. var oldProps = current.memoizedProps;
  8642. // If we get updated because one of our children updated, we don't
  8643. // have newProps so we'll have to reuse them.
  8644. // TODO: Split the update API as separate for the props vs. children.
  8645. // Even better would be if children weren't special cased at all tho.
  8646. var _instance = workInProgress.stateNode;
  8647. var currentHostContext = getHostContext();
  8648. // TODO: Experiencing an error where oldProps is null. Suggests a host
  8649. // component is hitting the resume path. Figure out why. Possibly
  8650. // related to `hidden`.
  8651. var updatePayload = prepareUpdate(_instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  8652. updateHostComponent(current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  8653. if (current.ref !== workInProgress.ref) {
  8654. markRef(workInProgress);
  8655. }
  8656. } else {
  8657. if (!newProps) {
  8658. !(workInProgress.stateNode !== null) ? invariant_1(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8659. // This can happen when we abort work.
  8660. return null;
  8661. }
  8662. var _currentHostContext = getHostContext();
  8663. // TODO: Move createInstance to beginWork and keep it on a context
  8664. // "stack" as the parent. Then append children as we go in beginWork
  8665. // or completeWork depending on we want to add then top->down or
  8666. // bottom->up. Top->down is faster in IE11.
  8667. var wasHydrated = popHydrationState(workInProgress);
  8668. if (wasHydrated) {
  8669. // TODO: Move this and createInstance step into the beginPhase
  8670. // to consolidate.
  8671. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, _currentHostContext)) {
  8672. // If changes to the hydrated node needs to be applied at the
  8673. // commit-phase we mark this as such.
  8674. markUpdate(workInProgress);
  8675. }
  8676. } else {
  8677. var _instance2 = createInstance(type, newProps, rootContainerInstance, _currentHostContext, workInProgress);
  8678. appendAllChildren(_instance2, workInProgress);
  8679. // Certain renderers require commit-time effects for initial mount.
  8680. // (eg DOM renderer supports auto-focus for certain elements).
  8681. // Make sure such renderers get scheduled for later work.
  8682. if (finalizeInitialChildren(_instance2, type, newProps, rootContainerInstance, _currentHostContext)) {
  8683. markUpdate(workInProgress);
  8684. }
  8685. workInProgress.stateNode = _instance2;
  8686. }
  8687. if (workInProgress.ref !== null) {
  8688. // If there is a ref on a host node we need to schedule a callback
  8689. markRef(workInProgress);
  8690. }
  8691. }
  8692. return null;
  8693. }
  8694. case HostText:
  8695. {
  8696. var newText = newProps;
  8697. if (current && workInProgress.stateNode != null) {
  8698. var oldText = current.memoizedProps;
  8699. // If we have an alternate, that means this is an update and we need
  8700. // to schedule a side-effect to do the updates.
  8701. updateHostText(current, workInProgress, oldText, newText);
  8702. } else {
  8703. if (typeof newText !== 'string') {
  8704. !(workInProgress.stateNode !== null) ? invariant_1(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8705. // This can happen when we abort work.
  8706. return null;
  8707. }
  8708. var _rootContainerInstance = getRootHostContainer();
  8709. var _currentHostContext2 = getHostContext();
  8710. var _wasHydrated = popHydrationState(workInProgress);
  8711. if (_wasHydrated) {
  8712. if (prepareToHydrateHostTextInstance(workInProgress)) {
  8713. markUpdate(workInProgress);
  8714. }
  8715. } else {
  8716. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext2, workInProgress);
  8717. }
  8718. }
  8719. return null;
  8720. }
  8721. case CallComponent:
  8722. return moveCallToHandlerPhase(current, workInProgress, renderExpirationTime);
  8723. case CallHandlerPhase:
  8724. // Reset the tag to now be a first phase call.
  8725. workInProgress.tag = CallComponent;
  8726. return null;
  8727. case ReturnComponent:
  8728. // Does nothing.
  8729. return null;
  8730. case ForwardRef:
  8731. return null;
  8732. case Fragment:
  8733. return null;
  8734. case Mode:
  8735. return null;
  8736. case HostPortal:
  8737. popHostContainer(workInProgress);
  8738. updateHostContainer(workInProgress);
  8739. return null;
  8740. case ContextProvider:
  8741. // Pop provider fiber
  8742. popProvider(workInProgress);
  8743. return null;
  8744. case ContextConsumer:
  8745. return null;
  8746. // Error cases
  8747. case IndeterminateComponent:
  8748. invariant_1(false, 'An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue.');
  8749. // eslint-disable-next-line no-fallthrough
  8750. default:
  8751. invariant_1(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
  8752. }
  8753. }
  8754. return {
  8755. completeWork: completeWork
  8756. };
  8757. };
  8758. function createCapturedValue(value, source) {
  8759. // If the value is an error, call this function immediately after it is thrown
  8760. // so the stack is accurate.
  8761. return {
  8762. value: value,
  8763. source: source,
  8764. stack: getStackAddendumByWorkInProgressFiber(source)
  8765. };
  8766. }
  8767. var ReactFiberUnwindWork = function (hostContext, legacyContext, newContext, scheduleWork, isAlreadyFailedLegacyErrorBoundary) {
  8768. var popHostContainer = hostContext.popHostContainer,
  8769. popHostContext = hostContext.popHostContext;
  8770. var popLegacyContextProvider = legacyContext.popContextProvider,
  8771. popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject;
  8772. var popProvider = newContext.popProvider;
  8773. function throwException(returnFiber, sourceFiber, rawValue) {
  8774. // The source fiber did not complete.
  8775. sourceFiber.effectTag |= Incomplete;
  8776. // Its effect list is no longer valid.
  8777. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  8778. var value = createCapturedValue(rawValue, sourceFiber);
  8779. var workInProgress = returnFiber;
  8780. do {
  8781. switch (workInProgress.tag) {
  8782. case HostRoot:
  8783. {
  8784. // Uncaught error
  8785. var errorInfo = value;
  8786. ensureUpdateQueues(workInProgress);
  8787. var updateQueue = workInProgress.updateQueue;
  8788. updateQueue.capturedValues = [errorInfo];
  8789. workInProgress.effectTag |= ShouldCapture;
  8790. return;
  8791. }
  8792. case ClassComponent:
  8793. // Capture and retry
  8794. var ctor = workInProgress.type;
  8795. var _instance = workInProgress.stateNode;
  8796. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromCatch === 'function' && enableGetDerivedStateFromCatch || _instance !== null && typeof _instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(_instance))) {
  8797. ensureUpdateQueues(workInProgress);
  8798. var _updateQueue = workInProgress.updateQueue;
  8799. var capturedValues = _updateQueue.capturedValues;
  8800. if (capturedValues === null) {
  8801. _updateQueue.capturedValues = [value];
  8802. } else {
  8803. capturedValues.push(value);
  8804. }
  8805. workInProgress.effectTag |= ShouldCapture;
  8806. return;
  8807. }
  8808. break;
  8809. default:
  8810. break;
  8811. }
  8812. workInProgress = workInProgress['return'];
  8813. } while (workInProgress !== null);
  8814. }
  8815. function unwindWork(workInProgress) {
  8816. switch (workInProgress.tag) {
  8817. case ClassComponent:
  8818. {
  8819. popLegacyContextProvider(workInProgress);
  8820. var effectTag = workInProgress.effectTag;
  8821. if (effectTag & ShouldCapture) {
  8822. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  8823. return workInProgress;
  8824. }
  8825. return null;
  8826. }
  8827. case HostRoot:
  8828. {
  8829. popHostContainer(workInProgress);
  8830. popTopLevelLegacyContextObject(workInProgress);
  8831. var _effectTag = workInProgress.effectTag;
  8832. if (_effectTag & ShouldCapture) {
  8833. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  8834. return workInProgress;
  8835. }
  8836. return null;
  8837. }
  8838. case HostComponent:
  8839. {
  8840. popHostContext(workInProgress);
  8841. return null;
  8842. }
  8843. case HostPortal:
  8844. popHostContainer(workInProgress);
  8845. return null;
  8846. case ContextProvider:
  8847. popProvider(workInProgress);
  8848. return null;
  8849. default:
  8850. return null;
  8851. }
  8852. }
  8853. function unwindInterruptedWork(interruptedWork) {
  8854. switch (interruptedWork.tag) {
  8855. case ClassComponent:
  8856. {
  8857. popLegacyContextProvider(interruptedWork);
  8858. break;
  8859. }
  8860. case HostRoot:
  8861. {
  8862. popHostContainer(interruptedWork);
  8863. popTopLevelLegacyContextObject(interruptedWork);
  8864. break;
  8865. }
  8866. case HostComponent:
  8867. {
  8868. popHostContext(interruptedWork);
  8869. break;
  8870. }
  8871. case HostPortal:
  8872. popHostContainer(interruptedWork);
  8873. break;
  8874. case ContextProvider:
  8875. popProvider(interruptedWork);
  8876. break;
  8877. default:
  8878. break;
  8879. }
  8880. }
  8881. return {
  8882. throwException: throwException,
  8883. unwindWork: unwindWork,
  8884. unwindInterruptedWork: unwindInterruptedWork
  8885. };
  8886. };
  8887. // This module is forked in different environments.
  8888. // By default, return `true` to log errors to the console.
  8889. // Forks can return `false` if this isn't desirable.
  8890. function showErrorDialog(capturedError) {
  8891. return true;
  8892. }
  8893. function logCapturedError(capturedError) {
  8894. var logError = showErrorDialog(capturedError);
  8895. // Allow injected showErrorDialog() to prevent default console.error logging.
  8896. // This enables renderers like ReactNative to better manage redbox behavior.
  8897. if (logError === false) {
  8898. return;
  8899. }
  8900. var error = capturedError.error;
  8901. var suppressLogging = error && error.suppressReactErrorLogging;
  8902. if (suppressLogging) {
  8903. return;
  8904. }
  8905. {
  8906. var componentName = capturedError.componentName,
  8907. componentStack = capturedError.componentStack,
  8908. errorBoundaryName = capturedError.errorBoundaryName,
  8909. errorBoundaryFound = capturedError.errorBoundaryFound,
  8910. willRetry = capturedError.willRetry;
  8911. var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
  8912. var errorBoundaryMessage = void 0;
  8913. // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  8914. if (errorBoundaryFound && errorBoundaryName) {
  8915. if (willRetry) {
  8916. errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
  8917. } else {
  8918. errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
  8919. }
  8920. } else {
  8921. errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
  8922. }
  8923. var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
  8924. // In development, we provide our own message with just the component stack.
  8925. // We don't include the original error message and JS stack because the browser
  8926. // has already printed it. Even if the application swallows the error, it is still
  8927. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  8928. console.error(combinedMessage);
  8929. }
  8930. }
  8931. var invokeGuardedCallback$3 = ReactErrorUtils.invokeGuardedCallback;
  8932. var hasCaughtError$1 = ReactErrorUtils.hasCaughtError;
  8933. var clearCaughtError$1 = ReactErrorUtils.clearCaughtError;
  8934. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  8935. {
  8936. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  8937. }
  8938. function logError(boundary, errorInfo) {
  8939. var source = errorInfo.source;
  8940. var stack = errorInfo.stack;
  8941. if (stack === null) {
  8942. stack = getStackAddendumByWorkInProgressFiber(source);
  8943. }
  8944. var capturedError = {
  8945. componentName: source !== null ? getComponentName(source) : null,
  8946. componentStack: stack !== null ? stack : '',
  8947. error: errorInfo.value,
  8948. errorBoundary: null,
  8949. errorBoundaryName: null,
  8950. errorBoundaryFound: false,
  8951. willRetry: false
  8952. };
  8953. if (boundary !== null && boundary.tag === ClassComponent) {
  8954. capturedError.errorBoundary = boundary.stateNode;
  8955. capturedError.errorBoundaryName = getComponentName(boundary);
  8956. capturedError.errorBoundaryFound = true;
  8957. capturedError.willRetry = true;
  8958. }
  8959. try {
  8960. logCapturedError(capturedError);
  8961. } catch (e) {
  8962. // Prevent cycle if logCapturedError() throws.
  8963. // A cycle may still occur if logCapturedError renders a component that throws.
  8964. var suppressLogging = e && e.suppressReactErrorLogging;
  8965. if (!suppressLogging) {
  8966. console.error(e);
  8967. }
  8968. }
  8969. }
  8970. var ReactFiberCommitWork = function (config, captureError, scheduleWork, computeExpirationForFiber, markLegacyErrorBoundaryAsFailed, recalculateCurrentTime) {
  8971. var getPublicInstance = config.getPublicInstance,
  8972. mutation = config.mutation,
  8973. persistence = config.persistence;
  8974. var callComponentWillUnmountWithTimer = function (current, instance) {
  8975. startPhaseTimer(current, 'componentWillUnmount');
  8976. instance.props = current.memoizedProps;
  8977. instance.state = current.memoizedState;
  8978. instance.componentWillUnmount();
  8979. stopPhaseTimer();
  8980. };
  8981. // Capture errors so they don't interrupt unmounting.
  8982. function safelyCallComponentWillUnmount(current, instance) {
  8983. {
  8984. invokeGuardedCallback$3(null, callComponentWillUnmountWithTimer, null, current, instance);
  8985. if (hasCaughtError$1()) {
  8986. var unmountError = clearCaughtError$1();
  8987. captureError(current, unmountError);
  8988. }
  8989. }
  8990. }
  8991. function safelyDetachRef(current) {
  8992. var ref = current.ref;
  8993. if (ref !== null) {
  8994. if (typeof ref === 'function') {
  8995. {
  8996. invokeGuardedCallback$3(null, ref, null, null);
  8997. if (hasCaughtError$1()) {
  8998. var refError = clearCaughtError$1();
  8999. captureError(current, refError);
  9000. }
  9001. }
  9002. } else {
  9003. ref.current = null;
  9004. }
  9005. }
  9006. }
  9007. function commitBeforeMutationLifeCycles(current, finishedWork) {
  9008. switch (finishedWork.tag) {
  9009. case ClassComponent:
  9010. {
  9011. if (finishedWork.effectTag & Snapshot) {
  9012. if (current !== null) {
  9013. var prevProps = current.memoizedProps;
  9014. var prevState = current.memoizedState;
  9015. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  9016. var _instance = finishedWork.stateNode;
  9017. _instance.props = finishedWork.memoizedProps;
  9018. _instance.state = finishedWork.memoizedState;
  9019. var snapshot = _instance.getSnapshotBeforeUpdate(prevProps, prevState);
  9020. {
  9021. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  9022. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  9023. didWarnSet.add(finishedWork.type);
  9024. warning_1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork));
  9025. }
  9026. }
  9027. _instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  9028. stopPhaseTimer();
  9029. }
  9030. }
  9031. return;
  9032. }
  9033. case HostRoot:
  9034. case HostComponent:
  9035. case HostText:
  9036. case HostPortal:
  9037. // Nothing to do for these component types
  9038. return;
  9039. default:
  9040. {
  9041. invariant_1(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  9042. }
  9043. }
  9044. }
  9045. function commitLifeCycles(finishedRoot, current, finishedWork, currentTime, committedExpirationTime) {
  9046. switch (finishedWork.tag) {
  9047. case ClassComponent:
  9048. {
  9049. var _instance2 = finishedWork.stateNode;
  9050. if (finishedWork.effectTag & Update) {
  9051. if (current === null) {
  9052. startPhaseTimer(finishedWork, 'componentDidMount');
  9053. _instance2.props = finishedWork.memoizedProps;
  9054. _instance2.state = finishedWork.memoizedState;
  9055. _instance2.componentDidMount();
  9056. stopPhaseTimer();
  9057. } else {
  9058. var prevProps = current.memoizedProps;
  9059. var prevState = current.memoizedState;
  9060. startPhaseTimer(finishedWork, 'componentDidUpdate');
  9061. _instance2.props = finishedWork.memoizedProps;
  9062. _instance2.state = finishedWork.memoizedState;
  9063. _instance2.componentDidUpdate(prevProps, prevState, _instance2.__reactInternalSnapshotBeforeUpdate);
  9064. stopPhaseTimer();
  9065. }
  9066. }
  9067. var updateQueue = finishedWork.updateQueue;
  9068. if (updateQueue !== null) {
  9069. commitCallbacks(updateQueue, _instance2);
  9070. }
  9071. return;
  9072. }
  9073. case HostRoot:
  9074. {
  9075. var _updateQueue = finishedWork.updateQueue;
  9076. if (_updateQueue !== null) {
  9077. var _instance3 = null;
  9078. if (finishedWork.child !== null) {
  9079. switch (finishedWork.child.tag) {
  9080. case HostComponent:
  9081. _instance3 = getPublicInstance(finishedWork.child.stateNode);
  9082. break;
  9083. case ClassComponent:
  9084. _instance3 = finishedWork.child.stateNode;
  9085. break;
  9086. }
  9087. }
  9088. commitCallbacks(_updateQueue, _instance3);
  9089. }
  9090. return;
  9091. }
  9092. case HostComponent:
  9093. {
  9094. var _instance4 = finishedWork.stateNode;
  9095. // Renderers may schedule work to be done after host components are mounted
  9096. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  9097. // These effects should only be committed when components are first mounted,
  9098. // aka when there is no current/alternate.
  9099. if (current === null && finishedWork.effectTag & Update) {
  9100. var type = finishedWork.type;
  9101. var props = finishedWork.memoizedProps;
  9102. commitMount(_instance4, type, props, finishedWork);
  9103. }
  9104. return;
  9105. }
  9106. case HostText:
  9107. {
  9108. // We have no life-cycles associated with text.
  9109. return;
  9110. }
  9111. case HostPortal:
  9112. {
  9113. // We have no life-cycles associated with portals.
  9114. return;
  9115. }
  9116. default:
  9117. {
  9118. invariant_1(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  9119. }
  9120. }
  9121. }
  9122. function commitErrorLogging(finishedWork, onUncaughtError) {
  9123. switch (finishedWork.tag) {
  9124. case ClassComponent:
  9125. {
  9126. var ctor = finishedWork.type;
  9127. var _instance5 = finishedWork.stateNode;
  9128. var updateQueue = finishedWork.updateQueue;
  9129. !(updateQueue !== null && updateQueue.capturedValues !== null) ? invariant_1(false, 'An error logging effect should not have been scheduled if no errors were captured. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  9130. var capturedErrors = updateQueue.capturedValues;
  9131. updateQueue.capturedValues = null;
  9132. if (typeof ctor.getDerivedStateFromCatch !== 'function') {
  9133. // To preserve the preexisting retry behavior of error boundaries,
  9134. // we keep track of which ones already failed during this batch.
  9135. // This gets reset before we yield back to the browser.
  9136. // TODO: Warn in strict mode if getDerivedStateFromCatch is
  9137. // not defined.
  9138. markLegacyErrorBoundaryAsFailed(_instance5);
  9139. }
  9140. _instance5.props = finishedWork.memoizedProps;
  9141. _instance5.state = finishedWork.memoizedState;
  9142. for (var i = 0; i < capturedErrors.length; i++) {
  9143. var errorInfo = capturedErrors[i];
  9144. var _error = errorInfo.value;
  9145. var stack = errorInfo.stack;
  9146. logError(finishedWork, errorInfo);
  9147. _instance5.componentDidCatch(_error, {
  9148. componentStack: stack !== null ? stack : ''
  9149. });
  9150. }
  9151. }
  9152. break;
  9153. case HostRoot:
  9154. {
  9155. var _updateQueue2 = finishedWork.updateQueue;
  9156. !(_updateQueue2 !== null && _updateQueue2.capturedValues !== null) ? invariant_1(false, 'An error logging effect should not have been scheduled if no errors were captured. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  9157. var _capturedErrors = _updateQueue2.capturedValues;
  9158. _updateQueue2.capturedValues = null;
  9159. for (var _i = 0; _i < _capturedErrors.length; _i++) {
  9160. var _errorInfo = _capturedErrors[_i];
  9161. logError(finishedWork, _errorInfo);
  9162. onUncaughtError(_errorInfo.value);
  9163. }
  9164. break;
  9165. }
  9166. default:
  9167. invariant_1(false, 'This unit of work tag cannot capture errors. This error is likely caused by a bug in React. Please file an issue.');
  9168. }
  9169. }
  9170. function commitAttachRef(finishedWork) {
  9171. var ref = finishedWork.ref;
  9172. if (ref !== null) {
  9173. var _instance6 = finishedWork.stateNode;
  9174. var instanceToUse = void 0;
  9175. switch (finishedWork.tag) {
  9176. case HostComponent:
  9177. instanceToUse = getPublicInstance(_instance6);
  9178. break;
  9179. default:
  9180. instanceToUse = _instance6;
  9181. }
  9182. if (typeof ref === 'function') {
  9183. ref(instanceToUse);
  9184. } else {
  9185. {
  9186. if (!ref.hasOwnProperty('current')) {
  9187. warning_1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork), getStackAddendumByWorkInProgressFiber(finishedWork));
  9188. }
  9189. }
  9190. ref.current = instanceToUse;
  9191. }
  9192. }
  9193. }
  9194. function commitDetachRef(current) {
  9195. var currentRef = current.ref;
  9196. if (currentRef !== null) {
  9197. if (typeof currentRef === 'function') {
  9198. currentRef(null);
  9199. } else {
  9200. currentRef.current = null;
  9201. }
  9202. }
  9203. }
  9204. // User-originating errors (lifecycles and refs) should not interrupt
  9205. // deletion, so don't let them throw. Host-originating errors should
  9206. // interrupt deletion, so it's okay
  9207. function commitUnmount(current) {
  9208. if (typeof onCommitUnmount === 'function') {
  9209. onCommitUnmount(current);
  9210. }
  9211. switch (current.tag) {
  9212. case ClassComponent:
  9213. {
  9214. safelyDetachRef(current);
  9215. var _instance7 = current.stateNode;
  9216. if (typeof _instance7.componentWillUnmount === 'function') {
  9217. safelyCallComponentWillUnmount(current, _instance7);
  9218. }
  9219. return;
  9220. }
  9221. case HostComponent:
  9222. {
  9223. safelyDetachRef(current);
  9224. return;
  9225. }
  9226. case CallComponent:
  9227. {
  9228. commitNestedUnmounts(current.stateNode);
  9229. return;
  9230. }
  9231. case HostPortal:
  9232. {
  9233. // TODO: this is recursive.
  9234. // We are also not using this parent because
  9235. // the portal will get pushed immediately.
  9236. if (enableMutatingReconciler && mutation) {
  9237. unmountHostComponents(current);
  9238. } else if (enablePersistentReconciler && persistence) {
  9239. emptyPortalContainer(current);
  9240. }
  9241. return;
  9242. }
  9243. }
  9244. }
  9245. function commitNestedUnmounts(root) {
  9246. // While we're inside a removed host node we don't want to call
  9247. // removeChild on the inner nodes because they're removed by the top
  9248. // call anyway. We also want to call componentWillUnmount on all
  9249. // composites before this host node is removed from the tree. Therefore
  9250. var node = root;
  9251. while (true) {
  9252. commitUnmount(node);
  9253. // Visit children because they may contain more composite or host nodes.
  9254. // Skip portals because commitUnmount() currently visits them recursively.
  9255. if (node.child !== null && (
  9256. // If we use mutation we drill down into portals using commitUnmount above.
  9257. // If we don't use mutation we drill down into portals here instead.
  9258. !mutation || node.tag !== HostPortal)) {
  9259. node.child['return'] = node;
  9260. node = node.child;
  9261. continue;
  9262. }
  9263. if (node === root) {
  9264. return;
  9265. }
  9266. while (node.sibling === null) {
  9267. if (node['return'] === null || node['return'] === root) {
  9268. return;
  9269. }
  9270. node = node['return'];
  9271. }
  9272. node.sibling['return'] = node['return'];
  9273. node = node.sibling;
  9274. }
  9275. }
  9276. function detachFiber(current) {
  9277. // Cut off the return pointers to disconnect it from the tree. Ideally, we
  9278. // should clear the child pointer of the parent alternate to let this
  9279. // get GC:ed but we don't know which for sure which parent is the current
  9280. // one so we'll settle for GC:ing the subtree of this child. This child
  9281. // itself will be GC:ed when the parent updates the next time.
  9282. current['return'] = null;
  9283. current.child = null;
  9284. if (current.alternate) {
  9285. current.alternate.child = null;
  9286. current.alternate['return'] = null;
  9287. }
  9288. }
  9289. var emptyPortalContainer = void 0;
  9290. if (!mutation) {
  9291. var commitContainer = void 0;
  9292. if (persistence) {
  9293. var replaceContainerChildren = persistence.replaceContainerChildren,
  9294. createContainerChildSet = persistence.createContainerChildSet;
  9295. emptyPortalContainer = function (current) {
  9296. var portal = current.stateNode;
  9297. var containerInfo = portal.containerInfo;
  9298. var emptyChildSet = createContainerChildSet(containerInfo);
  9299. replaceContainerChildren(containerInfo, emptyChildSet);
  9300. };
  9301. commitContainer = function (finishedWork) {
  9302. switch (finishedWork.tag) {
  9303. case ClassComponent:
  9304. {
  9305. return;
  9306. }
  9307. case HostComponent:
  9308. {
  9309. return;
  9310. }
  9311. case HostText:
  9312. {
  9313. return;
  9314. }
  9315. case HostRoot:
  9316. case HostPortal:
  9317. {
  9318. var portalOrRoot = finishedWork.stateNode;
  9319. var containerInfo = portalOrRoot.containerInfo,
  9320. _pendingChildren = portalOrRoot.pendingChildren;
  9321. replaceContainerChildren(containerInfo, _pendingChildren);
  9322. return;
  9323. }
  9324. default:
  9325. {
  9326. invariant_1(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  9327. }
  9328. }
  9329. };
  9330. } else {
  9331. commitContainer = function (finishedWork) {
  9332. // Noop
  9333. };
  9334. }
  9335. if (enablePersistentReconciler || enableNoopReconciler) {
  9336. return {
  9337. commitResetTextContent: function (finishedWork) {},
  9338. commitPlacement: function (finishedWork) {},
  9339. commitDeletion: function (current) {
  9340. // Detach refs and call componentWillUnmount() on the whole subtree.
  9341. commitNestedUnmounts(current);
  9342. detachFiber(current);
  9343. },
  9344. commitWork: function (current, finishedWork) {
  9345. commitContainer(finishedWork);
  9346. },
  9347. commitLifeCycles: commitLifeCycles,
  9348. commitBeforeMutationLifeCycles: commitBeforeMutationLifeCycles,
  9349. commitErrorLogging: commitErrorLogging,
  9350. commitAttachRef: commitAttachRef,
  9351. commitDetachRef: commitDetachRef
  9352. };
  9353. } else if (persistence) {
  9354. invariant_1(false, 'Persistent reconciler is disabled.');
  9355. } else {
  9356. invariant_1(false, 'Noop reconciler is disabled.');
  9357. }
  9358. }
  9359. var commitMount = mutation.commitMount,
  9360. commitUpdate = mutation.commitUpdate,
  9361. resetTextContent = mutation.resetTextContent,
  9362. commitTextUpdate = mutation.commitTextUpdate,
  9363. appendChild = mutation.appendChild,
  9364. appendChildToContainer = mutation.appendChildToContainer,
  9365. insertBefore = mutation.insertBefore,
  9366. insertInContainerBefore = mutation.insertInContainerBefore,
  9367. removeChild = mutation.removeChild,
  9368. removeChildFromContainer = mutation.removeChildFromContainer;
  9369. function getHostParentFiber(fiber) {
  9370. var parent = fiber['return'];
  9371. while (parent !== null) {
  9372. if (isHostParent(parent)) {
  9373. return parent;
  9374. }
  9375. parent = parent['return'];
  9376. }
  9377. invariant_1(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.');
  9378. }
  9379. function isHostParent(fiber) {
  9380. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  9381. }
  9382. function getHostSibling(fiber) {
  9383. // We're going to search forward into the tree until we find a sibling host
  9384. // node. Unfortunately, if multiple insertions are done in a row we have to
  9385. // search past them. This leads to exponential search for the next sibling.
  9386. var node = fiber;
  9387. siblings: while (true) {
  9388. // If we didn't find anything, let's try the next sibling.
  9389. while (node.sibling === null) {
  9390. if (node['return'] === null || isHostParent(node['return'])) {
  9391. // If we pop out of the root or hit the parent the fiber we are the
  9392. // last sibling.
  9393. return null;
  9394. }
  9395. node = node['return'];
  9396. }
  9397. node.sibling['return'] = node['return'];
  9398. node = node.sibling;
  9399. while (node.tag !== HostComponent && node.tag !== HostText) {
  9400. // If it is not host node and, we might have a host node inside it.
  9401. // Try to search down until we find one.
  9402. if (node.effectTag & Placement) {
  9403. // If we don't have a child, try the siblings instead.
  9404. continue siblings;
  9405. }
  9406. // If we don't have a child, try the siblings instead.
  9407. // We also skip portals because they are not part of this host tree.
  9408. if (node.child === null || node.tag === HostPortal) {
  9409. continue siblings;
  9410. } else {
  9411. node.child['return'] = node;
  9412. node = node.child;
  9413. }
  9414. }
  9415. // Check if this host node is stable or about to be placed.
  9416. if (!(node.effectTag & Placement)) {
  9417. // Found it!
  9418. return node.stateNode;
  9419. }
  9420. }
  9421. }
  9422. function commitPlacement(finishedWork) {
  9423. // Recursively insert all host nodes into the parent.
  9424. var parentFiber = getHostParentFiber(finishedWork);
  9425. var parent = void 0;
  9426. var isContainer = void 0;
  9427. switch (parentFiber.tag) {
  9428. case HostComponent:
  9429. parent = parentFiber.stateNode;
  9430. isContainer = false;
  9431. break;
  9432. case HostRoot:
  9433. parent = parentFiber.stateNode.containerInfo;
  9434. isContainer = true;
  9435. break;
  9436. case HostPortal:
  9437. parent = parentFiber.stateNode.containerInfo;
  9438. isContainer = true;
  9439. break;
  9440. default:
  9441. invariant_1(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
  9442. }
  9443. if (parentFiber.effectTag & ContentReset) {
  9444. // Reset the text content of the parent before doing any insertions
  9445. resetTextContent(parent);
  9446. // Clear ContentReset from the effect tag
  9447. parentFiber.effectTag &= ~ContentReset;
  9448. }
  9449. var before = getHostSibling(finishedWork);
  9450. // We only have the top Fiber that was inserted but we need recurse down its
  9451. // children to find all the terminal nodes.
  9452. var node = finishedWork;
  9453. while (true) {
  9454. if (node.tag === HostComponent || node.tag === HostText) {
  9455. if (before) {
  9456. if (isContainer) {
  9457. insertInContainerBefore(parent, node.stateNode, before);
  9458. } else {
  9459. insertBefore(parent, node.stateNode, before);
  9460. }
  9461. } else {
  9462. if (isContainer) {
  9463. appendChildToContainer(parent, node.stateNode);
  9464. } else {
  9465. appendChild(parent, node.stateNode);
  9466. }
  9467. }
  9468. } else if (node.tag === HostPortal) {
  9469. // If the insertion itself is a portal, then we don't want to traverse
  9470. // down its children. Instead, we'll get insertions from each child in
  9471. // the portal directly.
  9472. } else if (node.child !== null) {
  9473. node.child['return'] = node;
  9474. node = node.child;
  9475. continue;
  9476. }
  9477. if (node === finishedWork) {
  9478. return;
  9479. }
  9480. while (node.sibling === null) {
  9481. if (node['return'] === null || node['return'] === finishedWork) {
  9482. return;
  9483. }
  9484. node = node['return'];
  9485. }
  9486. node.sibling['return'] = node['return'];
  9487. node = node.sibling;
  9488. }
  9489. }
  9490. function unmountHostComponents(current) {
  9491. // We only have the top Fiber that was inserted but we need recurse down its
  9492. var node = current;
  9493. // Each iteration, currentParent is populated with node's host parent if not
  9494. // currentParentIsValid.
  9495. var currentParentIsValid = false;
  9496. var currentParent = void 0;
  9497. var currentParentIsContainer = void 0;
  9498. while (true) {
  9499. if (!currentParentIsValid) {
  9500. var parent = node['return'];
  9501. findParent: while (true) {
  9502. !(parent !== null) ? invariant_1(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  9503. switch (parent.tag) {
  9504. case HostComponent:
  9505. currentParent = parent.stateNode;
  9506. currentParentIsContainer = false;
  9507. break findParent;
  9508. case HostRoot:
  9509. currentParent = parent.stateNode.containerInfo;
  9510. currentParentIsContainer = true;
  9511. break findParent;
  9512. case HostPortal:
  9513. currentParent = parent.stateNode.containerInfo;
  9514. currentParentIsContainer = true;
  9515. break findParent;
  9516. }
  9517. parent = parent['return'];
  9518. }
  9519. currentParentIsValid = true;
  9520. }
  9521. if (node.tag === HostComponent || node.tag === HostText) {
  9522. commitNestedUnmounts(node);
  9523. // After all the children have unmounted, it is now safe to remove the
  9524. // node from the tree.
  9525. if (currentParentIsContainer) {
  9526. removeChildFromContainer(currentParent, node.stateNode);
  9527. } else {
  9528. removeChild(currentParent, node.stateNode);
  9529. }
  9530. // Don't visit children because we already visited them.
  9531. } else if (node.tag === HostPortal) {
  9532. // When we go into a portal, it becomes the parent to remove from.
  9533. // We will reassign it back when we pop the portal on the way up.
  9534. currentParent = node.stateNode.containerInfo;
  9535. // Visit children because portals might contain host components.
  9536. if (node.child !== null) {
  9537. node.child['return'] = node;
  9538. node = node.child;
  9539. continue;
  9540. }
  9541. } else {
  9542. commitUnmount(node);
  9543. // Visit children because we may find more host components below.
  9544. if (node.child !== null) {
  9545. node.child['return'] = node;
  9546. node = node.child;
  9547. continue;
  9548. }
  9549. }
  9550. if (node === current) {
  9551. return;
  9552. }
  9553. while (node.sibling === null) {
  9554. if (node['return'] === null || node['return'] === current) {
  9555. return;
  9556. }
  9557. node = node['return'];
  9558. if (node.tag === HostPortal) {
  9559. // When we go out of the portal, we need to restore the parent.
  9560. // Since we don't keep a stack of them, we will search for it.
  9561. currentParentIsValid = false;
  9562. }
  9563. }
  9564. node.sibling['return'] = node['return'];
  9565. node = node.sibling;
  9566. }
  9567. }
  9568. function commitDeletion(current) {
  9569. // Recursively delete all host nodes from the parent.
  9570. // Detach refs and call componentWillUnmount() on the whole subtree.
  9571. unmountHostComponents(current);
  9572. detachFiber(current);
  9573. }
  9574. function commitWork(current, finishedWork) {
  9575. switch (finishedWork.tag) {
  9576. case ClassComponent:
  9577. {
  9578. return;
  9579. }
  9580. case HostComponent:
  9581. {
  9582. var _instance8 = finishedWork.stateNode;
  9583. if (_instance8 != null) {
  9584. // Commit the work prepared earlier.
  9585. var newProps = finishedWork.memoizedProps;
  9586. // For hydration we reuse the update path but we treat the oldProps
  9587. // as the newProps. The updatePayload will contain the real change in
  9588. // this case.
  9589. var oldProps = current !== null ? current.memoizedProps : newProps;
  9590. var type = finishedWork.type;
  9591. // TODO: Type the updateQueue to be specific to host components.
  9592. var updatePayload = finishedWork.updateQueue;
  9593. finishedWork.updateQueue = null;
  9594. if (updatePayload !== null) {
  9595. commitUpdate(_instance8, updatePayload, type, oldProps, newProps, finishedWork);
  9596. }
  9597. }
  9598. return;
  9599. }
  9600. case HostText:
  9601. {
  9602. !(finishedWork.stateNode !== null) ? invariant_1(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  9603. var textInstance = finishedWork.stateNode;
  9604. var newText = finishedWork.memoizedProps;
  9605. // For hydration we reuse the update path but we treat the oldProps
  9606. // as the newProps. The updatePayload will contain the real change in
  9607. // this case.
  9608. var oldText = current !== null ? current.memoizedProps : newText;
  9609. commitTextUpdate(textInstance, oldText, newText);
  9610. return;
  9611. }
  9612. case HostRoot:
  9613. {
  9614. return;
  9615. }
  9616. default:
  9617. {
  9618. invariant_1(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  9619. }
  9620. }
  9621. }
  9622. function commitResetTextContent(current) {
  9623. resetTextContent(current.stateNode);
  9624. }
  9625. if (enableMutatingReconciler) {
  9626. return {
  9627. commitBeforeMutationLifeCycles: commitBeforeMutationLifeCycles,
  9628. commitResetTextContent: commitResetTextContent,
  9629. commitPlacement: commitPlacement,
  9630. commitDeletion: commitDeletion,
  9631. commitWork: commitWork,
  9632. commitLifeCycles: commitLifeCycles,
  9633. commitErrorLogging: commitErrorLogging,
  9634. commitAttachRef: commitAttachRef,
  9635. commitDetachRef: commitDetachRef
  9636. };
  9637. } else {
  9638. invariant_1(false, 'Mutating reconciler is disabled.');
  9639. }
  9640. };
  9641. var NO_CONTEXT = {};
  9642. var ReactFiberHostContext = function (config, stack) {
  9643. var getChildHostContext = config.getChildHostContext,
  9644. getRootHostContext = config.getRootHostContext;
  9645. var createCursor = stack.createCursor,
  9646. push = stack.push,
  9647. pop = stack.pop;
  9648. var contextStackCursor = createCursor(NO_CONTEXT);
  9649. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  9650. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  9651. function requiredContext(c) {
  9652. !(c !== NO_CONTEXT) ? invariant_1(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  9653. return c;
  9654. }
  9655. function getRootHostContainer() {
  9656. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  9657. return rootInstance;
  9658. }
  9659. function pushHostContainer(fiber, nextRootInstance) {
  9660. // Push current root instance onto the stack;
  9661. // This allows us to reset root when portals are popped.
  9662. push(rootInstanceStackCursor, nextRootInstance, fiber);
  9663. // Track the context and the Fiber that provided it.
  9664. // This enables us to pop only Fibers that provide unique contexts.
  9665. push(contextFiberStackCursor, fiber, fiber);
  9666. // Finally, we need to push the host context to the stack.
  9667. // However, we can't just call getRootHostContext() and push it because
  9668. // we'd have a different number of entries on the stack depending on
  9669. // whether getRootHostContext() throws somewhere in renderer code or not.
  9670. // So we push an empty value first. This lets us safely unwind on errors.
  9671. push(contextStackCursor, NO_CONTEXT, fiber);
  9672. var nextRootContext = getRootHostContext(nextRootInstance);
  9673. // Now that we know this function doesn't throw, replace it.
  9674. pop(contextStackCursor, fiber);
  9675. push(contextStackCursor, nextRootContext, fiber);
  9676. }
  9677. function popHostContainer(fiber) {
  9678. pop(contextStackCursor, fiber);
  9679. pop(contextFiberStackCursor, fiber);
  9680. pop(rootInstanceStackCursor, fiber);
  9681. }
  9682. function getHostContext() {
  9683. var context = requiredContext(contextStackCursor.current);
  9684. return context;
  9685. }
  9686. function pushHostContext(fiber) {
  9687. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  9688. var context = requiredContext(contextStackCursor.current);
  9689. var nextContext = getChildHostContext(context, fiber.type, rootInstance);
  9690. // Don't push this Fiber's context unless it's unique.
  9691. if (context === nextContext) {
  9692. return;
  9693. }
  9694. // Track the context and the Fiber that provided it.
  9695. // This enables us to pop only Fibers that provide unique contexts.
  9696. push(contextFiberStackCursor, fiber, fiber);
  9697. push(contextStackCursor, nextContext, fiber);
  9698. }
  9699. function popHostContext(fiber) {
  9700. // Do not pop unless this Fiber provided the current context.
  9701. // pushHostContext() only pushes Fibers that provide unique contexts.
  9702. if (contextFiberStackCursor.current !== fiber) {
  9703. return;
  9704. }
  9705. pop(contextStackCursor, fiber);
  9706. pop(contextFiberStackCursor, fiber);
  9707. }
  9708. return {
  9709. getHostContext: getHostContext,
  9710. getRootHostContainer: getRootHostContainer,
  9711. popHostContainer: popHostContainer,
  9712. popHostContext: popHostContext,
  9713. pushHostContainer: pushHostContainer,
  9714. pushHostContext: pushHostContext
  9715. };
  9716. };
  9717. var ReactFiberHydrationContext = function (config) {
  9718. var shouldSetTextContent = config.shouldSetTextContent,
  9719. hydration = config.hydration;
  9720. // If this doesn't have hydration mode.
  9721. if (!hydration) {
  9722. return {
  9723. enterHydrationState: function () {
  9724. return false;
  9725. },
  9726. resetHydrationState: function () {},
  9727. tryToClaimNextHydratableInstance: function () {},
  9728. prepareToHydrateHostInstance: function () {
  9729. invariant_1(false, 'Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
  9730. },
  9731. prepareToHydrateHostTextInstance: function () {
  9732. invariant_1(false, 'Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
  9733. },
  9734. popHydrationState: function (fiber) {
  9735. return false;
  9736. }
  9737. };
  9738. }
  9739. var canHydrateInstance = hydration.canHydrateInstance,
  9740. canHydrateTextInstance = hydration.canHydrateTextInstance,
  9741. getNextHydratableSibling = hydration.getNextHydratableSibling,
  9742. getFirstHydratableChild = hydration.getFirstHydratableChild,
  9743. hydrateInstance = hydration.hydrateInstance,
  9744. hydrateTextInstance = hydration.hydrateTextInstance,
  9745. didNotMatchHydratedContainerTextInstance = hydration.didNotMatchHydratedContainerTextInstance,
  9746. didNotMatchHydratedTextInstance = hydration.didNotMatchHydratedTextInstance,
  9747. didNotHydrateContainerInstance = hydration.didNotHydrateContainerInstance,
  9748. didNotHydrateInstance = hydration.didNotHydrateInstance,
  9749. didNotFindHydratableContainerInstance = hydration.didNotFindHydratableContainerInstance,
  9750. didNotFindHydratableContainerTextInstance = hydration.didNotFindHydratableContainerTextInstance,
  9751. didNotFindHydratableInstance = hydration.didNotFindHydratableInstance,
  9752. didNotFindHydratableTextInstance = hydration.didNotFindHydratableTextInstance;
  9753. // The deepest Fiber on the stack involved in a hydration context.
  9754. // This may have been an insertion or a hydration.
  9755. var hydrationParentFiber = null;
  9756. var nextHydratableInstance = null;
  9757. var isHydrating = false;
  9758. function enterHydrationState(fiber) {
  9759. var parentInstance = fiber.stateNode.containerInfo;
  9760. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  9761. hydrationParentFiber = fiber;
  9762. isHydrating = true;
  9763. return true;
  9764. }
  9765. function deleteHydratableInstance(returnFiber, instance) {
  9766. {
  9767. switch (returnFiber.tag) {
  9768. case HostRoot:
  9769. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  9770. break;
  9771. case HostComponent:
  9772. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  9773. break;
  9774. }
  9775. }
  9776. var childToDelete = createFiberFromHostInstanceForDeletion();
  9777. childToDelete.stateNode = instance;
  9778. childToDelete['return'] = returnFiber;
  9779. childToDelete.effectTag = Deletion;
  9780. // This might seem like it belongs on progressedFirstDeletion. However,
  9781. // these children are not part of the reconciliation list of children.
  9782. // Even if we abort and rereconcile the children, that will try to hydrate
  9783. // again and the nodes are still in the host tree so these will be
  9784. // recreated.
  9785. if (returnFiber.lastEffect !== null) {
  9786. returnFiber.lastEffect.nextEffect = childToDelete;
  9787. returnFiber.lastEffect = childToDelete;
  9788. } else {
  9789. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  9790. }
  9791. }
  9792. function insertNonHydratedInstance(returnFiber, fiber) {
  9793. fiber.effectTag |= Placement;
  9794. {
  9795. switch (returnFiber.tag) {
  9796. case HostRoot:
  9797. {
  9798. var parentContainer = returnFiber.stateNode.containerInfo;
  9799. switch (fiber.tag) {
  9800. case HostComponent:
  9801. var type = fiber.type;
  9802. var props = fiber.pendingProps;
  9803. didNotFindHydratableContainerInstance(parentContainer, type, props);
  9804. break;
  9805. case HostText:
  9806. var text = fiber.pendingProps;
  9807. didNotFindHydratableContainerTextInstance(parentContainer, text);
  9808. break;
  9809. }
  9810. break;
  9811. }
  9812. case HostComponent:
  9813. {
  9814. var parentType = returnFiber.type;
  9815. var parentProps = returnFiber.memoizedProps;
  9816. var parentInstance = returnFiber.stateNode;
  9817. switch (fiber.tag) {
  9818. case HostComponent:
  9819. var _type = fiber.type;
  9820. var _props = fiber.pendingProps;
  9821. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
  9822. break;
  9823. case HostText:
  9824. var _text = fiber.pendingProps;
  9825. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  9826. break;
  9827. }
  9828. break;
  9829. }
  9830. default:
  9831. return;
  9832. }
  9833. }
  9834. }
  9835. function tryHydrate(fiber, nextInstance) {
  9836. switch (fiber.tag) {
  9837. case HostComponent:
  9838. {
  9839. var type = fiber.type;
  9840. var props = fiber.pendingProps;
  9841. var instance = canHydrateInstance(nextInstance, type, props);
  9842. if (instance !== null) {
  9843. fiber.stateNode = instance;
  9844. return true;
  9845. }
  9846. return false;
  9847. }
  9848. case HostText:
  9849. {
  9850. var text = fiber.pendingProps;
  9851. var textInstance = canHydrateTextInstance(nextInstance, text);
  9852. if (textInstance !== null) {
  9853. fiber.stateNode = textInstance;
  9854. return true;
  9855. }
  9856. return false;
  9857. }
  9858. default:
  9859. return false;
  9860. }
  9861. }
  9862. function tryToClaimNextHydratableInstance(fiber) {
  9863. if (!isHydrating) {
  9864. return;
  9865. }
  9866. var nextInstance = nextHydratableInstance;
  9867. if (!nextInstance) {
  9868. // Nothing to hydrate. Make it an insertion.
  9869. insertNonHydratedInstance(hydrationParentFiber, fiber);
  9870. isHydrating = false;
  9871. hydrationParentFiber = fiber;
  9872. return;
  9873. }
  9874. if (!tryHydrate(fiber, nextInstance)) {
  9875. // If we can't hydrate this instance let's try the next one.
  9876. // We use this as a heuristic. It's based on intuition and not data so it
  9877. // might be flawed or unnecessary.
  9878. nextInstance = getNextHydratableSibling(nextInstance);
  9879. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  9880. // Nothing to hydrate. Make it an insertion.
  9881. insertNonHydratedInstance(hydrationParentFiber, fiber);
  9882. isHydrating = false;
  9883. hydrationParentFiber = fiber;
  9884. return;
  9885. }
  9886. // We matched the next one, we'll now assume that the first one was
  9887. // superfluous and we'll delete it. Since we can't eagerly delete it
  9888. // we'll have to schedule a deletion. To do that, this node needs a dummy
  9889. // fiber associated with it.
  9890. deleteHydratableInstance(hydrationParentFiber, nextHydratableInstance);
  9891. }
  9892. hydrationParentFiber = fiber;
  9893. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  9894. }
  9895. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  9896. var instance = fiber.stateNode;
  9897. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
  9898. // TODO: Type this specific to this type of component.
  9899. fiber.updateQueue = updatePayload;
  9900. // If the update payload indicates that there is a change or if there
  9901. // is a new ref we mark this as an update.
  9902. if (updatePayload !== null) {
  9903. return true;
  9904. }
  9905. return false;
  9906. }
  9907. function prepareToHydrateHostTextInstance(fiber) {
  9908. var textInstance = fiber.stateNode;
  9909. var textContent = fiber.memoizedProps;
  9910. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  9911. {
  9912. if (shouldUpdate) {
  9913. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  9914. // hydration parent is the parent host component of this host text.
  9915. var returnFiber = hydrationParentFiber;
  9916. if (returnFiber !== null) {
  9917. switch (returnFiber.tag) {
  9918. case HostRoot:
  9919. {
  9920. var parentContainer = returnFiber.stateNode.containerInfo;
  9921. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  9922. break;
  9923. }
  9924. case HostComponent:
  9925. {
  9926. var parentType = returnFiber.type;
  9927. var parentProps = returnFiber.memoizedProps;
  9928. var parentInstance = returnFiber.stateNode;
  9929. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  9930. break;
  9931. }
  9932. }
  9933. }
  9934. }
  9935. }
  9936. return shouldUpdate;
  9937. }
  9938. function popToNextHostParent(fiber) {
  9939. var parent = fiber['return'];
  9940. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
  9941. parent = parent['return'];
  9942. }
  9943. hydrationParentFiber = parent;
  9944. }
  9945. function popHydrationState(fiber) {
  9946. if (fiber !== hydrationParentFiber) {
  9947. // We're deeper than the current hydration context, inside an inserted
  9948. // tree.
  9949. return false;
  9950. }
  9951. if (!isHydrating) {
  9952. // If we're not currently hydrating but we're in a hydration context, then
  9953. // we were an insertion and now need to pop up reenter hydration of our
  9954. // siblings.
  9955. popToNextHostParent(fiber);
  9956. isHydrating = true;
  9957. return false;
  9958. }
  9959. var type = fiber.type;
  9960. // If we have any remaining hydratable nodes, we need to delete them now.
  9961. // We only do this deeper than head and body since they tend to have random
  9962. // other nodes in them. We also ignore components with pure text content in
  9963. // side of them.
  9964. // TODO: Better heuristic.
  9965. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  9966. var nextInstance = nextHydratableInstance;
  9967. while (nextInstance) {
  9968. deleteHydratableInstance(fiber, nextInstance);
  9969. nextInstance = getNextHydratableSibling(nextInstance);
  9970. }
  9971. }
  9972. popToNextHostParent(fiber);
  9973. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  9974. return true;
  9975. }
  9976. function resetHydrationState() {
  9977. hydrationParentFiber = null;
  9978. nextHydratableInstance = null;
  9979. isHydrating = false;
  9980. }
  9981. return {
  9982. enterHydrationState: enterHydrationState,
  9983. resetHydrationState: resetHydrationState,
  9984. tryToClaimNextHydratableInstance: tryToClaimNextHydratableInstance,
  9985. prepareToHydrateHostInstance: prepareToHydrateHostInstance,
  9986. prepareToHydrateHostTextInstance: prepareToHydrateHostTextInstance,
  9987. popHydrationState: popHydrationState
  9988. };
  9989. };
  9990. // This lets us hook into Fiber to debug what it's doing.
  9991. // See https://github.com/facebook/react/pull/8033.
  9992. // This is not part of the public API, not even for React DevTools.
  9993. // You may only inject a debugTool if you work on React Fiber itself.
  9994. var ReactFiberInstrumentation = {
  9995. debugTool: null
  9996. };
  9997. var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
  9998. var warnedAboutMissingGetChildContext = void 0;
  9999. {
  10000. warnedAboutMissingGetChildContext = {};
  10001. }
  10002. var ReactFiberLegacyContext = function (stack) {
  10003. var createCursor = stack.createCursor,
  10004. push = stack.push,
  10005. pop = stack.pop;
  10006. // A cursor to the current merged context object on the stack.
  10007. var contextStackCursor = createCursor(emptyObject_1);
  10008. // A cursor to a boolean indicating whether the context has changed.
  10009. var didPerformWorkStackCursor = createCursor(false);
  10010. // Keep track of the previous context object that was on the stack.
  10011. // We use this to get access to the parent context after we have already
  10012. // pushed the next context provider, and now need to merge their contexts.
  10013. var previousContext = emptyObject_1;
  10014. function getUnmaskedContext(workInProgress) {
  10015. var hasOwnContext = isContextProvider(workInProgress);
  10016. if (hasOwnContext) {
  10017. // If the fiber is a context provider itself, when we read its context
  10018. // we have already pushed its own child context on the stack. A context
  10019. // provider should not "see" its own child context. Therefore we read the
  10020. // previous (parent) context instead for a context provider.
  10021. return previousContext;
  10022. }
  10023. return contextStackCursor.current;
  10024. }
  10025. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  10026. var instance = workInProgress.stateNode;
  10027. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  10028. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  10029. }
  10030. function getMaskedContext(workInProgress, unmaskedContext) {
  10031. var type = workInProgress.type;
  10032. var contextTypes = type.contextTypes;
  10033. if (!contextTypes) {
  10034. return emptyObject_1;
  10035. }
  10036. // Avoid recreating masked context unless unmasked context has changed.
  10037. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  10038. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  10039. var instance = workInProgress.stateNode;
  10040. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  10041. return instance.__reactInternalMemoizedMaskedChildContext;
  10042. }
  10043. var context = {};
  10044. for (var key in contextTypes) {
  10045. context[key] = unmaskedContext[key];
  10046. }
  10047. {
  10048. var name = getComponentName(workInProgress) || 'Unknown';
  10049. checkPropTypes_1(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
  10050. }
  10051. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  10052. // Context is created before the class component is instantiated so check for instance.
  10053. if (instance) {
  10054. cacheContext(workInProgress, unmaskedContext, context);
  10055. }
  10056. return context;
  10057. }
  10058. function hasContextChanged() {
  10059. return didPerformWorkStackCursor.current;
  10060. }
  10061. function isContextConsumer(fiber) {
  10062. return fiber.tag === ClassComponent && fiber.type.contextTypes != null;
  10063. }
  10064. function isContextProvider(fiber) {
  10065. return fiber.tag === ClassComponent && fiber.type.childContextTypes != null;
  10066. }
  10067. function popContextProvider(fiber) {
  10068. if (!isContextProvider(fiber)) {
  10069. return;
  10070. }
  10071. pop(didPerformWorkStackCursor, fiber);
  10072. pop(contextStackCursor, fiber);
  10073. }
  10074. function popTopLevelContextObject(fiber) {
  10075. pop(didPerformWorkStackCursor, fiber);
  10076. pop(contextStackCursor, fiber);
  10077. }
  10078. function pushTopLevelContextObject(fiber, context, didChange) {
  10079. !(contextStackCursor.cursor == null) ? invariant_1(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10080. push(contextStackCursor, context, fiber);
  10081. push(didPerformWorkStackCursor, didChange, fiber);
  10082. }
  10083. function processChildContext(fiber, parentContext) {
  10084. var instance = fiber.stateNode;
  10085. var childContextTypes = fiber.type.childContextTypes;
  10086. // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  10087. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  10088. if (typeof instance.getChildContext !== 'function') {
  10089. {
  10090. var componentName = getComponentName(fiber) || 'Unknown';
  10091. if (!warnedAboutMissingGetChildContext[componentName]) {
  10092. warnedAboutMissingGetChildContext[componentName] = true;
  10093. warning_1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
  10094. }
  10095. }
  10096. return parentContext;
  10097. }
  10098. var childContext = void 0;
  10099. {
  10100. ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
  10101. }
  10102. startPhaseTimer(fiber, 'getChildContext');
  10103. childContext = instance.getChildContext();
  10104. stopPhaseTimer();
  10105. {
  10106. ReactDebugCurrentFiber.setCurrentPhase(null);
  10107. }
  10108. for (var contextKey in childContext) {
  10109. !(contextKey in childContextTypes) ? invariant_1(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
  10110. }
  10111. {
  10112. var name = getComponentName(fiber) || 'Unknown';
  10113. checkPropTypes_1(childContextTypes, childContext, 'child context', name,
  10114. // In practice, there is one case in which we won't get a stack. It's when
  10115. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  10116. // context from the parent component instance. The stack will be missing
  10117. // because it's outside of the reconciliation, and so the pointer has not
  10118. // been set. This is rare and doesn't matter. We'll also remove that API.
  10119. ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
  10120. }
  10121. return _assign({}, parentContext, childContext);
  10122. }
  10123. function pushContextProvider(workInProgress) {
  10124. if (!isContextProvider(workInProgress)) {
  10125. return false;
  10126. }
  10127. var instance = workInProgress.stateNode;
  10128. // We push the context as early as possible to ensure stack integrity.
  10129. // If the instance does not exist yet, we will push null at first,
  10130. // and replace it on the stack later when invalidating the context.
  10131. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyObject_1;
  10132. // Remember the parent context so we can merge with it later.
  10133. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  10134. previousContext = contextStackCursor.current;
  10135. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  10136. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  10137. return true;
  10138. }
  10139. function invalidateContextProvider(workInProgress, didChange) {
  10140. var instance = workInProgress.stateNode;
  10141. !instance ? invariant_1(false, 'Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10142. if (didChange) {
  10143. // Merge parent and own context.
  10144. // Skip this if we're not updating due to sCU.
  10145. // This avoids unnecessarily recomputing memoized values.
  10146. var mergedContext = processChildContext(workInProgress, previousContext);
  10147. instance.__reactInternalMemoizedMergedChildContext = mergedContext;
  10148. // Replace the old (or empty) context with the new one.
  10149. // It is important to unwind the context in the reverse order.
  10150. pop(didPerformWorkStackCursor, workInProgress);
  10151. pop(contextStackCursor, workInProgress);
  10152. // Now push the new context and mark that it has changed.
  10153. push(contextStackCursor, mergedContext, workInProgress);
  10154. push(didPerformWorkStackCursor, didChange, workInProgress);
  10155. } else {
  10156. pop(didPerformWorkStackCursor, workInProgress);
  10157. push(didPerformWorkStackCursor, didChange, workInProgress);
  10158. }
  10159. }
  10160. function findCurrentUnmaskedContext(fiber) {
  10161. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  10162. // makes sense elsewhere
  10163. !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant_1(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10164. var node = fiber;
  10165. while (node.tag !== HostRoot) {
  10166. if (isContextProvider(node)) {
  10167. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  10168. }
  10169. var parent = node['return'];
  10170. !parent ? invariant_1(false, 'Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10171. node = parent;
  10172. }
  10173. return node.stateNode.context;
  10174. }
  10175. return {
  10176. getUnmaskedContext: getUnmaskedContext,
  10177. cacheContext: cacheContext,
  10178. getMaskedContext: getMaskedContext,
  10179. hasContextChanged: hasContextChanged,
  10180. isContextConsumer: isContextConsumer,
  10181. isContextProvider: isContextProvider,
  10182. popContextProvider: popContextProvider,
  10183. popTopLevelContextObject: popTopLevelContextObject,
  10184. pushTopLevelContextObject: pushTopLevelContextObject,
  10185. processChildContext: processChildContext,
  10186. pushContextProvider: pushContextProvider,
  10187. invalidateContextProvider: invalidateContextProvider,
  10188. findCurrentUnmaskedContext: findCurrentUnmaskedContext
  10189. };
  10190. };
  10191. var ReactFiberNewContext = function (stack) {
  10192. var createCursor = stack.createCursor,
  10193. push = stack.push,
  10194. pop = stack.pop;
  10195. var providerCursor = createCursor(null);
  10196. var valueCursor = createCursor(null);
  10197. var changedBitsCursor = createCursor(0);
  10198. var rendererSigil = void 0;
  10199. {
  10200. // Use this to detect multiple renderers using the same context
  10201. rendererSigil = {};
  10202. }
  10203. function pushProvider(providerFiber) {
  10204. var context = providerFiber.type._context;
  10205. push(changedBitsCursor, context._changedBits, providerFiber);
  10206. push(valueCursor, context._currentValue, providerFiber);
  10207. push(providerCursor, providerFiber, providerFiber);
  10208. context._currentValue = providerFiber.pendingProps.value;
  10209. context._changedBits = providerFiber.stateNode;
  10210. {
  10211. !(context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warning_1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
  10212. context._currentRenderer = rendererSigil;
  10213. }
  10214. }
  10215. function popProvider(providerFiber) {
  10216. var changedBits = changedBitsCursor.current;
  10217. var currentValue = valueCursor.current;
  10218. pop(providerCursor, providerFiber);
  10219. pop(valueCursor, providerFiber);
  10220. pop(changedBitsCursor, providerFiber);
  10221. var context = providerFiber.type._context;
  10222. context._currentValue = currentValue;
  10223. context._changedBits = changedBits;
  10224. }
  10225. return {
  10226. pushProvider: pushProvider,
  10227. popProvider: popProvider
  10228. };
  10229. };
  10230. var ReactFiberStack = function () {
  10231. var valueStack = [];
  10232. var fiberStack = void 0;
  10233. {
  10234. fiberStack = [];
  10235. }
  10236. var index = -1;
  10237. function createCursor(defaultValue) {
  10238. return {
  10239. current: defaultValue
  10240. };
  10241. }
  10242. function isEmpty() {
  10243. return index === -1;
  10244. }
  10245. function pop(cursor, fiber) {
  10246. if (index < 0) {
  10247. {
  10248. warning_1(false, 'Unexpected pop.');
  10249. }
  10250. return;
  10251. }
  10252. {
  10253. if (fiber !== fiberStack[index]) {
  10254. warning_1(false, 'Unexpected Fiber popped.');
  10255. }
  10256. }
  10257. cursor.current = valueStack[index];
  10258. valueStack[index] = null;
  10259. {
  10260. fiberStack[index] = null;
  10261. }
  10262. index--;
  10263. }
  10264. function push(cursor, value, fiber) {
  10265. index++;
  10266. valueStack[index] = cursor.current;
  10267. {
  10268. fiberStack[index] = fiber;
  10269. }
  10270. cursor.current = value;
  10271. }
  10272. function checkThatStackIsEmpty() {
  10273. {
  10274. if (index !== -1) {
  10275. warning_1(false, 'Expected an empty stack. Something was not reset properly.');
  10276. }
  10277. }
  10278. }
  10279. function resetStackAfterFatalErrorInDev() {
  10280. {
  10281. index = -1;
  10282. valueStack.length = 0;
  10283. fiberStack.length = 0;
  10284. }
  10285. }
  10286. return {
  10287. createCursor: createCursor,
  10288. isEmpty: isEmpty,
  10289. pop: pop,
  10290. push: push,
  10291. checkThatStackIsEmpty: checkThatStackIsEmpty,
  10292. resetStackAfterFatalErrorInDev: resetStackAfterFatalErrorInDev
  10293. };
  10294. };
  10295. var invokeGuardedCallback$2 = ReactErrorUtils.invokeGuardedCallback;
  10296. var hasCaughtError = ReactErrorUtils.hasCaughtError;
  10297. var clearCaughtError = ReactErrorUtils.clearCaughtError;
  10298. var didWarnAboutStateTransition = void 0;
  10299. var didWarnSetStateChildContext = void 0;
  10300. var warnAboutUpdateOnUnmounted = void 0;
  10301. var warnAboutInvalidUpdates = void 0;
  10302. {
  10303. didWarnAboutStateTransition = false;
  10304. didWarnSetStateChildContext = false;
  10305. var didWarnStateUpdateForUnmountedComponent = {};
  10306. warnAboutUpdateOnUnmounted = function (fiber) {
  10307. // We show the whole stack but dedupe on the top component's name because
  10308. // the problematic code almost always lies inside that component.
  10309. var componentName = getComponentName(fiber) || 'ReactClass';
  10310. if (didWarnStateUpdateForUnmountedComponent[componentName]) {
  10311. return;
  10312. }
  10313. warning_1(false, "Can't call setState (or forceUpdate) on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in the ' + 'componentWillUnmount method.%s', getStackAddendumByWorkInProgressFiber(fiber));
  10314. didWarnStateUpdateForUnmountedComponent[componentName] = true;
  10315. };
  10316. warnAboutInvalidUpdates = function (instance) {
  10317. switch (ReactDebugCurrentFiber.phase) {
  10318. case 'getChildContext':
  10319. if (didWarnSetStateChildContext) {
  10320. return;
  10321. }
  10322. warning_1(false, 'setState(...): Cannot call setState() inside getChildContext()');
  10323. didWarnSetStateChildContext = true;
  10324. break;
  10325. case 'render':
  10326. if (didWarnAboutStateTransition) {
  10327. return;
  10328. }
  10329. warning_1(false, 'Cannot update during an existing state transition (such as within ' + "`render` or another component's constructor). Render methods should " + 'be a pure function of props and state; constructor side-effects are ' + 'an anti-pattern, but can be moved to `componentWillMount`.');
  10330. didWarnAboutStateTransition = true;
  10331. break;
  10332. }
  10333. };
  10334. }
  10335. var ReactFiberScheduler = function (config) {
  10336. var stack = ReactFiberStack();
  10337. var hostContext = ReactFiberHostContext(config, stack);
  10338. var legacyContext = ReactFiberLegacyContext(stack);
  10339. var newContext = ReactFiberNewContext(stack);
  10340. var popHostContext = hostContext.popHostContext,
  10341. popHostContainer = hostContext.popHostContainer;
  10342. var popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject,
  10343. popLegacyContextProvider = legacyContext.popContextProvider;
  10344. var popProvider = newContext.popProvider;
  10345. var hydrationContext = ReactFiberHydrationContext(config);
  10346. var _ReactFiberBeginWork = ReactFiberBeginWork(config, hostContext, legacyContext, newContext, hydrationContext, scheduleWork, computeExpirationForFiber),
  10347. beginWork = _ReactFiberBeginWork.beginWork;
  10348. var _ReactFiberCompleteWo = ReactFiberCompleteWork(config, hostContext, legacyContext, newContext, hydrationContext),
  10349. completeWork = _ReactFiberCompleteWo.completeWork;
  10350. var _ReactFiberUnwindWork = ReactFiberUnwindWork(hostContext, legacyContext, newContext, scheduleWork, isAlreadyFailedLegacyErrorBoundary),
  10351. throwException = _ReactFiberUnwindWork.throwException,
  10352. unwindWork = _ReactFiberUnwindWork.unwindWork,
  10353. unwindInterruptedWork = _ReactFiberUnwindWork.unwindInterruptedWork;
  10354. var _ReactFiberCommitWork = ReactFiberCommitWork(config, onCommitPhaseError, scheduleWork, computeExpirationForFiber, markLegacyErrorBoundaryAsFailed, recalculateCurrentTime),
  10355. commitBeforeMutationLifeCycles = _ReactFiberCommitWork.commitBeforeMutationLifeCycles,
  10356. commitResetTextContent = _ReactFiberCommitWork.commitResetTextContent,
  10357. commitPlacement = _ReactFiberCommitWork.commitPlacement,
  10358. commitDeletion = _ReactFiberCommitWork.commitDeletion,
  10359. commitWork = _ReactFiberCommitWork.commitWork,
  10360. commitLifeCycles = _ReactFiberCommitWork.commitLifeCycles,
  10361. commitErrorLogging = _ReactFiberCommitWork.commitErrorLogging,
  10362. commitAttachRef = _ReactFiberCommitWork.commitAttachRef,
  10363. commitDetachRef = _ReactFiberCommitWork.commitDetachRef;
  10364. var now = config.now,
  10365. scheduleDeferredCallback = config.scheduleDeferredCallback,
  10366. cancelDeferredCallback = config.cancelDeferredCallback,
  10367. prepareForCommit = config.prepareForCommit,
  10368. resetAfterCommit = config.resetAfterCommit;
  10369. // Represents the current time in ms.
  10370. var originalStartTimeMs = now();
  10371. var mostRecentCurrentTime = msToExpirationTime(0);
  10372. var mostRecentCurrentTimeMs = originalStartTimeMs;
  10373. // Used to ensure computeUniqueAsyncExpiration is monotonically increases.
  10374. var lastUniqueAsyncExpiration = 0;
  10375. // Represents the expiration time that incoming updates should use. (If this
  10376. // is NoWork, use the default strategy: async updates in async mode, sync
  10377. // updates in sync mode.)
  10378. var expirationContext = NoWork;
  10379. var isWorking = false;
  10380. // The next work in progress fiber that we're currently working on.
  10381. var nextUnitOfWork = null;
  10382. var nextRoot = null;
  10383. // The time at which we're currently rendering work.
  10384. var nextRenderExpirationTime = NoWork;
  10385. // The next fiber with an effect that we're currently committing.
  10386. var nextEffect = null;
  10387. var isCommitting = false;
  10388. var isRootReadyForCommit = false;
  10389. var legacyErrorBoundariesThatAlreadyFailed = null;
  10390. // Used for performance tracking.
  10391. var interruptedBy = null;
  10392. var stashedWorkInProgressProperties = void 0;
  10393. var replayUnitOfWork = void 0;
  10394. var isReplayingFailedUnitOfWork = void 0;
  10395. var originalReplayError = void 0;
  10396. var rethrowOriginalError = void 0;
  10397. if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  10398. stashedWorkInProgressProperties = null;
  10399. isReplayingFailedUnitOfWork = false;
  10400. originalReplayError = null;
  10401. replayUnitOfWork = function (failedUnitOfWork, error, isAsync) {
  10402. // Restore the original state of the work-in-progress
  10403. assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties);
  10404. switch (failedUnitOfWork.tag) {
  10405. case HostRoot:
  10406. popHostContainer(failedUnitOfWork);
  10407. popTopLevelLegacyContextObject(failedUnitOfWork);
  10408. break;
  10409. case HostComponent:
  10410. popHostContext(failedUnitOfWork);
  10411. break;
  10412. case ClassComponent:
  10413. popLegacyContextProvider(failedUnitOfWork);
  10414. break;
  10415. case HostPortal:
  10416. popHostContainer(failedUnitOfWork);
  10417. break;
  10418. case ContextProvider:
  10419. popProvider(failedUnitOfWork);
  10420. break;
  10421. }
  10422. // Replay the begin phase.
  10423. isReplayingFailedUnitOfWork = true;
  10424. originalReplayError = error;
  10425. invokeGuardedCallback$2(null, workLoop, null, isAsync);
  10426. isReplayingFailedUnitOfWork = false;
  10427. originalReplayError = null;
  10428. if (hasCaughtError()) {
  10429. clearCaughtError();
  10430. } else {
  10431. // If the begin phase did not fail the second time, set this pointer
  10432. // back to the original value.
  10433. nextUnitOfWork = failedUnitOfWork;
  10434. }
  10435. };
  10436. rethrowOriginalError = function () {
  10437. throw originalReplayError;
  10438. };
  10439. }
  10440. function resetStack() {
  10441. if (nextUnitOfWork !== null) {
  10442. var interruptedWork = nextUnitOfWork['return'];
  10443. while (interruptedWork !== null) {
  10444. unwindInterruptedWork(interruptedWork);
  10445. interruptedWork = interruptedWork['return'];
  10446. }
  10447. }
  10448. {
  10449. ReactStrictModeWarnings.discardPendingWarnings();
  10450. stack.checkThatStackIsEmpty();
  10451. }
  10452. nextRoot = null;
  10453. nextRenderExpirationTime = NoWork;
  10454. nextUnitOfWork = null;
  10455. isRootReadyForCommit = false;
  10456. }
  10457. function commitAllHostEffects() {
  10458. while (nextEffect !== null) {
  10459. {
  10460. ReactDebugCurrentFiber.setCurrentFiber(nextEffect);
  10461. }
  10462. recordEffect();
  10463. var effectTag = nextEffect.effectTag;
  10464. if (effectTag & ContentReset) {
  10465. commitResetTextContent(nextEffect);
  10466. }
  10467. if (effectTag & Ref) {
  10468. var current = nextEffect.alternate;
  10469. if (current !== null) {
  10470. commitDetachRef(current);
  10471. }
  10472. }
  10473. // The following switch statement is only concerned about placement,
  10474. // updates, and deletions. To avoid needing to add a case for every
  10475. // possible bitmap value, we remove the secondary effects from the
  10476. // effect tag and switch on that value.
  10477. var primaryEffectTag = effectTag & (Placement | Update | Deletion);
  10478. switch (primaryEffectTag) {
  10479. case Placement:
  10480. {
  10481. commitPlacement(nextEffect);
  10482. // Clear the "placement" from effect tag so that we know that this is inserted, before
  10483. // any life-cycles like componentDidMount gets called.
  10484. // TODO: findDOMNode doesn't rely on this any more but isMounted
  10485. // does and isMounted is deprecated anyway so we should be able
  10486. // to kill this.
  10487. nextEffect.effectTag &= ~Placement;
  10488. break;
  10489. }
  10490. case PlacementAndUpdate:
  10491. {
  10492. // Placement
  10493. commitPlacement(nextEffect);
  10494. // Clear the "placement" from effect tag so that we know that this is inserted, before
  10495. // any life-cycles like componentDidMount gets called.
  10496. nextEffect.effectTag &= ~Placement;
  10497. // Update
  10498. var _current = nextEffect.alternate;
  10499. commitWork(_current, nextEffect);
  10500. break;
  10501. }
  10502. case Update:
  10503. {
  10504. var _current2 = nextEffect.alternate;
  10505. commitWork(_current2, nextEffect);
  10506. break;
  10507. }
  10508. case Deletion:
  10509. {
  10510. commitDeletion(nextEffect);
  10511. break;
  10512. }
  10513. }
  10514. nextEffect = nextEffect.nextEffect;
  10515. }
  10516. {
  10517. ReactDebugCurrentFiber.resetCurrentFiber();
  10518. }
  10519. }
  10520. function commitBeforeMutationLifecycles() {
  10521. while (nextEffect !== null) {
  10522. var effectTag = nextEffect.effectTag;
  10523. if (effectTag & Snapshot) {
  10524. recordEffect();
  10525. var current = nextEffect.alternate;
  10526. commitBeforeMutationLifeCycles(current, nextEffect);
  10527. }
  10528. // Don't cleanup effects yet;
  10529. // This will be done by commitAllLifeCycles()
  10530. nextEffect = nextEffect.nextEffect;
  10531. }
  10532. }
  10533. function commitAllLifeCycles(finishedRoot, currentTime, committedExpirationTime) {
  10534. {
  10535. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  10536. if (warnAboutDeprecatedLifecycles) {
  10537. ReactStrictModeWarnings.flushPendingDeprecationWarnings();
  10538. }
  10539. }
  10540. while (nextEffect !== null) {
  10541. var effectTag = nextEffect.effectTag;
  10542. if (effectTag & (Update | Callback)) {
  10543. recordEffect();
  10544. var current = nextEffect.alternate;
  10545. commitLifeCycles(finishedRoot, current, nextEffect, currentTime, committedExpirationTime);
  10546. }
  10547. if (effectTag & ErrLog) {
  10548. commitErrorLogging(nextEffect, onUncaughtError);
  10549. }
  10550. if (effectTag & Ref) {
  10551. recordEffect();
  10552. commitAttachRef(nextEffect);
  10553. }
  10554. var next = nextEffect.nextEffect;
  10555. // Ensure that we clean these up so that we don't accidentally keep them.
  10556. // I'm not actually sure this matters because we can't reset firstEffect
  10557. // and lastEffect since they're on every node, not just the effectful
  10558. // ones. So we have to clean everything as we reuse nodes anyway.
  10559. nextEffect.nextEffect = null;
  10560. // Ensure that we reset the effectTag here so that we can rely on effect
  10561. // tags to reason about the current life-cycle.
  10562. nextEffect = next;
  10563. }
  10564. }
  10565. function isAlreadyFailedLegacyErrorBoundary(instance) {
  10566. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  10567. }
  10568. function markLegacyErrorBoundaryAsFailed(instance) {
  10569. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  10570. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  10571. } else {
  10572. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  10573. }
  10574. }
  10575. function commitRoot(finishedWork) {
  10576. isWorking = true;
  10577. isCommitting = true;
  10578. startCommitTimer();
  10579. var root = finishedWork.stateNode;
  10580. !(root.current !== finishedWork) ? invariant_1(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10581. var committedExpirationTime = root.pendingCommitExpirationTime;
  10582. !(committedExpirationTime !== NoWork) ? invariant_1(false, 'Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10583. root.pendingCommitExpirationTime = NoWork;
  10584. var currentTime = recalculateCurrentTime();
  10585. // Reset this to null before calling lifecycles
  10586. ReactCurrentOwner.current = null;
  10587. var firstEffect = void 0;
  10588. if (finishedWork.effectTag > PerformedWork) {
  10589. // A fiber's effect list consists only of its children, not itself. So if
  10590. // the root has an effect, we need to add it to the end of the list. The
  10591. // resulting list is the set that would belong to the root's parent, if
  10592. // it had one; that is, all the effects in the tree including the root.
  10593. if (finishedWork.lastEffect !== null) {
  10594. finishedWork.lastEffect.nextEffect = finishedWork;
  10595. firstEffect = finishedWork.firstEffect;
  10596. } else {
  10597. firstEffect = finishedWork;
  10598. }
  10599. } else {
  10600. // There is no effect on the root.
  10601. firstEffect = finishedWork.firstEffect;
  10602. }
  10603. prepareForCommit(root.containerInfo);
  10604. // Invoke instances of getSnapshotBeforeUpdate before mutation.
  10605. nextEffect = firstEffect;
  10606. startCommitSnapshotEffectsTimer();
  10607. while (nextEffect !== null) {
  10608. var didError = false;
  10609. var error = void 0;
  10610. {
  10611. invokeGuardedCallback$2(null, commitBeforeMutationLifecycles, null);
  10612. if (hasCaughtError()) {
  10613. didError = true;
  10614. error = clearCaughtError();
  10615. }
  10616. }
  10617. if (didError) {
  10618. !(nextEffect !== null) ? invariant_1(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10619. onCommitPhaseError(nextEffect, error);
  10620. // Clean-up
  10621. if (nextEffect !== null) {
  10622. nextEffect = nextEffect.nextEffect;
  10623. }
  10624. }
  10625. }
  10626. stopCommitSnapshotEffectsTimer();
  10627. // Commit all the side-effects within a tree. We'll do this in two passes.
  10628. // The first pass performs all the host insertions, updates, deletions and
  10629. // ref unmounts.
  10630. nextEffect = firstEffect;
  10631. startCommitHostEffectsTimer();
  10632. while (nextEffect !== null) {
  10633. var _didError = false;
  10634. var _error = void 0;
  10635. {
  10636. invokeGuardedCallback$2(null, commitAllHostEffects, null);
  10637. if (hasCaughtError()) {
  10638. _didError = true;
  10639. _error = clearCaughtError();
  10640. }
  10641. }
  10642. if (_didError) {
  10643. !(nextEffect !== null) ? invariant_1(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10644. onCommitPhaseError(nextEffect, _error);
  10645. // Clean-up
  10646. if (nextEffect !== null) {
  10647. nextEffect = nextEffect.nextEffect;
  10648. }
  10649. }
  10650. }
  10651. stopCommitHostEffectsTimer();
  10652. resetAfterCommit(root.containerInfo);
  10653. // The work-in-progress tree is now the current tree. This must come after
  10654. // the first pass of the commit phase, so that the previous tree is still
  10655. // current during componentWillUnmount, but before the second pass, so that
  10656. // the finished work is current during componentDidMount/Update.
  10657. root.current = finishedWork;
  10658. // In the second pass we'll perform all life-cycles and ref callbacks.
  10659. // Life-cycles happen as a separate pass so that all placements, updates,
  10660. // and deletions in the entire tree have already been invoked.
  10661. // This pass also triggers any renderer-specific initial effects.
  10662. nextEffect = firstEffect;
  10663. startCommitLifeCyclesTimer();
  10664. while (nextEffect !== null) {
  10665. var _didError2 = false;
  10666. var _error2 = void 0;
  10667. {
  10668. invokeGuardedCallback$2(null, commitAllLifeCycles, null, root, currentTime, committedExpirationTime);
  10669. if (hasCaughtError()) {
  10670. _didError2 = true;
  10671. _error2 = clearCaughtError();
  10672. }
  10673. }
  10674. if (_didError2) {
  10675. !(nextEffect !== null) ? invariant_1(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10676. onCommitPhaseError(nextEffect, _error2);
  10677. if (nextEffect !== null) {
  10678. nextEffect = nextEffect.nextEffect;
  10679. }
  10680. }
  10681. }
  10682. isCommitting = false;
  10683. isWorking = false;
  10684. stopCommitLifeCyclesTimer();
  10685. stopCommitTimer();
  10686. if (typeof onCommitRoot === 'function') {
  10687. onCommitRoot(finishedWork.stateNode);
  10688. }
  10689. if (true && ReactFiberInstrumentation_1.debugTool) {
  10690. ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork);
  10691. }
  10692. var remainingTime = root.current.expirationTime;
  10693. if (remainingTime === NoWork) {
  10694. // If there's no remaining work, we can clear the set of already failed
  10695. // error boundaries.
  10696. legacyErrorBoundariesThatAlreadyFailed = null;
  10697. }
  10698. return remainingTime;
  10699. }
  10700. function resetExpirationTime(workInProgress, renderTime) {
  10701. if (renderTime !== Never && workInProgress.expirationTime === Never) {
  10702. // The children of this component are hidden. Don't bubble their
  10703. // expiration times.
  10704. return;
  10705. }
  10706. // Check for pending updates.
  10707. var newExpirationTime = getUpdateExpirationTime(workInProgress);
  10708. // TODO: Calls need to visit stateNode
  10709. // Bubble up the earliest expiration time.
  10710. var child = workInProgress.child;
  10711. while (child !== null) {
  10712. if (child.expirationTime !== NoWork && (newExpirationTime === NoWork || newExpirationTime > child.expirationTime)) {
  10713. newExpirationTime = child.expirationTime;
  10714. }
  10715. child = child.sibling;
  10716. }
  10717. workInProgress.expirationTime = newExpirationTime;
  10718. }
  10719. function completeUnitOfWork(workInProgress) {
  10720. // Attempt to complete the current unit of work, then move to the
  10721. // next sibling. If there are no more siblings, return to the
  10722. // parent fiber.
  10723. while (true) {
  10724. // The current, flushed, state of this fiber is the alternate.
  10725. // Ideally nothing should rely on this, but relying on it here
  10726. // means that we don't need an additional field on the work in
  10727. // progress.
  10728. var current = workInProgress.alternate;
  10729. {
  10730. ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
  10731. }
  10732. var returnFiber = workInProgress['return'];
  10733. var siblingFiber = workInProgress.sibling;
  10734. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  10735. // This fiber completed.
  10736. var next = completeWork(current, workInProgress, nextRenderExpirationTime);
  10737. stopWorkTimer(workInProgress);
  10738. resetExpirationTime(workInProgress, nextRenderExpirationTime);
  10739. {
  10740. ReactDebugCurrentFiber.resetCurrentFiber();
  10741. }
  10742. if (next !== null) {
  10743. stopWorkTimer(workInProgress);
  10744. if (true && ReactFiberInstrumentation_1.debugTool) {
  10745. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  10746. }
  10747. // If completing this work spawned new work, do that next. We'll come
  10748. // back here again.
  10749. return next;
  10750. }
  10751. if (returnFiber !== null &&
  10752. // Do not append effects to parents if a sibling failed to complete
  10753. (returnFiber.effectTag & Incomplete) === NoEffect) {
  10754. // Append all the effects of the subtree and this fiber onto the effect
  10755. // list of the parent. The completion order of the children affects the
  10756. // side-effect order.
  10757. if (returnFiber.firstEffect === null) {
  10758. returnFiber.firstEffect = workInProgress.firstEffect;
  10759. }
  10760. if (workInProgress.lastEffect !== null) {
  10761. if (returnFiber.lastEffect !== null) {
  10762. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  10763. }
  10764. returnFiber.lastEffect = workInProgress.lastEffect;
  10765. }
  10766. // If this fiber had side-effects, we append it AFTER the children's
  10767. // side-effects. We can perform certain side-effects earlier if
  10768. // needed, by doing multiple passes over the effect list. We don't want
  10769. // to schedule our own side-effect on our own list because if end up
  10770. // reusing children we'll schedule this effect onto itself since we're
  10771. // at the end.
  10772. var effectTag = workInProgress.effectTag;
  10773. // Skip both NoWork and PerformedWork tags when creating the effect list.
  10774. // PerformedWork effect is read by React DevTools but shouldn't be committed.
  10775. if (effectTag > PerformedWork) {
  10776. if (returnFiber.lastEffect !== null) {
  10777. returnFiber.lastEffect.nextEffect = workInProgress;
  10778. } else {
  10779. returnFiber.firstEffect = workInProgress;
  10780. }
  10781. returnFiber.lastEffect = workInProgress;
  10782. }
  10783. }
  10784. if (true && ReactFiberInstrumentation_1.debugTool) {
  10785. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  10786. }
  10787. if (siblingFiber !== null) {
  10788. // If there is more work to do in this returnFiber, do that next.
  10789. return siblingFiber;
  10790. } else if (returnFiber !== null) {
  10791. // If there's no more work in this returnFiber. Complete the returnFiber.
  10792. workInProgress = returnFiber;
  10793. continue;
  10794. } else {
  10795. // We've reached the root.
  10796. isRootReadyForCommit = true;
  10797. return null;
  10798. }
  10799. } else {
  10800. // This fiber did not complete because something threw. Pop values off
  10801. // the stack without entering the complete phase. If this is a boundary,
  10802. // capture values if possible.
  10803. var _next = unwindWork(workInProgress);
  10804. // Because this fiber did not complete, don't reset its expiration time.
  10805. if (workInProgress.effectTag & DidCapture) {
  10806. // Restarting an error boundary
  10807. stopFailedWorkTimer(workInProgress);
  10808. } else {
  10809. stopWorkTimer(workInProgress);
  10810. }
  10811. {
  10812. ReactDebugCurrentFiber.resetCurrentFiber();
  10813. }
  10814. if (_next !== null) {
  10815. stopWorkTimer(workInProgress);
  10816. if (true && ReactFiberInstrumentation_1.debugTool) {
  10817. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  10818. }
  10819. // If completing this work spawned new work, do that next. We'll come
  10820. // back here again.
  10821. // Since we're restarting, remove anything that is not a host effect
  10822. // from the effect tag.
  10823. _next.effectTag &= HostEffectMask;
  10824. return _next;
  10825. }
  10826. if (returnFiber !== null) {
  10827. // Mark the parent fiber as incomplete and clear its effect list.
  10828. returnFiber.firstEffect = returnFiber.lastEffect = null;
  10829. returnFiber.effectTag |= Incomplete;
  10830. }
  10831. if (true && ReactFiberInstrumentation_1.debugTool) {
  10832. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  10833. }
  10834. if (siblingFiber !== null) {
  10835. // If there is more work to do in this returnFiber, do that next.
  10836. return siblingFiber;
  10837. } else if (returnFiber !== null) {
  10838. // If there's no more work in this returnFiber. Complete the returnFiber.
  10839. workInProgress = returnFiber;
  10840. continue;
  10841. } else {
  10842. return null;
  10843. }
  10844. }
  10845. }
  10846. // Without this explicit null return Flow complains of invalid return type
  10847. // TODO Remove the above while(true) loop
  10848. // eslint-disable-next-line no-unreachable
  10849. return null;
  10850. }
  10851. function performUnitOfWork(workInProgress) {
  10852. // The current, flushed, state of this fiber is the alternate.
  10853. // Ideally nothing should rely on this, but relying on it here
  10854. // means that we don't need an additional field on the work in
  10855. // progress.
  10856. var current = workInProgress.alternate;
  10857. // See if beginning this work spawns more work.
  10858. startWorkTimer(workInProgress);
  10859. {
  10860. ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
  10861. }
  10862. if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  10863. stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress);
  10864. }
  10865. var next = beginWork(current, workInProgress, nextRenderExpirationTime);
  10866. {
  10867. ReactDebugCurrentFiber.resetCurrentFiber();
  10868. if (isReplayingFailedUnitOfWork) {
  10869. // Currently replaying a failed unit of work. This should be unreachable,
  10870. // because the render phase is meant to be idempotent, and it should
  10871. // have thrown again. Since it didn't, rethrow the original error, so
  10872. // React's internal stack is not misaligned.
  10873. rethrowOriginalError();
  10874. }
  10875. }
  10876. if (true && ReactFiberInstrumentation_1.debugTool) {
  10877. ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress);
  10878. }
  10879. if (next === null) {
  10880. // If this doesn't spawn new work, complete the current work.
  10881. next = completeUnitOfWork(workInProgress);
  10882. }
  10883. ReactCurrentOwner.current = null;
  10884. return next;
  10885. }
  10886. function workLoop(isAsync) {
  10887. if (!isAsync) {
  10888. // Flush all expired work.
  10889. while (nextUnitOfWork !== null) {
  10890. nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
  10891. }
  10892. } else {
  10893. // Flush asynchronous work until the deadline runs out of time.
  10894. while (nextUnitOfWork !== null && !shouldYield()) {
  10895. nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
  10896. }
  10897. }
  10898. }
  10899. function renderRoot(root, expirationTime, isAsync) {
  10900. !!isWorking ? invariant_1(false, 'renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10901. isWorking = true;
  10902. // Check if we're starting from a fresh stack, or if we're resuming from
  10903. // previously yielded work.
  10904. if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
  10905. // Reset the stack and start working from the root.
  10906. resetStack();
  10907. nextRoot = root;
  10908. nextRenderExpirationTime = expirationTime;
  10909. nextUnitOfWork = createWorkInProgress(nextRoot.current, null, nextRenderExpirationTime);
  10910. root.pendingCommitExpirationTime = NoWork;
  10911. }
  10912. var didFatal = false;
  10913. startWorkLoopTimer(nextUnitOfWork);
  10914. do {
  10915. try {
  10916. workLoop(isAsync);
  10917. } catch (thrownValue) {
  10918. if (nextUnitOfWork === null) {
  10919. // This is a fatal error.
  10920. didFatal = true;
  10921. onUncaughtError(thrownValue);
  10922. break;
  10923. }
  10924. if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  10925. var failedUnitOfWork = nextUnitOfWork;
  10926. replayUnitOfWork(failedUnitOfWork, thrownValue, isAsync);
  10927. }
  10928. var sourceFiber = nextUnitOfWork;
  10929. var returnFiber = sourceFiber['return'];
  10930. if (returnFiber === null) {
  10931. // This is the root. The root could capture its own errors. However,
  10932. // we don't know if it errors before or after we pushed the host
  10933. // context. This information is needed to avoid a stack mismatch.
  10934. // Because we're not sure, treat this as a fatal error. We could track
  10935. // which phase it fails in, but doesn't seem worth it. At least
  10936. // for now.
  10937. didFatal = true;
  10938. onUncaughtError(thrownValue);
  10939. break;
  10940. }
  10941. throwException(returnFiber, sourceFiber, thrownValue);
  10942. nextUnitOfWork = completeUnitOfWork(sourceFiber);
  10943. }
  10944. break;
  10945. } while (true);
  10946. // We're done performing work. Time to clean up.
  10947. var didCompleteRoot = false;
  10948. isWorking = false;
  10949. // Yield back to main thread.
  10950. if (didFatal) {
  10951. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  10952. interruptedBy = null;
  10953. // There was a fatal error.
  10954. {
  10955. stack.resetStackAfterFatalErrorInDev();
  10956. }
  10957. return null;
  10958. } else if (nextUnitOfWork === null) {
  10959. // We reached the root.
  10960. if (isRootReadyForCommit) {
  10961. didCompleteRoot = true;
  10962. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  10963. interruptedBy = null;
  10964. // The root successfully completed. It's ready for commit.
  10965. root.pendingCommitExpirationTime = expirationTime;
  10966. var finishedWork = root.current.alternate;
  10967. return finishedWork;
  10968. } else {
  10969. // The root did not complete.
  10970. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  10971. interruptedBy = null;
  10972. invariant_1(false, 'Expired work should have completed. This error is likely caused by a bug in React. Please file an issue.');
  10973. }
  10974. } else {
  10975. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  10976. interruptedBy = null;
  10977. // There's more work to do, but we ran out of time. Yield back to
  10978. // the renderer.
  10979. return null;
  10980. }
  10981. }
  10982. function scheduleCapture(sourceFiber, boundaryFiber, value, expirationTime) {
  10983. // TODO: We only support dispatching errors.
  10984. var capturedValue = createCapturedValue(value, sourceFiber);
  10985. var update = {
  10986. expirationTime: expirationTime,
  10987. partialState: null,
  10988. callback: null,
  10989. isReplace: false,
  10990. isForced: false,
  10991. capturedValue: capturedValue,
  10992. next: null
  10993. };
  10994. insertUpdateIntoFiber(boundaryFiber, update);
  10995. scheduleWork(boundaryFiber, expirationTime);
  10996. }
  10997. function dispatch(sourceFiber, value, expirationTime) {
  10998. !(!isWorking || isCommitting) ? invariant_1(false, 'dispatch: Cannot dispatch during the render phase.') : void 0;
  10999. // TODO: Handle arrays
  11000. var fiber = sourceFiber['return'];
  11001. while (fiber !== null) {
  11002. switch (fiber.tag) {
  11003. case ClassComponent:
  11004. var ctor = fiber.type;
  11005. var instance = fiber.stateNode;
  11006. if (typeof ctor.getDerivedStateFromCatch === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  11007. scheduleCapture(sourceFiber, fiber, value, expirationTime);
  11008. return;
  11009. }
  11010. break;
  11011. // TODO: Handle async boundaries
  11012. case HostRoot:
  11013. scheduleCapture(sourceFiber, fiber, value, expirationTime);
  11014. return;
  11015. }
  11016. fiber = fiber['return'];
  11017. }
  11018. if (sourceFiber.tag === HostRoot) {
  11019. // Error was thrown at the root. There is no parent, so the root
  11020. // itself should capture it.
  11021. scheduleCapture(sourceFiber, sourceFiber, value, expirationTime);
  11022. }
  11023. }
  11024. function onCommitPhaseError(fiber, error) {
  11025. return dispatch(fiber, error, Sync);
  11026. }
  11027. function computeAsyncExpiration(currentTime) {
  11028. // Given the current clock time, returns an expiration time. We use rounding
  11029. // to batch like updates together.
  11030. // Should complete within ~1000ms. 1200ms max.
  11031. var expirationMs = 5000;
  11032. var bucketSizeMs = 250;
  11033. return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
  11034. }
  11035. function computeInteractiveExpiration(currentTime) {
  11036. var expirationMs = void 0;
  11037. // We intentionally set a higher expiration time for interactive updates in
  11038. // dev than in production.
  11039. // If the main thread is being blocked so long that you hit the expiration,
  11040. // it's a problem that could be solved with better scheduling.
  11041. // People will be more likely to notice this and fix it with the long
  11042. // expiration time in development.
  11043. // In production we opt for better UX at the risk of masking scheduling
  11044. // problems, by expiring fast.
  11045. {
  11046. // Should complete within ~500ms. 600ms max.
  11047. expirationMs = 500;
  11048. }
  11049. var bucketSizeMs = 100;
  11050. return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
  11051. }
  11052. // Creates a unique async expiration time.
  11053. function computeUniqueAsyncExpiration() {
  11054. var currentTime = recalculateCurrentTime();
  11055. var result = computeAsyncExpiration(currentTime);
  11056. if (result <= lastUniqueAsyncExpiration) {
  11057. // Since we assume the current time monotonically increases, we only hit
  11058. // this branch when computeUniqueAsyncExpiration is fired multiple times
  11059. // within a 200ms window (or whatever the async bucket size is).
  11060. result = lastUniqueAsyncExpiration + 1;
  11061. }
  11062. lastUniqueAsyncExpiration = result;
  11063. return lastUniqueAsyncExpiration;
  11064. }
  11065. function computeExpirationForFiber(fiber) {
  11066. var expirationTime = void 0;
  11067. if (expirationContext !== NoWork) {
  11068. // An explicit expiration context was set;
  11069. expirationTime = expirationContext;
  11070. } else if (isWorking) {
  11071. if (isCommitting) {
  11072. // Updates that occur during the commit phase should have sync priority
  11073. // by default.
  11074. expirationTime = Sync;
  11075. } else {
  11076. // Updates during the render phase should expire at the same time as
  11077. // the work that is being rendered.
  11078. expirationTime = nextRenderExpirationTime;
  11079. }
  11080. } else {
  11081. // No explicit expiration context was set, and we're not currently
  11082. // performing work. Calculate a new expiration time.
  11083. if (fiber.mode & AsyncMode) {
  11084. if (isBatchingInteractiveUpdates) {
  11085. // This is an interactive update
  11086. var currentTime = recalculateCurrentTime();
  11087. expirationTime = computeInteractiveExpiration(currentTime);
  11088. } else {
  11089. // This is an async update
  11090. var _currentTime = recalculateCurrentTime();
  11091. expirationTime = computeAsyncExpiration(_currentTime);
  11092. }
  11093. } else {
  11094. // This is a sync update
  11095. expirationTime = Sync;
  11096. }
  11097. }
  11098. if (isBatchingInteractiveUpdates) {
  11099. // This is an interactive update. Keep track of the lowest pending
  11100. // interactive expiration time. This allows us to synchronously flush
  11101. // all interactive updates when needed.
  11102. if (lowestPendingInteractiveExpirationTime === NoWork || expirationTime > lowestPendingInteractiveExpirationTime) {
  11103. lowestPendingInteractiveExpirationTime = expirationTime;
  11104. }
  11105. }
  11106. return expirationTime;
  11107. }
  11108. function scheduleWork(fiber, expirationTime) {
  11109. return scheduleWorkImpl(fiber, expirationTime, false);
  11110. }
  11111. function scheduleWorkImpl(fiber, expirationTime, isErrorRecovery) {
  11112. recordScheduleUpdate();
  11113. {
  11114. if (!isErrorRecovery && fiber.tag === ClassComponent) {
  11115. var instance = fiber.stateNode;
  11116. warnAboutInvalidUpdates(instance);
  11117. }
  11118. }
  11119. var node = fiber;
  11120. while (node !== null) {
  11121. // Walk the parent path to the root and update each node's
  11122. // expiration time.
  11123. if (node.expirationTime === NoWork || node.expirationTime > expirationTime) {
  11124. node.expirationTime = expirationTime;
  11125. }
  11126. if (node.alternate !== null) {
  11127. if (node.alternate.expirationTime === NoWork || node.alternate.expirationTime > expirationTime) {
  11128. node.alternate.expirationTime = expirationTime;
  11129. }
  11130. }
  11131. if (node['return'] === null) {
  11132. if (node.tag === HostRoot) {
  11133. var root = node.stateNode;
  11134. if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime < nextRenderExpirationTime) {
  11135. // This is an interruption. (Used for performance tracking.)
  11136. interruptedBy = fiber;
  11137. resetStack();
  11138. }
  11139. if (
  11140. // If we're in the render phase, we don't need to schedule this root
  11141. // for an update, because we'll do it before we exit...
  11142. !isWorking || isCommitting ||
  11143. // ...unless this is a different root than the one we're rendering.
  11144. nextRoot !== root) {
  11145. // Add this root to the root schedule.
  11146. requestWork(root, expirationTime);
  11147. }
  11148. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  11149. invariant_1(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.');
  11150. }
  11151. } else {
  11152. {
  11153. if (!isErrorRecovery && fiber.tag === ClassComponent) {
  11154. warnAboutUpdateOnUnmounted(fiber);
  11155. }
  11156. }
  11157. return;
  11158. }
  11159. }
  11160. node = node['return'];
  11161. }
  11162. }
  11163. function recalculateCurrentTime() {
  11164. // Subtract initial time so it fits inside 32bits
  11165. mostRecentCurrentTimeMs = now() - originalStartTimeMs;
  11166. mostRecentCurrentTime = msToExpirationTime(mostRecentCurrentTimeMs);
  11167. return mostRecentCurrentTime;
  11168. }
  11169. function deferredUpdates(fn) {
  11170. var previousExpirationContext = expirationContext;
  11171. var currentTime = recalculateCurrentTime();
  11172. expirationContext = computeAsyncExpiration(currentTime);
  11173. try {
  11174. return fn();
  11175. } finally {
  11176. expirationContext = previousExpirationContext;
  11177. }
  11178. }
  11179. function syncUpdates(fn, a, b, c, d) {
  11180. var previousExpirationContext = expirationContext;
  11181. expirationContext = Sync;
  11182. try {
  11183. return fn(a, b, c, d);
  11184. } finally {
  11185. expirationContext = previousExpirationContext;
  11186. }
  11187. }
  11188. // TODO: Everything below this is written as if it has been lifted to the
  11189. // renderers. I'll do this in a follow-up.
  11190. // Linked-list of roots
  11191. var firstScheduledRoot = null;
  11192. var lastScheduledRoot = null;
  11193. var callbackExpirationTime = NoWork;
  11194. var callbackID = -1;
  11195. var isRendering = false;
  11196. var nextFlushedRoot = null;
  11197. var nextFlushedExpirationTime = NoWork;
  11198. var lowestPendingInteractiveExpirationTime = NoWork;
  11199. var deadlineDidExpire = false;
  11200. var hasUnhandledError = false;
  11201. var unhandledError = null;
  11202. var deadline = null;
  11203. var isBatchingUpdates = false;
  11204. var isUnbatchingUpdates = false;
  11205. var isBatchingInteractiveUpdates = false;
  11206. var completedBatches = null;
  11207. // Use these to prevent an infinite loop of nested updates
  11208. var NESTED_UPDATE_LIMIT = 1000;
  11209. var nestedUpdateCount = 0;
  11210. var timeHeuristicForUnitOfWork = 1;
  11211. function scheduleCallbackWithExpiration(expirationTime) {
  11212. if (callbackExpirationTime !== NoWork) {
  11213. // A callback is already scheduled. Check its expiration time (timeout).
  11214. if (expirationTime > callbackExpirationTime) {
  11215. // Existing callback has sufficient timeout. Exit.
  11216. return;
  11217. } else {
  11218. // Existing callback has insufficient timeout. Cancel and schedule a
  11219. // new one.
  11220. cancelDeferredCallback(callbackID);
  11221. }
  11222. // The request callback timer is already running. Don't start a new one.
  11223. } else {
  11224. startRequestCallbackTimer();
  11225. }
  11226. // Compute a timeout for the given expiration time.
  11227. var currentMs = now() - originalStartTimeMs;
  11228. var expirationMs = expirationTimeToMs(expirationTime);
  11229. var timeout = expirationMs - currentMs;
  11230. callbackExpirationTime = expirationTime;
  11231. callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
  11232. }
  11233. // requestWork is called by the scheduler whenever a root receives an update.
  11234. // It's up to the renderer to call renderRoot at some point in the future.
  11235. function requestWork(root, expirationTime) {
  11236. addRootToSchedule(root, expirationTime);
  11237. if (isRendering) {
  11238. // Prevent reentrancy. Remaining work will be scheduled at the end of
  11239. // the currently rendering batch.
  11240. return;
  11241. }
  11242. if (isBatchingUpdates) {
  11243. // Flush work at the end of the batch.
  11244. if (isUnbatchingUpdates) {
  11245. // ...unless we're inside unbatchedUpdates, in which case we should
  11246. // flush it now.
  11247. nextFlushedRoot = root;
  11248. nextFlushedExpirationTime = Sync;
  11249. performWorkOnRoot(root, Sync, false);
  11250. }
  11251. return;
  11252. }
  11253. // TODO: Get rid of Sync and use current time?
  11254. if (expirationTime === Sync) {
  11255. performSyncWork();
  11256. } else {
  11257. scheduleCallbackWithExpiration(expirationTime);
  11258. }
  11259. }
  11260. function addRootToSchedule(root, expirationTime) {
  11261. // Add the root to the schedule.
  11262. // Check if this root is already part of the schedule.
  11263. if (root.nextScheduledRoot === null) {
  11264. // This root is not already scheduled. Add it.
  11265. root.remainingExpirationTime = expirationTime;
  11266. if (lastScheduledRoot === null) {
  11267. firstScheduledRoot = lastScheduledRoot = root;
  11268. root.nextScheduledRoot = root;
  11269. } else {
  11270. lastScheduledRoot.nextScheduledRoot = root;
  11271. lastScheduledRoot = root;
  11272. lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
  11273. }
  11274. } else {
  11275. // This root is already scheduled, but its priority may have increased.
  11276. var remainingExpirationTime = root.remainingExpirationTime;
  11277. if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) {
  11278. // Update the priority.
  11279. root.remainingExpirationTime = expirationTime;
  11280. }
  11281. }
  11282. }
  11283. function findHighestPriorityRoot() {
  11284. var highestPriorityWork = NoWork;
  11285. var highestPriorityRoot = null;
  11286. if (lastScheduledRoot !== null) {
  11287. var previousScheduledRoot = lastScheduledRoot;
  11288. var root = firstScheduledRoot;
  11289. while (root !== null) {
  11290. var remainingExpirationTime = root.remainingExpirationTime;
  11291. if (remainingExpirationTime === NoWork) {
  11292. // This root no longer has work. Remove it from the scheduler.
  11293. // TODO: This check is redudant, but Flow is confused by the branch
  11294. // below where we set lastScheduledRoot to null, even though we break
  11295. // from the loop right after.
  11296. !(previousScheduledRoot !== null && lastScheduledRoot !== null) ? invariant_1(false, 'Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  11297. if (root === root.nextScheduledRoot) {
  11298. // This is the only root in the list.
  11299. root.nextScheduledRoot = null;
  11300. firstScheduledRoot = lastScheduledRoot = null;
  11301. break;
  11302. } else if (root === firstScheduledRoot) {
  11303. // This is the first root in the list.
  11304. var next = root.nextScheduledRoot;
  11305. firstScheduledRoot = next;
  11306. lastScheduledRoot.nextScheduledRoot = next;
  11307. root.nextScheduledRoot = null;
  11308. } else if (root === lastScheduledRoot) {
  11309. // This is the last root in the list.
  11310. lastScheduledRoot = previousScheduledRoot;
  11311. lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
  11312. root.nextScheduledRoot = null;
  11313. break;
  11314. } else {
  11315. previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot;
  11316. root.nextScheduledRoot = null;
  11317. }
  11318. root = previousScheduledRoot.nextScheduledRoot;
  11319. } else {
  11320. if (highestPriorityWork === NoWork || remainingExpirationTime < highestPriorityWork) {
  11321. // Update the priority, if it's higher
  11322. highestPriorityWork = remainingExpirationTime;
  11323. highestPriorityRoot = root;
  11324. }
  11325. if (root === lastScheduledRoot) {
  11326. break;
  11327. }
  11328. previousScheduledRoot = root;
  11329. root = root.nextScheduledRoot;
  11330. }
  11331. }
  11332. }
  11333. // If the next root is the same as the previous root, this is a nested
  11334. // update. To prevent an infinite loop, increment the nested update count.
  11335. var previousFlushedRoot = nextFlushedRoot;
  11336. if (previousFlushedRoot !== null && previousFlushedRoot === highestPriorityRoot && highestPriorityWork === Sync) {
  11337. nestedUpdateCount++;
  11338. } else {
  11339. // Reset whenever we switch roots.
  11340. nestedUpdateCount = 0;
  11341. }
  11342. nextFlushedRoot = highestPriorityRoot;
  11343. nextFlushedExpirationTime = highestPriorityWork;
  11344. }
  11345. function performAsyncWork(dl) {
  11346. performWork(NoWork, true, dl);
  11347. }
  11348. function performSyncWork() {
  11349. performWork(Sync, false, null);
  11350. }
  11351. function performWork(minExpirationTime, isAsync, dl) {
  11352. deadline = dl;
  11353. // Keep working on roots until there's no more work, or until the we reach
  11354. // the deadline.
  11355. findHighestPriorityRoot();
  11356. if (enableUserTimingAPI && deadline !== null) {
  11357. var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
  11358. var timeout = expirationTimeToMs(nextFlushedExpirationTime);
  11359. stopRequestCallbackTimer(didExpire, timeout);
  11360. }
  11361. if (isAsync) {
  11362. while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) {
  11363. performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire);
  11364. findHighestPriorityRoot();
  11365. }
  11366. } else {
  11367. while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
  11368. performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
  11369. findHighestPriorityRoot();
  11370. }
  11371. }
  11372. // We're done flushing work. Either we ran out of time in this callback,
  11373. // or there's no more work left with sufficient priority.
  11374. // If we're inside a callback, set this to false since we just completed it.
  11375. if (deadline !== null) {
  11376. callbackExpirationTime = NoWork;
  11377. callbackID = -1;
  11378. }
  11379. // If there's work left over, schedule a new callback.
  11380. if (nextFlushedExpirationTime !== NoWork) {
  11381. scheduleCallbackWithExpiration(nextFlushedExpirationTime);
  11382. }
  11383. // Clean-up.
  11384. deadline = null;
  11385. deadlineDidExpire = false;
  11386. finishRendering();
  11387. }
  11388. function flushRoot(root, expirationTime) {
  11389. !!isRendering ? invariant_1(false, 'work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.') : void 0;
  11390. // Perform work on root as if the given expiration time is the current time.
  11391. // This has the effect of synchronously flushing all work up to and
  11392. // including the given time.
  11393. nextFlushedRoot = root;
  11394. nextFlushedExpirationTime = expirationTime;
  11395. performWorkOnRoot(root, expirationTime, false);
  11396. // Flush any sync work that was scheduled by lifecycles
  11397. performSyncWork();
  11398. finishRendering();
  11399. }
  11400. function finishRendering() {
  11401. nestedUpdateCount = 0;
  11402. if (completedBatches !== null) {
  11403. var batches = completedBatches;
  11404. completedBatches = null;
  11405. for (var i = 0; i < batches.length; i++) {
  11406. var batch = batches[i];
  11407. try {
  11408. batch._onComplete();
  11409. } catch (error) {
  11410. if (!hasUnhandledError) {
  11411. hasUnhandledError = true;
  11412. unhandledError = error;
  11413. }
  11414. }
  11415. }
  11416. }
  11417. if (hasUnhandledError) {
  11418. var error = unhandledError;
  11419. unhandledError = null;
  11420. hasUnhandledError = false;
  11421. throw error;
  11422. }
  11423. }
  11424. function performWorkOnRoot(root, expirationTime, isAsync) {
  11425. !!isRendering ? invariant_1(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  11426. isRendering = true;
  11427. // Check if this is async work or sync/expired work.
  11428. if (!isAsync) {
  11429. // Flush sync work.
  11430. var finishedWork = root.finishedWork;
  11431. if (finishedWork !== null) {
  11432. // This root is already complete. We can commit it.
  11433. completeRoot(root, finishedWork, expirationTime);
  11434. } else {
  11435. root.finishedWork = null;
  11436. finishedWork = renderRoot(root, expirationTime, false);
  11437. if (finishedWork !== null) {
  11438. // We've completed the root. Commit it.
  11439. completeRoot(root, finishedWork, expirationTime);
  11440. }
  11441. }
  11442. } else {
  11443. // Flush async work.
  11444. var _finishedWork = root.finishedWork;
  11445. if (_finishedWork !== null) {
  11446. // This root is already complete. We can commit it.
  11447. completeRoot(root, _finishedWork, expirationTime);
  11448. } else {
  11449. root.finishedWork = null;
  11450. _finishedWork = renderRoot(root, expirationTime, true);
  11451. if (_finishedWork !== null) {
  11452. // We've completed the root. Check the deadline one more time
  11453. // before committing.
  11454. if (!shouldYield()) {
  11455. // Still time left. Commit the root.
  11456. completeRoot(root, _finishedWork, expirationTime);
  11457. } else {
  11458. // There's no time left. Mark this root as complete. We'll come
  11459. // back and commit it later.
  11460. root.finishedWork = _finishedWork;
  11461. }
  11462. }
  11463. }
  11464. }
  11465. isRendering = false;
  11466. }
  11467. function completeRoot(root, finishedWork, expirationTime) {
  11468. // Check if there's a batch that matches this expiration time.
  11469. var firstBatch = root.firstBatch;
  11470. if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) {
  11471. if (completedBatches === null) {
  11472. completedBatches = [firstBatch];
  11473. } else {
  11474. completedBatches.push(firstBatch);
  11475. }
  11476. if (firstBatch._defer) {
  11477. // This root is blocked from committing by a batch. Unschedule it until
  11478. // we receive another update.
  11479. root.finishedWork = finishedWork;
  11480. root.remainingExpirationTime = NoWork;
  11481. return;
  11482. }
  11483. }
  11484. // Commit the root.
  11485. root.finishedWork = null;
  11486. root.remainingExpirationTime = commitRoot(finishedWork);
  11487. }
  11488. // When working on async work, the reconciler asks the renderer if it should
  11489. // yield execution. For DOM, we implement this with requestIdleCallback.
  11490. function shouldYield() {
  11491. if (deadline === null) {
  11492. return false;
  11493. }
  11494. if (deadline.timeRemaining() > timeHeuristicForUnitOfWork) {
  11495. // Disregard deadline.didTimeout. Only expired work should be flushed
  11496. // during a timeout. This path is only hit for non-expired work.
  11497. return false;
  11498. }
  11499. deadlineDidExpire = true;
  11500. return true;
  11501. }
  11502. function onUncaughtError(error) {
  11503. !(nextFlushedRoot !== null) ? invariant_1(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  11504. // Unschedule this root so we don't work on it again until there's
  11505. // another update.
  11506. nextFlushedRoot.remainingExpirationTime = NoWork;
  11507. if (!hasUnhandledError) {
  11508. hasUnhandledError = true;
  11509. unhandledError = error;
  11510. }
  11511. }
  11512. // TODO: Batching should be implemented at the renderer level, not inside
  11513. // the reconciler.
  11514. function batchedUpdates(fn, a) {
  11515. var previousIsBatchingUpdates = isBatchingUpdates;
  11516. isBatchingUpdates = true;
  11517. try {
  11518. return fn(a);
  11519. } finally {
  11520. isBatchingUpdates = previousIsBatchingUpdates;
  11521. if (!isBatchingUpdates && !isRendering) {
  11522. performSyncWork();
  11523. }
  11524. }
  11525. }
  11526. // TODO: Batching should be implemented at the renderer level, not inside
  11527. // the reconciler.
  11528. function unbatchedUpdates(fn, a) {
  11529. if (isBatchingUpdates && !isUnbatchingUpdates) {
  11530. isUnbatchingUpdates = true;
  11531. try {
  11532. return fn(a);
  11533. } finally {
  11534. isUnbatchingUpdates = false;
  11535. }
  11536. }
  11537. return fn(a);
  11538. }
  11539. // TODO: Batching should be implemented at the renderer level, not within
  11540. // the reconciler.
  11541. function flushSync(fn, a) {
  11542. !!isRendering ? invariant_1(false, 'flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.') : void 0;
  11543. var previousIsBatchingUpdates = isBatchingUpdates;
  11544. isBatchingUpdates = true;
  11545. try {
  11546. return syncUpdates(fn, a);
  11547. } finally {
  11548. isBatchingUpdates = previousIsBatchingUpdates;
  11549. performSyncWork();
  11550. }
  11551. }
  11552. function interactiveUpdates(fn, a, b) {
  11553. if (isBatchingInteractiveUpdates) {
  11554. return fn(a, b);
  11555. }
  11556. // If there are any pending interactive updates, synchronously flush them.
  11557. // This needs to happen before we read any handlers, because the effect of
  11558. // the previous event may influence which handlers are called during
  11559. // this event.
  11560. if (!isBatchingUpdates && !isRendering && lowestPendingInteractiveExpirationTime !== NoWork) {
  11561. // Synchronously flush pending interactive updates.
  11562. performWork(lowestPendingInteractiveExpirationTime, false, null);
  11563. lowestPendingInteractiveExpirationTime = NoWork;
  11564. }
  11565. var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
  11566. var previousIsBatchingUpdates = isBatchingUpdates;
  11567. isBatchingInteractiveUpdates = true;
  11568. isBatchingUpdates = true;
  11569. try {
  11570. return fn(a, b);
  11571. } finally {
  11572. isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
  11573. isBatchingUpdates = previousIsBatchingUpdates;
  11574. if (!isBatchingUpdates && !isRendering) {
  11575. performSyncWork();
  11576. }
  11577. }
  11578. }
  11579. function flushInteractiveUpdates() {
  11580. if (!isRendering && lowestPendingInteractiveExpirationTime !== NoWork) {
  11581. // Synchronously flush pending interactive updates.
  11582. performWork(lowestPendingInteractiveExpirationTime, false, null);
  11583. lowestPendingInteractiveExpirationTime = NoWork;
  11584. }
  11585. }
  11586. function flushControlled(fn) {
  11587. var previousIsBatchingUpdates = isBatchingUpdates;
  11588. isBatchingUpdates = true;
  11589. try {
  11590. syncUpdates(fn);
  11591. } finally {
  11592. isBatchingUpdates = previousIsBatchingUpdates;
  11593. if (!isBatchingUpdates && !isRendering) {
  11594. performWork(Sync, false, null);
  11595. }
  11596. }
  11597. }
  11598. return {
  11599. recalculateCurrentTime: recalculateCurrentTime,
  11600. computeExpirationForFiber: computeExpirationForFiber,
  11601. scheduleWork: scheduleWork,
  11602. requestWork: requestWork,
  11603. flushRoot: flushRoot,
  11604. batchedUpdates: batchedUpdates,
  11605. unbatchedUpdates: unbatchedUpdates,
  11606. flushSync: flushSync,
  11607. flushControlled: flushControlled,
  11608. deferredUpdates: deferredUpdates,
  11609. syncUpdates: syncUpdates,
  11610. interactiveUpdates: interactiveUpdates,
  11611. flushInteractiveUpdates: flushInteractiveUpdates,
  11612. computeUniqueAsyncExpiration: computeUniqueAsyncExpiration,
  11613. legacyContext: legacyContext
  11614. };
  11615. };
  11616. var didWarnAboutNestedUpdates = void 0;
  11617. {
  11618. didWarnAboutNestedUpdates = false;
  11619. }
  11620. // 0 is PROD, 1 is DEV.
  11621. // Might add PROFILE later.
  11622. var ReactFiberReconciler$1 = function (config) {
  11623. var getPublicInstance = config.getPublicInstance;
  11624. var _ReactFiberScheduler = ReactFiberScheduler(config),
  11625. computeUniqueAsyncExpiration = _ReactFiberScheduler.computeUniqueAsyncExpiration,
  11626. recalculateCurrentTime = _ReactFiberScheduler.recalculateCurrentTime,
  11627. computeExpirationForFiber = _ReactFiberScheduler.computeExpirationForFiber,
  11628. scheduleWork = _ReactFiberScheduler.scheduleWork,
  11629. requestWork = _ReactFiberScheduler.requestWork,
  11630. flushRoot = _ReactFiberScheduler.flushRoot,
  11631. batchedUpdates = _ReactFiberScheduler.batchedUpdates,
  11632. unbatchedUpdates = _ReactFiberScheduler.unbatchedUpdates,
  11633. flushSync = _ReactFiberScheduler.flushSync,
  11634. flushControlled = _ReactFiberScheduler.flushControlled,
  11635. deferredUpdates = _ReactFiberScheduler.deferredUpdates,
  11636. syncUpdates = _ReactFiberScheduler.syncUpdates,
  11637. interactiveUpdates = _ReactFiberScheduler.interactiveUpdates,
  11638. flushInteractiveUpdates = _ReactFiberScheduler.flushInteractiveUpdates,
  11639. legacyContext = _ReactFiberScheduler.legacyContext;
  11640. var findCurrentUnmaskedContext = legacyContext.findCurrentUnmaskedContext,
  11641. isContextProvider = legacyContext.isContextProvider,
  11642. processChildContext = legacyContext.processChildContext;
  11643. function getContextForSubtree(parentComponent) {
  11644. if (!parentComponent) {
  11645. return emptyObject_1;
  11646. }
  11647. var fiber = get(parentComponent);
  11648. var parentContext = findCurrentUnmaskedContext(fiber);
  11649. return isContextProvider(fiber) ? processChildContext(fiber, parentContext) : parentContext;
  11650. }
  11651. function scheduleRootUpdate(current, element, currentTime, expirationTime, callback) {
  11652. {
  11653. if (ReactDebugCurrentFiber.phase === 'render' && ReactDebugCurrentFiber.current !== null && !didWarnAboutNestedUpdates) {
  11654. didWarnAboutNestedUpdates = true;
  11655. warning_1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(ReactDebugCurrentFiber.current) || 'Unknown');
  11656. }
  11657. }
  11658. callback = callback === undefined ? null : callback;
  11659. {
  11660. !(callback === null || typeof callback === 'function') ? warning_1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
  11661. }
  11662. var update = {
  11663. expirationTime: expirationTime,
  11664. partialState: { element: element },
  11665. callback: callback,
  11666. isReplace: false,
  11667. isForced: false,
  11668. capturedValue: null,
  11669. next: null
  11670. };
  11671. insertUpdateIntoFiber(current, update);
  11672. scheduleWork(current, expirationTime);
  11673. return expirationTime;
  11674. }
  11675. function updateContainerAtExpirationTime(element, container, parentComponent, currentTime, expirationTime, callback) {
  11676. // TODO: If this is a nested container, this won't be the root.
  11677. var current = container.current;
  11678. {
  11679. if (ReactFiberInstrumentation_1.debugTool) {
  11680. if (current.alternate === null) {
  11681. ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
  11682. } else if (element === null) {
  11683. ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
  11684. } else {
  11685. ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
  11686. }
  11687. }
  11688. }
  11689. var context = getContextForSubtree(parentComponent);
  11690. if (container.context === null) {
  11691. container.context = context;
  11692. } else {
  11693. container.pendingContext = context;
  11694. }
  11695. return scheduleRootUpdate(current, element, currentTime, expirationTime, callback);
  11696. }
  11697. function findHostInstance(component) {
  11698. var fiber = get(component);
  11699. if (fiber === undefined) {
  11700. if (typeof component.render === 'function') {
  11701. invariant_1(false, 'Unable to find node on an unmounted component.');
  11702. } else {
  11703. invariant_1(false, 'Argument appears to not be a ReactComponent. Keys: %s', Object.keys(component));
  11704. }
  11705. }
  11706. var hostFiber = findCurrentHostFiber(fiber);
  11707. if (hostFiber === null) {
  11708. return null;
  11709. }
  11710. return hostFiber.stateNode;
  11711. }
  11712. return {
  11713. createContainer: function (containerInfo, isAsync, hydrate) {
  11714. return createFiberRoot(containerInfo, isAsync, hydrate);
  11715. },
  11716. updateContainer: function (element, container, parentComponent, callback) {
  11717. var current = container.current;
  11718. var currentTime = recalculateCurrentTime();
  11719. var expirationTime = computeExpirationForFiber(current);
  11720. return updateContainerAtExpirationTime(element, container, parentComponent, currentTime, expirationTime, callback);
  11721. },
  11722. updateContainerAtExpirationTime: function (element, container, parentComponent, expirationTime, callback) {
  11723. var currentTime = recalculateCurrentTime();
  11724. return updateContainerAtExpirationTime(element, container, parentComponent, currentTime, expirationTime, callback);
  11725. },
  11726. flushRoot: flushRoot,
  11727. requestWork: requestWork,
  11728. computeUniqueAsyncExpiration: computeUniqueAsyncExpiration,
  11729. batchedUpdates: batchedUpdates,
  11730. unbatchedUpdates: unbatchedUpdates,
  11731. deferredUpdates: deferredUpdates,
  11732. syncUpdates: syncUpdates,
  11733. interactiveUpdates: interactiveUpdates,
  11734. flushInteractiveUpdates: flushInteractiveUpdates,
  11735. flushControlled: flushControlled,
  11736. flushSync: flushSync,
  11737. getPublicRootInstance: function (container) {
  11738. var containerFiber = container.current;
  11739. if (!containerFiber.child) {
  11740. return null;
  11741. }
  11742. switch (containerFiber.child.tag) {
  11743. case HostComponent:
  11744. return getPublicInstance(containerFiber.child.stateNode);
  11745. default:
  11746. return containerFiber.child.stateNode;
  11747. }
  11748. },
  11749. findHostInstance: findHostInstance,
  11750. findHostInstanceWithNoPortals: function (fiber) {
  11751. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  11752. if (hostFiber === null) {
  11753. return null;
  11754. }
  11755. return hostFiber.stateNode;
  11756. },
  11757. injectIntoDevTools: function (devToolsConfig) {
  11758. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  11759. return injectInternals(_assign({}, devToolsConfig, {
  11760. findHostInstanceByFiber: function (fiber) {
  11761. var hostFiber = findCurrentHostFiber(fiber);
  11762. if (hostFiber === null) {
  11763. return null;
  11764. }
  11765. return hostFiber.stateNode;
  11766. },
  11767. findFiberByHostInstance: function (instance) {
  11768. if (!findFiberByHostInstance) {
  11769. // Might not be implemented by the renderer.
  11770. return null;
  11771. }
  11772. return findFiberByHostInstance(instance);
  11773. }
  11774. }));
  11775. }
  11776. };
  11777. };
  11778. var ReactFiberReconciler$2 = Object.freeze({
  11779. default: ReactFiberReconciler$1
  11780. });
  11781. var ReactFiberReconciler$3 = ( ReactFiberReconciler$2 && ReactFiberReconciler$1 ) || ReactFiberReconciler$2;
  11782. // TODO: bundle Flow types with the package.
  11783. // TODO: decide on the top-level export form.
  11784. // This is hacky but makes it work with both Rollup and Jest.
  11785. var reactReconciler = ReactFiberReconciler$3['default'] ? ReactFiberReconciler$3['default'] : ReactFiberReconciler$3;
  11786. function createPortal$1(children, containerInfo,
  11787. // TODO: figure out the API for cross-renderer implementation.
  11788. implementation) {
  11789. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  11790. return {
  11791. // This tag allow us to uniquely identify this as a React Portal
  11792. $$typeof: REACT_PORTAL_TYPE,
  11793. key: key == null ? null : '' + key,
  11794. children: children,
  11795. containerInfo: containerInfo,
  11796. implementation: implementation
  11797. };
  11798. }
  11799. // TODO: this is special because it gets imported during build.
  11800. var ReactVersion = '16.3.2';
  11801. // a requestAnimationFrame, storing the time for the start of the frame, then
  11802. // scheduling a postMessage which gets scheduled after paint. Within the
  11803. // postMessage handler do as much work as possible until time + frame rate.
  11804. // By separating the idle call into a separate event tick we ensure that
  11805. // layout, paint and other browser work is counted against the available time.
  11806. // The frame rate is dynamically adjusted.
  11807. {
  11808. if (ExecutionEnvironment_1.canUseDOM && typeof requestAnimationFrame !== 'function') {
  11809. warning_1(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  11810. }
  11811. }
  11812. var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
  11813. var now = void 0;
  11814. if (hasNativePerformanceNow) {
  11815. now = function () {
  11816. return performance.now();
  11817. };
  11818. } else {
  11819. now = function () {
  11820. return Date.now();
  11821. };
  11822. }
  11823. // TODO: There's no way to cancel, because Fiber doesn't atm.
  11824. var rIC = void 0;
  11825. var cIC = void 0;
  11826. if (!ExecutionEnvironment_1.canUseDOM) {
  11827. rIC = function (frameCallback) {
  11828. return setTimeout(function () {
  11829. frameCallback({
  11830. timeRemaining: function () {
  11831. return Infinity;
  11832. },
  11833. didTimeout: false
  11834. });
  11835. });
  11836. };
  11837. cIC = function (timeoutID) {
  11838. clearTimeout(timeoutID);
  11839. };
  11840. } else if (alwaysUseRequestIdleCallbackPolyfill || typeof requestIdleCallback !== 'function' || typeof cancelIdleCallback !== 'function') {
  11841. // Polyfill requestIdleCallback and cancelIdleCallback
  11842. var scheduledRICCallback = null;
  11843. var isIdleScheduled = false;
  11844. var timeoutTime = -1;
  11845. var isAnimationFrameScheduled = false;
  11846. var frameDeadline = 0;
  11847. // We start out assuming that we run at 30fps but then the heuristic tracking
  11848. // will adjust this value to a faster fps if we get more frequent animation
  11849. // frames.
  11850. var previousFrameTime = 33;
  11851. var activeFrameTime = 33;
  11852. var frameDeadlineObject = void 0;
  11853. if (hasNativePerformanceNow) {
  11854. frameDeadlineObject = {
  11855. didTimeout: false,
  11856. timeRemaining: function () {
  11857. // We assume that if we have a performance timer that the rAF callback
  11858. // gets a performance timer value. Not sure if this is always true.
  11859. var remaining = frameDeadline - performance.now();
  11860. return remaining > 0 ? remaining : 0;
  11861. }
  11862. };
  11863. } else {
  11864. frameDeadlineObject = {
  11865. didTimeout: false,
  11866. timeRemaining: function () {
  11867. // Fallback to Date.now()
  11868. var remaining = frameDeadline - Date.now();
  11869. return remaining > 0 ? remaining : 0;
  11870. }
  11871. };
  11872. }
  11873. // We use the postMessage trick to defer idle work until after the repaint.
  11874. var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2);
  11875. var idleTick = function (event) {
  11876. if (event.source !== window || event.data !== messageKey) {
  11877. return;
  11878. }
  11879. isIdleScheduled = false;
  11880. var currentTime = now();
  11881. if (frameDeadline - currentTime <= 0) {
  11882. // There's no time left in this idle period. Check if the callback has
  11883. // a timeout and whether it's been exceeded.
  11884. if (timeoutTime !== -1 && timeoutTime <= currentTime) {
  11885. // Exceeded the timeout. Invoke the callback even though there's no
  11886. // time left.
  11887. frameDeadlineObject.didTimeout = true;
  11888. } else {
  11889. // No timeout.
  11890. if (!isAnimationFrameScheduled) {
  11891. // Schedule another animation callback so we retry later.
  11892. isAnimationFrameScheduled = true;
  11893. requestAnimationFrame(animationTick);
  11894. }
  11895. // Exit without invoking the callback.
  11896. return;
  11897. }
  11898. } else {
  11899. // There's still time left in this idle period.
  11900. frameDeadlineObject.didTimeout = false;
  11901. }
  11902. timeoutTime = -1;
  11903. var callback = scheduledRICCallback;
  11904. scheduledRICCallback = null;
  11905. if (callback !== null) {
  11906. callback(frameDeadlineObject);
  11907. }
  11908. };
  11909. // Assumes that we have addEventListener in this environment. Might need
  11910. // something better for old IE.
  11911. window.addEventListener('message', idleTick, false);
  11912. var animationTick = function (rafTime) {
  11913. isAnimationFrameScheduled = false;
  11914. var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
  11915. if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
  11916. if (nextFrameTime < 8) {
  11917. // Defensive coding. We don't support higher frame rates than 120hz.
  11918. // If we get lower than that, it is probably a bug.
  11919. nextFrameTime = 8;
  11920. }
  11921. // If one frame goes long, then the next one can be short to catch up.
  11922. // If two frames are short in a row, then that's an indication that we
  11923. // actually have a higher frame rate than what we're currently optimizing.
  11924. // We adjust our heuristic dynamically accordingly. For example, if we're
  11925. // running on 120hz display or 90hz VR display.
  11926. // Take the max of the two in case one of them was an anomaly due to
  11927. // missed frame deadlines.
  11928. activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
  11929. } else {
  11930. previousFrameTime = nextFrameTime;
  11931. }
  11932. frameDeadline = rafTime + activeFrameTime;
  11933. if (!isIdleScheduled) {
  11934. isIdleScheduled = true;
  11935. window.postMessage(messageKey, '*');
  11936. }
  11937. };
  11938. rIC = function (callback, options) {
  11939. // This assumes that we only schedule one callback at a time because that's
  11940. // how Fiber uses it.
  11941. scheduledRICCallback = callback;
  11942. if (options != null && typeof options.timeout === 'number') {
  11943. timeoutTime = now() + options.timeout;
  11944. }
  11945. if (!isAnimationFrameScheduled) {
  11946. // If rAF didn't already schedule one, we need to schedule a frame.
  11947. // TODO: If this rAF doesn't materialize because the browser throttles, we
  11948. // might want to still have setTimeout trigger rIC as a backup to ensure
  11949. // that we keep performing work.
  11950. isAnimationFrameScheduled = true;
  11951. requestAnimationFrame(animationTick);
  11952. }
  11953. return 0;
  11954. };
  11955. cIC = function () {
  11956. scheduledRICCallback = null;
  11957. isIdleScheduled = false;
  11958. timeoutTime = -1;
  11959. };
  11960. } else {
  11961. rIC = window.requestIdleCallback;
  11962. cIC = window.cancelIdleCallback;
  11963. }
  11964. var didWarnSelectedSetOnOption = false;
  11965. function flattenChildren(children) {
  11966. var content = '';
  11967. // Flatten children and warn if they aren't strings or numbers;
  11968. // invalid types are ignored.
  11969. // We can silently skip them because invalid DOM nesting warning
  11970. // catches these cases in Fiber.
  11971. React.Children.forEach(children, function (child) {
  11972. if (child == null) {
  11973. return;
  11974. }
  11975. if (typeof child === 'string' || typeof child === 'number') {
  11976. content += child;
  11977. }
  11978. });
  11979. return content;
  11980. }
  11981. /**
  11982. * Implements an <option> host component that warns when `selected` is set.
  11983. */
  11984. function validateProps(element, props) {
  11985. // TODO (yungsters): Remove support for `selected` in <option>.
  11986. {
  11987. if (props.selected != null && !didWarnSelectedSetOnOption) {
  11988. warning_1(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  11989. didWarnSelectedSetOnOption = true;
  11990. }
  11991. }
  11992. }
  11993. function postMountWrapper$1(element, props) {
  11994. // value="" should make a value attribute (#6219)
  11995. if (props.value != null) {
  11996. element.setAttribute('value', props.value);
  11997. }
  11998. }
  11999. function getHostProps$1(element, props) {
  12000. var hostProps = _assign({ children: undefined }, props);
  12001. var content = flattenChildren(props.children);
  12002. if (content) {
  12003. hostProps.children = content;
  12004. }
  12005. return hostProps;
  12006. }
  12007. // TODO: direct imports like some-package/src/* are bad. Fix me.
  12008. var getCurrentFiberOwnerName$3 = ReactDebugCurrentFiber.getCurrentFiberOwnerName;
  12009. var getCurrentFiberStackAddendum$4 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  12010. var didWarnValueDefaultValue$1 = void 0;
  12011. {
  12012. didWarnValueDefaultValue$1 = false;
  12013. }
  12014. function getDeclarationErrorAddendum() {
  12015. var ownerName = getCurrentFiberOwnerName$3();
  12016. if (ownerName) {
  12017. return '\n\nCheck the render method of `' + ownerName + '`.';
  12018. }
  12019. return '';
  12020. }
  12021. var valuePropNames = ['value', 'defaultValue'];
  12022. /**
  12023. * Validation function for `value` and `defaultValue`.
  12024. */
  12025. function checkSelectPropTypes(props) {
  12026. ReactControlledValuePropTypes.checkPropTypes('select', props, getCurrentFiberStackAddendum$4);
  12027. for (var i = 0; i < valuePropNames.length; i++) {
  12028. var propName = valuePropNames[i];
  12029. if (props[propName] == null) {
  12030. continue;
  12031. }
  12032. var isArray = Array.isArray(props[propName]);
  12033. if (props.multiple && !isArray) {
  12034. warning_1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  12035. } else if (!props.multiple && isArray) {
  12036. warning_1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  12037. }
  12038. }
  12039. }
  12040. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  12041. var options = node.options;
  12042. if (multiple) {
  12043. var selectedValues = propValue;
  12044. var selectedValue = {};
  12045. for (var i = 0; i < selectedValues.length; i++) {
  12046. // Prefix to avoid chaos with special keys.
  12047. selectedValue['$' + selectedValues[i]] = true;
  12048. }
  12049. for (var _i = 0; _i < options.length; _i++) {
  12050. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  12051. if (options[_i].selected !== selected) {
  12052. options[_i].selected = selected;
  12053. }
  12054. if (selected && setDefaultSelected) {
  12055. options[_i].defaultSelected = true;
  12056. }
  12057. }
  12058. } else {
  12059. // Do not set `select.value` as exact behavior isn't consistent across all
  12060. // browsers for all cases.
  12061. var _selectedValue = '' + propValue;
  12062. var defaultSelected = null;
  12063. for (var _i2 = 0; _i2 < options.length; _i2++) {
  12064. if (options[_i2].value === _selectedValue) {
  12065. options[_i2].selected = true;
  12066. if (setDefaultSelected) {
  12067. options[_i2].defaultSelected = true;
  12068. }
  12069. return;
  12070. }
  12071. if (defaultSelected === null && !options[_i2].disabled) {
  12072. defaultSelected = options[_i2];
  12073. }
  12074. }
  12075. if (defaultSelected !== null) {
  12076. defaultSelected.selected = true;
  12077. }
  12078. }
  12079. }
  12080. /**
  12081. * Implements a <select> host component that allows optionally setting the
  12082. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  12083. * stringable. If `multiple` is true, the prop must be an array of stringables.
  12084. *
  12085. * If `value` is not supplied (or null/undefined), user actions that change the
  12086. * selected option will trigger updates to the rendered options.
  12087. *
  12088. * If it is supplied (and not null/undefined), the rendered options will not
  12089. * update in response to user actions. Instead, the `value` prop must change in
  12090. * order for the rendered options to update.
  12091. *
  12092. * If `defaultValue` is provided, any options with the supplied values will be
  12093. * selected.
  12094. */
  12095. function getHostProps$2(element, props) {
  12096. return _assign({}, props, {
  12097. value: undefined
  12098. });
  12099. }
  12100. function initWrapperState$1(element, props) {
  12101. var node = element;
  12102. {
  12103. checkSelectPropTypes(props);
  12104. }
  12105. var value = props.value;
  12106. node._wrapperState = {
  12107. initialValue: value != null ? value : props.defaultValue,
  12108. wasMultiple: !!props.multiple
  12109. };
  12110. {
  12111. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  12112. warning_1(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
  12113. didWarnValueDefaultValue$1 = true;
  12114. }
  12115. }
  12116. }
  12117. function postMountWrapper$2(element, props) {
  12118. var node = element;
  12119. node.multiple = !!props.multiple;
  12120. var value = props.value;
  12121. if (value != null) {
  12122. updateOptions(node, !!props.multiple, value, false);
  12123. } else if (props.defaultValue != null) {
  12124. updateOptions(node, !!props.multiple, props.defaultValue, true);
  12125. }
  12126. }
  12127. function postUpdateWrapper(element, props) {
  12128. var node = element;
  12129. // After the initial mount, we control selected-ness manually so don't pass
  12130. // this value down
  12131. node._wrapperState.initialValue = undefined;
  12132. var wasMultiple = node._wrapperState.wasMultiple;
  12133. node._wrapperState.wasMultiple = !!props.multiple;
  12134. var value = props.value;
  12135. if (value != null) {
  12136. updateOptions(node, !!props.multiple, value, false);
  12137. } else if (wasMultiple !== !!props.multiple) {
  12138. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  12139. if (props.defaultValue != null) {
  12140. updateOptions(node, !!props.multiple, props.defaultValue, true);
  12141. } else {
  12142. // Revert the select back to its default unselected state.
  12143. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  12144. }
  12145. }
  12146. }
  12147. function restoreControlledState$2(element, props) {
  12148. var node = element;
  12149. var value = props.value;
  12150. if (value != null) {
  12151. updateOptions(node, !!props.multiple, value, false);
  12152. }
  12153. }
  12154. // TODO: direct imports like some-package/src/* are bad. Fix me.
  12155. var getCurrentFiberStackAddendum$5 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  12156. var didWarnValDefaultVal = false;
  12157. /**
  12158. * Implements a <textarea> host component that allows setting `value`, and
  12159. * `defaultValue`. This differs from the traditional DOM API because value is
  12160. * usually set as PCDATA children.
  12161. *
  12162. * If `value` is not supplied (or null/undefined), user actions that affect the
  12163. * value will trigger updates to the element.
  12164. *
  12165. * If `value` is supplied (and not null/undefined), the rendered element will
  12166. * not trigger updates to the element. Instead, the `value` prop must change in
  12167. * order for the rendered element to be updated.
  12168. *
  12169. * The rendered element will be initialized with an empty value, the prop
  12170. * `defaultValue` if specified, or the children content (deprecated).
  12171. */
  12172. function getHostProps$3(element, props) {
  12173. var node = element;
  12174. !(props.dangerouslySetInnerHTML == null) ? invariant_1(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : void 0;
  12175. // Always set children to the same thing. In IE9, the selection range will
  12176. // get reset if `textContent` is mutated. We could add a check in setTextContent
  12177. // to only set the value if/when the value differs from the node value (which would
  12178. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  12179. // solution. The value can be a boolean or object so that's why it's forced
  12180. // to be a string.
  12181. var hostProps = _assign({}, props, {
  12182. value: undefined,
  12183. defaultValue: undefined,
  12184. children: '' + node._wrapperState.initialValue
  12185. });
  12186. return hostProps;
  12187. }
  12188. function initWrapperState$2(element, props) {
  12189. var node = element;
  12190. {
  12191. ReactControlledValuePropTypes.checkPropTypes('textarea', props, getCurrentFiberStackAddendum$5);
  12192. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  12193. warning_1(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
  12194. didWarnValDefaultVal = true;
  12195. }
  12196. }
  12197. var initialValue = props.value;
  12198. // Only bother fetching default value if we're going to use it
  12199. if (initialValue == null) {
  12200. var defaultValue = props.defaultValue;
  12201. // TODO (yungsters): Remove support for children content in <textarea>.
  12202. var children = props.children;
  12203. if (children != null) {
  12204. {
  12205. warning_1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  12206. }
  12207. !(defaultValue == null) ? invariant_1(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0;
  12208. if (Array.isArray(children)) {
  12209. !(children.length <= 1) ? invariant_1(false, '<textarea> can only have at most one child.') : void 0;
  12210. children = children[0];
  12211. }
  12212. defaultValue = '' + children;
  12213. }
  12214. if (defaultValue == null) {
  12215. defaultValue = '';
  12216. }
  12217. initialValue = defaultValue;
  12218. }
  12219. node._wrapperState = {
  12220. initialValue: '' + initialValue
  12221. };
  12222. }
  12223. function updateWrapper$1(element, props) {
  12224. var node = element;
  12225. var value = props.value;
  12226. if (value != null) {
  12227. // Cast `value` to a string to ensure the value is set correctly. While
  12228. // browsers typically do this as necessary, jsdom doesn't.
  12229. var newValue = '' + value;
  12230. // To avoid side effects (such as losing text selection), only set value if changed
  12231. if (newValue !== node.value) {
  12232. node.value = newValue;
  12233. }
  12234. if (props.defaultValue == null) {
  12235. node.defaultValue = newValue;
  12236. }
  12237. }
  12238. if (props.defaultValue != null) {
  12239. node.defaultValue = props.defaultValue;
  12240. }
  12241. }
  12242. function postMountWrapper$3(element, props) {
  12243. var node = element;
  12244. // This is in postMount because we need access to the DOM node, which is not
  12245. // available until after the component has mounted.
  12246. var textContent = node.textContent;
  12247. // Only set node.value if textContent is equal to the expected
  12248. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  12249. // will populate textContent as well.
  12250. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  12251. if (textContent === node._wrapperState.initialValue) {
  12252. node.value = textContent;
  12253. }
  12254. }
  12255. function restoreControlledState$3(element, props) {
  12256. // DOM component is still mounted; update
  12257. updateWrapper$1(element, props);
  12258. }
  12259. var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml';
  12260. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  12261. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  12262. var Namespaces = {
  12263. html: HTML_NAMESPACE$1,
  12264. mathml: MATH_NAMESPACE,
  12265. svg: SVG_NAMESPACE
  12266. };
  12267. // Assumes there is no parent namespace.
  12268. function getIntrinsicNamespace(type) {
  12269. switch (type) {
  12270. case 'svg':
  12271. return SVG_NAMESPACE;
  12272. case 'math':
  12273. return MATH_NAMESPACE;
  12274. default:
  12275. return HTML_NAMESPACE$1;
  12276. }
  12277. }
  12278. function getChildNamespace(parentNamespace, type) {
  12279. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) {
  12280. // No (or default) parent namespace: potential entry point.
  12281. return getIntrinsicNamespace(type);
  12282. }
  12283. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  12284. // We're leaving SVG.
  12285. return HTML_NAMESPACE$1;
  12286. }
  12287. // By default, pass namespace below.
  12288. return parentNamespace;
  12289. }
  12290. /* globals MSApp */
  12291. /**
  12292. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  12293. */
  12294. var createMicrosoftUnsafeLocalFunction = function (func) {
  12295. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  12296. return function (arg0, arg1, arg2, arg3) {
  12297. MSApp.execUnsafeLocalFunction(function () {
  12298. return func(arg0, arg1, arg2, arg3);
  12299. });
  12300. };
  12301. } else {
  12302. return func;
  12303. }
  12304. };
  12305. // SVG temp container for IE lacking innerHTML
  12306. var reusableSVGContainer = void 0;
  12307. /**
  12308. * Set the innerHTML property of a node
  12309. *
  12310. * @param {DOMElement} node
  12311. * @param {string} html
  12312. * @internal
  12313. */
  12314. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  12315. // IE does not have innerHTML for SVG nodes, so instead we inject the
  12316. // new markup in a temp node and then move the child nodes across into
  12317. // the target node
  12318. if (node.namespaceURI === Namespaces.svg && !('innerHTML' in node)) {
  12319. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  12320. reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
  12321. var svgNode = reusableSVGContainer.firstChild;
  12322. while (node.firstChild) {
  12323. node.removeChild(node.firstChild);
  12324. }
  12325. while (svgNode.firstChild) {
  12326. node.appendChild(svgNode.firstChild);
  12327. }
  12328. } else {
  12329. node.innerHTML = html;
  12330. }
  12331. });
  12332. /**
  12333. * Set the textContent property of a node. For text updates, it's faster
  12334. * to set the `nodeValue` of the Text node directly instead of using
  12335. * `.textContent` which will remove the existing node and create a new one.
  12336. *
  12337. * @param {DOMElement} node
  12338. * @param {string} text
  12339. * @internal
  12340. */
  12341. var setTextContent = function (node, text) {
  12342. if (text) {
  12343. var firstChild = node.firstChild;
  12344. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  12345. firstChild.nodeValue = text;
  12346. return;
  12347. }
  12348. }
  12349. node.textContent = text;
  12350. };
  12351. /**
  12352. * CSS properties which accept numbers but are not in units of "px".
  12353. */
  12354. var isUnitlessNumber = {
  12355. animationIterationCount: true,
  12356. borderImageOutset: true,
  12357. borderImageSlice: true,
  12358. borderImageWidth: true,
  12359. boxFlex: true,
  12360. boxFlexGroup: true,
  12361. boxOrdinalGroup: true,
  12362. columnCount: true,
  12363. columns: true,
  12364. flex: true,
  12365. flexGrow: true,
  12366. flexPositive: true,
  12367. flexShrink: true,
  12368. flexNegative: true,
  12369. flexOrder: true,
  12370. gridRow: true,
  12371. gridRowEnd: true,
  12372. gridRowSpan: true,
  12373. gridRowStart: true,
  12374. gridColumn: true,
  12375. gridColumnEnd: true,
  12376. gridColumnSpan: true,
  12377. gridColumnStart: true,
  12378. fontWeight: true,
  12379. lineClamp: true,
  12380. lineHeight: true,
  12381. opacity: true,
  12382. order: true,
  12383. orphans: true,
  12384. tabSize: true,
  12385. widows: true,
  12386. zIndex: true,
  12387. zoom: true,
  12388. // SVG-related properties
  12389. fillOpacity: true,
  12390. floodOpacity: true,
  12391. stopOpacity: true,
  12392. strokeDasharray: true,
  12393. strokeDashoffset: true,
  12394. strokeMiterlimit: true,
  12395. strokeOpacity: true,
  12396. strokeWidth: true
  12397. };
  12398. /**
  12399. * @param {string} prefix vendor-specific prefix, eg: Webkit
  12400. * @param {string} key style name, eg: transitionDuration
  12401. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  12402. * WebkitTransitionDuration
  12403. */
  12404. function prefixKey(prefix, key) {
  12405. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  12406. }
  12407. /**
  12408. * Support style names that may come passed in prefixed by adding permutations
  12409. * of vendor prefixes.
  12410. */
  12411. var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
  12412. // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  12413. // infinite loop, because it iterates over the newly added props too.
  12414. Object.keys(isUnitlessNumber).forEach(function (prop) {
  12415. prefixes.forEach(function (prefix) {
  12416. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  12417. });
  12418. });
  12419. /**
  12420. * Convert a value into the proper css writable value. The style name `name`
  12421. * should be logical (no hyphens), as specified
  12422. * in `CSSProperty.isUnitlessNumber`.
  12423. *
  12424. * @param {string} name CSS property name such as `topMargin`.
  12425. * @param {*} value CSS property value such as `10px`.
  12426. * @return {string} Normalized style value with dimensions applied.
  12427. */
  12428. function dangerousStyleValue(name, value, isCustomProperty) {
  12429. // Note that we've removed escapeTextForBrowser() calls here since the
  12430. // whole string will be escaped when the attribute is injected into
  12431. // the markup. If you provide unsafe user data here they can inject
  12432. // arbitrary CSS which may be problematic (I couldn't repro this):
  12433. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  12434. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  12435. // This is not an XSS hole but instead a potential CSS injection issue
  12436. // which has lead to a greater discussion about how we're going to
  12437. // trust URLs moving forward. See #2115901
  12438. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  12439. if (isEmpty) {
  12440. return '';
  12441. }
  12442. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  12443. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  12444. }
  12445. return ('' + value).trim();
  12446. }
  12447. /**
  12448. * Copyright (c) 2013-present, Facebook, Inc.
  12449. *
  12450. * This source code is licensed under the MIT license found in the
  12451. * LICENSE file in the root directory of this source tree.
  12452. *
  12453. * @typechecks
  12454. */
  12455. var _uppercasePattern = /([A-Z])/g;
  12456. /**
  12457. * Hyphenates a camelcased string, for example:
  12458. *
  12459. * > hyphenate('backgroundColor')
  12460. * < "background-color"
  12461. *
  12462. * For CSS style names, use `hyphenateStyleName` instead which works properly
  12463. * with all vendor prefixes, including `ms`.
  12464. *
  12465. * @param {string} string
  12466. * @return {string}
  12467. */
  12468. function hyphenate(string) {
  12469. return string.replace(_uppercasePattern, '-$1').toLowerCase();
  12470. }
  12471. var hyphenate_1 = hyphenate;
  12472. /**
  12473. * Copyright (c) 2013-present, Facebook, Inc.
  12474. *
  12475. * This source code is licensed under the MIT license found in the
  12476. * LICENSE file in the root directory of this source tree.
  12477. *
  12478. * @typechecks
  12479. */
  12480. var msPattern = /^ms-/;
  12481. /**
  12482. * Hyphenates a camelcased CSS property name, for example:
  12483. *
  12484. * > hyphenateStyleName('backgroundColor')
  12485. * < "background-color"
  12486. * > hyphenateStyleName('MozTransition')
  12487. * < "-moz-transition"
  12488. * > hyphenateStyleName('msTransition')
  12489. * < "-ms-transition"
  12490. *
  12491. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  12492. * is converted to `-ms-`.
  12493. *
  12494. * @param {string} string
  12495. * @return {string}
  12496. */
  12497. function hyphenateStyleName(string) {
  12498. return hyphenate_1(string).replace(msPattern, '-ms-');
  12499. }
  12500. var hyphenateStyleName_1 = hyphenateStyleName;
  12501. /**
  12502. * Copyright (c) 2013-present, Facebook, Inc.
  12503. *
  12504. * This source code is licensed under the MIT license found in the
  12505. * LICENSE file in the root directory of this source tree.
  12506. *
  12507. * @typechecks
  12508. */
  12509. var _hyphenPattern = /-(.)/g;
  12510. /**
  12511. * Camelcases a hyphenated string, for example:
  12512. *
  12513. * > camelize('background-color')
  12514. * < "backgroundColor"
  12515. *
  12516. * @param {string} string
  12517. * @return {string}
  12518. */
  12519. function camelize(string) {
  12520. return string.replace(_hyphenPattern, function (_, character) {
  12521. return character.toUpperCase();
  12522. });
  12523. }
  12524. var camelize_1 = camelize;
  12525. /**
  12526. * Copyright (c) 2013-present, Facebook, Inc.
  12527. *
  12528. * This source code is licensed under the MIT license found in the
  12529. * LICENSE file in the root directory of this source tree.
  12530. *
  12531. * @typechecks
  12532. */
  12533. var msPattern$1 = /^-ms-/;
  12534. /**
  12535. * Camelcases a hyphenated CSS property name, for example:
  12536. *
  12537. * > camelizeStyleName('background-color')
  12538. * < "backgroundColor"
  12539. * > camelizeStyleName('-moz-transition')
  12540. * < "MozTransition"
  12541. * > camelizeStyleName('-ms-transition')
  12542. * < "msTransition"
  12543. *
  12544. * As Andi Smith suggests
  12545. * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  12546. * is converted to lowercase `ms`.
  12547. *
  12548. * @param {string} string
  12549. * @return {string}
  12550. */
  12551. function camelizeStyleName(string) {
  12552. return camelize_1(string.replace(msPattern$1, 'ms-'));
  12553. }
  12554. var camelizeStyleName_1 = camelizeStyleName;
  12555. var warnValidStyle = emptyFunction_1;
  12556. {
  12557. // 'msTransform' is correct, but the other prefixes should be capitalized
  12558. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  12559. // style values shouldn't contain a semicolon
  12560. var badStyleValueWithSemicolonPattern = /;\s*$/;
  12561. var warnedStyleNames = {};
  12562. var warnedStyleValues = {};
  12563. var warnedForNaNValue = false;
  12564. var warnedForInfinityValue = false;
  12565. var warnHyphenatedStyleName = function (name, getStack) {
  12566. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  12567. return;
  12568. }
  12569. warnedStyleNames[name] = true;
  12570. warning_1(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName_1(name), getStack());
  12571. };
  12572. var warnBadVendoredStyleName = function (name, getStack) {
  12573. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  12574. return;
  12575. }
  12576. warnedStyleNames[name] = true;
  12577. warning_1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), getStack());
  12578. };
  12579. var warnStyleValueWithSemicolon = function (name, value, getStack) {
  12580. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  12581. return;
  12582. }
  12583. warnedStyleValues[value] = true;
  12584. warning_1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.%s', name, value.replace(badStyleValueWithSemicolonPattern, ''), getStack());
  12585. };
  12586. var warnStyleValueIsNaN = function (name, value, getStack) {
  12587. if (warnedForNaNValue) {
  12588. return;
  12589. }
  12590. warnedForNaNValue = true;
  12591. warning_1(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, getStack());
  12592. };
  12593. var warnStyleValueIsInfinity = function (name, value, getStack) {
  12594. if (warnedForInfinityValue) {
  12595. return;
  12596. }
  12597. warnedForInfinityValue = true;
  12598. warning_1(false, '`Infinity` is an invalid value for the `%s` css style property.%s', name, getStack());
  12599. };
  12600. warnValidStyle = function (name, value, getStack) {
  12601. if (name.indexOf('-') > -1) {
  12602. warnHyphenatedStyleName(name, getStack);
  12603. } else if (badVendoredStyleNamePattern.test(name)) {
  12604. warnBadVendoredStyleName(name, getStack);
  12605. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  12606. warnStyleValueWithSemicolon(name, value, getStack);
  12607. }
  12608. if (typeof value === 'number') {
  12609. if (isNaN(value)) {
  12610. warnStyleValueIsNaN(name, value, getStack);
  12611. } else if (!isFinite(value)) {
  12612. warnStyleValueIsInfinity(name, value, getStack);
  12613. }
  12614. }
  12615. };
  12616. }
  12617. var warnValidStyle$1 = warnValidStyle;
  12618. /**
  12619. * Operations for dealing with CSS properties.
  12620. */
  12621. /**
  12622. * This creates a string that is expected to be equivalent to the style
  12623. * attribute generated by server-side rendering. It by-passes warnings and
  12624. * security checks so it's not safe to use this value for anything other than
  12625. * comparison. It is only used in DEV for SSR validation.
  12626. */
  12627. function createDangerousStringForStyles(styles) {
  12628. {
  12629. var serialized = '';
  12630. var delimiter = '';
  12631. for (var styleName in styles) {
  12632. if (!styles.hasOwnProperty(styleName)) {
  12633. continue;
  12634. }
  12635. var styleValue = styles[styleName];
  12636. if (styleValue != null) {
  12637. var isCustomProperty = styleName.indexOf('--') === 0;
  12638. serialized += delimiter + hyphenateStyleName_1(styleName) + ':';
  12639. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  12640. delimiter = ';';
  12641. }
  12642. }
  12643. return serialized || null;
  12644. }
  12645. }
  12646. /**
  12647. * Sets the value for multiple styles on a node. If a value is specified as
  12648. * '' (empty string), the corresponding style property will be unset.
  12649. *
  12650. * @param {DOMElement} node
  12651. * @param {object} styles
  12652. */
  12653. function setValueForStyles(node, styles, getStack) {
  12654. var style = node.style;
  12655. for (var styleName in styles) {
  12656. if (!styles.hasOwnProperty(styleName)) {
  12657. continue;
  12658. }
  12659. var isCustomProperty = styleName.indexOf('--') === 0;
  12660. {
  12661. if (!isCustomProperty) {
  12662. warnValidStyle$1(styleName, styles[styleName], getStack);
  12663. }
  12664. }
  12665. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  12666. if (styleName === 'float') {
  12667. styleName = 'cssFloat';
  12668. }
  12669. if (isCustomProperty) {
  12670. style.setProperty(styleName, styleValue);
  12671. } else {
  12672. style[styleName] = styleValue;
  12673. }
  12674. }
  12675. }
  12676. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  12677. // those special-case tags.
  12678. var omittedCloseTags = {
  12679. area: true,
  12680. base: true,
  12681. br: true,
  12682. col: true,
  12683. embed: true,
  12684. hr: true,
  12685. img: true,
  12686. input: true,
  12687. keygen: true,
  12688. link: true,
  12689. meta: true,
  12690. param: true,
  12691. source: true,
  12692. track: true,
  12693. wbr: true
  12694. };
  12695. // For HTML, certain tags cannot have children. This has the same purpose as
  12696. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  12697. var voidElementTags = _assign({
  12698. menuitem: true
  12699. }, omittedCloseTags);
  12700. var HTML$1 = '__html';
  12701. function assertValidProps(tag, props, getStack) {
  12702. if (!props) {
  12703. return;
  12704. }
  12705. // Note the use of `==` which checks for null or undefined.
  12706. if (voidElementTags[tag]) {
  12707. !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant_1(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, getStack()) : void 0;
  12708. }
  12709. if (props.dangerouslySetInnerHTML != null) {
  12710. !(props.children == null) ? invariant_1(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0;
  12711. !(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML) ? invariant_1(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0;
  12712. }
  12713. {
  12714. !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning_1(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack()) : void 0;
  12715. }
  12716. !(props.style == null || typeof props.style === 'object') ? invariant_1(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getStack()) : void 0;
  12717. }
  12718. function isCustomComponent(tagName, props) {
  12719. if (tagName.indexOf('-') === -1) {
  12720. return typeof props.is === 'string';
  12721. }
  12722. switch (tagName) {
  12723. // These are reserved SVG and MathML elements.
  12724. // We don't mind this whitelist too much because we expect it to never grow.
  12725. // The alternative is to track the namespace in a few places which is convoluted.
  12726. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  12727. case 'annotation-xml':
  12728. case 'color-profile':
  12729. case 'font-face':
  12730. case 'font-face-src':
  12731. case 'font-face-uri':
  12732. case 'font-face-format':
  12733. case 'font-face-name':
  12734. case 'missing-glyph':
  12735. return false;
  12736. default:
  12737. return true;
  12738. }
  12739. }
  12740. // When adding attributes to the HTML or SVG whitelist, be sure to
  12741. // also add them to this module to ensure casing and incorrect name
  12742. // warnings.
  12743. var possibleStandardNames = {
  12744. // HTML
  12745. accept: 'accept',
  12746. acceptcharset: 'acceptCharset',
  12747. 'accept-charset': 'acceptCharset',
  12748. accesskey: 'accessKey',
  12749. action: 'action',
  12750. allowfullscreen: 'allowFullScreen',
  12751. alt: 'alt',
  12752. as: 'as',
  12753. async: 'async',
  12754. autocapitalize: 'autoCapitalize',
  12755. autocomplete: 'autoComplete',
  12756. autocorrect: 'autoCorrect',
  12757. autofocus: 'autoFocus',
  12758. autoplay: 'autoPlay',
  12759. autosave: 'autoSave',
  12760. capture: 'capture',
  12761. cellpadding: 'cellPadding',
  12762. cellspacing: 'cellSpacing',
  12763. challenge: 'challenge',
  12764. charset: 'charSet',
  12765. checked: 'checked',
  12766. children: 'children',
  12767. cite: 'cite',
  12768. 'class': 'className',
  12769. classid: 'classID',
  12770. classname: 'className',
  12771. cols: 'cols',
  12772. colspan: 'colSpan',
  12773. content: 'content',
  12774. contenteditable: 'contentEditable',
  12775. contextmenu: 'contextMenu',
  12776. controls: 'controls',
  12777. controlslist: 'controlsList',
  12778. coords: 'coords',
  12779. crossorigin: 'crossOrigin',
  12780. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  12781. data: 'data',
  12782. datetime: 'dateTime',
  12783. 'default': 'default',
  12784. defaultchecked: 'defaultChecked',
  12785. defaultvalue: 'defaultValue',
  12786. defer: 'defer',
  12787. dir: 'dir',
  12788. disabled: 'disabled',
  12789. download: 'download',
  12790. draggable: 'draggable',
  12791. enctype: 'encType',
  12792. 'for': 'htmlFor',
  12793. form: 'form',
  12794. formmethod: 'formMethod',
  12795. formaction: 'formAction',
  12796. formenctype: 'formEncType',
  12797. formnovalidate: 'formNoValidate',
  12798. formtarget: 'formTarget',
  12799. frameborder: 'frameBorder',
  12800. headers: 'headers',
  12801. height: 'height',
  12802. hidden: 'hidden',
  12803. high: 'high',
  12804. href: 'href',
  12805. hreflang: 'hrefLang',
  12806. htmlfor: 'htmlFor',
  12807. httpequiv: 'httpEquiv',
  12808. 'http-equiv': 'httpEquiv',
  12809. icon: 'icon',
  12810. id: 'id',
  12811. innerhtml: 'innerHTML',
  12812. inputmode: 'inputMode',
  12813. integrity: 'integrity',
  12814. is: 'is',
  12815. itemid: 'itemID',
  12816. itemprop: 'itemProp',
  12817. itemref: 'itemRef',
  12818. itemscope: 'itemScope',
  12819. itemtype: 'itemType',
  12820. keyparams: 'keyParams',
  12821. keytype: 'keyType',
  12822. kind: 'kind',
  12823. label: 'label',
  12824. lang: 'lang',
  12825. list: 'list',
  12826. loop: 'loop',
  12827. low: 'low',
  12828. manifest: 'manifest',
  12829. marginwidth: 'marginWidth',
  12830. marginheight: 'marginHeight',
  12831. max: 'max',
  12832. maxlength: 'maxLength',
  12833. media: 'media',
  12834. mediagroup: 'mediaGroup',
  12835. method: 'method',
  12836. min: 'min',
  12837. minlength: 'minLength',
  12838. multiple: 'multiple',
  12839. muted: 'muted',
  12840. name: 'name',
  12841. nomodule: 'noModule',
  12842. nonce: 'nonce',
  12843. novalidate: 'noValidate',
  12844. open: 'open',
  12845. optimum: 'optimum',
  12846. pattern: 'pattern',
  12847. placeholder: 'placeholder',
  12848. playsinline: 'playsInline',
  12849. poster: 'poster',
  12850. preload: 'preload',
  12851. profile: 'profile',
  12852. radiogroup: 'radioGroup',
  12853. readonly: 'readOnly',
  12854. referrerpolicy: 'referrerPolicy',
  12855. rel: 'rel',
  12856. required: 'required',
  12857. reversed: 'reversed',
  12858. role: 'role',
  12859. rows: 'rows',
  12860. rowspan: 'rowSpan',
  12861. sandbox: 'sandbox',
  12862. scope: 'scope',
  12863. scoped: 'scoped',
  12864. scrolling: 'scrolling',
  12865. seamless: 'seamless',
  12866. selected: 'selected',
  12867. shape: 'shape',
  12868. size: 'size',
  12869. sizes: 'sizes',
  12870. span: 'span',
  12871. spellcheck: 'spellCheck',
  12872. src: 'src',
  12873. srcdoc: 'srcDoc',
  12874. srclang: 'srcLang',
  12875. srcset: 'srcSet',
  12876. start: 'start',
  12877. step: 'step',
  12878. style: 'style',
  12879. summary: 'summary',
  12880. tabindex: 'tabIndex',
  12881. target: 'target',
  12882. title: 'title',
  12883. type: 'type',
  12884. usemap: 'useMap',
  12885. value: 'value',
  12886. width: 'width',
  12887. wmode: 'wmode',
  12888. wrap: 'wrap',
  12889. // SVG
  12890. about: 'about',
  12891. accentheight: 'accentHeight',
  12892. 'accent-height': 'accentHeight',
  12893. accumulate: 'accumulate',
  12894. additive: 'additive',
  12895. alignmentbaseline: 'alignmentBaseline',
  12896. 'alignment-baseline': 'alignmentBaseline',
  12897. allowreorder: 'allowReorder',
  12898. alphabetic: 'alphabetic',
  12899. amplitude: 'amplitude',
  12900. arabicform: 'arabicForm',
  12901. 'arabic-form': 'arabicForm',
  12902. ascent: 'ascent',
  12903. attributename: 'attributeName',
  12904. attributetype: 'attributeType',
  12905. autoreverse: 'autoReverse',
  12906. azimuth: 'azimuth',
  12907. basefrequency: 'baseFrequency',
  12908. baselineshift: 'baselineShift',
  12909. 'baseline-shift': 'baselineShift',
  12910. baseprofile: 'baseProfile',
  12911. bbox: 'bbox',
  12912. begin: 'begin',
  12913. bias: 'bias',
  12914. by: 'by',
  12915. calcmode: 'calcMode',
  12916. capheight: 'capHeight',
  12917. 'cap-height': 'capHeight',
  12918. clip: 'clip',
  12919. clippath: 'clipPath',
  12920. 'clip-path': 'clipPath',
  12921. clippathunits: 'clipPathUnits',
  12922. cliprule: 'clipRule',
  12923. 'clip-rule': 'clipRule',
  12924. color: 'color',
  12925. colorinterpolation: 'colorInterpolation',
  12926. 'color-interpolation': 'colorInterpolation',
  12927. colorinterpolationfilters: 'colorInterpolationFilters',
  12928. 'color-interpolation-filters': 'colorInterpolationFilters',
  12929. colorprofile: 'colorProfile',
  12930. 'color-profile': 'colorProfile',
  12931. colorrendering: 'colorRendering',
  12932. 'color-rendering': 'colorRendering',
  12933. contentscripttype: 'contentScriptType',
  12934. contentstyletype: 'contentStyleType',
  12935. cursor: 'cursor',
  12936. cx: 'cx',
  12937. cy: 'cy',
  12938. d: 'd',
  12939. datatype: 'datatype',
  12940. decelerate: 'decelerate',
  12941. descent: 'descent',
  12942. diffuseconstant: 'diffuseConstant',
  12943. direction: 'direction',
  12944. display: 'display',
  12945. divisor: 'divisor',
  12946. dominantbaseline: 'dominantBaseline',
  12947. 'dominant-baseline': 'dominantBaseline',
  12948. dur: 'dur',
  12949. dx: 'dx',
  12950. dy: 'dy',
  12951. edgemode: 'edgeMode',
  12952. elevation: 'elevation',
  12953. enablebackground: 'enableBackground',
  12954. 'enable-background': 'enableBackground',
  12955. end: 'end',
  12956. exponent: 'exponent',
  12957. externalresourcesrequired: 'externalResourcesRequired',
  12958. fill: 'fill',
  12959. fillopacity: 'fillOpacity',
  12960. 'fill-opacity': 'fillOpacity',
  12961. fillrule: 'fillRule',
  12962. 'fill-rule': 'fillRule',
  12963. filter: 'filter',
  12964. filterres: 'filterRes',
  12965. filterunits: 'filterUnits',
  12966. floodopacity: 'floodOpacity',
  12967. 'flood-opacity': 'floodOpacity',
  12968. floodcolor: 'floodColor',
  12969. 'flood-color': 'floodColor',
  12970. focusable: 'focusable',
  12971. fontfamily: 'fontFamily',
  12972. 'font-family': 'fontFamily',
  12973. fontsize: 'fontSize',
  12974. 'font-size': 'fontSize',
  12975. fontsizeadjust: 'fontSizeAdjust',
  12976. 'font-size-adjust': 'fontSizeAdjust',
  12977. fontstretch: 'fontStretch',
  12978. 'font-stretch': 'fontStretch',
  12979. fontstyle: 'fontStyle',
  12980. 'font-style': 'fontStyle',
  12981. fontvariant: 'fontVariant',
  12982. 'font-variant': 'fontVariant',
  12983. fontweight: 'fontWeight',
  12984. 'font-weight': 'fontWeight',
  12985. format: 'format',
  12986. from: 'from',
  12987. fx: 'fx',
  12988. fy: 'fy',
  12989. g1: 'g1',
  12990. g2: 'g2',
  12991. glyphname: 'glyphName',
  12992. 'glyph-name': 'glyphName',
  12993. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  12994. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  12995. glyphorientationvertical: 'glyphOrientationVertical',
  12996. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  12997. glyphref: 'glyphRef',
  12998. gradienttransform: 'gradientTransform',
  12999. gradientunits: 'gradientUnits',
  13000. hanging: 'hanging',
  13001. horizadvx: 'horizAdvX',
  13002. 'horiz-adv-x': 'horizAdvX',
  13003. horizoriginx: 'horizOriginX',
  13004. 'horiz-origin-x': 'horizOriginX',
  13005. ideographic: 'ideographic',
  13006. imagerendering: 'imageRendering',
  13007. 'image-rendering': 'imageRendering',
  13008. in2: 'in2',
  13009. 'in': 'in',
  13010. inlist: 'inlist',
  13011. intercept: 'intercept',
  13012. k1: 'k1',
  13013. k2: 'k2',
  13014. k3: 'k3',
  13015. k4: 'k4',
  13016. k: 'k',
  13017. kernelmatrix: 'kernelMatrix',
  13018. kernelunitlength: 'kernelUnitLength',
  13019. kerning: 'kerning',
  13020. keypoints: 'keyPoints',
  13021. keysplines: 'keySplines',
  13022. keytimes: 'keyTimes',
  13023. lengthadjust: 'lengthAdjust',
  13024. letterspacing: 'letterSpacing',
  13025. 'letter-spacing': 'letterSpacing',
  13026. lightingcolor: 'lightingColor',
  13027. 'lighting-color': 'lightingColor',
  13028. limitingconeangle: 'limitingConeAngle',
  13029. local: 'local',
  13030. markerend: 'markerEnd',
  13031. 'marker-end': 'markerEnd',
  13032. markerheight: 'markerHeight',
  13033. markermid: 'markerMid',
  13034. 'marker-mid': 'markerMid',
  13035. markerstart: 'markerStart',
  13036. 'marker-start': 'markerStart',
  13037. markerunits: 'markerUnits',
  13038. markerwidth: 'markerWidth',
  13039. mask: 'mask',
  13040. maskcontentunits: 'maskContentUnits',
  13041. maskunits: 'maskUnits',
  13042. mathematical: 'mathematical',
  13043. mode: 'mode',
  13044. numoctaves: 'numOctaves',
  13045. offset: 'offset',
  13046. opacity: 'opacity',
  13047. operator: 'operator',
  13048. order: 'order',
  13049. orient: 'orient',
  13050. orientation: 'orientation',
  13051. origin: 'origin',
  13052. overflow: 'overflow',
  13053. overlineposition: 'overlinePosition',
  13054. 'overline-position': 'overlinePosition',
  13055. overlinethickness: 'overlineThickness',
  13056. 'overline-thickness': 'overlineThickness',
  13057. paintorder: 'paintOrder',
  13058. 'paint-order': 'paintOrder',
  13059. panose1: 'panose1',
  13060. 'panose-1': 'panose1',
  13061. pathlength: 'pathLength',
  13062. patterncontentunits: 'patternContentUnits',
  13063. patterntransform: 'patternTransform',
  13064. patternunits: 'patternUnits',
  13065. pointerevents: 'pointerEvents',
  13066. 'pointer-events': 'pointerEvents',
  13067. points: 'points',
  13068. pointsatx: 'pointsAtX',
  13069. pointsaty: 'pointsAtY',
  13070. pointsatz: 'pointsAtZ',
  13071. prefix: 'prefix',
  13072. preservealpha: 'preserveAlpha',
  13073. preserveaspectratio: 'preserveAspectRatio',
  13074. primitiveunits: 'primitiveUnits',
  13075. property: 'property',
  13076. r: 'r',
  13077. radius: 'radius',
  13078. refx: 'refX',
  13079. refy: 'refY',
  13080. renderingintent: 'renderingIntent',
  13081. 'rendering-intent': 'renderingIntent',
  13082. repeatcount: 'repeatCount',
  13083. repeatdur: 'repeatDur',
  13084. requiredextensions: 'requiredExtensions',
  13085. requiredfeatures: 'requiredFeatures',
  13086. resource: 'resource',
  13087. restart: 'restart',
  13088. result: 'result',
  13089. results: 'results',
  13090. rotate: 'rotate',
  13091. rx: 'rx',
  13092. ry: 'ry',
  13093. scale: 'scale',
  13094. security: 'security',
  13095. seed: 'seed',
  13096. shaperendering: 'shapeRendering',
  13097. 'shape-rendering': 'shapeRendering',
  13098. slope: 'slope',
  13099. spacing: 'spacing',
  13100. specularconstant: 'specularConstant',
  13101. specularexponent: 'specularExponent',
  13102. speed: 'speed',
  13103. spreadmethod: 'spreadMethod',
  13104. startoffset: 'startOffset',
  13105. stddeviation: 'stdDeviation',
  13106. stemh: 'stemh',
  13107. stemv: 'stemv',
  13108. stitchtiles: 'stitchTiles',
  13109. stopcolor: 'stopColor',
  13110. 'stop-color': 'stopColor',
  13111. stopopacity: 'stopOpacity',
  13112. 'stop-opacity': 'stopOpacity',
  13113. strikethroughposition: 'strikethroughPosition',
  13114. 'strikethrough-position': 'strikethroughPosition',
  13115. strikethroughthickness: 'strikethroughThickness',
  13116. 'strikethrough-thickness': 'strikethroughThickness',
  13117. string: 'string',
  13118. stroke: 'stroke',
  13119. strokedasharray: 'strokeDasharray',
  13120. 'stroke-dasharray': 'strokeDasharray',
  13121. strokedashoffset: 'strokeDashoffset',
  13122. 'stroke-dashoffset': 'strokeDashoffset',
  13123. strokelinecap: 'strokeLinecap',
  13124. 'stroke-linecap': 'strokeLinecap',
  13125. strokelinejoin: 'strokeLinejoin',
  13126. 'stroke-linejoin': 'strokeLinejoin',
  13127. strokemiterlimit: 'strokeMiterlimit',
  13128. 'stroke-miterlimit': 'strokeMiterlimit',
  13129. strokewidth: 'strokeWidth',
  13130. 'stroke-width': 'strokeWidth',
  13131. strokeopacity: 'strokeOpacity',
  13132. 'stroke-opacity': 'strokeOpacity',
  13133. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  13134. suppresshydrationwarning: 'suppressHydrationWarning',
  13135. surfacescale: 'surfaceScale',
  13136. systemlanguage: 'systemLanguage',
  13137. tablevalues: 'tableValues',
  13138. targetx: 'targetX',
  13139. targety: 'targetY',
  13140. textanchor: 'textAnchor',
  13141. 'text-anchor': 'textAnchor',
  13142. textdecoration: 'textDecoration',
  13143. 'text-decoration': 'textDecoration',
  13144. textlength: 'textLength',
  13145. textrendering: 'textRendering',
  13146. 'text-rendering': 'textRendering',
  13147. to: 'to',
  13148. transform: 'transform',
  13149. 'typeof': 'typeof',
  13150. u1: 'u1',
  13151. u2: 'u2',
  13152. underlineposition: 'underlinePosition',
  13153. 'underline-position': 'underlinePosition',
  13154. underlinethickness: 'underlineThickness',
  13155. 'underline-thickness': 'underlineThickness',
  13156. unicode: 'unicode',
  13157. unicodebidi: 'unicodeBidi',
  13158. 'unicode-bidi': 'unicodeBidi',
  13159. unicoderange: 'unicodeRange',
  13160. 'unicode-range': 'unicodeRange',
  13161. unitsperem: 'unitsPerEm',
  13162. 'units-per-em': 'unitsPerEm',
  13163. unselectable: 'unselectable',
  13164. valphabetic: 'vAlphabetic',
  13165. 'v-alphabetic': 'vAlphabetic',
  13166. values: 'values',
  13167. vectoreffect: 'vectorEffect',
  13168. 'vector-effect': 'vectorEffect',
  13169. version: 'version',
  13170. vertadvy: 'vertAdvY',
  13171. 'vert-adv-y': 'vertAdvY',
  13172. vertoriginx: 'vertOriginX',
  13173. 'vert-origin-x': 'vertOriginX',
  13174. vertoriginy: 'vertOriginY',
  13175. 'vert-origin-y': 'vertOriginY',
  13176. vhanging: 'vHanging',
  13177. 'v-hanging': 'vHanging',
  13178. videographic: 'vIdeographic',
  13179. 'v-ideographic': 'vIdeographic',
  13180. viewbox: 'viewBox',
  13181. viewtarget: 'viewTarget',
  13182. visibility: 'visibility',
  13183. vmathematical: 'vMathematical',
  13184. 'v-mathematical': 'vMathematical',
  13185. vocab: 'vocab',
  13186. widths: 'widths',
  13187. wordspacing: 'wordSpacing',
  13188. 'word-spacing': 'wordSpacing',
  13189. writingmode: 'writingMode',
  13190. 'writing-mode': 'writingMode',
  13191. x1: 'x1',
  13192. x2: 'x2',
  13193. x: 'x',
  13194. xchannelselector: 'xChannelSelector',
  13195. xheight: 'xHeight',
  13196. 'x-height': 'xHeight',
  13197. xlinkactuate: 'xlinkActuate',
  13198. 'xlink:actuate': 'xlinkActuate',
  13199. xlinkarcrole: 'xlinkArcrole',
  13200. 'xlink:arcrole': 'xlinkArcrole',
  13201. xlinkhref: 'xlinkHref',
  13202. 'xlink:href': 'xlinkHref',
  13203. xlinkrole: 'xlinkRole',
  13204. 'xlink:role': 'xlinkRole',
  13205. xlinkshow: 'xlinkShow',
  13206. 'xlink:show': 'xlinkShow',
  13207. xlinktitle: 'xlinkTitle',
  13208. 'xlink:title': 'xlinkTitle',
  13209. xlinktype: 'xlinkType',
  13210. 'xlink:type': 'xlinkType',
  13211. xmlbase: 'xmlBase',
  13212. 'xml:base': 'xmlBase',
  13213. xmllang: 'xmlLang',
  13214. 'xml:lang': 'xmlLang',
  13215. xmlns: 'xmlns',
  13216. 'xml:space': 'xmlSpace',
  13217. xmlnsxlink: 'xmlnsXlink',
  13218. 'xmlns:xlink': 'xmlnsXlink',
  13219. xmlspace: 'xmlSpace',
  13220. y1: 'y1',
  13221. y2: 'y2',
  13222. y: 'y',
  13223. ychannelselector: 'yChannelSelector',
  13224. z: 'z',
  13225. zoomandpan: 'zoomAndPan'
  13226. };
  13227. var ariaProperties = {
  13228. 'aria-current': 0, // state
  13229. 'aria-details': 0,
  13230. 'aria-disabled': 0, // state
  13231. 'aria-hidden': 0, // state
  13232. 'aria-invalid': 0, // state
  13233. 'aria-keyshortcuts': 0,
  13234. 'aria-label': 0,
  13235. 'aria-roledescription': 0,
  13236. // Widget Attributes
  13237. 'aria-autocomplete': 0,
  13238. 'aria-checked': 0,
  13239. 'aria-expanded': 0,
  13240. 'aria-haspopup': 0,
  13241. 'aria-level': 0,
  13242. 'aria-modal': 0,
  13243. 'aria-multiline': 0,
  13244. 'aria-multiselectable': 0,
  13245. 'aria-orientation': 0,
  13246. 'aria-placeholder': 0,
  13247. 'aria-pressed': 0,
  13248. 'aria-readonly': 0,
  13249. 'aria-required': 0,
  13250. 'aria-selected': 0,
  13251. 'aria-sort': 0,
  13252. 'aria-valuemax': 0,
  13253. 'aria-valuemin': 0,
  13254. 'aria-valuenow': 0,
  13255. 'aria-valuetext': 0,
  13256. // Live Region Attributes
  13257. 'aria-atomic': 0,
  13258. 'aria-busy': 0,
  13259. 'aria-live': 0,
  13260. 'aria-relevant': 0,
  13261. // Drag-and-Drop Attributes
  13262. 'aria-dropeffect': 0,
  13263. 'aria-grabbed': 0,
  13264. // Relationship Attributes
  13265. 'aria-activedescendant': 0,
  13266. 'aria-colcount': 0,
  13267. 'aria-colindex': 0,
  13268. 'aria-colspan': 0,
  13269. 'aria-controls': 0,
  13270. 'aria-describedby': 0,
  13271. 'aria-errormessage': 0,
  13272. 'aria-flowto': 0,
  13273. 'aria-labelledby': 0,
  13274. 'aria-owns': 0,
  13275. 'aria-posinset': 0,
  13276. 'aria-rowcount': 0,
  13277. 'aria-rowindex': 0,
  13278. 'aria-rowspan': 0,
  13279. 'aria-setsize': 0
  13280. };
  13281. var warnedProperties = {};
  13282. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  13283. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  13284. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  13285. function getStackAddendum() {
  13286. var stack = ReactDebugCurrentFrame.getStackAddendum();
  13287. return stack != null ? stack : '';
  13288. }
  13289. function validateProperty(tagName, name) {
  13290. if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
  13291. return true;
  13292. }
  13293. if (rARIACamel.test(name)) {
  13294. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  13295. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
  13296. // If this is an aria-* attribute, but is not listed in the known DOM
  13297. // DOM properties, then it is an invalid aria-* attribute.
  13298. if (correctName == null) {
  13299. warning_1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
  13300. warnedProperties[name] = true;
  13301. return true;
  13302. }
  13303. // aria-* attributes should be lowercase; suggest the lowercase version.
  13304. if (name !== correctName) {
  13305. warning_1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
  13306. warnedProperties[name] = true;
  13307. return true;
  13308. }
  13309. }
  13310. if (rARIA.test(name)) {
  13311. var lowerCasedName = name.toLowerCase();
  13312. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
  13313. // If this is an aria-* attribute, but is not listed in the known DOM
  13314. // DOM properties, then it is an invalid aria-* attribute.
  13315. if (standardName == null) {
  13316. warnedProperties[name] = true;
  13317. return false;
  13318. }
  13319. // aria-* attributes should be lowercase; suggest the lowercase version.
  13320. if (name !== standardName) {
  13321. warning_1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
  13322. warnedProperties[name] = true;
  13323. return true;
  13324. }
  13325. }
  13326. return true;
  13327. }
  13328. function warnInvalidARIAProps(type, props) {
  13329. var invalidProps = [];
  13330. for (var key in props) {
  13331. var isValid = validateProperty(type, key);
  13332. if (!isValid) {
  13333. invalidProps.push(key);
  13334. }
  13335. }
  13336. var unknownPropString = invalidProps.map(function (prop) {
  13337. return '`' + prop + '`';
  13338. }).join(', ');
  13339. if (invalidProps.length === 1) {
  13340. warning_1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum());
  13341. } else if (invalidProps.length > 1) {
  13342. warning_1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum());
  13343. }
  13344. }
  13345. function validateProperties(type, props) {
  13346. if (isCustomComponent(type, props)) {
  13347. return;
  13348. }
  13349. warnInvalidARIAProps(type, props);
  13350. }
  13351. var didWarnValueNull = false;
  13352. function getStackAddendum$1() {
  13353. var stack = ReactDebugCurrentFrame.getStackAddendum();
  13354. return stack != null ? stack : '';
  13355. }
  13356. function validateProperties$1(type, props) {
  13357. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  13358. return;
  13359. }
  13360. if (props != null && props.value === null && !didWarnValueNull) {
  13361. didWarnValueNull = true;
  13362. if (type === 'select' && props.multiple) {
  13363. warning_1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.%s', type, getStackAddendum$1());
  13364. } else {
  13365. warning_1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$1());
  13366. }
  13367. }
  13368. }
  13369. function getStackAddendum$2() {
  13370. var stack = ReactDebugCurrentFrame.getStackAddendum();
  13371. return stack != null ? stack : '';
  13372. }
  13373. var validateProperty$1 = function () {};
  13374. {
  13375. var warnedProperties$1 = {};
  13376. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  13377. var EVENT_NAME_REGEX = /^on./;
  13378. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  13379. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  13380. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  13381. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  13382. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  13383. return true;
  13384. }
  13385. var lowerCasedName = name.toLowerCase();
  13386. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  13387. warning_1(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
  13388. warnedProperties$1[name] = true;
  13389. return true;
  13390. }
  13391. // We can't rely on the event system being injected on the server.
  13392. if (canUseEventSystem) {
  13393. if (registrationNameModules.hasOwnProperty(name)) {
  13394. return true;
  13395. }
  13396. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  13397. if (registrationName != null) {
  13398. warning_1(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2());
  13399. warnedProperties$1[name] = true;
  13400. return true;
  13401. }
  13402. if (EVENT_NAME_REGEX.test(name)) {
  13403. warning_1(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$2());
  13404. warnedProperties$1[name] = true;
  13405. return true;
  13406. }
  13407. } else if (EVENT_NAME_REGEX.test(name)) {
  13408. // If no event plugins have been injected, we are in a server environment.
  13409. // So we can't tell if the event name is correct for sure, but we can filter
  13410. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  13411. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  13412. warning_1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.%s', name, getStackAddendum$2());
  13413. }
  13414. warnedProperties$1[name] = true;
  13415. return true;
  13416. }
  13417. // Let the ARIA attribute hook validate ARIA attributes
  13418. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  13419. return true;
  13420. }
  13421. if (lowerCasedName === 'innerhtml') {
  13422. warning_1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  13423. warnedProperties$1[name] = true;
  13424. return true;
  13425. }
  13426. if (lowerCasedName === 'aria') {
  13427. warning_1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  13428. warnedProperties$1[name] = true;
  13429. return true;
  13430. }
  13431. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  13432. warning_1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.%s', typeof value, getStackAddendum$2());
  13433. warnedProperties$1[name] = true;
  13434. return true;
  13435. }
  13436. if (typeof value === 'number' && isNaN(value)) {
  13437. warning_1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.%s', name, getStackAddendum$2());
  13438. warnedProperties$1[name] = true;
  13439. return true;
  13440. }
  13441. var propertyInfo = getPropertyInfo(name);
  13442. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
  13443. // Known attributes should match the casing specified in the property config.
  13444. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  13445. var standardName = possibleStandardNames[lowerCasedName];
  13446. if (standardName !== name) {
  13447. warning_1(false, 'Invalid DOM property `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum$2());
  13448. warnedProperties$1[name] = true;
  13449. return true;
  13450. }
  13451. } else if (!isReserved && name !== lowerCasedName) {
  13452. // Unknown attributes should have lowercase casing since that's how they
  13453. // will be cased anyway with server rendering.
  13454. warning_1(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.%s', name, lowerCasedName, getStackAddendum$2());
  13455. warnedProperties$1[name] = true;
  13456. return true;
  13457. }
  13458. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  13459. if (value) {
  13460. warning_1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.%s', value, name, name, value, name, getStackAddendum$2());
  13461. } else {
  13462. warning_1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', value, name, name, value, name, name, name, getStackAddendum$2());
  13463. }
  13464. warnedProperties$1[name] = true;
  13465. return true;
  13466. }
  13467. // Now that we've validated casing, do not validate
  13468. // data types for reserved props
  13469. if (isReserved) {
  13470. return true;
  13471. }
  13472. // Warn when a known attribute is a bad type
  13473. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  13474. warnedProperties$1[name] = true;
  13475. return false;
  13476. }
  13477. return true;
  13478. };
  13479. }
  13480. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  13481. var unknownProps = [];
  13482. for (var key in props) {
  13483. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  13484. if (!isValid) {
  13485. unknownProps.push(key);
  13486. }
  13487. }
  13488. var unknownPropString = unknownProps.map(function (prop) {
  13489. return '`' + prop + '`';
  13490. }).join(', ');
  13491. if (unknownProps.length === 1) {
  13492. warning_1(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2());
  13493. } else if (unknownProps.length > 1) {
  13494. warning_1(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2());
  13495. }
  13496. };
  13497. function validateProperties$2(type, props, canUseEventSystem) {
  13498. if (isCustomComponent(type, props)) {
  13499. return;
  13500. }
  13501. warnUnknownProperties(type, props, canUseEventSystem);
  13502. }
  13503. // TODO: direct imports like some-package/src/* are bad. Fix me.
  13504. var getCurrentFiberOwnerName$2 = ReactDebugCurrentFiber.getCurrentFiberOwnerName;
  13505. var getCurrentFiberStackAddendum$3 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  13506. var didWarnInvalidHydration = false;
  13507. var didWarnShadyDOM = false;
  13508. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  13509. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  13510. var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  13511. var AUTOFOCUS = 'autoFocus';
  13512. var CHILDREN = 'children';
  13513. var STYLE = 'style';
  13514. var HTML = '__html';
  13515. var HTML_NAMESPACE = Namespaces.html;
  13516. var getStack = emptyFunction_1.thatReturns('');
  13517. var warnedUnknownTags = void 0;
  13518. var suppressHydrationWarning = void 0;
  13519. var validatePropertiesInDevelopment = void 0;
  13520. var warnForTextDifference = void 0;
  13521. var warnForPropDifference = void 0;
  13522. var warnForExtraAttributes = void 0;
  13523. var warnForInvalidEventListener = void 0;
  13524. var normalizeMarkupForTextOrAttribute = void 0;
  13525. var normalizeHTML = void 0;
  13526. {
  13527. getStack = getCurrentFiberStackAddendum$3;
  13528. warnedUnknownTags = {
  13529. // Chrome is the only major browser not shipping <time>. But as of July
  13530. // 2017 it intends to ship it due to widespread usage. We intentionally
  13531. // *don't* warn for <time> even if it's unrecognized by Chrome because
  13532. // it soon will be, and many apps have been using it anyway.
  13533. time: true,
  13534. // There are working polyfills for <dialog>. Let people use it.
  13535. dialog: true
  13536. };
  13537. validatePropertiesInDevelopment = function (type, props) {
  13538. validateProperties(type, props);
  13539. validateProperties$1(type, props);
  13540. validateProperties$2(type, props, /* canUseEventSystem */true);
  13541. };
  13542. // HTML parsing normalizes CR and CRLF to LF.
  13543. // It also can turn \u0000 into \uFFFD inside attributes.
  13544. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  13545. // If we have a mismatch, it might be caused by that.
  13546. // We will still patch up in this case but not fire the warning.
  13547. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  13548. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  13549. normalizeMarkupForTextOrAttribute = function (markup) {
  13550. var markupString = typeof markup === 'string' ? markup : '' + markup;
  13551. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  13552. };
  13553. warnForTextDifference = function (serverText, clientText) {
  13554. if (didWarnInvalidHydration) {
  13555. return;
  13556. }
  13557. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  13558. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  13559. if (normalizedServerText === normalizedClientText) {
  13560. return;
  13561. }
  13562. didWarnInvalidHydration = true;
  13563. warning_1(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  13564. };
  13565. warnForPropDifference = function (propName, serverValue, clientValue) {
  13566. if (didWarnInvalidHydration) {
  13567. return;
  13568. }
  13569. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  13570. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  13571. if (normalizedServerValue === normalizedClientValue) {
  13572. return;
  13573. }
  13574. didWarnInvalidHydration = true;
  13575. warning_1(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  13576. };
  13577. warnForExtraAttributes = function (attributeNames) {
  13578. if (didWarnInvalidHydration) {
  13579. return;
  13580. }
  13581. didWarnInvalidHydration = true;
  13582. var names = [];
  13583. attributeNames.forEach(function (name) {
  13584. names.push(name);
  13585. });
  13586. warning_1(false, 'Extra attributes from the server: %s', names);
  13587. };
  13588. warnForInvalidEventListener = function (registrationName, listener) {
  13589. if (listener === false) {
  13590. warning_1(false, 'Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', registrationName, registrationName, registrationName, getCurrentFiberStackAddendum$3());
  13591. } else {
  13592. warning_1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.%s', registrationName, typeof listener, getCurrentFiberStackAddendum$3());
  13593. }
  13594. };
  13595. // Parse the HTML and read it back to normalize the HTML string so that it
  13596. // can be used for comparison.
  13597. normalizeHTML = function (parent, html) {
  13598. // We could have created a separate document here to avoid
  13599. // re-initializing custom elements if they exist. But this breaks
  13600. // how <noscript> is being handled. So we use the same document.
  13601. // See the discussion in https://github.com/facebook/react/pull/11157.
  13602. var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  13603. testElement.innerHTML = html;
  13604. return testElement.innerHTML;
  13605. };
  13606. }
  13607. function ensureListeningTo(rootContainerElement, registrationName) {
  13608. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  13609. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  13610. listenTo(registrationName, doc);
  13611. }
  13612. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  13613. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  13614. }
  13615. function trapClickOnNonInteractiveElement(node) {
  13616. // Mobile Safari does not fire properly bubble click events on
  13617. // non-interactive elements, which means delegated click listeners do not
  13618. // fire. The workaround for this bug involves attaching an empty click
  13619. // listener on the target node.
  13620. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  13621. // Just set it using the onclick property so that we don't have to manage any
  13622. // bookkeeping for it. Not sure if we need to clear it when the listener is
  13623. // removed.
  13624. // TODO: Only do this for the relevant Safaris maybe?
  13625. node.onclick = emptyFunction_1;
  13626. }
  13627. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  13628. for (var propKey in nextProps) {
  13629. if (!nextProps.hasOwnProperty(propKey)) {
  13630. continue;
  13631. }
  13632. var nextProp = nextProps[propKey];
  13633. if (propKey === STYLE) {
  13634. {
  13635. if (nextProp) {
  13636. // Freeze the next style object so that we can assume it won't be
  13637. // mutated. We have already warned for this in the past.
  13638. Object.freeze(nextProp);
  13639. }
  13640. }
  13641. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  13642. setValueForStyles(domElement, nextProp, getStack);
  13643. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  13644. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  13645. if (nextHtml != null) {
  13646. setInnerHTML(domElement, nextHtml);
  13647. }
  13648. } else if (propKey === CHILDREN) {
  13649. if (typeof nextProp === 'string') {
  13650. // Avoid setting initial textContent when the text is empty. In IE11 setting
  13651. // textContent on a <textarea> will cause the placeholder to not
  13652. // show within the <textarea> until it has been focused and blurred again.
  13653. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  13654. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  13655. if (canSetTextContent) {
  13656. setTextContent(domElement, nextProp);
  13657. }
  13658. } else if (typeof nextProp === 'number') {
  13659. setTextContent(domElement, '' + nextProp);
  13660. }
  13661. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  13662. // Noop
  13663. } else if (propKey === AUTOFOCUS) {
  13664. // We polyfill it separately on the client during commit.
  13665. // We blacklist it here rather than in the property list because we emit it in SSR.
  13666. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  13667. if (nextProp != null) {
  13668. if (true && typeof nextProp !== 'function') {
  13669. warnForInvalidEventListener(propKey, nextProp);
  13670. }
  13671. ensureListeningTo(rootContainerElement, propKey);
  13672. }
  13673. } else if (nextProp != null) {
  13674. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  13675. }
  13676. }
  13677. }
  13678. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  13679. // TODO: Handle wasCustomComponentTag
  13680. for (var i = 0; i < updatePayload.length; i += 2) {
  13681. var propKey = updatePayload[i];
  13682. var propValue = updatePayload[i + 1];
  13683. if (propKey === STYLE) {
  13684. setValueForStyles(domElement, propValue, getStack);
  13685. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  13686. setInnerHTML(domElement, propValue);
  13687. } else if (propKey === CHILDREN) {
  13688. setTextContent(domElement, propValue);
  13689. } else {
  13690. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  13691. }
  13692. }
  13693. }
  13694. function createElement$1(type, props, rootContainerElement, parentNamespace) {
  13695. var isCustomComponentTag = void 0;
  13696. // We create tags in the namespace of their parent container, except HTML
  13697. // tags get no namespace.
  13698. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  13699. var domElement = void 0;
  13700. var namespaceURI = parentNamespace;
  13701. if (namespaceURI === HTML_NAMESPACE) {
  13702. namespaceURI = getIntrinsicNamespace(type);
  13703. }
  13704. if (namespaceURI === HTML_NAMESPACE) {
  13705. {
  13706. isCustomComponentTag = isCustomComponent(type, props);
  13707. // Should this check be gated by parent namespace? Not sure we want to
  13708. // allow <SVG> or <mATH>.
  13709. !(isCustomComponentTag || type === type.toLowerCase()) ? warning_1(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type) : void 0;
  13710. }
  13711. if (type === 'script') {
  13712. // Create the script via .innerHTML so its "parser-inserted" flag is
  13713. // set to true and it does not execute
  13714. var div = ownerDocument.createElement('div');
  13715. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  13716. // This is guaranteed to yield a script element.
  13717. var firstChild = div.firstChild;
  13718. domElement = div.removeChild(firstChild);
  13719. } else if (typeof props.is === 'string') {
  13720. // $FlowIssue `createElement` should be updated for Web Components
  13721. domElement = ownerDocument.createElement(type, { is: props.is });
  13722. } else {
  13723. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  13724. // See discussion in https://github.com/facebook/react/pull/6896
  13725. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  13726. domElement = ownerDocument.createElement(type);
  13727. }
  13728. } else {
  13729. domElement = ownerDocument.createElementNS(namespaceURI, type);
  13730. }
  13731. {
  13732. if (namespaceURI === HTML_NAMESPACE) {
  13733. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  13734. warnedUnknownTags[type] = true;
  13735. warning_1(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
  13736. }
  13737. }
  13738. }
  13739. return domElement;
  13740. }
  13741. function createTextNode$1(text, rootContainerElement) {
  13742. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  13743. }
  13744. function setInitialProperties$1(domElement, tag, rawProps, rootContainerElement) {
  13745. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  13746. {
  13747. validatePropertiesInDevelopment(tag, rawProps);
  13748. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  13749. warning_1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$2() || 'A component');
  13750. didWarnShadyDOM = true;
  13751. }
  13752. }
  13753. // TODO: Make sure that we check isMounted before firing any of these events.
  13754. var props = void 0;
  13755. switch (tag) {
  13756. case 'iframe':
  13757. case 'object':
  13758. trapBubbledEvent('topLoad', 'load', domElement);
  13759. props = rawProps;
  13760. break;
  13761. case 'video':
  13762. case 'audio':
  13763. // Create listener for each media event
  13764. for (var event in mediaEventTypes) {
  13765. if (mediaEventTypes.hasOwnProperty(event)) {
  13766. trapBubbledEvent(event, mediaEventTypes[event], domElement);
  13767. }
  13768. }
  13769. props = rawProps;
  13770. break;
  13771. case 'source':
  13772. trapBubbledEvent('topError', 'error', domElement);
  13773. props = rawProps;
  13774. break;
  13775. case 'img':
  13776. case 'image':
  13777. case 'link':
  13778. trapBubbledEvent('topError', 'error', domElement);
  13779. trapBubbledEvent('topLoad', 'load', domElement);
  13780. props = rawProps;
  13781. break;
  13782. case 'form':
  13783. trapBubbledEvent('topReset', 'reset', domElement);
  13784. trapBubbledEvent('topSubmit', 'submit', domElement);
  13785. props = rawProps;
  13786. break;
  13787. case 'details':
  13788. trapBubbledEvent('topToggle', 'toggle', domElement);
  13789. props = rawProps;
  13790. break;
  13791. case 'input':
  13792. initWrapperState(domElement, rawProps);
  13793. props = getHostProps(domElement, rawProps);
  13794. trapBubbledEvent('topInvalid', 'invalid', domElement);
  13795. // For controlled components we always need to ensure we're listening
  13796. // to onChange. Even if there is no listener.
  13797. ensureListeningTo(rootContainerElement, 'onChange');
  13798. break;
  13799. case 'option':
  13800. validateProps(domElement, rawProps);
  13801. props = getHostProps$1(domElement, rawProps);
  13802. break;
  13803. case 'select':
  13804. initWrapperState$1(domElement, rawProps);
  13805. props = getHostProps$2(domElement, rawProps);
  13806. trapBubbledEvent('topInvalid', 'invalid', domElement);
  13807. // For controlled components we always need to ensure we're listening
  13808. // to onChange. Even if there is no listener.
  13809. ensureListeningTo(rootContainerElement, 'onChange');
  13810. break;
  13811. case 'textarea':
  13812. initWrapperState$2(domElement, rawProps);
  13813. props = getHostProps$3(domElement, rawProps);
  13814. trapBubbledEvent('topInvalid', 'invalid', domElement);
  13815. // For controlled components we always need to ensure we're listening
  13816. // to onChange. Even if there is no listener.
  13817. ensureListeningTo(rootContainerElement, 'onChange');
  13818. break;
  13819. default:
  13820. props = rawProps;
  13821. }
  13822. assertValidProps(tag, props, getStack);
  13823. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  13824. switch (tag) {
  13825. case 'input':
  13826. // TODO: Make sure we check if this is still unmounted or do any clean
  13827. // up necessary since we never stop tracking anymore.
  13828. track(domElement);
  13829. postMountWrapper(domElement, rawProps);
  13830. break;
  13831. case 'textarea':
  13832. // TODO: Make sure we check if this is still unmounted or do any clean
  13833. // up necessary since we never stop tracking anymore.
  13834. track(domElement);
  13835. postMountWrapper$3(domElement, rawProps);
  13836. break;
  13837. case 'option':
  13838. postMountWrapper$1(domElement, rawProps);
  13839. break;
  13840. case 'select':
  13841. postMountWrapper$2(domElement, rawProps);
  13842. break;
  13843. default:
  13844. if (typeof props.onClick === 'function') {
  13845. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  13846. trapClickOnNonInteractiveElement(domElement);
  13847. }
  13848. break;
  13849. }
  13850. }
  13851. // Calculate the diff between the two objects.
  13852. function diffProperties$1(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  13853. {
  13854. validatePropertiesInDevelopment(tag, nextRawProps);
  13855. }
  13856. var updatePayload = null;
  13857. var lastProps = void 0;
  13858. var nextProps = void 0;
  13859. switch (tag) {
  13860. case 'input':
  13861. lastProps = getHostProps(domElement, lastRawProps);
  13862. nextProps = getHostProps(domElement, nextRawProps);
  13863. updatePayload = [];
  13864. break;
  13865. case 'option':
  13866. lastProps = getHostProps$1(domElement, lastRawProps);
  13867. nextProps = getHostProps$1(domElement, nextRawProps);
  13868. updatePayload = [];
  13869. break;
  13870. case 'select':
  13871. lastProps = getHostProps$2(domElement, lastRawProps);
  13872. nextProps = getHostProps$2(domElement, nextRawProps);
  13873. updatePayload = [];
  13874. break;
  13875. case 'textarea':
  13876. lastProps = getHostProps$3(domElement, lastRawProps);
  13877. nextProps = getHostProps$3(domElement, nextRawProps);
  13878. updatePayload = [];
  13879. break;
  13880. default:
  13881. lastProps = lastRawProps;
  13882. nextProps = nextRawProps;
  13883. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  13884. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  13885. trapClickOnNonInteractiveElement(domElement);
  13886. }
  13887. break;
  13888. }
  13889. assertValidProps(tag, nextProps, getStack);
  13890. var propKey = void 0;
  13891. var styleName = void 0;
  13892. var styleUpdates = null;
  13893. for (propKey in lastProps) {
  13894. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  13895. continue;
  13896. }
  13897. if (propKey === STYLE) {
  13898. var lastStyle = lastProps[propKey];
  13899. for (styleName in lastStyle) {
  13900. if (lastStyle.hasOwnProperty(styleName)) {
  13901. if (!styleUpdates) {
  13902. styleUpdates = {};
  13903. }
  13904. styleUpdates[styleName] = '';
  13905. }
  13906. }
  13907. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {
  13908. // Noop. This is handled by the clear text mechanism.
  13909. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  13910. // Noop
  13911. } else if (propKey === AUTOFOCUS) {
  13912. // Noop. It doesn't work on updates anyway.
  13913. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  13914. // This is a special case. If any listener updates we need to ensure
  13915. // that the "current" fiber pointer gets updated so we need a commit
  13916. // to update this element.
  13917. if (!updatePayload) {
  13918. updatePayload = [];
  13919. }
  13920. } else {
  13921. // For all other deleted properties we add it to the queue. We use
  13922. // the whitelist in the commit phase instead.
  13923. (updatePayload = updatePayload || []).push(propKey, null);
  13924. }
  13925. }
  13926. for (propKey in nextProps) {
  13927. var nextProp = nextProps[propKey];
  13928. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  13929. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  13930. continue;
  13931. }
  13932. if (propKey === STYLE) {
  13933. {
  13934. if (nextProp) {
  13935. // Freeze the next style object so that we can assume it won't be
  13936. // mutated. We have already warned for this in the past.
  13937. Object.freeze(nextProp);
  13938. }
  13939. }
  13940. if (lastProp) {
  13941. // Unset styles on `lastProp` but not on `nextProp`.
  13942. for (styleName in lastProp) {
  13943. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  13944. if (!styleUpdates) {
  13945. styleUpdates = {};
  13946. }
  13947. styleUpdates[styleName] = '';
  13948. }
  13949. }
  13950. // Update styles that changed since `lastProp`.
  13951. for (styleName in nextProp) {
  13952. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  13953. if (!styleUpdates) {
  13954. styleUpdates = {};
  13955. }
  13956. styleUpdates[styleName] = nextProp[styleName];
  13957. }
  13958. }
  13959. } else {
  13960. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  13961. if (!styleUpdates) {
  13962. if (!updatePayload) {
  13963. updatePayload = [];
  13964. }
  13965. updatePayload.push(propKey, styleUpdates);
  13966. }
  13967. styleUpdates = nextProp;
  13968. }
  13969. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  13970. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  13971. var lastHtml = lastProp ? lastProp[HTML] : undefined;
  13972. if (nextHtml != null) {
  13973. if (lastHtml !== nextHtml) {
  13974. (updatePayload = updatePayload || []).push(propKey, '' + nextHtml);
  13975. }
  13976. } else {
  13977. // TODO: It might be too late to clear this if we have children
  13978. // inserted already.
  13979. }
  13980. } else if (propKey === CHILDREN) {
  13981. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  13982. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  13983. }
  13984. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  13985. // Noop
  13986. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  13987. if (nextProp != null) {
  13988. // We eagerly listen to this even though we haven't committed yet.
  13989. if (true && typeof nextProp !== 'function') {
  13990. warnForInvalidEventListener(propKey, nextProp);
  13991. }
  13992. ensureListeningTo(rootContainerElement, propKey);
  13993. }
  13994. if (!updatePayload && lastProp !== nextProp) {
  13995. // This is a special case. If any listener updates we need to ensure
  13996. // that the "current" props pointer gets updated so we need a commit
  13997. // to update this element.
  13998. updatePayload = [];
  13999. }
  14000. } else {
  14001. // For any other property we always add it to the queue and then we
  14002. // filter it out using the whitelist during the commit.
  14003. (updatePayload = updatePayload || []).push(propKey, nextProp);
  14004. }
  14005. }
  14006. if (styleUpdates) {
  14007. (updatePayload = updatePayload || []).push(STYLE, styleUpdates);
  14008. }
  14009. return updatePayload;
  14010. }
  14011. // Apply the diff.
  14012. function updateProperties$1(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  14013. // Update checked *before* name.
  14014. // In the middle of an update, it is possible to have multiple checked.
  14015. // When a checked radio tries to change name, browser makes another radio's checked false.
  14016. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  14017. updateChecked(domElement, nextRawProps);
  14018. }
  14019. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  14020. var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
  14021. // Apply the diff.
  14022. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag);
  14023. // TODO: Ensure that an update gets scheduled if any of the special props
  14024. // changed.
  14025. switch (tag) {
  14026. case 'input':
  14027. // Update the wrapper around inputs *after* updating props. This has to
  14028. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  14029. // raise warnings and prevent the new value from being assigned.
  14030. updateWrapper(domElement, nextRawProps);
  14031. break;
  14032. case 'textarea':
  14033. updateWrapper$1(domElement, nextRawProps);
  14034. break;
  14035. case 'select':
  14036. // <select> value update needs to occur after <option> children
  14037. // reconciliation
  14038. postUpdateWrapper(domElement, nextRawProps);
  14039. break;
  14040. }
  14041. }
  14042. function getPossibleStandardName(propName) {
  14043. {
  14044. var lowerCasedName = propName.toLowerCase();
  14045. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  14046. return null;
  14047. }
  14048. return possibleStandardNames[lowerCasedName] || null;
  14049. }
  14050. return null;
  14051. }
  14052. function diffHydratedProperties$1(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  14053. var isCustomComponentTag = void 0;
  14054. var extraAttributeNames = void 0;
  14055. {
  14056. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true;
  14057. isCustomComponentTag = isCustomComponent(tag, rawProps);
  14058. validatePropertiesInDevelopment(tag, rawProps);
  14059. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  14060. warning_1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$2() || 'A component');
  14061. didWarnShadyDOM = true;
  14062. }
  14063. }
  14064. // TODO: Make sure that we check isMounted before firing any of these events.
  14065. switch (tag) {
  14066. case 'iframe':
  14067. case 'object':
  14068. trapBubbledEvent('topLoad', 'load', domElement);
  14069. break;
  14070. case 'video':
  14071. case 'audio':
  14072. // Create listener for each media event
  14073. for (var event in mediaEventTypes) {
  14074. if (mediaEventTypes.hasOwnProperty(event)) {
  14075. trapBubbledEvent(event, mediaEventTypes[event], domElement);
  14076. }
  14077. }
  14078. break;
  14079. case 'source':
  14080. trapBubbledEvent('topError', 'error', domElement);
  14081. break;
  14082. case 'img':
  14083. case 'image':
  14084. case 'link':
  14085. trapBubbledEvent('topError', 'error', domElement);
  14086. trapBubbledEvent('topLoad', 'load', domElement);
  14087. break;
  14088. case 'form':
  14089. trapBubbledEvent('topReset', 'reset', domElement);
  14090. trapBubbledEvent('topSubmit', 'submit', domElement);
  14091. break;
  14092. case 'details':
  14093. trapBubbledEvent('topToggle', 'toggle', domElement);
  14094. break;
  14095. case 'input':
  14096. initWrapperState(domElement, rawProps);
  14097. trapBubbledEvent('topInvalid', 'invalid', domElement);
  14098. // For controlled components we always need to ensure we're listening
  14099. // to onChange. Even if there is no listener.
  14100. ensureListeningTo(rootContainerElement, 'onChange');
  14101. break;
  14102. case 'option':
  14103. validateProps(domElement, rawProps);
  14104. break;
  14105. case 'select':
  14106. initWrapperState$1(domElement, rawProps);
  14107. trapBubbledEvent('topInvalid', 'invalid', domElement);
  14108. // For controlled components we always need to ensure we're listening
  14109. // to onChange. Even if there is no listener.
  14110. ensureListeningTo(rootContainerElement, 'onChange');
  14111. break;
  14112. case 'textarea':
  14113. initWrapperState$2(domElement, rawProps);
  14114. trapBubbledEvent('topInvalid', 'invalid', domElement);
  14115. // For controlled components we always need to ensure we're listening
  14116. // to onChange. Even if there is no listener.
  14117. ensureListeningTo(rootContainerElement, 'onChange');
  14118. break;
  14119. }
  14120. assertValidProps(tag, rawProps, getStack);
  14121. {
  14122. extraAttributeNames = new Set();
  14123. var attributes = domElement.attributes;
  14124. for (var i = 0; i < attributes.length; i++) {
  14125. var name = attributes[i].name.toLowerCase();
  14126. switch (name) {
  14127. // Built-in SSR attribute is whitelisted
  14128. case 'data-reactroot':
  14129. break;
  14130. // Controlled attributes are not validated
  14131. // TODO: Only ignore them on controlled tags.
  14132. case 'value':
  14133. break;
  14134. case 'checked':
  14135. break;
  14136. case 'selected':
  14137. break;
  14138. default:
  14139. // Intentionally use the original name.
  14140. // See discussion in https://github.com/facebook/react/pull/10676.
  14141. extraAttributeNames.add(attributes[i].name);
  14142. }
  14143. }
  14144. }
  14145. var updatePayload = null;
  14146. for (var propKey in rawProps) {
  14147. if (!rawProps.hasOwnProperty(propKey)) {
  14148. continue;
  14149. }
  14150. var nextProp = rawProps[propKey];
  14151. if (propKey === CHILDREN) {
  14152. // For text content children we compare against textContent. This
  14153. // might match additional HTML that is hidden when we read it using
  14154. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  14155. // satisfies our requirement. Our requirement is not to produce perfect
  14156. // HTML and attributes. Ideally we should preserve structure but it's
  14157. // ok not to if the visible content is still enough to indicate what
  14158. // even listeners these nodes might be wired up to.
  14159. // TODO: Warn if there is more than a single textNode as a child.
  14160. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  14161. if (typeof nextProp === 'string') {
  14162. if (domElement.textContent !== nextProp) {
  14163. if (true && !suppressHydrationWarning) {
  14164. warnForTextDifference(domElement.textContent, nextProp);
  14165. }
  14166. updatePayload = [CHILDREN, nextProp];
  14167. }
  14168. } else if (typeof nextProp === 'number') {
  14169. if (domElement.textContent !== '' + nextProp) {
  14170. if (true && !suppressHydrationWarning) {
  14171. warnForTextDifference(domElement.textContent, nextProp);
  14172. }
  14173. updatePayload = [CHILDREN, '' + nextProp];
  14174. }
  14175. }
  14176. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  14177. if (nextProp != null) {
  14178. if (true && typeof nextProp !== 'function') {
  14179. warnForInvalidEventListener(propKey, nextProp);
  14180. }
  14181. ensureListeningTo(rootContainerElement, propKey);
  14182. }
  14183. } else if (true &&
  14184. // Convince Flow we've calculated it (it's DEV-only in this method.)
  14185. typeof isCustomComponentTag === 'boolean') {
  14186. // Validate that the properties correspond to their expected values.
  14187. var serverValue = void 0;
  14188. var propertyInfo = getPropertyInfo(propKey);
  14189. if (suppressHydrationWarning) {
  14190. // Don't bother comparing. We're ignoring all these warnings.
  14191. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 ||
  14192. // Controlled attributes are not validated
  14193. // TODO: Only ignore them on controlled tags.
  14194. propKey === 'value' || propKey === 'checked' || propKey === 'selected') {
  14195. // Noop
  14196. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  14197. var rawHtml = nextProp ? nextProp[HTML] || '' : '';
  14198. var serverHTML = domElement.innerHTML;
  14199. var expectedHTML = normalizeHTML(domElement, rawHtml);
  14200. if (expectedHTML !== serverHTML) {
  14201. warnForPropDifference(propKey, serverHTML, expectedHTML);
  14202. }
  14203. } else if (propKey === STYLE) {
  14204. // $FlowFixMe - Should be inferred as not undefined.
  14205. extraAttributeNames['delete'](propKey);
  14206. var expectedStyle = createDangerousStringForStyles(nextProp);
  14207. serverValue = domElement.getAttribute('style');
  14208. if (expectedStyle !== serverValue) {
  14209. warnForPropDifference(propKey, serverValue, expectedStyle);
  14210. }
  14211. } else if (isCustomComponentTag) {
  14212. // $FlowFixMe - Should be inferred as not undefined.
  14213. extraAttributeNames['delete'](propKey.toLowerCase());
  14214. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  14215. if (nextProp !== serverValue) {
  14216. warnForPropDifference(propKey, serverValue, nextProp);
  14217. }
  14218. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  14219. var isMismatchDueToBadCasing = false;
  14220. if (propertyInfo !== null) {
  14221. // $FlowFixMe - Should be inferred as not undefined.
  14222. extraAttributeNames['delete'](propertyInfo.attributeName);
  14223. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  14224. } else {
  14225. var ownNamespace = parentNamespace;
  14226. if (ownNamespace === HTML_NAMESPACE) {
  14227. ownNamespace = getIntrinsicNamespace(tag);
  14228. }
  14229. if (ownNamespace === HTML_NAMESPACE) {
  14230. // $FlowFixMe - Should be inferred as not undefined.
  14231. extraAttributeNames['delete'](propKey.toLowerCase());
  14232. } else {
  14233. var standardName = getPossibleStandardName(propKey);
  14234. if (standardName !== null && standardName !== propKey) {
  14235. // If an SVG prop is supplied with bad casing, it will
  14236. // be successfully parsed from HTML, but will produce a mismatch
  14237. // (and would be incorrectly rendered on the client).
  14238. // However, we already warn about bad casing elsewhere.
  14239. // So we'll skip the misleading extra mismatch warning in this case.
  14240. isMismatchDueToBadCasing = true;
  14241. // $FlowFixMe - Should be inferred as not undefined.
  14242. extraAttributeNames['delete'](standardName);
  14243. }
  14244. // $FlowFixMe - Should be inferred as not undefined.
  14245. extraAttributeNames['delete'](propKey);
  14246. }
  14247. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  14248. }
  14249. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  14250. warnForPropDifference(propKey, serverValue, nextProp);
  14251. }
  14252. }
  14253. }
  14254. }
  14255. {
  14256. // $FlowFixMe - Should be inferred as not undefined.
  14257. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  14258. // $FlowFixMe - Should be inferred as not undefined.
  14259. warnForExtraAttributes(extraAttributeNames);
  14260. }
  14261. }
  14262. switch (tag) {
  14263. case 'input':
  14264. // TODO: Make sure we check if this is still unmounted or do any clean
  14265. // up necessary since we never stop tracking anymore.
  14266. track(domElement);
  14267. postMountWrapper(domElement, rawProps);
  14268. break;
  14269. case 'textarea':
  14270. // TODO: Make sure we check if this is still unmounted or do any clean
  14271. // up necessary since we never stop tracking anymore.
  14272. track(domElement);
  14273. postMountWrapper$3(domElement, rawProps);
  14274. break;
  14275. case 'select':
  14276. case 'option':
  14277. // For input and textarea we current always set the value property at
  14278. // post mount to force it to diverge from attributes. However, for
  14279. // option and select we don't quite do the same thing and select
  14280. // is not resilient to the DOM state changing so we don't do that here.
  14281. // TODO: Consider not doing this for input and textarea.
  14282. break;
  14283. default:
  14284. if (typeof rawProps.onClick === 'function') {
  14285. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  14286. trapClickOnNonInteractiveElement(domElement);
  14287. }
  14288. break;
  14289. }
  14290. return updatePayload;
  14291. }
  14292. function diffHydratedText$1(textNode, text) {
  14293. var isDifferent = textNode.nodeValue !== text;
  14294. return isDifferent;
  14295. }
  14296. function warnForUnmatchedText$1(textNode, text) {
  14297. {
  14298. warnForTextDifference(textNode.nodeValue, text);
  14299. }
  14300. }
  14301. function warnForDeletedHydratableElement$1(parentNode, child) {
  14302. {
  14303. if (didWarnInvalidHydration) {
  14304. return;
  14305. }
  14306. didWarnInvalidHydration = true;
  14307. warning_1(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  14308. }
  14309. }
  14310. function warnForDeletedHydratableText$1(parentNode, child) {
  14311. {
  14312. if (didWarnInvalidHydration) {
  14313. return;
  14314. }
  14315. didWarnInvalidHydration = true;
  14316. warning_1(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  14317. }
  14318. }
  14319. function warnForInsertedHydratedElement$1(parentNode, tag, props) {
  14320. {
  14321. if (didWarnInvalidHydration) {
  14322. return;
  14323. }
  14324. didWarnInvalidHydration = true;
  14325. warning_1(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  14326. }
  14327. }
  14328. function warnForInsertedHydratedText$1(parentNode, text) {
  14329. {
  14330. if (text === '') {
  14331. // We expect to insert empty text nodes since they're not represented in
  14332. // the HTML.
  14333. // TODO: Remove this special case if we can just avoid inserting empty
  14334. // text nodes.
  14335. return;
  14336. }
  14337. if (didWarnInvalidHydration) {
  14338. return;
  14339. }
  14340. didWarnInvalidHydration = true;
  14341. warning_1(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  14342. }
  14343. }
  14344. function restoreControlledState$1(domElement, tag, props) {
  14345. switch (tag) {
  14346. case 'input':
  14347. restoreControlledState(domElement, props);
  14348. return;
  14349. case 'textarea':
  14350. restoreControlledState$3(domElement, props);
  14351. return;
  14352. case 'select':
  14353. restoreControlledState$2(domElement, props);
  14354. return;
  14355. }
  14356. }
  14357. var ReactDOMFiberComponent = Object.freeze({
  14358. createElement: createElement$1,
  14359. createTextNode: createTextNode$1,
  14360. setInitialProperties: setInitialProperties$1,
  14361. diffProperties: diffProperties$1,
  14362. updateProperties: updateProperties$1,
  14363. diffHydratedProperties: diffHydratedProperties$1,
  14364. diffHydratedText: diffHydratedText$1,
  14365. warnForUnmatchedText: warnForUnmatchedText$1,
  14366. warnForDeletedHydratableElement: warnForDeletedHydratableElement$1,
  14367. warnForDeletedHydratableText: warnForDeletedHydratableText$1,
  14368. warnForInsertedHydratedElement: warnForInsertedHydratedElement$1,
  14369. warnForInsertedHydratedText: warnForInsertedHydratedText$1,
  14370. restoreControlledState: restoreControlledState$1
  14371. });
  14372. // TODO: direct imports like some-package/src/* are bad. Fix me.
  14373. var getCurrentFiberStackAddendum$6 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
  14374. var validateDOMNesting = emptyFunction_1;
  14375. {
  14376. // This validation code was written based on the HTML5 parsing spec:
  14377. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  14378. //
  14379. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  14380. // not clear what practical benefit doing so provides); instead, we warn only
  14381. // for cases where the parser will give a parse tree differing from what React
  14382. // intended. For example, <b><div></div></b> is invalid but we don't warn
  14383. // because it still parses correctly; we do warn for other cases like nested
  14384. // <p> tags where the beginning of the second element implicitly closes the
  14385. // first, causing a confusing mess.
  14386. // https://html.spec.whatwg.org/multipage/syntax.html#special
  14387. var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp'];
  14388. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  14389. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',
  14390. // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  14391. // TODO: Distinguish by namespace here -- for <title>, including it here
  14392. // errs on the side of fewer warnings
  14393. 'foreignObject', 'desc', 'title'];
  14394. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  14395. var buttonScopeTags = inScopeTags.concat(['button']);
  14396. // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  14397. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  14398. var emptyAncestorInfo = {
  14399. current: null,
  14400. formTag: null,
  14401. aTagInScope: null,
  14402. buttonTagInScope: null,
  14403. nobrTagInScope: null,
  14404. pTagInButtonScope: null,
  14405. listItemTagAutoclosing: null,
  14406. dlItemTagAutoclosing: null
  14407. };
  14408. var updatedAncestorInfo$1 = function (oldInfo, tag, instance) {
  14409. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  14410. var info = { tag: tag, instance: instance };
  14411. if (inScopeTags.indexOf(tag) !== -1) {
  14412. ancestorInfo.aTagInScope = null;
  14413. ancestorInfo.buttonTagInScope = null;
  14414. ancestorInfo.nobrTagInScope = null;
  14415. }
  14416. if (buttonScopeTags.indexOf(tag) !== -1) {
  14417. ancestorInfo.pTagInButtonScope = null;
  14418. }
  14419. // See rules for 'li', 'dd', 'dt' start tags in
  14420. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  14421. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  14422. ancestorInfo.listItemTagAutoclosing = null;
  14423. ancestorInfo.dlItemTagAutoclosing = null;
  14424. }
  14425. ancestorInfo.current = info;
  14426. if (tag === 'form') {
  14427. ancestorInfo.formTag = info;
  14428. }
  14429. if (tag === 'a') {
  14430. ancestorInfo.aTagInScope = info;
  14431. }
  14432. if (tag === 'button') {
  14433. ancestorInfo.buttonTagInScope = info;
  14434. }
  14435. if (tag === 'nobr') {
  14436. ancestorInfo.nobrTagInScope = info;
  14437. }
  14438. if (tag === 'p') {
  14439. ancestorInfo.pTagInButtonScope = info;
  14440. }
  14441. if (tag === 'li') {
  14442. ancestorInfo.listItemTagAutoclosing = info;
  14443. }
  14444. if (tag === 'dd' || tag === 'dt') {
  14445. ancestorInfo.dlItemTagAutoclosing = info;
  14446. }
  14447. return ancestorInfo;
  14448. };
  14449. /**
  14450. * Returns whether
  14451. */
  14452. var isTagValidWithParent = function (tag, parentTag) {
  14453. // First, let's check if we're in an unusual parsing mode...
  14454. switch (parentTag) {
  14455. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  14456. case 'select':
  14457. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  14458. case 'optgroup':
  14459. return tag === 'option' || tag === '#text';
  14460. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  14461. // but
  14462. case 'option':
  14463. return tag === '#text';
  14464. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  14465. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  14466. // No special behavior since these rules fall back to "in body" mode for
  14467. // all except special table nodes which cause bad parsing behavior anyway.
  14468. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  14469. case 'tr':
  14470. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  14471. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  14472. case 'tbody':
  14473. case 'thead':
  14474. case 'tfoot':
  14475. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  14476. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  14477. case 'colgroup':
  14478. return tag === 'col' || tag === 'template';
  14479. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  14480. case 'table':
  14481. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  14482. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  14483. case 'head':
  14484. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  14485. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  14486. case 'html':
  14487. return tag === 'head' || tag === 'body';
  14488. case '#document':
  14489. return tag === 'html';
  14490. }
  14491. // Probably in the "in body" parsing mode, so we outlaw only tag combos
  14492. // where the parsing rules cause implicit opens or closes to be added.
  14493. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  14494. switch (tag) {
  14495. case 'h1':
  14496. case 'h2':
  14497. case 'h3':
  14498. case 'h4':
  14499. case 'h5':
  14500. case 'h6':
  14501. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  14502. case 'rp':
  14503. case 'rt':
  14504. return impliedEndTags.indexOf(parentTag) === -1;
  14505. case 'body':
  14506. case 'caption':
  14507. case 'col':
  14508. case 'colgroup':
  14509. case 'frame':
  14510. case 'head':
  14511. case 'html':
  14512. case 'tbody':
  14513. case 'td':
  14514. case 'tfoot':
  14515. case 'th':
  14516. case 'thead':
  14517. case 'tr':
  14518. // These tags are only valid with a few parents that have special child
  14519. // parsing rules -- if we're down here, then none of those matched and
  14520. // so we allow it only if we don't know what the parent is, as all other
  14521. // cases are invalid.
  14522. return parentTag == null;
  14523. }
  14524. return true;
  14525. };
  14526. /**
  14527. * Returns whether
  14528. */
  14529. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  14530. switch (tag) {
  14531. case 'address':
  14532. case 'article':
  14533. case 'aside':
  14534. case 'blockquote':
  14535. case 'center':
  14536. case 'details':
  14537. case 'dialog':
  14538. case 'dir':
  14539. case 'div':
  14540. case 'dl':
  14541. case 'fieldset':
  14542. case 'figcaption':
  14543. case 'figure':
  14544. case 'footer':
  14545. case 'header':
  14546. case 'hgroup':
  14547. case 'main':
  14548. case 'menu':
  14549. case 'nav':
  14550. case 'ol':
  14551. case 'p':
  14552. case 'section':
  14553. case 'summary':
  14554. case 'ul':
  14555. case 'pre':
  14556. case 'listing':
  14557. case 'table':
  14558. case 'hr':
  14559. case 'xmp':
  14560. case 'h1':
  14561. case 'h2':
  14562. case 'h3':
  14563. case 'h4':
  14564. case 'h5':
  14565. case 'h6':
  14566. return ancestorInfo.pTagInButtonScope;
  14567. case 'form':
  14568. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  14569. case 'li':
  14570. return ancestorInfo.listItemTagAutoclosing;
  14571. case 'dd':
  14572. case 'dt':
  14573. return ancestorInfo.dlItemTagAutoclosing;
  14574. case 'button':
  14575. return ancestorInfo.buttonTagInScope;
  14576. case 'a':
  14577. // Spec says something about storing a list of markers, but it sounds
  14578. // equivalent to this check.
  14579. return ancestorInfo.aTagInScope;
  14580. case 'nobr':
  14581. return ancestorInfo.nobrTagInScope;
  14582. }
  14583. return null;
  14584. };
  14585. var didWarn = {};
  14586. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  14587. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  14588. var parentInfo = ancestorInfo.current;
  14589. var parentTag = parentInfo && parentInfo.tag;
  14590. if (childText != null) {
  14591. !(childTag == null) ? warning_1(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
  14592. childTag = '#text';
  14593. }
  14594. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  14595. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  14596. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  14597. if (!invalidParentOrAncestor) {
  14598. return;
  14599. }
  14600. var ancestorTag = invalidParentOrAncestor.tag;
  14601. var addendum = getCurrentFiberStackAddendum$6();
  14602. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  14603. if (didWarn[warnKey]) {
  14604. return;
  14605. }
  14606. didWarn[warnKey] = true;
  14607. var tagDisplayName = childTag;
  14608. var whitespaceInfo = '';
  14609. if (childTag === '#text') {
  14610. if (/\S/.test(childText)) {
  14611. tagDisplayName = 'Text nodes';
  14612. } else {
  14613. tagDisplayName = 'Whitespace text nodes';
  14614. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  14615. }
  14616. } else {
  14617. tagDisplayName = '<' + childTag + '>';
  14618. }
  14619. if (invalidParent) {
  14620. var info = '';
  14621. if (ancestorTag === 'table' && childTag === 'tr') {
  14622. info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
  14623. }
  14624. warning_1(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum);
  14625. } else {
  14626. warning_1(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum);
  14627. }
  14628. };
  14629. // TODO: turn this into a named export
  14630. validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo$1;
  14631. }
  14632. var validateDOMNesting$1 = validateDOMNesting;
  14633. // TODO: This type is shared between the reconciler and ReactDOM, but will
  14634. // eventually be lifted out to the renderer.
  14635. // TODO: direct imports like some-package/src/* are bad. Fix me.
  14636. var createElement = createElement$1;
  14637. var createTextNode = createTextNode$1;
  14638. var setInitialProperties = setInitialProperties$1;
  14639. var diffProperties = diffProperties$1;
  14640. var updateProperties = updateProperties$1;
  14641. var diffHydratedProperties = diffHydratedProperties$1;
  14642. var diffHydratedText = diffHydratedText$1;
  14643. var warnForUnmatchedText = warnForUnmatchedText$1;
  14644. var warnForDeletedHydratableElement = warnForDeletedHydratableElement$1;
  14645. var warnForDeletedHydratableText = warnForDeletedHydratableText$1;
  14646. var warnForInsertedHydratedElement = warnForInsertedHydratedElement$1;
  14647. var warnForInsertedHydratedText = warnForInsertedHydratedText$1;
  14648. var updatedAncestorInfo = validateDOMNesting$1.updatedAncestorInfo;
  14649. var precacheFiberNode = precacheFiberNode$1;
  14650. var updateFiberProps = updateFiberProps$1;
  14651. var SUPPRESS_HYDRATION_WARNING = void 0;
  14652. var topLevelUpdateWarnings = void 0;
  14653. var warnOnInvalidCallback = void 0;
  14654. var didWarnAboutUnstableCreatePortal = false;
  14655. {
  14656. SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  14657. if (typeof Map !== 'function' || Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  14658. warning_1(false, 'React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  14659. }
  14660. topLevelUpdateWarnings = function (container) {
  14661. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  14662. var hostInstance = DOMRenderer.findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  14663. if (hostInstance) {
  14664. !(hostInstance.parentNode === container) ? warning_1(false, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.') : void 0;
  14665. }
  14666. }
  14667. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  14668. var rootEl = getReactRootElementInContainer(container);
  14669. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  14670. !(!hasNonRootReactChild || isRootRenderedBySomeReact) ? warning_1(false, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : void 0;
  14671. !(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY') ? warning_1(false, 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
  14672. };
  14673. warnOnInvalidCallback = function (callback, callerName) {
  14674. !(callback === null || typeof callback === 'function') ? warning_1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback) : void 0;
  14675. };
  14676. }
  14677. injection$2.injectFiberControlledHostComponent(ReactDOMFiberComponent);
  14678. var eventsEnabled = null;
  14679. var selectionInformation = null;
  14680. function ReactBatch(root) {
  14681. var expirationTime = DOMRenderer.computeUniqueAsyncExpiration();
  14682. this._expirationTime = expirationTime;
  14683. this._root = root;
  14684. this._next = null;
  14685. this._callbacks = null;
  14686. this._didComplete = false;
  14687. this._hasChildren = false;
  14688. this._children = null;
  14689. this._defer = true;
  14690. }
  14691. ReactBatch.prototype.render = function (children) {
  14692. !this._defer ? invariant_1(false, 'batch.render: Cannot render a batch that already committed.') : void 0;
  14693. this._hasChildren = true;
  14694. this._children = children;
  14695. var internalRoot = this._root._internalRoot;
  14696. var expirationTime = this._expirationTime;
  14697. var work = new ReactWork();
  14698. DOMRenderer.updateContainerAtExpirationTime(children, internalRoot, null, expirationTime, work._onCommit);
  14699. return work;
  14700. };
  14701. ReactBatch.prototype.then = function (onComplete) {
  14702. if (this._didComplete) {
  14703. onComplete();
  14704. return;
  14705. }
  14706. var callbacks = this._callbacks;
  14707. if (callbacks === null) {
  14708. callbacks = this._callbacks = [];
  14709. }
  14710. callbacks.push(onComplete);
  14711. };
  14712. ReactBatch.prototype.commit = function () {
  14713. var internalRoot = this._root._internalRoot;
  14714. var firstBatch = internalRoot.firstBatch;
  14715. !(this._defer && firstBatch !== null) ? invariant_1(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0;
  14716. if (!this._hasChildren) {
  14717. // This batch is empty. Return.
  14718. this._next = null;
  14719. this._defer = false;
  14720. return;
  14721. }
  14722. var expirationTime = this._expirationTime;
  14723. // Ensure this is the first batch in the list.
  14724. if (firstBatch !== this) {
  14725. // This batch is not the earliest batch. We need to move it to the front.
  14726. // Update its expiration time to be the expiration time of the earliest
  14727. // batch, so that we can flush it without flushing the other batches.
  14728. if (this._hasChildren) {
  14729. expirationTime = this._expirationTime = firstBatch._expirationTime;
  14730. // Rendering this batch again ensures its children will be the final state
  14731. // when we flush (updates are processed in insertion order: last
  14732. // update wins).
  14733. // TODO: This forces a restart. Should we print a warning?
  14734. this.render(this._children);
  14735. }
  14736. // Remove the batch from the list.
  14737. var previous = null;
  14738. var batch = firstBatch;
  14739. while (batch !== this) {
  14740. previous = batch;
  14741. batch = batch._next;
  14742. }
  14743. !(previous !== null) ? invariant_1(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0;
  14744. previous._next = batch._next;
  14745. // Add it to the front.
  14746. this._next = firstBatch;
  14747. firstBatch = internalRoot.firstBatch = this;
  14748. }
  14749. // Synchronously flush all the work up to this batch's expiration time.
  14750. this._defer = false;
  14751. DOMRenderer.flushRoot(internalRoot, expirationTime);
  14752. // Pop the batch from the list.
  14753. var next = this._next;
  14754. this._next = null;
  14755. firstBatch = internalRoot.firstBatch = next;
  14756. // Append the next earliest batch's children to the update queue.
  14757. if (firstBatch !== null && firstBatch._hasChildren) {
  14758. firstBatch.render(firstBatch._children);
  14759. }
  14760. };
  14761. ReactBatch.prototype._onComplete = function () {
  14762. if (this._didComplete) {
  14763. return;
  14764. }
  14765. this._didComplete = true;
  14766. var callbacks = this._callbacks;
  14767. if (callbacks === null) {
  14768. return;
  14769. }
  14770. // TODO: Error handling.
  14771. for (var i = 0; i < callbacks.length; i++) {
  14772. var _callback = callbacks[i];
  14773. _callback();
  14774. }
  14775. };
  14776. function ReactWork() {
  14777. this._callbacks = null;
  14778. this._didCommit = false;
  14779. // TODO: Avoid need to bind by replacing callbacks in the update queue with
  14780. // list of Work objects.
  14781. this._onCommit = this._onCommit.bind(this);
  14782. }
  14783. ReactWork.prototype.then = function (onCommit) {
  14784. if (this._didCommit) {
  14785. onCommit();
  14786. return;
  14787. }
  14788. var callbacks = this._callbacks;
  14789. if (callbacks === null) {
  14790. callbacks = this._callbacks = [];
  14791. }
  14792. callbacks.push(onCommit);
  14793. };
  14794. ReactWork.prototype._onCommit = function () {
  14795. if (this._didCommit) {
  14796. return;
  14797. }
  14798. this._didCommit = true;
  14799. var callbacks = this._callbacks;
  14800. if (callbacks === null) {
  14801. return;
  14802. }
  14803. // TODO: Error handling.
  14804. for (var i = 0; i < callbacks.length; i++) {
  14805. var _callback2 = callbacks[i];
  14806. !(typeof _callback2 === 'function') ? invariant_1(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback2) : void 0;
  14807. _callback2();
  14808. }
  14809. };
  14810. function ReactRoot(container, isAsync, hydrate) {
  14811. var root = DOMRenderer.createContainer(container, isAsync, hydrate);
  14812. this._internalRoot = root;
  14813. }
  14814. ReactRoot.prototype.render = function (children, callback) {
  14815. var root = this._internalRoot;
  14816. var work = new ReactWork();
  14817. callback = callback === undefined ? null : callback;
  14818. {
  14819. warnOnInvalidCallback(callback, 'render');
  14820. }
  14821. if (callback !== null) {
  14822. work.then(callback);
  14823. }
  14824. DOMRenderer.updateContainer(children, root, null, work._onCommit);
  14825. return work;
  14826. };
  14827. ReactRoot.prototype.unmount = function (callback) {
  14828. var root = this._internalRoot;
  14829. var work = new ReactWork();
  14830. callback = callback === undefined ? null : callback;
  14831. {
  14832. warnOnInvalidCallback(callback, 'render');
  14833. }
  14834. if (callback !== null) {
  14835. work.then(callback);
  14836. }
  14837. DOMRenderer.updateContainer(null, root, null, work._onCommit);
  14838. return work;
  14839. };
  14840. ReactRoot.prototype.legacy_renderSubtreeIntoContainer = function (parentComponent, children, callback) {
  14841. var root = this._internalRoot;
  14842. var work = new ReactWork();
  14843. callback = callback === undefined ? null : callback;
  14844. {
  14845. warnOnInvalidCallback(callback, 'render');
  14846. }
  14847. if (callback !== null) {
  14848. work.then(callback);
  14849. }
  14850. DOMRenderer.updateContainer(children, root, parentComponent, work._onCommit);
  14851. return work;
  14852. };
  14853. ReactRoot.prototype.createBatch = function () {
  14854. var batch = new ReactBatch(this);
  14855. var expirationTime = batch._expirationTime;
  14856. var internalRoot = this._internalRoot;
  14857. var firstBatch = internalRoot.firstBatch;
  14858. if (firstBatch === null) {
  14859. internalRoot.firstBatch = batch;
  14860. batch._next = null;
  14861. } else {
  14862. // Insert sorted by expiration time then insertion order
  14863. var insertAfter = null;
  14864. var insertBefore = firstBatch;
  14865. while (insertBefore !== null && insertBefore._expirationTime <= expirationTime) {
  14866. insertAfter = insertBefore;
  14867. insertBefore = insertBefore._next;
  14868. }
  14869. batch._next = insertBefore;
  14870. if (insertAfter !== null) {
  14871. insertAfter._next = batch;
  14872. }
  14873. }
  14874. return batch;
  14875. };
  14876. /**
  14877. * True if the supplied DOM node is a valid node element.
  14878. *
  14879. * @param {?DOMElement} node The candidate DOM node.
  14880. * @return {boolean} True if the DOM is a valid DOM node.
  14881. * @internal
  14882. */
  14883. function isValidContainer(node) {
  14884. return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable '));
  14885. }
  14886. function getReactRootElementInContainer(container) {
  14887. if (!container) {
  14888. return null;
  14889. }
  14890. if (container.nodeType === DOCUMENT_NODE) {
  14891. return container.documentElement;
  14892. } else {
  14893. return container.firstChild;
  14894. }
  14895. }
  14896. function shouldHydrateDueToLegacyHeuristic(container) {
  14897. var rootElement = getReactRootElementInContainer(container);
  14898. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  14899. }
  14900. function shouldAutoFocusHostComponent(type, props) {
  14901. switch (type) {
  14902. case 'button':
  14903. case 'input':
  14904. case 'select':
  14905. case 'textarea':
  14906. return !!props.autoFocus;
  14907. }
  14908. return false;
  14909. }
  14910. var DOMRenderer = reactReconciler({
  14911. getRootHostContext: function (rootContainerInstance) {
  14912. var type = void 0;
  14913. var namespace = void 0;
  14914. var nodeType = rootContainerInstance.nodeType;
  14915. switch (nodeType) {
  14916. case DOCUMENT_NODE:
  14917. case DOCUMENT_FRAGMENT_NODE:
  14918. {
  14919. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  14920. var root = rootContainerInstance.documentElement;
  14921. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  14922. break;
  14923. }
  14924. default:
  14925. {
  14926. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  14927. var ownNamespace = container.namespaceURI || null;
  14928. type = container.tagName;
  14929. namespace = getChildNamespace(ownNamespace, type);
  14930. break;
  14931. }
  14932. }
  14933. {
  14934. var validatedTag = type.toLowerCase();
  14935. var _ancestorInfo = updatedAncestorInfo(null, validatedTag, null);
  14936. return { namespace: namespace, ancestorInfo: _ancestorInfo };
  14937. }
  14938. return namespace;
  14939. },
  14940. getChildHostContext: function (parentHostContext, type) {
  14941. {
  14942. var parentHostContextDev = parentHostContext;
  14943. var _namespace = getChildNamespace(parentHostContextDev.namespace, type);
  14944. var _ancestorInfo2 = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type, null);
  14945. return { namespace: _namespace, ancestorInfo: _ancestorInfo2 };
  14946. }
  14947. var parentNamespace = parentHostContext;
  14948. return getChildNamespace(parentNamespace, type);
  14949. },
  14950. getPublicInstance: function (instance) {
  14951. return instance;
  14952. },
  14953. prepareForCommit: function () {
  14954. eventsEnabled = isEnabled();
  14955. selectionInformation = getSelectionInformation();
  14956. setEnabled(false);
  14957. },
  14958. resetAfterCommit: function () {
  14959. restoreSelection(selectionInformation);
  14960. selectionInformation = null;
  14961. setEnabled(eventsEnabled);
  14962. eventsEnabled = null;
  14963. },
  14964. createInstance: function (type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  14965. var parentNamespace = void 0;
  14966. {
  14967. // TODO: take namespace into account when validating.
  14968. var hostContextDev = hostContext;
  14969. validateDOMNesting$1(type, null, hostContextDev.ancestorInfo);
  14970. if (typeof props.children === 'string' || typeof props.children === 'number') {
  14971. var string = '' + props.children;
  14972. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null);
  14973. validateDOMNesting$1(null, string, ownAncestorInfo);
  14974. }
  14975. parentNamespace = hostContextDev.namespace;
  14976. }
  14977. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  14978. precacheFiberNode(internalInstanceHandle, domElement);
  14979. updateFiberProps(domElement, props);
  14980. return domElement;
  14981. },
  14982. appendInitialChild: function (parentInstance, child) {
  14983. parentInstance.appendChild(child);
  14984. },
  14985. finalizeInitialChildren: function (domElement, type, props, rootContainerInstance) {
  14986. setInitialProperties(domElement, type, props, rootContainerInstance);
  14987. return shouldAutoFocusHostComponent(type, props);
  14988. },
  14989. prepareUpdate: function (domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  14990. {
  14991. var hostContextDev = hostContext;
  14992. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  14993. var string = '' + newProps.children;
  14994. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null);
  14995. validateDOMNesting$1(null, string, ownAncestorInfo);
  14996. }
  14997. }
  14998. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  14999. },
  15000. shouldSetTextContent: function (type, props) {
  15001. return type === 'textarea' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && typeof props.dangerouslySetInnerHTML.__html === 'string';
  15002. },
  15003. shouldDeprioritizeSubtree: function (type, props) {
  15004. return !!props.hidden;
  15005. },
  15006. createTextInstance: function (text, rootContainerInstance, hostContext, internalInstanceHandle) {
  15007. {
  15008. var hostContextDev = hostContext;
  15009. validateDOMNesting$1(null, text, hostContextDev.ancestorInfo);
  15010. }
  15011. var textNode = createTextNode(text, rootContainerInstance);
  15012. precacheFiberNode(internalInstanceHandle, textNode);
  15013. return textNode;
  15014. },
  15015. now: now,
  15016. mutation: {
  15017. commitMount: function (domElement, type, newProps, internalInstanceHandle) {
  15018. // Despite the naming that might imply otherwise, this method only
  15019. // fires if there is an `Update` effect scheduled during mounting.
  15020. // This happens if `finalizeInitialChildren` returns `true` (which it
  15021. // does to implement the `autoFocus` attribute on the client). But
  15022. // there are also other cases when this might happen (such as patching
  15023. // up text content during hydration mismatch). So we'll check this again.
  15024. if (shouldAutoFocusHostComponent(type, newProps)) {
  15025. domElement.focus();
  15026. }
  15027. },
  15028. commitUpdate: function (domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  15029. // Update the props handle so that we know which props are the ones with
  15030. // with current event handlers.
  15031. updateFiberProps(domElement, newProps);
  15032. // Apply the diff to the DOM node.
  15033. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  15034. },
  15035. resetTextContent: function (domElement) {
  15036. setTextContent(domElement, '');
  15037. },
  15038. commitTextUpdate: function (textInstance, oldText, newText) {
  15039. textInstance.nodeValue = newText;
  15040. },
  15041. appendChild: function (parentInstance, child) {
  15042. parentInstance.appendChild(child);
  15043. },
  15044. appendChildToContainer: function (container, child) {
  15045. if (container.nodeType === COMMENT_NODE) {
  15046. container.parentNode.insertBefore(child, container);
  15047. } else {
  15048. container.appendChild(child);
  15049. }
  15050. },
  15051. insertBefore: function (parentInstance, child, beforeChild) {
  15052. parentInstance.insertBefore(child, beforeChild);
  15053. },
  15054. insertInContainerBefore: function (container, child, beforeChild) {
  15055. if (container.nodeType === COMMENT_NODE) {
  15056. container.parentNode.insertBefore(child, beforeChild);
  15057. } else {
  15058. container.insertBefore(child, beforeChild);
  15059. }
  15060. },
  15061. removeChild: function (parentInstance, child) {
  15062. parentInstance.removeChild(child);
  15063. },
  15064. removeChildFromContainer: function (container, child) {
  15065. if (container.nodeType === COMMENT_NODE) {
  15066. container.parentNode.removeChild(child);
  15067. } else {
  15068. container.removeChild(child);
  15069. }
  15070. }
  15071. },
  15072. hydration: {
  15073. canHydrateInstance: function (instance, type, props) {
  15074. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  15075. return null;
  15076. }
  15077. // This has now been refined to an element node.
  15078. return instance;
  15079. },
  15080. canHydrateTextInstance: function (instance, text) {
  15081. if (text === '' || instance.nodeType !== TEXT_NODE) {
  15082. // Empty strings are not parsed by HTML so there won't be a correct match here.
  15083. return null;
  15084. }
  15085. // This has now been refined to a text node.
  15086. return instance;
  15087. },
  15088. getNextHydratableSibling: function (instance) {
  15089. var node = instance.nextSibling;
  15090. // Skip non-hydratable nodes.
  15091. while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
  15092. node = node.nextSibling;
  15093. }
  15094. return node;
  15095. },
  15096. getFirstHydratableChild: function (parentInstance) {
  15097. var next = parentInstance.firstChild;
  15098. // Skip non-hydratable nodes.
  15099. while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
  15100. next = next.nextSibling;
  15101. }
  15102. return next;
  15103. },
  15104. hydrateInstance: function (instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  15105. precacheFiberNode(internalInstanceHandle, instance);
  15106. // TODO: Possibly defer this until the commit phase where all the events
  15107. // get attached.
  15108. updateFiberProps(instance, props);
  15109. var parentNamespace = void 0;
  15110. {
  15111. var hostContextDev = hostContext;
  15112. parentNamespace = hostContextDev.namespace;
  15113. }
  15114. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  15115. },
  15116. hydrateTextInstance: function (textInstance, text, internalInstanceHandle) {
  15117. precacheFiberNode(internalInstanceHandle, textInstance);
  15118. return diffHydratedText(textInstance, text);
  15119. },
  15120. didNotMatchHydratedContainerTextInstance: function (parentContainer, textInstance, text) {
  15121. {
  15122. warnForUnmatchedText(textInstance, text);
  15123. }
  15124. },
  15125. didNotMatchHydratedTextInstance: function (parentType, parentProps, parentInstance, textInstance, text) {
  15126. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  15127. warnForUnmatchedText(textInstance, text);
  15128. }
  15129. },
  15130. didNotHydrateContainerInstance: function (parentContainer, instance) {
  15131. {
  15132. if (instance.nodeType === 1) {
  15133. warnForDeletedHydratableElement(parentContainer, instance);
  15134. } else {
  15135. warnForDeletedHydratableText(parentContainer, instance);
  15136. }
  15137. }
  15138. },
  15139. didNotHydrateInstance: function (parentType, parentProps, parentInstance, instance) {
  15140. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  15141. if (instance.nodeType === 1) {
  15142. warnForDeletedHydratableElement(parentInstance, instance);
  15143. } else {
  15144. warnForDeletedHydratableText(parentInstance, instance);
  15145. }
  15146. }
  15147. },
  15148. didNotFindHydratableContainerInstance: function (parentContainer, type, props) {
  15149. {
  15150. warnForInsertedHydratedElement(parentContainer, type, props);
  15151. }
  15152. },
  15153. didNotFindHydratableContainerTextInstance: function (parentContainer, text) {
  15154. {
  15155. warnForInsertedHydratedText(parentContainer, text);
  15156. }
  15157. },
  15158. didNotFindHydratableInstance: function (parentType, parentProps, parentInstance, type, props) {
  15159. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  15160. warnForInsertedHydratedElement(parentInstance, type, props);
  15161. }
  15162. },
  15163. didNotFindHydratableTextInstance: function (parentType, parentProps, parentInstance, text) {
  15164. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  15165. warnForInsertedHydratedText(parentInstance, text);
  15166. }
  15167. }
  15168. },
  15169. scheduleDeferredCallback: rIC,
  15170. cancelDeferredCallback: cIC
  15171. });
  15172. injection$3.injectRenderer(DOMRenderer);
  15173. var warnedAboutHydrateAPI = false;
  15174. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  15175. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
  15176. // First clear any existing content.
  15177. if (!shouldHydrate) {
  15178. var warned = false;
  15179. var rootSibling = void 0;
  15180. while (rootSibling = container.lastChild) {
  15181. {
  15182. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  15183. warned = true;
  15184. warning_1(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.');
  15185. }
  15186. }
  15187. container.removeChild(rootSibling);
  15188. }
  15189. }
  15190. {
  15191. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  15192. warnedAboutHydrateAPI = true;
  15193. lowPriorityWarning$1(false, 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.');
  15194. }
  15195. }
  15196. // Legacy roots are not async by default.
  15197. var isAsync = false;
  15198. return new ReactRoot(container, isAsync, shouldHydrate);
  15199. }
  15200. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  15201. // TODO: Ensure all entry points contain this check
  15202. !isValidContainer(container) ? invariant_1(false, 'Target container is not a DOM element.') : void 0;
  15203. {
  15204. topLevelUpdateWarnings(container);
  15205. }
  15206. // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  15207. // member of intersection type." Whyyyyyy.
  15208. var root = container._reactRootContainer;
  15209. if (!root) {
  15210. // Initial mount
  15211. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  15212. if (typeof callback === 'function') {
  15213. var originalCallback = callback;
  15214. callback = function () {
  15215. var instance = DOMRenderer.getPublicRootInstance(root._internalRoot);
  15216. originalCallback.call(instance);
  15217. };
  15218. }
  15219. // Initial mount should not be batched.
  15220. DOMRenderer.unbatchedUpdates(function () {
  15221. if (parentComponent != null) {
  15222. root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
  15223. } else {
  15224. root.render(children, callback);
  15225. }
  15226. });
  15227. } else {
  15228. if (typeof callback === 'function') {
  15229. var _originalCallback = callback;
  15230. callback = function () {
  15231. var instance = DOMRenderer.getPublicRootInstance(root._internalRoot);
  15232. _originalCallback.call(instance);
  15233. };
  15234. }
  15235. // Update
  15236. if (parentComponent != null) {
  15237. root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
  15238. } else {
  15239. root.render(children, callback);
  15240. }
  15241. }
  15242. return DOMRenderer.getPublicRootInstance(root._internalRoot);
  15243. }
  15244. function createPortal(children, container) {
  15245. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  15246. !isValidContainer(container) ? invariant_1(false, 'Target container is not a DOM element.') : void 0;
  15247. // TODO: pass ReactDOM portal implementation as third argument
  15248. return createPortal$1(children, container, null, key);
  15249. }
  15250. var ReactDOM = {
  15251. createPortal: createPortal,
  15252. findDOMNode: function (componentOrElement) {
  15253. {
  15254. var owner = ReactCurrentOwner.current;
  15255. if (owner !== null && owner.stateNode !== null) {
  15256. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  15257. !warnedAboutRefsInRender ? warning_1(false, '%s is accessing findDOMNode inside its render(). ' + '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(owner) || 'A component') : void 0;
  15258. owner.stateNode._warnedAboutRefsInRender = true;
  15259. }
  15260. }
  15261. if (componentOrElement == null) {
  15262. return null;
  15263. }
  15264. if (componentOrElement.nodeType === ELEMENT_NODE) {
  15265. return componentOrElement;
  15266. }
  15267. return DOMRenderer.findHostInstance(componentOrElement);
  15268. },
  15269. hydrate: function (element, container, callback) {
  15270. // TODO: throw or warn if we couldn't hydrate?
  15271. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  15272. },
  15273. render: function (element, container, callback) {
  15274. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  15275. },
  15276. unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) {
  15277. !(parentComponent != null && has(parentComponent)) ? invariant_1(false, 'parentComponent must be a valid React Component') : void 0;
  15278. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  15279. },
  15280. unmountComponentAtNode: function (container) {
  15281. !isValidContainer(container) ? invariant_1(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : void 0;
  15282. if (container._reactRootContainer) {
  15283. {
  15284. var rootEl = getReactRootElementInContainer(container);
  15285. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  15286. !!renderedByDifferentReact ? warning_1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
  15287. }
  15288. // Unmount should not be batched.
  15289. DOMRenderer.unbatchedUpdates(function () {
  15290. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  15291. container._reactRootContainer = null;
  15292. });
  15293. });
  15294. // If you call unmountComponentAtNode twice in quick succession, you'll
  15295. // get `true` twice. That's probably fine?
  15296. return true;
  15297. } else {
  15298. {
  15299. var _rootEl = getReactRootElementInContainer(container);
  15300. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl));
  15301. // Check if the container itself is a React root node.
  15302. var isContainerReactRoot = container.nodeType === 1 && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  15303. !!hasNonRootReactChild ? warning_1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : void 0;
  15304. }
  15305. return false;
  15306. }
  15307. },
  15308. // Temporary alias since we already shipped React 16 RC with it.
  15309. // TODO: remove in React 17.
  15310. unstable_createPortal: function () {
  15311. if (!didWarnAboutUnstableCreatePortal) {
  15312. didWarnAboutUnstableCreatePortal = true;
  15313. lowPriorityWarning$1(false, 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.');
  15314. }
  15315. return createPortal.apply(undefined, arguments);
  15316. },
  15317. unstable_batchedUpdates: DOMRenderer.batchedUpdates,
  15318. unstable_deferredUpdates: DOMRenderer.deferredUpdates,
  15319. flushSync: DOMRenderer.flushSync,
  15320. unstable_flushControlled: DOMRenderer.flushControlled,
  15321. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  15322. // For TapEventPlugin which is popular in open source
  15323. EventPluginHub: EventPluginHub,
  15324. // Used by test-utils
  15325. EventPluginRegistry: EventPluginRegistry,
  15326. EventPropagators: EventPropagators,
  15327. ReactControlledComponent: ReactControlledComponent,
  15328. ReactDOMComponentTree: ReactDOMComponentTree,
  15329. ReactDOMEventListener: ReactDOMEventListener
  15330. }
  15331. };
  15332. ReactDOM.unstable_createRoot = function createRoot(container, options) {
  15333. var hydrate = options != null && options.hydrate === true;
  15334. return new ReactRoot(container, true, hydrate);
  15335. };
  15336. var foundDevTools = DOMRenderer.injectIntoDevTools({
  15337. findFiberByHostInstance: getClosestInstanceFromNode,
  15338. bundleType: 1,
  15339. version: ReactVersion,
  15340. rendererPackageName: 'react-dom'
  15341. });
  15342. {
  15343. if (!foundDevTools && ExecutionEnvironment_1.canUseDOM && window.top === window.self) {
  15344. // If we're in Chrome or Firefox, provide a download link if not installed.
  15345. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  15346. var protocol = window.location.protocol;
  15347. // Don't warn in exotic cases like chrome-extension://.
  15348. if (/^(https?|file):$/.test(protocol)) {
  15349. console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://fb.me/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://fb.me/react-devtools-faq' : ''), 'font-weight:bold');
  15350. }
  15351. }
  15352. }
  15353. }
  15354. var ReactDOM$2 = Object.freeze({
  15355. default: ReactDOM
  15356. });
  15357. var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2;
  15358. // TODO: decide on the top-level export form.
  15359. // This is hacky but makes it work with both Rollup and Jest.
  15360. var reactDom = ReactDOM$3['default'] ? ReactDOM$3['default'] : ReactDOM$3;
  15361. return reactDom;
  15362. })));