vue.esm.browser.js 388 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712
  1. /*!
  2. * Vue.js v2.7.14
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. const emptyObject = Object.freeze({});
  7. const isArray = Array.isArray;
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef(v) {
  11. return v === undefined || v === null;
  12. }
  13. function isDef(v) {
  14. return v !== undefined && v !== null;
  15. }
  16. function isTrue(v) {
  17. return v === true;
  18. }
  19. function isFalse(v) {
  20. return v === false;
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive(value) {
  26. return (typeof value === 'string' ||
  27. typeof value === 'number' ||
  28. // $flow-disable-line
  29. typeof value === 'symbol' ||
  30. typeof value === 'boolean');
  31. }
  32. function isFunction(value) {
  33. return typeof value === 'function';
  34. }
  35. /**
  36. * Quick object check - this is primarily used to tell
  37. * objects from primitive values when we know the value
  38. * is a JSON-compliant type.
  39. */
  40. function isObject(obj) {
  41. return obj !== null && typeof obj === 'object';
  42. }
  43. /**
  44. * Get the raw type string of a value, e.g., [object Object].
  45. */
  46. const _toString = Object.prototype.toString;
  47. function toRawType(value) {
  48. return _toString.call(value).slice(8, -1);
  49. }
  50. /**
  51. * Strict object type check. Only returns true
  52. * for plain JavaScript objects.
  53. */
  54. function isPlainObject(obj) {
  55. return _toString.call(obj) === '[object Object]';
  56. }
  57. function isRegExp(v) {
  58. return _toString.call(v) === '[object RegExp]';
  59. }
  60. /**
  61. * Check if val is a valid array index.
  62. */
  63. function isValidArrayIndex(val) {
  64. const n = parseFloat(String(val));
  65. return n >= 0 && Math.floor(n) === n && isFinite(val);
  66. }
  67. function isPromise(val) {
  68. return (isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function');
  71. }
  72. /**
  73. * Convert a value to a string that is actually rendered.
  74. */
  75. function toString(val) {
  76. return val == null
  77. ? ''
  78. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  79. ? JSON.stringify(val, null, 2)
  80. : String(val);
  81. }
  82. /**
  83. * Convert an input value to a number for persistence.
  84. * If the conversion fails, return original string.
  85. */
  86. function toNumber(val) {
  87. const n = parseFloat(val);
  88. return isNaN(n) ? val : n;
  89. }
  90. /**
  91. * Make a map and return a function for checking if a key
  92. * is in that map.
  93. */
  94. function makeMap(str, expectsLowerCase) {
  95. const map = Object.create(null);
  96. const list = str.split(',');
  97. for (let i = 0; i < list.length; i++) {
  98. map[list[i]] = true;
  99. }
  100. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  101. }
  102. /**
  103. * Check if a tag is a built-in tag.
  104. */
  105. const isBuiltInTag = makeMap('slot,component', true);
  106. /**
  107. * Check if an attribute is a reserved attribute.
  108. */
  109. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  110. /**
  111. * Remove an item from an array.
  112. */
  113. function remove$2(arr, item) {
  114. const len = arr.length;
  115. if (len) {
  116. // fast path for the only / last item
  117. if (item === arr[len - 1]) {
  118. arr.length = len - 1;
  119. return;
  120. }
  121. const index = arr.indexOf(item);
  122. if (index > -1) {
  123. return arr.splice(index, 1);
  124. }
  125. }
  126. }
  127. /**
  128. * Check whether an object has the property.
  129. */
  130. const hasOwnProperty = Object.prototype.hasOwnProperty;
  131. function hasOwn(obj, key) {
  132. return hasOwnProperty.call(obj, key);
  133. }
  134. /**
  135. * Create a cached version of a pure function.
  136. */
  137. function cached(fn) {
  138. const cache = Object.create(null);
  139. return function cachedFn(str) {
  140. const hit = cache[str];
  141. return hit || (cache[str] = fn(str));
  142. };
  143. }
  144. /**
  145. * Camelize a hyphen-delimited string.
  146. */
  147. const camelizeRE = /-(\w)/g;
  148. const camelize = cached((str) => {
  149. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  150. });
  151. /**
  152. * Capitalize a string.
  153. */
  154. const capitalize = cached((str) => {
  155. return str.charAt(0).toUpperCase() + str.slice(1);
  156. });
  157. /**
  158. * Hyphenate a camelCase string.
  159. */
  160. const hyphenateRE = /\B([A-Z])/g;
  161. const hyphenate = cached((str) => {
  162. return str.replace(hyphenateRE, '-$1').toLowerCase();
  163. });
  164. /**
  165. * Simple bind polyfill for environments that do not support it,
  166. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  167. * since native bind is now performant enough in most browsers.
  168. * But removing it would mean breaking code that was able to run in
  169. * PhantomJS 1.x, so this must be kept for backward compatibility.
  170. */
  171. /* istanbul ignore next */
  172. function polyfillBind(fn, ctx) {
  173. function boundFn(a) {
  174. const l = arguments.length;
  175. return l
  176. ? l > 1
  177. ? fn.apply(ctx, arguments)
  178. : fn.call(ctx, a)
  179. : fn.call(ctx);
  180. }
  181. boundFn._length = fn.length;
  182. return boundFn;
  183. }
  184. function nativeBind(fn, ctx) {
  185. return fn.bind(ctx);
  186. }
  187. // @ts-expect-error bind cannot be `undefined`
  188. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  189. /**
  190. * Convert an Array-like object to a real Array.
  191. */
  192. function toArray(list, start) {
  193. start = start || 0;
  194. let i = list.length - start;
  195. const ret = new Array(i);
  196. while (i--) {
  197. ret[i] = list[i + start];
  198. }
  199. return ret;
  200. }
  201. /**
  202. * Mix properties into target object.
  203. */
  204. function extend(to, _from) {
  205. for (const key in _from) {
  206. to[key] = _from[key];
  207. }
  208. return to;
  209. }
  210. /**
  211. * Merge an Array of Objects into a single Object.
  212. */
  213. function toObject(arr) {
  214. const res = {};
  215. for (let i = 0; i < arr.length; i++) {
  216. if (arr[i]) {
  217. extend(res, arr[i]);
  218. }
  219. }
  220. return res;
  221. }
  222. /* eslint-disable no-unused-vars */
  223. /**
  224. * Perform no operation.
  225. * Stubbing args to make Flow happy without leaving useless transpiled code
  226. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  227. */
  228. function noop(a, b, c) { }
  229. /**
  230. * Always return false.
  231. */
  232. const no = (a, b, c) => false;
  233. /* eslint-enable no-unused-vars */
  234. /**
  235. * Return the same value.
  236. */
  237. const identity = (_) => _;
  238. /**
  239. * Generate a string containing static keys from compiler modules.
  240. */
  241. function genStaticKeys$1(modules) {
  242. return modules
  243. .reduce((keys, m) => {
  244. return keys.concat(m.staticKeys || []);
  245. }, [])
  246. .join(',');
  247. }
  248. /**
  249. * Check if two values are loosely equal - that is,
  250. * if they are plain objects, do they have the same shape?
  251. */
  252. function looseEqual(a, b) {
  253. if (a === b)
  254. return true;
  255. const isObjectA = isObject(a);
  256. const isObjectB = isObject(b);
  257. if (isObjectA && isObjectB) {
  258. try {
  259. const isArrayA = Array.isArray(a);
  260. const isArrayB = Array.isArray(b);
  261. if (isArrayA && isArrayB) {
  262. return (a.length === b.length &&
  263. a.every((e, i) => {
  264. return looseEqual(e, b[i]);
  265. }));
  266. }
  267. else if (a instanceof Date && b instanceof Date) {
  268. return a.getTime() === b.getTime();
  269. }
  270. else if (!isArrayA && !isArrayB) {
  271. const keysA = Object.keys(a);
  272. const keysB = Object.keys(b);
  273. return (keysA.length === keysB.length &&
  274. keysA.every(key => {
  275. return looseEqual(a[key], b[key]);
  276. }));
  277. }
  278. else {
  279. /* istanbul ignore next */
  280. return false;
  281. }
  282. }
  283. catch (e) {
  284. /* istanbul ignore next */
  285. return false;
  286. }
  287. }
  288. else if (!isObjectA && !isObjectB) {
  289. return String(a) === String(b);
  290. }
  291. else {
  292. return false;
  293. }
  294. }
  295. /**
  296. * Return the first index at which a loosely equal value can be
  297. * found in the array (if value is a plain object, the array must
  298. * contain an object of the same shape), or -1 if it is not present.
  299. */
  300. function looseIndexOf(arr, val) {
  301. for (let i = 0; i < arr.length; i++) {
  302. if (looseEqual(arr[i], val))
  303. return i;
  304. }
  305. return -1;
  306. }
  307. /**
  308. * Ensure a function is called only once.
  309. */
  310. function once(fn) {
  311. let called = false;
  312. return function () {
  313. if (!called) {
  314. called = true;
  315. fn.apply(this, arguments);
  316. }
  317. };
  318. }
  319. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  320. function hasChanged(x, y) {
  321. if (x === y) {
  322. return x === 0 && 1 / x !== 1 / y;
  323. }
  324. else {
  325. return x === x || y === y;
  326. }
  327. }
  328. const SSR_ATTR = 'data-server-rendered';
  329. const ASSET_TYPES = ['component', 'directive', 'filter'];
  330. const LIFECYCLE_HOOKS = [
  331. 'beforeCreate',
  332. 'created',
  333. 'beforeMount',
  334. 'mounted',
  335. 'beforeUpdate',
  336. 'updated',
  337. 'beforeDestroy',
  338. 'destroyed',
  339. 'activated',
  340. 'deactivated',
  341. 'errorCaptured',
  342. 'serverPrefetch',
  343. 'renderTracked',
  344. 'renderTriggered'
  345. ];
  346. var config = {
  347. /**
  348. * Option merge strategies (used in core/util/options)
  349. */
  350. // $flow-disable-line
  351. optionMergeStrategies: Object.create(null),
  352. /**
  353. * Whether to suppress warnings.
  354. */
  355. silent: false,
  356. /**
  357. * Show production mode tip message on boot?
  358. */
  359. productionTip: true,
  360. /**
  361. * Whether to enable devtools
  362. */
  363. devtools: true,
  364. /**
  365. * Whether to record perf
  366. */
  367. performance: false,
  368. /**
  369. * Error handler for watcher errors
  370. */
  371. errorHandler: null,
  372. /**
  373. * Warn handler for watcher warns
  374. */
  375. warnHandler: null,
  376. /**
  377. * Ignore certain custom elements
  378. */
  379. ignoredElements: [],
  380. /**
  381. * Custom user key aliases for v-on
  382. */
  383. // $flow-disable-line
  384. keyCodes: Object.create(null),
  385. /**
  386. * Check if a tag is reserved so that it cannot be registered as a
  387. * component. This is platform-dependent and may be overwritten.
  388. */
  389. isReservedTag: no,
  390. /**
  391. * Check if an attribute is reserved so that it cannot be used as a component
  392. * prop. This is platform-dependent and may be overwritten.
  393. */
  394. isReservedAttr: no,
  395. /**
  396. * Check if a tag is an unknown element.
  397. * Platform-dependent.
  398. */
  399. isUnknownElement: no,
  400. /**
  401. * Get the namespace of an element
  402. */
  403. getTagNamespace: noop,
  404. /**
  405. * Parse the real tag name for the specific platform.
  406. */
  407. parsePlatformTagName: identity,
  408. /**
  409. * Check if an attribute must be bound using property, e.g. value
  410. * Platform-dependent.
  411. */
  412. mustUseProp: no,
  413. /**
  414. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  415. * This will significantly reduce performance if set to false.
  416. */
  417. async: true,
  418. /**
  419. * Exposed for legacy reasons
  420. */
  421. _lifecycleHooks: LIFECYCLE_HOOKS
  422. };
  423. /**
  424. * unicode letters used for parsing html tags, component names and property paths.
  425. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  426. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  427. */
  428. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  429. /**
  430. * Check if a string starts with $ or _
  431. */
  432. function isReserved(str) {
  433. const c = (str + '').charCodeAt(0);
  434. return c === 0x24 || c === 0x5f;
  435. }
  436. /**
  437. * Define a property.
  438. */
  439. function def(obj, key, val, enumerable) {
  440. Object.defineProperty(obj, key, {
  441. value: val,
  442. enumerable: !!enumerable,
  443. writable: true,
  444. configurable: true
  445. });
  446. }
  447. /**
  448. * Parse simple path.
  449. */
  450. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  451. function parsePath(path) {
  452. if (bailRE.test(path)) {
  453. return;
  454. }
  455. const segments = path.split('.');
  456. return function (obj) {
  457. for (let i = 0; i < segments.length; i++) {
  458. if (!obj)
  459. return;
  460. obj = obj[segments[i]];
  461. }
  462. return obj;
  463. };
  464. }
  465. // can we use __proto__?
  466. const hasProto = '__proto__' in {};
  467. // Browser environment sniffing
  468. const inBrowser = typeof window !== 'undefined';
  469. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  470. const isIE = UA && /msie|trident/.test(UA);
  471. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  472. const isEdge = UA && UA.indexOf('edge/') > 0;
  473. UA && UA.indexOf('android') > 0;
  474. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  475. UA && /chrome\/\d+/.test(UA) && !isEdge;
  476. UA && /phantomjs/.test(UA);
  477. const isFF = UA && UA.match(/firefox\/(\d+)/);
  478. // Firefox has a "watch" function on Object.prototype...
  479. // @ts-expect-error firebox support
  480. const nativeWatch = {}.watch;
  481. let supportsPassive = false;
  482. if (inBrowser) {
  483. try {
  484. const opts = {};
  485. Object.defineProperty(opts, 'passive', {
  486. get() {
  487. /* istanbul ignore next */
  488. supportsPassive = true;
  489. }
  490. }); // https://github.com/facebook/flow/issues/285
  491. window.addEventListener('test-passive', null, opts);
  492. }
  493. catch (e) { }
  494. }
  495. // this needs to be lazy-evaled because vue may be required before
  496. // vue-server-renderer can set VUE_ENV
  497. let _isServer;
  498. const isServerRendering = () => {
  499. if (_isServer === undefined) {
  500. /* istanbul ignore if */
  501. if (!inBrowser && typeof global !== 'undefined') {
  502. // detect presence of vue-server-renderer and avoid
  503. // Webpack shimming the process
  504. _isServer =
  505. global['process'] && global['process'].env.VUE_ENV === 'server';
  506. }
  507. else {
  508. _isServer = false;
  509. }
  510. }
  511. return _isServer;
  512. };
  513. // detect devtools
  514. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  515. /* istanbul ignore next */
  516. function isNative(Ctor) {
  517. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  518. }
  519. const hasSymbol = typeof Symbol !== 'undefined' &&
  520. isNative(Symbol) &&
  521. typeof Reflect !== 'undefined' &&
  522. isNative(Reflect.ownKeys);
  523. let _Set; // $flow-disable-line
  524. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  525. // use native Set when available.
  526. _Set = Set;
  527. }
  528. else {
  529. // a non-standard Set polyfill that only works with primitive keys.
  530. _Set = class Set {
  531. constructor() {
  532. this.set = Object.create(null);
  533. }
  534. has(key) {
  535. return this.set[key] === true;
  536. }
  537. add(key) {
  538. this.set[key] = true;
  539. }
  540. clear() {
  541. this.set = Object.create(null);
  542. }
  543. };
  544. }
  545. let currentInstance = null;
  546. /**
  547. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  548. * relies on it). Do not use this internally, just use `currentInstance`.
  549. *
  550. * @internal this function needs manual type declaration because it relies
  551. * on previously manually authored types from Vue 2
  552. */
  553. function getCurrentInstance() {
  554. return currentInstance && { proxy: currentInstance };
  555. }
  556. /**
  557. * @internal
  558. */
  559. function setCurrentInstance(vm = null) {
  560. if (!vm)
  561. currentInstance && currentInstance._scope.off();
  562. currentInstance = vm;
  563. vm && vm._scope.on();
  564. }
  565. /**
  566. * @internal
  567. */
  568. class VNode {
  569. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  570. this.tag = tag;
  571. this.data = data;
  572. this.children = children;
  573. this.text = text;
  574. this.elm = elm;
  575. this.ns = undefined;
  576. this.context = context;
  577. this.fnContext = undefined;
  578. this.fnOptions = undefined;
  579. this.fnScopeId = undefined;
  580. this.key = data && data.key;
  581. this.componentOptions = componentOptions;
  582. this.componentInstance = undefined;
  583. this.parent = undefined;
  584. this.raw = false;
  585. this.isStatic = false;
  586. this.isRootInsert = true;
  587. this.isComment = false;
  588. this.isCloned = false;
  589. this.isOnce = false;
  590. this.asyncFactory = asyncFactory;
  591. this.asyncMeta = undefined;
  592. this.isAsyncPlaceholder = false;
  593. }
  594. // DEPRECATED: alias for componentInstance for backwards compat.
  595. /* istanbul ignore next */
  596. get child() {
  597. return this.componentInstance;
  598. }
  599. }
  600. const createEmptyVNode = (text = '') => {
  601. const node = new VNode();
  602. node.text = text;
  603. node.isComment = true;
  604. return node;
  605. };
  606. function createTextVNode(val) {
  607. return new VNode(undefined, undefined, undefined, String(val));
  608. }
  609. // optimized shallow clone
  610. // used for static nodes and slot nodes because they may be reused across
  611. // multiple renders, cloning them avoids errors when DOM manipulations rely
  612. // on their elm reference.
  613. function cloneVNode(vnode) {
  614. const cloned = new VNode(vnode.tag, vnode.data,
  615. // #7975
  616. // clone children array to avoid mutating original in case of cloning
  617. // a child.
  618. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  619. cloned.ns = vnode.ns;
  620. cloned.isStatic = vnode.isStatic;
  621. cloned.key = vnode.key;
  622. cloned.isComment = vnode.isComment;
  623. cloned.fnContext = vnode.fnContext;
  624. cloned.fnOptions = vnode.fnOptions;
  625. cloned.fnScopeId = vnode.fnScopeId;
  626. cloned.asyncMeta = vnode.asyncMeta;
  627. cloned.isCloned = true;
  628. return cloned;
  629. }
  630. /* not type checking this file because flow doesn't play well with Proxy */
  631. let initProxy;
  632. {
  633. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  634. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  635. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  636. 'require' // for Webpack/Browserify
  637. );
  638. const warnNonPresent = (target, key) => {
  639. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  640. 'referenced during render. Make sure that this property is reactive, ' +
  641. 'either in the data option, or for class-based components, by ' +
  642. 'initializing the property. ' +
  643. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  644. };
  645. const warnReservedPrefix = (target, key) => {
  646. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  647. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  648. 'prevent conflicts with Vue internals. ' +
  649. 'See: https://v2.vuejs.org/v2/api/#data', target);
  650. };
  651. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  652. if (hasProxy) {
  653. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  654. config.keyCodes = new Proxy(config.keyCodes, {
  655. set(target, key, value) {
  656. if (isBuiltInModifier(key)) {
  657. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  658. return false;
  659. }
  660. else {
  661. target[key] = value;
  662. return true;
  663. }
  664. }
  665. });
  666. }
  667. const hasHandler = {
  668. has(target, key) {
  669. const has = key in target;
  670. const isAllowed = allowedGlobals(key) ||
  671. (typeof key === 'string' &&
  672. key.charAt(0) === '_' &&
  673. !(key in target.$data));
  674. if (!has && !isAllowed) {
  675. if (key in target.$data)
  676. warnReservedPrefix(target, key);
  677. else
  678. warnNonPresent(target, key);
  679. }
  680. return has || !isAllowed;
  681. }
  682. };
  683. const getHandler = {
  684. get(target, key) {
  685. if (typeof key === 'string' && !(key in target)) {
  686. if (key in target.$data)
  687. warnReservedPrefix(target, key);
  688. else
  689. warnNonPresent(target, key);
  690. }
  691. return target[key];
  692. }
  693. };
  694. initProxy = function initProxy(vm) {
  695. if (hasProxy) {
  696. // determine which proxy handler to use
  697. const options = vm.$options;
  698. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  699. vm._renderProxy = new Proxy(vm, handlers);
  700. }
  701. else {
  702. vm._renderProxy = vm;
  703. }
  704. };
  705. }
  706. let uid$2 = 0;
  707. const pendingCleanupDeps = [];
  708. const cleanupDeps = () => {
  709. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  710. const dep = pendingCleanupDeps[i];
  711. dep.subs = dep.subs.filter(s => s);
  712. dep._pending = false;
  713. }
  714. pendingCleanupDeps.length = 0;
  715. };
  716. /**
  717. * A dep is an observable that can have multiple
  718. * directives subscribing to it.
  719. * @internal
  720. */
  721. class Dep {
  722. constructor() {
  723. // pending subs cleanup
  724. this._pending = false;
  725. this.id = uid$2++;
  726. this.subs = [];
  727. }
  728. addSub(sub) {
  729. this.subs.push(sub);
  730. }
  731. removeSub(sub) {
  732. // #12696 deps with massive amount of subscribers are extremely slow to
  733. // clean up in Chromium
  734. // to workaround this, we unset the sub for now, and clear them on
  735. // next scheduler flush.
  736. this.subs[this.subs.indexOf(sub)] = null;
  737. if (!this._pending) {
  738. this._pending = true;
  739. pendingCleanupDeps.push(this);
  740. }
  741. }
  742. depend(info) {
  743. if (Dep.target) {
  744. Dep.target.addDep(this);
  745. if (info && Dep.target.onTrack) {
  746. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  747. }
  748. }
  749. }
  750. notify(info) {
  751. // stabilize the subscriber list first
  752. const subs = this.subs.filter(s => s);
  753. if (!config.async) {
  754. // subs aren't sorted in scheduler if not running async
  755. // we need to sort them now to make sure they fire in correct
  756. // order
  757. subs.sort((a, b) => a.id - b.id);
  758. }
  759. for (let i = 0, l = subs.length; i < l; i++) {
  760. const sub = subs[i];
  761. if (info) {
  762. sub.onTrigger &&
  763. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  764. }
  765. sub.update();
  766. }
  767. }
  768. }
  769. // The current target watcher being evaluated.
  770. // This is globally unique because only one watcher
  771. // can be evaluated at a time.
  772. Dep.target = null;
  773. const targetStack = [];
  774. function pushTarget(target) {
  775. targetStack.push(target);
  776. Dep.target = target;
  777. }
  778. function popTarget() {
  779. targetStack.pop();
  780. Dep.target = targetStack[targetStack.length - 1];
  781. }
  782. /*
  783. * not type checking this file because flow doesn't play well with
  784. * dynamically accessing methods on Array prototype
  785. */
  786. const arrayProto = Array.prototype;
  787. const arrayMethods = Object.create(arrayProto);
  788. const methodsToPatch = [
  789. 'push',
  790. 'pop',
  791. 'shift',
  792. 'unshift',
  793. 'splice',
  794. 'sort',
  795. 'reverse'
  796. ];
  797. /**
  798. * Intercept mutating methods and emit events
  799. */
  800. methodsToPatch.forEach(function (method) {
  801. // cache original method
  802. const original = arrayProto[method];
  803. def(arrayMethods, method, function mutator(...args) {
  804. const result = original.apply(this, args);
  805. const ob = this.__ob__;
  806. let inserted;
  807. switch (method) {
  808. case 'push':
  809. case 'unshift':
  810. inserted = args;
  811. break;
  812. case 'splice':
  813. inserted = args.slice(2);
  814. break;
  815. }
  816. if (inserted)
  817. ob.observeArray(inserted);
  818. // notify change
  819. {
  820. ob.dep.notify({
  821. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  822. target: this,
  823. key: method
  824. });
  825. }
  826. return result;
  827. });
  828. });
  829. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  830. const NO_INIITIAL_VALUE = {};
  831. /**
  832. * In some cases we may want to disable observation inside a component's
  833. * update computation.
  834. */
  835. let shouldObserve = true;
  836. function toggleObserving(value) {
  837. shouldObserve = value;
  838. }
  839. // ssr mock dep
  840. const mockDep = {
  841. notify: noop,
  842. depend: noop,
  843. addSub: noop,
  844. removeSub: noop
  845. };
  846. /**
  847. * Observer class that is attached to each observed
  848. * object. Once attached, the observer converts the target
  849. * object's property keys into getter/setters that
  850. * collect dependencies and dispatch updates.
  851. */
  852. class Observer {
  853. constructor(value, shallow = false, mock = false) {
  854. this.value = value;
  855. this.shallow = shallow;
  856. this.mock = mock;
  857. // this.value = value
  858. this.dep = mock ? mockDep : new Dep();
  859. this.vmCount = 0;
  860. def(value, '__ob__', this);
  861. if (isArray(value)) {
  862. if (!mock) {
  863. if (hasProto) {
  864. value.__proto__ = arrayMethods;
  865. /* eslint-enable no-proto */
  866. }
  867. else {
  868. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  869. const key = arrayKeys[i];
  870. def(value, key, arrayMethods[key]);
  871. }
  872. }
  873. }
  874. if (!shallow) {
  875. this.observeArray(value);
  876. }
  877. }
  878. else {
  879. /**
  880. * Walk through all properties and convert them into
  881. * getter/setters. This method should only be called when
  882. * value type is Object.
  883. */
  884. const keys = Object.keys(value);
  885. for (let i = 0; i < keys.length; i++) {
  886. const key = keys[i];
  887. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  888. }
  889. }
  890. }
  891. /**
  892. * Observe a list of Array items.
  893. */
  894. observeArray(value) {
  895. for (let i = 0, l = value.length; i < l; i++) {
  896. observe(value[i], false, this.mock);
  897. }
  898. }
  899. }
  900. // helpers
  901. /**
  902. * Attempt to create an observer instance for a value,
  903. * returns the new observer if successfully observed,
  904. * or the existing observer if the value already has one.
  905. */
  906. function observe(value, shallow, ssrMockReactivity) {
  907. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  908. return value.__ob__;
  909. }
  910. if (shouldObserve &&
  911. (ssrMockReactivity || !isServerRendering()) &&
  912. (isArray(value) || isPlainObject(value)) &&
  913. Object.isExtensible(value) &&
  914. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  915. !isRef(value) &&
  916. !(value instanceof VNode)) {
  917. return new Observer(value, shallow, ssrMockReactivity);
  918. }
  919. }
  920. /**
  921. * Define a reactive property on an Object.
  922. */
  923. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  924. const dep = new Dep();
  925. const property = Object.getOwnPropertyDescriptor(obj, key);
  926. if (property && property.configurable === false) {
  927. return;
  928. }
  929. // cater for pre-defined getter/setters
  930. const getter = property && property.get;
  931. const setter = property && property.set;
  932. if ((!getter || setter) &&
  933. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  934. val = obj[key];
  935. }
  936. let childOb = !shallow && observe(val, false, mock);
  937. Object.defineProperty(obj, key, {
  938. enumerable: true,
  939. configurable: true,
  940. get: function reactiveGetter() {
  941. const value = getter ? getter.call(obj) : val;
  942. if (Dep.target) {
  943. {
  944. dep.depend({
  945. target: obj,
  946. type: "get" /* TrackOpTypes.GET */,
  947. key
  948. });
  949. }
  950. if (childOb) {
  951. childOb.dep.depend();
  952. if (isArray(value)) {
  953. dependArray(value);
  954. }
  955. }
  956. }
  957. return isRef(value) && !shallow ? value.value : value;
  958. },
  959. set: function reactiveSetter(newVal) {
  960. const value = getter ? getter.call(obj) : val;
  961. if (!hasChanged(value, newVal)) {
  962. return;
  963. }
  964. if (customSetter) {
  965. customSetter();
  966. }
  967. if (setter) {
  968. setter.call(obj, newVal);
  969. }
  970. else if (getter) {
  971. // #7981: for accessor properties without setter
  972. return;
  973. }
  974. else if (!shallow && isRef(value) && !isRef(newVal)) {
  975. value.value = newVal;
  976. return;
  977. }
  978. else {
  979. val = newVal;
  980. }
  981. childOb = !shallow && observe(newVal, false, mock);
  982. {
  983. dep.notify({
  984. type: "set" /* TriggerOpTypes.SET */,
  985. target: obj,
  986. key,
  987. newValue: newVal,
  988. oldValue: value
  989. });
  990. }
  991. }
  992. });
  993. return dep;
  994. }
  995. function set(target, key, val) {
  996. if ((isUndef(target) || isPrimitive(target))) {
  997. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  998. }
  999. if (isReadonly(target)) {
  1000. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1001. return;
  1002. }
  1003. const ob = target.__ob__;
  1004. if (isArray(target) && isValidArrayIndex(key)) {
  1005. target.length = Math.max(target.length, key);
  1006. target.splice(key, 1, val);
  1007. // when mocking for SSR, array methods are not hijacked
  1008. if (ob && !ob.shallow && ob.mock) {
  1009. observe(val, false, true);
  1010. }
  1011. return val;
  1012. }
  1013. if (key in target && !(key in Object.prototype)) {
  1014. target[key] = val;
  1015. return val;
  1016. }
  1017. if (target._isVue || (ob && ob.vmCount)) {
  1018. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1019. 'at runtime - declare it upfront in the data option.');
  1020. return val;
  1021. }
  1022. if (!ob) {
  1023. target[key] = val;
  1024. return val;
  1025. }
  1026. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1027. {
  1028. ob.dep.notify({
  1029. type: "add" /* TriggerOpTypes.ADD */,
  1030. target: target,
  1031. key,
  1032. newValue: val,
  1033. oldValue: undefined
  1034. });
  1035. }
  1036. return val;
  1037. }
  1038. function del(target, key) {
  1039. if ((isUndef(target) || isPrimitive(target))) {
  1040. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1041. }
  1042. if (isArray(target) && isValidArrayIndex(key)) {
  1043. target.splice(key, 1);
  1044. return;
  1045. }
  1046. const ob = target.__ob__;
  1047. if (target._isVue || (ob && ob.vmCount)) {
  1048. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1049. '- just set it to null.');
  1050. return;
  1051. }
  1052. if (isReadonly(target)) {
  1053. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1054. return;
  1055. }
  1056. if (!hasOwn(target, key)) {
  1057. return;
  1058. }
  1059. delete target[key];
  1060. if (!ob) {
  1061. return;
  1062. }
  1063. {
  1064. ob.dep.notify({
  1065. type: "delete" /* TriggerOpTypes.DELETE */,
  1066. target: target,
  1067. key
  1068. });
  1069. }
  1070. }
  1071. /**
  1072. * Collect dependencies on array elements when the array is touched, since
  1073. * we cannot intercept array element access like property getters.
  1074. */
  1075. function dependArray(value) {
  1076. for (let e, i = 0, l = value.length; i < l; i++) {
  1077. e = value[i];
  1078. if (e && e.__ob__) {
  1079. e.__ob__.dep.depend();
  1080. }
  1081. if (isArray(e)) {
  1082. dependArray(e);
  1083. }
  1084. }
  1085. }
  1086. function reactive(target) {
  1087. makeReactive(target, false);
  1088. return target;
  1089. }
  1090. /**
  1091. * Return a shallowly-reactive copy of the original object, where only the root
  1092. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1093. * root level).
  1094. */
  1095. function shallowReactive(target) {
  1096. makeReactive(target, true);
  1097. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1098. return target;
  1099. }
  1100. function makeReactive(target, shallow) {
  1101. // if trying to observe a readonly proxy, return the readonly version.
  1102. if (!isReadonly(target)) {
  1103. {
  1104. if (isArray(target)) {
  1105. warn$2(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
  1106. }
  1107. const existingOb = target && target.__ob__;
  1108. if (existingOb && existingOb.shallow !== shallow) {
  1109. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1110. }
  1111. }
  1112. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1113. if (!ob) {
  1114. if (target == null || isPrimitive(target)) {
  1115. warn$2(`value cannot be made reactive: ${String(target)}`);
  1116. }
  1117. if (isCollectionType(target)) {
  1118. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1119. }
  1120. }
  1121. }
  1122. }
  1123. function isReactive(value) {
  1124. if (isReadonly(value)) {
  1125. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1126. }
  1127. return !!(value && value.__ob__);
  1128. }
  1129. function isShallow(value) {
  1130. return !!(value && value.__v_isShallow);
  1131. }
  1132. function isReadonly(value) {
  1133. return !!(value && value.__v_isReadonly);
  1134. }
  1135. function isProxy(value) {
  1136. return isReactive(value) || isReadonly(value);
  1137. }
  1138. function toRaw(observed) {
  1139. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1140. return raw ? toRaw(raw) : observed;
  1141. }
  1142. function markRaw(value) {
  1143. // non-extensible objects won't be observed anyway
  1144. if (Object.isExtensible(value)) {
  1145. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1146. }
  1147. return value;
  1148. }
  1149. /**
  1150. * @internal
  1151. */
  1152. function isCollectionType(value) {
  1153. const type = toRawType(value);
  1154. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1155. }
  1156. /**
  1157. * @internal
  1158. */
  1159. const RefFlag = `__v_isRef`;
  1160. function isRef(r) {
  1161. return !!(r && r.__v_isRef === true);
  1162. }
  1163. function ref$1(value) {
  1164. return createRef(value, false);
  1165. }
  1166. function shallowRef(value) {
  1167. return createRef(value, true);
  1168. }
  1169. function createRef(rawValue, shallow) {
  1170. if (isRef(rawValue)) {
  1171. return rawValue;
  1172. }
  1173. const ref = {};
  1174. def(ref, RefFlag, true);
  1175. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1176. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1177. return ref;
  1178. }
  1179. function triggerRef(ref) {
  1180. if (!ref.dep) {
  1181. warn$2(`received object is not a triggerable ref.`);
  1182. }
  1183. {
  1184. ref.dep &&
  1185. ref.dep.notify({
  1186. type: "set" /* TriggerOpTypes.SET */,
  1187. target: ref,
  1188. key: 'value'
  1189. });
  1190. }
  1191. }
  1192. function unref(ref) {
  1193. return isRef(ref) ? ref.value : ref;
  1194. }
  1195. function proxyRefs(objectWithRefs) {
  1196. if (isReactive(objectWithRefs)) {
  1197. return objectWithRefs;
  1198. }
  1199. const proxy = {};
  1200. const keys = Object.keys(objectWithRefs);
  1201. for (let i = 0; i < keys.length; i++) {
  1202. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1203. }
  1204. return proxy;
  1205. }
  1206. function proxyWithRefUnwrap(target, source, key) {
  1207. Object.defineProperty(target, key, {
  1208. enumerable: true,
  1209. configurable: true,
  1210. get: () => {
  1211. const val = source[key];
  1212. if (isRef(val)) {
  1213. return val.value;
  1214. }
  1215. else {
  1216. const ob = val && val.__ob__;
  1217. if (ob)
  1218. ob.dep.depend();
  1219. return val;
  1220. }
  1221. },
  1222. set: value => {
  1223. const oldValue = source[key];
  1224. if (isRef(oldValue) && !isRef(value)) {
  1225. oldValue.value = value;
  1226. }
  1227. else {
  1228. source[key] = value;
  1229. }
  1230. }
  1231. });
  1232. }
  1233. function customRef(factory) {
  1234. const dep = new Dep();
  1235. const { get, set } = factory(() => {
  1236. {
  1237. dep.depend({
  1238. target: ref,
  1239. type: "get" /* TrackOpTypes.GET */,
  1240. key: 'value'
  1241. });
  1242. }
  1243. }, () => {
  1244. {
  1245. dep.notify({
  1246. target: ref,
  1247. type: "set" /* TriggerOpTypes.SET */,
  1248. key: 'value'
  1249. });
  1250. }
  1251. });
  1252. const ref = {
  1253. get value() {
  1254. return get();
  1255. },
  1256. set value(newVal) {
  1257. set(newVal);
  1258. }
  1259. };
  1260. def(ref, RefFlag, true);
  1261. return ref;
  1262. }
  1263. function toRefs(object) {
  1264. if (!isReactive(object)) {
  1265. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1266. }
  1267. const ret = isArray(object) ? new Array(object.length) : {};
  1268. for (const key in object) {
  1269. ret[key] = toRef(object, key);
  1270. }
  1271. return ret;
  1272. }
  1273. function toRef(object, key, defaultValue) {
  1274. const val = object[key];
  1275. if (isRef(val)) {
  1276. return val;
  1277. }
  1278. const ref = {
  1279. get value() {
  1280. const val = object[key];
  1281. return val === undefined ? defaultValue : val;
  1282. },
  1283. set value(newVal) {
  1284. object[key] = newVal;
  1285. }
  1286. };
  1287. def(ref, RefFlag, true);
  1288. return ref;
  1289. }
  1290. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1291. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1292. function readonly(target) {
  1293. return createReadonly(target, false);
  1294. }
  1295. function createReadonly(target, shallow) {
  1296. if (!isPlainObject(target)) {
  1297. {
  1298. if (isArray(target)) {
  1299. warn$2(`Vue 2 does not support readonly arrays.`);
  1300. }
  1301. else if (isCollectionType(target)) {
  1302. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1303. }
  1304. else {
  1305. warn$2(`value cannot be made readonly: ${typeof target}`);
  1306. }
  1307. }
  1308. return target;
  1309. }
  1310. if (!Object.isExtensible(target)) {
  1311. warn$2(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1312. }
  1313. // already a readonly object
  1314. if (isReadonly(target)) {
  1315. return target;
  1316. }
  1317. // already has a readonly proxy
  1318. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1319. const existingProxy = target[existingFlag];
  1320. if (existingProxy) {
  1321. return existingProxy;
  1322. }
  1323. const proxy = Object.create(Object.getPrototypeOf(target));
  1324. def(target, existingFlag, proxy);
  1325. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1326. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1327. if (isRef(target)) {
  1328. def(proxy, RefFlag, true);
  1329. }
  1330. if (shallow || isShallow(target)) {
  1331. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1332. }
  1333. const keys = Object.keys(target);
  1334. for (let i = 0; i < keys.length; i++) {
  1335. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1336. }
  1337. return proxy;
  1338. }
  1339. function defineReadonlyProperty(proxy, target, key, shallow) {
  1340. Object.defineProperty(proxy, key, {
  1341. enumerable: true,
  1342. configurable: true,
  1343. get() {
  1344. const val = target[key];
  1345. return shallow || !isPlainObject(val) ? val : readonly(val);
  1346. },
  1347. set() {
  1348. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1349. }
  1350. });
  1351. }
  1352. /**
  1353. * Returns a reactive-copy of the original object, where only the root level
  1354. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1355. * returned properties.
  1356. * This is used for creating the props proxy object for stateful components.
  1357. */
  1358. function shallowReadonly(target) {
  1359. return createReadonly(target, true);
  1360. }
  1361. function computed(getterOrOptions, debugOptions) {
  1362. let getter;
  1363. let setter;
  1364. const onlyGetter = isFunction(getterOrOptions);
  1365. if (onlyGetter) {
  1366. getter = getterOrOptions;
  1367. setter = () => {
  1368. warn$2('Write operation failed: computed value is readonly');
  1369. }
  1370. ;
  1371. }
  1372. else {
  1373. getter = getterOrOptions.get;
  1374. setter = getterOrOptions.set;
  1375. }
  1376. const watcher = isServerRendering()
  1377. ? null
  1378. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1379. if (watcher && debugOptions) {
  1380. watcher.onTrack = debugOptions.onTrack;
  1381. watcher.onTrigger = debugOptions.onTrigger;
  1382. }
  1383. const ref = {
  1384. // some libs rely on the presence effect for checking computed refs
  1385. // from normal refs, but the implementation doesn't matter
  1386. effect: watcher,
  1387. get value() {
  1388. if (watcher) {
  1389. if (watcher.dirty) {
  1390. watcher.evaluate();
  1391. }
  1392. if (Dep.target) {
  1393. if (Dep.target.onTrack) {
  1394. Dep.target.onTrack({
  1395. effect: Dep.target,
  1396. target: ref,
  1397. type: "get" /* TrackOpTypes.GET */,
  1398. key: 'value'
  1399. });
  1400. }
  1401. watcher.depend();
  1402. }
  1403. return watcher.value;
  1404. }
  1405. else {
  1406. return getter();
  1407. }
  1408. },
  1409. set value(newVal) {
  1410. setter(newVal);
  1411. }
  1412. };
  1413. def(ref, RefFlag, true);
  1414. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1415. return ref;
  1416. }
  1417. let mark;
  1418. let measure;
  1419. {
  1420. const perf = inBrowser && window.performance;
  1421. /* istanbul ignore if */
  1422. if (perf &&
  1423. // @ts-ignore
  1424. perf.mark &&
  1425. // @ts-ignore
  1426. perf.measure &&
  1427. // @ts-ignore
  1428. perf.clearMarks &&
  1429. // @ts-ignore
  1430. perf.clearMeasures) {
  1431. mark = tag => perf.mark(tag);
  1432. measure = (name, startTag, endTag) => {
  1433. perf.measure(name, startTag, endTag);
  1434. perf.clearMarks(startTag);
  1435. perf.clearMarks(endTag);
  1436. // perf.clearMeasures(name)
  1437. };
  1438. }
  1439. }
  1440. const normalizeEvent = cached((name) => {
  1441. const passive = name.charAt(0) === '&';
  1442. name = passive ? name.slice(1) : name;
  1443. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1444. name = once ? name.slice(1) : name;
  1445. const capture = name.charAt(0) === '!';
  1446. name = capture ? name.slice(1) : name;
  1447. return {
  1448. name,
  1449. once,
  1450. capture,
  1451. passive
  1452. };
  1453. });
  1454. function createFnInvoker(fns, vm) {
  1455. function invoker() {
  1456. const fns = invoker.fns;
  1457. if (isArray(fns)) {
  1458. const cloned = fns.slice();
  1459. for (let i = 0; i < cloned.length; i++) {
  1460. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1461. }
  1462. }
  1463. else {
  1464. // return handler return value for single handlers
  1465. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1466. }
  1467. }
  1468. invoker.fns = fns;
  1469. return invoker;
  1470. }
  1471. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1472. let name, cur, old, event;
  1473. for (name in on) {
  1474. cur = on[name];
  1475. old = oldOn[name];
  1476. event = normalizeEvent(name);
  1477. if (isUndef(cur)) {
  1478. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1479. }
  1480. else if (isUndef(old)) {
  1481. if (isUndef(cur.fns)) {
  1482. cur = on[name] = createFnInvoker(cur, vm);
  1483. }
  1484. if (isTrue(event.once)) {
  1485. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1486. }
  1487. add(event.name, cur, event.capture, event.passive, event.params);
  1488. }
  1489. else if (cur !== old) {
  1490. old.fns = cur;
  1491. on[name] = old;
  1492. }
  1493. }
  1494. for (name in oldOn) {
  1495. if (isUndef(on[name])) {
  1496. event = normalizeEvent(name);
  1497. remove(event.name, oldOn[name], event.capture);
  1498. }
  1499. }
  1500. }
  1501. function mergeVNodeHook(def, hookKey, hook) {
  1502. if (def instanceof VNode) {
  1503. def = def.data.hook || (def.data.hook = {});
  1504. }
  1505. let invoker;
  1506. const oldHook = def[hookKey];
  1507. function wrappedHook() {
  1508. hook.apply(this, arguments);
  1509. // important: remove merged hook to ensure it's called only once
  1510. // and prevent memory leak
  1511. remove$2(invoker.fns, wrappedHook);
  1512. }
  1513. if (isUndef(oldHook)) {
  1514. // no existing hook
  1515. invoker = createFnInvoker([wrappedHook]);
  1516. }
  1517. else {
  1518. /* istanbul ignore if */
  1519. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1520. // already a merged invoker
  1521. invoker = oldHook;
  1522. invoker.fns.push(wrappedHook);
  1523. }
  1524. else {
  1525. // existing plain hook
  1526. invoker = createFnInvoker([oldHook, wrappedHook]);
  1527. }
  1528. }
  1529. invoker.merged = true;
  1530. def[hookKey] = invoker;
  1531. }
  1532. function extractPropsFromVNodeData(data, Ctor, tag) {
  1533. // we are only extracting raw values here.
  1534. // validation and default values are handled in the child
  1535. // component itself.
  1536. const propOptions = Ctor.options.props;
  1537. if (isUndef(propOptions)) {
  1538. return;
  1539. }
  1540. const res = {};
  1541. const { attrs, props } = data;
  1542. if (isDef(attrs) || isDef(props)) {
  1543. for (const key in propOptions) {
  1544. const altKey = hyphenate(key);
  1545. {
  1546. const keyInLowerCase = key.toLowerCase();
  1547. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1548. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1549. `${formatComponentName(
  1550. // @ts-expect-error tag is string
  1551. tag || Ctor)}, but the declared prop name is` +
  1552. ` "${key}". ` +
  1553. `Note that HTML attributes are case-insensitive and camelCased ` +
  1554. `props need to use their kebab-case equivalents when using in-DOM ` +
  1555. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1556. }
  1557. }
  1558. checkProp(res, props, key, altKey, true) ||
  1559. checkProp(res, attrs, key, altKey, false);
  1560. }
  1561. }
  1562. return res;
  1563. }
  1564. function checkProp(res, hash, key, altKey, preserve) {
  1565. if (isDef(hash)) {
  1566. if (hasOwn(hash, key)) {
  1567. res[key] = hash[key];
  1568. if (!preserve) {
  1569. delete hash[key];
  1570. }
  1571. return true;
  1572. }
  1573. else if (hasOwn(hash, altKey)) {
  1574. res[key] = hash[altKey];
  1575. if (!preserve) {
  1576. delete hash[altKey];
  1577. }
  1578. return true;
  1579. }
  1580. }
  1581. return false;
  1582. }
  1583. // The template compiler attempts to minimize the need for normalization by
  1584. // statically analyzing the template at compile time.
  1585. //
  1586. // For plain HTML markup, normalization can be completely skipped because the
  1587. // generated render function is guaranteed to return Array<VNode>. There are
  1588. // two cases where extra normalization is needed:
  1589. // 1. When the children contains components - because a functional component
  1590. // may return an Array instead of a single root. In this case, just a simple
  1591. // normalization is needed - if any child is an Array, we flatten the whole
  1592. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1593. // because functional components already normalize their own children.
  1594. function simpleNormalizeChildren(children) {
  1595. for (let i = 0; i < children.length; i++) {
  1596. if (isArray(children[i])) {
  1597. return Array.prototype.concat.apply([], children);
  1598. }
  1599. }
  1600. return children;
  1601. }
  1602. // 2. When the children contains constructs that always generated nested Arrays,
  1603. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1604. // with hand-written render functions / JSX. In such cases a full normalization
  1605. // is needed to cater to all possible types of children values.
  1606. function normalizeChildren(children) {
  1607. return isPrimitive(children)
  1608. ? [createTextVNode(children)]
  1609. : isArray(children)
  1610. ? normalizeArrayChildren(children)
  1611. : undefined;
  1612. }
  1613. function isTextNode(node) {
  1614. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1615. }
  1616. function normalizeArrayChildren(children, nestedIndex) {
  1617. const res = [];
  1618. let i, c, lastIndex, last;
  1619. for (i = 0; i < children.length; i++) {
  1620. c = children[i];
  1621. if (isUndef(c) || typeof c === 'boolean')
  1622. continue;
  1623. lastIndex = res.length - 1;
  1624. last = res[lastIndex];
  1625. // nested
  1626. if (isArray(c)) {
  1627. if (c.length > 0) {
  1628. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1629. // merge adjacent text nodes
  1630. if (isTextNode(c[0]) && isTextNode(last)) {
  1631. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1632. c.shift();
  1633. }
  1634. res.push.apply(res, c);
  1635. }
  1636. }
  1637. else if (isPrimitive(c)) {
  1638. if (isTextNode(last)) {
  1639. // merge adjacent text nodes
  1640. // this is necessary for SSR hydration because text nodes are
  1641. // essentially merged when rendered to HTML strings
  1642. res[lastIndex] = createTextVNode(last.text + c);
  1643. }
  1644. else if (c !== '') {
  1645. // convert primitive to vnode
  1646. res.push(createTextVNode(c));
  1647. }
  1648. }
  1649. else {
  1650. if (isTextNode(c) && isTextNode(last)) {
  1651. // merge adjacent text nodes
  1652. res[lastIndex] = createTextVNode(last.text + c.text);
  1653. }
  1654. else {
  1655. // default key for nested array children (likely generated by v-for)
  1656. if (isTrue(children._isVList) &&
  1657. isDef(c.tag) &&
  1658. isUndef(c.key) &&
  1659. isDef(nestedIndex)) {
  1660. c.key = `__vlist${nestedIndex}_${i}__`;
  1661. }
  1662. res.push(c);
  1663. }
  1664. }
  1665. }
  1666. return res;
  1667. }
  1668. const SIMPLE_NORMALIZE = 1;
  1669. const ALWAYS_NORMALIZE = 2;
  1670. // wrapper function for providing a more flexible interface
  1671. // without getting yelled at by flow
  1672. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1673. if (isArray(data) || isPrimitive(data)) {
  1674. normalizationType = children;
  1675. children = data;
  1676. data = undefined;
  1677. }
  1678. if (isTrue(alwaysNormalize)) {
  1679. normalizationType = ALWAYS_NORMALIZE;
  1680. }
  1681. return _createElement(context, tag, data, children, normalizationType);
  1682. }
  1683. function _createElement(context, tag, data, children, normalizationType) {
  1684. if (isDef(data) && isDef(data.__ob__)) {
  1685. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1686. return createEmptyVNode();
  1687. }
  1688. // object syntax in v-bind
  1689. if (isDef(data) && isDef(data.is)) {
  1690. tag = data.is;
  1691. }
  1692. if (!tag) {
  1693. // in case of component :is set to falsy value
  1694. return createEmptyVNode();
  1695. }
  1696. // warn against non-primitive key
  1697. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1698. warn$2('Avoid using non-primitive value as key, ' +
  1699. 'use string/number value instead.', context);
  1700. }
  1701. // support single function children as default scoped slot
  1702. if (isArray(children) && isFunction(children[0])) {
  1703. data = data || {};
  1704. data.scopedSlots = { default: children[0] };
  1705. children.length = 0;
  1706. }
  1707. if (normalizationType === ALWAYS_NORMALIZE) {
  1708. children = normalizeChildren(children);
  1709. }
  1710. else if (normalizationType === SIMPLE_NORMALIZE) {
  1711. children = simpleNormalizeChildren(children);
  1712. }
  1713. let vnode, ns;
  1714. if (typeof tag === 'string') {
  1715. let Ctor;
  1716. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1717. if (config.isReservedTag(tag)) {
  1718. // platform built-in elements
  1719. if (isDef(data) &&
  1720. isDef(data.nativeOn) &&
  1721. data.tag !== 'component') {
  1722. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1723. }
  1724. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1725. }
  1726. else if ((!data || !data.pre) &&
  1727. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1728. // component
  1729. vnode = createComponent(Ctor, data, context, children, tag);
  1730. }
  1731. else {
  1732. // unknown or unlisted namespaced elements
  1733. // check at runtime because it may get assigned a namespace when its
  1734. // parent normalizes children
  1735. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1736. }
  1737. }
  1738. else {
  1739. // direct component options / constructor
  1740. vnode = createComponent(tag, data, context, children);
  1741. }
  1742. if (isArray(vnode)) {
  1743. return vnode;
  1744. }
  1745. else if (isDef(vnode)) {
  1746. if (isDef(ns))
  1747. applyNS(vnode, ns);
  1748. if (isDef(data))
  1749. registerDeepBindings(data);
  1750. return vnode;
  1751. }
  1752. else {
  1753. return createEmptyVNode();
  1754. }
  1755. }
  1756. function applyNS(vnode, ns, force) {
  1757. vnode.ns = ns;
  1758. if (vnode.tag === 'foreignObject') {
  1759. // use default namespace inside foreignObject
  1760. ns = undefined;
  1761. force = true;
  1762. }
  1763. if (isDef(vnode.children)) {
  1764. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1765. const child = vnode.children[i];
  1766. if (isDef(child.tag) &&
  1767. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1768. applyNS(child, ns, force);
  1769. }
  1770. }
  1771. }
  1772. }
  1773. // ref #5318
  1774. // necessary to ensure parent re-render when deep bindings like :style and
  1775. // :class are used on slot nodes
  1776. function registerDeepBindings(data) {
  1777. if (isObject(data.style)) {
  1778. traverse(data.style);
  1779. }
  1780. if (isObject(data.class)) {
  1781. traverse(data.class);
  1782. }
  1783. }
  1784. /**
  1785. * Runtime helper for rendering v-for lists.
  1786. */
  1787. function renderList(val, render) {
  1788. let ret = null, i, l, keys, key;
  1789. if (isArray(val) || typeof val === 'string') {
  1790. ret = new Array(val.length);
  1791. for (i = 0, l = val.length; i < l; i++) {
  1792. ret[i] = render(val[i], i);
  1793. }
  1794. }
  1795. else if (typeof val === 'number') {
  1796. ret = new Array(val);
  1797. for (i = 0; i < val; i++) {
  1798. ret[i] = render(i + 1, i);
  1799. }
  1800. }
  1801. else if (isObject(val)) {
  1802. if (hasSymbol && val[Symbol.iterator]) {
  1803. ret = [];
  1804. const iterator = val[Symbol.iterator]();
  1805. let result = iterator.next();
  1806. while (!result.done) {
  1807. ret.push(render(result.value, ret.length));
  1808. result = iterator.next();
  1809. }
  1810. }
  1811. else {
  1812. keys = Object.keys(val);
  1813. ret = new Array(keys.length);
  1814. for (i = 0, l = keys.length; i < l; i++) {
  1815. key = keys[i];
  1816. ret[i] = render(val[key], key, i);
  1817. }
  1818. }
  1819. }
  1820. if (!isDef(ret)) {
  1821. ret = [];
  1822. }
  1823. ret._isVList = true;
  1824. return ret;
  1825. }
  1826. /**
  1827. * Runtime helper for rendering <slot>
  1828. */
  1829. function renderSlot(name, fallbackRender, props, bindObject) {
  1830. const scopedSlotFn = this.$scopedSlots[name];
  1831. let nodes;
  1832. if (scopedSlotFn) {
  1833. // scoped slot
  1834. props = props || {};
  1835. if (bindObject) {
  1836. if (!isObject(bindObject)) {
  1837. warn$2('slot v-bind without argument expects an Object', this);
  1838. }
  1839. props = extend(extend({}, bindObject), props);
  1840. }
  1841. nodes =
  1842. scopedSlotFn(props) ||
  1843. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1844. }
  1845. else {
  1846. nodes =
  1847. this.$slots[name] ||
  1848. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1849. }
  1850. const target = props && props.slot;
  1851. if (target) {
  1852. return this.$createElement('template', { slot: target }, nodes);
  1853. }
  1854. else {
  1855. return nodes;
  1856. }
  1857. }
  1858. /**
  1859. * Runtime helper for resolving filters
  1860. */
  1861. function resolveFilter(id) {
  1862. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1863. }
  1864. function isKeyNotMatch(expect, actual) {
  1865. if (isArray(expect)) {
  1866. return expect.indexOf(actual) === -1;
  1867. }
  1868. else {
  1869. return expect !== actual;
  1870. }
  1871. }
  1872. /**
  1873. * Runtime helper for checking keyCodes from config.
  1874. * exposed as Vue.prototype._k
  1875. * passing in eventKeyName as last argument separately for backwards compat
  1876. */
  1877. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1878. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1879. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1880. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1881. }
  1882. else if (mappedKeyCode) {
  1883. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1884. }
  1885. else if (eventKeyName) {
  1886. return hyphenate(eventKeyName) !== key;
  1887. }
  1888. return eventKeyCode === undefined;
  1889. }
  1890. /**
  1891. * Runtime helper for merging v-bind="object" into a VNode's data.
  1892. */
  1893. function bindObjectProps(data, tag, value, asProp, isSync) {
  1894. if (value) {
  1895. if (!isObject(value)) {
  1896. warn$2('v-bind without argument expects an Object or Array value', this);
  1897. }
  1898. else {
  1899. if (isArray(value)) {
  1900. value = toObject(value);
  1901. }
  1902. let hash;
  1903. for (const key in value) {
  1904. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1905. hash = data;
  1906. }
  1907. else {
  1908. const type = data.attrs && data.attrs.type;
  1909. hash =
  1910. asProp || config.mustUseProp(tag, type, key)
  1911. ? data.domProps || (data.domProps = {})
  1912. : data.attrs || (data.attrs = {});
  1913. }
  1914. const camelizedKey = camelize(key);
  1915. const hyphenatedKey = hyphenate(key);
  1916. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1917. hash[key] = value[key];
  1918. if (isSync) {
  1919. const on = data.on || (data.on = {});
  1920. on[`update:${key}`] = function ($event) {
  1921. value[key] = $event;
  1922. };
  1923. }
  1924. }
  1925. }
  1926. }
  1927. }
  1928. return data;
  1929. }
  1930. /**
  1931. * Runtime helper for rendering static trees.
  1932. */
  1933. function renderStatic(index, isInFor) {
  1934. const cached = this._staticTrees || (this._staticTrees = []);
  1935. let tree = cached[index];
  1936. // if has already-rendered static tree and not inside v-for,
  1937. // we can reuse the same tree.
  1938. if (tree && !isInFor) {
  1939. return tree;
  1940. }
  1941. // otherwise, render a fresh tree.
  1942. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1943. );
  1944. markStatic$1(tree, `__static__${index}`, false);
  1945. return tree;
  1946. }
  1947. /**
  1948. * Runtime helper for v-once.
  1949. * Effectively it means marking the node as static with a unique key.
  1950. */
  1951. function markOnce(tree, index, key) {
  1952. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1953. return tree;
  1954. }
  1955. function markStatic$1(tree, key, isOnce) {
  1956. if (isArray(tree)) {
  1957. for (let i = 0; i < tree.length; i++) {
  1958. if (tree[i] && typeof tree[i] !== 'string') {
  1959. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1960. }
  1961. }
  1962. }
  1963. else {
  1964. markStaticNode(tree, key, isOnce);
  1965. }
  1966. }
  1967. function markStaticNode(node, key, isOnce) {
  1968. node.isStatic = true;
  1969. node.key = key;
  1970. node.isOnce = isOnce;
  1971. }
  1972. function bindObjectListeners(data, value) {
  1973. if (value) {
  1974. if (!isPlainObject(value)) {
  1975. warn$2('v-on without argument expects an Object value', this);
  1976. }
  1977. else {
  1978. const on = (data.on = data.on ? extend({}, data.on) : {});
  1979. for (const key in value) {
  1980. const existing = on[key];
  1981. const ours = value[key];
  1982. on[key] = existing ? [].concat(existing, ours) : ours;
  1983. }
  1984. }
  1985. }
  1986. return data;
  1987. }
  1988. function resolveScopedSlots(fns, res,
  1989. // the following are added in 2.6
  1990. hasDynamicKeys, contentHashKey) {
  1991. res = res || { $stable: !hasDynamicKeys };
  1992. for (let i = 0; i < fns.length; i++) {
  1993. const slot = fns[i];
  1994. if (isArray(slot)) {
  1995. resolveScopedSlots(slot, res, hasDynamicKeys);
  1996. }
  1997. else if (slot) {
  1998. // marker for reverse proxying v-slot without scope on this.$slots
  1999. // @ts-expect-error
  2000. if (slot.proxy) {
  2001. // @ts-expect-error
  2002. slot.fn.proxy = true;
  2003. }
  2004. res[slot.key] = slot.fn;
  2005. }
  2006. }
  2007. if (contentHashKey) {
  2008. res.$key = contentHashKey;
  2009. }
  2010. return res;
  2011. }
  2012. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2013. function bindDynamicKeys(baseObj, values) {
  2014. for (let i = 0; i < values.length; i += 2) {
  2015. const key = values[i];
  2016. if (typeof key === 'string' && key) {
  2017. baseObj[values[i]] = values[i + 1];
  2018. }
  2019. else if (key !== '' && key !== null) {
  2020. // null is a special value for explicitly removing a binding
  2021. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2022. }
  2023. }
  2024. return baseObj;
  2025. }
  2026. // helper to dynamically append modifier runtime markers to event names.
  2027. // ensure only append when value is already string, otherwise it will be cast
  2028. // to string and cause the type check to miss.
  2029. function prependModifier(value, symbol) {
  2030. return typeof value === 'string' ? symbol + value : value;
  2031. }
  2032. function installRenderHelpers(target) {
  2033. target._o = markOnce;
  2034. target._n = toNumber;
  2035. target._s = toString;
  2036. target._l = renderList;
  2037. target._t = renderSlot;
  2038. target._q = looseEqual;
  2039. target._i = looseIndexOf;
  2040. target._m = renderStatic;
  2041. target._f = resolveFilter;
  2042. target._k = checkKeyCodes;
  2043. target._b = bindObjectProps;
  2044. target._v = createTextVNode;
  2045. target._e = createEmptyVNode;
  2046. target._u = resolveScopedSlots;
  2047. target._g = bindObjectListeners;
  2048. target._d = bindDynamicKeys;
  2049. target._p = prependModifier;
  2050. }
  2051. /**
  2052. * Runtime helper for resolving raw children VNodes into a slot object.
  2053. */
  2054. function resolveSlots(children, context) {
  2055. if (!children || !children.length) {
  2056. return {};
  2057. }
  2058. const slots = {};
  2059. for (let i = 0, l = children.length; i < l; i++) {
  2060. const child = children[i];
  2061. const data = child.data;
  2062. // remove slot attribute if the node is resolved as a Vue slot node
  2063. if (data && data.attrs && data.attrs.slot) {
  2064. delete data.attrs.slot;
  2065. }
  2066. // named slots should only be respected if the vnode was rendered in the
  2067. // same context.
  2068. if ((child.context === context || child.fnContext === context) &&
  2069. data &&
  2070. data.slot != null) {
  2071. const name = data.slot;
  2072. const slot = slots[name] || (slots[name] = []);
  2073. if (child.tag === 'template') {
  2074. slot.push.apply(slot, child.children || []);
  2075. }
  2076. else {
  2077. slot.push(child);
  2078. }
  2079. }
  2080. else {
  2081. (slots.default || (slots.default = [])).push(child);
  2082. }
  2083. }
  2084. // ignore slots that contains only whitespace
  2085. for (const name in slots) {
  2086. if (slots[name].every(isWhitespace)) {
  2087. delete slots[name];
  2088. }
  2089. }
  2090. return slots;
  2091. }
  2092. function isWhitespace(node) {
  2093. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2094. }
  2095. function isAsyncPlaceholder(node) {
  2096. // @ts-expect-error not really boolean type
  2097. return node.isComment && node.asyncFactory;
  2098. }
  2099. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2100. let res;
  2101. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2102. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2103. const key = scopedSlots && scopedSlots.$key;
  2104. if (!scopedSlots) {
  2105. res = {};
  2106. }
  2107. else if (scopedSlots._normalized) {
  2108. // fast path 1: child component re-render only, parent did not change
  2109. return scopedSlots._normalized;
  2110. }
  2111. else if (isStable &&
  2112. prevScopedSlots &&
  2113. prevScopedSlots !== emptyObject &&
  2114. key === prevScopedSlots.$key &&
  2115. !hasNormalSlots &&
  2116. !prevScopedSlots.$hasNormal) {
  2117. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2118. // only need to normalize once
  2119. return prevScopedSlots;
  2120. }
  2121. else {
  2122. res = {};
  2123. for (const key in scopedSlots) {
  2124. if (scopedSlots[key] && key[0] !== '$') {
  2125. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2126. }
  2127. }
  2128. }
  2129. // expose normal slots on scopedSlots
  2130. for (const key in normalSlots) {
  2131. if (!(key in res)) {
  2132. res[key] = proxyNormalSlot(normalSlots, key);
  2133. }
  2134. }
  2135. // avoriaz seems to mock a non-extensible $scopedSlots object
  2136. // and when that is passed down this would cause an error
  2137. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2138. scopedSlots._normalized = res;
  2139. }
  2140. def(res, '$stable', isStable);
  2141. def(res, '$key', key);
  2142. def(res, '$hasNormal', hasNormalSlots);
  2143. return res;
  2144. }
  2145. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2146. const normalized = function () {
  2147. const cur = currentInstance;
  2148. setCurrentInstance(vm);
  2149. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2150. res =
  2151. res && typeof res === 'object' && !isArray(res)
  2152. ? [res] // single vnode
  2153. : normalizeChildren(res);
  2154. const vnode = res && res[0];
  2155. setCurrentInstance(cur);
  2156. return res &&
  2157. (!vnode ||
  2158. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2159. ? undefined
  2160. : res;
  2161. };
  2162. // this is a slot using the new v-slot syntax without scope. although it is
  2163. // compiled as a scoped slot, render fn users would expect it to be present
  2164. // on this.$slots because the usage is semantically a normal slot.
  2165. if (fn.proxy) {
  2166. Object.defineProperty(normalSlots, key, {
  2167. get: normalized,
  2168. enumerable: true,
  2169. configurable: true
  2170. });
  2171. }
  2172. return normalized;
  2173. }
  2174. function proxyNormalSlot(slots, key) {
  2175. return () => slots[key];
  2176. }
  2177. function initSetup(vm) {
  2178. const options = vm.$options;
  2179. const setup = options.setup;
  2180. if (setup) {
  2181. const ctx = (vm._setupContext = createSetupContext(vm));
  2182. setCurrentInstance(vm);
  2183. pushTarget();
  2184. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2185. popTarget();
  2186. setCurrentInstance();
  2187. if (isFunction(setupResult)) {
  2188. // render function
  2189. // @ts-ignore
  2190. options.render = setupResult;
  2191. }
  2192. else if (isObject(setupResult)) {
  2193. // bindings
  2194. if (setupResult instanceof VNode) {
  2195. warn$2(`setup() should not return VNodes directly - ` +
  2196. `return a render function instead.`);
  2197. }
  2198. vm._setupState = setupResult;
  2199. // __sfc indicates compiled bindings from <script setup>
  2200. if (!setupResult.__sfc) {
  2201. for (const key in setupResult) {
  2202. if (!isReserved(key)) {
  2203. proxyWithRefUnwrap(vm, setupResult, key);
  2204. }
  2205. else {
  2206. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2207. }
  2208. }
  2209. }
  2210. else {
  2211. // exposed for compiled render fn
  2212. const proxy = (vm._setupProxy = {});
  2213. for (const key in setupResult) {
  2214. if (key !== '__sfc') {
  2215. proxyWithRefUnwrap(proxy, setupResult, key);
  2216. }
  2217. }
  2218. }
  2219. }
  2220. else if (setupResult !== undefined) {
  2221. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2222. }
  2223. }
  2224. }
  2225. function createSetupContext(vm) {
  2226. let exposeCalled = false;
  2227. return {
  2228. get attrs() {
  2229. if (!vm._attrsProxy) {
  2230. const proxy = (vm._attrsProxy = {});
  2231. def(proxy, '_v_attr_proxy', true);
  2232. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2233. }
  2234. return vm._attrsProxy;
  2235. },
  2236. get listeners() {
  2237. if (!vm._listenersProxy) {
  2238. const proxy = (vm._listenersProxy = {});
  2239. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2240. }
  2241. return vm._listenersProxy;
  2242. },
  2243. get slots() {
  2244. return initSlotsProxy(vm);
  2245. },
  2246. emit: bind$1(vm.$emit, vm),
  2247. expose(exposed) {
  2248. {
  2249. if (exposeCalled) {
  2250. warn$2(`expose() should be called only once per setup().`, vm);
  2251. }
  2252. exposeCalled = true;
  2253. }
  2254. if (exposed) {
  2255. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2256. }
  2257. }
  2258. };
  2259. }
  2260. function syncSetupProxy(to, from, prev, instance, type) {
  2261. let changed = false;
  2262. for (const key in from) {
  2263. if (!(key in to)) {
  2264. changed = true;
  2265. defineProxyAttr(to, key, instance, type);
  2266. }
  2267. else if (from[key] !== prev[key]) {
  2268. changed = true;
  2269. }
  2270. }
  2271. for (const key in to) {
  2272. if (!(key in from)) {
  2273. changed = true;
  2274. delete to[key];
  2275. }
  2276. }
  2277. return changed;
  2278. }
  2279. function defineProxyAttr(proxy, key, instance, type) {
  2280. Object.defineProperty(proxy, key, {
  2281. enumerable: true,
  2282. configurable: true,
  2283. get() {
  2284. return instance[type][key];
  2285. }
  2286. });
  2287. }
  2288. function initSlotsProxy(vm) {
  2289. if (!vm._slotsProxy) {
  2290. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2291. }
  2292. return vm._slotsProxy;
  2293. }
  2294. function syncSetupSlots(to, from) {
  2295. for (const key in from) {
  2296. to[key] = from[key];
  2297. }
  2298. for (const key in to) {
  2299. if (!(key in from)) {
  2300. delete to[key];
  2301. }
  2302. }
  2303. }
  2304. /**
  2305. * @internal use manual type def because public setup context type relies on
  2306. * legacy VNode types
  2307. */
  2308. function useSlots() {
  2309. return getContext().slots;
  2310. }
  2311. /**
  2312. * @internal use manual type def because public setup context type relies on
  2313. * legacy VNode types
  2314. */
  2315. function useAttrs() {
  2316. return getContext().attrs;
  2317. }
  2318. /**
  2319. * Vue 2 only
  2320. * @internal use manual type def because public setup context type relies on
  2321. * legacy VNode types
  2322. */
  2323. function useListeners() {
  2324. return getContext().listeners;
  2325. }
  2326. function getContext() {
  2327. if (!currentInstance) {
  2328. warn$2(`useContext() called without active instance.`);
  2329. }
  2330. const vm = currentInstance;
  2331. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2332. }
  2333. /**
  2334. * Runtime helper for merging default declarations. Imported by compiled code
  2335. * only.
  2336. * @internal
  2337. */
  2338. function mergeDefaults(raw, defaults) {
  2339. const props = isArray(raw)
  2340. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2341. : raw;
  2342. for (const key in defaults) {
  2343. const opt = props[key];
  2344. if (opt) {
  2345. if (isArray(opt) || isFunction(opt)) {
  2346. props[key] = { type: opt, default: defaults[key] };
  2347. }
  2348. else {
  2349. opt.default = defaults[key];
  2350. }
  2351. }
  2352. else if (opt === null) {
  2353. props[key] = { default: defaults[key] };
  2354. }
  2355. else {
  2356. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2357. }
  2358. }
  2359. return props;
  2360. }
  2361. function initRender(vm) {
  2362. vm._vnode = null; // the root of the child tree
  2363. vm._staticTrees = null; // v-once cached trees
  2364. const options = vm.$options;
  2365. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2366. const renderContext = parentVnode && parentVnode.context;
  2367. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2368. vm.$scopedSlots = parentVnode
  2369. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2370. : emptyObject;
  2371. // bind the createElement fn to this instance
  2372. // so that we get proper render context inside it.
  2373. // args order: tag, data, children, normalizationType, alwaysNormalize
  2374. // internal version is used by render functions compiled from templates
  2375. // @ts-expect-error
  2376. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2377. // normalization is always applied for the public version, used in
  2378. // user-written render functions.
  2379. // @ts-expect-error
  2380. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2381. // $attrs & $listeners are exposed for easier HOC creation.
  2382. // they need to be reactive so that HOCs using them are always updated
  2383. const parentData = parentVnode && parentVnode.data;
  2384. /* istanbul ignore else */
  2385. {
  2386. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2387. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2388. }, true);
  2389. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2390. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2391. }, true);
  2392. }
  2393. }
  2394. let currentRenderingInstance = null;
  2395. function renderMixin(Vue) {
  2396. // install runtime convenience helpers
  2397. installRenderHelpers(Vue.prototype);
  2398. Vue.prototype.$nextTick = function (fn) {
  2399. return nextTick(fn, this);
  2400. };
  2401. Vue.prototype._render = function () {
  2402. const vm = this;
  2403. const { render, _parentVnode } = vm.$options;
  2404. if (_parentVnode && vm._isMounted) {
  2405. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2406. if (vm._slotsProxy) {
  2407. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2408. }
  2409. }
  2410. // set parent vnode. this allows render functions to have access
  2411. // to the data on the placeholder node.
  2412. vm.$vnode = _parentVnode;
  2413. // render self
  2414. let vnode;
  2415. try {
  2416. // There's no need to maintain a stack because all render fns are called
  2417. // separately from one another. Nested component's render fns are called
  2418. // when parent component is patched.
  2419. setCurrentInstance(vm);
  2420. currentRenderingInstance = vm;
  2421. vnode = render.call(vm._renderProxy, vm.$createElement);
  2422. }
  2423. catch (e) {
  2424. handleError(e, vm, `render`);
  2425. // return error render result,
  2426. // or previous vnode to prevent render error causing blank component
  2427. /* istanbul ignore else */
  2428. if (vm.$options.renderError) {
  2429. try {
  2430. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2431. }
  2432. catch (e) {
  2433. handleError(e, vm, `renderError`);
  2434. vnode = vm._vnode;
  2435. }
  2436. }
  2437. else {
  2438. vnode = vm._vnode;
  2439. }
  2440. }
  2441. finally {
  2442. currentRenderingInstance = null;
  2443. setCurrentInstance();
  2444. }
  2445. // if the returned array contains only a single node, allow it
  2446. if (isArray(vnode) && vnode.length === 1) {
  2447. vnode = vnode[0];
  2448. }
  2449. // return empty vnode in case the render function errored out
  2450. if (!(vnode instanceof VNode)) {
  2451. if (isArray(vnode)) {
  2452. warn$2('Multiple root nodes returned from render function. Render function ' +
  2453. 'should return a single root node.', vm);
  2454. }
  2455. vnode = createEmptyVNode();
  2456. }
  2457. // set parent
  2458. vnode.parent = _parentVnode;
  2459. return vnode;
  2460. };
  2461. }
  2462. function ensureCtor(comp, base) {
  2463. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2464. comp = comp.default;
  2465. }
  2466. return isObject(comp) ? base.extend(comp) : comp;
  2467. }
  2468. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2469. const node = createEmptyVNode();
  2470. node.asyncFactory = factory;
  2471. node.asyncMeta = { data, context, children, tag };
  2472. return node;
  2473. }
  2474. function resolveAsyncComponent(factory, baseCtor) {
  2475. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2476. return factory.errorComp;
  2477. }
  2478. if (isDef(factory.resolved)) {
  2479. return factory.resolved;
  2480. }
  2481. const owner = currentRenderingInstance;
  2482. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2483. // already pending
  2484. factory.owners.push(owner);
  2485. }
  2486. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2487. return factory.loadingComp;
  2488. }
  2489. if (owner && !isDef(factory.owners)) {
  2490. const owners = (factory.owners = [owner]);
  2491. let sync = true;
  2492. let timerLoading = null;
  2493. let timerTimeout = null;
  2494. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2495. const forceRender = (renderCompleted) => {
  2496. for (let i = 0, l = owners.length; i < l; i++) {
  2497. owners[i].$forceUpdate();
  2498. }
  2499. if (renderCompleted) {
  2500. owners.length = 0;
  2501. if (timerLoading !== null) {
  2502. clearTimeout(timerLoading);
  2503. timerLoading = null;
  2504. }
  2505. if (timerTimeout !== null) {
  2506. clearTimeout(timerTimeout);
  2507. timerTimeout = null;
  2508. }
  2509. }
  2510. };
  2511. const resolve = once((res) => {
  2512. // cache resolved
  2513. factory.resolved = ensureCtor(res, baseCtor);
  2514. // invoke callbacks only if this is not a synchronous resolve
  2515. // (async resolves are shimmed as synchronous during SSR)
  2516. if (!sync) {
  2517. forceRender(true);
  2518. }
  2519. else {
  2520. owners.length = 0;
  2521. }
  2522. });
  2523. const reject = once(reason => {
  2524. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2525. (reason ? `\nReason: ${reason}` : ''));
  2526. if (isDef(factory.errorComp)) {
  2527. factory.error = true;
  2528. forceRender(true);
  2529. }
  2530. });
  2531. const res = factory(resolve, reject);
  2532. if (isObject(res)) {
  2533. if (isPromise(res)) {
  2534. // () => Promise
  2535. if (isUndef(factory.resolved)) {
  2536. res.then(resolve, reject);
  2537. }
  2538. }
  2539. else if (isPromise(res.component)) {
  2540. res.component.then(resolve, reject);
  2541. if (isDef(res.error)) {
  2542. factory.errorComp = ensureCtor(res.error, baseCtor);
  2543. }
  2544. if (isDef(res.loading)) {
  2545. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2546. if (res.delay === 0) {
  2547. factory.loading = true;
  2548. }
  2549. else {
  2550. // @ts-expect-error NodeJS timeout type
  2551. timerLoading = setTimeout(() => {
  2552. timerLoading = null;
  2553. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2554. factory.loading = true;
  2555. forceRender(false);
  2556. }
  2557. }, res.delay || 200);
  2558. }
  2559. }
  2560. if (isDef(res.timeout)) {
  2561. // @ts-expect-error NodeJS timeout type
  2562. timerTimeout = setTimeout(() => {
  2563. timerTimeout = null;
  2564. if (isUndef(factory.resolved)) {
  2565. reject(`timeout (${res.timeout}ms)` );
  2566. }
  2567. }, res.timeout);
  2568. }
  2569. }
  2570. }
  2571. sync = false;
  2572. // return in case resolved synchronously
  2573. return factory.loading ? factory.loadingComp : factory.resolved;
  2574. }
  2575. }
  2576. function getFirstComponentChild(children) {
  2577. if (isArray(children)) {
  2578. for (let i = 0; i < children.length; i++) {
  2579. const c = children[i];
  2580. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2581. return c;
  2582. }
  2583. }
  2584. }
  2585. }
  2586. function initEvents(vm) {
  2587. vm._events = Object.create(null);
  2588. vm._hasHookEvent = false;
  2589. // init parent attached events
  2590. const listeners = vm.$options._parentListeners;
  2591. if (listeners) {
  2592. updateComponentListeners(vm, listeners);
  2593. }
  2594. }
  2595. let target$1;
  2596. function add$1(event, fn) {
  2597. target$1.$on(event, fn);
  2598. }
  2599. function remove$1(event, fn) {
  2600. target$1.$off(event, fn);
  2601. }
  2602. function createOnceHandler$1(event, fn) {
  2603. const _target = target$1;
  2604. return function onceHandler() {
  2605. const res = fn.apply(null, arguments);
  2606. if (res !== null) {
  2607. _target.$off(event, onceHandler);
  2608. }
  2609. };
  2610. }
  2611. function updateComponentListeners(vm, listeners, oldListeners) {
  2612. target$1 = vm;
  2613. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2614. target$1 = undefined;
  2615. }
  2616. function eventsMixin(Vue) {
  2617. const hookRE = /^hook:/;
  2618. Vue.prototype.$on = function (event, fn) {
  2619. const vm = this;
  2620. if (isArray(event)) {
  2621. for (let i = 0, l = event.length; i < l; i++) {
  2622. vm.$on(event[i], fn);
  2623. }
  2624. }
  2625. else {
  2626. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2627. // optimize hook:event cost by using a boolean flag marked at registration
  2628. // instead of a hash lookup
  2629. if (hookRE.test(event)) {
  2630. vm._hasHookEvent = true;
  2631. }
  2632. }
  2633. return vm;
  2634. };
  2635. Vue.prototype.$once = function (event, fn) {
  2636. const vm = this;
  2637. function on() {
  2638. vm.$off(event, on);
  2639. fn.apply(vm, arguments);
  2640. }
  2641. on.fn = fn;
  2642. vm.$on(event, on);
  2643. return vm;
  2644. };
  2645. Vue.prototype.$off = function (event, fn) {
  2646. const vm = this;
  2647. // all
  2648. if (!arguments.length) {
  2649. vm._events = Object.create(null);
  2650. return vm;
  2651. }
  2652. // array of events
  2653. if (isArray(event)) {
  2654. for (let i = 0, l = event.length; i < l; i++) {
  2655. vm.$off(event[i], fn);
  2656. }
  2657. return vm;
  2658. }
  2659. // specific event
  2660. const cbs = vm._events[event];
  2661. if (!cbs) {
  2662. return vm;
  2663. }
  2664. if (!fn) {
  2665. vm._events[event] = null;
  2666. return vm;
  2667. }
  2668. // specific handler
  2669. let cb;
  2670. let i = cbs.length;
  2671. while (i--) {
  2672. cb = cbs[i];
  2673. if (cb === fn || cb.fn === fn) {
  2674. cbs.splice(i, 1);
  2675. break;
  2676. }
  2677. }
  2678. return vm;
  2679. };
  2680. Vue.prototype.$emit = function (event) {
  2681. const vm = this;
  2682. {
  2683. const lowerCaseEvent = event.toLowerCase();
  2684. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2685. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2686. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2687. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2688. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2689. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2690. }
  2691. }
  2692. let cbs = vm._events[event];
  2693. if (cbs) {
  2694. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2695. const args = toArray(arguments, 1);
  2696. const info = `event handler for "${event}"`;
  2697. for (let i = 0, l = cbs.length; i < l; i++) {
  2698. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2699. }
  2700. }
  2701. return vm;
  2702. };
  2703. }
  2704. let activeInstance = null;
  2705. let isUpdatingChildComponent = false;
  2706. function setActiveInstance(vm) {
  2707. const prevActiveInstance = activeInstance;
  2708. activeInstance = vm;
  2709. return () => {
  2710. activeInstance = prevActiveInstance;
  2711. };
  2712. }
  2713. function initLifecycle(vm) {
  2714. const options = vm.$options;
  2715. // locate first non-abstract parent
  2716. let parent = options.parent;
  2717. if (parent && !options.abstract) {
  2718. while (parent.$options.abstract && parent.$parent) {
  2719. parent = parent.$parent;
  2720. }
  2721. parent.$children.push(vm);
  2722. }
  2723. vm.$parent = parent;
  2724. vm.$root = parent ? parent.$root : vm;
  2725. vm.$children = [];
  2726. vm.$refs = {};
  2727. vm._provided = parent ? parent._provided : Object.create(null);
  2728. vm._watcher = null;
  2729. vm._inactive = null;
  2730. vm._directInactive = false;
  2731. vm._isMounted = false;
  2732. vm._isDestroyed = false;
  2733. vm._isBeingDestroyed = false;
  2734. }
  2735. function lifecycleMixin(Vue) {
  2736. Vue.prototype._update = function (vnode, hydrating) {
  2737. const vm = this;
  2738. const prevEl = vm.$el;
  2739. const prevVnode = vm._vnode;
  2740. const restoreActiveInstance = setActiveInstance(vm);
  2741. vm._vnode = vnode;
  2742. // Vue.prototype.__patch__ is injected in entry points
  2743. // based on the rendering backend used.
  2744. if (!prevVnode) {
  2745. // initial render
  2746. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2747. }
  2748. else {
  2749. // updates
  2750. vm.$el = vm.__patch__(prevVnode, vnode);
  2751. }
  2752. restoreActiveInstance();
  2753. // update __vue__ reference
  2754. if (prevEl) {
  2755. prevEl.__vue__ = null;
  2756. }
  2757. if (vm.$el) {
  2758. vm.$el.__vue__ = vm;
  2759. }
  2760. // if parent is an HOC, update its $el as well
  2761. let wrapper = vm;
  2762. while (wrapper &&
  2763. wrapper.$vnode &&
  2764. wrapper.$parent &&
  2765. wrapper.$vnode === wrapper.$parent._vnode) {
  2766. wrapper.$parent.$el = wrapper.$el;
  2767. wrapper = wrapper.$parent;
  2768. }
  2769. // updated hook is called by the scheduler to ensure that children are
  2770. // updated in a parent's updated hook.
  2771. };
  2772. Vue.prototype.$forceUpdate = function () {
  2773. const vm = this;
  2774. if (vm._watcher) {
  2775. vm._watcher.update();
  2776. }
  2777. };
  2778. Vue.prototype.$destroy = function () {
  2779. const vm = this;
  2780. if (vm._isBeingDestroyed) {
  2781. return;
  2782. }
  2783. callHook$1(vm, 'beforeDestroy');
  2784. vm._isBeingDestroyed = true;
  2785. // remove self from parent
  2786. const parent = vm.$parent;
  2787. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2788. remove$2(parent.$children, vm);
  2789. }
  2790. // teardown scope. this includes both the render watcher and other
  2791. // watchers created
  2792. vm._scope.stop();
  2793. // remove reference from data ob
  2794. // frozen object may not have observer.
  2795. if (vm._data.__ob__) {
  2796. vm._data.__ob__.vmCount--;
  2797. }
  2798. // call the last hook...
  2799. vm._isDestroyed = true;
  2800. // invoke destroy hooks on current rendered tree
  2801. vm.__patch__(vm._vnode, null);
  2802. // fire destroyed hook
  2803. callHook$1(vm, 'destroyed');
  2804. // turn off all instance listeners.
  2805. vm.$off();
  2806. // remove __vue__ reference
  2807. if (vm.$el) {
  2808. vm.$el.__vue__ = null;
  2809. }
  2810. // release circular reference (#6759)
  2811. if (vm.$vnode) {
  2812. vm.$vnode.parent = null;
  2813. }
  2814. };
  2815. }
  2816. function mountComponent(vm, el, hydrating) {
  2817. vm.$el = el;
  2818. if (!vm.$options.render) {
  2819. // @ts-expect-error invalid type
  2820. vm.$options.render = createEmptyVNode;
  2821. {
  2822. /* istanbul ignore if */
  2823. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2824. vm.$options.el ||
  2825. el) {
  2826. warn$2('You are using the runtime-only build of Vue where the template ' +
  2827. 'compiler is not available. Either pre-compile the templates into ' +
  2828. 'render functions, or use the compiler-included build.', vm);
  2829. }
  2830. else {
  2831. warn$2('Failed to mount component: template or render function not defined.', vm);
  2832. }
  2833. }
  2834. }
  2835. callHook$1(vm, 'beforeMount');
  2836. let updateComponent;
  2837. /* istanbul ignore if */
  2838. if (config.performance && mark) {
  2839. updateComponent = () => {
  2840. const name = vm._name;
  2841. const id = vm._uid;
  2842. const startTag = `vue-perf-start:${id}`;
  2843. const endTag = `vue-perf-end:${id}`;
  2844. mark(startTag);
  2845. const vnode = vm._render();
  2846. mark(endTag);
  2847. measure(`vue ${name} render`, startTag, endTag);
  2848. mark(startTag);
  2849. vm._update(vnode, hydrating);
  2850. mark(endTag);
  2851. measure(`vue ${name} patch`, startTag, endTag);
  2852. };
  2853. }
  2854. else {
  2855. updateComponent = () => {
  2856. vm._update(vm._render(), hydrating);
  2857. };
  2858. }
  2859. const watcherOptions = {
  2860. before() {
  2861. if (vm._isMounted && !vm._isDestroyed) {
  2862. callHook$1(vm, 'beforeUpdate');
  2863. }
  2864. }
  2865. };
  2866. {
  2867. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2868. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2869. }
  2870. // we set this to vm._watcher inside the watcher's constructor
  2871. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2872. // component's mounted hook), which relies on vm._watcher being already defined
  2873. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2874. hydrating = false;
  2875. // flush buffer for flush: "pre" watchers queued in setup()
  2876. const preWatchers = vm._preWatchers;
  2877. if (preWatchers) {
  2878. for (let i = 0; i < preWatchers.length; i++) {
  2879. preWatchers[i].run();
  2880. }
  2881. }
  2882. // manually mounted instance, call mounted on self
  2883. // mounted is called for render-created child components in its inserted hook
  2884. if (vm.$vnode == null) {
  2885. vm._isMounted = true;
  2886. callHook$1(vm, 'mounted');
  2887. }
  2888. return vm;
  2889. }
  2890. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2891. {
  2892. isUpdatingChildComponent = true;
  2893. }
  2894. // determine whether component has slot children
  2895. // we need to do this before overwriting $options._renderChildren.
  2896. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2897. // dynamic slot names). Static scoped slots compiled from template has the
  2898. // "$stable" marker.
  2899. const newScopedSlots = parentVnode.data.scopedSlots;
  2900. const oldScopedSlots = vm.$scopedSlots;
  2901. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  2902. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  2903. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  2904. (!newScopedSlots && vm.$scopedSlots.$key));
  2905. // Any static slot children from the parent may have changed during parent's
  2906. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  2907. // update is necessary to ensure correctness.
  2908. let needsForceUpdate = !!(renderChildren || // has new static slots
  2909. vm.$options._renderChildren || // has old static slots
  2910. hasDynamicScopedSlot);
  2911. const prevVNode = vm.$vnode;
  2912. vm.$options._parentVnode = parentVnode;
  2913. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2914. if (vm._vnode) {
  2915. // update child tree's parent
  2916. vm._vnode.parent = parentVnode;
  2917. }
  2918. vm.$options._renderChildren = renderChildren;
  2919. // update $attrs and $listeners hash
  2920. // these are also reactive so they may trigger child update if the child
  2921. // used them during render
  2922. const attrs = parentVnode.data.attrs || emptyObject;
  2923. if (vm._attrsProxy) {
  2924. // force update if attrs are accessed and has changed since it may be
  2925. // passed to a child component.
  2926. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  2927. needsForceUpdate = true;
  2928. }
  2929. }
  2930. vm.$attrs = attrs;
  2931. // update listeners
  2932. listeners = listeners || emptyObject;
  2933. const prevListeners = vm.$options._parentListeners;
  2934. if (vm._listenersProxy) {
  2935. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  2936. }
  2937. vm.$listeners = vm.$options._parentListeners = listeners;
  2938. updateComponentListeners(vm, listeners, prevListeners);
  2939. // update props
  2940. if (propsData && vm.$options.props) {
  2941. toggleObserving(false);
  2942. const props = vm._props;
  2943. const propKeys = vm.$options._propKeys || [];
  2944. for (let i = 0; i < propKeys.length; i++) {
  2945. const key = propKeys[i];
  2946. const propOptions = vm.$options.props; // wtf flow?
  2947. props[key] = validateProp(key, propOptions, propsData, vm);
  2948. }
  2949. toggleObserving(true);
  2950. // keep a copy of raw propsData
  2951. vm.$options.propsData = propsData;
  2952. }
  2953. // resolve slots + force update if has children
  2954. if (needsForceUpdate) {
  2955. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2956. vm.$forceUpdate();
  2957. }
  2958. {
  2959. isUpdatingChildComponent = false;
  2960. }
  2961. }
  2962. function isInInactiveTree(vm) {
  2963. while (vm && (vm = vm.$parent)) {
  2964. if (vm._inactive)
  2965. return true;
  2966. }
  2967. return false;
  2968. }
  2969. function activateChildComponent(vm, direct) {
  2970. if (direct) {
  2971. vm._directInactive = false;
  2972. if (isInInactiveTree(vm)) {
  2973. return;
  2974. }
  2975. }
  2976. else if (vm._directInactive) {
  2977. return;
  2978. }
  2979. if (vm._inactive || vm._inactive === null) {
  2980. vm._inactive = false;
  2981. for (let i = 0; i < vm.$children.length; i++) {
  2982. activateChildComponent(vm.$children[i]);
  2983. }
  2984. callHook$1(vm, 'activated');
  2985. }
  2986. }
  2987. function deactivateChildComponent(vm, direct) {
  2988. if (direct) {
  2989. vm._directInactive = true;
  2990. if (isInInactiveTree(vm)) {
  2991. return;
  2992. }
  2993. }
  2994. if (!vm._inactive) {
  2995. vm._inactive = true;
  2996. for (let i = 0; i < vm.$children.length; i++) {
  2997. deactivateChildComponent(vm.$children[i]);
  2998. }
  2999. callHook$1(vm, 'deactivated');
  3000. }
  3001. }
  3002. function callHook$1(vm, hook, args, setContext = true) {
  3003. // #7573 disable dep collection when invoking lifecycle hooks
  3004. pushTarget();
  3005. const prev = currentInstance;
  3006. setContext && setCurrentInstance(vm);
  3007. const handlers = vm.$options[hook];
  3008. const info = `${hook} hook`;
  3009. if (handlers) {
  3010. for (let i = 0, j = handlers.length; i < j; i++) {
  3011. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3012. }
  3013. }
  3014. if (vm._hasHookEvent) {
  3015. vm.$emit('hook:' + hook);
  3016. }
  3017. setContext && setCurrentInstance(prev);
  3018. popTarget();
  3019. }
  3020. const MAX_UPDATE_COUNT = 100;
  3021. const queue = [];
  3022. const activatedChildren = [];
  3023. let has = {};
  3024. let circular = {};
  3025. let waiting = false;
  3026. let flushing = false;
  3027. let index$1 = 0;
  3028. /**
  3029. * Reset the scheduler's state.
  3030. */
  3031. function resetSchedulerState() {
  3032. index$1 = queue.length = activatedChildren.length = 0;
  3033. has = {};
  3034. {
  3035. circular = {};
  3036. }
  3037. waiting = flushing = false;
  3038. }
  3039. // Async edge case #6566 requires saving the timestamp when event listeners are
  3040. // attached. However, calling performance.now() has a perf overhead especially
  3041. // if the page has thousands of event listeners. Instead, we take a timestamp
  3042. // every time the scheduler flushes and use that for all event listeners
  3043. // attached during that flush.
  3044. let currentFlushTimestamp = 0;
  3045. // Async edge case fix requires storing an event listener's attach timestamp.
  3046. let getNow = Date.now;
  3047. // Determine what event timestamp the browser is using. Annoyingly, the
  3048. // timestamp can either be hi-res (relative to page load) or low-res
  3049. // (relative to UNIX epoch), so in order to compare time we have to use the
  3050. // same timestamp type when saving the flush timestamp.
  3051. // All IE versions use low-res event timestamps, and have problematic clock
  3052. // implementations (#9632)
  3053. if (inBrowser && !isIE) {
  3054. const performance = window.performance;
  3055. if (performance &&
  3056. typeof performance.now === 'function' &&
  3057. getNow() > document.createEvent('Event').timeStamp) {
  3058. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3059. // smaller than it, it means the event is using a hi-res timestamp,
  3060. // and we need to use the hi-res version for event listener timestamps as
  3061. // well.
  3062. getNow = () => performance.now();
  3063. }
  3064. }
  3065. const sortCompareFn = (a, b) => {
  3066. if (a.post) {
  3067. if (!b.post)
  3068. return 1;
  3069. }
  3070. else if (b.post) {
  3071. return -1;
  3072. }
  3073. return a.id - b.id;
  3074. };
  3075. /**
  3076. * Flush both queues and run the watchers.
  3077. */
  3078. function flushSchedulerQueue() {
  3079. currentFlushTimestamp = getNow();
  3080. flushing = true;
  3081. let watcher, id;
  3082. // Sort queue before flush.
  3083. // This ensures that:
  3084. // 1. Components are updated from parent to child. (because parent is always
  3085. // created before the child)
  3086. // 2. A component's user watchers are run before its render watcher (because
  3087. // user watchers are created before the render watcher)
  3088. // 3. If a component is destroyed during a parent component's watcher run,
  3089. // its watchers can be skipped.
  3090. queue.sort(sortCompareFn);
  3091. // do not cache length because more watchers might be pushed
  3092. // as we run existing watchers
  3093. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3094. watcher = queue[index$1];
  3095. if (watcher.before) {
  3096. watcher.before();
  3097. }
  3098. id = watcher.id;
  3099. has[id] = null;
  3100. watcher.run();
  3101. // in dev build, check and stop circular updates.
  3102. if (has[id] != null) {
  3103. circular[id] = (circular[id] || 0) + 1;
  3104. if (circular[id] > MAX_UPDATE_COUNT) {
  3105. warn$2('You may have an infinite update loop ' +
  3106. (watcher.user
  3107. ? `in watcher with expression "${watcher.expression}"`
  3108. : `in a component render function.`), watcher.vm);
  3109. break;
  3110. }
  3111. }
  3112. }
  3113. // keep copies of post queues before resetting state
  3114. const activatedQueue = activatedChildren.slice();
  3115. const updatedQueue = queue.slice();
  3116. resetSchedulerState();
  3117. // call component updated and activated hooks
  3118. callActivatedHooks(activatedQueue);
  3119. callUpdatedHooks(updatedQueue);
  3120. cleanupDeps();
  3121. // devtool hook
  3122. /* istanbul ignore if */
  3123. if (devtools && config.devtools) {
  3124. devtools.emit('flush');
  3125. }
  3126. }
  3127. function callUpdatedHooks(queue) {
  3128. let i = queue.length;
  3129. while (i--) {
  3130. const watcher = queue[i];
  3131. const vm = watcher.vm;
  3132. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3133. callHook$1(vm, 'updated');
  3134. }
  3135. }
  3136. }
  3137. /**
  3138. * Queue a kept-alive component that was activated during patch.
  3139. * The queue will be processed after the entire tree has been patched.
  3140. */
  3141. function queueActivatedComponent(vm) {
  3142. // setting _inactive to false here so that a render function can
  3143. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3144. vm._inactive = false;
  3145. activatedChildren.push(vm);
  3146. }
  3147. function callActivatedHooks(queue) {
  3148. for (let i = 0; i < queue.length; i++) {
  3149. queue[i]._inactive = true;
  3150. activateChildComponent(queue[i], true /* true */);
  3151. }
  3152. }
  3153. /**
  3154. * Push a watcher into the watcher queue.
  3155. * Jobs with duplicate IDs will be skipped unless it's
  3156. * pushed when the queue is being flushed.
  3157. */
  3158. function queueWatcher(watcher) {
  3159. const id = watcher.id;
  3160. if (has[id] != null) {
  3161. return;
  3162. }
  3163. if (watcher === Dep.target && watcher.noRecurse) {
  3164. return;
  3165. }
  3166. has[id] = true;
  3167. if (!flushing) {
  3168. queue.push(watcher);
  3169. }
  3170. else {
  3171. // if already flushing, splice the watcher based on its id
  3172. // if already past its id, it will be run next immediately.
  3173. let i = queue.length - 1;
  3174. while (i > index$1 && queue[i].id > watcher.id) {
  3175. i--;
  3176. }
  3177. queue.splice(i + 1, 0, watcher);
  3178. }
  3179. // queue the flush
  3180. if (!waiting) {
  3181. waiting = true;
  3182. if (!config.async) {
  3183. flushSchedulerQueue();
  3184. return;
  3185. }
  3186. nextTick(flushSchedulerQueue);
  3187. }
  3188. }
  3189. const WATCHER = `watcher`;
  3190. const WATCHER_CB = `${WATCHER} callback`;
  3191. const WATCHER_GETTER = `${WATCHER} getter`;
  3192. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3193. // Simple effect.
  3194. function watchEffect(effect, options) {
  3195. return doWatch(effect, null, options);
  3196. }
  3197. function watchPostEffect(effect, options) {
  3198. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3199. }
  3200. function watchSyncEffect(effect, options) {
  3201. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3202. }
  3203. // initial value for watchers to trigger on undefined initial values
  3204. const INITIAL_WATCHER_VALUE = {};
  3205. // implementation
  3206. function watch(source, cb, options) {
  3207. if (typeof cb !== 'function') {
  3208. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3209. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3210. `supports \`watch(source, cb, options?) signature.`);
  3211. }
  3212. return doWatch(source, cb, options);
  3213. }
  3214. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3215. if (!cb) {
  3216. if (immediate !== undefined) {
  3217. warn$2(`watch() "immediate" option is only respected when using the ` +
  3218. `watch(source, callback, options?) signature.`);
  3219. }
  3220. if (deep !== undefined) {
  3221. warn$2(`watch() "deep" option is only respected when using the ` +
  3222. `watch(source, callback, options?) signature.`);
  3223. }
  3224. }
  3225. const warnInvalidSource = (s) => {
  3226. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3227. `function, a ref, a reactive object, or an array of these types.`);
  3228. };
  3229. const instance = currentInstance;
  3230. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3231. let getter;
  3232. let forceTrigger = false;
  3233. let isMultiSource = false;
  3234. if (isRef(source)) {
  3235. getter = () => source.value;
  3236. forceTrigger = isShallow(source);
  3237. }
  3238. else if (isReactive(source)) {
  3239. getter = () => {
  3240. source.__ob__.dep.depend();
  3241. return source;
  3242. };
  3243. deep = true;
  3244. }
  3245. else if (isArray(source)) {
  3246. isMultiSource = true;
  3247. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3248. getter = () => source.map(s => {
  3249. if (isRef(s)) {
  3250. return s.value;
  3251. }
  3252. else if (isReactive(s)) {
  3253. return traverse(s);
  3254. }
  3255. else if (isFunction(s)) {
  3256. return call(s, WATCHER_GETTER);
  3257. }
  3258. else {
  3259. warnInvalidSource(s);
  3260. }
  3261. });
  3262. }
  3263. else if (isFunction(source)) {
  3264. if (cb) {
  3265. // getter with cb
  3266. getter = () => call(source, WATCHER_GETTER);
  3267. }
  3268. else {
  3269. // no cb -> simple effect
  3270. getter = () => {
  3271. if (instance && instance._isDestroyed) {
  3272. return;
  3273. }
  3274. if (cleanup) {
  3275. cleanup();
  3276. }
  3277. return call(source, WATCHER, [onCleanup]);
  3278. };
  3279. }
  3280. }
  3281. else {
  3282. getter = noop;
  3283. warnInvalidSource(source);
  3284. }
  3285. if (cb && deep) {
  3286. const baseGetter = getter;
  3287. getter = () => traverse(baseGetter());
  3288. }
  3289. let cleanup;
  3290. let onCleanup = (fn) => {
  3291. cleanup = watcher.onStop = () => {
  3292. call(fn, WATCHER_CLEANUP);
  3293. };
  3294. };
  3295. // in SSR there is no need to setup an actual effect, and it should be noop
  3296. // unless it's eager
  3297. if (isServerRendering()) {
  3298. // we will also not call the invalidate callback (+ runner is not set up)
  3299. onCleanup = noop;
  3300. if (!cb) {
  3301. getter();
  3302. }
  3303. else if (immediate) {
  3304. call(cb, WATCHER_CB, [
  3305. getter(),
  3306. isMultiSource ? [] : undefined,
  3307. onCleanup
  3308. ]);
  3309. }
  3310. return noop;
  3311. }
  3312. const watcher = new Watcher(currentInstance, getter, noop, {
  3313. lazy: true
  3314. });
  3315. watcher.noRecurse = !cb;
  3316. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3317. // overwrite default run
  3318. watcher.run = () => {
  3319. if (!watcher.active) {
  3320. return;
  3321. }
  3322. if (cb) {
  3323. // watch(source, cb)
  3324. const newValue = watcher.get();
  3325. if (deep ||
  3326. forceTrigger ||
  3327. (isMultiSource
  3328. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3329. : hasChanged(newValue, oldValue))) {
  3330. // cleanup before running cb again
  3331. if (cleanup) {
  3332. cleanup();
  3333. }
  3334. call(cb, WATCHER_CB, [
  3335. newValue,
  3336. // pass undefined as the old value when it's changed for the first time
  3337. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3338. onCleanup
  3339. ]);
  3340. oldValue = newValue;
  3341. }
  3342. }
  3343. else {
  3344. // watchEffect
  3345. watcher.get();
  3346. }
  3347. };
  3348. if (flush === 'sync') {
  3349. watcher.update = watcher.run;
  3350. }
  3351. else if (flush === 'post') {
  3352. watcher.post = true;
  3353. watcher.update = () => queueWatcher(watcher);
  3354. }
  3355. else {
  3356. // pre
  3357. watcher.update = () => {
  3358. if (instance && instance === currentInstance && !instance._isMounted) {
  3359. // pre-watcher triggered before
  3360. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3361. if (buffer.indexOf(watcher) < 0)
  3362. buffer.push(watcher);
  3363. }
  3364. else {
  3365. queueWatcher(watcher);
  3366. }
  3367. };
  3368. }
  3369. {
  3370. watcher.onTrack = onTrack;
  3371. watcher.onTrigger = onTrigger;
  3372. }
  3373. // initial run
  3374. if (cb) {
  3375. if (immediate) {
  3376. watcher.run();
  3377. }
  3378. else {
  3379. oldValue = watcher.get();
  3380. }
  3381. }
  3382. else if (flush === 'post' && instance) {
  3383. instance.$once('hook:mounted', () => watcher.get());
  3384. }
  3385. else {
  3386. watcher.get();
  3387. }
  3388. return () => {
  3389. watcher.teardown();
  3390. };
  3391. }
  3392. let activeEffectScope;
  3393. class EffectScope {
  3394. constructor(detached = false) {
  3395. this.detached = detached;
  3396. /**
  3397. * @internal
  3398. */
  3399. this.active = true;
  3400. /**
  3401. * @internal
  3402. */
  3403. this.effects = [];
  3404. /**
  3405. * @internal
  3406. */
  3407. this.cleanups = [];
  3408. this.parent = activeEffectScope;
  3409. if (!detached && activeEffectScope) {
  3410. this.index =
  3411. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  3412. }
  3413. }
  3414. run(fn) {
  3415. if (this.active) {
  3416. const currentEffectScope = activeEffectScope;
  3417. try {
  3418. activeEffectScope = this;
  3419. return fn();
  3420. }
  3421. finally {
  3422. activeEffectScope = currentEffectScope;
  3423. }
  3424. }
  3425. else {
  3426. warn$2(`cannot run an inactive effect scope.`);
  3427. }
  3428. }
  3429. /**
  3430. * This should only be called on non-detached scopes
  3431. * @internal
  3432. */
  3433. on() {
  3434. activeEffectScope = this;
  3435. }
  3436. /**
  3437. * This should only be called on non-detached scopes
  3438. * @internal
  3439. */
  3440. off() {
  3441. activeEffectScope = this.parent;
  3442. }
  3443. stop(fromParent) {
  3444. if (this.active) {
  3445. let i, l;
  3446. for (i = 0, l = this.effects.length; i < l; i++) {
  3447. this.effects[i].teardown();
  3448. }
  3449. for (i = 0, l = this.cleanups.length; i < l; i++) {
  3450. this.cleanups[i]();
  3451. }
  3452. if (this.scopes) {
  3453. for (i = 0, l = this.scopes.length; i < l; i++) {
  3454. this.scopes[i].stop(true);
  3455. }
  3456. }
  3457. // nested scope, dereference from parent to avoid memory leaks
  3458. if (!this.detached && this.parent && !fromParent) {
  3459. // optimized O(1) removal
  3460. const last = this.parent.scopes.pop();
  3461. if (last && last !== this) {
  3462. this.parent.scopes[this.index] = last;
  3463. last.index = this.index;
  3464. }
  3465. }
  3466. this.parent = undefined;
  3467. this.active = false;
  3468. }
  3469. }
  3470. }
  3471. function effectScope(detached) {
  3472. return new EffectScope(detached);
  3473. }
  3474. /**
  3475. * @internal
  3476. */
  3477. function recordEffectScope(effect, scope = activeEffectScope) {
  3478. if (scope && scope.active) {
  3479. scope.effects.push(effect);
  3480. }
  3481. }
  3482. function getCurrentScope() {
  3483. return activeEffectScope;
  3484. }
  3485. function onScopeDispose(fn) {
  3486. if (activeEffectScope) {
  3487. activeEffectScope.cleanups.push(fn);
  3488. }
  3489. else {
  3490. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  3491. ` to be associated with.`);
  3492. }
  3493. }
  3494. function provide(key, value) {
  3495. if (!currentInstance) {
  3496. {
  3497. warn$2(`provide() can only be used inside setup().`);
  3498. }
  3499. }
  3500. else {
  3501. // TS doesn't allow symbol as index type
  3502. resolveProvided(currentInstance)[key] = value;
  3503. }
  3504. }
  3505. function resolveProvided(vm) {
  3506. // by default an instance inherits its parent's provides object
  3507. // but when it needs to provide values of its own, it creates its
  3508. // own provides object using parent provides object as prototype.
  3509. // this way in `inject` we can simply look up injections from direct
  3510. // parent and let the prototype chain do the work.
  3511. const existing = vm._provided;
  3512. const parentProvides = vm.$parent && vm.$parent._provided;
  3513. if (parentProvides === existing) {
  3514. return (vm._provided = Object.create(parentProvides));
  3515. }
  3516. else {
  3517. return existing;
  3518. }
  3519. }
  3520. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3521. // fallback to `currentRenderingInstance` so that this can be called in
  3522. // a functional component
  3523. const instance = currentInstance;
  3524. if (instance) {
  3525. // #2400
  3526. // to support `app.use` plugins,
  3527. // fallback to appContext's `provides` if the instance is at root
  3528. const provides = instance.$parent && instance.$parent._provided;
  3529. if (provides && key in provides) {
  3530. // TS doesn't allow symbol as index type
  3531. return provides[key];
  3532. }
  3533. else if (arguments.length > 1) {
  3534. return treatDefaultAsFactory && isFunction(defaultValue)
  3535. ? defaultValue.call(instance)
  3536. : defaultValue;
  3537. }
  3538. else {
  3539. warn$2(`injection "${String(key)}" not found.`);
  3540. }
  3541. }
  3542. else {
  3543. warn$2(`inject() can only be used inside setup() or functional components.`);
  3544. }
  3545. }
  3546. /**
  3547. * @internal this function needs manual public type declaration because it relies
  3548. * on previously manually authored types from Vue 2
  3549. */
  3550. function h(type, props, children) {
  3551. if (!currentInstance) {
  3552. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3553. `component instance, e.g. synchronously in a component's render or setup function.`);
  3554. }
  3555. return createElement$1(currentInstance, type, props, children, 2, true);
  3556. }
  3557. function handleError(err, vm, info) {
  3558. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3559. // See: https://github.com/vuejs/vuex/issues/1505
  3560. pushTarget();
  3561. try {
  3562. if (vm) {
  3563. let cur = vm;
  3564. while ((cur = cur.$parent)) {
  3565. const hooks = cur.$options.errorCaptured;
  3566. if (hooks) {
  3567. for (let i = 0; i < hooks.length; i++) {
  3568. try {
  3569. const capture = hooks[i].call(cur, err, vm, info) === false;
  3570. if (capture)
  3571. return;
  3572. }
  3573. catch (e) {
  3574. globalHandleError(e, cur, 'errorCaptured hook');
  3575. }
  3576. }
  3577. }
  3578. }
  3579. }
  3580. globalHandleError(err, vm, info);
  3581. }
  3582. finally {
  3583. popTarget();
  3584. }
  3585. }
  3586. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3587. let res;
  3588. try {
  3589. res = args ? handler.apply(context, args) : handler.call(context);
  3590. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3591. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3592. res._handled = true;
  3593. }
  3594. }
  3595. catch (e) {
  3596. handleError(e, vm, info);
  3597. }
  3598. return res;
  3599. }
  3600. function globalHandleError(err, vm, info) {
  3601. if (config.errorHandler) {
  3602. try {
  3603. return config.errorHandler.call(null, err, vm, info);
  3604. }
  3605. catch (e) {
  3606. // if the user intentionally throws the original error in the handler,
  3607. // do not log it twice
  3608. if (e !== err) {
  3609. logError(e, null, 'config.errorHandler');
  3610. }
  3611. }
  3612. }
  3613. logError(err, vm, info);
  3614. }
  3615. function logError(err, vm, info) {
  3616. {
  3617. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3618. }
  3619. /* istanbul ignore else */
  3620. if (inBrowser && typeof console !== 'undefined') {
  3621. console.error(err);
  3622. }
  3623. else {
  3624. throw err;
  3625. }
  3626. }
  3627. /* globals MutationObserver */
  3628. let isUsingMicroTask = false;
  3629. const callbacks = [];
  3630. let pending = false;
  3631. function flushCallbacks() {
  3632. pending = false;
  3633. const copies = callbacks.slice(0);
  3634. callbacks.length = 0;
  3635. for (let i = 0; i < copies.length; i++) {
  3636. copies[i]();
  3637. }
  3638. }
  3639. // Here we have async deferring wrappers using microtasks.
  3640. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3641. // However, it has subtle problems when state is changed right before repaint
  3642. // (e.g. #6813, out-in transitions).
  3643. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3644. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3645. // So we now use microtasks everywhere, again.
  3646. // A major drawback of this tradeoff is that there are some scenarios
  3647. // where microtasks have too high a priority and fire in between supposedly
  3648. // sequential events (e.g. #4521, #6690, which have workarounds)
  3649. // or even between bubbling of the same event (#6566).
  3650. let timerFunc;
  3651. // The nextTick behavior leverages the microtask queue, which can be accessed
  3652. // via either native Promise.then or MutationObserver.
  3653. // MutationObserver has wider support, however it is seriously bugged in
  3654. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3655. // completely stops working after triggering a few times... so, if native
  3656. // Promise is available, we will use it:
  3657. /* istanbul ignore next, $flow-disable-line */
  3658. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3659. const p = Promise.resolve();
  3660. timerFunc = () => {
  3661. p.then(flushCallbacks);
  3662. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3663. // it can get stuck in a weird state where callbacks are pushed into the
  3664. // microtask queue but the queue isn't being flushed, until the browser
  3665. // needs to do some other work, e.g. handle a timer. Therefore we can
  3666. // "force" the microtask queue to be flushed by adding an empty timer.
  3667. if (isIOS)
  3668. setTimeout(noop);
  3669. };
  3670. isUsingMicroTask = true;
  3671. }
  3672. else if (!isIE &&
  3673. typeof MutationObserver !== 'undefined' &&
  3674. (isNative(MutationObserver) ||
  3675. // PhantomJS and iOS 7.x
  3676. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3677. // Use MutationObserver where native Promise is not available,
  3678. // e.g. PhantomJS, iOS7, Android 4.4
  3679. // (#6466 MutationObserver is unreliable in IE11)
  3680. let counter = 1;
  3681. const observer = new MutationObserver(flushCallbacks);
  3682. const textNode = document.createTextNode(String(counter));
  3683. observer.observe(textNode, {
  3684. characterData: true
  3685. });
  3686. timerFunc = () => {
  3687. counter = (counter + 1) % 2;
  3688. textNode.data = String(counter);
  3689. };
  3690. isUsingMicroTask = true;
  3691. }
  3692. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3693. // Fallback to setImmediate.
  3694. // Technically it leverages the (macro) task queue,
  3695. // but it is still a better choice than setTimeout.
  3696. timerFunc = () => {
  3697. setImmediate(flushCallbacks);
  3698. };
  3699. }
  3700. else {
  3701. // Fallback to setTimeout.
  3702. timerFunc = () => {
  3703. setTimeout(flushCallbacks, 0);
  3704. };
  3705. }
  3706. /**
  3707. * @internal
  3708. */
  3709. function nextTick(cb, ctx) {
  3710. let _resolve;
  3711. callbacks.push(() => {
  3712. if (cb) {
  3713. try {
  3714. cb.call(ctx);
  3715. }
  3716. catch (e) {
  3717. handleError(e, ctx, 'nextTick');
  3718. }
  3719. }
  3720. else if (_resolve) {
  3721. _resolve(ctx);
  3722. }
  3723. });
  3724. if (!pending) {
  3725. pending = true;
  3726. timerFunc();
  3727. }
  3728. // $flow-disable-line
  3729. if (!cb && typeof Promise !== 'undefined') {
  3730. return new Promise(resolve => {
  3731. _resolve = resolve;
  3732. });
  3733. }
  3734. }
  3735. function useCssModule(name = '$style') {
  3736. /* istanbul ignore else */
  3737. {
  3738. {
  3739. warn$2(`useCssModule() is not supported in the global build.`);
  3740. }
  3741. return emptyObject;
  3742. }
  3743. }
  3744. /**
  3745. * Runtime helper for SFC's CSS variable injection feature.
  3746. * @private
  3747. */
  3748. function useCssVars(getter) {
  3749. if (!inBrowser && !false)
  3750. return;
  3751. const instance = currentInstance;
  3752. if (!instance) {
  3753. warn$2(`useCssVars is called without current active component instance.`);
  3754. return;
  3755. }
  3756. watchPostEffect(() => {
  3757. const el = instance.$el;
  3758. const vars = getter(instance, instance._setupProxy);
  3759. if (el && el.nodeType === 1) {
  3760. const style = el.style;
  3761. for (const key in vars) {
  3762. style.setProperty(`--${key}`, vars[key]);
  3763. }
  3764. }
  3765. });
  3766. }
  3767. /**
  3768. * v3-compatible async component API.
  3769. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3770. * because it relies on existing manual types
  3771. */
  3772. function defineAsyncComponent(source) {
  3773. if (isFunction(source)) {
  3774. source = { loader: source };
  3775. }
  3776. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3777. suspensible = false, // in Vue 3 default is true
  3778. onError: userOnError } = source;
  3779. if (suspensible) {
  3780. warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3781. }
  3782. let pendingRequest = null;
  3783. let retries = 0;
  3784. const retry = () => {
  3785. retries++;
  3786. pendingRequest = null;
  3787. return load();
  3788. };
  3789. const load = () => {
  3790. let thisRequest;
  3791. return (pendingRequest ||
  3792. (thisRequest = pendingRequest =
  3793. loader()
  3794. .catch(err => {
  3795. err = err instanceof Error ? err : new Error(String(err));
  3796. if (userOnError) {
  3797. return new Promise((resolve, reject) => {
  3798. const userRetry = () => resolve(retry());
  3799. const userFail = () => reject(err);
  3800. userOnError(err, userRetry, userFail, retries + 1);
  3801. });
  3802. }
  3803. else {
  3804. throw err;
  3805. }
  3806. })
  3807. .then((comp) => {
  3808. if (thisRequest !== pendingRequest && pendingRequest) {
  3809. return pendingRequest;
  3810. }
  3811. if (!comp) {
  3812. warn$2(`Async component loader resolved to undefined. ` +
  3813. `If you are using retry(), make sure to return its return value.`);
  3814. }
  3815. // interop module default
  3816. if (comp &&
  3817. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3818. comp = comp.default;
  3819. }
  3820. if (comp && !isObject(comp) && !isFunction(comp)) {
  3821. throw new Error(`Invalid async component load result: ${comp}`);
  3822. }
  3823. return comp;
  3824. })));
  3825. };
  3826. return () => {
  3827. const component = load();
  3828. return {
  3829. component,
  3830. delay,
  3831. timeout,
  3832. error: errorComponent,
  3833. loading: loadingComponent
  3834. };
  3835. };
  3836. }
  3837. function createLifeCycle(hookName) {
  3838. return (fn, target = currentInstance) => {
  3839. if (!target) {
  3840. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3841. `associated with. ` +
  3842. `Lifecycle injection APIs can only be used during execution of setup().`);
  3843. return;
  3844. }
  3845. return injectHook(target, hookName, fn);
  3846. };
  3847. }
  3848. function formatName(name) {
  3849. if (name === 'beforeDestroy') {
  3850. name = 'beforeUnmount';
  3851. }
  3852. else if (name === 'destroyed') {
  3853. name = 'unmounted';
  3854. }
  3855. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3856. }
  3857. function injectHook(instance, hookName, fn) {
  3858. const options = instance.$options;
  3859. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3860. }
  3861. const onBeforeMount = createLifeCycle('beforeMount');
  3862. const onMounted = createLifeCycle('mounted');
  3863. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3864. const onUpdated = createLifeCycle('updated');
  3865. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3866. const onUnmounted = createLifeCycle('destroyed');
  3867. const onActivated = createLifeCycle('activated');
  3868. const onDeactivated = createLifeCycle('deactivated');
  3869. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3870. const onRenderTracked = createLifeCycle('renderTracked');
  3871. const onRenderTriggered = createLifeCycle('renderTriggered');
  3872. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3873. function onErrorCaptured(hook, target = currentInstance) {
  3874. injectErrorCapturedHook(hook, target);
  3875. }
  3876. /**
  3877. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3878. */
  3879. const version = '2.7.14';
  3880. /**
  3881. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3882. */
  3883. function defineComponent(options) {
  3884. return options;
  3885. }
  3886. const seenObjects = new _Set();
  3887. /**
  3888. * Recursively traverse an object to evoke all converted
  3889. * getters, so that every nested property inside the object
  3890. * is collected as a "deep" dependency.
  3891. */
  3892. function traverse(val) {
  3893. _traverse(val, seenObjects);
  3894. seenObjects.clear();
  3895. return val;
  3896. }
  3897. function _traverse(val, seen) {
  3898. let i, keys;
  3899. const isA = isArray(val);
  3900. if ((!isA && !isObject(val)) ||
  3901. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3902. Object.isFrozen(val) ||
  3903. val instanceof VNode) {
  3904. return;
  3905. }
  3906. if (val.__ob__) {
  3907. const depId = val.__ob__.dep.id;
  3908. if (seen.has(depId)) {
  3909. return;
  3910. }
  3911. seen.add(depId);
  3912. }
  3913. if (isA) {
  3914. i = val.length;
  3915. while (i--)
  3916. _traverse(val[i], seen);
  3917. }
  3918. else if (isRef(val)) {
  3919. _traverse(val.value, seen);
  3920. }
  3921. else {
  3922. keys = Object.keys(val);
  3923. i = keys.length;
  3924. while (i--)
  3925. _traverse(val[keys[i]], seen);
  3926. }
  3927. }
  3928. let uid$1 = 0;
  3929. /**
  3930. * A watcher parses an expression, collects dependencies,
  3931. * and fires callback when the expression value changes.
  3932. * This is used for both the $watch() api and directives.
  3933. * @internal
  3934. */
  3935. class Watcher {
  3936. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3937. recordEffectScope(this,
  3938. // if the active effect scope is manually created (not a component scope),
  3939. // prioritize it
  3940. activeEffectScope && !activeEffectScope._vm
  3941. ? activeEffectScope
  3942. : vm
  3943. ? vm._scope
  3944. : undefined);
  3945. if ((this.vm = vm) && isRenderWatcher) {
  3946. vm._watcher = this;
  3947. }
  3948. // options
  3949. if (options) {
  3950. this.deep = !!options.deep;
  3951. this.user = !!options.user;
  3952. this.lazy = !!options.lazy;
  3953. this.sync = !!options.sync;
  3954. this.before = options.before;
  3955. {
  3956. this.onTrack = options.onTrack;
  3957. this.onTrigger = options.onTrigger;
  3958. }
  3959. }
  3960. else {
  3961. this.deep = this.user = this.lazy = this.sync = false;
  3962. }
  3963. this.cb = cb;
  3964. this.id = ++uid$1; // uid for batching
  3965. this.active = true;
  3966. this.post = false;
  3967. this.dirty = this.lazy; // for lazy watchers
  3968. this.deps = [];
  3969. this.newDeps = [];
  3970. this.depIds = new _Set();
  3971. this.newDepIds = new _Set();
  3972. this.expression = expOrFn.toString() ;
  3973. // parse expression for getter
  3974. if (isFunction(expOrFn)) {
  3975. this.getter = expOrFn;
  3976. }
  3977. else {
  3978. this.getter = parsePath(expOrFn);
  3979. if (!this.getter) {
  3980. this.getter = noop;
  3981. warn$2(`Failed watching path: "${expOrFn}" ` +
  3982. 'Watcher only accepts simple dot-delimited paths. ' +
  3983. 'For full control, use a function instead.', vm);
  3984. }
  3985. }
  3986. this.value = this.lazy ? undefined : this.get();
  3987. }
  3988. /**
  3989. * Evaluate the getter, and re-collect dependencies.
  3990. */
  3991. get() {
  3992. pushTarget(this);
  3993. let value;
  3994. const vm = this.vm;
  3995. try {
  3996. value = this.getter.call(vm, vm);
  3997. }
  3998. catch (e) {
  3999. if (this.user) {
  4000. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4001. }
  4002. else {
  4003. throw e;
  4004. }
  4005. }
  4006. finally {
  4007. // "touch" every property so they are all tracked as
  4008. // dependencies for deep watching
  4009. if (this.deep) {
  4010. traverse(value);
  4011. }
  4012. popTarget();
  4013. this.cleanupDeps();
  4014. }
  4015. return value;
  4016. }
  4017. /**
  4018. * Add a dependency to this directive.
  4019. */
  4020. addDep(dep) {
  4021. const id = dep.id;
  4022. if (!this.newDepIds.has(id)) {
  4023. this.newDepIds.add(id);
  4024. this.newDeps.push(dep);
  4025. if (!this.depIds.has(id)) {
  4026. dep.addSub(this);
  4027. }
  4028. }
  4029. }
  4030. /**
  4031. * Clean up for dependency collection.
  4032. */
  4033. cleanupDeps() {
  4034. let i = this.deps.length;
  4035. while (i--) {
  4036. const dep = this.deps[i];
  4037. if (!this.newDepIds.has(dep.id)) {
  4038. dep.removeSub(this);
  4039. }
  4040. }
  4041. let tmp = this.depIds;
  4042. this.depIds = this.newDepIds;
  4043. this.newDepIds = tmp;
  4044. this.newDepIds.clear();
  4045. tmp = this.deps;
  4046. this.deps = this.newDeps;
  4047. this.newDeps = tmp;
  4048. this.newDeps.length = 0;
  4049. }
  4050. /**
  4051. * Subscriber interface.
  4052. * Will be called when a dependency changes.
  4053. */
  4054. update() {
  4055. /* istanbul ignore else */
  4056. if (this.lazy) {
  4057. this.dirty = true;
  4058. }
  4059. else if (this.sync) {
  4060. this.run();
  4061. }
  4062. else {
  4063. queueWatcher(this);
  4064. }
  4065. }
  4066. /**
  4067. * Scheduler job interface.
  4068. * Will be called by the scheduler.
  4069. */
  4070. run() {
  4071. if (this.active) {
  4072. const value = this.get();
  4073. if (value !== this.value ||
  4074. // Deep watchers and watchers on Object/Arrays should fire even
  4075. // when the value is the same, because the value may
  4076. // have mutated.
  4077. isObject(value) ||
  4078. this.deep) {
  4079. // set new value
  4080. const oldValue = this.value;
  4081. this.value = value;
  4082. if (this.user) {
  4083. const info = `callback for watcher "${this.expression}"`;
  4084. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4085. }
  4086. else {
  4087. this.cb.call(this.vm, value, oldValue);
  4088. }
  4089. }
  4090. }
  4091. }
  4092. /**
  4093. * Evaluate the value of the watcher.
  4094. * This only gets called for lazy watchers.
  4095. */
  4096. evaluate() {
  4097. this.value = this.get();
  4098. this.dirty = false;
  4099. }
  4100. /**
  4101. * Depend on all deps collected by this watcher.
  4102. */
  4103. depend() {
  4104. let i = this.deps.length;
  4105. while (i--) {
  4106. this.deps[i].depend();
  4107. }
  4108. }
  4109. /**
  4110. * Remove self from all dependencies' subscriber list.
  4111. */
  4112. teardown() {
  4113. if (this.vm && !this.vm._isBeingDestroyed) {
  4114. remove$2(this.vm._scope.effects, this);
  4115. }
  4116. if (this.active) {
  4117. let i = this.deps.length;
  4118. while (i--) {
  4119. this.deps[i].removeSub(this);
  4120. }
  4121. this.active = false;
  4122. if (this.onStop) {
  4123. this.onStop();
  4124. }
  4125. }
  4126. }
  4127. }
  4128. const sharedPropertyDefinition = {
  4129. enumerable: true,
  4130. configurable: true,
  4131. get: noop,
  4132. set: noop
  4133. };
  4134. function proxy(target, sourceKey, key) {
  4135. sharedPropertyDefinition.get = function proxyGetter() {
  4136. return this[sourceKey][key];
  4137. };
  4138. sharedPropertyDefinition.set = function proxySetter(val) {
  4139. this[sourceKey][key] = val;
  4140. };
  4141. Object.defineProperty(target, key, sharedPropertyDefinition);
  4142. }
  4143. function initState(vm) {
  4144. const opts = vm.$options;
  4145. if (opts.props)
  4146. initProps$1(vm, opts.props);
  4147. // Composition API
  4148. initSetup(vm);
  4149. if (opts.methods)
  4150. initMethods(vm, opts.methods);
  4151. if (opts.data) {
  4152. initData(vm);
  4153. }
  4154. else {
  4155. const ob = observe((vm._data = {}));
  4156. ob && ob.vmCount++;
  4157. }
  4158. if (opts.computed)
  4159. initComputed$1(vm, opts.computed);
  4160. if (opts.watch && opts.watch !== nativeWatch) {
  4161. initWatch(vm, opts.watch);
  4162. }
  4163. }
  4164. function initProps$1(vm, propsOptions) {
  4165. const propsData = vm.$options.propsData || {};
  4166. const props = (vm._props = shallowReactive({}));
  4167. // cache prop keys so that future props updates can iterate using Array
  4168. // instead of dynamic object key enumeration.
  4169. const keys = (vm.$options._propKeys = []);
  4170. const isRoot = !vm.$parent;
  4171. // root instance props should be converted
  4172. if (!isRoot) {
  4173. toggleObserving(false);
  4174. }
  4175. for (const key in propsOptions) {
  4176. keys.push(key);
  4177. const value = validateProp(key, propsOptions, propsData, vm);
  4178. /* istanbul ignore else */
  4179. {
  4180. const hyphenatedKey = hyphenate(key);
  4181. if (isReservedAttribute(hyphenatedKey) ||
  4182. config.isReservedAttr(hyphenatedKey)) {
  4183. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4184. }
  4185. defineReactive(props, key, value, () => {
  4186. if (!isRoot && !isUpdatingChildComponent) {
  4187. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4188. `overwritten whenever the parent component re-renders. ` +
  4189. `Instead, use a data or computed property based on the prop's ` +
  4190. `value. Prop being mutated: "${key}"`, vm);
  4191. }
  4192. });
  4193. }
  4194. // static props are already proxied on the component's prototype
  4195. // during Vue.extend(). We only need to proxy props defined at
  4196. // instantiation here.
  4197. if (!(key in vm)) {
  4198. proxy(vm, `_props`, key);
  4199. }
  4200. }
  4201. toggleObserving(true);
  4202. }
  4203. function initData(vm) {
  4204. let data = vm.$options.data;
  4205. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4206. if (!isPlainObject(data)) {
  4207. data = {};
  4208. warn$2('data functions should return an object:\n' +
  4209. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4210. }
  4211. // proxy data on instance
  4212. const keys = Object.keys(data);
  4213. const props = vm.$options.props;
  4214. const methods = vm.$options.methods;
  4215. let i = keys.length;
  4216. while (i--) {
  4217. const key = keys[i];
  4218. {
  4219. if (methods && hasOwn(methods, key)) {
  4220. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4221. }
  4222. }
  4223. if (props && hasOwn(props, key)) {
  4224. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4225. `Use prop default value instead.`, vm);
  4226. }
  4227. else if (!isReserved(key)) {
  4228. proxy(vm, `_data`, key);
  4229. }
  4230. }
  4231. // observe data
  4232. const ob = observe(data);
  4233. ob && ob.vmCount++;
  4234. }
  4235. function getData(data, vm) {
  4236. // #7573 disable dep collection when invoking data getters
  4237. pushTarget();
  4238. try {
  4239. return data.call(vm, vm);
  4240. }
  4241. catch (e) {
  4242. handleError(e, vm, `data()`);
  4243. return {};
  4244. }
  4245. finally {
  4246. popTarget();
  4247. }
  4248. }
  4249. const computedWatcherOptions = { lazy: true };
  4250. function initComputed$1(vm, computed) {
  4251. // $flow-disable-line
  4252. const watchers = (vm._computedWatchers = Object.create(null));
  4253. // computed properties are just getters during SSR
  4254. const isSSR = isServerRendering();
  4255. for (const key in computed) {
  4256. const userDef = computed[key];
  4257. const getter = isFunction(userDef) ? userDef : userDef.get;
  4258. if (getter == null) {
  4259. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4260. }
  4261. if (!isSSR) {
  4262. // create internal watcher for the computed property.
  4263. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4264. }
  4265. // component-defined computed properties are already defined on the
  4266. // component prototype. We only need to define computed properties defined
  4267. // at instantiation here.
  4268. if (!(key in vm)) {
  4269. defineComputed(vm, key, userDef);
  4270. }
  4271. else {
  4272. if (key in vm.$data) {
  4273. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4274. }
  4275. else if (vm.$options.props && key in vm.$options.props) {
  4276. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4277. }
  4278. else if (vm.$options.methods && key in vm.$options.methods) {
  4279. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4280. }
  4281. }
  4282. }
  4283. }
  4284. function defineComputed(target, key, userDef) {
  4285. const shouldCache = !isServerRendering();
  4286. if (isFunction(userDef)) {
  4287. sharedPropertyDefinition.get = shouldCache
  4288. ? createComputedGetter(key)
  4289. : createGetterInvoker(userDef);
  4290. sharedPropertyDefinition.set = noop;
  4291. }
  4292. else {
  4293. sharedPropertyDefinition.get = userDef.get
  4294. ? shouldCache && userDef.cache !== false
  4295. ? createComputedGetter(key)
  4296. : createGetterInvoker(userDef.get)
  4297. : noop;
  4298. sharedPropertyDefinition.set = userDef.set || noop;
  4299. }
  4300. if (sharedPropertyDefinition.set === noop) {
  4301. sharedPropertyDefinition.set = function () {
  4302. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4303. };
  4304. }
  4305. Object.defineProperty(target, key, sharedPropertyDefinition);
  4306. }
  4307. function createComputedGetter(key) {
  4308. return function computedGetter() {
  4309. const watcher = this._computedWatchers && this._computedWatchers[key];
  4310. if (watcher) {
  4311. if (watcher.dirty) {
  4312. watcher.evaluate();
  4313. }
  4314. if (Dep.target) {
  4315. if (Dep.target.onTrack) {
  4316. Dep.target.onTrack({
  4317. effect: Dep.target,
  4318. target: this,
  4319. type: "get" /* TrackOpTypes.GET */,
  4320. key
  4321. });
  4322. }
  4323. watcher.depend();
  4324. }
  4325. return watcher.value;
  4326. }
  4327. };
  4328. }
  4329. function createGetterInvoker(fn) {
  4330. return function computedGetter() {
  4331. return fn.call(this, this);
  4332. };
  4333. }
  4334. function initMethods(vm, methods) {
  4335. const props = vm.$options.props;
  4336. for (const key in methods) {
  4337. {
  4338. if (typeof methods[key] !== 'function') {
  4339. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4340. `Did you reference the function correctly?`, vm);
  4341. }
  4342. if (props && hasOwn(props, key)) {
  4343. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4344. }
  4345. if (key in vm && isReserved(key)) {
  4346. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4347. `Avoid defining component methods that start with _ or $.`);
  4348. }
  4349. }
  4350. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4351. }
  4352. }
  4353. function initWatch(vm, watch) {
  4354. for (const key in watch) {
  4355. const handler = watch[key];
  4356. if (isArray(handler)) {
  4357. for (let i = 0; i < handler.length; i++) {
  4358. createWatcher(vm, key, handler[i]);
  4359. }
  4360. }
  4361. else {
  4362. createWatcher(vm, key, handler);
  4363. }
  4364. }
  4365. }
  4366. function createWatcher(vm, expOrFn, handler, options) {
  4367. if (isPlainObject(handler)) {
  4368. options = handler;
  4369. handler = handler.handler;
  4370. }
  4371. if (typeof handler === 'string') {
  4372. handler = vm[handler];
  4373. }
  4374. return vm.$watch(expOrFn, handler, options);
  4375. }
  4376. function stateMixin(Vue) {
  4377. // flow somehow has problems with directly declared definition object
  4378. // when using Object.defineProperty, so we have to procedurally build up
  4379. // the object here.
  4380. const dataDef = {};
  4381. dataDef.get = function () {
  4382. return this._data;
  4383. };
  4384. const propsDef = {};
  4385. propsDef.get = function () {
  4386. return this._props;
  4387. };
  4388. {
  4389. dataDef.set = function () {
  4390. warn$2('Avoid replacing instance root $data. ' +
  4391. 'Use nested data properties instead.', this);
  4392. };
  4393. propsDef.set = function () {
  4394. warn$2(`$props is readonly.`, this);
  4395. };
  4396. }
  4397. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4398. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4399. Vue.prototype.$set = set;
  4400. Vue.prototype.$delete = del;
  4401. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4402. const vm = this;
  4403. if (isPlainObject(cb)) {
  4404. return createWatcher(vm, expOrFn, cb, options);
  4405. }
  4406. options = options || {};
  4407. options.user = true;
  4408. const watcher = new Watcher(vm, expOrFn, cb, options);
  4409. if (options.immediate) {
  4410. const info = `callback for immediate watcher "${watcher.expression}"`;
  4411. pushTarget();
  4412. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4413. popTarget();
  4414. }
  4415. return function unwatchFn() {
  4416. watcher.teardown();
  4417. };
  4418. };
  4419. }
  4420. function initProvide(vm) {
  4421. const provideOption = vm.$options.provide;
  4422. if (provideOption) {
  4423. const provided = isFunction(provideOption)
  4424. ? provideOption.call(vm)
  4425. : provideOption;
  4426. if (!isObject(provided)) {
  4427. return;
  4428. }
  4429. const source = resolveProvided(vm);
  4430. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4431. // iterate the keys ourselves.
  4432. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4433. for (let i = 0; i < keys.length; i++) {
  4434. const key = keys[i];
  4435. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4436. }
  4437. }
  4438. }
  4439. function initInjections(vm) {
  4440. const result = resolveInject(vm.$options.inject, vm);
  4441. if (result) {
  4442. toggleObserving(false);
  4443. Object.keys(result).forEach(key => {
  4444. /* istanbul ignore else */
  4445. {
  4446. defineReactive(vm, key, result[key], () => {
  4447. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4448. `overwritten whenever the provided component re-renders. ` +
  4449. `injection being mutated: "${key}"`, vm);
  4450. });
  4451. }
  4452. });
  4453. toggleObserving(true);
  4454. }
  4455. }
  4456. function resolveInject(inject, vm) {
  4457. if (inject) {
  4458. // inject is :any because flow is not smart enough to figure out cached
  4459. const result = Object.create(null);
  4460. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4461. for (let i = 0; i < keys.length; i++) {
  4462. const key = keys[i];
  4463. // #6574 in case the inject object is observed...
  4464. if (key === '__ob__')
  4465. continue;
  4466. const provideKey = inject[key].from;
  4467. if (provideKey in vm._provided) {
  4468. result[key] = vm._provided[provideKey];
  4469. }
  4470. else if ('default' in inject[key]) {
  4471. const provideDefault = inject[key].default;
  4472. result[key] = isFunction(provideDefault)
  4473. ? provideDefault.call(vm)
  4474. : provideDefault;
  4475. }
  4476. else {
  4477. warn$2(`Injection "${key}" not found`, vm);
  4478. }
  4479. }
  4480. return result;
  4481. }
  4482. }
  4483. let uid = 0;
  4484. function initMixin$1(Vue) {
  4485. Vue.prototype._init = function (options) {
  4486. const vm = this;
  4487. // a uid
  4488. vm._uid = uid++;
  4489. let startTag, endTag;
  4490. /* istanbul ignore if */
  4491. if (config.performance && mark) {
  4492. startTag = `vue-perf-start:${vm._uid}`;
  4493. endTag = `vue-perf-end:${vm._uid}`;
  4494. mark(startTag);
  4495. }
  4496. // a flag to mark this as a Vue instance without having to do instanceof
  4497. // check
  4498. vm._isVue = true;
  4499. // avoid instances from being observed
  4500. vm.__v_skip = true;
  4501. // effect scope
  4502. vm._scope = new EffectScope(true /* detached */);
  4503. vm._scope._vm = true;
  4504. // merge options
  4505. if (options && options._isComponent) {
  4506. // optimize internal component instantiation
  4507. // since dynamic options merging is pretty slow, and none of the
  4508. // internal component options needs special treatment.
  4509. initInternalComponent(vm, options);
  4510. }
  4511. else {
  4512. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4513. }
  4514. /* istanbul ignore else */
  4515. {
  4516. initProxy(vm);
  4517. }
  4518. // expose real self
  4519. vm._self = vm;
  4520. initLifecycle(vm);
  4521. initEvents(vm);
  4522. initRender(vm);
  4523. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4524. initInjections(vm); // resolve injections before data/props
  4525. initState(vm);
  4526. initProvide(vm); // resolve provide after data/props
  4527. callHook$1(vm, 'created');
  4528. /* istanbul ignore if */
  4529. if (config.performance && mark) {
  4530. vm._name = formatComponentName(vm, false);
  4531. mark(endTag);
  4532. measure(`vue ${vm._name} init`, startTag, endTag);
  4533. }
  4534. if (vm.$options.el) {
  4535. vm.$mount(vm.$options.el);
  4536. }
  4537. };
  4538. }
  4539. function initInternalComponent(vm, options) {
  4540. const opts = (vm.$options = Object.create(vm.constructor.options));
  4541. // doing this because it's faster than dynamic enumeration.
  4542. const parentVnode = options._parentVnode;
  4543. opts.parent = options.parent;
  4544. opts._parentVnode = parentVnode;
  4545. const vnodeComponentOptions = parentVnode.componentOptions;
  4546. opts.propsData = vnodeComponentOptions.propsData;
  4547. opts._parentListeners = vnodeComponentOptions.listeners;
  4548. opts._renderChildren = vnodeComponentOptions.children;
  4549. opts._componentTag = vnodeComponentOptions.tag;
  4550. if (options.render) {
  4551. opts.render = options.render;
  4552. opts.staticRenderFns = options.staticRenderFns;
  4553. }
  4554. }
  4555. function resolveConstructorOptions(Ctor) {
  4556. let options = Ctor.options;
  4557. if (Ctor.super) {
  4558. const superOptions = resolveConstructorOptions(Ctor.super);
  4559. const cachedSuperOptions = Ctor.superOptions;
  4560. if (superOptions !== cachedSuperOptions) {
  4561. // super option changed,
  4562. // need to resolve new options.
  4563. Ctor.superOptions = superOptions;
  4564. // check if there are any late-modified/attached options (#4976)
  4565. const modifiedOptions = resolveModifiedOptions(Ctor);
  4566. // update base extend options
  4567. if (modifiedOptions) {
  4568. extend(Ctor.extendOptions, modifiedOptions);
  4569. }
  4570. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4571. if (options.name) {
  4572. options.components[options.name] = Ctor;
  4573. }
  4574. }
  4575. }
  4576. return options;
  4577. }
  4578. function resolveModifiedOptions(Ctor) {
  4579. let modified;
  4580. const latest = Ctor.options;
  4581. const sealed = Ctor.sealedOptions;
  4582. for (const key in latest) {
  4583. if (latest[key] !== sealed[key]) {
  4584. if (!modified)
  4585. modified = {};
  4586. modified[key] = latest[key];
  4587. }
  4588. }
  4589. return modified;
  4590. }
  4591. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4592. const options = Ctor.options;
  4593. // ensure the createElement function in functional components
  4594. // gets a unique context - this is necessary for correct named slot check
  4595. let contextVm;
  4596. if (hasOwn(parent, '_uid')) {
  4597. contextVm = Object.create(parent);
  4598. contextVm._original = parent;
  4599. }
  4600. else {
  4601. // the context vm passed in is a functional context as well.
  4602. // in this case we want to make sure we are able to get a hold to the
  4603. // real context instance.
  4604. contextVm = parent;
  4605. // @ts-ignore
  4606. parent = parent._original;
  4607. }
  4608. const isCompiled = isTrue(options._compiled);
  4609. const needNormalization = !isCompiled;
  4610. this.data = data;
  4611. this.props = props;
  4612. this.children = children;
  4613. this.parent = parent;
  4614. this.listeners = data.on || emptyObject;
  4615. this.injections = resolveInject(options.inject, parent);
  4616. this.slots = () => {
  4617. if (!this.$slots) {
  4618. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4619. }
  4620. return this.$slots;
  4621. };
  4622. Object.defineProperty(this, 'scopedSlots', {
  4623. enumerable: true,
  4624. get() {
  4625. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4626. }
  4627. });
  4628. // support for compiled functional template
  4629. if (isCompiled) {
  4630. // exposing $options for renderStatic()
  4631. this.$options = options;
  4632. // pre-resolve slots for renderSlot()
  4633. this.$slots = this.slots();
  4634. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4635. }
  4636. if (options._scopeId) {
  4637. this._c = (a, b, c, d) => {
  4638. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4639. if (vnode && !isArray(vnode)) {
  4640. vnode.fnScopeId = options._scopeId;
  4641. vnode.fnContext = parent;
  4642. }
  4643. return vnode;
  4644. };
  4645. }
  4646. else {
  4647. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4648. }
  4649. }
  4650. installRenderHelpers(FunctionalRenderContext.prototype);
  4651. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4652. const options = Ctor.options;
  4653. const props = {};
  4654. const propOptions = options.props;
  4655. if (isDef(propOptions)) {
  4656. for (const key in propOptions) {
  4657. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4658. }
  4659. }
  4660. else {
  4661. if (isDef(data.attrs))
  4662. mergeProps(props, data.attrs);
  4663. if (isDef(data.props))
  4664. mergeProps(props, data.props);
  4665. }
  4666. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4667. const vnode = options.render.call(null, renderContext._c, renderContext);
  4668. if (vnode instanceof VNode) {
  4669. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4670. }
  4671. else if (isArray(vnode)) {
  4672. const vnodes = normalizeChildren(vnode) || [];
  4673. const res = new Array(vnodes.length);
  4674. for (let i = 0; i < vnodes.length; i++) {
  4675. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4676. }
  4677. return res;
  4678. }
  4679. }
  4680. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4681. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4682. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4683. // that should not be matched to match.
  4684. const clone = cloneVNode(vnode);
  4685. clone.fnContext = contextVm;
  4686. clone.fnOptions = options;
  4687. {
  4688. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4689. renderContext;
  4690. }
  4691. if (data.slot) {
  4692. (clone.data || (clone.data = {})).slot = data.slot;
  4693. }
  4694. return clone;
  4695. }
  4696. function mergeProps(to, from) {
  4697. for (const key in from) {
  4698. to[camelize(key)] = from[key];
  4699. }
  4700. }
  4701. function getComponentName(options) {
  4702. return options.name || options.__name || options._componentTag;
  4703. }
  4704. // inline hooks to be invoked on component VNodes during patch
  4705. const componentVNodeHooks = {
  4706. init(vnode, hydrating) {
  4707. if (vnode.componentInstance &&
  4708. !vnode.componentInstance._isDestroyed &&
  4709. vnode.data.keepAlive) {
  4710. // kept-alive components, treat as a patch
  4711. const mountedNode = vnode; // work around flow
  4712. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4713. }
  4714. else {
  4715. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4716. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4717. }
  4718. },
  4719. prepatch(oldVnode, vnode) {
  4720. const options = vnode.componentOptions;
  4721. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4722. updateChildComponent(child, options.propsData, // updated props
  4723. options.listeners, // updated listeners
  4724. vnode, // new parent vnode
  4725. options.children // new children
  4726. );
  4727. },
  4728. insert(vnode) {
  4729. const { context, componentInstance } = vnode;
  4730. if (!componentInstance._isMounted) {
  4731. componentInstance._isMounted = true;
  4732. callHook$1(componentInstance, 'mounted');
  4733. }
  4734. if (vnode.data.keepAlive) {
  4735. if (context._isMounted) {
  4736. // vue-router#1212
  4737. // During updates, a kept-alive component's child components may
  4738. // change, so directly walking the tree here may call activated hooks
  4739. // on incorrect children. Instead we push them into a queue which will
  4740. // be processed after the whole patch process ended.
  4741. queueActivatedComponent(componentInstance);
  4742. }
  4743. else {
  4744. activateChildComponent(componentInstance, true /* direct */);
  4745. }
  4746. }
  4747. },
  4748. destroy(vnode) {
  4749. const { componentInstance } = vnode;
  4750. if (!componentInstance._isDestroyed) {
  4751. if (!vnode.data.keepAlive) {
  4752. componentInstance.$destroy();
  4753. }
  4754. else {
  4755. deactivateChildComponent(componentInstance, true /* direct */);
  4756. }
  4757. }
  4758. }
  4759. };
  4760. const hooksToMerge = Object.keys(componentVNodeHooks);
  4761. function createComponent(Ctor, data, context, children, tag) {
  4762. if (isUndef(Ctor)) {
  4763. return;
  4764. }
  4765. const baseCtor = context.$options._base;
  4766. // plain options object: turn it into a constructor
  4767. if (isObject(Ctor)) {
  4768. Ctor = baseCtor.extend(Ctor);
  4769. }
  4770. // if at this stage it's not a constructor or an async component factory,
  4771. // reject.
  4772. if (typeof Ctor !== 'function') {
  4773. {
  4774. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4775. }
  4776. return;
  4777. }
  4778. // async component
  4779. let asyncFactory;
  4780. // @ts-expect-error
  4781. if (isUndef(Ctor.cid)) {
  4782. asyncFactory = Ctor;
  4783. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4784. if (Ctor === undefined) {
  4785. // return a placeholder node for async component, which is rendered
  4786. // as a comment node but preserves all the raw information for the node.
  4787. // the information will be used for async server-rendering and hydration.
  4788. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4789. }
  4790. }
  4791. data = data || {};
  4792. // resolve constructor options in case global mixins are applied after
  4793. // component constructor creation
  4794. resolveConstructorOptions(Ctor);
  4795. // transform component v-model data into props & events
  4796. if (isDef(data.model)) {
  4797. // @ts-expect-error
  4798. transformModel(Ctor.options, data);
  4799. }
  4800. // extract props
  4801. // @ts-expect-error
  4802. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4803. // functional component
  4804. // @ts-expect-error
  4805. if (isTrue(Ctor.options.functional)) {
  4806. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4807. }
  4808. // extract listeners, since these needs to be treated as
  4809. // child component listeners instead of DOM listeners
  4810. const listeners = data.on;
  4811. // replace with listeners with .native modifier
  4812. // so it gets processed during parent component patch.
  4813. data.on = data.nativeOn;
  4814. // @ts-expect-error
  4815. if (isTrue(Ctor.options.abstract)) {
  4816. // abstract components do not keep anything
  4817. // other than props & listeners & slot
  4818. // work around flow
  4819. const slot = data.slot;
  4820. data = {};
  4821. if (slot) {
  4822. data.slot = slot;
  4823. }
  4824. }
  4825. // install component management hooks onto the placeholder node
  4826. installComponentHooks(data);
  4827. // return a placeholder vnode
  4828. // @ts-expect-error
  4829. const name = getComponentName(Ctor.options) || tag;
  4830. const vnode = new VNode(
  4831. // @ts-expect-error
  4832. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4833. // @ts-expect-error
  4834. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4835. return vnode;
  4836. }
  4837. function createComponentInstanceForVnode(
  4838. // we know it's MountedComponentVNode but flow doesn't
  4839. vnode,
  4840. // activeInstance in lifecycle state
  4841. parent) {
  4842. const options = {
  4843. _isComponent: true,
  4844. _parentVnode: vnode,
  4845. parent
  4846. };
  4847. // check inline-template render functions
  4848. const inlineTemplate = vnode.data.inlineTemplate;
  4849. if (isDef(inlineTemplate)) {
  4850. options.render = inlineTemplate.render;
  4851. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4852. }
  4853. return new vnode.componentOptions.Ctor(options);
  4854. }
  4855. function installComponentHooks(data) {
  4856. const hooks = data.hook || (data.hook = {});
  4857. for (let i = 0; i < hooksToMerge.length; i++) {
  4858. const key = hooksToMerge[i];
  4859. const existing = hooks[key];
  4860. const toMerge = componentVNodeHooks[key];
  4861. // @ts-expect-error
  4862. if (existing !== toMerge && !(existing && existing._merged)) {
  4863. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4864. }
  4865. }
  4866. }
  4867. function mergeHook(f1, f2) {
  4868. const merged = (a, b) => {
  4869. // flow complains about extra args which is why we use any
  4870. f1(a, b);
  4871. f2(a, b);
  4872. };
  4873. merged._merged = true;
  4874. return merged;
  4875. }
  4876. // transform component v-model info (value and callback) into
  4877. // prop and event handler respectively.
  4878. function transformModel(options, data) {
  4879. const prop = (options.model && options.model.prop) || 'value';
  4880. const event = (options.model && options.model.event) || 'input';
  4881. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4882. const on = data.on || (data.on = {});
  4883. const existing = on[event];
  4884. const callback = data.model.callback;
  4885. if (isDef(existing)) {
  4886. if (isArray(existing)
  4887. ? existing.indexOf(callback) === -1
  4888. : existing !== callback) {
  4889. on[event] = [callback].concat(existing);
  4890. }
  4891. }
  4892. else {
  4893. on[event] = callback;
  4894. }
  4895. }
  4896. let warn$2 = noop;
  4897. let tip = noop;
  4898. let generateComponentTrace; // work around flow check
  4899. let formatComponentName;
  4900. {
  4901. const hasConsole = typeof console !== 'undefined';
  4902. const classifyRE = /(?:^|[-_])(\w)/g;
  4903. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4904. warn$2 = (msg, vm = currentInstance) => {
  4905. const trace = vm ? generateComponentTrace(vm) : '';
  4906. if (config.warnHandler) {
  4907. config.warnHandler.call(null, msg, vm, trace);
  4908. }
  4909. else if (hasConsole && !config.silent) {
  4910. console.error(`[Vue warn]: ${msg}${trace}`);
  4911. }
  4912. };
  4913. tip = (msg, vm) => {
  4914. if (hasConsole && !config.silent) {
  4915. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4916. }
  4917. };
  4918. formatComponentName = (vm, includeFile) => {
  4919. if (vm.$root === vm) {
  4920. return '<Root>';
  4921. }
  4922. const options = isFunction(vm) && vm.cid != null
  4923. ? vm.options
  4924. : vm._isVue
  4925. ? vm.$options || vm.constructor.options
  4926. : vm;
  4927. let name = getComponentName(options);
  4928. const file = options.__file;
  4929. if (!name && file) {
  4930. const match = file.match(/([^/\\]+)\.vue$/);
  4931. name = match && match[1];
  4932. }
  4933. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4934. (file && includeFile !== false ? ` at ${file}` : ''));
  4935. };
  4936. const repeat = (str, n) => {
  4937. let res = '';
  4938. while (n) {
  4939. if (n % 2 === 1)
  4940. res += str;
  4941. if (n > 1)
  4942. str += str;
  4943. n >>= 1;
  4944. }
  4945. return res;
  4946. };
  4947. generateComponentTrace = (vm) => {
  4948. if (vm._isVue && vm.$parent) {
  4949. const tree = [];
  4950. let currentRecursiveSequence = 0;
  4951. while (vm) {
  4952. if (tree.length > 0) {
  4953. const last = tree[tree.length - 1];
  4954. if (last.constructor === vm.constructor) {
  4955. currentRecursiveSequence++;
  4956. vm = vm.$parent;
  4957. continue;
  4958. }
  4959. else if (currentRecursiveSequence > 0) {
  4960. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4961. currentRecursiveSequence = 0;
  4962. }
  4963. }
  4964. tree.push(vm);
  4965. vm = vm.$parent;
  4966. }
  4967. return ('\n\nfound in\n\n' +
  4968. tree
  4969. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4970. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4971. : formatComponentName(vm)}`)
  4972. .join('\n'));
  4973. }
  4974. else {
  4975. return `\n\n(found in ${formatComponentName(vm)})`;
  4976. }
  4977. };
  4978. }
  4979. /**
  4980. * Option overwriting strategies are functions that handle
  4981. * how to merge a parent option value and a child option
  4982. * value into the final value.
  4983. */
  4984. const strats = config.optionMergeStrategies;
  4985. /**
  4986. * Options with restrictions
  4987. */
  4988. {
  4989. strats.el = strats.propsData = function (parent, child, vm, key) {
  4990. if (!vm) {
  4991. warn$2(`option "${key}" can only be used during instance ` +
  4992. 'creation with the `new` keyword.');
  4993. }
  4994. return defaultStrat(parent, child);
  4995. };
  4996. }
  4997. /**
  4998. * Helper that recursively merges two data objects together.
  4999. */
  5000. function mergeData(to, from, recursive = true) {
  5001. if (!from)
  5002. return to;
  5003. let key, toVal, fromVal;
  5004. const keys = hasSymbol
  5005. ? Reflect.ownKeys(from)
  5006. : Object.keys(from);
  5007. for (let i = 0; i < keys.length; i++) {
  5008. key = keys[i];
  5009. // in case the object is already observed...
  5010. if (key === '__ob__')
  5011. continue;
  5012. toVal = to[key];
  5013. fromVal = from[key];
  5014. if (!recursive || !hasOwn(to, key)) {
  5015. set(to, key, fromVal);
  5016. }
  5017. else if (toVal !== fromVal &&
  5018. isPlainObject(toVal) &&
  5019. isPlainObject(fromVal)) {
  5020. mergeData(toVal, fromVal);
  5021. }
  5022. }
  5023. return to;
  5024. }
  5025. /**
  5026. * Data
  5027. */
  5028. function mergeDataOrFn(parentVal, childVal, vm) {
  5029. if (!vm) {
  5030. // in a Vue.extend merge, both should be functions
  5031. if (!childVal) {
  5032. return parentVal;
  5033. }
  5034. if (!parentVal) {
  5035. return childVal;
  5036. }
  5037. // when parentVal & childVal are both present,
  5038. // we need to return a function that returns the
  5039. // merged result of both functions... no need to
  5040. // check if parentVal is a function here because
  5041. // it has to be a function to pass previous merges.
  5042. return function mergedDataFn() {
  5043. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5044. };
  5045. }
  5046. else {
  5047. return function mergedInstanceDataFn() {
  5048. // instance merge
  5049. const instanceData = isFunction(childVal)
  5050. ? childVal.call(vm, vm)
  5051. : childVal;
  5052. const defaultData = isFunction(parentVal)
  5053. ? parentVal.call(vm, vm)
  5054. : parentVal;
  5055. if (instanceData) {
  5056. return mergeData(instanceData, defaultData);
  5057. }
  5058. else {
  5059. return defaultData;
  5060. }
  5061. };
  5062. }
  5063. }
  5064. strats.data = function (parentVal, childVal, vm) {
  5065. if (!vm) {
  5066. if (childVal && typeof childVal !== 'function') {
  5067. warn$2('The "data" option should be a function ' +
  5068. 'that returns a per-instance value in component ' +
  5069. 'definitions.', vm);
  5070. return parentVal;
  5071. }
  5072. return mergeDataOrFn(parentVal, childVal);
  5073. }
  5074. return mergeDataOrFn(parentVal, childVal, vm);
  5075. };
  5076. /**
  5077. * Hooks and props are merged as arrays.
  5078. */
  5079. function mergeLifecycleHook(parentVal, childVal) {
  5080. const res = childVal
  5081. ? parentVal
  5082. ? parentVal.concat(childVal)
  5083. : isArray(childVal)
  5084. ? childVal
  5085. : [childVal]
  5086. : parentVal;
  5087. return res ? dedupeHooks(res) : res;
  5088. }
  5089. function dedupeHooks(hooks) {
  5090. const res = [];
  5091. for (let i = 0; i < hooks.length; i++) {
  5092. if (res.indexOf(hooks[i]) === -1) {
  5093. res.push(hooks[i]);
  5094. }
  5095. }
  5096. return res;
  5097. }
  5098. LIFECYCLE_HOOKS.forEach(hook => {
  5099. strats[hook] = mergeLifecycleHook;
  5100. });
  5101. /**
  5102. * Assets
  5103. *
  5104. * When a vm is present (instance creation), we need to do
  5105. * a three-way merge between constructor options, instance
  5106. * options and parent options.
  5107. */
  5108. function mergeAssets(parentVal, childVal, vm, key) {
  5109. const res = Object.create(parentVal || null);
  5110. if (childVal) {
  5111. assertObjectType(key, childVal, vm);
  5112. return extend(res, childVal);
  5113. }
  5114. else {
  5115. return res;
  5116. }
  5117. }
  5118. ASSET_TYPES.forEach(function (type) {
  5119. strats[type + 's'] = mergeAssets;
  5120. });
  5121. /**
  5122. * Watchers.
  5123. *
  5124. * Watchers hashes should not overwrite one
  5125. * another, so we merge them as arrays.
  5126. */
  5127. strats.watch = function (parentVal, childVal, vm, key) {
  5128. // work around Firefox's Object.prototype.watch...
  5129. //@ts-expect-error work around
  5130. if (parentVal === nativeWatch)
  5131. parentVal = undefined;
  5132. //@ts-expect-error work around
  5133. if (childVal === nativeWatch)
  5134. childVal = undefined;
  5135. /* istanbul ignore if */
  5136. if (!childVal)
  5137. return Object.create(parentVal || null);
  5138. {
  5139. assertObjectType(key, childVal, vm);
  5140. }
  5141. if (!parentVal)
  5142. return childVal;
  5143. const ret = {};
  5144. extend(ret, parentVal);
  5145. for (const key in childVal) {
  5146. let parent = ret[key];
  5147. const child = childVal[key];
  5148. if (parent && !isArray(parent)) {
  5149. parent = [parent];
  5150. }
  5151. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5152. }
  5153. return ret;
  5154. };
  5155. /**
  5156. * Other object hashes.
  5157. */
  5158. strats.props =
  5159. strats.methods =
  5160. strats.inject =
  5161. strats.computed =
  5162. function (parentVal, childVal, vm, key) {
  5163. if (childVal && true) {
  5164. assertObjectType(key, childVal, vm);
  5165. }
  5166. if (!parentVal)
  5167. return childVal;
  5168. const ret = Object.create(null);
  5169. extend(ret, parentVal);
  5170. if (childVal)
  5171. extend(ret, childVal);
  5172. return ret;
  5173. };
  5174. strats.provide = function (parentVal, childVal) {
  5175. if (!parentVal)
  5176. return childVal;
  5177. return function () {
  5178. const ret = Object.create(null);
  5179. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5180. if (childVal) {
  5181. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5182. );
  5183. }
  5184. return ret;
  5185. };
  5186. };
  5187. /**
  5188. * Default strategy.
  5189. */
  5190. const defaultStrat = function (parentVal, childVal) {
  5191. return childVal === undefined ? parentVal : childVal;
  5192. };
  5193. /**
  5194. * Validate component names
  5195. */
  5196. function checkComponents(options) {
  5197. for (const key in options.components) {
  5198. validateComponentName(key);
  5199. }
  5200. }
  5201. function validateComponentName(name) {
  5202. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5203. warn$2('Invalid component name: "' +
  5204. name +
  5205. '". Component names ' +
  5206. 'should conform to valid custom element name in html5 specification.');
  5207. }
  5208. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5209. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5210. 'id: ' +
  5211. name);
  5212. }
  5213. }
  5214. /**
  5215. * Ensure all props option syntax are normalized into the
  5216. * Object-based format.
  5217. */
  5218. function normalizeProps(options, vm) {
  5219. const props = options.props;
  5220. if (!props)
  5221. return;
  5222. const res = {};
  5223. let i, val, name;
  5224. if (isArray(props)) {
  5225. i = props.length;
  5226. while (i--) {
  5227. val = props[i];
  5228. if (typeof val === 'string') {
  5229. name = camelize(val);
  5230. res[name] = { type: null };
  5231. }
  5232. else {
  5233. warn$2('props must be strings when using array syntax.');
  5234. }
  5235. }
  5236. }
  5237. else if (isPlainObject(props)) {
  5238. for (const key in props) {
  5239. val = props[key];
  5240. name = camelize(key);
  5241. res[name] = isPlainObject(val) ? val : { type: val };
  5242. }
  5243. }
  5244. else {
  5245. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5246. `but got ${toRawType(props)}.`, vm);
  5247. }
  5248. options.props = res;
  5249. }
  5250. /**
  5251. * Normalize all injections into Object-based format
  5252. */
  5253. function normalizeInject(options, vm) {
  5254. const inject = options.inject;
  5255. if (!inject)
  5256. return;
  5257. const normalized = (options.inject = {});
  5258. if (isArray(inject)) {
  5259. for (let i = 0; i < inject.length; i++) {
  5260. normalized[inject[i]] = { from: inject[i] };
  5261. }
  5262. }
  5263. else if (isPlainObject(inject)) {
  5264. for (const key in inject) {
  5265. const val = inject[key];
  5266. normalized[key] = isPlainObject(val)
  5267. ? extend({ from: key }, val)
  5268. : { from: val };
  5269. }
  5270. }
  5271. else {
  5272. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5273. `but got ${toRawType(inject)}.`, vm);
  5274. }
  5275. }
  5276. /**
  5277. * Normalize raw function directives into object format.
  5278. */
  5279. function normalizeDirectives$1(options) {
  5280. const dirs = options.directives;
  5281. if (dirs) {
  5282. for (const key in dirs) {
  5283. const def = dirs[key];
  5284. if (isFunction(def)) {
  5285. dirs[key] = { bind: def, update: def };
  5286. }
  5287. }
  5288. }
  5289. }
  5290. function assertObjectType(name, value, vm) {
  5291. if (!isPlainObject(value)) {
  5292. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5293. `but got ${toRawType(value)}.`, vm);
  5294. }
  5295. }
  5296. /**
  5297. * Merge two option objects into a new one.
  5298. * Core utility used in both instantiation and inheritance.
  5299. */
  5300. function mergeOptions(parent, child, vm) {
  5301. {
  5302. checkComponents(child);
  5303. }
  5304. if (isFunction(child)) {
  5305. // @ts-expect-error
  5306. child = child.options;
  5307. }
  5308. normalizeProps(child, vm);
  5309. normalizeInject(child, vm);
  5310. normalizeDirectives$1(child);
  5311. // Apply extends and mixins on the child options,
  5312. // but only if it is a raw options object that isn't
  5313. // the result of another mergeOptions call.
  5314. // Only merged options has the _base property.
  5315. if (!child._base) {
  5316. if (child.extends) {
  5317. parent = mergeOptions(parent, child.extends, vm);
  5318. }
  5319. if (child.mixins) {
  5320. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5321. parent = mergeOptions(parent, child.mixins[i], vm);
  5322. }
  5323. }
  5324. }
  5325. const options = {};
  5326. let key;
  5327. for (key in parent) {
  5328. mergeField(key);
  5329. }
  5330. for (key in child) {
  5331. if (!hasOwn(parent, key)) {
  5332. mergeField(key);
  5333. }
  5334. }
  5335. function mergeField(key) {
  5336. const strat = strats[key] || defaultStrat;
  5337. options[key] = strat(parent[key], child[key], vm, key);
  5338. }
  5339. return options;
  5340. }
  5341. /**
  5342. * Resolve an asset.
  5343. * This function is used because child instances need access
  5344. * to assets defined in its ancestor chain.
  5345. */
  5346. function resolveAsset(options, type, id, warnMissing) {
  5347. /* istanbul ignore if */
  5348. if (typeof id !== 'string') {
  5349. return;
  5350. }
  5351. const assets = options[type];
  5352. // check local registration variations first
  5353. if (hasOwn(assets, id))
  5354. return assets[id];
  5355. const camelizedId = camelize(id);
  5356. if (hasOwn(assets, camelizedId))
  5357. return assets[camelizedId];
  5358. const PascalCaseId = capitalize(camelizedId);
  5359. if (hasOwn(assets, PascalCaseId))
  5360. return assets[PascalCaseId];
  5361. // fallback to prototype chain
  5362. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5363. if (warnMissing && !res) {
  5364. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5365. }
  5366. return res;
  5367. }
  5368. function validateProp(key, propOptions, propsData, vm) {
  5369. const prop = propOptions[key];
  5370. const absent = !hasOwn(propsData, key);
  5371. let value = propsData[key];
  5372. // boolean casting
  5373. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5374. if (booleanIndex > -1) {
  5375. if (absent && !hasOwn(prop, 'default')) {
  5376. value = false;
  5377. }
  5378. else if (value === '' || value === hyphenate(key)) {
  5379. // only cast empty string / same name to boolean if
  5380. // boolean has higher priority
  5381. const stringIndex = getTypeIndex(String, prop.type);
  5382. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5383. value = true;
  5384. }
  5385. }
  5386. }
  5387. // check default value
  5388. if (value === undefined) {
  5389. value = getPropDefaultValue(vm, prop, key);
  5390. // since the default value is a fresh copy,
  5391. // make sure to observe it.
  5392. const prevShouldObserve = shouldObserve;
  5393. toggleObserving(true);
  5394. observe(value);
  5395. toggleObserving(prevShouldObserve);
  5396. }
  5397. {
  5398. assertProp(prop, key, value, vm, absent);
  5399. }
  5400. return value;
  5401. }
  5402. /**
  5403. * Get the default value of a prop.
  5404. */
  5405. function getPropDefaultValue(vm, prop, key) {
  5406. // no default, return undefined
  5407. if (!hasOwn(prop, 'default')) {
  5408. return undefined;
  5409. }
  5410. const def = prop.default;
  5411. // warn against non-factory defaults for Object & Array
  5412. if (isObject(def)) {
  5413. warn$2('Invalid default value for prop "' +
  5414. key +
  5415. '": ' +
  5416. 'Props with type Object/Array must use a factory function ' +
  5417. 'to return the default value.', vm);
  5418. }
  5419. // the raw prop value was also undefined from previous render,
  5420. // return previous default value to avoid unnecessary watcher trigger
  5421. if (vm &&
  5422. vm.$options.propsData &&
  5423. vm.$options.propsData[key] === undefined &&
  5424. vm._props[key] !== undefined) {
  5425. return vm._props[key];
  5426. }
  5427. // call factory function for non-Function types
  5428. // a value is Function if its prototype is function even across different execution context
  5429. return isFunction(def) && getType(prop.type) !== 'Function'
  5430. ? def.call(vm)
  5431. : def;
  5432. }
  5433. /**
  5434. * Assert whether a prop is valid.
  5435. */
  5436. function assertProp(prop, name, value, vm, absent) {
  5437. if (prop.required && absent) {
  5438. warn$2('Missing required prop: "' + name + '"', vm);
  5439. return;
  5440. }
  5441. if (value == null && !prop.required) {
  5442. return;
  5443. }
  5444. let type = prop.type;
  5445. let valid = !type || type === true;
  5446. const expectedTypes = [];
  5447. if (type) {
  5448. if (!isArray(type)) {
  5449. type = [type];
  5450. }
  5451. for (let i = 0; i < type.length && !valid; i++) {
  5452. const assertedType = assertType(value, type[i], vm);
  5453. expectedTypes.push(assertedType.expectedType || '');
  5454. valid = assertedType.valid;
  5455. }
  5456. }
  5457. const haveExpectedTypes = expectedTypes.some(t => t);
  5458. if (!valid && haveExpectedTypes) {
  5459. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5460. return;
  5461. }
  5462. const validator = prop.validator;
  5463. if (validator) {
  5464. if (!validator(value)) {
  5465. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5466. }
  5467. }
  5468. }
  5469. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5470. function assertType(value, type, vm) {
  5471. let valid;
  5472. const expectedType = getType(type);
  5473. if (simpleCheckRE.test(expectedType)) {
  5474. const t = typeof value;
  5475. valid = t === expectedType.toLowerCase();
  5476. // for primitive wrapper objects
  5477. if (!valid && t === 'object') {
  5478. valid = value instanceof type;
  5479. }
  5480. }
  5481. else if (expectedType === 'Object') {
  5482. valid = isPlainObject(value);
  5483. }
  5484. else if (expectedType === 'Array') {
  5485. valid = isArray(value);
  5486. }
  5487. else {
  5488. try {
  5489. valid = value instanceof type;
  5490. }
  5491. catch (e) {
  5492. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5493. valid = false;
  5494. }
  5495. }
  5496. return {
  5497. valid,
  5498. expectedType
  5499. };
  5500. }
  5501. const functionTypeCheckRE = /^\s*function (\w+)/;
  5502. /**
  5503. * Use function string name to check built-in types,
  5504. * because a simple equality check will fail when running
  5505. * across different vms / iframes.
  5506. */
  5507. function getType(fn) {
  5508. const match = fn && fn.toString().match(functionTypeCheckRE);
  5509. return match ? match[1] : '';
  5510. }
  5511. function isSameType(a, b) {
  5512. return getType(a) === getType(b);
  5513. }
  5514. function getTypeIndex(type, expectedTypes) {
  5515. if (!isArray(expectedTypes)) {
  5516. return isSameType(expectedTypes, type) ? 0 : -1;
  5517. }
  5518. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5519. if (isSameType(expectedTypes[i], type)) {
  5520. return i;
  5521. }
  5522. }
  5523. return -1;
  5524. }
  5525. function getInvalidTypeMessage(name, value, expectedTypes) {
  5526. let message = `Invalid prop: type check failed for prop "${name}".` +
  5527. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5528. const expectedType = expectedTypes[0];
  5529. const receivedType = toRawType(value);
  5530. // check if we need to specify expected value
  5531. if (expectedTypes.length === 1 &&
  5532. isExplicable(expectedType) &&
  5533. isExplicable(typeof value) &&
  5534. !isBoolean(expectedType, receivedType)) {
  5535. message += ` with value ${styleValue(value, expectedType)}`;
  5536. }
  5537. message += `, got ${receivedType} `;
  5538. // check if we need to specify received value
  5539. if (isExplicable(receivedType)) {
  5540. message += `with value ${styleValue(value, receivedType)}.`;
  5541. }
  5542. return message;
  5543. }
  5544. function styleValue(value, type) {
  5545. if (type === 'String') {
  5546. return `"${value}"`;
  5547. }
  5548. else if (type === 'Number') {
  5549. return `${Number(value)}`;
  5550. }
  5551. else {
  5552. return `${value}`;
  5553. }
  5554. }
  5555. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5556. function isExplicable(value) {
  5557. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5558. }
  5559. function isBoolean(...args) {
  5560. return args.some(elem => elem.toLowerCase() === 'boolean');
  5561. }
  5562. function Vue(options) {
  5563. if (!(this instanceof Vue)) {
  5564. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5565. }
  5566. this._init(options);
  5567. }
  5568. //@ts-expect-error Vue has function type
  5569. initMixin$1(Vue);
  5570. //@ts-expect-error Vue has function type
  5571. stateMixin(Vue);
  5572. //@ts-expect-error Vue has function type
  5573. eventsMixin(Vue);
  5574. //@ts-expect-error Vue has function type
  5575. lifecycleMixin(Vue);
  5576. //@ts-expect-error Vue has function type
  5577. renderMixin(Vue);
  5578. function initUse(Vue) {
  5579. Vue.use = function (plugin) {
  5580. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5581. if (installedPlugins.indexOf(plugin) > -1) {
  5582. return this;
  5583. }
  5584. // additional parameters
  5585. const args = toArray(arguments, 1);
  5586. args.unshift(this);
  5587. if (isFunction(plugin.install)) {
  5588. plugin.install.apply(plugin, args);
  5589. }
  5590. else if (isFunction(plugin)) {
  5591. plugin.apply(null, args);
  5592. }
  5593. installedPlugins.push(plugin);
  5594. return this;
  5595. };
  5596. }
  5597. function initMixin(Vue) {
  5598. Vue.mixin = function (mixin) {
  5599. this.options = mergeOptions(this.options, mixin);
  5600. return this;
  5601. };
  5602. }
  5603. function initExtend(Vue) {
  5604. /**
  5605. * Each instance constructor, including Vue, has a unique
  5606. * cid. This enables us to create wrapped "child
  5607. * constructors" for prototypal inheritance and cache them.
  5608. */
  5609. Vue.cid = 0;
  5610. let cid = 1;
  5611. /**
  5612. * Class inheritance
  5613. */
  5614. Vue.extend = function (extendOptions) {
  5615. extendOptions = extendOptions || {};
  5616. const Super = this;
  5617. const SuperId = Super.cid;
  5618. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5619. if (cachedCtors[SuperId]) {
  5620. return cachedCtors[SuperId];
  5621. }
  5622. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5623. if (name) {
  5624. validateComponentName(name);
  5625. }
  5626. const Sub = function VueComponent(options) {
  5627. this._init(options);
  5628. };
  5629. Sub.prototype = Object.create(Super.prototype);
  5630. Sub.prototype.constructor = Sub;
  5631. Sub.cid = cid++;
  5632. Sub.options = mergeOptions(Super.options, extendOptions);
  5633. Sub['super'] = Super;
  5634. // For props and computed properties, we define the proxy getters on
  5635. // the Vue instances at extension time, on the extended prototype. This
  5636. // avoids Object.defineProperty calls for each instance created.
  5637. if (Sub.options.props) {
  5638. initProps(Sub);
  5639. }
  5640. if (Sub.options.computed) {
  5641. initComputed(Sub);
  5642. }
  5643. // allow further extension/mixin/plugin usage
  5644. Sub.extend = Super.extend;
  5645. Sub.mixin = Super.mixin;
  5646. Sub.use = Super.use;
  5647. // create asset registers, so extended classes
  5648. // can have their private assets too.
  5649. ASSET_TYPES.forEach(function (type) {
  5650. Sub[type] = Super[type];
  5651. });
  5652. // enable recursive self-lookup
  5653. if (name) {
  5654. Sub.options.components[name] = Sub;
  5655. }
  5656. // keep a reference to the super options at extension time.
  5657. // later at instantiation we can check if Super's options have
  5658. // been updated.
  5659. Sub.superOptions = Super.options;
  5660. Sub.extendOptions = extendOptions;
  5661. Sub.sealedOptions = extend({}, Sub.options);
  5662. // cache constructor
  5663. cachedCtors[SuperId] = Sub;
  5664. return Sub;
  5665. };
  5666. }
  5667. function initProps(Comp) {
  5668. const props = Comp.options.props;
  5669. for (const key in props) {
  5670. proxy(Comp.prototype, `_props`, key);
  5671. }
  5672. }
  5673. function initComputed(Comp) {
  5674. const computed = Comp.options.computed;
  5675. for (const key in computed) {
  5676. defineComputed(Comp.prototype, key, computed[key]);
  5677. }
  5678. }
  5679. function initAssetRegisters(Vue) {
  5680. /**
  5681. * Create asset registration methods.
  5682. */
  5683. ASSET_TYPES.forEach(type => {
  5684. // @ts-expect-error function is not exact same type
  5685. Vue[type] = function (id, definition) {
  5686. if (!definition) {
  5687. return this.options[type + 's'][id];
  5688. }
  5689. else {
  5690. /* istanbul ignore if */
  5691. if (type === 'component') {
  5692. validateComponentName(id);
  5693. }
  5694. if (type === 'component' && isPlainObject(definition)) {
  5695. // @ts-expect-error
  5696. definition.name = definition.name || id;
  5697. definition = this.options._base.extend(definition);
  5698. }
  5699. if (type === 'directive' && isFunction(definition)) {
  5700. definition = { bind: definition, update: definition };
  5701. }
  5702. this.options[type + 's'][id] = definition;
  5703. return definition;
  5704. }
  5705. };
  5706. });
  5707. }
  5708. function _getComponentName(opts) {
  5709. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5710. }
  5711. function matches(pattern, name) {
  5712. if (isArray(pattern)) {
  5713. return pattern.indexOf(name) > -1;
  5714. }
  5715. else if (typeof pattern === 'string') {
  5716. return pattern.split(',').indexOf(name) > -1;
  5717. }
  5718. else if (isRegExp(pattern)) {
  5719. return pattern.test(name);
  5720. }
  5721. /* istanbul ignore next */
  5722. return false;
  5723. }
  5724. function pruneCache(keepAliveInstance, filter) {
  5725. const { cache, keys, _vnode } = keepAliveInstance;
  5726. for (const key in cache) {
  5727. const entry = cache[key];
  5728. if (entry) {
  5729. const name = entry.name;
  5730. if (name && !filter(name)) {
  5731. pruneCacheEntry(cache, key, keys, _vnode);
  5732. }
  5733. }
  5734. }
  5735. }
  5736. function pruneCacheEntry(cache, key, keys, current) {
  5737. const entry = cache[key];
  5738. if (entry && (!current || entry.tag !== current.tag)) {
  5739. // @ts-expect-error can be undefined
  5740. entry.componentInstance.$destroy();
  5741. }
  5742. cache[key] = null;
  5743. remove$2(keys, key);
  5744. }
  5745. const patternTypes = [String, RegExp, Array];
  5746. // TODO defineComponent
  5747. var KeepAlive = {
  5748. name: 'keep-alive',
  5749. abstract: true,
  5750. props: {
  5751. include: patternTypes,
  5752. exclude: patternTypes,
  5753. max: [String, Number]
  5754. },
  5755. methods: {
  5756. cacheVNode() {
  5757. const { cache, keys, vnodeToCache, keyToCache } = this;
  5758. if (vnodeToCache) {
  5759. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5760. cache[keyToCache] = {
  5761. name: _getComponentName(componentOptions),
  5762. tag,
  5763. componentInstance
  5764. };
  5765. keys.push(keyToCache);
  5766. // prune oldest entry
  5767. if (this.max && keys.length > parseInt(this.max)) {
  5768. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5769. }
  5770. this.vnodeToCache = null;
  5771. }
  5772. }
  5773. },
  5774. created() {
  5775. this.cache = Object.create(null);
  5776. this.keys = [];
  5777. },
  5778. destroyed() {
  5779. for (const key in this.cache) {
  5780. pruneCacheEntry(this.cache, key, this.keys);
  5781. }
  5782. },
  5783. mounted() {
  5784. this.cacheVNode();
  5785. this.$watch('include', val => {
  5786. pruneCache(this, name => matches(val, name));
  5787. });
  5788. this.$watch('exclude', val => {
  5789. pruneCache(this, name => !matches(val, name));
  5790. });
  5791. },
  5792. updated() {
  5793. this.cacheVNode();
  5794. },
  5795. render() {
  5796. const slot = this.$slots.default;
  5797. const vnode = getFirstComponentChild(slot);
  5798. const componentOptions = vnode && vnode.componentOptions;
  5799. if (componentOptions) {
  5800. // check pattern
  5801. const name = _getComponentName(componentOptions);
  5802. const { include, exclude } = this;
  5803. if (
  5804. // not included
  5805. (include && (!name || !matches(include, name))) ||
  5806. // excluded
  5807. (exclude && name && matches(exclude, name))) {
  5808. return vnode;
  5809. }
  5810. const { cache, keys } = this;
  5811. const key = vnode.key == null
  5812. ? // same constructor may get registered as different local components
  5813. // so cid alone is not enough (#3269)
  5814. componentOptions.Ctor.cid +
  5815. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5816. : vnode.key;
  5817. if (cache[key]) {
  5818. vnode.componentInstance = cache[key].componentInstance;
  5819. // make current key freshest
  5820. remove$2(keys, key);
  5821. keys.push(key);
  5822. }
  5823. else {
  5824. // delay setting the cache until update
  5825. this.vnodeToCache = vnode;
  5826. this.keyToCache = key;
  5827. }
  5828. // @ts-expect-error can vnode.data can be undefined
  5829. vnode.data.keepAlive = true;
  5830. }
  5831. return vnode || (slot && slot[0]);
  5832. }
  5833. };
  5834. var builtInComponents = {
  5835. KeepAlive
  5836. };
  5837. function initGlobalAPI(Vue) {
  5838. // config
  5839. const configDef = {};
  5840. configDef.get = () => config;
  5841. {
  5842. configDef.set = () => {
  5843. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5844. };
  5845. }
  5846. Object.defineProperty(Vue, 'config', configDef);
  5847. // exposed util methods.
  5848. // NOTE: these are not considered part of the public API - avoid relying on
  5849. // them unless you are aware of the risk.
  5850. Vue.util = {
  5851. warn: warn$2,
  5852. extend,
  5853. mergeOptions,
  5854. defineReactive
  5855. };
  5856. Vue.set = set;
  5857. Vue.delete = del;
  5858. Vue.nextTick = nextTick;
  5859. // 2.6 explicit observable API
  5860. Vue.observable = (obj) => {
  5861. observe(obj);
  5862. return obj;
  5863. };
  5864. Vue.options = Object.create(null);
  5865. ASSET_TYPES.forEach(type => {
  5866. Vue.options[type + 's'] = Object.create(null);
  5867. });
  5868. // this is used to identify the "base" constructor to extend all plain-object
  5869. // components with in Weex's multi-instance scenarios.
  5870. Vue.options._base = Vue;
  5871. extend(Vue.options.components, builtInComponents);
  5872. initUse(Vue);
  5873. initMixin(Vue);
  5874. initExtend(Vue);
  5875. initAssetRegisters(Vue);
  5876. }
  5877. initGlobalAPI(Vue);
  5878. Object.defineProperty(Vue.prototype, '$isServer', {
  5879. get: isServerRendering
  5880. });
  5881. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5882. get() {
  5883. /* istanbul ignore next */
  5884. return this.$vnode && this.$vnode.ssrContext;
  5885. }
  5886. });
  5887. // expose FunctionalRenderContext for ssr runtime helper installation
  5888. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5889. value: FunctionalRenderContext
  5890. });
  5891. Vue.version = version;
  5892. // these are reserved for web because they are directly compiled away
  5893. // during template compilation
  5894. const isReservedAttr = makeMap('style,class');
  5895. // attributes that should be using props for binding
  5896. const acceptValue = makeMap('input,textarea,option,select,progress');
  5897. const mustUseProp = (tag, type, attr) => {
  5898. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5899. (attr === 'selected' && tag === 'option') ||
  5900. (attr === 'checked' && tag === 'input') ||
  5901. (attr === 'muted' && tag === 'video'));
  5902. };
  5903. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5904. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5905. const convertEnumeratedValue = (key, value) => {
  5906. return isFalsyAttrValue(value) || value === 'false'
  5907. ? 'false'
  5908. : // allow arbitrary string value for contenteditable
  5909. key === 'contenteditable' && isValidContentEditableValue(value)
  5910. ? value
  5911. : 'true';
  5912. };
  5913. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5914. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5915. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5916. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5917. 'required,reversed,scoped,seamless,selected,sortable,' +
  5918. 'truespeed,typemustmatch,visible');
  5919. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5920. const isXlink = (name) => {
  5921. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5922. };
  5923. const getXlinkProp = (name) => {
  5924. return isXlink(name) ? name.slice(6, name.length) : '';
  5925. };
  5926. const isFalsyAttrValue = (val) => {
  5927. return val == null || val === false;
  5928. };
  5929. function genClassForVnode(vnode) {
  5930. let data = vnode.data;
  5931. let parentNode = vnode;
  5932. let childNode = vnode;
  5933. while (isDef(childNode.componentInstance)) {
  5934. childNode = childNode.componentInstance._vnode;
  5935. if (childNode && childNode.data) {
  5936. data = mergeClassData(childNode.data, data);
  5937. }
  5938. }
  5939. // @ts-expect-error parentNode.parent not VNodeWithData
  5940. while (isDef((parentNode = parentNode.parent))) {
  5941. if (parentNode && parentNode.data) {
  5942. data = mergeClassData(data, parentNode.data);
  5943. }
  5944. }
  5945. return renderClass(data.staticClass, data.class);
  5946. }
  5947. function mergeClassData(child, parent) {
  5948. return {
  5949. staticClass: concat(child.staticClass, parent.staticClass),
  5950. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  5951. };
  5952. }
  5953. function renderClass(staticClass, dynamicClass) {
  5954. if (isDef(staticClass) || isDef(dynamicClass)) {
  5955. return concat(staticClass, stringifyClass(dynamicClass));
  5956. }
  5957. /* istanbul ignore next */
  5958. return '';
  5959. }
  5960. function concat(a, b) {
  5961. return a ? (b ? a + ' ' + b : a) : b || '';
  5962. }
  5963. function stringifyClass(value) {
  5964. if (Array.isArray(value)) {
  5965. return stringifyArray(value);
  5966. }
  5967. if (isObject(value)) {
  5968. return stringifyObject(value);
  5969. }
  5970. if (typeof value === 'string') {
  5971. return value;
  5972. }
  5973. /* istanbul ignore next */
  5974. return '';
  5975. }
  5976. function stringifyArray(value) {
  5977. let res = '';
  5978. let stringified;
  5979. for (let i = 0, l = value.length; i < l; i++) {
  5980. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  5981. if (res)
  5982. res += ' ';
  5983. res += stringified;
  5984. }
  5985. }
  5986. return res;
  5987. }
  5988. function stringifyObject(value) {
  5989. let res = '';
  5990. for (const key in value) {
  5991. if (value[key]) {
  5992. if (res)
  5993. res += ' ';
  5994. res += key;
  5995. }
  5996. }
  5997. return res;
  5998. }
  5999. const namespaceMap = {
  6000. svg: 'http://www.w3.org/2000/svg',
  6001. math: 'http://www.w3.org/1998/Math/MathML'
  6002. };
  6003. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6004. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6005. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6006. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6007. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6008. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6009. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6010. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6011. 'output,progress,select,textarea,' +
  6012. 'details,dialog,menu,menuitem,summary,' +
  6013. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6014. // this map is intentionally selective, only covering SVG elements that may
  6015. // contain child elements.
  6016. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6017. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6018. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6019. const isPreTag = (tag) => tag === 'pre';
  6020. const isReservedTag = (tag) => {
  6021. return isHTMLTag(tag) || isSVG(tag);
  6022. };
  6023. function getTagNamespace(tag) {
  6024. if (isSVG(tag)) {
  6025. return 'svg';
  6026. }
  6027. // basic support for MathML
  6028. // note it doesn't support other MathML elements being component roots
  6029. if (tag === 'math') {
  6030. return 'math';
  6031. }
  6032. }
  6033. const unknownElementCache = Object.create(null);
  6034. function isUnknownElement(tag) {
  6035. /* istanbul ignore if */
  6036. if (!inBrowser) {
  6037. return true;
  6038. }
  6039. if (isReservedTag(tag)) {
  6040. return false;
  6041. }
  6042. tag = tag.toLowerCase();
  6043. /* istanbul ignore if */
  6044. if (unknownElementCache[tag] != null) {
  6045. return unknownElementCache[tag];
  6046. }
  6047. const el = document.createElement(tag);
  6048. if (tag.indexOf('-') > -1) {
  6049. // http://stackoverflow.com/a/28210364/1070244
  6050. return (unknownElementCache[tag] =
  6051. el.constructor === window.HTMLUnknownElement ||
  6052. el.constructor === window.HTMLElement);
  6053. }
  6054. else {
  6055. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6056. }
  6057. }
  6058. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6059. /**
  6060. * Query an element selector if it's not an element already.
  6061. */
  6062. function query(el) {
  6063. if (typeof el === 'string') {
  6064. const selected = document.querySelector(el);
  6065. if (!selected) {
  6066. warn$2('Cannot find element: ' + el);
  6067. return document.createElement('div');
  6068. }
  6069. return selected;
  6070. }
  6071. else {
  6072. return el;
  6073. }
  6074. }
  6075. function createElement(tagName, vnode) {
  6076. const elm = document.createElement(tagName);
  6077. if (tagName !== 'select') {
  6078. return elm;
  6079. }
  6080. // false or null will remove the attribute but undefined will not
  6081. if (vnode.data &&
  6082. vnode.data.attrs &&
  6083. vnode.data.attrs.multiple !== undefined) {
  6084. elm.setAttribute('multiple', 'multiple');
  6085. }
  6086. return elm;
  6087. }
  6088. function createElementNS(namespace, tagName) {
  6089. return document.createElementNS(namespaceMap[namespace], tagName);
  6090. }
  6091. function createTextNode(text) {
  6092. return document.createTextNode(text);
  6093. }
  6094. function createComment(text) {
  6095. return document.createComment(text);
  6096. }
  6097. function insertBefore(parentNode, newNode, referenceNode) {
  6098. parentNode.insertBefore(newNode, referenceNode);
  6099. }
  6100. function removeChild(node, child) {
  6101. node.removeChild(child);
  6102. }
  6103. function appendChild(node, child) {
  6104. node.appendChild(child);
  6105. }
  6106. function parentNode(node) {
  6107. return node.parentNode;
  6108. }
  6109. function nextSibling(node) {
  6110. return node.nextSibling;
  6111. }
  6112. function tagName(node) {
  6113. return node.tagName;
  6114. }
  6115. function setTextContent(node, text) {
  6116. node.textContent = text;
  6117. }
  6118. function setStyleScope(node, scopeId) {
  6119. node.setAttribute(scopeId, '');
  6120. }
  6121. var nodeOps = /*#__PURE__*/Object.freeze({
  6122. __proto__: null,
  6123. createElement: createElement,
  6124. createElementNS: createElementNS,
  6125. createTextNode: createTextNode,
  6126. createComment: createComment,
  6127. insertBefore: insertBefore,
  6128. removeChild: removeChild,
  6129. appendChild: appendChild,
  6130. parentNode: parentNode,
  6131. nextSibling: nextSibling,
  6132. tagName: tagName,
  6133. setTextContent: setTextContent,
  6134. setStyleScope: setStyleScope
  6135. });
  6136. var ref = {
  6137. create(_, vnode) {
  6138. registerRef(vnode);
  6139. },
  6140. update(oldVnode, vnode) {
  6141. if (oldVnode.data.ref !== vnode.data.ref) {
  6142. registerRef(oldVnode, true);
  6143. registerRef(vnode);
  6144. }
  6145. },
  6146. destroy(vnode) {
  6147. registerRef(vnode, true);
  6148. }
  6149. };
  6150. function registerRef(vnode, isRemoval) {
  6151. const ref = vnode.data.ref;
  6152. if (!isDef(ref))
  6153. return;
  6154. const vm = vnode.context;
  6155. const refValue = vnode.componentInstance || vnode.elm;
  6156. const value = isRemoval ? null : refValue;
  6157. const $refsValue = isRemoval ? undefined : refValue;
  6158. if (isFunction(ref)) {
  6159. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6160. return;
  6161. }
  6162. const isFor = vnode.data.refInFor;
  6163. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6164. const _isRef = isRef(ref);
  6165. const refs = vm.$refs;
  6166. if (_isString || _isRef) {
  6167. if (isFor) {
  6168. const existing = _isString ? refs[ref] : ref.value;
  6169. if (isRemoval) {
  6170. isArray(existing) && remove$2(existing, refValue);
  6171. }
  6172. else {
  6173. if (!isArray(existing)) {
  6174. if (_isString) {
  6175. refs[ref] = [refValue];
  6176. setSetupRef(vm, ref, refs[ref]);
  6177. }
  6178. else {
  6179. ref.value = [refValue];
  6180. }
  6181. }
  6182. else if (!existing.includes(refValue)) {
  6183. existing.push(refValue);
  6184. }
  6185. }
  6186. }
  6187. else if (_isString) {
  6188. if (isRemoval && refs[ref] !== refValue) {
  6189. return;
  6190. }
  6191. refs[ref] = $refsValue;
  6192. setSetupRef(vm, ref, value);
  6193. }
  6194. else if (_isRef) {
  6195. if (isRemoval && ref.value !== refValue) {
  6196. return;
  6197. }
  6198. ref.value = value;
  6199. }
  6200. else {
  6201. warn$2(`Invalid template ref type: ${typeof ref}`);
  6202. }
  6203. }
  6204. }
  6205. function setSetupRef({ _setupState }, key, val) {
  6206. if (_setupState && hasOwn(_setupState, key)) {
  6207. if (isRef(_setupState[key])) {
  6208. _setupState[key].value = val;
  6209. }
  6210. else {
  6211. _setupState[key] = val;
  6212. }
  6213. }
  6214. }
  6215. /**
  6216. * Virtual DOM patching algorithm based on Snabbdom by
  6217. * Simon Friis Vindum (@paldepind)
  6218. * Licensed under the MIT License
  6219. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6220. *
  6221. * modified by Evan You (@yyx990803)
  6222. *
  6223. * Not type-checking this because this file is perf-critical and the cost
  6224. * of making flow understand it is not worth it.
  6225. */
  6226. const emptyNode = new VNode('', {}, []);
  6227. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6228. function sameVnode(a, b) {
  6229. return (a.key === b.key &&
  6230. a.asyncFactory === b.asyncFactory &&
  6231. ((a.tag === b.tag &&
  6232. a.isComment === b.isComment &&
  6233. isDef(a.data) === isDef(b.data) &&
  6234. sameInputType(a, b)) ||
  6235. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6236. }
  6237. function sameInputType(a, b) {
  6238. if (a.tag !== 'input')
  6239. return true;
  6240. let i;
  6241. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6242. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6243. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6244. }
  6245. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6246. let i, key;
  6247. const map = {};
  6248. for (i = beginIdx; i <= endIdx; ++i) {
  6249. key = children[i].key;
  6250. if (isDef(key))
  6251. map[key] = i;
  6252. }
  6253. return map;
  6254. }
  6255. function createPatchFunction(backend) {
  6256. let i, j;
  6257. const cbs = {};
  6258. const { modules, nodeOps } = backend;
  6259. for (i = 0; i < hooks.length; ++i) {
  6260. cbs[hooks[i]] = [];
  6261. for (j = 0; j < modules.length; ++j) {
  6262. if (isDef(modules[j][hooks[i]])) {
  6263. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6264. }
  6265. }
  6266. }
  6267. function emptyNodeAt(elm) {
  6268. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6269. }
  6270. function createRmCb(childElm, listeners) {
  6271. function remove() {
  6272. if (--remove.listeners === 0) {
  6273. removeNode(childElm);
  6274. }
  6275. }
  6276. remove.listeners = listeners;
  6277. return remove;
  6278. }
  6279. function removeNode(el) {
  6280. const parent = nodeOps.parentNode(el);
  6281. // element may have already been removed due to v-html / v-text
  6282. if (isDef(parent)) {
  6283. nodeOps.removeChild(parent, el);
  6284. }
  6285. }
  6286. function isUnknownElement(vnode, inVPre) {
  6287. return (!inVPre &&
  6288. !vnode.ns &&
  6289. !(config.ignoredElements.length &&
  6290. config.ignoredElements.some(ignore => {
  6291. return isRegExp(ignore)
  6292. ? ignore.test(vnode.tag)
  6293. : ignore === vnode.tag;
  6294. })) &&
  6295. config.isUnknownElement(vnode.tag));
  6296. }
  6297. let creatingElmInVPre = 0;
  6298. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6299. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6300. // This vnode was used in a previous render!
  6301. // now it's used as a new node, overwriting its elm would cause
  6302. // potential patch errors down the road when it's used as an insertion
  6303. // reference node. Instead, we clone the node on-demand before creating
  6304. // associated DOM element for it.
  6305. vnode = ownerArray[index] = cloneVNode(vnode);
  6306. }
  6307. vnode.isRootInsert = !nested; // for transition enter check
  6308. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6309. return;
  6310. }
  6311. const data = vnode.data;
  6312. const children = vnode.children;
  6313. const tag = vnode.tag;
  6314. if (isDef(tag)) {
  6315. {
  6316. if (data && data.pre) {
  6317. creatingElmInVPre++;
  6318. }
  6319. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6320. warn$2('Unknown custom element: <' +
  6321. tag +
  6322. '> - did you ' +
  6323. 'register the component correctly? For recursive components, ' +
  6324. 'make sure to provide the "name" option.', vnode.context);
  6325. }
  6326. }
  6327. vnode.elm = vnode.ns
  6328. ? nodeOps.createElementNS(vnode.ns, tag)
  6329. : nodeOps.createElement(tag, vnode);
  6330. setScope(vnode);
  6331. createChildren(vnode, children, insertedVnodeQueue);
  6332. if (isDef(data)) {
  6333. invokeCreateHooks(vnode, insertedVnodeQueue);
  6334. }
  6335. insert(parentElm, vnode.elm, refElm);
  6336. if (data && data.pre) {
  6337. creatingElmInVPre--;
  6338. }
  6339. }
  6340. else if (isTrue(vnode.isComment)) {
  6341. vnode.elm = nodeOps.createComment(vnode.text);
  6342. insert(parentElm, vnode.elm, refElm);
  6343. }
  6344. else {
  6345. vnode.elm = nodeOps.createTextNode(vnode.text);
  6346. insert(parentElm, vnode.elm, refElm);
  6347. }
  6348. }
  6349. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6350. let i = vnode.data;
  6351. if (isDef(i)) {
  6352. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6353. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6354. i(vnode, false /* hydrating */);
  6355. }
  6356. // after calling the init hook, if the vnode is a child component
  6357. // it should've created a child instance and mounted it. the child
  6358. // component also has set the placeholder vnode's elm.
  6359. // in that case we can just return the element and be done.
  6360. if (isDef(vnode.componentInstance)) {
  6361. initComponent(vnode, insertedVnodeQueue);
  6362. insert(parentElm, vnode.elm, refElm);
  6363. if (isTrue(isReactivated)) {
  6364. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6365. }
  6366. return true;
  6367. }
  6368. }
  6369. }
  6370. function initComponent(vnode, insertedVnodeQueue) {
  6371. if (isDef(vnode.data.pendingInsert)) {
  6372. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6373. vnode.data.pendingInsert = null;
  6374. }
  6375. vnode.elm = vnode.componentInstance.$el;
  6376. if (isPatchable(vnode)) {
  6377. invokeCreateHooks(vnode, insertedVnodeQueue);
  6378. setScope(vnode);
  6379. }
  6380. else {
  6381. // empty component root.
  6382. // skip all element-related modules except for ref (#3455)
  6383. registerRef(vnode);
  6384. // make sure to invoke the insert hook
  6385. insertedVnodeQueue.push(vnode);
  6386. }
  6387. }
  6388. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6389. let i;
  6390. // hack for #4339: a reactivated component with inner transition
  6391. // does not trigger because the inner node's created hooks are not called
  6392. // again. It's not ideal to involve module-specific logic in here but
  6393. // there doesn't seem to be a better way to do it.
  6394. let innerNode = vnode;
  6395. while (innerNode.componentInstance) {
  6396. innerNode = innerNode.componentInstance._vnode;
  6397. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6398. for (i = 0; i < cbs.activate.length; ++i) {
  6399. cbs.activate[i](emptyNode, innerNode);
  6400. }
  6401. insertedVnodeQueue.push(innerNode);
  6402. break;
  6403. }
  6404. }
  6405. // unlike a newly created component,
  6406. // a reactivated keep-alive component doesn't insert itself
  6407. insert(parentElm, vnode.elm, refElm);
  6408. }
  6409. function insert(parent, elm, ref) {
  6410. if (isDef(parent)) {
  6411. if (isDef(ref)) {
  6412. if (nodeOps.parentNode(ref) === parent) {
  6413. nodeOps.insertBefore(parent, elm, ref);
  6414. }
  6415. }
  6416. else {
  6417. nodeOps.appendChild(parent, elm);
  6418. }
  6419. }
  6420. }
  6421. function createChildren(vnode, children, insertedVnodeQueue) {
  6422. if (isArray(children)) {
  6423. {
  6424. checkDuplicateKeys(children);
  6425. }
  6426. for (let i = 0; i < children.length; ++i) {
  6427. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6428. }
  6429. }
  6430. else if (isPrimitive(vnode.text)) {
  6431. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6432. }
  6433. }
  6434. function isPatchable(vnode) {
  6435. while (vnode.componentInstance) {
  6436. vnode = vnode.componentInstance._vnode;
  6437. }
  6438. return isDef(vnode.tag);
  6439. }
  6440. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6441. for (let i = 0; i < cbs.create.length; ++i) {
  6442. cbs.create[i](emptyNode, vnode);
  6443. }
  6444. i = vnode.data.hook; // Reuse variable
  6445. if (isDef(i)) {
  6446. if (isDef(i.create))
  6447. i.create(emptyNode, vnode);
  6448. if (isDef(i.insert))
  6449. insertedVnodeQueue.push(vnode);
  6450. }
  6451. }
  6452. // set scope id attribute for scoped CSS.
  6453. // this is implemented as a special case to avoid the overhead
  6454. // of going through the normal attribute patching process.
  6455. function setScope(vnode) {
  6456. let i;
  6457. if (isDef((i = vnode.fnScopeId))) {
  6458. nodeOps.setStyleScope(vnode.elm, i);
  6459. }
  6460. else {
  6461. let ancestor = vnode;
  6462. while (ancestor) {
  6463. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6464. nodeOps.setStyleScope(vnode.elm, i);
  6465. }
  6466. ancestor = ancestor.parent;
  6467. }
  6468. }
  6469. // for slot content they should also get the scopeId from the host instance.
  6470. if (isDef((i = activeInstance)) &&
  6471. i !== vnode.context &&
  6472. i !== vnode.fnContext &&
  6473. isDef((i = i.$options._scopeId))) {
  6474. nodeOps.setStyleScope(vnode.elm, i);
  6475. }
  6476. }
  6477. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6478. for (; startIdx <= endIdx; ++startIdx) {
  6479. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6480. }
  6481. }
  6482. function invokeDestroyHook(vnode) {
  6483. let i, j;
  6484. const data = vnode.data;
  6485. if (isDef(data)) {
  6486. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6487. i(vnode);
  6488. for (i = 0; i < cbs.destroy.length; ++i)
  6489. cbs.destroy[i](vnode);
  6490. }
  6491. if (isDef((i = vnode.children))) {
  6492. for (j = 0; j < vnode.children.length; ++j) {
  6493. invokeDestroyHook(vnode.children[j]);
  6494. }
  6495. }
  6496. }
  6497. function removeVnodes(vnodes, startIdx, endIdx) {
  6498. for (; startIdx <= endIdx; ++startIdx) {
  6499. const ch = vnodes[startIdx];
  6500. if (isDef(ch)) {
  6501. if (isDef(ch.tag)) {
  6502. removeAndInvokeRemoveHook(ch);
  6503. invokeDestroyHook(ch);
  6504. }
  6505. else {
  6506. // Text node
  6507. removeNode(ch.elm);
  6508. }
  6509. }
  6510. }
  6511. }
  6512. function removeAndInvokeRemoveHook(vnode, rm) {
  6513. if (isDef(rm) || isDef(vnode.data)) {
  6514. let i;
  6515. const listeners = cbs.remove.length + 1;
  6516. if (isDef(rm)) {
  6517. // we have a recursively passed down rm callback
  6518. // increase the listeners count
  6519. rm.listeners += listeners;
  6520. }
  6521. else {
  6522. // directly removing
  6523. rm = createRmCb(vnode.elm, listeners);
  6524. }
  6525. // recursively invoke hooks on child component root node
  6526. if (isDef((i = vnode.componentInstance)) &&
  6527. isDef((i = i._vnode)) &&
  6528. isDef(i.data)) {
  6529. removeAndInvokeRemoveHook(i, rm);
  6530. }
  6531. for (i = 0; i < cbs.remove.length; ++i) {
  6532. cbs.remove[i](vnode, rm);
  6533. }
  6534. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6535. i(vnode, rm);
  6536. }
  6537. else {
  6538. rm();
  6539. }
  6540. }
  6541. else {
  6542. removeNode(vnode.elm);
  6543. }
  6544. }
  6545. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6546. let oldStartIdx = 0;
  6547. let newStartIdx = 0;
  6548. let oldEndIdx = oldCh.length - 1;
  6549. let oldStartVnode = oldCh[0];
  6550. let oldEndVnode = oldCh[oldEndIdx];
  6551. let newEndIdx = newCh.length - 1;
  6552. let newStartVnode = newCh[0];
  6553. let newEndVnode = newCh[newEndIdx];
  6554. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6555. // removeOnly is a special flag used only by <transition-group>
  6556. // to ensure removed elements stay in correct relative positions
  6557. // during leaving transitions
  6558. const canMove = !removeOnly;
  6559. {
  6560. checkDuplicateKeys(newCh);
  6561. }
  6562. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6563. if (isUndef(oldStartVnode)) {
  6564. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6565. }
  6566. else if (isUndef(oldEndVnode)) {
  6567. oldEndVnode = oldCh[--oldEndIdx];
  6568. }
  6569. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6570. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6571. oldStartVnode = oldCh[++oldStartIdx];
  6572. newStartVnode = newCh[++newStartIdx];
  6573. }
  6574. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6575. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6576. oldEndVnode = oldCh[--oldEndIdx];
  6577. newEndVnode = newCh[--newEndIdx];
  6578. }
  6579. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6580. // Vnode moved right
  6581. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6582. canMove &&
  6583. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6584. oldStartVnode = oldCh[++oldStartIdx];
  6585. newEndVnode = newCh[--newEndIdx];
  6586. }
  6587. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6588. // Vnode moved left
  6589. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6590. canMove &&
  6591. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6592. oldEndVnode = oldCh[--oldEndIdx];
  6593. newStartVnode = newCh[++newStartIdx];
  6594. }
  6595. else {
  6596. if (isUndef(oldKeyToIdx))
  6597. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6598. idxInOld = isDef(newStartVnode.key)
  6599. ? oldKeyToIdx[newStartVnode.key]
  6600. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6601. if (isUndef(idxInOld)) {
  6602. // New element
  6603. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6604. }
  6605. else {
  6606. vnodeToMove = oldCh[idxInOld];
  6607. if (sameVnode(vnodeToMove, newStartVnode)) {
  6608. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6609. oldCh[idxInOld] = undefined;
  6610. canMove &&
  6611. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6612. }
  6613. else {
  6614. // same key but different element. treat as new element
  6615. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6616. }
  6617. }
  6618. newStartVnode = newCh[++newStartIdx];
  6619. }
  6620. }
  6621. if (oldStartIdx > oldEndIdx) {
  6622. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6623. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6624. }
  6625. else if (newStartIdx > newEndIdx) {
  6626. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6627. }
  6628. }
  6629. function checkDuplicateKeys(children) {
  6630. const seenKeys = {};
  6631. for (let i = 0; i < children.length; i++) {
  6632. const vnode = children[i];
  6633. const key = vnode.key;
  6634. if (isDef(key)) {
  6635. if (seenKeys[key]) {
  6636. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6637. }
  6638. else {
  6639. seenKeys[key] = true;
  6640. }
  6641. }
  6642. }
  6643. }
  6644. function findIdxInOld(node, oldCh, start, end) {
  6645. for (let i = start; i < end; i++) {
  6646. const c = oldCh[i];
  6647. if (isDef(c) && sameVnode(node, c))
  6648. return i;
  6649. }
  6650. }
  6651. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6652. if (oldVnode === vnode) {
  6653. return;
  6654. }
  6655. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6656. // clone reused vnode
  6657. vnode = ownerArray[index] = cloneVNode(vnode);
  6658. }
  6659. const elm = (vnode.elm = oldVnode.elm);
  6660. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6661. if (isDef(vnode.asyncFactory.resolved)) {
  6662. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6663. }
  6664. else {
  6665. vnode.isAsyncPlaceholder = true;
  6666. }
  6667. return;
  6668. }
  6669. // reuse element for static trees.
  6670. // note we only do this if the vnode is cloned -
  6671. // if the new node is not cloned it means the render functions have been
  6672. // reset by the hot-reload-api and we need to do a proper re-render.
  6673. if (isTrue(vnode.isStatic) &&
  6674. isTrue(oldVnode.isStatic) &&
  6675. vnode.key === oldVnode.key &&
  6676. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6677. vnode.componentInstance = oldVnode.componentInstance;
  6678. return;
  6679. }
  6680. let i;
  6681. const data = vnode.data;
  6682. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6683. i(oldVnode, vnode);
  6684. }
  6685. const oldCh = oldVnode.children;
  6686. const ch = vnode.children;
  6687. if (isDef(data) && isPatchable(vnode)) {
  6688. for (i = 0; i < cbs.update.length; ++i)
  6689. cbs.update[i](oldVnode, vnode);
  6690. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6691. i(oldVnode, vnode);
  6692. }
  6693. if (isUndef(vnode.text)) {
  6694. if (isDef(oldCh) && isDef(ch)) {
  6695. if (oldCh !== ch)
  6696. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6697. }
  6698. else if (isDef(ch)) {
  6699. {
  6700. checkDuplicateKeys(ch);
  6701. }
  6702. if (isDef(oldVnode.text))
  6703. nodeOps.setTextContent(elm, '');
  6704. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6705. }
  6706. else if (isDef(oldCh)) {
  6707. removeVnodes(oldCh, 0, oldCh.length - 1);
  6708. }
  6709. else if (isDef(oldVnode.text)) {
  6710. nodeOps.setTextContent(elm, '');
  6711. }
  6712. }
  6713. else if (oldVnode.text !== vnode.text) {
  6714. nodeOps.setTextContent(elm, vnode.text);
  6715. }
  6716. if (isDef(data)) {
  6717. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6718. i(oldVnode, vnode);
  6719. }
  6720. }
  6721. function invokeInsertHook(vnode, queue, initial) {
  6722. // delay insert hooks for component root nodes, invoke them after the
  6723. // element is really inserted
  6724. if (isTrue(initial) && isDef(vnode.parent)) {
  6725. vnode.parent.data.pendingInsert = queue;
  6726. }
  6727. else {
  6728. for (let i = 0; i < queue.length; ++i) {
  6729. queue[i].data.hook.insert(queue[i]);
  6730. }
  6731. }
  6732. }
  6733. let hydrationBailed = false;
  6734. // list of modules that can skip create hook during hydration because they
  6735. // are already rendered on the client or has no need for initialization
  6736. // Note: style is excluded because it relies on initial clone for future
  6737. // deep updates (#7063).
  6738. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6739. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6740. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6741. let i;
  6742. const { tag, data, children } = vnode;
  6743. inVPre = inVPre || (data && data.pre);
  6744. vnode.elm = elm;
  6745. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6746. vnode.isAsyncPlaceholder = true;
  6747. return true;
  6748. }
  6749. // assert node match
  6750. {
  6751. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6752. return false;
  6753. }
  6754. }
  6755. if (isDef(data)) {
  6756. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6757. i(vnode, true /* hydrating */);
  6758. if (isDef((i = vnode.componentInstance))) {
  6759. // child component. it should have hydrated its own tree.
  6760. initComponent(vnode, insertedVnodeQueue);
  6761. return true;
  6762. }
  6763. }
  6764. if (isDef(tag)) {
  6765. if (isDef(children)) {
  6766. // empty element, allow client to pick up and populate children
  6767. if (!elm.hasChildNodes()) {
  6768. createChildren(vnode, children, insertedVnodeQueue);
  6769. }
  6770. else {
  6771. // v-html and domProps: innerHTML
  6772. if (isDef((i = data)) &&
  6773. isDef((i = i.domProps)) &&
  6774. isDef((i = i.innerHTML))) {
  6775. if (i !== elm.innerHTML) {
  6776. /* istanbul ignore if */
  6777. if (typeof console !== 'undefined' &&
  6778. !hydrationBailed) {
  6779. hydrationBailed = true;
  6780. console.warn('Parent: ', elm);
  6781. console.warn('server innerHTML: ', i);
  6782. console.warn('client innerHTML: ', elm.innerHTML);
  6783. }
  6784. return false;
  6785. }
  6786. }
  6787. else {
  6788. // iterate and compare children lists
  6789. let childrenMatch = true;
  6790. let childNode = elm.firstChild;
  6791. for (let i = 0; i < children.length; i++) {
  6792. if (!childNode ||
  6793. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6794. childrenMatch = false;
  6795. break;
  6796. }
  6797. childNode = childNode.nextSibling;
  6798. }
  6799. // if childNode is not null, it means the actual childNodes list is
  6800. // longer than the virtual children list.
  6801. if (!childrenMatch || childNode) {
  6802. /* istanbul ignore if */
  6803. if (typeof console !== 'undefined' &&
  6804. !hydrationBailed) {
  6805. hydrationBailed = true;
  6806. console.warn('Parent: ', elm);
  6807. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6808. }
  6809. return false;
  6810. }
  6811. }
  6812. }
  6813. }
  6814. if (isDef(data)) {
  6815. let fullInvoke = false;
  6816. for (const key in data) {
  6817. if (!isRenderedModule(key)) {
  6818. fullInvoke = true;
  6819. invokeCreateHooks(vnode, insertedVnodeQueue);
  6820. break;
  6821. }
  6822. }
  6823. if (!fullInvoke && data['class']) {
  6824. // ensure collecting deps for deep class bindings for future updates
  6825. traverse(data['class']);
  6826. }
  6827. }
  6828. }
  6829. else if (elm.data !== vnode.text) {
  6830. elm.data = vnode.text;
  6831. }
  6832. return true;
  6833. }
  6834. function assertNodeMatch(node, vnode, inVPre) {
  6835. if (isDef(vnode.tag)) {
  6836. return (vnode.tag.indexOf('vue-component') === 0 ||
  6837. (!isUnknownElement(vnode, inVPre) &&
  6838. vnode.tag.toLowerCase() ===
  6839. (node.tagName && node.tagName.toLowerCase())));
  6840. }
  6841. else {
  6842. return node.nodeType === (vnode.isComment ? 8 : 3);
  6843. }
  6844. }
  6845. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6846. if (isUndef(vnode)) {
  6847. if (isDef(oldVnode))
  6848. invokeDestroyHook(oldVnode);
  6849. return;
  6850. }
  6851. let isInitialPatch = false;
  6852. const insertedVnodeQueue = [];
  6853. if (isUndef(oldVnode)) {
  6854. // empty mount (likely as component), create new root element
  6855. isInitialPatch = true;
  6856. createElm(vnode, insertedVnodeQueue);
  6857. }
  6858. else {
  6859. const isRealElement = isDef(oldVnode.nodeType);
  6860. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6861. // patch existing root node
  6862. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6863. }
  6864. else {
  6865. if (isRealElement) {
  6866. // mounting to a real element
  6867. // check if this is server-rendered content and if we can perform
  6868. // a successful hydration.
  6869. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6870. oldVnode.removeAttribute(SSR_ATTR);
  6871. hydrating = true;
  6872. }
  6873. if (isTrue(hydrating)) {
  6874. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6875. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6876. return oldVnode;
  6877. }
  6878. else {
  6879. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6880. 'server-rendered content. This is likely caused by incorrect ' +
  6881. 'HTML markup, for example nesting block-level elements inside ' +
  6882. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6883. 'full client-side render.');
  6884. }
  6885. }
  6886. // either not server-rendered, or hydration failed.
  6887. // create an empty node and replace it
  6888. oldVnode = emptyNodeAt(oldVnode);
  6889. }
  6890. // replacing existing element
  6891. const oldElm = oldVnode.elm;
  6892. const parentElm = nodeOps.parentNode(oldElm);
  6893. // create new node
  6894. createElm(vnode, insertedVnodeQueue,
  6895. // extremely rare edge case: do not insert if old element is in a
  6896. // leaving transition. Only happens when combining transition +
  6897. // keep-alive + HOCs. (#4590)
  6898. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6899. // update parent placeholder node element, recursively
  6900. if (isDef(vnode.parent)) {
  6901. let ancestor = vnode.parent;
  6902. const patchable = isPatchable(vnode);
  6903. while (ancestor) {
  6904. for (let i = 0; i < cbs.destroy.length; ++i) {
  6905. cbs.destroy[i](ancestor);
  6906. }
  6907. ancestor.elm = vnode.elm;
  6908. if (patchable) {
  6909. for (let i = 0; i < cbs.create.length; ++i) {
  6910. cbs.create[i](emptyNode, ancestor);
  6911. }
  6912. // #6513
  6913. // invoke insert hooks that may have been merged by create hooks.
  6914. // e.g. for directives that uses the "inserted" hook.
  6915. const insert = ancestor.data.hook.insert;
  6916. if (insert.merged) {
  6917. // start at index 1 to avoid re-invoking component mounted hook
  6918. for (let i = 1; i < insert.fns.length; i++) {
  6919. insert.fns[i]();
  6920. }
  6921. }
  6922. }
  6923. else {
  6924. registerRef(ancestor);
  6925. }
  6926. ancestor = ancestor.parent;
  6927. }
  6928. }
  6929. // destroy old node
  6930. if (isDef(parentElm)) {
  6931. removeVnodes([oldVnode], 0, 0);
  6932. }
  6933. else if (isDef(oldVnode.tag)) {
  6934. invokeDestroyHook(oldVnode);
  6935. }
  6936. }
  6937. }
  6938. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6939. return vnode.elm;
  6940. };
  6941. }
  6942. var directives$1 = {
  6943. create: updateDirectives,
  6944. update: updateDirectives,
  6945. destroy: function unbindDirectives(vnode) {
  6946. // @ts-expect-error emptyNode is not VNodeWithData
  6947. updateDirectives(vnode, emptyNode);
  6948. }
  6949. };
  6950. function updateDirectives(oldVnode, vnode) {
  6951. if (oldVnode.data.directives || vnode.data.directives) {
  6952. _update(oldVnode, vnode);
  6953. }
  6954. }
  6955. function _update(oldVnode, vnode) {
  6956. const isCreate = oldVnode === emptyNode;
  6957. const isDestroy = vnode === emptyNode;
  6958. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  6959. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  6960. const dirsWithInsert = [];
  6961. const dirsWithPostpatch = [];
  6962. let key, oldDir, dir;
  6963. for (key in newDirs) {
  6964. oldDir = oldDirs[key];
  6965. dir = newDirs[key];
  6966. if (!oldDir) {
  6967. // new directive, bind
  6968. callHook(dir, 'bind', vnode, oldVnode);
  6969. if (dir.def && dir.def.inserted) {
  6970. dirsWithInsert.push(dir);
  6971. }
  6972. }
  6973. else {
  6974. // existing directive, update
  6975. dir.oldValue = oldDir.value;
  6976. dir.oldArg = oldDir.arg;
  6977. callHook(dir, 'update', vnode, oldVnode);
  6978. if (dir.def && dir.def.componentUpdated) {
  6979. dirsWithPostpatch.push(dir);
  6980. }
  6981. }
  6982. }
  6983. if (dirsWithInsert.length) {
  6984. const callInsert = () => {
  6985. for (let i = 0; i < dirsWithInsert.length; i++) {
  6986. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  6987. }
  6988. };
  6989. if (isCreate) {
  6990. mergeVNodeHook(vnode, 'insert', callInsert);
  6991. }
  6992. else {
  6993. callInsert();
  6994. }
  6995. }
  6996. if (dirsWithPostpatch.length) {
  6997. mergeVNodeHook(vnode, 'postpatch', () => {
  6998. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  6999. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7000. }
  7001. });
  7002. }
  7003. if (!isCreate) {
  7004. for (key in oldDirs) {
  7005. if (!newDirs[key]) {
  7006. // no longer present, unbind
  7007. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7008. }
  7009. }
  7010. }
  7011. }
  7012. const emptyModifiers = Object.create(null);
  7013. function normalizeDirectives(dirs, vm) {
  7014. const res = Object.create(null);
  7015. if (!dirs) {
  7016. // $flow-disable-line
  7017. return res;
  7018. }
  7019. let i, dir;
  7020. for (i = 0; i < dirs.length; i++) {
  7021. dir = dirs[i];
  7022. if (!dir.modifiers) {
  7023. // $flow-disable-line
  7024. dir.modifiers = emptyModifiers;
  7025. }
  7026. res[getRawDirName(dir)] = dir;
  7027. if (vm._setupState && vm._setupState.__sfc) {
  7028. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7029. if (typeof setupDef === 'function') {
  7030. dir.def = {
  7031. bind: setupDef,
  7032. update: setupDef,
  7033. };
  7034. }
  7035. else {
  7036. dir.def = setupDef;
  7037. }
  7038. }
  7039. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7040. }
  7041. // $flow-disable-line
  7042. return res;
  7043. }
  7044. function getRawDirName(dir) {
  7045. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7046. }
  7047. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7048. const fn = dir.def && dir.def[hook];
  7049. if (fn) {
  7050. try {
  7051. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7052. }
  7053. catch (e) {
  7054. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7055. }
  7056. }
  7057. }
  7058. var baseModules = [ref, directives$1];
  7059. function updateAttrs(oldVnode, vnode) {
  7060. const opts = vnode.componentOptions;
  7061. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7062. return;
  7063. }
  7064. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7065. return;
  7066. }
  7067. let key, cur, old;
  7068. const elm = vnode.elm;
  7069. const oldAttrs = oldVnode.data.attrs || {};
  7070. let attrs = vnode.data.attrs || {};
  7071. // clone observed objects, as the user probably wants to mutate it
  7072. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7073. attrs = vnode.data.attrs = extend({}, attrs);
  7074. }
  7075. for (key in attrs) {
  7076. cur = attrs[key];
  7077. old = oldAttrs[key];
  7078. if (old !== cur) {
  7079. setAttr(elm, key, cur, vnode.data.pre);
  7080. }
  7081. }
  7082. // #4391: in IE9, setting type can reset value for input[type=radio]
  7083. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7084. /* istanbul ignore if */
  7085. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7086. setAttr(elm, 'value', attrs.value);
  7087. }
  7088. for (key in oldAttrs) {
  7089. if (isUndef(attrs[key])) {
  7090. if (isXlink(key)) {
  7091. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7092. }
  7093. else if (!isEnumeratedAttr(key)) {
  7094. elm.removeAttribute(key);
  7095. }
  7096. }
  7097. }
  7098. }
  7099. function setAttr(el, key, value, isInPre) {
  7100. if (isInPre || el.tagName.indexOf('-') > -1) {
  7101. baseSetAttr(el, key, value);
  7102. }
  7103. else if (isBooleanAttr(key)) {
  7104. // set attribute for blank value
  7105. // e.g. <option disabled>Select one</option>
  7106. if (isFalsyAttrValue(value)) {
  7107. el.removeAttribute(key);
  7108. }
  7109. else {
  7110. // technically allowfullscreen is a boolean attribute for <iframe>,
  7111. // but Flash expects a value of "true" when used on <embed> tag
  7112. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7113. el.setAttribute(key, value);
  7114. }
  7115. }
  7116. else if (isEnumeratedAttr(key)) {
  7117. el.setAttribute(key, convertEnumeratedValue(key, value));
  7118. }
  7119. else if (isXlink(key)) {
  7120. if (isFalsyAttrValue(value)) {
  7121. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7122. }
  7123. else {
  7124. el.setAttributeNS(xlinkNS, key, value);
  7125. }
  7126. }
  7127. else {
  7128. baseSetAttr(el, key, value);
  7129. }
  7130. }
  7131. function baseSetAttr(el, key, value) {
  7132. if (isFalsyAttrValue(value)) {
  7133. el.removeAttribute(key);
  7134. }
  7135. else {
  7136. // #7138: IE10 & 11 fires input event when setting placeholder on
  7137. // <textarea>... block the first input event and remove the blocker
  7138. // immediately.
  7139. /* istanbul ignore if */
  7140. if (isIE &&
  7141. !isIE9 &&
  7142. el.tagName === 'TEXTAREA' &&
  7143. key === 'placeholder' &&
  7144. value !== '' &&
  7145. !el.__ieph) {
  7146. const blocker = e => {
  7147. e.stopImmediatePropagation();
  7148. el.removeEventListener('input', blocker);
  7149. };
  7150. el.addEventListener('input', blocker);
  7151. // $flow-disable-line
  7152. el.__ieph = true; /* IE placeholder patched */
  7153. }
  7154. el.setAttribute(key, value);
  7155. }
  7156. }
  7157. var attrs = {
  7158. create: updateAttrs,
  7159. update: updateAttrs
  7160. };
  7161. function updateClass(oldVnode, vnode) {
  7162. const el = vnode.elm;
  7163. const data = vnode.data;
  7164. const oldData = oldVnode.data;
  7165. if (isUndef(data.staticClass) &&
  7166. isUndef(data.class) &&
  7167. (isUndef(oldData) ||
  7168. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7169. return;
  7170. }
  7171. let cls = genClassForVnode(vnode);
  7172. // handle transition classes
  7173. const transitionClass = el._transitionClasses;
  7174. if (isDef(transitionClass)) {
  7175. cls = concat(cls, stringifyClass(transitionClass));
  7176. }
  7177. // set the class
  7178. if (cls !== el._prevClass) {
  7179. el.setAttribute('class', cls);
  7180. el._prevClass = cls;
  7181. }
  7182. }
  7183. var klass$1 = {
  7184. create: updateClass,
  7185. update: updateClass
  7186. };
  7187. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7188. function parseFilters(exp) {
  7189. let inSingle = false;
  7190. let inDouble = false;
  7191. let inTemplateString = false;
  7192. let inRegex = false;
  7193. let curly = 0;
  7194. let square = 0;
  7195. let paren = 0;
  7196. let lastFilterIndex = 0;
  7197. let c, prev, i, expression, filters;
  7198. for (i = 0; i < exp.length; i++) {
  7199. prev = c;
  7200. c = exp.charCodeAt(i);
  7201. if (inSingle) {
  7202. if (c === 0x27 && prev !== 0x5c)
  7203. inSingle = false;
  7204. }
  7205. else if (inDouble) {
  7206. if (c === 0x22 && prev !== 0x5c)
  7207. inDouble = false;
  7208. }
  7209. else if (inTemplateString) {
  7210. if (c === 0x60 && prev !== 0x5c)
  7211. inTemplateString = false;
  7212. }
  7213. else if (inRegex) {
  7214. if (c === 0x2f && prev !== 0x5c)
  7215. inRegex = false;
  7216. }
  7217. else if (c === 0x7c && // pipe
  7218. exp.charCodeAt(i + 1) !== 0x7c &&
  7219. exp.charCodeAt(i - 1) !== 0x7c &&
  7220. !curly &&
  7221. !square &&
  7222. !paren) {
  7223. if (expression === undefined) {
  7224. // first filter, end of expression
  7225. lastFilterIndex = i + 1;
  7226. expression = exp.slice(0, i).trim();
  7227. }
  7228. else {
  7229. pushFilter();
  7230. }
  7231. }
  7232. else {
  7233. switch (c) {
  7234. case 0x22:
  7235. inDouble = true;
  7236. break; // "
  7237. case 0x27:
  7238. inSingle = true;
  7239. break; // '
  7240. case 0x60:
  7241. inTemplateString = true;
  7242. break; // `
  7243. case 0x28:
  7244. paren++;
  7245. break; // (
  7246. case 0x29:
  7247. paren--;
  7248. break; // )
  7249. case 0x5b:
  7250. square++;
  7251. break; // [
  7252. case 0x5d:
  7253. square--;
  7254. break; // ]
  7255. case 0x7b:
  7256. curly++;
  7257. break; // {
  7258. case 0x7d:
  7259. curly--;
  7260. break; // }
  7261. }
  7262. if (c === 0x2f) {
  7263. // /
  7264. let j = i - 1;
  7265. let p;
  7266. // find first non-whitespace prev char
  7267. for (; j >= 0; j--) {
  7268. p = exp.charAt(j);
  7269. if (p !== ' ')
  7270. break;
  7271. }
  7272. if (!p || !validDivisionCharRE.test(p)) {
  7273. inRegex = true;
  7274. }
  7275. }
  7276. }
  7277. }
  7278. if (expression === undefined) {
  7279. expression = exp.slice(0, i).trim();
  7280. }
  7281. else if (lastFilterIndex !== 0) {
  7282. pushFilter();
  7283. }
  7284. function pushFilter() {
  7285. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7286. lastFilterIndex = i + 1;
  7287. }
  7288. if (filters) {
  7289. for (i = 0; i < filters.length; i++) {
  7290. expression = wrapFilter(expression, filters[i]);
  7291. }
  7292. }
  7293. return expression;
  7294. }
  7295. function wrapFilter(exp, filter) {
  7296. const i = filter.indexOf('(');
  7297. if (i < 0) {
  7298. // _f: resolveFilter
  7299. return `_f("${filter}")(${exp})`;
  7300. }
  7301. else {
  7302. const name = filter.slice(0, i);
  7303. const args = filter.slice(i + 1);
  7304. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7305. }
  7306. }
  7307. /* eslint-disable no-unused-vars */
  7308. function baseWarn(msg, range) {
  7309. console.error(`[Vue compiler]: ${msg}`);
  7310. }
  7311. /* eslint-enable no-unused-vars */
  7312. function pluckModuleFunction(modules, key) {
  7313. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7314. }
  7315. function addProp(el, name, value, range, dynamic) {
  7316. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7317. el.plain = false;
  7318. }
  7319. function addAttr(el, name, value, range, dynamic) {
  7320. const attrs = dynamic
  7321. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7322. : el.attrs || (el.attrs = []);
  7323. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7324. el.plain = false;
  7325. }
  7326. // add a raw attr (use this in preTransforms)
  7327. function addRawAttr(el, name, value, range) {
  7328. el.attrsMap[name] = value;
  7329. el.attrsList.push(rangeSetItem({ name, value }, range));
  7330. }
  7331. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7332. (el.directives || (el.directives = [])).push(rangeSetItem({
  7333. name,
  7334. rawName,
  7335. value,
  7336. arg,
  7337. isDynamicArg,
  7338. modifiers
  7339. }, range));
  7340. el.plain = false;
  7341. }
  7342. function prependModifierMarker(symbol, name, dynamic) {
  7343. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7344. }
  7345. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7346. modifiers = modifiers || emptyObject;
  7347. // warn prevent and passive modifier
  7348. /* istanbul ignore if */
  7349. if (warn && modifiers.prevent && modifiers.passive) {
  7350. warn("passive and prevent can't be used together. " +
  7351. "Passive handler can't prevent default event.", range);
  7352. }
  7353. // normalize click.right and click.middle since they don't actually fire
  7354. // this is technically browser-specific, but at least for now browsers are
  7355. // the only target envs that have right/middle clicks.
  7356. if (modifiers.right) {
  7357. if (dynamic) {
  7358. name = `(${name})==='click'?'contextmenu':(${name})`;
  7359. }
  7360. else if (name === 'click') {
  7361. name = 'contextmenu';
  7362. delete modifiers.right;
  7363. }
  7364. }
  7365. else if (modifiers.middle) {
  7366. if (dynamic) {
  7367. name = `(${name})==='click'?'mouseup':(${name})`;
  7368. }
  7369. else if (name === 'click') {
  7370. name = 'mouseup';
  7371. }
  7372. }
  7373. // check capture modifier
  7374. if (modifiers.capture) {
  7375. delete modifiers.capture;
  7376. name = prependModifierMarker('!', name, dynamic);
  7377. }
  7378. if (modifiers.once) {
  7379. delete modifiers.once;
  7380. name = prependModifierMarker('~', name, dynamic);
  7381. }
  7382. /* istanbul ignore if */
  7383. if (modifiers.passive) {
  7384. delete modifiers.passive;
  7385. name = prependModifierMarker('&', name, dynamic);
  7386. }
  7387. let events;
  7388. if (modifiers.native) {
  7389. delete modifiers.native;
  7390. events = el.nativeEvents || (el.nativeEvents = {});
  7391. }
  7392. else {
  7393. events = el.events || (el.events = {});
  7394. }
  7395. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7396. if (modifiers !== emptyObject) {
  7397. newHandler.modifiers = modifiers;
  7398. }
  7399. const handlers = events[name];
  7400. /* istanbul ignore if */
  7401. if (Array.isArray(handlers)) {
  7402. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7403. }
  7404. else if (handlers) {
  7405. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7406. }
  7407. else {
  7408. events[name] = newHandler;
  7409. }
  7410. el.plain = false;
  7411. }
  7412. function getRawBindingAttr(el, name) {
  7413. return (el.rawAttrsMap[':' + name] ||
  7414. el.rawAttrsMap['v-bind:' + name] ||
  7415. el.rawAttrsMap[name]);
  7416. }
  7417. function getBindingAttr(el, name, getStatic) {
  7418. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7419. if (dynamicValue != null) {
  7420. return parseFilters(dynamicValue);
  7421. }
  7422. else if (getStatic !== false) {
  7423. const staticValue = getAndRemoveAttr(el, name);
  7424. if (staticValue != null) {
  7425. return JSON.stringify(staticValue);
  7426. }
  7427. }
  7428. }
  7429. // note: this only removes the attr from the Array (attrsList) so that it
  7430. // doesn't get processed by processAttrs.
  7431. // By default it does NOT remove it from the map (attrsMap) because the map is
  7432. // needed during codegen.
  7433. function getAndRemoveAttr(el, name, removeFromMap) {
  7434. let val;
  7435. if ((val = el.attrsMap[name]) != null) {
  7436. const list = el.attrsList;
  7437. for (let i = 0, l = list.length; i < l; i++) {
  7438. if (list[i].name === name) {
  7439. list.splice(i, 1);
  7440. break;
  7441. }
  7442. }
  7443. }
  7444. if (removeFromMap) {
  7445. delete el.attrsMap[name];
  7446. }
  7447. return val;
  7448. }
  7449. function getAndRemoveAttrByRegex(el, name) {
  7450. const list = el.attrsList;
  7451. for (let i = 0, l = list.length; i < l; i++) {
  7452. const attr = list[i];
  7453. if (name.test(attr.name)) {
  7454. list.splice(i, 1);
  7455. return attr;
  7456. }
  7457. }
  7458. }
  7459. function rangeSetItem(item, range) {
  7460. if (range) {
  7461. if (range.start != null) {
  7462. item.start = range.start;
  7463. }
  7464. if (range.end != null) {
  7465. item.end = range.end;
  7466. }
  7467. }
  7468. return item;
  7469. }
  7470. /**
  7471. * Cross-platform code generation for component v-model
  7472. */
  7473. function genComponentModel(el, value, modifiers) {
  7474. const { number, trim } = modifiers || {};
  7475. const baseValueExpression = '$$v';
  7476. let valueExpression = baseValueExpression;
  7477. if (trim) {
  7478. valueExpression =
  7479. `(typeof ${baseValueExpression} === 'string'` +
  7480. `? ${baseValueExpression}.trim()` +
  7481. `: ${baseValueExpression})`;
  7482. }
  7483. if (number) {
  7484. valueExpression = `_n(${valueExpression})`;
  7485. }
  7486. const assignment = genAssignmentCode(value, valueExpression);
  7487. el.model = {
  7488. value: `(${value})`,
  7489. expression: JSON.stringify(value),
  7490. callback: `function (${baseValueExpression}) {${assignment}}`
  7491. };
  7492. }
  7493. /**
  7494. * Cross-platform codegen helper for generating v-model value assignment code.
  7495. */
  7496. function genAssignmentCode(value, assignment) {
  7497. const res = parseModel(value);
  7498. if (res.key === null) {
  7499. return `${value}=${assignment}`;
  7500. }
  7501. else {
  7502. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7503. }
  7504. }
  7505. /**
  7506. * Parse a v-model expression into a base path and a final key segment.
  7507. * Handles both dot-path and possible square brackets.
  7508. *
  7509. * Possible cases:
  7510. *
  7511. * - test
  7512. * - test[key]
  7513. * - test[test1[key]]
  7514. * - test["a"][key]
  7515. * - xxx.test[a[a].test1[key]]
  7516. * - test.xxx.a["asa"][test1[key]]
  7517. *
  7518. */
  7519. let len, str, chr, index, expressionPos, expressionEndPos;
  7520. function parseModel(val) {
  7521. // Fix https://github.com/vuejs/vue/pull/7730
  7522. // allow v-model="obj.val " (trailing whitespace)
  7523. val = val.trim();
  7524. len = val.length;
  7525. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7526. index = val.lastIndexOf('.');
  7527. if (index > -1) {
  7528. return {
  7529. exp: val.slice(0, index),
  7530. key: '"' + val.slice(index + 1) + '"'
  7531. };
  7532. }
  7533. else {
  7534. return {
  7535. exp: val,
  7536. key: null
  7537. };
  7538. }
  7539. }
  7540. str = val;
  7541. index = expressionPos = expressionEndPos = 0;
  7542. while (!eof()) {
  7543. chr = next();
  7544. /* istanbul ignore if */
  7545. if (isStringStart(chr)) {
  7546. parseString(chr);
  7547. }
  7548. else if (chr === 0x5b) {
  7549. parseBracket(chr);
  7550. }
  7551. }
  7552. return {
  7553. exp: val.slice(0, expressionPos),
  7554. key: val.slice(expressionPos + 1, expressionEndPos)
  7555. };
  7556. }
  7557. function next() {
  7558. return str.charCodeAt(++index);
  7559. }
  7560. function eof() {
  7561. return index >= len;
  7562. }
  7563. function isStringStart(chr) {
  7564. return chr === 0x22 || chr === 0x27;
  7565. }
  7566. function parseBracket(chr) {
  7567. let inBracket = 1;
  7568. expressionPos = index;
  7569. while (!eof()) {
  7570. chr = next();
  7571. if (isStringStart(chr)) {
  7572. parseString(chr);
  7573. continue;
  7574. }
  7575. if (chr === 0x5b)
  7576. inBracket++;
  7577. if (chr === 0x5d)
  7578. inBracket--;
  7579. if (inBracket === 0) {
  7580. expressionEndPos = index;
  7581. break;
  7582. }
  7583. }
  7584. }
  7585. function parseString(chr) {
  7586. const stringQuote = chr;
  7587. while (!eof()) {
  7588. chr = next();
  7589. if (chr === stringQuote) {
  7590. break;
  7591. }
  7592. }
  7593. }
  7594. let warn$1;
  7595. // in some cases, the event used has to be determined at runtime
  7596. // so we used some reserved tokens during compile.
  7597. const RANGE_TOKEN = '__r';
  7598. const CHECKBOX_RADIO_TOKEN = '__c';
  7599. function model$1(el, dir, _warn) {
  7600. warn$1 = _warn;
  7601. const value = dir.value;
  7602. const modifiers = dir.modifiers;
  7603. const tag = el.tag;
  7604. const type = el.attrsMap.type;
  7605. {
  7606. // inputs with type="file" are read only and setting the input's
  7607. // value will throw an error.
  7608. if (tag === 'input' && type === 'file') {
  7609. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7610. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7611. }
  7612. }
  7613. if (el.component) {
  7614. genComponentModel(el, value, modifiers);
  7615. // component v-model doesn't need extra runtime
  7616. return false;
  7617. }
  7618. else if (tag === 'select') {
  7619. genSelect(el, value, modifiers);
  7620. }
  7621. else if (tag === 'input' && type === 'checkbox') {
  7622. genCheckboxModel(el, value, modifiers);
  7623. }
  7624. else if (tag === 'input' && type === 'radio') {
  7625. genRadioModel(el, value, modifiers);
  7626. }
  7627. else if (tag === 'input' || tag === 'textarea') {
  7628. genDefaultModel(el, value, modifiers);
  7629. }
  7630. else if (!config.isReservedTag(tag)) {
  7631. genComponentModel(el, value, modifiers);
  7632. // component v-model doesn't need extra runtime
  7633. return false;
  7634. }
  7635. else {
  7636. warn$1(`<${el.tag} v-model="${value}">: ` +
  7637. `v-model is not supported on this element type. ` +
  7638. "If you are working with contenteditable, it's recommended to " +
  7639. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7640. }
  7641. // ensure runtime directive metadata
  7642. return true;
  7643. }
  7644. function genCheckboxModel(el, value, modifiers) {
  7645. const number = modifiers && modifiers.number;
  7646. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7647. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7648. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7649. addProp(el, 'checked', `Array.isArray(${value})` +
  7650. `?_i(${value},${valueBinding})>-1` +
  7651. (trueValueBinding === 'true'
  7652. ? `:(${value})`
  7653. : `:_q(${value},${trueValueBinding})`));
  7654. addHandler(el, 'change', `var $$a=${value},` +
  7655. '$$el=$event.target,' +
  7656. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7657. 'if(Array.isArray($$a)){' +
  7658. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7659. '$$i=_i($$a,$$v);' +
  7660. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7661. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7662. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7663. }
  7664. function genRadioModel(el, value, modifiers) {
  7665. const number = modifiers && modifiers.number;
  7666. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7667. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7668. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7669. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7670. }
  7671. function genSelect(el, value, modifiers) {
  7672. const number = modifiers && modifiers.number;
  7673. const selectedVal = `Array.prototype.filter` +
  7674. `.call($event.target.options,function(o){return o.selected})` +
  7675. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7676. `return ${number ? '_n(val)' : 'val'}})`;
  7677. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7678. let code = `var $$selectedVal = ${selectedVal};`;
  7679. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7680. addHandler(el, 'change', code, null, true);
  7681. }
  7682. function genDefaultModel(el, value, modifiers) {
  7683. const type = el.attrsMap.type;
  7684. // warn if v-bind:value conflicts with v-model
  7685. // except for inputs with v-bind:type
  7686. {
  7687. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7688. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7689. if (value && !typeBinding) {
  7690. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7691. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7692. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7693. }
  7694. }
  7695. const { lazy, number, trim } = modifiers || {};
  7696. const needCompositionGuard = !lazy && type !== 'range';
  7697. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7698. let valueExpression = '$event.target.value';
  7699. if (trim) {
  7700. valueExpression = `$event.target.value.trim()`;
  7701. }
  7702. if (number) {
  7703. valueExpression = `_n(${valueExpression})`;
  7704. }
  7705. let code = genAssignmentCode(value, valueExpression);
  7706. if (needCompositionGuard) {
  7707. code = `if($event.target.composing)return;${code}`;
  7708. }
  7709. addProp(el, 'value', `(${value})`);
  7710. addHandler(el, event, code, null, true);
  7711. if (trim || number) {
  7712. addHandler(el, 'blur', '$forceUpdate()');
  7713. }
  7714. }
  7715. // normalize v-model event tokens that can only be determined at runtime.
  7716. // it's important to place the event as the first in the array because
  7717. // the whole point is ensuring the v-model callback gets called before
  7718. // user-attached handlers.
  7719. function normalizeEvents(on) {
  7720. /* istanbul ignore if */
  7721. if (isDef(on[RANGE_TOKEN])) {
  7722. // IE input[type=range] only supports `change` event
  7723. const event = isIE ? 'change' : 'input';
  7724. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7725. delete on[RANGE_TOKEN];
  7726. }
  7727. // This was originally intended to fix #4521 but no longer necessary
  7728. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7729. /* istanbul ignore if */
  7730. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7731. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7732. delete on[CHECKBOX_RADIO_TOKEN];
  7733. }
  7734. }
  7735. let target;
  7736. function createOnceHandler(event, handler, capture) {
  7737. const _target = target; // save current target element in closure
  7738. return function onceHandler() {
  7739. const res = handler.apply(null, arguments);
  7740. if (res !== null) {
  7741. remove(event, onceHandler, capture, _target);
  7742. }
  7743. };
  7744. }
  7745. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7746. // implementation and does not fire microtasks in between event propagation, so
  7747. // safe to exclude.
  7748. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7749. function add(name, handler, capture, passive) {
  7750. // async edge case #6566: inner click event triggers patch, event handler
  7751. // attached to outer element during patch, and triggered again. This
  7752. // happens because browsers fire microtask ticks between event propagation.
  7753. // the solution is simple: we save the timestamp when a handler is attached,
  7754. // and the handler would only fire if the event passed to it was fired
  7755. // AFTER it was attached.
  7756. if (useMicrotaskFix) {
  7757. const attachedTimestamp = currentFlushTimestamp;
  7758. const original = handler;
  7759. //@ts-expect-error
  7760. handler = original._wrapper = function (e) {
  7761. if (
  7762. // no bubbling, should always fire.
  7763. // this is just a safety net in case event.timeStamp is unreliable in
  7764. // certain weird environments...
  7765. e.target === e.currentTarget ||
  7766. // event is fired after handler attachment
  7767. e.timeStamp >= attachedTimestamp ||
  7768. // bail for environments that have buggy event.timeStamp implementations
  7769. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7770. // #9681 QtWebEngine event.timeStamp is negative value
  7771. e.timeStamp <= 0 ||
  7772. // #9448 bail if event is fired in another document in a multi-page
  7773. // electron/nw.js app, since event.timeStamp will be using a different
  7774. // starting reference
  7775. e.target.ownerDocument !== document) {
  7776. return original.apply(this, arguments);
  7777. }
  7778. };
  7779. }
  7780. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7781. }
  7782. function remove(name, handler, capture, _target) {
  7783. (_target || target).removeEventListener(name,
  7784. //@ts-expect-error
  7785. handler._wrapper || handler, capture);
  7786. }
  7787. function updateDOMListeners(oldVnode, vnode) {
  7788. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7789. return;
  7790. }
  7791. const on = vnode.data.on || {};
  7792. const oldOn = oldVnode.data.on || {};
  7793. // vnode is empty when removing all listeners,
  7794. // and use old vnode dom element
  7795. target = vnode.elm || oldVnode.elm;
  7796. normalizeEvents(on);
  7797. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7798. target = undefined;
  7799. }
  7800. var events = {
  7801. create: updateDOMListeners,
  7802. update: updateDOMListeners,
  7803. // @ts-expect-error emptyNode has actually data
  7804. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7805. };
  7806. let svgContainer;
  7807. function updateDOMProps(oldVnode, vnode) {
  7808. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7809. return;
  7810. }
  7811. let key, cur;
  7812. const elm = vnode.elm;
  7813. const oldProps = oldVnode.data.domProps || {};
  7814. let props = vnode.data.domProps || {};
  7815. // clone observed objects, as the user probably wants to mutate it
  7816. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7817. props = vnode.data.domProps = extend({}, props);
  7818. }
  7819. for (key in oldProps) {
  7820. if (!(key in props)) {
  7821. elm[key] = '';
  7822. }
  7823. }
  7824. for (key in props) {
  7825. cur = props[key];
  7826. // ignore children if the node has textContent or innerHTML,
  7827. // as these will throw away existing DOM nodes and cause removal errors
  7828. // on subsequent patches (#3360)
  7829. if (key === 'textContent' || key === 'innerHTML') {
  7830. if (vnode.children)
  7831. vnode.children.length = 0;
  7832. if (cur === oldProps[key])
  7833. continue;
  7834. // #6601 work around Chrome version <= 55 bug where single textNode
  7835. // replaced by innerHTML/textContent retains its parentNode property
  7836. if (elm.childNodes.length === 1) {
  7837. elm.removeChild(elm.childNodes[0]);
  7838. }
  7839. }
  7840. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7841. // store value as _value as well since
  7842. // non-string values will be stringified
  7843. elm._value = cur;
  7844. // avoid resetting cursor position when value is the same
  7845. const strCur = isUndef(cur) ? '' : String(cur);
  7846. if (shouldUpdateValue(elm, strCur)) {
  7847. elm.value = strCur;
  7848. }
  7849. }
  7850. else if (key === 'innerHTML' &&
  7851. isSVG(elm.tagName) &&
  7852. isUndef(elm.innerHTML)) {
  7853. // IE doesn't support innerHTML for SVG elements
  7854. svgContainer = svgContainer || document.createElement('div');
  7855. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7856. const svg = svgContainer.firstChild;
  7857. while (elm.firstChild) {
  7858. elm.removeChild(elm.firstChild);
  7859. }
  7860. while (svg.firstChild) {
  7861. elm.appendChild(svg.firstChild);
  7862. }
  7863. }
  7864. else if (
  7865. // skip the update if old and new VDOM state is the same.
  7866. // `value` is handled separately because the DOM value may be temporarily
  7867. // out of sync with VDOM state due to focus, composition and modifiers.
  7868. // This #4521 by skipping the unnecessary `checked` update.
  7869. cur !== oldProps[key]) {
  7870. // some property updates can throw
  7871. // e.g. `value` on <progress> w/ non-finite value
  7872. try {
  7873. elm[key] = cur;
  7874. }
  7875. catch (e) { }
  7876. }
  7877. }
  7878. }
  7879. function shouldUpdateValue(elm, checkVal) {
  7880. return (
  7881. //@ts-expect-error
  7882. !elm.composing &&
  7883. (elm.tagName === 'OPTION' ||
  7884. isNotInFocusAndDirty(elm, checkVal) ||
  7885. isDirtyWithModifiers(elm, checkVal)));
  7886. }
  7887. function isNotInFocusAndDirty(elm, checkVal) {
  7888. // return true when textbox (.number and .trim) loses focus and its value is
  7889. // not equal to the updated value
  7890. let notInFocus = true;
  7891. // #6157
  7892. // work around IE bug when accessing document.activeElement in an iframe
  7893. try {
  7894. notInFocus = document.activeElement !== elm;
  7895. }
  7896. catch (e) { }
  7897. return notInFocus && elm.value !== checkVal;
  7898. }
  7899. function isDirtyWithModifiers(elm, newVal) {
  7900. const value = elm.value;
  7901. const modifiers = elm._vModifiers; // injected by v-model runtime
  7902. if (isDef(modifiers)) {
  7903. if (modifiers.number) {
  7904. return toNumber(value) !== toNumber(newVal);
  7905. }
  7906. if (modifiers.trim) {
  7907. return value.trim() !== newVal.trim();
  7908. }
  7909. }
  7910. return value !== newVal;
  7911. }
  7912. var domProps = {
  7913. create: updateDOMProps,
  7914. update: updateDOMProps
  7915. };
  7916. const parseStyleText = cached(function (cssText) {
  7917. const res = {};
  7918. const listDelimiter = /;(?![^(]*\))/g;
  7919. const propertyDelimiter = /:(.+)/;
  7920. cssText.split(listDelimiter).forEach(function (item) {
  7921. if (item) {
  7922. const tmp = item.split(propertyDelimiter);
  7923. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7924. }
  7925. });
  7926. return res;
  7927. });
  7928. // merge static and dynamic style data on the same vnode
  7929. function normalizeStyleData(data) {
  7930. const style = normalizeStyleBinding(data.style);
  7931. // static style is pre-processed into an object during compilation
  7932. // and is always a fresh object, so it's safe to merge into it
  7933. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7934. }
  7935. // normalize possible array / string values into Object
  7936. function normalizeStyleBinding(bindingStyle) {
  7937. if (Array.isArray(bindingStyle)) {
  7938. return toObject(bindingStyle);
  7939. }
  7940. if (typeof bindingStyle === 'string') {
  7941. return parseStyleText(bindingStyle);
  7942. }
  7943. return bindingStyle;
  7944. }
  7945. /**
  7946. * parent component style should be after child's
  7947. * so that parent component's style could override it
  7948. */
  7949. function getStyle(vnode, checkChild) {
  7950. const res = {};
  7951. let styleData;
  7952. if (checkChild) {
  7953. let childNode = vnode;
  7954. while (childNode.componentInstance) {
  7955. childNode = childNode.componentInstance._vnode;
  7956. if (childNode &&
  7957. childNode.data &&
  7958. (styleData = normalizeStyleData(childNode.data))) {
  7959. extend(res, styleData);
  7960. }
  7961. }
  7962. }
  7963. if ((styleData = normalizeStyleData(vnode.data))) {
  7964. extend(res, styleData);
  7965. }
  7966. let parentNode = vnode;
  7967. // @ts-expect-error parentNode.parent not VNodeWithData
  7968. while ((parentNode = parentNode.parent)) {
  7969. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7970. extend(res, styleData);
  7971. }
  7972. }
  7973. return res;
  7974. }
  7975. const cssVarRE = /^--/;
  7976. const importantRE = /\s*!important$/;
  7977. const setProp = (el, name, val) => {
  7978. /* istanbul ignore if */
  7979. if (cssVarRE.test(name)) {
  7980. el.style.setProperty(name, val);
  7981. }
  7982. else if (importantRE.test(val)) {
  7983. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7984. }
  7985. else {
  7986. const normalizedName = normalize(name);
  7987. if (Array.isArray(val)) {
  7988. // Support values array created by autoprefixer, e.g.
  7989. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7990. // Set them one by one, and the browser will only set those it can recognize
  7991. for (let i = 0, len = val.length; i < len; i++) {
  7992. el.style[normalizedName] = val[i];
  7993. }
  7994. }
  7995. else {
  7996. el.style[normalizedName] = val;
  7997. }
  7998. }
  7999. };
  8000. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8001. let emptyStyle;
  8002. const normalize = cached(function (prop) {
  8003. emptyStyle = emptyStyle || document.createElement('div').style;
  8004. prop = camelize(prop);
  8005. if (prop !== 'filter' && prop in emptyStyle) {
  8006. return prop;
  8007. }
  8008. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8009. for (let i = 0; i < vendorNames.length; i++) {
  8010. const name = vendorNames[i] + capName;
  8011. if (name in emptyStyle) {
  8012. return name;
  8013. }
  8014. }
  8015. });
  8016. function updateStyle(oldVnode, vnode) {
  8017. const data = vnode.data;
  8018. const oldData = oldVnode.data;
  8019. if (isUndef(data.staticStyle) &&
  8020. isUndef(data.style) &&
  8021. isUndef(oldData.staticStyle) &&
  8022. isUndef(oldData.style)) {
  8023. return;
  8024. }
  8025. let cur, name;
  8026. const el = vnode.elm;
  8027. const oldStaticStyle = oldData.staticStyle;
  8028. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8029. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8030. const oldStyle = oldStaticStyle || oldStyleBinding;
  8031. const style = normalizeStyleBinding(vnode.data.style) || {};
  8032. // store normalized style under a different key for next diff
  8033. // make sure to clone it if it's reactive, since the user likely wants
  8034. // to mutate it.
  8035. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8036. const newStyle = getStyle(vnode, true);
  8037. for (name in oldStyle) {
  8038. if (isUndef(newStyle[name])) {
  8039. setProp(el, name, '');
  8040. }
  8041. }
  8042. for (name in newStyle) {
  8043. cur = newStyle[name];
  8044. if (cur !== oldStyle[name]) {
  8045. // ie9 setting to null has no effect, must use empty string
  8046. setProp(el, name, cur == null ? '' : cur);
  8047. }
  8048. }
  8049. }
  8050. var style$1 = {
  8051. create: updateStyle,
  8052. update: updateStyle
  8053. };
  8054. const whitespaceRE$1 = /\s+/;
  8055. /**
  8056. * Add class with compatibility for SVG since classList is not supported on
  8057. * SVG elements in IE
  8058. */
  8059. function addClass(el, cls) {
  8060. /* istanbul ignore if */
  8061. if (!cls || !(cls = cls.trim())) {
  8062. return;
  8063. }
  8064. /* istanbul ignore else */
  8065. if (el.classList) {
  8066. if (cls.indexOf(' ') > -1) {
  8067. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8068. }
  8069. else {
  8070. el.classList.add(cls);
  8071. }
  8072. }
  8073. else {
  8074. const cur = ` ${el.getAttribute('class') || ''} `;
  8075. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8076. el.setAttribute('class', (cur + cls).trim());
  8077. }
  8078. }
  8079. }
  8080. /**
  8081. * Remove class with compatibility for SVG since classList is not supported on
  8082. * SVG elements in IE
  8083. */
  8084. function removeClass(el, cls) {
  8085. /* istanbul ignore if */
  8086. if (!cls || !(cls = cls.trim())) {
  8087. return;
  8088. }
  8089. /* istanbul ignore else */
  8090. if (el.classList) {
  8091. if (cls.indexOf(' ') > -1) {
  8092. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8093. }
  8094. else {
  8095. el.classList.remove(cls);
  8096. }
  8097. if (!el.classList.length) {
  8098. el.removeAttribute('class');
  8099. }
  8100. }
  8101. else {
  8102. let cur = ` ${el.getAttribute('class') || ''} `;
  8103. const tar = ' ' + cls + ' ';
  8104. while (cur.indexOf(tar) >= 0) {
  8105. cur = cur.replace(tar, ' ');
  8106. }
  8107. cur = cur.trim();
  8108. if (cur) {
  8109. el.setAttribute('class', cur);
  8110. }
  8111. else {
  8112. el.removeAttribute('class');
  8113. }
  8114. }
  8115. }
  8116. function resolveTransition(def) {
  8117. if (!def) {
  8118. return;
  8119. }
  8120. /* istanbul ignore else */
  8121. if (typeof def === 'object') {
  8122. const res = {};
  8123. if (def.css !== false) {
  8124. extend(res, autoCssTransition(def.name || 'v'));
  8125. }
  8126. extend(res, def);
  8127. return res;
  8128. }
  8129. else if (typeof def === 'string') {
  8130. return autoCssTransition(def);
  8131. }
  8132. }
  8133. const autoCssTransition = cached(name => {
  8134. return {
  8135. enterClass: `${name}-enter`,
  8136. enterToClass: `${name}-enter-to`,
  8137. enterActiveClass: `${name}-enter-active`,
  8138. leaveClass: `${name}-leave`,
  8139. leaveToClass: `${name}-leave-to`,
  8140. leaveActiveClass: `${name}-leave-active`
  8141. };
  8142. });
  8143. const hasTransition = inBrowser && !isIE9;
  8144. const TRANSITION = 'transition';
  8145. const ANIMATION = 'animation';
  8146. // Transition property/event sniffing
  8147. let transitionProp = 'transition';
  8148. let transitionEndEvent = 'transitionend';
  8149. let animationProp = 'animation';
  8150. let animationEndEvent = 'animationend';
  8151. if (hasTransition) {
  8152. /* istanbul ignore if */
  8153. if (window.ontransitionend === undefined &&
  8154. window.onwebkittransitionend !== undefined) {
  8155. transitionProp = 'WebkitTransition';
  8156. transitionEndEvent = 'webkitTransitionEnd';
  8157. }
  8158. if (window.onanimationend === undefined &&
  8159. window.onwebkitanimationend !== undefined) {
  8160. animationProp = 'WebkitAnimation';
  8161. animationEndEvent = 'webkitAnimationEnd';
  8162. }
  8163. }
  8164. // binding to window is necessary to make hot reload work in IE in strict mode
  8165. const raf = inBrowser
  8166. ? window.requestAnimationFrame
  8167. ? window.requestAnimationFrame.bind(window)
  8168. : setTimeout
  8169. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8170. function nextFrame(fn) {
  8171. raf(() => {
  8172. // @ts-expect-error
  8173. raf(fn);
  8174. });
  8175. }
  8176. function addTransitionClass(el, cls) {
  8177. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8178. if (transitionClasses.indexOf(cls) < 0) {
  8179. transitionClasses.push(cls);
  8180. addClass(el, cls);
  8181. }
  8182. }
  8183. function removeTransitionClass(el, cls) {
  8184. if (el._transitionClasses) {
  8185. remove$2(el._transitionClasses, cls);
  8186. }
  8187. removeClass(el, cls);
  8188. }
  8189. function whenTransitionEnds(el, expectedType, cb) {
  8190. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8191. if (!type)
  8192. return cb();
  8193. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8194. let ended = 0;
  8195. const end = () => {
  8196. el.removeEventListener(event, onEnd);
  8197. cb();
  8198. };
  8199. const onEnd = e => {
  8200. if (e.target === el) {
  8201. if (++ended >= propCount) {
  8202. end();
  8203. }
  8204. }
  8205. };
  8206. setTimeout(() => {
  8207. if (ended < propCount) {
  8208. end();
  8209. }
  8210. }, timeout + 1);
  8211. el.addEventListener(event, onEnd);
  8212. }
  8213. const transformRE = /\b(transform|all)(,|$)/;
  8214. function getTransitionInfo(el, expectedType) {
  8215. const styles = window.getComputedStyle(el);
  8216. // JSDOM may return undefined for transition properties
  8217. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8218. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8219. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8220. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8221. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8222. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8223. let type;
  8224. let timeout = 0;
  8225. let propCount = 0;
  8226. /* istanbul ignore if */
  8227. if (expectedType === TRANSITION) {
  8228. if (transitionTimeout > 0) {
  8229. type = TRANSITION;
  8230. timeout = transitionTimeout;
  8231. propCount = transitionDurations.length;
  8232. }
  8233. }
  8234. else if (expectedType === ANIMATION) {
  8235. if (animationTimeout > 0) {
  8236. type = ANIMATION;
  8237. timeout = animationTimeout;
  8238. propCount = animationDurations.length;
  8239. }
  8240. }
  8241. else {
  8242. timeout = Math.max(transitionTimeout, animationTimeout);
  8243. type =
  8244. timeout > 0
  8245. ? transitionTimeout > animationTimeout
  8246. ? TRANSITION
  8247. : ANIMATION
  8248. : null;
  8249. propCount = type
  8250. ? type === TRANSITION
  8251. ? transitionDurations.length
  8252. : animationDurations.length
  8253. : 0;
  8254. }
  8255. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8256. return {
  8257. type,
  8258. timeout,
  8259. propCount,
  8260. hasTransform
  8261. };
  8262. }
  8263. function getTimeout(delays, durations) {
  8264. /* istanbul ignore next */
  8265. while (delays.length < durations.length) {
  8266. delays = delays.concat(delays);
  8267. }
  8268. return Math.max.apply(null, durations.map((d, i) => {
  8269. return toMs(d) + toMs(delays[i]);
  8270. }));
  8271. }
  8272. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8273. // in a locale-dependent way, using a comma instead of a dot.
  8274. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8275. // as a floor function) causing unexpected behaviors
  8276. function toMs(s) {
  8277. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8278. }
  8279. function enter(vnode, toggleDisplay) {
  8280. const el = vnode.elm;
  8281. // call leave callback now
  8282. if (isDef(el._leaveCb)) {
  8283. el._leaveCb.cancelled = true;
  8284. el._leaveCb();
  8285. }
  8286. const data = resolveTransition(vnode.data.transition);
  8287. if (isUndef(data)) {
  8288. return;
  8289. }
  8290. /* istanbul ignore if */
  8291. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8292. return;
  8293. }
  8294. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8295. // activeInstance will always be the <transition> component managing this
  8296. // transition. One edge case to check is when the <transition> is placed
  8297. // as the root node of a child component. In that case we need to check
  8298. // <transition>'s parent for appear check.
  8299. let context = activeInstance;
  8300. let transitionNode = activeInstance.$vnode;
  8301. while (transitionNode && transitionNode.parent) {
  8302. context = transitionNode.context;
  8303. transitionNode = transitionNode.parent;
  8304. }
  8305. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8306. if (isAppear && !appear && appear !== '') {
  8307. return;
  8308. }
  8309. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8310. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8311. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8312. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8313. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8314. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8315. const enterCancelledHook = isAppear
  8316. ? appearCancelled || enterCancelled
  8317. : enterCancelled;
  8318. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8319. if (explicitEnterDuration != null) {
  8320. checkDuration(explicitEnterDuration, 'enter', vnode);
  8321. }
  8322. const expectsCSS = css !== false && !isIE9;
  8323. const userWantsControl = getHookArgumentsLength(enterHook);
  8324. const cb = (el._enterCb = once(() => {
  8325. if (expectsCSS) {
  8326. removeTransitionClass(el, toClass);
  8327. removeTransitionClass(el, activeClass);
  8328. }
  8329. // @ts-expect-error
  8330. if (cb.cancelled) {
  8331. if (expectsCSS) {
  8332. removeTransitionClass(el, startClass);
  8333. }
  8334. enterCancelledHook && enterCancelledHook(el);
  8335. }
  8336. else {
  8337. afterEnterHook && afterEnterHook(el);
  8338. }
  8339. el._enterCb = null;
  8340. }));
  8341. if (!vnode.data.show) {
  8342. // remove pending leave element on enter by injecting an insert hook
  8343. mergeVNodeHook(vnode, 'insert', () => {
  8344. const parent = el.parentNode;
  8345. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8346. if (pendingNode &&
  8347. pendingNode.tag === vnode.tag &&
  8348. pendingNode.elm._leaveCb) {
  8349. pendingNode.elm._leaveCb();
  8350. }
  8351. enterHook && enterHook(el, cb);
  8352. });
  8353. }
  8354. // start enter transition
  8355. beforeEnterHook && beforeEnterHook(el);
  8356. if (expectsCSS) {
  8357. addTransitionClass(el, startClass);
  8358. addTransitionClass(el, activeClass);
  8359. nextFrame(() => {
  8360. removeTransitionClass(el, startClass);
  8361. // @ts-expect-error
  8362. if (!cb.cancelled) {
  8363. addTransitionClass(el, toClass);
  8364. if (!userWantsControl) {
  8365. if (isValidDuration(explicitEnterDuration)) {
  8366. setTimeout(cb, explicitEnterDuration);
  8367. }
  8368. else {
  8369. whenTransitionEnds(el, type, cb);
  8370. }
  8371. }
  8372. }
  8373. });
  8374. }
  8375. if (vnode.data.show) {
  8376. toggleDisplay && toggleDisplay();
  8377. enterHook && enterHook(el, cb);
  8378. }
  8379. if (!expectsCSS && !userWantsControl) {
  8380. cb();
  8381. }
  8382. }
  8383. function leave(vnode, rm) {
  8384. const el = vnode.elm;
  8385. // call enter callback now
  8386. if (isDef(el._enterCb)) {
  8387. el._enterCb.cancelled = true;
  8388. el._enterCb();
  8389. }
  8390. const data = resolveTransition(vnode.data.transition);
  8391. if (isUndef(data) || el.nodeType !== 1) {
  8392. return rm();
  8393. }
  8394. /* istanbul ignore if */
  8395. if (isDef(el._leaveCb)) {
  8396. return;
  8397. }
  8398. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8399. const expectsCSS = css !== false && !isIE9;
  8400. const userWantsControl = getHookArgumentsLength(leave);
  8401. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8402. if (isDef(explicitLeaveDuration)) {
  8403. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8404. }
  8405. const cb = (el._leaveCb = once(() => {
  8406. if (el.parentNode && el.parentNode._pending) {
  8407. el.parentNode._pending[vnode.key] = null;
  8408. }
  8409. if (expectsCSS) {
  8410. removeTransitionClass(el, leaveToClass);
  8411. removeTransitionClass(el, leaveActiveClass);
  8412. }
  8413. // @ts-expect-error
  8414. if (cb.cancelled) {
  8415. if (expectsCSS) {
  8416. removeTransitionClass(el, leaveClass);
  8417. }
  8418. leaveCancelled && leaveCancelled(el);
  8419. }
  8420. else {
  8421. rm();
  8422. afterLeave && afterLeave(el);
  8423. }
  8424. el._leaveCb = null;
  8425. }));
  8426. if (delayLeave) {
  8427. delayLeave(performLeave);
  8428. }
  8429. else {
  8430. performLeave();
  8431. }
  8432. function performLeave() {
  8433. // the delayed leave may have already been cancelled
  8434. // @ts-expect-error
  8435. if (cb.cancelled) {
  8436. return;
  8437. }
  8438. // record leaving element
  8439. if (!vnode.data.show && el.parentNode) {
  8440. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8441. vnode;
  8442. }
  8443. beforeLeave && beforeLeave(el);
  8444. if (expectsCSS) {
  8445. addTransitionClass(el, leaveClass);
  8446. addTransitionClass(el, leaveActiveClass);
  8447. nextFrame(() => {
  8448. removeTransitionClass(el, leaveClass);
  8449. // @ts-expect-error
  8450. if (!cb.cancelled) {
  8451. addTransitionClass(el, leaveToClass);
  8452. if (!userWantsControl) {
  8453. if (isValidDuration(explicitLeaveDuration)) {
  8454. setTimeout(cb, explicitLeaveDuration);
  8455. }
  8456. else {
  8457. whenTransitionEnds(el, type, cb);
  8458. }
  8459. }
  8460. }
  8461. });
  8462. }
  8463. leave && leave(el, cb);
  8464. if (!expectsCSS && !userWantsControl) {
  8465. cb();
  8466. }
  8467. }
  8468. }
  8469. // only used in dev mode
  8470. function checkDuration(val, name, vnode) {
  8471. if (typeof val !== 'number') {
  8472. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8473. `got ${JSON.stringify(val)}.`, vnode.context);
  8474. }
  8475. else if (isNaN(val)) {
  8476. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8477. 'the duration expression might be incorrect.', vnode.context);
  8478. }
  8479. }
  8480. function isValidDuration(val) {
  8481. return typeof val === 'number' && !isNaN(val);
  8482. }
  8483. /**
  8484. * Normalize a transition hook's argument length. The hook may be:
  8485. * - a merged hook (invoker) with the original in .fns
  8486. * - a wrapped component method (check ._length)
  8487. * - a plain function (.length)
  8488. */
  8489. function getHookArgumentsLength(fn) {
  8490. if (isUndef(fn)) {
  8491. return false;
  8492. }
  8493. // @ts-expect-error
  8494. const invokerFns = fn.fns;
  8495. if (isDef(invokerFns)) {
  8496. // invoker
  8497. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8498. }
  8499. else {
  8500. // @ts-expect-error
  8501. return (fn._length || fn.length) > 1;
  8502. }
  8503. }
  8504. function _enter(_, vnode) {
  8505. if (vnode.data.show !== true) {
  8506. enter(vnode);
  8507. }
  8508. }
  8509. var transition = inBrowser
  8510. ? {
  8511. create: _enter,
  8512. activate: _enter,
  8513. remove(vnode, rm) {
  8514. /* istanbul ignore else */
  8515. if (vnode.data.show !== true) {
  8516. // @ts-expect-error
  8517. leave(vnode, rm);
  8518. }
  8519. else {
  8520. rm();
  8521. }
  8522. }
  8523. }
  8524. : {};
  8525. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8526. // the directive module should be applied last, after all
  8527. // built-in modules have been applied.
  8528. const modules$1 = platformModules.concat(baseModules);
  8529. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8530. /**
  8531. * Not type checking this file because flow doesn't like attaching
  8532. * properties to Elements.
  8533. */
  8534. /* istanbul ignore if */
  8535. if (isIE9) {
  8536. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8537. document.addEventListener('selectionchange', () => {
  8538. const el = document.activeElement;
  8539. // @ts-expect-error
  8540. if (el && el.vmodel) {
  8541. trigger(el, 'input');
  8542. }
  8543. });
  8544. }
  8545. const directive = {
  8546. inserted(el, binding, vnode, oldVnode) {
  8547. if (vnode.tag === 'select') {
  8548. // #6903
  8549. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8550. mergeVNodeHook(vnode, 'postpatch', () => {
  8551. directive.componentUpdated(el, binding, vnode);
  8552. });
  8553. }
  8554. else {
  8555. setSelected(el, binding, vnode.context);
  8556. }
  8557. el._vOptions = [].map.call(el.options, getValue);
  8558. }
  8559. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8560. el._vModifiers = binding.modifiers;
  8561. if (!binding.modifiers.lazy) {
  8562. el.addEventListener('compositionstart', onCompositionStart);
  8563. el.addEventListener('compositionend', onCompositionEnd);
  8564. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8565. // switching focus before confirming composition choice
  8566. // this also fixes the issue where some browsers e.g. iOS Chrome
  8567. // fires "change" instead of "input" on autocomplete.
  8568. el.addEventListener('change', onCompositionEnd);
  8569. /* istanbul ignore if */
  8570. if (isIE9) {
  8571. el.vmodel = true;
  8572. }
  8573. }
  8574. }
  8575. },
  8576. componentUpdated(el, binding, vnode) {
  8577. if (vnode.tag === 'select') {
  8578. setSelected(el, binding, vnode.context);
  8579. // in case the options rendered by v-for have changed,
  8580. // it's possible that the value is out-of-sync with the rendered options.
  8581. // detect such cases and filter out values that no longer has a matching
  8582. // option in the DOM.
  8583. const prevOptions = el._vOptions;
  8584. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8585. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8586. // trigger change event if
  8587. // no matching option found for at least one value
  8588. const needReset = el.multiple
  8589. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8590. : binding.value !== binding.oldValue &&
  8591. hasNoMatchingOption(binding.value, curOptions);
  8592. if (needReset) {
  8593. trigger(el, 'change');
  8594. }
  8595. }
  8596. }
  8597. }
  8598. };
  8599. function setSelected(el, binding, vm) {
  8600. actuallySetSelected(el, binding, vm);
  8601. /* istanbul ignore if */
  8602. if (isIE || isEdge) {
  8603. setTimeout(() => {
  8604. actuallySetSelected(el, binding, vm);
  8605. }, 0);
  8606. }
  8607. }
  8608. function actuallySetSelected(el, binding, vm) {
  8609. const value = binding.value;
  8610. const isMultiple = el.multiple;
  8611. if (isMultiple && !Array.isArray(value)) {
  8612. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8613. `expects an Array value for its binding, but got ${Object.prototype.toString
  8614. .call(value)
  8615. .slice(8, -1)}`, vm);
  8616. return;
  8617. }
  8618. let selected, option;
  8619. for (let i = 0, l = el.options.length; i < l; i++) {
  8620. option = el.options[i];
  8621. if (isMultiple) {
  8622. selected = looseIndexOf(value, getValue(option)) > -1;
  8623. if (option.selected !== selected) {
  8624. option.selected = selected;
  8625. }
  8626. }
  8627. else {
  8628. if (looseEqual(getValue(option), value)) {
  8629. if (el.selectedIndex !== i) {
  8630. el.selectedIndex = i;
  8631. }
  8632. return;
  8633. }
  8634. }
  8635. }
  8636. if (!isMultiple) {
  8637. el.selectedIndex = -1;
  8638. }
  8639. }
  8640. function hasNoMatchingOption(value, options) {
  8641. return options.every(o => !looseEqual(o, value));
  8642. }
  8643. function getValue(option) {
  8644. return '_value' in option ? option._value : option.value;
  8645. }
  8646. function onCompositionStart(e) {
  8647. e.target.composing = true;
  8648. }
  8649. function onCompositionEnd(e) {
  8650. // prevent triggering an input event for no reason
  8651. if (!e.target.composing)
  8652. return;
  8653. e.target.composing = false;
  8654. trigger(e.target, 'input');
  8655. }
  8656. function trigger(el, type) {
  8657. const e = document.createEvent('HTMLEvents');
  8658. e.initEvent(type, true, true);
  8659. el.dispatchEvent(e);
  8660. }
  8661. // recursively search for possible transition defined inside the component root
  8662. function locateNode(vnode) {
  8663. // @ts-expect-error
  8664. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8665. ? locateNode(vnode.componentInstance._vnode)
  8666. : vnode;
  8667. }
  8668. var show = {
  8669. bind(el, { value }, vnode) {
  8670. vnode = locateNode(vnode);
  8671. const transition = vnode.data && vnode.data.transition;
  8672. const originalDisplay = (el.__vOriginalDisplay =
  8673. el.style.display === 'none' ? '' : el.style.display);
  8674. if (value && transition) {
  8675. vnode.data.show = true;
  8676. enter(vnode, () => {
  8677. el.style.display = originalDisplay;
  8678. });
  8679. }
  8680. else {
  8681. el.style.display = value ? originalDisplay : 'none';
  8682. }
  8683. },
  8684. update(el, { value, oldValue }, vnode) {
  8685. /* istanbul ignore if */
  8686. if (!value === !oldValue)
  8687. return;
  8688. vnode = locateNode(vnode);
  8689. const transition = vnode.data && vnode.data.transition;
  8690. if (transition) {
  8691. vnode.data.show = true;
  8692. if (value) {
  8693. enter(vnode, () => {
  8694. el.style.display = el.__vOriginalDisplay;
  8695. });
  8696. }
  8697. else {
  8698. leave(vnode, () => {
  8699. el.style.display = 'none';
  8700. });
  8701. }
  8702. }
  8703. else {
  8704. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8705. }
  8706. },
  8707. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8708. if (!isDestroy) {
  8709. el.style.display = el.__vOriginalDisplay;
  8710. }
  8711. }
  8712. };
  8713. var platformDirectives = {
  8714. model: directive,
  8715. show
  8716. };
  8717. // Provides transition support for a single element/component.
  8718. const transitionProps = {
  8719. name: String,
  8720. appear: Boolean,
  8721. css: Boolean,
  8722. mode: String,
  8723. type: String,
  8724. enterClass: String,
  8725. leaveClass: String,
  8726. enterToClass: String,
  8727. leaveToClass: String,
  8728. enterActiveClass: String,
  8729. leaveActiveClass: String,
  8730. appearClass: String,
  8731. appearActiveClass: String,
  8732. appearToClass: String,
  8733. duration: [Number, String, Object]
  8734. };
  8735. // in case the child is also an abstract component, e.g. <keep-alive>
  8736. // we want to recursively retrieve the real component to be rendered
  8737. function getRealChild(vnode) {
  8738. const compOptions = vnode && vnode.componentOptions;
  8739. if (compOptions && compOptions.Ctor.options.abstract) {
  8740. return getRealChild(getFirstComponentChild(compOptions.children));
  8741. }
  8742. else {
  8743. return vnode;
  8744. }
  8745. }
  8746. function extractTransitionData(comp) {
  8747. const data = {};
  8748. const options = comp.$options;
  8749. // props
  8750. for (const key in options.propsData) {
  8751. data[key] = comp[key];
  8752. }
  8753. // events.
  8754. // extract listeners and pass them directly to the transition methods
  8755. const listeners = options._parentListeners;
  8756. for (const key in listeners) {
  8757. data[camelize(key)] = listeners[key];
  8758. }
  8759. return data;
  8760. }
  8761. function placeholder(h, rawChild) {
  8762. // @ts-expect-error
  8763. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8764. return h('keep-alive', {
  8765. props: rawChild.componentOptions.propsData
  8766. });
  8767. }
  8768. }
  8769. function hasParentTransition(vnode) {
  8770. while ((vnode = vnode.parent)) {
  8771. if (vnode.data.transition) {
  8772. return true;
  8773. }
  8774. }
  8775. }
  8776. function isSameChild(child, oldChild) {
  8777. return oldChild.key === child.key && oldChild.tag === child.tag;
  8778. }
  8779. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8780. const isVShowDirective = d => d.name === 'show';
  8781. var Transition = {
  8782. name: 'transition',
  8783. props: transitionProps,
  8784. abstract: true,
  8785. render(h) {
  8786. let children = this.$slots.default;
  8787. if (!children) {
  8788. return;
  8789. }
  8790. // filter out text nodes (possible whitespaces)
  8791. children = children.filter(isNotTextNode);
  8792. /* istanbul ignore if */
  8793. if (!children.length) {
  8794. return;
  8795. }
  8796. // warn multiple elements
  8797. if (children.length > 1) {
  8798. warn$2('<transition> can only be used on a single element. Use ' +
  8799. '<transition-group> for lists.', this.$parent);
  8800. }
  8801. const mode = this.mode;
  8802. // warn invalid mode
  8803. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8804. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8805. }
  8806. const rawChild = children[0];
  8807. // if this is a component root node and the component's
  8808. // parent container node also has transition, skip.
  8809. if (hasParentTransition(this.$vnode)) {
  8810. return rawChild;
  8811. }
  8812. // apply transition data to child
  8813. // use getRealChild() to ignore abstract components e.g. keep-alive
  8814. const child = getRealChild(rawChild);
  8815. /* istanbul ignore if */
  8816. if (!child) {
  8817. return rawChild;
  8818. }
  8819. if (this._leaving) {
  8820. return placeholder(h, rawChild);
  8821. }
  8822. // ensure a key that is unique to the vnode type and to this transition
  8823. // component instance. This key will be used to remove pending leaving nodes
  8824. // during entering.
  8825. const id = `__transition-${this._uid}-`;
  8826. child.key =
  8827. child.key == null
  8828. ? child.isComment
  8829. ? id + 'comment'
  8830. : id + child.tag
  8831. : isPrimitive(child.key)
  8832. ? String(child.key).indexOf(id) === 0
  8833. ? child.key
  8834. : id + child.key
  8835. : child.key;
  8836. const data = ((child.data || (child.data = {})).transition =
  8837. extractTransitionData(this));
  8838. const oldRawChild = this._vnode;
  8839. const oldChild = getRealChild(oldRawChild);
  8840. // mark v-show
  8841. // so that the transition module can hand over the control to the directive
  8842. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8843. child.data.show = true;
  8844. }
  8845. if (oldChild &&
  8846. oldChild.data &&
  8847. !isSameChild(child, oldChild) &&
  8848. !isAsyncPlaceholder(oldChild) &&
  8849. // #6687 component root is a comment node
  8850. !(oldChild.componentInstance &&
  8851. oldChild.componentInstance._vnode.isComment)) {
  8852. // replace old child transition data with fresh one
  8853. // important for dynamic transitions!
  8854. const oldData = (oldChild.data.transition = extend({}, data));
  8855. // handle transition mode
  8856. if (mode === 'out-in') {
  8857. // return placeholder node and queue update when leave finishes
  8858. this._leaving = true;
  8859. mergeVNodeHook(oldData, 'afterLeave', () => {
  8860. this._leaving = false;
  8861. this.$forceUpdate();
  8862. });
  8863. return placeholder(h, rawChild);
  8864. }
  8865. else if (mode === 'in-out') {
  8866. if (isAsyncPlaceholder(child)) {
  8867. return oldRawChild;
  8868. }
  8869. let delayedLeave;
  8870. const performLeave = () => {
  8871. delayedLeave();
  8872. };
  8873. mergeVNodeHook(data, 'afterEnter', performLeave);
  8874. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8875. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8876. delayedLeave = leave;
  8877. });
  8878. }
  8879. }
  8880. return rawChild;
  8881. }
  8882. };
  8883. // Provides transition support for list items.
  8884. const props = extend({
  8885. tag: String,
  8886. moveClass: String
  8887. }, transitionProps);
  8888. delete props.mode;
  8889. var TransitionGroup = {
  8890. props,
  8891. beforeMount() {
  8892. const update = this._update;
  8893. this._update = (vnode, hydrating) => {
  8894. const restoreActiveInstance = setActiveInstance(this);
  8895. // force removing pass
  8896. this.__patch__(this._vnode, this.kept, false, // hydrating
  8897. true // removeOnly (!important, avoids unnecessary moves)
  8898. );
  8899. this._vnode = this.kept;
  8900. restoreActiveInstance();
  8901. update.call(this, vnode, hydrating);
  8902. };
  8903. },
  8904. render(h) {
  8905. const tag = this.tag || this.$vnode.data.tag || 'span';
  8906. const map = Object.create(null);
  8907. const prevChildren = (this.prevChildren = this.children);
  8908. const rawChildren = this.$slots.default || [];
  8909. const children = (this.children = []);
  8910. const transitionData = extractTransitionData(this);
  8911. for (let i = 0; i < rawChildren.length; i++) {
  8912. const c = rawChildren[i];
  8913. if (c.tag) {
  8914. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8915. children.push(c);
  8916. map[c.key] = c;
  8917. (c.data || (c.data = {})).transition = transitionData;
  8918. }
  8919. else {
  8920. const opts = c.componentOptions;
  8921. const name = opts
  8922. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8923. : c.tag;
  8924. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8925. }
  8926. }
  8927. }
  8928. if (prevChildren) {
  8929. const kept = [];
  8930. const removed = [];
  8931. for (let i = 0; i < prevChildren.length; i++) {
  8932. const c = prevChildren[i];
  8933. c.data.transition = transitionData;
  8934. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8935. c.data.pos = c.elm.getBoundingClientRect();
  8936. if (map[c.key]) {
  8937. kept.push(c);
  8938. }
  8939. else {
  8940. removed.push(c);
  8941. }
  8942. }
  8943. this.kept = h(tag, null, kept);
  8944. this.removed = removed;
  8945. }
  8946. return h(tag, null, children);
  8947. },
  8948. updated() {
  8949. const children = this.prevChildren;
  8950. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8951. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8952. return;
  8953. }
  8954. // we divide the work into three loops to avoid mixing DOM reads and writes
  8955. // in each iteration - which helps prevent layout thrashing.
  8956. children.forEach(callPendingCbs);
  8957. children.forEach(recordPosition);
  8958. children.forEach(applyTranslation);
  8959. // force reflow to put everything in position
  8960. // assign to this to avoid being removed in tree-shaking
  8961. // $flow-disable-line
  8962. this._reflow = document.body.offsetHeight;
  8963. children.forEach((c) => {
  8964. if (c.data.moved) {
  8965. const el = c.elm;
  8966. const s = el.style;
  8967. addTransitionClass(el, moveClass);
  8968. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8969. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8970. if (e && e.target !== el) {
  8971. return;
  8972. }
  8973. if (!e || /transform$/.test(e.propertyName)) {
  8974. el.removeEventListener(transitionEndEvent, cb);
  8975. el._moveCb = null;
  8976. removeTransitionClass(el, moveClass);
  8977. }
  8978. }));
  8979. }
  8980. });
  8981. },
  8982. methods: {
  8983. hasMove(el, moveClass) {
  8984. /* istanbul ignore if */
  8985. if (!hasTransition) {
  8986. return false;
  8987. }
  8988. /* istanbul ignore if */
  8989. if (this._hasMove) {
  8990. return this._hasMove;
  8991. }
  8992. // Detect whether an element with the move class applied has
  8993. // CSS transitions. Since the element may be inside an entering
  8994. // transition at this very moment, we make a clone of it and remove
  8995. // all other transition classes applied to ensure only the move class
  8996. // is applied.
  8997. const clone = el.cloneNode();
  8998. if (el._transitionClasses) {
  8999. el._transitionClasses.forEach((cls) => {
  9000. removeClass(clone, cls);
  9001. });
  9002. }
  9003. addClass(clone, moveClass);
  9004. clone.style.display = 'none';
  9005. this.$el.appendChild(clone);
  9006. const info = getTransitionInfo(clone);
  9007. this.$el.removeChild(clone);
  9008. return (this._hasMove = info.hasTransform);
  9009. }
  9010. }
  9011. };
  9012. function callPendingCbs(c) {
  9013. /* istanbul ignore if */
  9014. if (c.elm._moveCb) {
  9015. c.elm._moveCb();
  9016. }
  9017. /* istanbul ignore if */
  9018. if (c.elm._enterCb) {
  9019. c.elm._enterCb();
  9020. }
  9021. }
  9022. function recordPosition(c) {
  9023. c.data.newPos = c.elm.getBoundingClientRect();
  9024. }
  9025. function applyTranslation(c) {
  9026. const oldPos = c.data.pos;
  9027. const newPos = c.data.newPos;
  9028. const dx = oldPos.left - newPos.left;
  9029. const dy = oldPos.top - newPos.top;
  9030. if (dx || dy) {
  9031. c.data.moved = true;
  9032. const s = c.elm.style;
  9033. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9034. s.transitionDuration = '0s';
  9035. }
  9036. }
  9037. var platformComponents = {
  9038. Transition,
  9039. TransitionGroup
  9040. };
  9041. // install platform specific utils
  9042. Vue.config.mustUseProp = mustUseProp;
  9043. Vue.config.isReservedTag = isReservedTag;
  9044. Vue.config.isReservedAttr = isReservedAttr;
  9045. Vue.config.getTagNamespace = getTagNamespace;
  9046. Vue.config.isUnknownElement = isUnknownElement;
  9047. // install platform runtime directives & components
  9048. extend(Vue.options.directives, platformDirectives);
  9049. extend(Vue.options.components, platformComponents);
  9050. // install platform patch function
  9051. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9052. // public mount method
  9053. Vue.prototype.$mount = function (el, hydrating) {
  9054. el = el && inBrowser ? query(el) : undefined;
  9055. return mountComponent(this, el, hydrating);
  9056. };
  9057. // devtools global hook
  9058. /* istanbul ignore next */
  9059. if (inBrowser) {
  9060. setTimeout(() => {
  9061. if (config.devtools) {
  9062. if (devtools) {
  9063. devtools.emit('init', Vue);
  9064. }
  9065. else {
  9066. // @ts-expect-error
  9067. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9068. 'https://github.com/vuejs/vue-devtools');
  9069. }
  9070. }
  9071. if (config.productionTip !== false &&
  9072. typeof console !== 'undefined') {
  9073. // @ts-expect-error
  9074. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9075. `Make sure to turn on production mode when deploying for production.\n` +
  9076. `See more tips at https://vuejs.org/guide/deployment.html`);
  9077. }
  9078. }, 0);
  9079. }
  9080. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9081. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9082. const buildRegex = cached(delimiters => {
  9083. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9084. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9085. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9086. });
  9087. function parseText(text, delimiters) {
  9088. //@ts-expect-error
  9089. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9090. if (!tagRE.test(text)) {
  9091. return;
  9092. }
  9093. const tokens = [];
  9094. const rawTokens = [];
  9095. let lastIndex = (tagRE.lastIndex = 0);
  9096. let match, index, tokenValue;
  9097. while ((match = tagRE.exec(text))) {
  9098. index = match.index;
  9099. // push text token
  9100. if (index > lastIndex) {
  9101. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9102. tokens.push(JSON.stringify(tokenValue));
  9103. }
  9104. // tag token
  9105. const exp = parseFilters(match[1].trim());
  9106. tokens.push(`_s(${exp})`);
  9107. rawTokens.push({ '@binding': exp });
  9108. lastIndex = index + match[0].length;
  9109. }
  9110. if (lastIndex < text.length) {
  9111. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9112. tokens.push(JSON.stringify(tokenValue));
  9113. }
  9114. return {
  9115. expression: tokens.join('+'),
  9116. tokens: rawTokens
  9117. };
  9118. }
  9119. function transformNode$1(el, options) {
  9120. const warn = options.warn || baseWarn;
  9121. const staticClass = getAndRemoveAttr(el, 'class');
  9122. if (staticClass) {
  9123. const res = parseText(staticClass, options.delimiters);
  9124. if (res) {
  9125. warn(`class="${staticClass}": ` +
  9126. 'Interpolation inside attributes has been removed. ' +
  9127. 'Use v-bind or the colon shorthand instead. For example, ' +
  9128. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9129. }
  9130. }
  9131. if (staticClass) {
  9132. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9133. }
  9134. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9135. if (classBinding) {
  9136. el.classBinding = classBinding;
  9137. }
  9138. }
  9139. function genData$2(el) {
  9140. let data = '';
  9141. if (el.staticClass) {
  9142. data += `staticClass:${el.staticClass},`;
  9143. }
  9144. if (el.classBinding) {
  9145. data += `class:${el.classBinding},`;
  9146. }
  9147. return data;
  9148. }
  9149. var klass = {
  9150. staticKeys: ['staticClass'],
  9151. transformNode: transformNode$1,
  9152. genData: genData$2
  9153. };
  9154. function transformNode(el, options) {
  9155. const warn = options.warn || baseWarn;
  9156. const staticStyle = getAndRemoveAttr(el, 'style');
  9157. if (staticStyle) {
  9158. /* istanbul ignore if */
  9159. {
  9160. const res = parseText(staticStyle, options.delimiters);
  9161. if (res) {
  9162. warn(`style="${staticStyle}": ` +
  9163. 'Interpolation inside attributes has been removed. ' +
  9164. 'Use v-bind or the colon shorthand instead. For example, ' +
  9165. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9166. }
  9167. }
  9168. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9169. }
  9170. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9171. if (styleBinding) {
  9172. el.styleBinding = styleBinding;
  9173. }
  9174. }
  9175. function genData$1(el) {
  9176. let data = '';
  9177. if (el.staticStyle) {
  9178. data += `staticStyle:${el.staticStyle},`;
  9179. }
  9180. if (el.styleBinding) {
  9181. data += `style:(${el.styleBinding}),`;
  9182. }
  9183. return data;
  9184. }
  9185. var style = {
  9186. staticKeys: ['staticStyle'],
  9187. transformNode,
  9188. genData: genData$1
  9189. };
  9190. let decoder;
  9191. var he = {
  9192. decode(html) {
  9193. decoder = decoder || document.createElement('div');
  9194. decoder.innerHTML = html;
  9195. return decoder.textContent;
  9196. }
  9197. };
  9198. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9199. 'link,meta,param,source,track,wbr');
  9200. // Elements that you can, intentionally, leave open
  9201. // (and which close themselves)
  9202. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9203. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9204. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9205. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9206. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9207. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9208. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9209. 'title,tr,track');
  9210. /**
  9211. * Not type-checking this file because it's mostly vendor code.
  9212. */
  9213. // Regular Expressions for parsing tags and attributes
  9214. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9215. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9216. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9217. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9218. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9219. const startTagClose = /^\s*(\/?)>/;
  9220. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9221. const doctype = /^<!DOCTYPE [^>]+>/i;
  9222. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9223. const comment = /^<!\--/;
  9224. const conditionalComment = /^<!\[/;
  9225. // Special Elements (can contain anything)
  9226. const isPlainTextElement = makeMap('script,style,textarea', true);
  9227. const reCache = {};
  9228. const decodingMap = {
  9229. '&lt;': '<',
  9230. '&gt;': '>',
  9231. '&quot;': '"',
  9232. '&amp;': '&',
  9233. '&#10;': '\n',
  9234. '&#9;': '\t',
  9235. '&#39;': "'"
  9236. };
  9237. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9238. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9239. // #5992
  9240. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9241. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9242. function decodeAttr(value, shouldDecodeNewlines) {
  9243. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9244. return value.replace(re, match => decodingMap[match]);
  9245. }
  9246. function parseHTML(html, options) {
  9247. const stack = [];
  9248. const expectHTML = options.expectHTML;
  9249. const isUnaryTag = options.isUnaryTag || no;
  9250. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9251. let index = 0;
  9252. let last, lastTag;
  9253. while (html) {
  9254. last = html;
  9255. // Make sure we're not in a plaintext content element like script/style
  9256. if (!lastTag || !isPlainTextElement(lastTag)) {
  9257. let textEnd = html.indexOf('<');
  9258. if (textEnd === 0) {
  9259. // Comment:
  9260. if (comment.test(html)) {
  9261. const commentEnd = html.indexOf('-->');
  9262. if (commentEnd >= 0) {
  9263. if (options.shouldKeepComment && options.comment) {
  9264. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9265. }
  9266. advance(commentEnd + 3);
  9267. continue;
  9268. }
  9269. }
  9270. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9271. if (conditionalComment.test(html)) {
  9272. const conditionalEnd = html.indexOf(']>');
  9273. if (conditionalEnd >= 0) {
  9274. advance(conditionalEnd + 2);
  9275. continue;
  9276. }
  9277. }
  9278. // Doctype:
  9279. const doctypeMatch = html.match(doctype);
  9280. if (doctypeMatch) {
  9281. advance(doctypeMatch[0].length);
  9282. continue;
  9283. }
  9284. // End tag:
  9285. const endTagMatch = html.match(endTag);
  9286. if (endTagMatch) {
  9287. const curIndex = index;
  9288. advance(endTagMatch[0].length);
  9289. parseEndTag(endTagMatch[1], curIndex, index);
  9290. continue;
  9291. }
  9292. // Start tag:
  9293. const startTagMatch = parseStartTag();
  9294. if (startTagMatch) {
  9295. handleStartTag(startTagMatch);
  9296. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9297. advance(1);
  9298. }
  9299. continue;
  9300. }
  9301. }
  9302. let text, rest, next;
  9303. if (textEnd >= 0) {
  9304. rest = html.slice(textEnd);
  9305. while (!endTag.test(rest) &&
  9306. !startTagOpen.test(rest) &&
  9307. !comment.test(rest) &&
  9308. !conditionalComment.test(rest)) {
  9309. // < in plain text, be forgiving and treat it as text
  9310. next = rest.indexOf('<', 1);
  9311. if (next < 0)
  9312. break;
  9313. textEnd += next;
  9314. rest = html.slice(textEnd);
  9315. }
  9316. text = html.substring(0, textEnd);
  9317. }
  9318. if (textEnd < 0) {
  9319. text = html;
  9320. }
  9321. if (text) {
  9322. advance(text.length);
  9323. }
  9324. if (options.chars && text) {
  9325. options.chars(text, index - text.length, index);
  9326. }
  9327. }
  9328. else {
  9329. let endTagLength = 0;
  9330. const stackedTag = lastTag.toLowerCase();
  9331. const reStackedTag = reCache[stackedTag] ||
  9332. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9333. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9334. endTagLength = endTag.length;
  9335. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9336. text = text
  9337. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9338. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9339. }
  9340. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9341. text = text.slice(1);
  9342. }
  9343. if (options.chars) {
  9344. options.chars(text);
  9345. }
  9346. return '';
  9347. });
  9348. index += html.length - rest.length;
  9349. html = rest;
  9350. parseEndTag(stackedTag, index - endTagLength, index);
  9351. }
  9352. if (html === last) {
  9353. options.chars && options.chars(html);
  9354. if (!stack.length && options.warn) {
  9355. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9356. start: index + html.length
  9357. });
  9358. }
  9359. break;
  9360. }
  9361. }
  9362. // Clean up any remaining tags
  9363. parseEndTag();
  9364. function advance(n) {
  9365. index += n;
  9366. html = html.substring(n);
  9367. }
  9368. function parseStartTag() {
  9369. const start = html.match(startTagOpen);
  9370. if (start) {
  9371. const match = {
  9372. tagName: start[1],
  9373. attrs: [],
  9374. start: index
  9375. };
  9376. advance(start[0].length);
  9377. let end, attr;
  9378. while (!(end = html.match(startTagClose)) &&
  9379. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9380. attr.start = index;
  9381. advance(attr[0].length);
  9382. attr.end = index;
  9383. match.attrs.push(attr);
  9384. }
  9385. if (end) {
  9386. match.unarySlash = end[1];
  9387. advance(end[0].length);
  9388. match.end = index;
  9389. return match;
  9390. }
  9391. }
  9392. }
  9393. function handleStartTag(match) {
  9394. const tagName = match.tagName;
  9395. const unarySlash = match.unarySlash;
  9396. if (expectHTML) {
  9397. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9398. parseEndTag(lastTag);
  9399. }
  9400. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9401. parseEndTag(tagName);
  9402. }
  9403. }
  9404. const unary = isUnaryTag(tagName) || !!unarySlash;
  9405. const l = match.attrs.length;
  9406. const attrs = new Array(l);
  9407. for (let i = 0; i < l; i++) {
  9408. const args = match.attrs[i];
  9409. const value = args[3] || args[4] || args[5] || '';
  9410. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9411. ? options.shouldDecodeNewlinesForHref
  9412. : options.shouldDecodeNewlines;
  9413. attrs[i] = {
  9414. name: args[1],
  9415. value: decodeAttr(value, shouldDecodeNewlines)
  9416. };
  9417. if (options.outputSourceRange) {
  9418. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9419. attrs[i].end = args.end;
  9420. }
  9421. }
  9422. if (!unary) {
  9423. stack.push({
  9424. tag: tagName,
  9425. lowerCasedTag: tagName.toLowerCase(),
  9426. attrs: attrs,
  9427. start: match.start,
  9428. end: match.end
  9429. });
  9430. lastTag = tagName;
  9431. }
  9432. if (options.start) {
  9433. options.start(tagName, attrs, unary, match.start, match.end);
  9434. }
  9435. }
  9436. function parseEndTag(tagName, start, end) {
  9437. let pos, lowerCasedTagName;
  9438. if (start == null)
  9439. start = index;
  9440. if (end == null)
  9441. end = index;
  9442. // Find the closest opened tag of the same type
  9443. if (tagName) {
  9444. lowerCasedTagName = tagName.toLowerCase();
  9445. for (pos = stack.length - 1; pos >= 0; pos--) {
  9446. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9447. break;
  9448. }
  9449. }
  9450. }
  9451. else {
  9452. // If no tag name is provided, clean shop
  9453. pos = 0;
  9454. }
  9455. if (pos >= 0) {
  9456. // Close all the open elements, up the stack
  9457. for (let i = stack.length - 1; i >= pos; i--) {
  9458. if ((i > pos || !tagName) && options.warn) {
  9459. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9460. start: stack[i].start,
  9461. end: stack[i].end
  9462. });
  9463. }
  9464. if (options.end) {
  9465. options.end(stack[i].tag, start, end);
  9466. }
  9467. }
  9468. // Remove the open elements from the stack
  9469. stack.length = pos;
  9470. lastTag = pos && stack[pos - 1].tag;
  9471. }
  9472. else if (lowerCasedTagName === 'br') {
  9473. if (options.start) {
  9474. options.start(tagName, [], true, start, end);
  9475. }
  9476. }
  9477. else if (lowerCasedTagName === 'p') {
  9478. if (options.start) {
  9479. options.start(tagName, [], false, start, end);
  9480. }
  9481. if (options.end) {
  9482. options.end(tagName, start, end);
  9483. }
  9484. }
  9485. }
  9486. }
  9487. const onRE = /^@|^v-on:/;
  9488. const dirRE = /^v-|^@|^:|^#/;
  9489. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9490. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9491. const stripParensRE = /^\(|\)$/g;
  9492. const dynamicArgRE = /^\[.*\]$/;
  9493. const argRE = /:(.*)$/;
  9494. const bindRE = /^:|^\.|^v-bind:/;
  9495. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9496. const slotRE = /^v-slot(:|$)|^#/;
  9497. const lineBreakRE = /[\r\n]/;
  9498. const whitespaceRE = /[ \f\t\r\n]+/g;
  9499. const invalidAttributeRE = /[\s"'<>\/=]/;
  9500. const decodeHTMLCached = cached(he.decode);
  9501. const emptySlotScopeToken = `_empty_`;
  9502. // configurable state
  9503. let warn;
  9504. let delimiters;
  9505. let transforms;
  9506. let preTransforms;
  9507. let postTransforms;
  9508. let platformIsPreTag;
  9509. let platformMustUseProp;
  9510. let platformGetTagNamespace;
  9511. let maybeComponent;
  9512. function createASTElement(tag, attrs, parent) {
  9513. return {
  9514. type: 1,
  9515. tag,
  9516. attrsList: attrs,
  9517. attrsMap: makeAttrsMap(attrs),
  9518. rawAttrsMap: {},
  9519. parent,
  9520. children: []
  9521. };
  9522. }
  9523. /**
  9524. * Convert HTML string to AST.
  9525. */
  9526. function parse(template, options) {
  9527. warn = options.warn || baseWarn;
  9528. platformIsPreTag = options.isPreTag || no;
  9529. platformMustUseProp = options.mustUseProp || no;
  9530. platformGetTagNamespace = options.getTagNamespace || no;
  9531. const isReservedTag = options.isReservedTag || no;
  9532. maybeComponent = (el) => !!(el.component ||
  9533. el.attrsMap[':is'] ||
  9534. el.attrsMap['v-bind:is'] ||
  9535. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9536. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9537. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9538. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9539. delimiters = options.delimiters;
  9540. const stack = [];
  9541. const preserveWhitespace = options.preserveWhitespace !== false;
  9542. const whitespaceOption = options.whitespace;
  9543. let root;
  9544. let currentParent;
  9545. let inVPre = false;
  9546. let inPre = false;
  9547. let warned = false;
  9548. function warnOnce(msg, range) {
  9549. if (!warned) {
  9550. warned = true;
  9551. warn(msg, range);
  9552. }
  9553. }
  9554. function closeElement(element) {
  9555. trimEndingWhitespace(element);
  9556. if (!inVPre && !element.processed) {
  9557. element = processElement(element, options);
  9558. }
  9559. // tree management
  9560. if (!stack.length && element !== root) {
  9561. // allow root elements with v-if, v-else-if and v-else
  9562. if (root.if && (element.elseif || element.else)) {
  9563. {
  9564. checkRootConstraints(element);
  9565. }
  9566. addIfCondition(root, {
  9567. exp: element.elseif,
  9568. block: element
  9569. });
  9570. }
  9571. else {
  9572. warnOnce(`Component template should contain exactly one root element. ` +
  9573. `If you are using v-if on multiple elements, ` +
  9574. `use v-else-if to chain them instead.`, { start: element.start });
  9575. }
  9576. }
  9577. if (currentParent && !element.forbidden) {
  9578. if (element.elseif || element.else) {
  9579. processIfConditions(element, currentParent);
  9580. }
  9581. else {
  9582. if (element.slotScope) {
  9583. // scoped slot
  9584. // keep it in the children list so that v-else(-if) conditions can
  9585. // find it as the prev node.
  9586. const name = element.slotTarget || '"default"';
  9587. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9588. }
  9589. currentParent.children.push(element);
  9590. element.parent = currentParent;
  9591. }
  9592. }
  9593. // final children cleanup
  9594. // filter out scoped slots
  9595. element.children = element.children.filter(c => !c.slotScope);
  9596. // remove trailing whitespace node again
  9597. trimEndingWhitespace(element);
  9598. // check pre state
  9599. if (element.pre) {
  9600. inVPre = false;
  9601. }
  9602. if (platformIsPreTag(element.tag)) {
  9603. inPre = false;
  9604. }
  9605. // apply post-transforms
  9606. for (let i = 0; i < postTransforms.length; i++) {
  9607. postTransforms[i](element, options);
  9608. }
  9609. }
  9610. function trimEndingWhitespace(el) {
  9611. // remove trailing whitespace node
  9612. if (!inPre) {
  9613. let lastNode;
  9614. while ((lastNode = el.children[el.children.length - 1]) &&
  9615. lastNode.type === 3 &&
  9616. lastNode.text === ' ') {
  9617. el.children.pop();
  9618. }
  9619. }
  9620. }
  9621. function checkRootConstraints(el) {
  9622. if (el.tag === 'slot' || el.tag === 'template') {
  9623. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9624. 'contain multiple nodes.', { start: el.start });
  9625. }
  9626. if (el.attrsMap.hasOwnProperty('v-for')) {
  9627. warnOnce('Cannot use v-for on stateful component root element because ' +
  9628. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9629. }
  9630. }
  9631. parseHTML(template, {
  9632. warn,
  9633. expectHTML: options.expectHTML,
  9634. isUnaryTag: options.isUnaryTag,
  9635. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9636. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9637. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9638. shouldKeepComment: options.comments,
  9639. outputSourceRange: options.outputSourceRange,
  9640. start(tag, attrs, unary, start, end) {
  9641. // check namespace.
  9642. // inherit parent ns if there is one
  9643. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9644. // handle IE svg bug
  9645. /* istanbul ignore if */
  9646. if (isIE && ns === 'svg') {
  9647. attrs = guardIESVGBug(attrs);
  9648. }
  9649. let element = createASTElement(tag, attrs, currentParent);
  9650. if (ns) {
  9651. element.ns = ns;
  9652. }
  9653. {
  9654. if (options.outputSourceRange) {
  9655. element.start = start;
  9656. element.end = end;
  9657. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9658. cumulated[attr.name] = attr;
  9659. return cumulated;
  9660. }, {});
  9661. }
  9662. attrs.forEach(attr => {
  9663. if (invalidAttributeRE.test(attr.name)) {
  9664. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9665. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9666. ? {
  9667. start: attr.start + attr.name.indexOf(`[`),
  9668. end: attr.start + attr.name.length
  9669. }
  9670. : undefined);
  9671. }
  9672. });
  9673. }
  9674. if (isForbiddenTag(element) && !isServerRendering()) {
  9675. element.forbidden = true;
  9676. warn('Templates should only be responsible for mapping the state to the ' +
  9677. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9678. `<${tag}>` +
  9679. ', as they will not be parsed.', { start: element.start });
  9680. }
  9681. // apply pre-transforms
  9682. for (let i = 0; i < preTransforms.length; i++) {
  9683. element = preTransforms[i](element, options) || element;
  9684. }
  9685. if (!inVPre) {
  9686. processPre(element);
  9687. if (element.pre) {
  9688. inVPre = true;
  9689. }
  9690. }
  9691. if (platformIsPreTag(element.tag)) {
  9692. inPre = true;
  9693. }
  9694. if (inVPre) {
  9695. processRawAttrs(element);
  9696. }
  9697. else if (!element.processed) {
  9698. // structural directives
  9699. processFor(element);
  9700. processIf(element);
  9701. processOnce(element);
  9702. }
  9703. if (!root) {
  9704. root = element;
  9705. {
  9706. checkRootConstraints(root);
  9707. }
  9708. }
  9709. if (!unary) {
  9710. currentParent = element;
  9711. stack.push(element);
  9712. }
  9713. else {
  9714. closeElement(element);
  9715. }
  9716. },
  9717. end(tag, start, end) {
  9718. const element = stack[stack.length - 1];
  9719. // pop stack
  9720. stack.length -= 1;
  9721. currentParent = stack[stack.length - 1];
  9722. if (options.outputSourceRange) {
  9723. element.end = end;
  9724. }
  9725. closeElement(element);
  9726. },
  9727. chars(text, start, end) {
  9728. if (!currentParent) {
  9729. {
  9730. if (text === template) {
  9731. warnOnce('Component template requires a root element, rather than just text.', { start });
  9732. }
  9733. else if ((text = text.trim())) {
  9734. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9735. start
  9736. });
  9737. }
  9738. }
  9739. return;
  9740. }
  9741. // IE textarea placeholder bug
  9742. /* istanbul ignore if */
  9743. if (isIE &&
  9744. currentParent.tag === 'textarea' &&
  9745. currentParent.attrsMap.placeholder === text) {
  9746. return;
  9747. }
  9748. const children = currentParent.children;
  9749. if (inPre || text.trim()) {
  9750. text = isTextTag(currentParent)
  9751. ? text
  9752. : decodeHTMLCached(text);
  9753. }
  9754. else if (!children.length) {
  9755. // remove the whitespace-only node right after an opening tag
  9756. text = '';
  9757. }
  9758. else if (whitespaceOption) {
  9759. if (whitespaceOption === 'condense') {
  9760. // in condense mode, remove the whitespace node if it contains
  9761. // line break, otherwise condense to a single space
  9762. text = lineBreakRE.test(text) ? '' : ' ';
  9763. }
  9764. else {
  9765. text = ' ';
  9766. }
  9767. }
  9768. else {
  9769. text = preserveWhitespace ? ' ' : '';
  9770. }
  9771. if (text) {
  9772. if (!inPre && whitespaceOption === 'condense') {
  9773. // condense consecutive whitespaces into single space
  9774. text = text.replace(whitespaceRE, ' ');
  9775. }
  9776. let res;
  9777. let child;
  9778. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9779. child = {
  9780. type: 2,
  9781. expression: res.expression,
  9782. tokens: res.tokens,
  9783. text
  9784. };
  9785. }
  9786. else if (text !== ' ' ||
  9787. !children.length ||
  9788. children[children.length - 1].text !== ' ') {
  9789. child = {
  9790. type: 3,
  9791. text
  9792. };
  9793. }
  9794. if (child) {
  9795. if (options.outputSourceRange) {
  9796. child.start = start;
  9797. child.end = end;
  9798. }
  9799. children.push(child);
  9800. }
  9801. }
  9802. },
  9803. comment(text, start, end) {
  9804. // adding anything as a sibling to the root node is forbidden
  9805. // comments should still be allowed, but ignored
  9806. if (currentParent) {
  9807. const child = {
  9808. type: 3,
  9809. text,
  9810. isComment: true
  9811. };
  9812. if (options.outputSourceRange) {
  9813. child.start = start;
  9814. child.end = end;
  9815. }
  9816. currentParent.children.push(child);
  9817. }
  9818. }
  9819. });
  9820. return root;
  9821. }
  9822. function processPre(el) {
  9823. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9824. el.pre = true;
  9825. }
  9826. }
  9827. function processRawAttrs(el) {
  9828. const list = el.attrsList;
  9829. const len = list.length;
  9830. if (len) {
  9831. const attrs = (el.attrs = new Array(len));
  9832. for (let i = 0; i < len; i++) {
  9833. attrs[i] = {
  9834. name: list[i].name,
  9835. value: JSON.stringify(list[i].value)
  9836. };
  9837. if (list[i].start != null) {
  9838. attrs[i].start = list[i].start;
  9839. attrs[i].end = list[i].end;
  9840. }
  9841. }
  9842. }
  9843. else if (!el.pre) {
  9844. // non root node in pre blocks with no attributes
  9845. el.plain = true;
  9846. }
  9847. }
  9848. function processElement(element, options) {
  9849. processKey(element);
  9850. // determine whether this is a plain element after
  9851. // removing structural attributes
  9852. element.plain =
  9853. !element.key && !element.scopedSlots && !element.attrsList.length;
  9854. processRef(element);
  9855. processSlotContent(element);
  9856. processSlotOutlet(element);
  9857. processComponent(element);
  9858. for (let i = 0; i < transforms.length; i++) {
  9859. element = transforms[i](element, options) || element;
  9860. }
  9861. processAttrs(element);
  9862. return element;
  9863. }
  9864. function processKey(el) {
  9865. const exp = getBindingAttr(el, 'key');
  9866. if (exp) {
  9867. {
  9868. if (el.tag === 'template') {
  9869. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9870. }
  9871. if (el.for) {
  9872. const iterator = el.iterator2 || el.iterator1;
  9873. const parent = el.parent;
  9874. if (iterator &&
  9875. iterator === exp &&
  9876. parent &&
  9877. parent.tag === 'transition-group') {
  9878. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9879. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9880. }
  9881. }
  9882. }
  9883. el.key = exp;
  9884. }
  9885. }
  9886. function processRef(el) {
  9887. const ref = getBindingAttr(el, 'ref');
  9888. if (ref) {
  9889. el.ref = ref;
  9890. el.refInFor = checkInFor(el);
  9891. }
  9892. }
  9893. function processFor(el) {
  9894. let exp;
  9895. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9896. const res = parseFor(exp);
  9897. if (res) {
  9898. extend(el, res);
  9899. }
  9900. else {
  9901. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9902. }
  9903. }
  9904. }
  9905. function parseFor(exp) {
  9906. const inMatch = exp.match(forAliasRE);
  9907. if (!inMatch)
  9908. return;
  9909. const res = {};
  9910. res.for = inMatch[2].trim();
  9911. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9912. const iteratorMatch = alias.match(forIteratorRE);
  9913. if (iteratorMatch) {
  9914. res.alias = alias.replace(forIteratorRE, '').trim();
  9915. res.iterator1 = iteratorMatch[1].trim();
  9916. if (iteratorMatch[2]) {
  9917. res.iterator2 = iteratorMatch[2].trim();
  9918. }
  9919. }
  9920. else {
  9921. res.alias = alias;
  9922. }
  9923. return res;
  9924. }
  9925. function processIf(el) {
  9926. const exp = getAndRemoveAttr(el, 'v-if');
  9927. if (exp) {
  9928. el.if = exp;
  9929. addIfCondition(el, {
  9930. exp: exp,
  9931. block: el
  9932. });
  9933. }
  9934. else {
  9935. if (getAndRemoveAttr(el, 'v-else') != null) {
  9936. el.else = true;
  9937. }
  9938. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9939. if (elseif) {
  9940. el.elseif = elseif;
  9941. }
  9942. }
  9943. }
  9944. function processIfConditions(el, parent) {
  9945. const prev = findPrevElement(parent.children);
  9946. if (prev && prev.if) {
  9947. addIfCondition(prev, {
  9948. exp: el.elseif,
  9949. block: el
  9950. });
  9951. }
  9952. else {
  9953. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  9954. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  9955. }
  9956. }
  9957. function findPrevElement(children) {
  9958. let i = children.length;
  9959. while (i--) {
  9960. if (children[i].type === 1) {
  9961. return children[i];
  9962. }
  9963. else {
  9964. if (children[i].text !== ' ') {
  9965. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9966. `will be ignored.`, children[i]);
  9967. }
  9968. children.pop();
  9969. }
  9970. }
  9971. }
  9972. function addIfCondition(el, condition) {
  9973. if (!el.ifConditions) {
  9974. el.ifConditions = [];
  9975. }
  9976. el.ifConditions.push(condition);
  9977. }
  9978. function processOnce(el) {
  9979. const once = getAndRemoveAttr(el, 'v-once');
  9980. if (once != null) {
  9981. el.once = true;
  9982. }
  9983. }
  9984. // handle content being passed to a component as slot,
  9985. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9986. function processSlotContent(el) {
  9987. let slotScope;
  9988. if (el.tag === 'template') {
  9989. slotScope = getAndRemoveAttr(el, 'scope');
  9990. /* istanbul ignore if */
  9991. if (slotScope) {
  9992. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  9993. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  9994. `can also be used on plain elements in addition to <template> to ` +
  9995. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  9996. }
  9997. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9998. }
  9999. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10000. /* istanbul ignore if */
  10001. if (el.attrsMap['v-for']) {
  10002. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10003. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10004. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10005. }
  10006. el.slotScope = slotScope;
  10007. }
  10008. // slot="xxx"
  10009. const slotTarget = getBindingAttr(el, 'slot');
  10010. if (slotTarget) {
  10011. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10012. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10013. // preserve slot as an attribute for native shadow DOM compat
  10014. // only for non-scoped slots.
  10015. if (el.tag !== 'template' && !el.slotScope) {
  10016. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10017. }
  10018. }
  10019. // 2.6 v-slot syntax
  10020. {
  10021. if (el.tag === 'template') {
  10022. // v-slot on <template>
  10023. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10024. if (slotBinding) {
  10025. {
  10026. if (el.slotTarget || el.slotScope) {
  10027. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10028. }
  10029. if (el.parent && !maybeComponent(el.parent)) {
  10030. warn(`<template v-slot> can only appear at the root level inside ` +
  10031. `the receiving component`, el);
  10032. }
  10033. }
  10034. const { name, dynamic } = getSlotName(slotBinding);
  10035. el.slotTarget = name;
  10036. el.slotTargetDynamic = dynamic;
  10037. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10038. }
  10039. }
  10040. else {
  10041. // v-slot on component, denotes default slot
  10042. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10043. if (slotBinding) {
  10044. {
  10045. if (!maybeComponent(el)) {
  10046. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10047. }
  10048. if (el.slotScope || el.slotTarget) {
  10049. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10050. }
  10051. if (el.scopedSlots) {
  10052. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10053. `<template> syntax when there are other named slots.`, slotBinding);
  10054. }
  10055. }
  10056. // add the component's children to its default slot
  10057. const slots = el.scopedSlots || (el.scopedSlots = {});
  10058. const { name, dynamic } = getSlotName(slotBinding);
  10059. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10060. slotContainer.slotTarget = name;
  10061. slotContainer.slotTargetDynamic = dynamic;
  10062. slotContainer.children = el.children.filter((c) => {
  10063. if (!c.slotScope) {
  10064. c.parent = slotContainer;
  10065. return true;
  10066. }
  10067. });
  10068. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10069. // remove children as they are returned from scopedSlots now
  10070. el.children = [];
  10071. // mark el non-plain so data gets generated
  10072. el.plain = false;
  10073. }
  10074. }
  10075. }
  10076. }
  10077. function getSlotName(binding) {
  10078. let name = binding.name.replace(slotRE, '');
  10079. if (!name) {
  10080. if (binding.name[0] !== '#') {
  10081. name = 'default';
  10082. }
  10083. else {
  10084. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10085. }
  10086. }
  10087. return dynamicArgRE.test(name)
  10088. ? // dynamic [name]
  10089. { name: name.slice(1, -1), dynamic: true }
  10090. : // static name
  10091. { name: `"${name}"`, dynamic: false };
  10092. }
  10093. // handle <slot/> outlets
  10094. function processSlotOutlet(el) {
  10095. if (el.tag === 'slot') {
  10096. el.slotName = getBindingAttr(el, 'name');
  10097. if (el.key) {
  10098. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10099. `and can possibly expand into multiple elements. ` +
  10100. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10101. }
  10102. }
  10103. }
  10104. function processComponent(el) {
  10105. let binding;
  10106. if ((binding = getBindingAttr(el, 'is'))) {
  10107. el.component = binding;
  10108. }
  10109. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10110. el.inlineTemplate = true;
  10111. }
  10112. }
  10113. function processAttrs(el) {
  10114. const list = el.attrsList;
  10115. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10116. for (i = 0, l = list.length; i < l; i++) {
  10117. name = rawName = list[i].name;
  10118. value = list[i].value;
  10119. if (dirRE.test(name)) {
  10120. // mark element as dynamic
  10121. el.hasBindings = true;
  10122. // modifiers
  10123. modifiers = parseModifiers(name.replace(dirRE, ''));
  10124. // support .foo shorthand syntax for the .prop modifier
  10125. if (modifiers) {
  10126. name = name.replace(modifierRE, '');
  10127. }
  10128. if (bindRE.test(name)) {
  10129. // v-bind
  10130. name = name.replace(bindRE, '');
  10131. value = parseFilters(value);
  10132. isDynamic = dynamicArgRE.test(name);
  10133. if (isDynamic) {
  10134. name = name.slice(1, -1);
  10135. }
  10136. if (value.trim().length === 0) {
  10137. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10138. }
  10139. if (modifiers) {
  10140. if (modifiers.prop && !isDynamic) {
  10141. name = camelize(name);
  10142. if (name === 'innerHtml')
  10143. name = 'innerHTML';
  10144. }
  10145. if (modifiers.camel && !isDynamic) {
  10146. name = camelize(name);
  10147. }
  10148. if (modifiers.sync) {
  10149. syncGen = genAssignmentCode(value, `$event`);
  10150. if (!isDynamic) {
  10151. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10152. if (hyphenate(name) !== camelize(name)) {
  10153. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10154. }
  10155. }
  10156. else {
  10157. // handler w/ dynamic event name
  10158. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10159. );
  10160. }
  10161. }
  10162. }
  10163. if ((modifiers && modifiers.prop) ||
  10164. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10165. addProp(el, name, value, list[i], isDynamic);
  10166. }
  10167. else {
  10168. addAttr(el, name, value, list[i], isDynamic);
  10169. }
  10170. }
  10171. else if (onRE.test(name)) {
  10172. // v-on
  10173. name = name.replace(onRE, '');
  10174. isDynamic = dynamicArgRE.test(name);
  10175. if (isDynamic) {
  10176. name = name.slice(1, -1);
  10177. }
  10178. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10179. }
  10180. else {
  10181. // normal directives
  10182. name = name.replace(dirRE, '');
  10183. // parse arg
  10184. const argMatch = name.match(argRE);
  10185. let arg = argMatch && argMatch[1];
  10186. isDynamic = false;
  10187. if (arg) {
  10188. name = name.slice(0, -(arg.length + 1));
  10189. if (dynamicArgRE.test(arg)) {
  10190. arg = arg.slice(1, -1);
  10191. isDynamic = true;
  10192. }
  10193. }
  10194. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10195. if (name === 'model') {
  10196. checkForAliasModel(el, value);
  10197. }
  10198. }
  10199. }
  10200. else {
  10201. // literal attribute
  10202. {
  10203. const res = parseText(value, delimiters);
  10204. if (res) {
  10205. warn(`${name}="${value}": ` +
  10206. 'Interpolation inside attributes has been removed. ' +
  10207. 'Use v-bind or the colon shorthand instead. For example, ' +
  10208. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10209. }
  10210. }
  10211. addAttr(el, name, JSON.stringify(value), list[i]);
  10212. // #6887 firefox doesn't update muted state if set via attribute
  10213. // even immediately after element creation
  10214. if (!el.component &&
  10215. name === 'muted' &&
  10216. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10217. addProp(el, name, 'true', list[i]);
  10218. }
  10219. }
  10220. }
  10221. }
  10222. function checkInFor(el) {
  10223. let parent = el;
  10224. while (parent) {
  10225. if (parent.for !== undefined) {
  10226. return true;
  10227. }
  10228. parent = parent.parent;
  10229. }
  10230. return false;
  10231. }
  10232. function parseModifiers(name) {
  10233. const match = name.match(modifierRE);
  10234. if (match) {
  10235. const ret = {};
  10236. match.forEach(m => {
  10237. ret[m.slice(1)] = true;
  10238. });
  10239. return ret;
  10240. }
  10241. }
  10242. function makeAttrsMap(attrs) {
  10243. const map = {};
  10244. for (let i = 0, l = attrs.length; i < l; i++) {
  10245. if (map[attrs[i].name] && !isIE && !isEdge) {
  10246. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10247. }
  10248. map[attrs[i].name] = attrs[i].value;
  10249. }
  10250. return map;
  10251. }
  10252. // for script (e.g. type="x/template") or style, do not decode content
  10253. function isTextTag(el) {
  10254. return el.tag === 'script' || el.tag === 'style';
  10255. }
  10256. function isForbiddenTag(el) {
  10257. return (el.tag === 'style' ||
  10258. (el.tag === 'script' &&
  10259. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10260. }
  10261. const ieNSBug = /^xmlns:NS\d+/;
  10262. const ieNSPrefix = /^NS\d+:/;
  10263. /* istanbul ignore next */
  10264. function guardIESVGBug(attrs) {
  10265. const res = [];
  10266. for (let i = 0; i < attrs.length; i++) {
  10267. const attr = attrs[i];
  10268. if (!ieNSBug.test(attr.name)) {
  10269. attr.name = attr.name.replace(ieNSPrefix, '');
  10270. res.push(attr);
  10271. }
  10272. }
  10273. return res;
  10274. }
  10275. function checkForAliasModel(el, value) {
  10276. let _el = el;
  10277. while (_el) {
  10278. if (_el.for && _el.alias === value) {
  10279. warn(`<${el.tag} v-model="${value}">: ` +
  10280. `You are binding v-model directly to a v-for iteration alias. ` +
  10281. `This will not be able to modify the v-for source array because ` +
  10282. `writing to the alias is like modifying a function local variable. ` +
  10283. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10284. }
  10285. _el = _el.parent;
  10286. }
  10287. }
  10288. /**
  10289. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10290. * Turn this:
  10291. * <input v-model="data[type]" :type="type">
  10292. * into this:
  10293. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10294. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10295. * <input v-else :type="type" v-model="data[type]">
  10296. */
  10297. function preTransformNode(el, options) {
  10298. if (el.tag === 'input') {
  10299. const map = el.attrsMap;
  10300. if (!map['v-model']) {
  10301. return;
  10302. }
  10303. let typeBinding;
  10304. if (map[':type'] || map['v-bind:type']) {
  10305. typeBinding = getBindingAttr(el, 'type');
  10306. }
  10307. if (!map.type && !typeBinding && map['v-bind']) {
  10308. typeBinding = `(${map['v-bind']}).type`;
  10309. }
  10310. if (typeBinding) {
  10311. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10312. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10313. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10314. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10315. // 1. checkbox
  10316. const branch0 = cloneASTElement(el);
  10317. // process for on the main node
  10318. processFor(branch0);
  10319. addRawAttr(branch0, 'type', 'checkbox');
  10320. processElement(branch0, options);
  10321. branch0.processed = true; // prevent it from double-processed
  10322. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10323. addIfCondition(branch0, {
  10324. exp: branch0.if,
  10325. block: branch0
  10326. });
  10327. // 2. add radio else-if condition
  10328. const branch1 = cloneASTElement(el);
  10329. getAndRemoveAttr(branch1, 'v-for', true);
  10330. addRawAttr(branch1, 'type', 'radio');
  10331. processElement(branch1, options);
  10332. addIfCondition(branch0, {
  10333. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10334. block: branch1
  10335. });
  10336. // 3. other
  10337. const branch2 = cloneASTElement(el);
  10338. getAndRemoveAttr(branch2, 'v-for', true);
  10339. addRawAttr(branch2, ':type', typeBinding);
  10340. processElement(branch2, options);
  10341. addIfCondition(branch0, {
  10342. exp: ifCondition,
  10343. block: branch2
  10344. });
  10345. if (hasElse) {
  10346. branch0.else = true;
  10347. }
  10348. else if (elseIfCondition) {
  10349. branch0.elseif = elseIfCondition;
  10350. }
  10351. return branch0;
  10352. }
  10353. }
  10354. }
  10355. function cloneASTElement(el) {
  10356. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10357. }
  10358. var model = {
  10359. preTransformNode
  10360. };
  10361. var modules = [klass, style, model];
  10362. function text(el, dir) {
  10363. if (dir.value) {
  10364. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10365. }
  10366. }
  10367. function html(el, dir) {
  10368. if (dir.value) {
  10369. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10370. }
  10371. }
  10372. var directives = {
  10373. model: model$1,
  10374. text,
  10375. html
  10376. };
  10377. const baseOptions = {
  10378. expectHTML: true,
  10379. modules,
  10380. directives,
  10381. isPreTag,
  10382. isUnaryTag,
  10383. mustUseProp,
  10384. canBeLeftOpenTag,
  10385. isReservedTag,
  10386. getTagNamespace,
  10387. staticKeys: genStaticKeys$1(modules)
  10388. };
  10389. let isStaticKey;
  10390. let isPlatformReservedTag;
  10391. const genStaticKeysCached = cached(genStaticKeys);
  10392. /**
  10393. * Goal of the optimizer: walk the generated template AST tree
  10394. * and detect sub-trees that are purely static, i.e. parts of
  10395. * the DOM that never needs to change.
  10396. *
  10397. * Once we detect these sub-trees, we can:
  10398. *
  10399. * 1. Hoist them into constants, so that we no longer need to
  10400. * create fresh nodes for them on each re-render;
  10401. * 2. Completely skip them in the patching process.
  10402. */
  10403. function optimize(root, options) {
  10404. if (!root)
  10405. return;
  10406. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10407. isPlatformReservedTag = options.isReservedTag || no;
  10408. // first pass: mark all non-static nodes.
  10409. markStatic(root);
  10410. // second pass: mark static roots.
  10411. markStaticRoots(root, false);
  10412. }
  10413. function genStaticKeys(keys) {
  10414. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10415. (keys ? ',' + keys : ''));
  10416. }
  10417. function markStatic(node) {
  10418. node.static = isStatic(node);
  10419. if (node.type === 1) {
  10420. // do not make component slot content static. this avoids
  10421. // 1. components not able to mutate slot nodes
  10422. // 2. static slot content fails for hot-reloading
  10423. if (!isPlatformReservedTag(node.tag) &&
  10424. node.tag !== 'slot' &&
  10425. node.attrsMap['inline-template'] == null) {
  10426. return;
  10427. }
  10428. for (let i = 0, l = node.children.length; i < l; i++) {
  10429. const child = node.children[i];
  10430. markStatic(child);
  10431. if (!child.static) {
  10432. node.static = false;
  10433. }
  10434. }
  10435. if (node.ifConditions) {
  10436. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10437. const block = node.ifConditions[i].block;
  10438. markStatic(block);
  10439. if (!block.static) {
  10440. node.static = false;
  10441. }
  10442. }
  10443. }
  10444. }
  10445. }
  10446. function markStaticRoots(node, isInFor) {
  10447. if (node.type === 1) {
  10448. if (node.static || node.once) {
  10449. node.staticInFor = isInFor;
  10450. }
  10451. // For a node to qualify as a static root, it should have children that
  10452. // are not just static text. Otherwise the cost of hoisting out will
  10453. // outweigh the benefits and it's better off to just always render it fresh.
  10454. if (node.static &&
  10455. node.children.length &&
  10456. !(node.children.length === 1 && node.children[0].type === 3)) {
  10457. node.staticRoot = true;
  10458. return;
  10459. }
  10460. else {
  10461. node.staticRoot = false;
  10462. }
  10463. if (node.children) {
  10464. for (let i = 0, l = node.children.length; i < l; i++) {
  10465. markStaticRoots(node.children[i], isInFor || !!node.for);
  10466. }
  10467. }
  10468. if (node.ifConditions) {
  10469. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10470. markStaticRoots(node.ifConditions[i].block, isInFor);
  10471. }
  10472. }
  10473. }
  10474. }
  10475. function isStatic(node) {
  10476. if (node.type === 2) {
  10477. // expression
  10478. return false;
  10479. }
  10480. if (node.type === 3) {
  10481. // text
  10482. return true;
  10483. }
  10484. return !!(node.pre ||
  10485. (!node.hasBindings && // no dynamic bindings
  10486. !node.if &&
  10487. !node.for && // not v-if or v-for or v-else
  10488. !isBuiltInTag(node.tag) && // not a built-in
  10489. isPlatformReservedTag(node.tag) && // not a component
  10490. !isDirectChildOfTemplateFor(node) &&
  10491. Object.keys(node).every(isStaticKey)));
  10492. }
  10493. function isDirectChildOfTemplateFor(node) {
  10494. while (node.parent) {
  10495. node = node.parent;
  10496. if (node.tag !== 'template') {
  10497. return false;
  10498. }
  10499. if (node.for) {
  10500. return true;
  10501. }
  10502. }
  10503. return false;
  10504. }
  10505. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10506. const fnInvokeRE = /\([^)]*?\);*$/;
  10507. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10508. // KeyboardEvent.keyCode aliases
  10509. const keyCodes = {
  10510. esc: 27,
  10511. tab: 9,
  10512. enter: 13,
  10513. space: 32,
  10514. up: 38,
  10515. left: 37,
  10516. right: 39,
  10517. down: 40,
  10518. delete: [8, 46]
  10519. };
  10520. // KeyboardEvent.key aliases
  10521. const keyNames = {
  10522. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10523. esc: ['Esc', 'Escape'],
  10524. tab: 'Tab',
  10525. enter: 'Enter',
  10526. // #9112: IE11 uses `Spacebar` for Space key name.
  10527. space: [' ', 'Spacebar'],
  10528. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10529. up: ['Up', 'ArrowUp'],
  10530. left: ['Left', 'ArrowLeft'],
  10531. right: ['Right', 'ArrowRight'],
  10532. down: ['Down', 'ArrowDown'],
  10533. // #9112: IE11 uses `Del` for Delete key name.
  10534. delete: ['Backspace', 'Delete', 'Del']
  10535. };
  10536. // #4868: modifiers that prevent the execution of the listener
  10537. // need to explicitly return null so that we can determine whether to remove
  10538. // the listener for .once
  10539. const genGuard = condition => `if(${condition})return null;`;
  10540. const modifierCode = {
  10541. stop: '$event.stopPropagation();',
  10542. prevent: '$event.preventDefault();',
  10543. self: genGuard(`$event.target !== $event.currentTarget`),
  10544. ctrl: genGuard(`!$event.ctrlKey`),
  10545. shift: genGuard(`!$event.shiftKey`),
  10546. alt: genGuard(`!$event.altKey`),
  10547. meta: genGuard(`!$event.metaKey`),
  10548. left: genGuard(`'button' in $event && $event.button !== 0`),
  10549. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10550. right: genGuard(`'button' in $event && $event.button !== 2`)
  10551. };
  10552. function genHandlers(events, isNative) {
  10553. const prefix = isNative ? 'nativeOn:' : 'on:';
  10554. let staticHandlers = ``;
  10555. let dynamicHandlers = ``;
  10556. for (const name in events) {
  10557. const handlerCode = genHandler(events[name]);
  10558. //@ts-expect-error
  10559. if (events[name] && events[name].dynamic) {
  10560. dynamicHandlers += `${name},${handlerCode},`;
  10561. }
  10562. else {
  10563. staticHandlers += `"${name}":${handlerCode},`;
  10564. }
  10565. }
  10566. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10567. if (dynamicHandlers) {
  10568. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10569. }
  10570. else {
  10571. return prefix + staticHandlers;
  10572. }
  10573. }
  10574. function genHandler(handler) {
  10575. if (!handler) {
  10576. return 'function(){}';
  10577. }
  10578. if (Array.isArray(handler)) {
  10579. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10580. }
  10581. const isMethodPath = simplePathRE.test(handler.value);
  10582. const isFunctionExpression = fnExpRE.test(handler.value);
  10583. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10584. if (!handler.modifiers) {
  10585. if (isMethodPath || isFunctionExpression) {
  10586. return handler.value;
  10587. }
  10588. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10589. }
  10590. else {
  10591. let code = '';
  10592. let genModifierCode = '';
  10593. const keys = [];
  10594. for (const key in handler.modifiers) {
  10595. if (modifierCode[key]) {
  10596. genModifierCode += modifierCode[key];
  10597. // left/right
  10598. if (keyCodes[key]) {
  10599. keys.push(key);
  10600. }
  10601. }
  10602. else if (key === 'exact') {
  10603. const modifiers = handler.modifiers;
  10604. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10605. .filter(keyModifier => !modifiers[keyModifier])
  10606. .map(keyModifier => `$event.${keyModifier}Key`)
  10607. .join('||'));
  10608. }
  10609. else {
  10610. keys.push(key);
  10611. }
  10612. }
  10613. if (keys.length) {
  10614. code += genKeyFilter(keys);
  10615. }
  10616. // Make sure modifiers like prevent and stop get executed after key filtering
  10617. if (genModifierCode) {
  10618. code += genModifierCode;
  10619. }
  10620. const handlerCode = isMethodPath
  10621. ? `return ${handler.value}.apply(null, arguments)`
  10622. : isFunctionExpression
  10623. ? `return (${handler.value}).apply(null, arguments)`
  10624. : isFunctionInvocation
  10625. ? `return ${handler.value}`
  10626. : handler.value;
  10627. return `function($event){${code}${handlerCode}}`;
  10628. }
  10629. }
  10630. function genKeyFilter(keys) {
  10631. return (
  10632. // make sure the key filters only apply to KeyboardEvents
  10633. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10634. // key events that do not have keyCode property...
  10635. `if(!$event.type.indexOf('key')&&` +
  10636. `${keys.map(genFilterCode).join('&&')})return null;`);
  10637. }
  10638. function genFilterCode(key) {
  10639. const keyVal = parseInt(key, 10);
  10640. if (keyVal) {
  10641. return `$event.keyCode!==${keyVal}`;
  10642. }
  10643. const keyCode = keyCodes[key];
  10644. const keyName = keyNames[key];
  10645. return (`_k($event.keyCode,` +
  10646. `${JSON.stringify(key)},` +
  10647. `${JSON.stringify(keyCode)},` +
  10648. `$event.key,` +
  10649. `${JSON.stringify(keyName)}` +
  10650. `)`);
  10651. }
  10652. function on(el, dir) {
  10653. if (dir.modifiers) {
  10654. warn$2(`v-on without argument does not support modifiers.`);
  10655. }
  10656. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10657. }
  10658. function bind(el, dir) {
  10659. el.wrapData = (code) => {
  10660. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10661. };
  10662. }
  10663. var baseDirectives = {
  10664. on,
  10665. bind,
  10666. cloak: noop
  10667. };
  10668. class CodegenState {
  10669. constructor(options) {
  10670. this.options = options;
  10671. this.warn = options.warn || baseWarn;
  10672. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10673. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10674. this.directives = extend(extend({}, baseDirectives), options.directives);
  10675. const isReservedTag = options.isReservedTag || no;
  10676. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10677. this.onceId = 0;
  10678. this.staticRenderFns = [];
  10679. this.pre = false;
  10680. }
  10681. }
  10682. function generate(ast, options) {
  10683. const state = new CodegenState(options);
  10684. // fix #11483, Root level <script> tags should not be rendered.
  10685. const code = ast
  10686. ? ast.tag === 'script'
  10687. ? 'null'
  10688. : genElement(ast, state)
  10689. : '_c("div")';
  10690. return {
  10691. render: `with(this){return ${code}}`,
  10692. staticRenderFns: state.staticRenderFns
  10693. };
  10694. }
  10695. function genElement(el, state) {
  10696. if (el.parent) {
  10697. el.pre = el.pre || el.parent.pre;
  10698. }
  10699. if (el.staticRoot && !el.staticProcessed) {
  10700. return genStatic(el, state);
  10701. }
  10702. else if (el.once && !el.onceProcessed) {
  10703. return genOnce(el, state);
  10704. }
  10705. else if (el.for && !el.forProcessed) {
  10706. return genFor(el, state);
  10707. }
  10708. else if (el.if && !el.ifProcessed) {
  10709. return genIf(el, state);
  10710. }
  10711. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10712. return genChildren(el, state) || 'void 0';
  10713. }
  10714. else if (el.tag === 'slot') {
  10715. return genSlot(el, state);
  10716. }
  10717. else {
  10718. // component or element
  10719. let code;
  10720. if (el.component) {
  10721. code = genComponent(el.component, el, state);
  10722. }
  10723. else {
  10724. let data;
  10725. const maybeComponent = state.maybeComponent(el);
  10726. if (!el.plain || (el.pre && maybeComponent)) {
  10727. data = genData(el, state);
  10728. }
  10729. let tag;
  10730. // check if this is a component in <script setup>
  10731. const bindings = state.options.bindings;
  10732. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10733. tag = checkBindingType(bindings, el.tag);
  10734. }
  10735. if (!tag)
  10736. tag = `'${el.tag}'`;
  10737. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10738. code = `_c(${tag}${data ? `,${data}` : '' // data
  10739. }${children ? `,${children}` : '' // children
  10740. })`;
  10741. }
  10742. // module transforms
  10743. for (let i = 0; i < state.transforms.length; i++) {
  10744. code = state.transforms[i](el, code);
  10745. }
  10746. return code;
  10747. }
  10748. }
  10749. function checkBindingType(bindings, key) {
  10750. const camelName = camelize(key);
  10751. const PascalName = capitalize(camelName);
  10752. const checkType = (type) => {
  10753. if (bindings[key] === type) {
  10754. return key;
  10755. }
  10756. if (bindings[camelName] === type) {
  10757. return camelName;
  10758. }
  10759. if (bindings[PascalName] === type) {
  10760. return PascalName;
  10761. }
  10762. };
  10763. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10764. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10765. if (fromConst) {
  10766. return fromConst;
  10767. }
  10768. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10769. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10770. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10771. if (fromMaybeRef) {
  10772. return fromMaybeRef;
  10773. }
  10774. }
  10775. // hoist static sub-trees out
  10776. function genStatic(el, state) {
  10777. el.staticProcessed = true;
  10778. // Some elements (templates) need to behave differently inside of a v-pre
  10779. // node. All pre nodes are static roots, so we can use this as a location to
  10780. // wrap a state change and reset it upon exiting the pre node.
  10781. const originalPreState = state.pre;
  10782. if (el.pre) {
  10783. state.pre = el.pre;
  10784. }
  10785. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10786. state.pre = originalPreState;
  10787. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10788. }
  10789. // v-once
  10790. function genOnce(el, state) {
  10791. el.onceProcessed = true;
  10792. if (el.if && !el.ifProcessed) {
  10793. return genIf(el, state);
  10794. }
  10795. else if (el.staticInFor) {
  10796. let key = '';
  10797. let parent = el.parent;
  10798. while (parent) {
  10799. if (parent.for) {
  10800. key = parent.key;
  10801. break;
  10802. }
  10803. parent = parent.parent;
  10804. }
  10805. if (!key) {
  10806. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10807. return genElement(el, state);
  10808. }
  10809. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10810. }
  10811. else {
  10812. return genStatic(el, state);
  10813. }
  10814. }
  10815. function genIf(el, state, altGen, altEmpty) {
  10816. el.ifProcessed = true; // avoid recursion
  10817. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10818. }
  10819. function genIfConditions(conditions, state, altGen, altEmpty) {
  10820. if (!conditions.length) {
  10821. return altEmpty || '_e()';
  10822. }
  10823. const condition = conditions.shift();
  10824. if (condition.exp) {
  10825. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10826. }
  10827. else {
  10828. return `${genTernaryExp(condition.block)}`;
  10829. }
  10830. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10831. function genTernaryExp(el) {
  10832. return altGen
  10833. ? altGen(el, state)
  10834. : el.once
  10835. ? genOnce(el, state)
  10836. : genElement(el, state);
  10837. }
  10838. }
  10839. function genFor(el, state, altGen, altHelper) {
  10840. const exp = el.for;
  10841. const alias = el.alias;
  10842. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10843. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10844. if (state.maybeComponent(el) &&
  10845. el.tag !== 'slot' &&
  10846. el.tag !== 'template' &&
  10847. !el.key) {
  10848. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10849. `v-for should have explicit keys. ` +
  10850. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10851. }
  10852. el.forProcessed = true; // avoid recursion
  10853. return (`${altHelper || '_l'}((${exp}),` +
  10854. `function(${alias}${iterator1}${iterator2}){` +
  10855. `return ${(altGen || genElement)(el, state)}` +
  10856. '})');
  10857. }
  10858. function genData(el, state) {
  10859. let data = '{';
  10860. // directives first.
  10861. // directives may mutate the el's other properties before they are generated.
  10862. const dirs = genDirectives(el, state);
  10863. if (dirs)
  10864. data += dirs + ',';
  10865. // key
  10866. if (el.key) {
  10867. data += `key:${el.key},`;
  10868. }
  10869. // ref
  10870. if (el.ref) {
  10871. data += `ref:${el.ref},`;
  10872. }
  10873. if (el.refInFor) {
  10874. data += `refInFor:true,`;
  10875. }
  10876. // pre
  10877. if (el.pre) {
  10878. data += `pre:true,`;
  10879. }
  10880. // record original tag name for components using "is" attribute
  10881. if (el.component) {
  10882. data += `tag:"${el.tag}",`;
  10883. }
  10884. // module data generation functions
  10885. for (let i = 0; i < state.dataGenFns.length; i++) {
  10886. data += state.dataGenFns[i](el);
  10887. }
  10888. // attributes
  10889. if (el.attrs) {
  10890. data += `attrs:${genProps(el.attrs)},`;
  10891. }
  10892. // DOM props
  10893. if (el.props) {
  10894. data += `domProps:${genProps(el.props)},`;
  10895. }
  10896. // event handlers
  10897. if (el.events) {
  10898. data += `${genHandlers(el.events, false)},`;
  10899. }
  10900. if (el.nativeEvents) {
  10901. data += `${genHandlers(el.nativeEvents, true)},`;
  10902. }
  10903. // slot target
  10904. // only for non-scoped slots
  10905. if (el.slotTarget && !el.slotScope) {
  10906. data += `slot:${el.slotTarget},`;
  10907. }
  10908. // scoped slots
  10909. if (el.scopedSlots) {
  10910. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10911. }
  10912. // component v-model
  10913. if (el.model) {
  10914. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10915. }
  10916. // inline-template
  10917. if (el.inlineTemplate) {
  10918. const inlineTemplate = genInlineTemplate(el, state);
  10919. if (inlineTemplate) {
  10920. data += `${inlineTemplate},`;
  10921. }
  10922. }
  10923. data = data.replace(/,$/, '') + '}';
  10924. // v-bind dynamic argument wrap
  10925. // v-bind with dynamic arguments must be applied using the same v-bind object
  10926. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10927. if (el.dynamicAttrs) {
  10928. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10929. }
  10930. // v-bind data wrap
  10931. if (el.wrapData) {
  10932. data = el.wrapData(data);
  10933. }
  10934. // v-on data wrap
  10935. if (el.wrapListeners) {
  10936. data = el.wrapListeners(data);
  10937. }
  10938. return data;
  10939. }
  10940. function genDirectives(el, state) {
  10941. const dirs = el.directives;
  10942. if (!dirs)
  10943. return;
  10944. let res = 'directives:[';
  10945. let hasRuntime = false;
  10946. let i, l, dir, needRuntime;
  10947. for (i = 0, l = dirs.length; i < l; i++) {
  10948. dir = dirs[i];
  10949. needRuntime = true;
  10950. const gen = state.directives[dir.name];
  10951. if (gen) {
  10952. // compile-time directive that manipulates AST.
  10953. // returns true if it also needs a runtime counterpart.
  10954. needRuntime = !!gen(el, dir, state.warn);
  10955. }
  10956. if (needRuntime) {
  10957. hasRuntime = true;
  10958. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  10959. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  10960. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  10961. }
  10962. }
  10963. if (hasRuntime) {
  10964. return res.slice(0, -1) + ']';
  10965. }
  10966. }
  10967. function genInlineTemplate(el, state) {
  10968. const ast = el.children[0];
  10969. if ((el.children.length !== 1 || ast.type !== 1)) {
  10970. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  10971. }
  10972. if (ast && ast.type === 1) {
  10973. const inlineRenderFns = generate(ast, state.options);
  10974. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  10975. .map(code => `function(){${code}}`)
  10976. .join(',')}]}`;
  10977. }
  10978. }
  10979. function genScopedSlots(el, slots, state) {
  10980. // by default scoped slots are considered "stable", this allows child
  10981. // components with only scoped slots to skip forced updates from parent.
  10982. // but in some cases we have to bail-out of this optimization
  10983. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10984. let needsForceUpdate = el.for ||
  10985. Object.keys(slots).some(key => {
  10986. const slot = slots[key];
  10987. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10988. );
  10989. });
  10990. // #9534: if a component with scoped slots is inside a conditional branch,
  10991. // it's possible for the same component to be reused but with different
  10992. // compiled slot content. To avoid that, we generate a unique key based on
  10993. // the generated code of all the slot contents.
  10994. let needsKey = !!el.if;
  10995. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10996. // disconnected due to the intermediate scope variable)
  10997. // #9438, #9506
  10998. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10999. // and skip force updating ones that do not actually use scope variables.
  11000. if (!needsForceUpdate) {
  11001. let parent = el.parent;
  11002. while (parent) {
  11003. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11004. parent.for) {
  11005. needsForceUpdate = true;
  11006. break;
  11007. }
  11008. if (parent.if) {
  11009. needsKey = true;
  11010. }
  11011. parent = parent.parent;
  11012. }
  11013. }
  11014. const generatedSlots = Object.keys(slots)
  11015. .map(key => genScopedSlot(slots[key], state))
  11016. .join(',');
  11017. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11018. }
  11019. function hash(str) {
  11020. let hash = 5381;
  11021. let i = str.length;
  11022. while (i) {
  11023. hash = (hash * 33) ^ str.charCodeAt(--i);
  11024. }
  11025. return hash >>> 0;
  11026. }
  11027. function containsSlotChild(el) {
  11028. if (el.type === 1) {
  11029. if (el.tag === 'slot') {
  11030. return true;
  11031. }
  11032. return el.children.some(containsSlotChild);
  11033. }
  11034. return false;
  11035. }
  11036. function genScopedSlot(el, state) {
  11037. const isLegacySyntax = el.attrsMap['slot-scope'];
  11038. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11039. return genIf(el, state, genScopedSlot, `null`);
  11040. }
  11041. if (el.for && !el.forProcessed) {
  11042. return genFor(el, state, genScopedSlot);
  11043. }
  11044. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11045. const fn = `function(${slotScope}){` +
  11046. `return ${el.tag === 'template'
  11047. ? el.if && isLegacySyntax
  11048. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11049. : genChildren(el, state) || 'undefined'
  11050. : genElement(el, state)}}`;
  11051. // reverse proxy v-slot without scope on this.$slots
  11052. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11053. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11054. }
  11055. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11056. const children = el.children;
  11057. if (children.length) {
  11058. const el = children[0];
  11059. // optimize single v-for
  11060. if (children.length === 1 &&
  11061. el.for &&
  11062. el.tag !== 'template' &&
  11063. el.tag !== 'slot') {
  11064. const normalizationType = checkSkip
  11065. ? state.maybeComponent(el)
  11066. ? `,1`
  11067. : `,0`
  11068. : ``;
  11069. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11070. }
  11071. const normalizationType = checkSkip
  11072. ? getNormalizationType(children, state.maybeComponent)
  11073. : 0;
  11074. const gen = altGenNode || genNode;
  11075. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11076. }
  11077. }
  11078. // determine the normalization needed for the children array.
  11079. // 0: no normalization needed
  11080. // 1: simple normalization needed (possible 1-level deep nested array)
  11081. // 2: full normalization needed
  11082. function getNormalizationType(children, maybeComponent) {
  11083. let res = 0;
  11084. for (let i = 0; i < children.length; i++) {
  11085. const el = children[i];
  11086. if (el.type !== 1) {
  11087. continue;
  11088. }
  11089. if (needsNormalization(el) ||
  11090. (el.ifConditions &&
  11091. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11092. res = 2;
  11093. break;
  11094. }
  11095. if (maybeComponent(el) ||
  11096. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11097. res = 1;
  11098. }
  11099. }
  11100. return res;
  11101. }
  11102. function needsNormalization(el) {
  11103. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11104. }
  11105. function genNode(node, state) {
  11106. if (node.type === 1) {
  11107. return genElement(node, state);
  11108. }
  11109. else if (node.type === 3 && node.isComment) {
  11110. return genComment(node);
  11111. }
  11112. else {
  11113. return genText(node);
  11114. }
  11115. }
  11116. function genText(text) {
  11117. return `_v(${text.type === 2
  11118. ? text.expression // no need for () because already wrapped in _s()
  11119. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11120. }
  11121. function genComment(comment) {
  11122. return `_e(${JSON.stringify(comment.text)})`;
  11123. }
  11124. function genSlot(el, state) {
  11125. const slotName = el.slotName || '"default"';
  11126. const children = genChildren(el, state);
  11127. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11128. const attrs = el.attrs || el.dynamicAttrs
  11129. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11130. // slot props are camelized
  11131. name: camelize(attr.name),
  11132. value: attr.value,
  11133. dynamic: attr.dynamic
  11134. })))
  11135. : null;
  11136. const bind = el.attrsMap['v-bind'];
  11137. if ((attrs || bind) && !children) {
  11138. res += `,null`;
  11139. }
  11140. if (attrs) {
  11141. res += `,${attrs}`;
  11142. }
  11143. if (bind) {
  11144. res += `${attrs ? '' : ',null'},${bind}`;
  11145. }
  11146. return res + ')';
  11147. }
  11148. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11149. function genComponent(componentName, el, state) {
  11150. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11151. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11152. }
  11153. function genProps(props) {
  11154. let staticProps = ``;
  11155. let dynamicProps = ``;
  11156. for (let i = 0; i < props.length; i++) {
  11157. const prop = props[i];
  11158. const value = transformSpecialNewlines(prop.value);
  11159. if (prop.dynamic) {
  11160. dynamicProps += `${prop.name},${value},`;
  11161. }
  11162. else {
  11163. staticProps += `"${prop.name}":${value},`;
  11164. }
  11165. }
  11166. staticProps = `{${staticProps.slice(0, -1)}}`;
  11167. if (dynamicProps) {
  11168. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11169. }
  11170. else {
  11171. return staticProps;
  11172. }
  11173. }
  11174. // #3895, #4268
  11175. function transformSpecialNewlines(text) {
  11176. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11177. }
  11178. // these keywords should not appear inside expressions, but operators like
  11179. // typeof, instanceof and in are allowed
  11180. const prohibitedKeywordRE = new RegExp('\\b' +
  11181. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11182. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11183. 'extends,finally,continue,debugger,function,arguments')
  11184. .split(',')
  11185. .join('\\b|\\b') +
  11186. '\\b');
  11187. // these unary operators should not be used as property/method names
  11188. const unaryOperatorsRE = new RegExp('\\b' +
  11189. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11190. '\\s*\\([^\\)]*\\)');
  11191. // strip strings in expressions
  11192. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11193. // detect problematic expressions in a template
  11194. function detectErrors(ast, warn) {
  11195. if (ast) {
  11196. checkNode(ast, warn);
  11197. }
  11198. }
  11199. function checkNode(node, warn) {
  11200. if (node.type === 1) {
  11201. for (const name in node.attrsMap) {
  11202. if (dirRE.test(name)) {
  11203. const value = node.attrsMap[name];
  11204. if (value) {
  11205. const range = node.rawAttrsMap[name];
  11206. if (name === 'v-for') {
  11207. checkFor(node, `v-for="${value}"`, warn, range);
  11208. }
  11209. else if (name === 'v-slot' || name[0] === '#') {
  11210. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11211. }
  11212. else if (onRE.test(name)) {
  11213. checkEvent(value, `${name}="${value}"`, warn, range);
  11214. }
  11215. else {
  11216. checkExpression(value, `${name}="${value}"`, warn, range);
  11217. }
  11218. }
  11219. }
  11220. }
  11221. if (node.children) {
  11222. for (let i = 0; i < node.children.length; i++) {
  11223. checkNode(node.children[i], warn);
  11224. }
  11225. }
  11226. }
  11227. else if (node.type === 2) {
  11228. checkExpression(node.expression, node.text, warn, node);
  11229. }
  11230. }
  11231. function checkEvent(exp, text, warn, range) {
  11232. const stripped = exp.replace(stripStringRE, '');
  11233. const keywordMatch = stripped.match(unaryOperatorsRE);
  11234. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11235. warn(`avoid using JavaScript unary operator as property name: ` +
  11236. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11237. }
  11238. checkExpression(exp, text, warn, range);
  11239. }
  11240. function checkFor(node, text, warn, range) {
  11241. checkExpression(node.for || '', text, warn, range);
  11242. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11243. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11244. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11245. }
  11246. function checkIdentifier(ident, type, text, warn, range) {
  11247. if (typeof ident === 'string') {
  11248. try {
  11249. new Function(`var ${ident}=_`);
  11250. }
  11251. catch (e) {
  11252. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11253. }
  11254. }
  11255. }
  11256. function checkExpression(exp, text, warn, range) {
  11257. try {
  11258. new Function(`return ${exp}`);
  11259. }
  11260. catch (e) {
  11261. const keywordMatch = exp
  11262. .replace(stripStringRE, '')
  11263. .match(prohibitedKeywordRE);
  11264. if (keywordMatch) {
  11265. warn(`avoid using JavaScript keyword as property name: ` +
  11266. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11267. }
  11268. else {
  11269. warn(`invalid expression: ${e.message} in\n\n` +
  11270. ` ${exp}\n\n` +
  11271. ` Raw expression: ${text.trim()}\n`, range);
  11272. }
  11273. }
  11274. }
  11275. function checkFunctionParameterExpression(exp, text, warn, range) {
  11276. try {
  11277. new Function(exp, '');
  11278. }
  11279. catch (e) {
  11280. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11281. ` ${exp}\n\n` +
  11282. ` Raw expression: ${text.trim()}\n`, range);
  11283. }
  11284. }
  11285. const range = 2;
  11286. function generateCodeFrame(source, start = 0, end = source.length) {
  11287. const lines = source.split(/\r?\n/);
  11288. let count = 0;
  11289. const res = [];
  11290. for (let i = 0; i < lines.length; i++) {
  11291. count += lines[i].length + 1;
  11292. if (count >= start) {
  11293. for (let j = i - range; j <= i + range || end > count; j++) {
  11294. if (j < 0 || j >= lines.length)
  11295. continue;
  11296. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11297. const lineLength = lines[j].length;
  11298. if (j === i) {
  11299. // push underline
  11300. const pad = start - (count - lineLength) + 1;
  11301. const length = end > count ? lineLength - pad : end - start;
  11302. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11303. }
  11304. else if (j > i) {
  11305. if (end > count) {
  11306. const length = Math.min(end - count, lineLength);
  11307. res.push(` | ` + repeat(`^`, length));
  11308. }
  11309. count += lineLength + 1;
  11310. }
  11311. }
  11312. break;
  11313. }
  11314. }
  11315. return res.join('\n');
  11316. }
  11317. function repeat(str, n) {
  11318. let result = '';
  11319. if (n > 0) {
  11320. // eslint-disable-next-line no-constant-condition
  11321. while (true) {
  11322. // eslint-disable-line
  11323. if (n & 1)
  11324. result += str;
  11325. n >>>= 1;
  11326. if (n <= 0)
  11327. break;
  11328. str += str;
  11329. }
  11330. }
  11331. return result;
  11332. }
  11333. function createFunction(code, errors) {
  11334. try {
  11335. return new Function(code);
  11336. }
  11337. catch (err) {
  11338. errors.push({ err, code });
  11339. return noop;
  11340. }
  11341. }
  11342. function createCompileToFunctionFn(compile) {
  11343. const cache = Object.create(null);
  11344. return function compileToFunctions(template, options, vm) {
  11345. options = extend({}, options);
  11346. const warn = options.warn || warn$2;
  11347. delete options.warn;
  11348. /* istanbul ignore if */
  11349. {
  11350. // detect possible CSP restriction
  11351. try {
  11352. new Function('return 1');
  11353. }
  11354. catch (e) {
  11355. if (e.toString().match(/unsafe-eval|CSP/)) {
  11356. warn('It seems you are using the standalone build of Vue.js in an ' +
  11357. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11358. 'The template compiler cannot work in this environment. Consider ' +
  11359. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11360. 'templates into render functions.');
  11361. }
  11362. }
  11363. }
  11364. // check cache
  11365. const key = options.delimiters
  11366. ? String(options.delimiters) + template
  11367. : template;
  11368. if (cache[key]) {
  11369. return cache[key];
  11370. }
  11371. // compile
  11372. const compiled = compile(template, options);
  11373. // check compilation errors/tips
  11374. {
  11375. if (compiled.errors && compiled.errors.length) {
  11376. if (options.outputSourceRange) {
  11377. compiled.errors.forEach(e => {
  11378. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11379. generateCodeFrame(template, e.start, e.end), vm);
  11380. });
  11381. }
  11382. else {
  11383. warn(`Error compiling template:\n\n${template}\n\n` +
  11384. compiled.errors.map(e => `- ${e}`).join('\n') +
  11385. '\n', vm);
  11386. }
  11387. }
  11388. if (compiled.tips && compiled.tips.length) {
  11389. if (options.outputSourceRange) {
  11390. compiled.tips.forEach(e => tip(e.msg, vm));
  11391. }
  11392. else {
  11393. compiled.tips.forEach(msg => tip(msg, vm));
  11394. }
  11395. }
  11396. }
  11397. // turn code into functions
  11398. const res = {};
  11399. const fnGenErrors = [];
  11400. res.render = createFunction(compiled.render, fnGenErrors);
  11401. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11402. return createFunction(code, fnGenErrors);
  11403. });
  11404. // check function generation errors.
  11405. // this should only happen if there is a bug in the compiler itself.
  11406. // mostly for codegen development use
  11407. /* istanbul ignore if */
  11408. {
  11409. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11410. warn(`Failed to generate render function:\n\n` +
  11411. fnGenErrors
  11412. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11413. .join('\n'), vm);
  11414. }
  11415. }
  11416. return (cache[key] = res);
  11417. };
  11418. }
  11419. function createCompilerCreator(baseCompile) {
  11420. return function createCompiler(baseOptions) {
  11421. function compile(template, options) {
  11422. const finalOptions = Object.create(baseOptions);
  11423. const errors = [];
  11424. const tips = [];
  11425. let warn = (msg, range, tip) => {
  11426. (tip ? tips : errors).push(msg);
  11427. };
  11428. if (options) {
  11429. if (options.outputSourceRange) {
  11430. // $flow-disable-line
  11431. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11432. warn = (msg, range, tip) => {
  11433. const data = typeof msg === 'string' ? { msg } : msg;
  11434. if (range) {
  11435. if (range.start != null) {
  11436. data.start = range.start + leadingSpaceLength;
  11437. }
  11438. if (range.end != null) {
  11439. data.end = range.end + leadingSpaceLength;
  11440. }
  11441. }
  11442. (tip ? tips : errors).push(data);
  11443. };
  11444. }
  11445. // merge custom modules
  11446. if (options.modules) {
  11447. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11448. }
  11449. // merge custom directives
  11450. if (options.directives) {
  11451. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11452. }
  11453. // copy other options
  11454. for (const key in options) {
  11455. if (key !== 'modules' && key !== 'directives') {
  11456. finalOptions[key] = options[key];
  11457. }
  11458. }
  11459. }
  11460. finalOptions.warn = warn;
  11461. const compiled = baseCompile(template.trim(), finalOptions);
  11462. {
  11463. detectErrors(compiled.ast, warn);
  11464. }
  11465. compiled.errors = errors;
  11466. compiled.tips = tips;
  11467. return compiled;
  11468. }
  11469. return {
  11470. compile,
  11471. compileToFunctions: createCompileToFunctionFn(compile)
  11472. };
  11473. };
  11474. }
  11475. // `createCompilerCreator` allows creating compilers that use alternative
  11476. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11477. // Here we just export a default compiler using the default parts.
  11478. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11479. const ast = parse(template.trim(), options);
  11480. if (options.optimize !== false) {
  11481. optimize(ast, options);
  11482. }
  11483. const code = generate(ast, options);
  11484. return {
  11485. ast,
  11486. render: code.render,
  11487. staticRenderFns: code.staticRenderFns
  11488. };
  11489. });
  11490. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11491. // check whether current browser encodes a char inside attribute values
  11492. let div;
  11493. function getShouldDecode(href) {
  11494. div = div || document.createElement('div');
  11495. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11496. return div.innerHTML.indexOf('&#10;') > 0;
  11497. }
  11498. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11499. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11500. // #6828: chrome encodes content in a[href]
  11501. const shouldDecodeNewlinesForHref = inBrowser
  11502. ? getShouldDecode(true)
  11503. : false;
  11504. const idToTemplate = cached(id => {
  11505. const el = query(id);
  11506. return el && el.innerHTML;
  11507. });
  11508. const mount = Vue.prototype.$mount;
  11509. Vue.prototype.$mount = function (el, hydrating) {
  11510. el = el && query(el);
  11511. /* istanbul ignore if */
  11512. if (el === document.body || el === document.documentElement) {
  11513. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11514. return this;
  11515. }
  11516. const options = this.$options;
  11517. // resolve template/el and convert to render function
  11518. if (!options.render) {
  11519. let template = options.template;
  11520. if (template) {
  11521. if (typeof template === 'string') {
  11522. if (template.charAt(0) === '#') {
  11523. template = idToTemplate(template);
  11524. /* istanbul ignore if */
  11525. if (!template) {
  11526. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11527. }
  11528. }
  11529. }
  11530. else if (template.nodeType) {
  11531. template = template.innerHTML;
  11532. }
  11533. else {
  11534. {
  11535. warn$2('invalid template option:' + template, this);
  11536. }
  11537. return this;
  11538. }
  11539. }
  11540. else if (el) {
  11541. // @ts-expect-error
  11542. template = getOuterHTML(el);
  11543. }
  11544. if (template) {
  11545. /* istanbul ignore if */
  11546. if (config.performance && mark) {
  11547. mark('compile');
  11548. }
  11549. const { render, staticRenderFns } = compileToFunctions(template, {
  11550. outputSourceRange: true,
  11551. shouldDecodeNewlines,
  11552. shouldDecodeNewlinesForHref,
  11553. delimiters: options.delimiters,
  11554. comments: options.comments
  11555. }, this);
  11556. options.render = render;
  11557. options.staticRenderFns = staticRenderFns;
  11558. /* istanbul ignore if */
  11559. if (config.performance && mark) {
  11560. mark('compile end');
  11561. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11562. }
  11563. }
  11564. }
  11565. return mount.call(this, el, hydrating);
  11566. };
  11567. /**
  11568. * Get outerHTML of elements, taking care
  11569. * of SVG elements in IE as well.
  11570. */
  11571. function getOuterHTML(el) {
  11572. if (el.outerHTML) {
  11573. return el.outerHTML;
  11574. }
  11575. else {
  11576. const container = document.createElement('div');
  11577. container.appendChild(el.cloneNode(true));
  11578. return container.innerHTML;
  11579. }
  11580. }
  11581. Vue.compile = compileToFunctions;
  11582. export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };