vue.common.dev.js 389 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799
  1. /*!
  2. * Vue.js v2.7.14
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray(list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret;
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend(to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to;
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject(arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res;
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop(a, b, c) { }
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys$1(modules) {
  243. return modules
  244. .reduce((keys, m) => {
  245. return keys.concat(m.staticKeys || []);
  246. }, [])
  247. .join(',');
  248. }
  249. /**
  250. * Check if two values are loosely equal - that is,
  251. * if they are plain objects, do they have the same shape?
  252. */
  253. function looseEqual(a, b) {
  254. if (a === b)
  255. return true;
  256. const isObjectA = isObject(a);
  257. const isObjectB = isObject(b);
  258. if (isObjectA && isObjectB) {
  259. try {
  260. const isArrayA = Array.isArray(a);
  261. const isArrayB = Array.isArray(b);
  262. if (isArrayA && isArrayB) {
  263. return (a.length === b.length &&
  264. a.every((e, i) => {
  265. return looseEqual(e, b[i]);
  266. }));
  267. }
  268. else if (a instanceof Date && b instanceof Date) {
  269. return a.getTime() === b.getTime();
  270. }
  271. else if (!isArrayA && !isArrayB) {
  272. const keysA = Object.keys(a);
  273. const keysB = Object.keys(b);
  274. return (keysA.length === keysB.length &&
  275. keysA.every(key => {
  276. return looseEqual(a[key], b[key]);
  277. }));
  278. }
  279. else {
  280. /* istanbul ignore next */
  281. return false;
  282. }
  283. }
  284. catch (e) {
  285. /* istanbul ignore next */
  286. return false;
  287. }
  288. }
  289. else if (!isObjectA && !isObjectB) {
  290. return String(a) === String(b);
  291. }
  292. else {
  293. return false;
  294. }
  295. }
  296. /**
  297. * Return the first index at which a loosely equal value can be
  298. * found in the array (if value is a plain object, the array must
  299. * contain an object of the same shape), or -1 if it is not present.
  300. */
  301. function looseIndexOf(arr, val) {
  302. for (let i = 0; i < arr.length; i++) {
  303. if (looseEqual(arr[i], val))
  304. return i;
  305. }
  306. return -1;
  307. }
  308. /**
  309. * Ensure a function is called only once.
  310. */
  311. function once(fn) {
  312. let called = false;
  313. return function () {
  314. if (!called) {
  315. called = true;
  316. fn.apply(this, arguments);
  317. }
  318. };
  319. }
  320. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  321. function hasChanged(x, y) {
  322. if (x === y) {
  323. return x === 0 && 1 / x !== 1 / y;
  324. }
  325. else {
  326. return x === x || y === y;
  327. }
  328. }
  329. const SSR_ATTR = 'data-server-rendered';
  330. const ASSET_TYPES = ['component', 'directive', 'filter'];
  331. const LIFECYCLE_HOOKS = [
  332. 'beforeCreate',
  333. 'created',
  334. 'beforeMount',
  335. 'mounted',
  336. 'beforeUpdate',
  337. 'updated',
  338. 'beforeDestroy',
  339. 'destroyed',
  340. 'activated',
  341. 'deactivated',
  342. 'errorCaptured',
  343. 'serverPrefetch',
  344. 'renderTracked',
  345. 'renderTriggered'
  346. ];
  347. var config = {
  348. /**
  349. * Option merge strategies (used in core/util/options)
  350. */
  351. // $flow-disable-line
  352. optionMergeStrategies: Object.create(null),
  353. /**
  354. * Whether to suppress warnings.
  355. */
  356. silent: false,
  357. /**
  358. * Show production mode tip message on boot?
  359. */
  360. productionTip: true,
  361. /**
  362. * Whether to enable devtools
  363. */
  364. devtools: true,
  365. /**
  366. * Whether to record perf
  367. */
  368. performance: false,
  369. /**
  370. * Error handler for watcher errors
  371. */
  372. errorHandler: null,
  373. /**
  374. * Warn handler for watcher warns
  375. */
  376. warnHandler: null,
  377. /**
  378. * Ignore certain custom elements
  379. */
  380. ignoredElements: [],
  381. /**
  382. * Custom user key aliases for v-on
  383. */
  384. // $flow-disable-line
  385. keyCodes: Object.create(null),
  386. /**
  387. * Check if a tag is reserved so that it cannot be registered as a
  388. * component. This is platform-dependent and may be overwritten.
  389. */
  390. isReservedTag: no,
  391. /**
  392. * Check if an attribute is reserved so that it cannot be used as a component
  393. * prop. This is platform-dependent and may be overwritten.
  394. */
  395. isReservedAttr: no,
  396. /**
  397. * Check if a tag is an unknown element.
  398. * Platform-dependent.
  399. */
  400. isUnknownElement: no,
  401. /**
  402. * Get the namespace of an element
  403. */
  404. getTagNamespace: noop,
  405. /**
  406. * Parse the real tag name for the specific platform.
  407. */
  408. parsePlatformTagName: identity,
  409. /**
  410. * Check if an attribute must be bound using property, e.g. value
  411. * Platform-dependent.
  412. */
  413. mustUseProp: no,
  414. /**
  415. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  416. * This will significantly reduce performance if set to false.
  417. */
  418. async: true,
  419. /**
  420. * Exposed for legacy reasons
  421. */
  422. _lifecycleHooks: LIFECYCLE_HOOKS
  423. };
  424. /**
  425. * unicode letters used for parsing html tags, component names and property paths.
  426. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  427. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  428. */
  429. 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/;
  430. /**
  431. * Check if a string starts with $ or _
  432. */
  433. function isReserved(str) {
  434. const c = (str + '').charCodeAt(0);
  435. return c === 0x24 || c === 0x5f;
  436. }
  437. /**
  438. * Define a property.
  439. */
  440. function def(obj, key, val, enumerable) {
  441. Object.defineProperty(obj, key, {
  442. value: val,
  443. enumerable: !!enumerable,
  444. writable: true,
  445. configurable: true
  446. });
  447. }
  448. /**
  449. * Parse simple path.
  450. */
  451. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  452. function parsePath(path) {
  453. if (bailRE.test(path)) {
  454. return;
  455. }
  456. const segments = path.split('.');
  457. return function (obj) {
  458. for (let i = 0; i < segments.length; i++) {
  459. if (!obj)
  460. return;
  461. obj = obj[segments[i]];
  462. }
  463. return obj;
  464. };
  465. }
  466. // can we use __proto__?
  467. const hasProto = '__proto__' in {};
  468. // Browser environment sniffing
  469. const inBrowser = typeof window !== 'undefined';
  470. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  471. const isIE = UA && /msie|trident/.test(UA);
  472. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  473. const isEdge = UA && UA.indexOf('edge/') > 0;
  474. UA && UA.indexOf('android') > 0;
  475. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  476. UA && /chrome\/\d+/.test(UA) && !isEdge;
  477. UA && /phantomjs/.test(UA);
  478. const isFF = UA && UA.match(/firefox\/(\d+)/);
  479. // Firefox has a "watch" function on Object.prototype...
  480. // @ts-expect-error firebox support
  481. const nativeWatch = {}.watch;
  482. let supportsPassive = false;
  483. if (inBrowser) {
  484. try {
  485. const opts = {};
  486. Object.defineProperty(opts, 'passive', {
  487. get() {
  488. /* istanbul ignore next */
  489. supportsPassive = true;
  490. }
  491. }); // https://github.com/facebook/flow/issues/285
  492. window.addEventListener('test-passive', null, opts);
  493. }
  494. catch (e) { }
  495. }
  496. // this needs to be lazy-evaled because vue may be required before
  497. // vue-server-renderer can set VUE_ENV
  498. let _isServer;
  499. const isServerRendering = () => {
  500. if (_isServer === undefined) {
  501. /* istanbul ignore if */
  502. if (!inBrowser && typeof global !== 'undefined') {
  503. // detect presence of vue-server-renderer and avoid
  504. // Webpack shimming the process
  505. _isServer =
  506. global['process'] && global['process'].env.VUE_ENV === 'server';
  507. }
  508. else {
  509. _isServer = false;
  510. }
  511. }
  512. return _isServer;
  513. };
  514. // detect devtools
  515. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  516. /* istanbul ignore next */
  517. function isNative(Ctor) {
  518. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  519. }
  520. const hasSymbol = typeof Symbol !== 'undefined' &&
  521. isNative(Symbol) &&
  522. typeof Reflect !== 'undefined' &&
  523. isNative(Reflect.ownKeys);
  524. let _Set; // $flow-disable-line
  525. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  526. // use native Set when available.
  527. _Set = Set;
  528. }
  529. else {
  530. // a non-standard Set polyfill that only works with primitive keys.
  531. _Set = class Set {
  532. constructor() {
  533. this.set = Object.create(null);
  534. }
  535. has(key) {
  536. return this.set[key] === true;
  537. }
  538. add(key) {
  539. this.set[key] = true;
  540. }
  541. clear() {
  542. this.set = Object.create(null);
  543. }
  544. };
  545. }
  546. let currentInstance = null;
  547. /**
  548. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  549. * relies on it). Do not use this internally, just use `currentInstance`.
  550. *
  551. * @internal this function needs manual type declaration because it relies
  552. * on previously manually authored types from Vue 2
  553. */
  554. function getCurrentInstance() {
  555. return currentInstance && { proxy: currentInstance };
  556. }
  557. /**
  558. * @internal
  559. */
  560. function setCurrentInstance(vm = null) {
  561. if (!vm)
  562. currentInstance && currentInstance._scope.off();
  563. currentInstance = vm;
  564. vm && vm._scope.on();
  565. }
  566. /**
  567. * @internal
  568. */
  569. class VNode {
  570. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  571. this.tag = tag;
  572. this.data = data;
  573. this.children = children;
  574. this.text = text;
  575. this.elm = elm;
  576. this.ns = undefined;
  577. this.context = context;
  578. this.fnContext = undefined;
  579. this.fnOptions = undefined;
  580. this.fnScopeId = undefined;
  581. this.key = data && data.key;
  582. this.componentOptions = componentOptions;
  583. this.componentInstance = undefined;
  584. this.parent = undefined;
  585. this.raw = false;
  586. this.isStatic = false;
  587. this.isRootInsert = true;
  588. this.isComment = false;
  589. this.isCloned = false;
  590. this.isOnce = false;
  591. this.asyncFactory = asyncFactory;
  592. this.asyncMeta = undefined;
  593. this.isAsyncPlaceholder = false;
  594. }
  595. // DEPRECATED: alias for componentInstance for backwards compat.
  596. /* istanbul ignore next */
  597. get child() {
  598. return this.componentInstance;
  599. }
  600. }
  601. const createEmptyVNode = (text = '') => {
  602. const node = new VNode();
  603. node.text = text;
  604. node.isComment = true;
  605. return node;
  606. };
  607. function createTextVNode(val) {
  608. return new VNode(undefined, undefined, undefined, String(val));
  609. }
  610. // optimized shallow clone
  611. // used for static nodes and slot nodes because they may be reused across
  612. // multiple renders, cloning them avoids errors when DOM manipulations rely
  613. // on their elm reference.
  614. function cloneVNode(vnode) {
  615. const cloned = new VNode(vnode.tag, vnode.data,
  616. // #7975
  617. // clone children array to avoid mutating original in case of cloning
  618. // a child.
  619. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  620. cloned.ns = vnode.ns;
  621. cloned.isStatic = vnode.isStatic;
  622. cloned.key = vnode.key;
  623. cloned.isComment = vnode.isComment;
  624. cloned.fnContext = vnode.fnContext;
  625. cloned.fnOptions = vnode.fnOptions;
  626. cloned.fnScopeId = vnode.fnScopeId;
  627. cloned.asyncMeta = vnode.asyncMeta;
  628. cloned.isCloned = true;
  629. return cloned;
  630. }
  631. /* not type checking this file because flow doesn't play well with Proxy */
  632. let initProxy;
  633. {
  634. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  635. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  636. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  637. 'require' // for Webpack/Browserify
  638. );
  639. const warnNonPresent = (target, key) => {
  640. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  641. 'referenced during render. Make sure that this property is reactive, ' +
  642. 'either in the data option, or for class-based components, by ' +
  643. 'initializing the property. ' +
  644. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  645. };
  646. const warnReservedPrefix = (target, key) => {
  647. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  648. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  649. 'prevent conflicts with Vue internals. ' +
  650. 'See: https://v2.vuejs.org/v2/api/#data', target);
  651. };
  652. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  653. if (hasProxy) {
  654. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  655. config.keyCodes = new Proxy(config.keyCodes, {
  656. set(target, key, value) {
  657. if (isBuiltInModifier(key)) {
  658. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  659. return false;
  660. }
  661. else {
  662. target[key] = value;
  663. return true;
  664. }
  665. }
  666. });
  667. }
  668. const hasHandler = {
  669. has(target, key) {
  670. const has = key in target;
  671. const isAllowed = allowedGlobals(key) ||
  672. (typeof key === 'string' &&
  673. key.charAt(0) === '_' &&
  674. !(key in target.$data));
  675. if (!has && !isAllowed) {
  676. if (key in target.$data)
  677. warnReservedPrefix(target, key);
  678. else
  679. warnNonPresent(target, key);
  680. }
  681. return has || !isAllowed;
  682. }
  683. };
  684. const getHandler = {
  685. get(target, key) {
  686. if (typeof key === 'string' && !(key in target)) {
  687. if (key in target.$data)
  688. warnReservedPrefix(target, key);
  689. else
  690. warnNonPresent(target, key);
  691. }
  692. return target[key];
  693. }
  694. };
  695. initProxy = function initProxy(vm) {
  696. if (hasProxy) {
  697. // determine which proxy handler to use
  698. const options = vm.$options;
  699. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  700. vm._renderProxy = new Proxy(vm, handlers);
  701. }
  702. else {
  703. vm._renderProxy = vm;
  704. }
  705. };
  706. }
  707. let uid$2 = 0;
  708. const pendingCleanupDeps = [];
  709. const cleanupDeps = () => {
  710. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  711. const dep = pendingCleanupDeps[i];
  712. dep.subs = dep.subs.filter(s => s);
  713. dep._pending = false;
  714. }
  715. pendingCleanupDeps.length = 0;
  716. };
  717. /**
  718. * A dep is an observable that can have multiple
  719. * directives subscribing to it.
  720. * @internal
  721. */
  722. class Dep {
  723. constructor() {
  724. // pending subs cleanup
  725. this._pending = false;
  726. this.id = uid$2++;
  727. this.subs = [];
  728. }
  729. addSub(sub) {
  730. this.subs.push(sub);
  731. }
  732. removeSub(sub) {
  733. // #12696 deps with massive amount of subscribers are extremely slow to
  734. // clean up in Chromium
  735. // to workaround this, we unset the sub for now, and clear them on
  736. // next scheduler flush.
  737. this.subs[this.subs.indexOf(sub)] = null;
  738. if (!this._pending) {
  739. this._pending = true;
  740. pendingCleanupDeps.push(this);
  741. }
  742. }
  743. depend(info) {
  744. if (Dep.target) {
  745. Dep.target.addDep(this);
  746. if (info && Dep.target.onTrack) {
  747. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  748. }
  749. }
  750. }
  751. notify(info) {
  752. // stabilize the subscriber list first
  753. const subs = this.subs.filter(s => s);
  754. if (!config.async) {
  755. // subs aren't sorted in scheduler if not running async
  756. // we need to sort them now to make sure they fire in correct
  757. // order
  758. subs.sort((a, b) => a.id - b.id);
  759. }
  760. for (let i = 0, l = subs.length; i < l; i++) {
  761. const sub = subs[i];
  762. if (info) {
  763. sub.onTrigger &&
  764. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  765. }
  766. sub.update();
  767. }
  768. }
  769. }
  770. // The current target watcher being evaluated.
  771. // This is globally unique because only one watcher
  772. // can be evaluated at a time.
  773. Dep.target = null;
  774. const targetStack = [];
  775. function pushTarget(target) {
  776. targetStack.push(target);
  777. Dep.target = target;
  778. }
  779. function popTarget() {
  780. targetStack.pop();
  781. Dep.target = targetStack[targetStack.length - 1];
  782. }
  783. /*
  784. * not type checking this file because flow doesn't play well with
  785. * dynamically accessing methods on Array prototype
  786. */
  787. const arrayProto = Array.prototype;
  788. const arrayMethods = Object.create(arrayProto);
  789. const methodsToPatch = [
  790. 'push',
  791. 'pop',
  792. 'shift',
  793. 'unshift',
  794. 'splice',
  795. 'sort',
  796. 'reverse'
  797. ];
  798. /**
  799. * Intercept mutating methods and emit events
  800. */
  801. methodsToPatch.forEach(function (method) {
  802. // cache original method
  803. const original = arrayProto[method];
  804. def(arrayMethods, method, function mutator(...args) {
  805. const result = original.apply(this, args);
  806. const ob = this.__ob__;
  807. let inserted;
  808. switch (method) {
  809. case 'push':
  810. case 'unshift':
  811. inserted = args;
  812. break;
  813. case 'splice':
  814. inserted = args.slice(2);
  815. break;
  816. }
  817. if (inserted)
  818. ob.observeArray(inserted);
  819. // notify change
  820. {
  821. ob.dep.notify({
  822. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  823. target: this,
  824. key: method
  825. });
  826. }
  827. return result;
  828. });
  829. });
  830. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  831. const NO_INIITIAL_VALUE = {};
  832. /**
  833. * In some cases we may want to disable observation inside a component's
  834. * update computation.
  835. */
  836. let shouldObserve = true;
  837. function toggleObserving(value) {
  838. shouldObserve = value;
  839. }
  840. // ssr mock dep
  841. const mockDep = {
  842. notify: noop,
  843. depend: noop,
  844. addSub: noop,
  845. removeSub: noop
  846. };
  847. /**
  848. * Observer class that is attached to each observed
  849. * object. Once attached, the observer converts the target
  850. * object's property keys into getter/setters that
  851. * collect dependencies and dispatch updates.
  852. */
  853. class Observer {
  854. constructor(value, shallow = false, mock = false) {
  855. this.value = value;
  856. this.shallow = shallow;
  857. this.mock = mock;
  858. // this.value = value
  859. this.dep = mock ? mockDep : new Dep();
  860. this.vmCount = 0;
  861. def(value, '__ob__', this);
  862. if (isArray(value)) {
  863. if (!mock) {
  864. if (hasProto) {
  865. value.__proto__ = arrayMethods;
  866. /* eslint-enable no-proto */
  867. }
  868. else {
  869. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  870. const key = arrayKeys[i];
  871. def(value, key, arrayMethods[key]);
  872. }
  873. }
  874. }
  875. if (!shallow) {
  876. this.observeArray(value);
  877. }
  878. }
  879. else {
  880. /**
  881. * Walk through all properties and convert them into
  882. * getter/setters. This method should only be called when
  883. * value type is Object.
  884. */
  885. const keys = Object.keys(value);
  886. for (let i = 0; i < keys.length; i++) {
  887. const key = keys[i];
  888. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  889. }
  890. }
  891. }
  892. /**
  893. * Observe a list of Array items.
  894. */
  895. observeArray(value) {
  896. for (let i = 0, l = value.length; i < l; i++) {
  897. observe(value[i], false, this.mock);
  898. }
  899. }
  900. }
  901. // helpers
  902. /**
  903. * Attempt to create an observer instance for a value,
  904. * returns the new observer if successfully observed,
  905. * or the existing observer if the value already has one.
  906. */
  907. function observe(value, shallow, ssrMockReactivity) {
  908. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  909. return value.__ob__;
  910. }
  911. if (shouldObserve &&
  912. (ssrMockReactivity || !isServerRendering()) &&
  913. (isArray(value) || isPlainObject(value)) &&
  914. Object.isExtensible(value) &&
  915. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  916. !isRef(value) &&
  917. !(value instanceof VNode)) {
  918. return new Observer(value, shallow, ssrMockReactivity);
  919. }
  920. }
  921. /**
  922. * Define a reactive property on an Object.
  923. */
  924. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  925. const dep = new Dep();
  926. const property = Object.getOwnPropertyDescriptor(obj, key);
  927. if (property && property.configurable === false) {
  928. return;
  929. }
  930. // cater for pre-defined getter/setters
  931. const getter = property && property.get;
  932. const setter = property && property.set;
  933. if ((!getter || setter) &&
  934. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  935. val = obj[key];
  936. }
  937. let childOb = !shallow && observe(val, false, mock);
  938. Object.defineProperty(obj, key, {
  939. enumerable: true,
  940. configurable: true,
  941. get: function reactiveGetter() {
  942. const value = getter ? getter.call(obj) : val;
  943. if (Dep.target) {
  944. {
  945. dep.depend({
  946. target: obj,
  947. type: "get" /* TrackOpTypes.GET */,
  948. key
  949. });
  950. }
  951. if (childOb) {
  952. childOb.dep.depend();
  953. if (isArray(value)) {
  954. dependArray(value);
  955. }
  956. }
  957. }
  958. return isRef(value) && !shallow ? value.value : value;
  959. },
  960. set: function reactiveSetter(newVal) {
  961. const value = getter ? getter.call(obj) : val;
  962. if (!hasChanged(value, newVal)) {
  963. return;
  964. }
  965. if (customSetter) {
  966. customSetter();
  967. }
  968. if (setter) {
  969. setter.call(obj, newVal);
  970. }
  971. else if (getter) {
  972. // #7981: for accessor properties without setter
  973. return;
  974. }
  975. else if (!shallow && isRef(value) && !isRef(newVal)) {
  976. value.value = newVal;
  977. return;
  978. }
  979. else {
  980. val = newVal;
  981. }
  982. childOb = !shallow && observe(newVal, false, mock);
  983. {
  984. dep.notify({
  985. type: "set" /* TriggerOpTypes.SET */,
  986. target: obj,
  987. key,
  988. newValue: newVal,
  989. oldValue: value
  990. });
  991. }
  992. }
  993. });
  994. return dep;
  995. }
  996. function set(target, key, val) {
  997. if ((isUndef(target) || isPrimitive(target))) {
  998. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  999. }
  1000. if (isReadonly(target)) {
  1001. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1002. return;
  1003. }
  1004. const ob = target.__ob__;
  1005. if (isArray(target) && isValidArrayIndex(key)) {
  1006. target.length = Math.max(target.length, key);
  1007. target.splice(key, 1, val);
  1008. // when mocking for SSR, array methods are not hijacked
  1009. if (ob && !ob.shallow && ob.mock) {
  1010. observe(val, false, true);
  1011. }
  1012. return val;
  1013. }
  1014. if (key in target && !(key in Object.prototype)) {
  1015. target[key] = val;
  1016. return val;
  1017. }
  1018. if (target._isVue || (ob && ob.vmCount)) {
  1019. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1020. 'at runtime - declare it upfront in the data option.');
  1021. return val;
  1022. }
  1023. if (!ob) {
  1024. target[key] = val;
  1025. return val;
  1026. }
  1027. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1028. {
  1029. ob.dep.notify({
  1030. type: "add" /* TriggerOpTypes.ADD */,
  1031. target: target,
  1032. key,
  1033. newValue: val,
  1034. oldValue: undefined
  1035. });
  1036. }
  1037. return val;
  1038. }
  1039. function del(target, key) {
  1040. if ((isUndef(target) || isPrimitive(target))) {
  1041. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1042. }
  1043. if (isArray(target) && isValidArrayIndex(key)) {
  1044. target.splice(key, 1);
  1045. return;
  1046. }
  1047. const ob = target.__ob__;
  1048. if (target._isVue || (ob && ob.vmCount)) {
  1049. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1050. '- just set it to null.');
  1051. return;
  1052. }
  1053. if (isReadonly(target)) {
  1054. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1055. return;
  1056. }
  1057. if (!hasOwn(target, key)) {
  1058. return;
  1059. }
  1060. delete target[key];
  1061. if (!ob) {
  1062. return;
  1063. }
  1064. {
  1065. ob.dep.notify({
  1066. type: "delete" /* TriggerOpTypes.DELETE */,
  1067. target: target,
  1068. key
  1069. });
  1070. }
  1071. }
  1072. /**
  1073. * Collect dependencies on array elements when the array is touched, since
  1074. * we cannot intercept array element access like property getters.
  1075. */
  1076. function dependArray(value) {
  1077. for (let e, i = 0, l = value.length; i < l; i++) {
  1078. e = value[i];
  1079. if (e && e.__ob__) {
  1080. e.__ob__.dep.depend();
  1081. }
  1082. if (isArray(e)) {
  1083. dependArray(e);
  1084. }
  1085. }
  1086. }
  1087. function reactive(target) {
  1088. makeReactive(target, false);
  1089. return target;
  1090. }
  1091. /**
  1092. * Return a shallowly-reactive copy of the original object, where only the root
  1093. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1094. * root level).
  1095. */
  1096. function shallowReactive(target) {
  1097. makeReactive(target, true);
  1098. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1099. return target;
  1100. }
  1101. function makeReactive(target, shallow) {
  1102. // if trying to observe a readonly proxy, return the readonly version.
  1103. if (!isReadonly(target)) {
  1104. {
  1105. if (isArray(target)) {
  1106. 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.`);
  1107. }
  1108. const existingOb = target && target.__ob__;
  1109. if (existingOb && existingOb.shallow !== shallow) {
  1110. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1111. }
  1112. }
  1113. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1114. if (!ob) {
  1115. if (target == null || isPrimitive(target)) {
  1116. warn$2(`value cannot be made reactive: ${String(target)}`);
  1117. }
  1118. if (isCollectionType(target)) {
  1119. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1120. }
  1121. }
  1122. }
  1123. }
  1124. function isReactive(value) {
  1125. if (isReadonly(value)) {
  1126. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1127. }
  1128. return !!(value && value.__ob__);
  1129. }
  1130. function isShallow(value) {
  1131. return !!(value && value.__v_isShallow);
  1132. }
  1133. function isReadonly(value) {
  1134. return !!(value && value.__v_isReadonly);
  1135. }
  1136. function isProxy(value) {
  1137. return isReactive(value) || isReadonly(value);
  1138. }
  1139. function toRaw(observed) {
  1140. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1141. return raw ? toRaw(raw) : observed;
  1142. }
  1143. function markRaw(value) {
  1144. // non-extensible objects won't be observed anyway
  1145. if (Object.isExtensible(value)) {
  1146. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1147. }
  1148. return value;
  1149. }
  1150. /**
  1151. * @internal
  1152. */
  1153. function isCollectionType(value) {
  1154. const type = toRawType(value);
  1155. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1156. }
  1157. /**
  1158. * @internal
  1159. */
  1160. const RefFlag = `__v_isRef`;
  1161. function isRef(r) {
  1162. return !!(r && r.__v_isRef === true);
  1163. }
  1164. function ref$1(value) {
  1165. return createRef(value, false);
  1166. }
  1167. function shallowRef(value) {
  1168. return createRef(value, true);
  1169. }
  1170. function createRef(rawValue, shallow) {
  1171. if (isRef(rawValue)) {
  1172. return rawValue;
  1173. }
  1174. const ref = {};
  1175. def(ref, RefFlag, true);
  1176. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1177. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1178. return ref;
  1179. }
  1180. function triggerRef(ref) {
  1181. if (!ref.dep) {
  1182. warn$2(`received object is not a triggerable ref.`);
  1183. }
  1184. {
  1185. ref.dep &&
  1186. ref.dep.notify({
  1187. type: "set" /* TriggerOpTypes.SET */,
  1188. target: ref,
  1189. key: 'value'
  1190. });
  1191. }
  1192. }
  1193. function unref(ref) {
  1194. return isRef(ref) ? ref.value : ref;
  1195. }
  1196. function proxyRefs(objectWithRefs) {
  1197. if (isReactive(objectWithRefs)) {
  1198. return objectWithRefs;
  1199. }
  1200. const proxy = {};
  1201. const keys = Object.keys(objectWithRefs);
  1202. for (let i = 0; i < keys.length; i++) {
  1203. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1204. }
  1205. return proxy;
  1206. }
  1207. function proxyWithRefUnwrap(target, source, key) {
  1208. Object.defineProperty(target, key, {
  1209. enumerable: true,
  1210. configurable: true,
  1211. get: () => {
  1212. const val = source[key];
  1213. if (isRef(val)) {
  1214. return val.value;
  1215. }
  1216. else {
  1217. const ob = val && val.__ob__;
  1218. if (ob)
  1219. ob.dep.depend();
  1220. return val;
  1221. }
  1222. },
  1223. set: value => {
  1224. const oldValue = source[key];
  1225. if (isRef(oldValue) && !isRef(value)) {
  1226. oldValue.value = value;
  1227. }
  1228. else {
  1229. source[key] = value;
  1230. }
  1231. }
  1232. });
  1233. }
  1234. function customRef(factory) {
  1235. const dep = new Dep();
  1236. const { get, set } = factory(() => {
  1237. {
  1238. dep.depend({
  1239. target: ref,
  1240. type: "get" /* TrackOpTypes.GET */,
  1241. key: 'value'
  1242. });
  1243. }
  1244. }, () => {
  1245. {
  1246. dep.notify({
  1247. target: ref,
  1248. type: "set" /* TriggerOpTypes.SET */,
  1249. key: 'value'
  1250. });
  1251. }
  1252. });
  1253. const ref = {
  1254. get value() {
  1255. return get();
  1256. },
  1257. set value(newVal) {
  1258. set(newVal);
  1259. }
  1260. };
  1261. def(ref, RefFlag, true);
  1262. return ref;
  1263. }
  1264. function toRefs(object) {
  1265. if (!isReactive(object)) {
  1266. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1267. }
  1268. const ret = isArray(object) ? new Array(object.length) : {};
  1269. for (const key in object) {
  1270. ret[key] = toRef(object, key);
  1271. }
  1272. return ret;
  1273. }
  1274. function toRef(object, key, defaultValue) {
  1275. const val = object[key];
  1276. if (isRef(val)) {
  1277. return val;
  1278. }
  1279. const ref = {
  1280. get value() {
  1281. const val = object[key];
  1282. return val === undefined ? defaultValue : val;
  1283. },
  1284. set value(newVal) {
  1285. object[key] = newVal;
  1286. }
  1287. };
  1288. def(ref, RefFlag, true);
  1289. return ref;
  1290. }
  1291. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1292. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1293. function readonly(target) {
  1294. return createReadonly(target, false);
  1295. }
  1296. function createReadonly(target, shallow) {
  1297. if (!isPlainObject(target)) {
  1298. {
  1299. if (isArray(target)) {
  1300. warn$2(`Vue 2 does not support readonly arrays.`);
  1301. }
  1302. else if (isCollectionType(target)) {
  1303. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1304. }
  1305. else {
  1306. warn$2(`value cannot be made readonly: ${typeof target}`);
  1307. }
  1308. }
  1309. return target;
  1310. }
  1311. if (!Object.isExtensible(target)) {
  1312. warn$2(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1313. }
  1314. // already a readonly object
  1315. if (isReadonly(target)) {
  1316. return target;
  1317. }
  1318. // already has a readonly proxy
  1319. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1320. const existingProxy = target[existingFlag];
  1321. if (existingProxy) {
  1322. return existingProxy;
  1323. }
  1324. const proxy = Object.create(Object.getPrototypeOf(target));
  1325. def(target, existingFlag, proxy);
  1326. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1327. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1328. if (isRef(target)) {
  1329. def(proxy, RefFlag, true);
  1330. }
  1331. if (shallow || isShallow(target)) {
  1332. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1333. }
  1334. const keys = Object.keys(target);
  1335. for (let i = 0; i < keys.length; i++) {
  1336. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1337. }
  1338. return proxy;
  1339. }
  1340. function defineReadonlyProperty(proxy, target, key, shallow) {
  1341. Object.defineProperty(proxy, key, {
  1342. enumerable: true,
  1343. configurable: true,
  1344. get() {
  1345. const val = target[key];
  1346. return shallow || !isPlainObject(val) ? val : readonly(val);
  1347. },
  1348. set() {
  1349. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1350. }
  1351. });
  1352. }
  1353. /**
  1354. * Returns a reactive-copy of the original object, where only the root level
  1355. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1356. * returned properties.
  1357. * This is used for creating the props proxy object for stateful components.
  1358. */
  1359. function shallowReadonly(target) {
  1360. return createReadonly(target, true);
  1361. }
  1362. function computed(getterOrOptions, debugOptions) {
  1363. let getter;
  1364. let setter;
  1365. const onlyGetter = isFunction(getterOrOptions);
  1366. if (onlyGetter) {
  1367. getter = getterOrOptions;
  1368. setter = () => {
  1369. warn$2('Write operation failed: computed value is readonly');
  1370. }
  1371. ;
  1372. }
  1373. else {
  1374. getter = getterOrOptions.get;
  1375. setter = getterOrOptions.set;
  1376. }
  1377. const watcher = isServerRendering()
  1378. ? null
  1379. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1380. if (watcher && debugOptions) {
  1381. watcher.onTrack = debugOptions.onTrack;
  1382. watcher.onTrigger = debugOptions.onTrigger;
  1383. }
  1384. const ref = {
  1385. // some libs rely on the presence effect for checking computed refs
  1386. // from normal refs, but the implementation doesn't matter
  1387. effect: watcher,
  1388. get value() {
  1389. if (watcher) {
  1390. if (watcher.dirty) {
  1391. watcher.evaluate();
  1392. }
  1393. if (Dep.target) {
  1394. if (Dep.target.onTrack) {
  1395. Dep.target.onTrack({
  1396. effect: Dep.target,
  1397. target: ref,
  1398. type: "get" /* TrackOpTypes.GET */,
  1399. key: 'value'
  1400. });
  1401. }
  1402. watcher.depend();
  1403. }
  1404. return watcher.value;
  1405. }
  1406. else {
  1407. return getter();
  1408. }
  1409. },
  1410. set value(newVal) {
  1411. setter(newVal);
  1412. }
  1413. };
  1414. def(ref, RefFlag, true);
  1415. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1416. return ref;
  1417. }
  1418. let mark;
  1419. let measure;
  1420. {
  1421. const perf = inBrowser && window.performance;
  1422. /* istanbul ignore if */
  1423. if (perf &&
  1424. // @ts-ignore
  1425. perf.mark &&
  1426. // @ts-ignore
  1427. perf.measure &&
  1428. // @ts-ignore
  1429. perf.clearMarks &&
  1430. // @ts-ignore
  1431. perf.clearMeasures) {
  1432. mark = tag => perf.mark(tag);
  1433. measure = (name, startTag, endTag) => {
  1434. perf.measure(name, startTag, endTag);
  1435. perf.clearMarks(startTag);
  1436. perf.clearMarks(endTag);
  1437. // perf.clearMeasures(name)
  1438. };
  1439. }
  1440. }
  1441. const normalizeEvent = cached((name) => {
  1442. const passive = name.charAt(0) === '&';
  1443. name = passive ? name.slice(1) : name;
  1444. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1445. name = once ? name.slice(1) : name;
  1446. const capture = name.charAt(0) === '!';
  1447. name = capture ? name.slice(1) : name;
  1448. return {
  1449. name,
  1450. once,
  1451. capture,
  1452. passive
  1453. };
  1454. });
  1455. function createFnInvoker(fns, vm) {
  1456. function invoker() {
  1457. const fns = invoker.fns;
  1458. if (isArray(fns)) {
  1459. const cloned = fns.slice();
  1460. for (let i = 0; i < cloned.length; i++) {
  1461. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1462. }
  1463. }
  1464. else {
  1465. // return handler return value for single handlers
  1466. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1467. }
  1468. }
  1469. invoker.fns = fns;
  1470. return invoker;
  1471. }
  1472. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1473. let name, cur, old, event;
  1474. for (name in on) {
  1475. cur = on[name];
  1476. old = oldOn[name];
  1477. event = normalizeEvent(name);
  1478. if (isUndef(cur)) {
  1479. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1480. }
  1481. else if (isUndef(old)) {
  1482. if (isUndef(cur.fns)) {
  1483. cur = on[name] = createFnInvoker(cur, vm);
  1484. }
  1485. if (isTrue(event.once)) {
  1486. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1487. }
  1488. add(event.name, cur, event.capture, event.passive, event.params);
  1489. }
  1490. else if (cur !== old) {
  1491. old.fns = cur;
  1492. on[name] = old;
  1493. }
  1494. }
  1495. for (name in oldOn) {
  1496. if (isUndef(on[name])) {
  1497. event = normalizeEvent(name);
  1498. remove(event.name, oldOn[name], event.capture);
  1499. }
  1500. }
  1501. }
  1502. function mergeVNodeHook(def, hookKey, hook) {
  1503. if (def instanceof VNode) {
  1504. def = def.data.hook || (def.data.hook = {});
  1505. }
  1506. let invoker;
  1507. const oldHook = def[hookKey];
  1508. function wrappedHook() {
  1509. hook.apply(this, arguments);
  1510. // important: remove merged hook to ensure it's called only once
  1511. // and prevent memory leak
  1512. remove$2(invoker.fns, wrappedHook);
  1513. }
  1514. if (isUndef(oldHook)) {
  1515. // no existing hook
  1516. invoker = createFnInvoker([wrappedHook]);
  1517. }
  1518. else {
  1519. /* istanbul ignore if */
  1520. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1521. // already a merged invoker
  1522. invoker = oldHook;
  1523. invoker.fns.push(wrappedHook);
  1524. }
  1525. else {
  1526. // existing plain hook
  1527. invoker = createFnInvoker([oldHook, wrappedHook]);
  1528. }
  1529. }
  1530. invoker.merged = true;
  1531. def[hookKey] = invoker;
  1532. }
  1533. function extractPropsFromVNodeData(data, Ctor, tag) {
  1534. // we are only extracting raw values here.
  1535. // validation and default values are handled in the child
  1536. // component itself.
  1537. const propOptions = Ctor.options.props;
  1538. if (isUndef(propOptions)) {
  1539. return;
  1540. }
  1541. const res = {};
  1542. const { attrs, props } = data;
  1543. if (isDef(attrs) || isDef(props)) {
  1544. for (const key in propOptions) {
  1545. const altKey = hyphenate(key);
  1546. {
  1547. const keyInLowerCase = key.toLowerCase();
  1548. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1549. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1550. `${formatComponentName(
  1551. // @ts-expect-error tag is string
  1552. tag || Ctor)}, but the declared prop name is` +
  1553. ` "${key}". ` +
  1554. `Note that HTML attributes are case-insensitive and camelCased ` +
  1555. `props need to use their kebab-case equivalents when using in-DOM ` +
  1556. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1557. }
  1558. }
  1559. checkProp(res, props, key, altKey, true) ||
  1560. checkProp(res, attrs, key, altKey, false);
  1561. }
  1562. }
  1563. return res;
  1564. }
  1565. function checkProp(res, hash, key, altKey, preserve) {
  1566. if (isDef(hash)) {
  1567. if (hasOwn(hash, key)) {
  1568. res[key] = hash[key];
  1569. if (!preserve) {
  1570. delete hash[key];
  1571. }
  1572. return true;
  1573. }
  1574. else if (hasOwn(hash, altKey)) {
  1575. res[key] = hash[altKey];
  1576. if (!preserve) {
  1577. delete hash[altKey];
  1578. }
  1579. return true;
  1580. }
  1581. }
  1582. return false;
  1583. }
  1584. // The template compiler attempts to minimize the need for normalization by
  1585. // statically analyzing the template at compile time.
  1586. //
  1587. // For plain HTML markup, normalization can be completely skipped because the
  1588. // generated render function is guaranteed to return Array<VNode>. There are
  1589. // two cases where extra normalization is needed:
  1590. // 1. When the children contains components - because a functional component
  1591. // may return an Array instead of a single root. In this case, just a simple
  1592. // normalization is needed - if any child is an Array, we flatten the whole
  1593. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1594. // because functional components already normalize their own children.
  1595. function simpleNormalizeChildren(children) {
  1596. for (let i = 0; i < children.length; i++) {
  1597. if (isArray(children[i])) {
  1598. return Array.prototype.concat.apply([], children);
  1599. }
  1600. }
  1601. return children;
  1602. }
  1603. // 2. When the children contains constructs that always generated nested Arrays,
  1604. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1605. // with hand-written render functions / JSX. In such cases a full normalization
  1606. // is needed to cater to all possible types of children values.
  1607. function normalizeChildren(children) {
  1608. return isPrimitive(children)
  1609. ? [createTextVNode(children)]
  1610. : isArray(children)
  1611. ? normalizeArrayChildren(children)
  1612. : undefined;
  1613. }
  1614. function isTextNode(node) {
  1615. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1616. }
  1617. function normalizeArrayChildren(children, nestedIndex) {
  1618. const res = [];
  1619. let i, c, lastIndex, last;
  1620. for (i = 0; i < children.length; i++) {
  1621. c = children[i];
  1622. if (isUndef(c) || typeof c === 'boolean')
  1623. continue;
  1624. lastIndex = res.length - 1;
  1625. last = res[lastIndex];
  1626. // nested
  1627. if (isArray(c)) {
  1628. if (c.length > 0) {
  1629. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1630. // merge adjacent text nodes
  1631. if (isTextNode(c[0]) && isTextNode(last)) {
  1632. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1633. c.shift();
  1634. }
  1635. res.push.apply(res, c);
  1636. }
  1637. }
  1638. else if (isPrimitive(c)) {
  1639. if (isTextNode(last)) {
  1640. // merge adjacent text nodes
  1641. // this is necessary for SSR hydration because text nodes are
  1642. // essentially merged when rendered to HTML strings
  1643. res[lastIndex] = createTextVNode(last.text + c);
  1644. }
  1645. else if (c !== '') {
  1646. // convert primitive to vnode
  1647. res.push(createTextVNode(c));
  1648. }
  1649. }
  1650. else {
  1651. if (isTextNode(c) && isTextNode(last)) {
  1652. // merge adjacent text nodes
  1653. res[lastIndex] = createTextVNode(last.text + c.text);
  1654. }
  1655. else {
  1656. // default key for nested array children (likely generated by v-for)
  1657. if (isTrue(children._isVList) &&
  1658. isDef(c.tag) &&
  1659. isUndef(c.key) &&
  1660. isDef(nestedIndex)) {
  1661. c.key = `__vlist${nestedIndex}_${i}__`;
  1662. }
  1663. res.push(c);
  1664. }
  1665. }
  1666. }
  1667. return res;
  1668. }
  1669. const SIMPLE_NORMALIZE = 1;
  1670. const ALWAYS_NORMALIZE = 2;
  1671. // wrapper function for providing a more flexible interface
  1672. // without getting yelled at by flow
  1673. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1674. if (isArray(data) || isPrimitive(data)) {
  1675. normalizationType = children;
  1676. children = data;
  1677. data = undefined;
  1678. }
  1679. if (isTrue(alwaysNormalize)) {
  1680. normalizationType = ALWAYS_NORMALIZE;
  1681. }
  1682. return _createElement(context, tag, data, children, normalizationType);
  1683. }
  1684. function _createElement(context, tag, data, children, normalizationType) {
  1685. if (isDef(data) && isDef(data.__ob__)) {
  1686. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1687. return createEmptyVNode();
  1688. }
  1689. // object syntax in v-bind
  1690. if (isDef(data) && isDef(data.is)) {
  1691. tag = data.is;
  1692. }
  1693. if (!tag) {
  1694. // in case of component :is set to falsy value
  1695. return createEmptyVNode();
  1696. }
  1697. // warn against non-primitive key
  1698. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1699. warn$2('Avoid using non-primitive value as key, ' +
  1700. 'use string/number value instead.', context);
  1701. }
  1702. // support single function children as default scoped slot
  1703. if (isArray(children) && isFunction(children[0])) {
  1704. data = data || {};
  1705. data.scopedSlots = { default: children[0] };
  1706. children.length = 0;
  1707. }
  1708. if (normalizationType === ALWAYS_NORMALIZE) {
  1709. children = normalizeChildren(children);
  1710. }
  1711. else if (normalizationType === SIMPLE_NORMALIZE) {
  1712. children = simpleNormalizeChildren(children);
  1713. }
  1714. let vnode, ns;
  1715. if (typeof tag === 'string') {
  1716. let Ctor;
  1717. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1718. if (config.isReservedTag(tag)) {
  1719. // platform built-in elements
  1720. if (isDef(data) &&
  1721. isDef(data.nativeOn) &&
  1722. data.tag !== 'component') {
  1723. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1724. }
  1725. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1726. }
  1727. else if ((!data || !data.pre) &&
  1728. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1729. // component
  1730. vnode = createComponent(Ctor, data, context, children, tag);
  1731. }
  1732. else {
  1733. // unknown or unlisted namespaced elements
  1734. // check at runtime because it may get assigned a namespace when its
  1735. // parent normalizes children
  1736. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1737. }
  1738. }
  1739. else {
  1740. // direct component options / constructor
  1741. vnode = createComponent(tag, data, context, children);
  1742. }
  1743. if (isArray(vnode)) {
  1744. return vnode;
  1745. }
  1746. else if (isDef(vnode)) {
  1747. if (isDef(ns))
  1748. applyNS(vnode, ns);
  1749. if (isDef(data))
  1750. registerDeepBindings(data);
  1751. return vnode;
  1752. }
  1753. else {
  1754. return createEmptyVNode();
  1755. }
  1756. }
  1757. function applyNS(vnode, ns, force) {
  1758. vnode.ns = ns;
  1759. if (vnode.tag === 'foreignObject') {
  1760. // use default namespace inside foreignObject
  1761. ns = undefined;
  1762. force = true;
  1763. }
  1764. if (isDef(vnode.children)) {
  1765. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1766. const child = vnode.children[i];
  1767. if (isDef(child.tag) &&
  1768. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1769. applyNS(child, ns, force);
  1770. }
  1771. }
  1772. }
  1773. }
  1774. // ref #5318
  1775. // necessary to ensure parent re-render when deep bindings like :style and
  1776. // :class are used on slot nodes
  1777. function registerDeepBindings(data) {
  1778. if (isObject(data.style)) {
  1779. traverse(data.style);
  1780. }
  1781. if (isObject(data.class)) {
  1782. traverse(data.class);
  1783. }
  1784. }
  1785. /**
  1786. * Runtime helper for rendering v-for lists.
  1787. */
  1788. function renderList(val, render) {
  1789. let ret = null, i, l, keys, key;
  1790. if (isArray(val) || typeof val === 'string') {
  1791. ret = new Array(val.length);
  1792. for (i = 0, l = val.length; i < l; i++) {
  1793. ret[i] = render(val[i], i);
  1794. }
  1795. }
  1796. else if (typeof val === 'number') {
  1797. ret = new Array(val);
  1798. for (i = 0; i < val; i++) {
  1799. ret[i] = render(i + 1, i);
  1800. }
  1801. }
  1802. else if (isObject(val)) {
  1803. if (hasSymbol && val[Symbol.iterator]) {
  1804. ret = [];
  1805. const iterator = val[Symbol.iterator]();
  1806. let result = iterator.next();
  1807. while (!result.done) {
  1808. ret.push(render(result.value, ret.length));
  1809. result = iterator.next();
  1810. }
  1811. }
  1812. else {
  1813. keys = Object.keys(val);
  1814. ret = new Array(keys.length);
  1815. for (i = 0, l = keys.length; i < l; i++) {
  1816. key = keys[i];
  1817. ret[i] = render(val[key], key, i);
  1818. }
  1819. }
  1820. }
  1821. if (!isDef(ret)) {
  1822. ret = [];
  1823. }
  1824. ret._isVList = true;
  1825. return ret;
  1826. }
  1827. /**
  1828. * Runtime helper for rendering <slot>
  1829. */
  1830. function renderSlot(name, fallbackRender, props, bindObject) {
  1831. const scopedSlotFn = this.$scopedSlots[name];
  1832. let nodes;
  1833. if (scopedSlotFn) {
  1834. // scoped slot
  1835. props = props || {};
  1836. if (bindObject) {
  1837. if (!isObject(bindObject)) {
  1838. warn$2('slot v-bind without argument expects an Object', this);
  1839. }
  1840. props = extend(extend({}, bindObject), props);
  1841. }
  1842. nodes =
  1843. scopedSlotFn(props) ||
  1844. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1845. }
  1846. else {
  1847. nodes =
  1848. this.$slots[name] ||
  1849. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1850. }
  1851. const target = props && props.slot;
  1852. if (target) {
  1853. return this.$createElement('template', { slot: target }, nodes);
  1854. }
  1855. else {
  1856. return nodes;
  1857. }
  1858. }
  1859. /**
  1860. * Runtime helper for resolving filters
  1861. */
  1862. function resolveFilter(id) {
  1863. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1864. }
  1865. function isKeyNotMatch(expect, actual) {
  1866. if (isArray(expect)) {
  1867. return expect.indexOf(actual) === -1;
  1868. }
  1869. else {
  1870. return expect !== actual;
  1871. }
  1872. }
  1873. /**
  1874. * Runtime helper for checking keyCodes from config.
  1875. * exposed as Vue.prototype._k
  1876. * passing in eventKeyName as last argument separately for backwards compat
  1877. */
  1878. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1879. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1880. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1881. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1882. }
  1883. else if (mappedKeyCode) {
  1884. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1885. }
  1886. else if (eventKeyName) {
  1887. return hyphenate(eventKeyName) !== key;
  1888. }
  1889. return eventKeyCode === undefined;
  1890. }
  1891. /**
  1892. * Runtime helper for merging v-bind="object" into a VNode's data.
  1893. */
  1894. function bindObjectProps(data, tag, value, asProp, isSync) {
  1895. if (value) {
  1896. if (!isObject(value)) {
  1897. warn$2('v-bind without argument expects an Object or Array value', this);
  1898. }
  1899. else {
  1900. if (isArray(value)) {
  1901. value = toObject(value);
  1902. }
  1903. let hash;
  1904. for (const key in value) {
  1905. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1906. hash = data;
  1907. }
  1908. else {
  1909. const type = data.attrs && data.attrs.type;
  1910. hash =
  1911. asProp || config.mustUseProp(tag, type, key)
  1912. ? data.domProps || (data.domProps = {})
  1913. : data.attrs || (data.attrs = {});
  1914. }
  1915. const camelizedKey = camelize(key);
  1916. const hyphenatedKey = hyphenate(key);
  1917. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1918. hash[key] = value[key];
  1919. if (isSync) {
  1920. const on = data.on || (data.on = {});
  1921. on[`update:${key}`] = function ($event) {
  1922. value[key] = $event;
  1923. };
  1924. }
  1925. }
  1926. }
  1927. }
  1928. }
  1929. return data;
  1930. }
  1931. /**
  1932. * Runtime helper for rendering static trees.
  1933. */
  1934. function renderStatic(index, isInFor) {
  1935. const cached = this._staticTrees || (this._staticTrees = []);
  1936. let tree = cached[index];
  1937. // if has already-rendered static tree and not inside v-for,
  1938. // we can reuse the same tree.
  1939. if (tree && !isInFor) {
  1940. return tree;
  1941. }
  1942. // otherwise, render a fresh tree.
  1943. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1944. );
  1945. markStatic$1(tree, `__static__${index}`, false);
  1946. return tree;
  1947. }
  1948. /**
  1949. * Runtime helper for v-once.
  1950. * Effectively it means marking the node as static with a unique key.
  1951. */
  1952. function markOnce(tree, index, key) {
  1953. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1954. return tree;
  1955. }
  1956. function markStatic$1(tree, key, isOnce) {
  1957. if (isArray(tree)) {
  1958. for (let i = 0; i < tree.length; i++) {
  1959. if (tree[i] && typeof tree[i] !== 'string') {
  1960. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1961. }
  1962. }
  1963. }
  1964. else {
  1965. markStaticNode(tree, key, isOnce);
  1966. }
  1967. }
  1968. function markStaticNode(node, key, isOnce) {
  1969. node.isStatic = true;
  1970. node.key = key;
  1971. node.isOnce = isOnce;
  1972. }
  1973. function bindObjectListeners(data, value) {
  1974. if (value) {
  1975. if (!isPlainObject(value)) {
  1976. warn$2('v-on without argument expects an Object value', this);
  1977. }
  1978. else {
  1979. const on = (data.on = data.on ? extend({}, data.on) : {});
  1980. for (const key in value) {
  1981. const existing = on[key];
  1982. const ours = value[key];
  1983. on[key] = existing ? [].concat(existing, ours) : ours;
  1984. }
  1985. }
  1986. }
  1987. return data;
  1988. }
  1989. function resolveScopedSlots(fns, res,
  1990. // the following are added in 2.6
  1991. hasDynamicKeys, contentHashKey) {
  1992. res = res || { $stable: !hasDynamicKeys };
  1993. for (let i = 0; i < fns.length; i++) {
  1994. const slot = fns[i];
  1995. if (isArray(slot)) {
  1996. resolveScopedSlots(slot, res, hasDynamicKeys);
  1997. }
  1998. else if (slot) {
  1999. // marker for reverse proxying v-slot without scope on this.$slots
  2000. // @ts-expect-error
  2001. if (slot.proxy) {
  2002. // @ts-expect-error
  2003. slot.fn.proxy = true;
  2004. }
  2005. res[slot.key] = slot.fn;
  2006. }
  2007. }
  2008. if (contentHashKey) {
  2009. res.$key = contentHashKey;
  2010. }
  2011. return res;
  2012. }
  2013. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2014. function bindDynamicKeys(baseObj, values) {
  2015. for (let i = 0; i < values.length; i += 2) {
  2016. const key = values[i];
  2017. if (typeof key === 'string' && key) {
  2018. baseObj[values[i]] = values[i + 1];
  2019. }
  2020. else if (key !== '' && key !== null) {
  2021. // null is a special value for explicitly removing a binding
  2022. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2023. }
  2024. }
  2025. return baseObj;
  2026. }
  2027. // helper to dynamically append modifier runtime markers to event names.
  2028. // ensure only append when value is already string, otherwise it will be cast
  2029. // to string and cause the type check to miss.
  2030. function prependModifier(value, symbol) {
  2031. return typeof value === 'string' ? symbol + value : value;
  2032. }
  2033. function installRenderHelpers(target) {
  2034. target._o = markOnce;
  2035. target._n = toNumber;
  2036. target._s = toString;
  2037. target._l = renderList;
  2038. target._t = renderSlot;
  2039. target._q = looseEqual;
  2040. target._i = looseIndexOf;
  2041. target._m = renderStatic;
  2042. target._f = resolveFilter;
  2043. target._k = checkKeyCodes;
  2044. target._b = bindObjectProps;
  2045. target._v = createTextVNode;
  2046. target._e = createEmptyVNode;
  2047. target._u = resolveScopedSlots;
  2048. target._g = bindObjectListeners;
  2049. target._d = bindDynamicKeys;
  2050. target._p = prependModifier;
  2051. }
  2052. /**
  2053. * Runtime helper for resolving raw children VNodes into a slot object.
  2054. */
  2055. function resolveSlots(children, context) {
  2056. if (!children || !children.length) {
  2057. return {};
  2058. }
  2059. const slots = {};
  2060. for (let i = 0, l = children.length; i < l; i++) {
  2061. const child = children[i];
  2062. const data = child.data;
  2063. // remove slot attribute if the node is resolved as a Vue slot node
  2064. if (data && data.attrs && data.attrs.slot) {
  2065. delete data.attrs.slot;
  2066. }
  2067. // named slots should only be respected if the vnode was rendered in the
  2068. // same context.
  2069. if ((child.context === context || child.fnContext === context) &&
  2070. data &&
  2071. data.slot != null) {
  2072. const name = data.slot;
  2073. const slot = slots[name] || (slots[name] = []);
  2074. if (child.tag === 'template') {
  2075. slot.push.apply(slot, child.children || []);
  2076. }
  2077. else {
  2078. slot.push(child);
  2079. }
  2080. }
  2081. else {
  2082. (slots.default || (slots.default = [])).push(child);
  2083. }
  2084. }
  2085. // ignore slots that contains only whitespace
  2086. for (const name in slots) {
  2087. if (slots[name].every(isWhitespace)) {
  2088. delete slots[name];
  2089. }
  2090. }
  2091. return slots;
  2092. }
  2093. function isWhitespace(node) {
  2094. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2095. }
  2096. function isAsyncPlaceholder(node) {
  2097. // @ts-expect-error not really boolean type
  2098. return node.isComment && node.asyncFactory;
  2099. }
  2100. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2101. let res;
  2102. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2103. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2104. const key = scopedSlots && scopedSlots.$key;
  2105. if (!scopedSlots) {
  2106. res = {};
  2107. }
  2108. else if (scopedSlots._normalized) {
  2109. // fast path 1: child component re-render only, parent did not change
  2110. return scopedSlots._normalized;
  2111. }
  2112. else if (isStable &&
  2113. prevScopedSlots &&
  2114. prevScopedSlots !== emptyObject &&
  2115. key === prevScopedSlots.$key &&
  2116. !hasNormalSlots &&
  2117. !prevScopedSlots.$hasNormal) {
  2118. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2119. // only need to normalize once
  2120. return prevScopedSlots;
  2121. }
  2122. else {
  2123. res = {};
  2124. for (const key in scopedSlots) {
  2125. if (scopedSlots[key] && key[0] !== '$') {
  2126. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2127. }
  2128. }
  2129. }
  2130. // expose normal slots on scopedSlots
  2131. for (const key in normalSlots) {
  2132. if (!(key in res)) {
  2133. res[key] = proxyNormalSlot(normalSlots, key);
  2134. }
  2135. }
  2136. // avoriaz seems to mock a non-extensible $scopedSlots object
  2137. // and when that is passed down this would cause an error
  2138. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2139. scopedSlots._normalized = res;
  2140. }
  2141. def(res, '$stable', isStable);
  2142. def(res, '$key', key);
  2143. def(res, '$hasNormal', hasNormalSlots);
  2144. return res;
  2145. }
  2146. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2147. const normalized = function () {
  2148. const cur = currentInstance;
  2149. setCurrentInstance(vm);
  2150. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2151. res =
  2152. res && typeof res === 'object' && !isArray(res)
  2153. ? [res] // single vnode
  2154. : normalizeChildren(res);
  2155. const vnode = res && res[0];
  2156. setCurrentInstance(cur);
  2157. return res &&
  2158. (!vnode ||
  2159. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2160. ? undefined
  2161. : res;
  2162. };
  2163. // this is a slot using the new v-slot syntax without scope. although it is
  2164. // compiled as a scoped slot, render fn users would expect it to be present
  2165. // on this.$slots because the usage is semantically a normal slot.
  2166. if (fn.proxy) {
  2167. Object.defineProperty(normalSlots, key, {
  2168. get: normalized,
  2169. enumerable: true,
  2170. configurable: true
  2171. });
  2172. }
  2173. return normalized;
  2174. }
  2175. function proxyNormalSlot(slots, key) {
  2176. return () => slots[key];
  2177. }
  2178. function initSetup(vm) {
  2179. const options = vm.$options;
  2180. const setup = options.setup;
  2181. if (setup) {
  2182. const ctx = (vm._setupContext = createSetupContext(vm));
  2183. setCurrentInstance(vm);
  2184. pushTarget();
  2185. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2186. popTarget();
  2187. setCurrentInstance();
  2188. if (isFunction(setupResult)) {
  2189. // render function
  2190. // @ts-ignore
  2191. options.render = setupResult;
  2192. }
  2193. else if (isObject(setupResult)) {
  2194. // bindings
  2195. if (setupResult instanceof VNode) {
  2196. warn$2(`setup() should not return VNodes directly - ` +
  2197. `return a render function instead.`);
  2198. }
  2199. vm._setupState = setupResult;
  2200. // __sfc indicates compiled bindings from <script setup>
  2201. if (!setupResult.__sfc) {
  2202. for (const key in setupResult) {
  2203. if (!isReserved(key)) {
  2204. proxyWithRefUnwrap(vm, setupResult, key);
  2205. }
  2206. else {
  2207. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2208. }
  2209. }
  2210. }
  2211. else {
  2212. // exposed for compiled render fn
  2213. const proxy = (vm._setupProxy = {});
  2214. for (const key in setupResult) {
  2215. if (key !== '__sfc') {
  2216. proxyWithRefUnwrap(proxy, setupResult, key);
  2217. }
  2218. }
  2219. }
  2220. }
  2221. else if (setupResult !== undefined) {
  2222. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2223. }
  2224. }
  2225. }
  2226. function createSetupContext(vm) {
  2227. let exposeCalled = false;
  2228. return {
  2229. get attrs() {
  2230. if (!vm._attrsProxy) {
  2231. const proxy = (vm._attrsProxy = {});
  2232. def(proxy, '_v_attr_proxy', true);
  2233. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2234. }
  2235. return vm._attrsProxy;
  2236. },
  2237. get listeners() {
  2238. if (!vm._listenersProxy) {
  2239. const proxy = (vm._listenersProxy = {});
  2240. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2241. }
  2242. return vm._listenersProxy;
  2243. },
  2244. get slots() {
  2245. return initSlotsProxy(vm);
  2246. },
  2247. emit: bind$1(vm.$emit, vm),
  2248. expose(exposed) {
  2249. {
  2250. if (exposeCalled) {
  2251. warn$2(`expose() should be called only once per setup().`, vm);
  2252. }
  2253. exposeCalled = true;
  2254. }
  2255. if (exposed) {
  2256. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2257. }
  2258. }
  2259. };
  2260. }
  2261. function syncSetupProxy(to, from, prev, instance, type) {
  2262. let changed = false;
  2263. for (const key in from) {
  2264. if (!(key in to)) {
  2265. changed = true;
  2266. defineProxyAttr(to, key, instance, type);
  2267. }
  2268. else if (from[key] !== prev[key]) {
  2269. changed = true;
  2270. }
  2271. }
  2272. for (const key in to) {
  2273. if (!(key in from)) {
  2274. changed = true;
  2275. delete to[key];
  2276. }
  2277. }
  2278. return changed;
  2279. }
  2280. function defineProxyAttr(proxy, key, instance, type) {
  2281. Object.defineProperty(proxy, key, {
  2282. enumerable: true,
  2283. configurable: true,
  2284. get() {
  2285. return instance[type][key];
  2286. }
  2287. });
  2288. }
  2289. function initSlotsProxy(vm) {
  2290. if (!vm._slotsProxy) {
  2291. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2292. }
  2293. return vm._slotsProxy;
  2294. }
  2295. function syncSetupSlots(to, from) {
  2296. for (const key in from) {
  2297. to[key] = from[key];
  2298. }
  2299. for (const key in to) {
  2300. if (!(key in from)) {
  2301. delete to[key];
  2302. }
  2303. }
  2304. }
  2305. /**
  2306. * @internal use manual type def because public setup context type relies on
  2307. * legacy VNode types
  2308. */
  2309. function useSlots() {
  2310. return getContext().slots;
  2311. }
  2312. /**
  2313. * @internal use manual type def because public setup context type relies on
  2314. * legacy VNode types
  2315. */
  2316. function useAttrs() {
  2317. return getContext().attrs;
  2318. }
  2319. /**
  2320. * Vue 2 only
  2321. * @internal use manual type def because public setup context type relies on
  2322. * legacy VNode types
  2323. */
  2324. function useListeners() {
  2325. return getContext().listeners;
  2326. }
  2327. function getContext() {
  2328. if (!currentInstance) {
  2329. warn$2(`useContext() called without active instance.`);
  2330. }
  2331. const vm = currentInstance;
  2332. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2333. }
  2334. /**
  2335. * Runtime helper for merging default declarations. Imported by compiled code
  2336. * only.
  2337. * @internal
  2338. */
  2339. function mergeDefaults(raw, defaults) {
  2340. const props = isArray(raw)
  2341. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2342. : raw;
  2343. for (const key in defaults) {
  2344. const opt = props[key];
  2345. if (opt) {
  2346. if (isArray(opt) || isFunction(opt)) {
  2347. props[key] = { type: opt, default: defaults[key] };
  2348. }
  2349. else {
  2350. opt.default = defaults[key];
  2351. }
  2352. }
  2353. else if (opt === null) {
  2354. props[key] = { default: defaults[key] };
  2355. }
  2356. else {
  2357. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2358. }
  2359. }
  2360. return props;
  2361. }
  2362. function initRender(vm) {
  2363. vm._vnode = null; // the root of the child tree
  2364. vm._staticTrees = null; // v-once cached trees
  2365. const options = vm.$options;
  2366. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2367. const renderContext = parentVnode && parentVnode.context;
  2368. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2369. vm.$scopedSlots = parentVnode
  2370. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2371. : emptyObject;
  2372. // bind the createElement fn to this instance
  2373. // so that we get proper render context inside it.
  2374. // args order: tag, data, children, normalizationType, alwaysNormalize
  2375. // internal version is used by render functions compiled from templates
  2376. // @ts-expect-error
  2377. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2378. // normalization is always applied for the public version, used in
  2379. // user-written render functions.
  2380. // @ts-expect-error
  2381. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2382. // $attrs & $listeners are exposed for easier HOC creation.
  2383. // they need to be reactive so that HOCs using them are always updated
  2384. const parentData = parentVnode && parentVnode.data;
  2385. /* istanbul ignore else */
  2386. {
  2387. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2388. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2389. }, true);
  2390. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2391. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2392. }, true);
  2393. }
  2394. }
  2395. let currentRenderingInstance = null;
  2396. function renderMixin(Vue) {
  2397. // install runtime convenience helpers
  2398. installRenderHelpers(Vue.prototype);
  2399. Vue.prototype.$nextTick = function (fn) {
  2400. return nextTick(fn, this);
  2401. };
  2402. Vue.prototype._render = function () {
  2403. const vm = this;
  2404. const { render, _parentVnode } = vm.$options;
  2405. if (_parentVnode && vm._isMounted) {
  2406. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2407. if (vm._slotsProxy) {
  2408. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2409. }
  2410. }
  2411. // set parent vnode. this allows render functions to have access
  2412. // to the data on the placeholder node.
  2413. vm.$vnode = _parentVnode;
  2414. // render self
  2415. let vnode;
  2416. try {
  2417. // There's no need to maintain a stack because all render fns are called
  2418. // separately from one another. Nested component's render fns are called
  2419. // when parent component is patched.
  2420. setCurrentInstance(vm);
  2421. currentRenderingInstance = vm;
  2422. vnode = render.call(vm._renderProxy, vm.$createElement);
  2423. }
  2424. catch (e) {
  2425. handleError(e, vm, `render`);
  2426. // return error render result,
  2427. // or previous vnode to prevent render error causing blank component
  2428. /* istanbul ignore else */
  2429. if (vm.$options.renderError) {
  2430. try {
  2431. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2432. }
  2433. catch (e) {
  2434. handleError(e, vm, `renderError`);
  2435. vnode = vm._vnode;
  2436. }
  2437. }
  2438. else {
  2439. vnode = vm._vnode;
  2440. }
  2441. }
  2442. finally {
  2443. currentRenderingInstance = null;
  2444. setCurrentInstance();
  2445. }
  2446. // if the returned array contains only a single node, allow it
  2447. if (isArray(vnode) && vnode.length === 1) {
  2448. vnode = vnode[0];
  2449. }
  2450. // return empty vnode in case the render function errored out
  2451. if (!(vnode instanceof VNode)) {
  2452. if (isArray(vnode)) {
  2453. warn$2('Multiple root nodes returned from render function. Render function ' +
  2454. 'should return a single root node.', vm);
  2455. }
  2456. vnode = createEmptyVNode();
  2457. }
  2458. // set parent
  2459. vnode.parent = _parentVnode;
  2460. return vnode;
  2461. };
  2462. }
  2463. function ensureCtor(comp, base) {
  2464. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2465. comp = comp.default;
  2466. }
  2467. return isObject(comp) ? base.extend(comp) : comp;
  2468. }
  2469. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2470. const node = createEmptyVNode();
  2471. node.asyncFactory = factory;
  2472. node.asyncMeta = { data, context, children, tag };
  2473. return node;
  2474. }
  2475. function resolveAsyncComponent(factory, baseCtor) {
  2476. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2477. return factory.errorComp;
  2478. }
  2479. if (isDef(factory.resolved)) {
  2480. return factory.resolved;
  2481. }
  2482. const owner = currentRenderingInstance;
  2483. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2484. // already pending
  2485. factory.owners.push(owner);
  2486. }
  2487. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2488. return factory.loadingComp;
  2489. }
  2490. if (owner && !isDef(factory.owners)) {
  2491. const owners = (factory.owners = [owner]);
  2492. let sync = true;
  2493. let timerLoading = null;
  2494. let timerTimeout = null;
  2495. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2496. const forceRender = (renderCompleted) => {
  2497. for (let i = 0, l = owners.length; i < l; i++) {
  2498. owners[i].$forceUpdate();
  2499. }
  2500. if (renderCompleted) {
  2501. owners.length = 0;
  2502. if (timerLoading !== null) {
  2503. clearTimeout(timerLoading);
  2504. timerLoading = null;
  2505. }
  2506. if (timerTimeout !== null) {
  2507. clearTimeout(timerTimeout);
  2508. timerTimeout = null;
  2509. }
  2510. }
  2511. };
  2512. const resolve = once((res) => {
  2513. // cache resolved
  2514. factory.resolved = ensureCtor(res, baseCtor);
  2515. // invoke callbacks only if this is not a synchronous resolve
  2516. // (async resolves are shimmed as synchronous during SSR)
  2517. if (!sync) {
  2518. forceRender(true);
  2519. }
  2520. else {
  2521. owners.length = 0;
  2522. }
  2523. });
  2524. const reject = once(reason => {
  2525. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2526. (reason ? `\nReason: ${reason}` : ''));
  2527. if (isDef(factory.errorComp)) {
  2528. factory.error = true;
  2529. forceRender(true);
  2530. }
  2531. });
  2532. const res = factory(resolve, reject);
  2533. if (isObject(res)) {
  2534. if (isPromise(res)) {
  2535. // () => Promise
  2536. if (isUndef(factory.resolved)) {
  2537. res.then(resolve, reject);
  2538. }
  2539. }
  2540. else if (isPromise(res.component)) {
  2541. res.component.then(resolve, reject);
  2542. if (isDef(res.error)) {
  2543. factory.errorComp = ensureCtor(res.error, baseCtor);
  2544. }
  2545. if (isDef(res.loading)) {
  2546. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2547. if (res.delay === 0) {
  2548. factory.loading = true;
  2549. }
  2550. else {
  2551. // @ts-expect-error NodeJS timeout type
  2552. timerLoading = setTimeout(() => {
  2553. timerLoading = null;
  2554. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2555. factory.loading = true;
  2556. forceRender(false);
  2557. }
  2558. }, res.delay || 200);
  2559. }
  2560. }
  2561. if (isDef(res.timeout)) {
  2562. // @ts-expect-error NodeJS timeout type
  2563. timerTimeout = setTimeout(() => {
  2564. timerTimeout = null;
  2565. if (isUndef(factory.resolved)) {
  2566. reject(`timeout (${res.timeout}ms)` );
  2567. }
  2568. }, res.timeout);
  2569. }
  2570. }
  2571. }
  2572. sync = false;
  2573. // return in case resolved synchronously
  2574. return factory.loading ? factory.loadingComp : factory.resolved;
  2575. }
  2576. }
  2577. function getFirstComponentChild(children) {
  2578. if (isArray(children)) {
  2579. for (let i = 0; i < children.length; i++) {
  2580. const c = children[i];
  2581. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2582. return c;
  2583. }
  2584. }
  2585. }
  2586. }
  2587. function initEvents(vm) {
  2588. vm._events = Object.create(null);
  2589. vm._hasHookEvent = false;
  2590. // init parent attached events
  2591. const listeners = vm.$options._parentListeners;
  2592. if (listeners) {
  2593. updateComponentListeners(vm, listeners);
  2594. }
  2595. }
  2596. let target$1;
  2597. function add$1(event, fn) {
  2598. target$1.$on(event, fn);
  2599. }
  2600. function remove$1(event, fn) {
  2601. target$1.$off(event, fn);
  2602. }
  2603. function createOnceHandler$1(event, fn) {
  2604. const _target = target$1;
  2605. return function onceHandler() {
  2606. const res = fn.apply(null, arguments);
  2607. if (res !== null) {
  2608. _target.$off(event, onceHandler);
  2609. }
  2610. };
  2611. }
  2612. function updateComponentListeners(vm, listeners, oldListeners) {
  2613. target$1 = vm;
  2614. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2615. target$1 = undefined;
  2616. }
  2617. function eventsMixin(Vue) {
  2618. const hookRE = /^hook:/;
  2619. Vue.prototype.$on = function (event, fn) {
  2620. const vm = this;
  2621. if (isArray(event)) {
  2622. for (let i = 0, l = event.length; i < l; i++) {
  2623. vm.$on(event[i], fn);
  2624. }
  2625. }
  2626. else {
  2627. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2628. // optimize hook:event cost by using a boolean flag marked at registration
  2629. // instead of a hash lookup
  2630. if (hookRE.test(event)) {
  2631. vm._hasHookEvent = true;
  2632. }
  2633. }
  2634. return vm;
  2635. };
  2636. Vue.prototype.$once = function (event, fn) {
  2637. const vm = this;
  2638. function on() {
  2639. vm.$off(event, on);
  2640. fn.apply(vm, arguments);
  2641. }
  2642. on.fn = fn;
  2643. vm.$on(event, on);
  2644. return vm;
  2645. };
  2646. Vue.prototype.$off = function (event, fn) {
  2647. const vm = this;
  2648. // all
  2649. if (!arguments.length) {
  2650. vm._events = Object.create(null);
  2651. return vm;
  2652. }
  2653. // array of events
  2654. if (isArray(event)) {
  2655. for (let i = 0, l = event.length; i < l; i++) {
  2656. vm.$off(event[i], fn);
  2657. }
  2658. return vm;
  2659. }
  2660. // specific event
  2661. const cbs = vm._events[event];
  2662. if (!cbs) {
  2663. return vm;
  2664. }
  2665. if (!fn) {
  2666. vm._events[event] = null;
  2667. return vm;
  2668. }
  2669. // specific handler
  2670. let cb;
  2671. let i = cbs.length;
  2672. while (i--) {
  2673. cb = cbs[i];
  2674. if (cb === fn || cb.fn === fn) {
  2675. cbs.splice(i, 1);
  2676. break;
  2677. }
  2678. }
  2679. return vm;
  2680. };
  2681. Vue.prototype.$emit = function (event) {
  2682. const vm = this;
  2683. {
  2684. const lowerCaseEvent = event.toLowerCase();
  2685. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2686. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2687. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2688. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2689. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2690. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2691. }
  2692. }
  2693. let cbs = vm._events[event];
  2694. if (cbs) {
  2695. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2696. const args = toArray(arguments, 1);
  2697. const info = `event handler for "${event}"`;
  2698. for (let i = 0, l = cbs.length; i < l; i++) {
  2699. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2700. }
  2701. }
  2702. return vm;
  2703. };
  2704. }
  2705. let activeInstance = null;
  2706. let isUpdatingChildComponent = false;
  2707. function setActiveInstance(vm) {
  2708. const prevActiveInstance = activeInstance;
  2709. activeInstance = vm;
  2710. return () => {
  2711. activeInstance = prevActiveInstance;
  2712. };
  2713. }
  2714. function initLifecycle(vm) {
  2715. const options = vm.$options;
  2716. // locate first non-abstract parent
  2717. let parent = options.parent;
  2718. if (parent && !options.abstract) {
  2719. while (parent.$options.abstract && parent.$parent) {
  2720. parent = parent.$parent;
  2721. }
  2722. parent.$children.push(vm);
  2723. }
  2724. vm.$parent = parent;
  2725. vm.$root = parent ? parent.$root : vm;
  2726. vm.$children = [];
  2727. vm.$refs = {};
  2728. vm._provided = parent ? parent._provided : Object.create(null);
  2729. vm._watcher = null;
  2730. vm._inactive = null;
  2731. vm._directInactive = false;
  2732. vm._isMounted = false;
  2733. vm._isDestroyed = false;
  2734. vm._isBeingDestroyed = false;
  2735. }
  2736. function lifecycleMixin(Vue) {
  2737. Vue.prototype._update = function (vnode, hydrating) {
  2738. const vm = this;
  2739. const prevEl = vm.$el;
  2740. const prevVnode = vm._vnode;
  2741. const restoreActiveInstance = setActiveInstance(vm);
  2742. vm._vnode = vnode;
  2743. // Vue.prototype.__patch__ is injected in entry points
  2744. // based on the rendering backend used.
  2745. if (!prevVnode) {
  2746. // initial render
  2747. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2748. }
  2749. else {
  2750. // updates
  2751. vm.$el = vm.__patch__(prevVnode, vnode);
  2752. }
  2753. restoreActiveInstance();
  2754. // update __vue__ reference
  2755. if (prevEl) {
  2756. prevEl.__vue__ = null;
  2757. }
  2758. if (vm.$el) {
  2759. vm.$el.__vue__ = vm;
  2760. }
  2761. // if parent is an HOC, update its $el as well
  2762. let wrapper = vm;
  2763. while (wrapper &&
  2764. wrapper.$vnode &&
  2765. wrapper.$parent &&
  2766. wrapper.$vnode === wrapper.$parent._vnode) {
  2767. wrapper.$parent.$el = wrapper.$el;
  2768. wrapper = wrapper.$parent;
  2769. }
  2770. // updated hook is called by the scheduler to ensure that children are
  2771. // updated in a parent's updated hook.
  2772. };
  2773. Vue.prototype.$forceUpdate = function () {
  2774. const vm = this;
  2775. if (vm._watcher) {
  2776. vm._watcher.update();
  2777. }
  2778. };
  2779. Vue.prototype.$destroy = function () {
  2780. const vm = this;
  2781. if (vm._isBeingDestroyed) {
  2782. return;
  2783. }
  2784. callHook$1(vm, 'beforeDestroy');
  2785. vm._isBeingDestroyed = true;
  2786. // remove self from parent
  2787. const parent = vm.$parent;
  2788. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2789. remove$2(parent.$children, vm);
  2790. }
  2791. // teardown scope. this includes both the render watcher and other
  2792. // watchers created
  2793. vm._scope.stop();
  2794. // remove reference from data ob
  2795. // frozen object may not have observer.
  2796. if (vm._data.__ob__) {
  2797. vm._data.__ob__.vmCount--;
  2798. }
  2799. // call the last hook...
  2800. vm._isDestroyed = true;
  2801. // invoke destroy hooks on current rendered tree
  2802. vm.__patch__(vm._vnode, null);
  2803. // fire destroyed hook
  2804. callHook$1(vm, 'destroyed');
  2805. // turn off all instance listeners.
  2806. vm.$off();
  2807. // remove __vue__ reference
  2808. if (vm.$el) {
  2809. vm.$el.__vue__ = null;
  2810. }
  2811. // release circular reference (#6759)
  2812. if (vm.$vnode) {
  2813. vm.$vnode.parent = null;
  2814. }
  2815. };
  2816. }
  2817. function mountComponent(vm, el, hydrating) {
  2818. vm.$el = el;
  2819. if (!vm.$options.render) {
  2820. // @ts-expect-error invalid type
  2821. vm.$options.render = createEmptyVNode;
  2822. {
  2823. /* istanbul ignore if */
  2824. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2825. vm.$options.el ||
  2826. el) {
  2827. warn$2('You are using the runtime-only build of Vue where the template ' +
  2828. 'compiler is not available. Either pre-compile the templates into ' +
  2829. 'render functions, or use the compiler-included build.', vm);
  2830. }
  2831. else {
  2832. warn$2('Failed to mount component: template or render function not defined.', vm);
  2833. }
  2834. }
  2835. }
  2836. callHook$1(vm, 'beforeMount');
  2837. let updateComponent;
  2838. /* istanbul ignore if */
  2839. if (config.performance && mark) {
  2840. updateComponent = () => {
  2841. const name = vm._name;
  2842. const id = vm._uid;
  2843. const startTag = `vue-perf-start:${id}`;
  2844. const endTag = `vue-perf-end:${id}`;
  2845. mark(startTag);
  2846. const vnode = vm._render();
  2847. mark(endTag);
  2848. measure(`vue ${name} render`, startTag, endTag);
  2849. mark(startTag);
  2850. vm._update(vnode, hydrating);
  2851. mark(endTag);
  2852. measure(`vue ${name} patch`, startTag, endTag);
  2853. };
  2854. }
  2855. else {
  2856. updateComponent = () => {
  2857. vm._update(vm._render(), hydrating);
  2858. };
  2859. }
  2860. const watcherOptions = {
  2861. before() {
  2862. if (vm._isMounted && !vm._isDestroyed) {
  2863. callHook$1(vm, 'beforeUpdate');
  2864. }
  2865. }
  2866. };
  2867. {
  2868. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2869. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2870. }
  2871. // we set this to vm._watcher inside the watcher's constructor
  2872. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2873. // component's mounted hook), which relies on vm._watcher being already defined
  2874. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2875. hydrating = false;
  2876. // flush buffer for flush: "pre" watchers queued in setup()
  2877. const preWatchers = vm._preWatchers;
  2878. if (preWatchers) {
  2879. for (let i = 0; i < preWatchers.length; i++) {
  2880. preWatchers[i].run();
  2881. }
  2882. }
  2883. // manually mounted instance, call mounted on self
  2884. // mounted is called for render-created child components in its inserted hook
  2885. if (vm.$vnode == null) {
  2886. vm._isMounted = true;
  2887. callHook$1(vm, 'mounted');
  2888. }
  2889. return vm;
  2890. }
  2891. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2892. {
  2893. isUpdatingChildComponent = true;
  2894. }
  2895. // determine whether component has slot children
  2896. // we need to do this before overwriting $options._renderChildren.
  2897. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2898. // dynamic slot names). Static scoped slots compiled from template has the
  2899. // "$stable" marker.
  2900. const newScopedSlots = parentVnode.data.scopedSlots;
  2901. const oldScopedSlots = vm.$scopedSlots;
  2902. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  2903. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  2904. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  2905. (!newScopedSlots && vm.$scopedSlots.$key));
  2906. // Any static slot children from the parent may have changed during parent's
  2907. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  2908. // update is necessary to ensure correctness.
  2909. let needsForceUpdate = !!(renderChildren || // has new static slots
  2910. vm.$options._renderChildren || // has old static slots
  2911. hasDynamicScopedSlot);
  2912. const prevVNode = vm.$vnode;
  2913. vm.$options._parentVnode = parentVnode;
  2914. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2915. if (vm._vnode) {
  2916. // update child tree's parent
  2917. vm._vnode.parent = parentVnode;
  2918. }
  2919. vm.$options._renderChildren = renderChildren;
  2920. // update $attrs and $listeners hash
  2921. // these are also reactive so they may trigger child update if the child
  2922. // used them during render
  2923. const attrs = parentVnode.data.attrs || emptyObject;
  2924. if (vm._attrsProxy) {
  2925. // force update if attrs are accessed and has changed since it may be
  2926. // passed to a child component.
  2927. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  2928. needsForceUpdate = true;
  2929. }
  2930. }
  2931. vm.$attrs = attrs;
  2932. // update listeners
  2933. listeners = listeners || emptyObject;
  2934. const prevListeners = vm.$options._parentListeners;
  2935. if (vm._listenersProxy) {
  2936. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  2937. }
  2938. vm.$listeners = vm.$options._parentListeners = listeners;
  2939. updateComponentListeners(vm, listeners, prevListeners);
  2940. // update props
  2941. if (propsData && vm.$options.props) {
  2942. toggleObserving(false);
  2943. const props = vm._props;
  2944. const propKeys = vm.$options._propKeys || [];
  2945. for (let i = 0; i < propKeys.length; i++) {
  2946. const key = propKeys[i];
  2947. const propOptions = vm.$options.props; // wtf flow?
  2948. props[key] = validateProp(key, propOptions, propsData, vm);
  2949. }
  2950. toggleObserving(true);
  2951. // keep a copy of raw propsData
  2952. vm.$options.propsData = propsData;
  2953. }
  2954. // resolve slots + force update if has children
  2955. if (needsForceUpdate) {
  2956. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2957. vm.$forceUpdate();
  2958. }
  2959. {
  2960. isUpdatingChildComponent = false;
  2961. }
  2962. }
  2963. function isInInactiveTree(vm) {
  2964. while (vm && (vm = vm.$parent)) {
  2965. if (vm._inactive)
  2966. return true;
  2967. }
  2968. return false;
  2969. }
  2970. function activateChildComponent(vm, direct) {
  2971. if (direct) {
  2972. vm._directInactive = false;
  2973. if (isInInactiveTree(vm)) {
  2974. return;
  2975. }
  2976. }
  2977. else if (vm._directInactive) {
  2978. return;
  2979. }
  2980. if (vm._inactive || vm._inactive === null) {
  2981. vm._inactive = false;
  2982. for (let i = 0; i < vm.$children.length; i++) {
  2983. activateChildComponent(vm.$children[i]);
  2984. }
  2985. callHook$1(vm, 'activated');
  2986. }
  2987. }
  2988. function deactivateChildComponent(vm, direct) {
  2989. if (direct) {
  2990. vm._directInactive = true;
  2991. if (isInInactiveTree(vm)) {
  2992. return;
  2993. }
  2994. }
  2995. if (!vm._inactive) {
  2996. vm._inactive = true;
  2997. for (let i = 0; i < vm.$children.length; i++) {
  2998. deactivateChildComponent(vm.$children[i]);
  2999. }
  3000. callHook$1(vm, 'deactivated');
  3001. }
  3002. }
  3003. function callHook$1(vm, hook, args, setContext = true) {
  3004. // #7573 disable dep collection when invoking lifecycle hooks
  3005. pushTarget();
  3006. const prev = currentInstance;
  3007. setContext && setCurrentInstance(vm);
  3008. const handlers = vm.$options[hook];
  3009. const info = `${hook} hook`;
  3010. if (handlers) {
  3011. for (let i = 0, j = handlers.length; i < j; i++) {
  3012. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3013. }
  3014. }
  3015. if (vm._hasHookEvent) {
  3016. vm.$emit('hook:' + hook);
  3017. }
  3018. setContext && setCurrentInstance(prev);
  3019. popTarget();
  3020. }
  3021. const MAX_UPDATE_COUNT = 100;
  3022. const queue = [];
  3023. const activatedChildren = [];
  3024. let has = {};
  3025. let circular = {};
  3026. let waiting = false;
  3027. let flushing = false;
  3028. let index$1 = 0;
  3029. /**
  3030. * Reset the scheduler's state.
  3031. */
  3032. function resetSchedulerState() {
  3033. index$1 = queue.length = activatedChildren.length = 0;
  3034. has = {};
  3035. {
  3036. circular = {};
  3037. }
  3038. waiting = flushing = false;
  3039. }
  3040. // Async edge case #6566 requires saving the timestamp when event listeners are
  3041. // attached. However, calling performance.now() has a perf overhead especially
  3042. // if the page has thousands of event listeners. Instead, we take a timestamp
  3043. // every time the scheduler flushes and use that for all event listeners
  3044. // attached during that flush.
  3045. let currentFlushTimestamp = 0;
  3046. // Async edge case fix requires storing an event listener's attach timestamp.
  3047. let getNow = Date.now;
  3048. // Determine what event timestamp the browser is using. Annoyingly, the
  3049. // timestamp can either be hi-res (relative to page load) or low-res
  3050. // (relative to UNIX epoch), so in order to compare time we have to use the
  3051. // same timestamp type when saving the flush timestamp.
  3052. // All IE versions use low-res event timestamps, and have problematic clock
  3053. // implementations (#9632)
  3054. if (inBrowser && !isIE) {
  3055. const performance = window.performance;
  3056. if (performance &&
  3057. typeof performance.now === 'function' &&
  3058. getNow() > document.createEvent('Event').timeStamp) {
  3059. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3060. // smaller than it, it means the event is using a hi-res timestamp,
  3061. // and we need to use the hi-res version for event listener timestamps as
  3062. // well.
  3063. getNow = () => performance.now();
  3064. }
  3065. }
  3066. const sortCompareFn = (a, b) => {
  3067. if (a.post) {
  3068. if (!b.post)
  3069. return 1;
  3070. }
  3071. else if (b.post) {
  3072. return -1;
  3073. }
  3074. return a.id - b.id;
  3075. };
  3076. /**
  3077. * Flush both queues and run the watchers.
  3078. */
  3079. function flushSchedulerQueue() {
  3080. currentFlushTimestamp = getNow();
  3081. flushing = true;
  3082. let watcher, id;
  3083. // Sort queue before flush.
  3084. // This ensures that:
  3085. // 1. Components are updated from parent to child. (because parent is always
  3086. // created before the child)
  3087. // 2. A component's user watchers are run before its render watcher (because
  3088. // user watchers are created before the render watcher)
  3089. // 3. If a component is destroyed during a parent component's watcher run,
  3090. // its watchers can be skipped.
  3091. queue.sort(sortCompareFn);
  3092. // do not cache length because more watchers might be pushed
  3093. // as we run existing watchers
  3094. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3095. watcher = queue[index$1];
  3096. if (watcher.before) {
  3097. watcher.before();
  3098. }
  3099. id = watcher.id;
  3100. has[id] = null;
  3101. watcher.run();
  3102. // in dev build, check and stop circular updates.
  3103. if (has[id] != null) {
  3104. circular[id] = (circular[id] || 0) + 1;
  3105. if (circular[id] > MAX_UPDATE_COUNT) {
  3106. warn$2('You may have an infinite update loop ' +
  3107. (watcher.user
  3108. ? `in watcher with expression "${watcher.expression}"`
  3109. : `in a component render function.`), watcher.vm);
  3110. break;
  3111. }
  3112. }
  3113. }
  3114. // keep copies of post queues before resetting state
  3115. const activatedQueue = activatedChildren.slice();
  3116. const updatedQueue = queue.slice();
  3117. resetSchedulerState();
  3118. // call component updated and activated hooks
  3119. callActivatedHooks(activatedQueue);
  3120. callUpdatedHooks(updatedQueue);
  3121. cleanupDeps();
  3122. // devtool hook
  3123. /* istanbul ignore if */
  3124. if (devtools && config.devtools) {
  3125. devtools.emit('flush');
  3126. }
  3127. }
  3128. function callUpdatedHooks(queue) {
  3129. let i = queue.length;
  3130. while (i--) {
  3131. const watcher = queue[i];
  3132. const vm = watcher.vm;
  3133. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3134. callHook$1(vm, 'updated');
  3135. }
  3136. }
  3137. }
  3138. /**
  3139. * Queue a kept-alive component that was activated during patch.
  3140. * The queue will be processed after the entire tree has been patched.
  3141. */
  3142. function queueActivatedComponent(vm) {
  3143. // setting _inactive to false here so that a render function can
  3144. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3145. vm._inactive = false;
  3146. activatedChildren.push(vm);
  3147. }
  3148. function callActivatedHooks(queue) {
  3149. for (let i = 0; i < queue.length; i++) {
  3150. queue[i]._inactive = true;
  3151. activateChildComponent(queue[i], true /* true */);
  3152. }
  3153. }
  3154. /**
  3155. * Push a watcher into the watcher queue.
  3156. * Jobs with duplicate IDs will be skipped unless it's
  3157. * pushed when the queue is being flushed.
  3158. */
  3159. function queueWatcher(watcher) {
  3160. const id = watcher.id;
  3161. if (has[id] != null) {
  3162. return;
  3163. }
  3164. if (watcher === Dep.target && watcher.noRecurse) {
  3165. return;
  3166. }
  3167. has[id] = true;
  3168. if (!flushing) {
  3169. queue.push(watcher);
  3170. }
  3171. else {
  3172. // if already flushing, splice the watcher based on its id
  3173. // if already past its id, it will be run next immediately.
  3174. let i = queue.length - 1;
  3175. while (i > index$1 && queue[i].id > watcher.id) {
  3176. i--;
  3177. }
  3178. queue.splice(i + 1, 0, watcher);
  3179. }
  3180. // queue the flush
  3181. if (!waiting) {
  3182. waiting = true;
  3183. if (!config.async) {
  3184. flushSchedulerQueue();
  3185. return;
  3186. }
  3187. nextTick(flushSchedulerQueue);
  3188. }
  3189. }
  3190. const WATCHER = `watcher`;
  3191. const WATCHER_CB = `${WATCHER} callback`;
  3192. const WATCHER_GETTER = `${WATCHER} getter`;
  3193. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3194. // Simple effect.
  3195. function watchEffect(effect, options) {
  3196. return doWatch(effect, null, options);
  3197. }
  3198. function watchPostEffect(effect, options) {
  3199. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3200. }
  3201. function watchSyncEffect(effect, options) {
  3202. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3203. }
  3204. // initial value for watchers to trigger on undefined initial values
  3205. const INITIAL_WATCHER_VALUE = {};
  3206. // implementation
  3207. function watch(source, cb, options) {
  3208. if (typeof cb !== 'function') {
  3209. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3210. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3211. `supports \`watch(source, cb, options?) signature.`);
  3212. }
  3213. return doWatch(source, cb, options);
  3214. }
  3215. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3216. if (!cb) {
  3217. if (immediate !== undefined) {
  3218. warn$2(`watch() "immediate" option is only respected when using the ` +
  3219. `watch(source, callback, options?) signature.`);
  3220. }
  3221. if (deep !== undefined) {
  3222. warn$2(`watch() "deep" option is only respected when using the ` +
  3223. `watch(source, callback, options?) signature.`);
  3224. }
  3225. }
  3226. const warnInvalidSource = (s) => {
  3227. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3228. `function, a ref, a reactive object, or an array of these types.`);
  3229. };
  3230. const instance = currentInstance;
  3231. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3232. let getter;
  3233. let forceTrigger = false;
  3234. let isMultiSource = false;
  3235. if (isRef(source)) {
  3236. getter = () => source.value;
  3237. forceTrigger = isShallow(source);
  3238. }
  3239. else if (isReactive(source)) {
  3240. getter = () => {
  3241. source.__ob__.dep.depend();
  3242. return source;
  3243. };
  3244. deep = true;
  3245. }
  3246. else if (isArray(source)) {
  3247. isMultiSource = true;
  3248. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3249. getter = () => source.map(s => {
  3250. if (isRef(s)) {
  3251. return s.value;
  3252. }
  3253. else if (isReactive(s)) {
  3254. return traverse(s);
  3255. }
  3256. else if (isFunction(s)) {
  3257. return call(s, WATCHER_GETTER);
  3258. }
  3259. else {
  3260. warnInvalidSource(s);
  3261. }
  3262. });
  3263. }
  3264. else if (isFunction(source)) {
  3265. if (cb) {
  3266. // getter with cb
  3267. getter = () => call(source, WATCHER_GETTER);
  3268. }
  3269. else {
  3270. // no cb -> simple effect
  3271. getter = () => {
  3272. if (instance && instance._isDestroyed) {
  3273. return;
  3274. }
  3275. if (cleanup) {
  3276. cleanup();
  3277. }
  3278. return call(source, WATCHER, [onCleanup]);
  3279. };
  3280. }
  3281. }
  3282. else {
  3283. getter = noop;
  3284. warnInvalidSource(source);
  3285. }
  3286. if (cb && deep) {
  3287. const baseGetter = getter;
  3288. getter = () => traverse(baseGetter());
  3289. }
  3290. let cleanup;
  3291. let onCleanup = (fn) => {
  3292. cleanup = watcher.onStop = () => {
  3293. call(fn, WATCHER_CLEANUP);
  3294. };
  3295. };
  3296. // in SSR there is no need to setup an actual effect, and it should be noop
  3297. // unless it's eager
  3298. if (isServerRendering()) {
  3299. // we will also not call the invalidate callback (+ runner is not set up)
  3300. onCleanup = noop;
  3301. if (!cb) {
  3302. getter();
  3303. }
  3304. else if (immediate) {
  3305. call(cb, WATCHER_CB, [
  3306. getter(),
  3307. isMultiSource ? [] : undefined,
  3308. onCleanup
  3309. ]);
  3310. }
  3311. return noop;
  3312. }
  3313. const watcher = new Watcher(currentInstance, getter, noop, {
  3314. lazy: true
  3315. });
  3316. watcher.noRecurse = !cb;
  3317. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3318. // overwrite default run
  3319. watcher.run = () => {
  3320. if (!watcher.active) {
  3321. return;
  3322. }
  3323. if (cb) {
  3324. // watch(source, cb)
  3325. const newValue = watcher.get();
  3326. if (deep ||
  3327. forceTrigger ||
  3328. (isMultiSource
  3329. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3330. : hasChanged(newValue, oldValue))) {
  3331. // cleanup before running cb again
  3332. if (cleanup) {
  3333. cleanup();
  3334. }
  3335. call(cb, WATCHER_CB, [
  3336. newValue,
  3337. // pass undefined as the old value when it's changed for the first time
  3338. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3339. onCleanup
  3340. ]);
  3341. oldValue = newValue;
  3342. }
  3343. }
  3344. else {
  3345. // watchEffect
  3346. watcher.get();
  3347. }
  3348. };
  3349. if (flush === 'sync') {
  3350. watcher.update = watcher.run;
  3351. }
  3352. else if (flush === 'post') {
  3353. watcher.post = true;
  3354. watcher.update = () => queueWatcher(watcher);
  3355. }
  3356. else {
  3357. // pre
  3358. watcher.update = () => {
  3359. if (instance && instance === currentInstance && !instance._isMounted) {
  3360. // pre-watcher triggered before
  3361. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3362. if (buffer.indexOf(watcher) < 0)
  3363. buffer.push(watcher);
  3364. }
  3365. else {
  3366. queueWatcher(watcher);
  3367. }
  3368. };
  3369. }
  3370. {
  3371. watcher.onTrack = onTrack;
  3372. watcher.onTrigger = onTrigger;
  3373. }
  3374. // initial run
  3375. if (cb) {
  3376. if (immediate) {
  3377. watcher.run();
  3378. }
  3379. else {
  3380. oldValue = watcher.get();
  3381. }
  3382. }
  3383. else if (flush === 'post' && instance) {
  3384. instance.$once('hook:mounted', () => watcher.get());
  3385. }
  3386. else {
  3387. watcher.get();
  3388. }
  3389. return () => {
  3390. watcher.teardown();
  3391. };
  3392. }
  3393. let activeEffectScope;
  3394. class EffectScope {
  3395. constructor(detached = false) {
  3396. this.detached = detached;
  3397. /**
  3398. * @internal
  3399. */
  3400. this.active = true;
  3401. /**
  3402. * @internal
  3403. */
  3404. this.effects = [];
  3405. /**
  3406. * @internal
  3407. */
  3408. this.cleanups = [];
  3409. this.parent = activeEffectScope;
  3410. if (!detached && activeEffectScope) {
  3411. this.index =
  3412. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  3413. }
  3414. }
  3415. run(fn) {
  3416. if (this.active) {
  3417. const currentEffectScope = activeEffectScope;
  3418. try {
  3419. activeEffectScope = this;
  3420. return fn();
  3421. }
  3422. finally {
  3423. activeEffectScope = currentEffectScope;
  3424. }
  3425. }
  3426. else {
  3427. warn$2(`cannot run an inactive effect scope.`);
  3428. }
  3429. }
  3430. /**
  3431. * This should only be called on non-detached scopes
  3432. * @internal
  3433. */
  3434. on() {
  3435. activeEffectScope = this;
  3436. }
  3437. /**
  3438. * This should only be called on non-detached scopes
  3439. * @internal
  3440. */
  3441. off() {
  3442. activeEffectScope = this.parent;
  3443. }
  3444. stop(fromParent) {
  3445. if (this.active) {
  3446. let i, l;
  3447. for (i = 0, l = this.effects.length; i < l; i++) {
  3448. this.effects[i].teardown();
  3449. }
  3450. for (i = 0, l = this.cleanups.length; i < l; i++) {
  3451. this.cleanups[i]();
  3452. }
  3453. if (this.scopes) {
  3454. for (i = 0, l = this.scopes.length; i < l; i++) {
  3455. this.scopes[i].stop(true);
  3456. }
  3457. }
  3458. // nested scope, dereference from parent to avoid memory leaks
  3459. if (!this.detached && this.parent && !fromParent) {
  3460. // optimized O(1) removal
  3461. const last = this.parent.scopes.pop();
  3462. if (last && last !== this) {
  3463. this.parent.scopes[this.index] = last;
  3464. last.index = this.index;
  3465. }
  3466. }
  3467. this.parent = undefined;
  3468. this.active = false;
  3469. }
  3470. }
  3471. }
  3472. function effectScope(detached) {
  3473. return new EffectScope(detached);
  3474. }
  3475. /**
  3476. * @internal
  3477. */
  3478. function recordEffectScope(effect, scope = activeEffectScope) {
  3479. if (scope && scope.active) {
  3480. scope.effects.push(effect);
  3481. }
  3482. }
  3483. function getCurrentScope() {
  3484. return activeEffectScope;
  3485. }
  3486. function onScopeDispose(fn) {
  3487. if (activeEffectScope) {
  3488. activeEffectScope.cleanups.push(fn);
  3489. }
  3490. else {
  3491. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  3492. ` to be associated with.`);
  3493. }
  3494. }
  3495. function provide(key, value) {
  3496. if (!currentInstance) {
  3497. {
  3498. warn$2(`provide() can only be used inside setup().`);
  3499. }
  3500. }
  3501. else {
  3502. // TS doesn't allow symbol as index type
  3503. resolveProvided(currentInstance)[key] = value;
  3504. }
  3505. }
  3506. function resolveProvided(vm) {
  3507. // by default an instance inherits its parent's provides object
  3508. // but when it needs to provide values of its own, it creates its
  3509. // own provides object using parent provides object as prototype.
  3510. // this way in `inject` we can simply look up injections from direct
  3511. // parent and let the prototype chain do the work.
  3512. const existing = vm._provided;
  3513. const parentProvides = vm.$parent && vm.$parent._provided;
  3514. if (parentProvides === existing) {
  3515. return (vm._provided = Object.create(parentProvides));
  3516. }
  3517. else {
  3518. return existing;
  3519. }
  3520. }
  3521. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3522. // fallback to `currentRenderingInstance` so that this can be called in
  3523. // a functional component
  3524. const instance = currentInstance;
  3525. if (instance) {
  3526. // #2400
  3527. // to support `app.use` plugins,
  3528. // fallback to appContext's `provides` if the instance is at root
  3529. const provides = instance.$parent && instance.$parent._provided;
  3530. if (provides && key in provides) {
  3531. // TS doesn't allow symbol as index type
  3532. return provides[key];
  3533. }
  3534. else if (arguments.length > 1) {
  3535. return treatDefaultAsFactory && isFunction(defaultValue)
  3536. ? defaultValue.call(instance)
  3537. : defaultValue;
  3538. }
  3539. else {
  3540. warn$2(`injection "${String(key)}" not found.`);
  3541. }
  3542. }
  3543. else {
  3544. warn$2(`inject() can only be used inside setup() or functional components.`);
  3545. }
  3546. }
  3547. /**
  3548. * @internal this function needs manual public type declaration because it relies
  3549. * on previously manually authored types from Vue 2
  3550. */
  3551. function h(type, props, children) {
  3552. if (!currentInstance) {
  3553. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3554. `component instance, e.g. synchronously in a component's render or setup function.`);
  3555. }
  3556. return createElement$1(currentInstance, type, props, children, 2, true);
  3557. }
  3558. function handleError(err, vm, info) {
  3559. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3560. // See: https://github.com/vuejs/vuex/issues/1505
  3561. pushTarget();
  3562. try {
  3563. if (vm) {
  3564. let cur = vm;
  3565. while ((cur = cur.$parent)) {
  3566. const hooks = cur.$options.errorCaptured;
  3567. if (hooks) {
  3568. for (let i = 0; i < hooks.length; i++) {
  3569. try {
  3570. const capture = hooks[i].call(cur, err, vm, info) === false;
  3571. if (capture)
  3572. return;
  3573. }
  3574. catch (e) {
  3575. globalHandleError(e, cur, 'errorCaptured hook');
  3576. }
  3577. }
  3578. }
  3579. }
  3580. }
  3581. globalHandleError(err, vm, info);
  3582. }
  3583. finally {
  3584. popTarget();
  3585. }
  3586. }
  3587. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3588. let res;
  3589. try {
  3590. res = args ? handler.apply(context, args) : handler.call(context);
  3591. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3592. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3593. res._handled = true;
  3594. }
  3595. }
  3596. catch (e) {
  3597. handleError(e, vm, info);
  3598. }
  3599. return res;
  3600. }
  3601. function globalHandleError(err, vm, info) {
  3602. if (config.errorHandler) {
  3603. try {
  3604. return config.errorHandler.call(null, err, vm, info);
  3605. }
  3606. catch (e) {
  3607. // if the user intentionally throws the original error in the handler,
  3608. // do not log it twice
  3609. if (e !== err) {
  3610. logError(e, null, 'config.errorHandler');
  3611. }
  3612. }
  3613. }
  3614. logError(err, vm, info);
  3615. }
  3616. function logError(err, vm, info) {
  3617. {
  3618. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3619. }
  3620. /* istanbul ignore else */
  3621. if (inBrowser && typeof console !== 'undefined') {
  3622. console.error(err);
  3623. }
  3624. else {
  3625. throw err;
  3626. }
  3627. }
  3628. /* globals MutationObserver */
  3629. let isUsingMicroTask = false;
  3630. const callbacks = [];
  3631. let pending = false;
  3632. function flushCallbacks() {
  3633. pending = false;
  3634. const copies = callbacks.slice(0);
  3635. callbacks.length = 0;
  3636. for (let i = 0; i < copies.length; i++) {
  3637. copies[i]();
  3638. }
  3639. }
  3640. // Here we have async deferring wrappers using microtasks.
  3641. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3642. // However, it has subtle problems when state is changed right before repaint
  3643. // (e.g. #6813, out-in transitions).
  3644. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3645. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3646. // So we now use microtasks everywhere, again.
  3647. // A major drawback of this tradeoff is that there are some scenarios
  3648. // where microtasks have too high a priority and fire in between supposedly
  3649. // sequential events (e.g. #4521, #6690, which have workarounds)
  3650. // or even between bubbling of the same event (#6566).
  3651. let timerFunc;
  3652. // The nextTick behavior leverages the microtask queue, which can be accessed
  3653. // via either native Promise.then or MutationObserver.
  3654. // MutationObserver has wider support, however it is seriously bugged in
  3655. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3656. // completely stops working after triggering a few times... so, if native
  3657. // Promise is available, we will use it:
  3658. /* istanbul ignore next, $flow-disable-line */
  3659. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3660. const p = Promise.resolve();
  3661. timerFunc = () => {
  3662. p.then(flushCallbacks);
  3663. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3664. // it can get stuck in a weird state where callbacks are pushed into the
  3665. // microtask queue but the queue isn't being flushed, until the browser
  3666. // needs to do some other work, e.g. handle a timer. Therefore we can
  3667. // "force" the microtask queue to be flushed by adding an empty timer.
  3668. if (isIOS)
  3669. setTimeout(noop);
  3670. };
  3671. isUsingMicroTask = true;
  3672. }
  3673. else if (!isIE &&
  3674. typeof MutationObserver !== 'undefined' &&
  3675. (isNative(MutationObserver) ||
  3676. // PhantomJS and iOS 7.x
  3677. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3678. // Use MutationObserver where native Promise is not available,
  3679. // e.g. PhantomJS, iOS7, Android 4.4
  3680. // (#6466 MutationObserver is unreliable in IE11)
  3681. let counter = 1;
  3682. const observer = new MutationObserver(flushCallbacks);
  3683. const textNode = document.createTextNode(String(counter));
  3684. observer.observe(textNode, {
  3685. characterData: true
  3686. });
  3687. timerFunc = () => {
  3688. counter = (counter + 1) % 2;
  3689. textNode.data = String(counter);
  3690. };
  3691. isUsingMicroTask = true;
  3692. }
  3693. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3694. // Fallback to setImmediate.
  3695. // Technically it leverages the (macro) task queue,
  3696. // but it is still a better choice than setTimeout.
  3697. timerFunc = () => {
  3698. setImmediate(flushCallbacks);
  3699. };
  3700. }
  3701. else {
  3702. // Fallback to setTimeout.
  3703. timerFunc = () => {
  3704. setTimeout(flushCallbacks, 0);
  3705. };
  3706. }
  3707. /**
  3708. * @internal
  3709. */
  3710. function nextTick(cb, ctx) {
  3711. let _resolve;
  3712. callbacks.push(() => {
  3713. if (cb) {
  3714. try {
  3715. cb.call(ctx);
  3716. }
  3717. catch (e) {
  3718. handleError(e, ctx, 'nextTick');
  3719. }
  3720. }
  3721. else if (_resolve) {
  3722. _resolve(ctx);
  3723. }
  3724. });
  3725. if (!pending) {
  3726. pending = true;
  3727. timerFunc();
  3728. }
  3729. // $flow-disable-line
  3730. if (!cb && typeof Promise !== 'undefined') {
  3731. return new Promise(resolve => {
  3732. _resolve = resolve;
  3733. });
  3734. }
  3735. }
  3736. function useCssModule(name = '$style') {
  3737. /* istanbul ignore else */
  3738. {
  3739. if (!currentInstance) {
  3740. warn$2(`useCssModule must be called inside setup()`);
  3741. return emptyObject;
  3742. }
  3743. const mod = currentInstance[name];
  3744. if (!mod) {
  3745. warn$2(`Current instance does not have CSS module named "${name}".`);
  3746. return emptyObject;
  3747. }
  3748. return mod;
  3749. }
  3750. }
  3751. /**
  3752. * Runtime helper for SFC's CSS variable injection feature.
  3753. * @private
  3754. */
  3755. function useCssVars(getter) {
  3756. if (!inBrowser && !false)
  3757. return;
  3758. const instance = currentInstance;
  3759. if (!instance) {
  3760. warn$2(`useCssVars is called without current active component instance.`);
  3761. return;
  3762. }
  3763. watchPostEffect(() => {
  3764. const el = instance.$el;
  3765. const vars = getter(instance, instance._setupProxy);
  3766. if (el && el.nodeType === 1) {
  3767. const style = el.style;
  3768. for (const key in vars) {
  3769. style.setProperty(`--${key}`, vars[key]);
  3770. }
  3771. }
  3772. });
  3773. }
  3774. /**
  3775. * v3-compatible async component API.
  3776. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3777. * because it relies on existing manual types
  3778. */
  3779. function defineAsyncComponent(source) {
  3780. if (isFunction(source)) {
  3781. source = { loader: source };
  3782. }
  3783. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3784. suspensible = false, // in Vue 3 default is true
  3785. onError: userOnError } = source;
  3786. if (suspensible) {
  3787. warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3788. }
  3789. let pendingRequest = null;
  3790. let retries = 0;
  3791. const retry = () => {
  3792. retries++;
  3793. pendingRequest = null;
  3794. return load();
  3795. };
  3796. const load = () => {
  3797. let thisRequest;
  3798. return (pendingRequest ||
  3799. (thisRequest = pendingRequest =
  3800. loader()
  3801. .catch(err => {
  3802. err = err instanceof Error ? err : new Error(String(err));
  3803. if (userOnError) {
  3804. return new Promise((resolve, reject) => {
  3805. const userRetry = () => resolve(retry());
  3806. const userFail = () => reject(err);
  3807. userOnError(err, userRetry, userFail, retries + 1);
  3808. });
  3809. }
  3810. else {
  3811. throw err;
  3812. }
  3813. })
  3814. .then((comp) => {
  3815. if (thisRequest !== pendingRequest && pendingRequest) {
  3816. return pendingRequest;
  3817. }
  3818. if (!comp) {
  3819. warn$2(`Async component loader resolved to undefined. ` +
  3820. `If you are using retry(), make sure to return its return value.`);
  3821. }
  3822. // interop module default
  3823. if (comp &&
  3824. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3825. comp = comp.default;
  3826. }
  3827. if (comp && !isObject(comp) && !isFunction(comp)) {
  3828. throw new Error(`Invalid async component load result: ${comp}`);
  3829. }
  3830. return comp;
  3831. })));
  3832. };
  3833. return () => {
  3834. const component = load();
  3835. return {
  3836. component,
  3837. delay,
  3838. timeout,
  3839. error: errorComponent,
  3840. loading: loadingComponent
  3841. };
  3842. };
  3843. }
  3844. function createLifeCycle(hookName) {
  3845. return (fn, target = currentInstance) => {
  3846. if (!target) {
  3847. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3848. `associated with. ` +
  3849. `Lifecycle injection APIs can only be used during execution of setup().`);
  3850. return;
  3851. }
  3852. return injectHook(target, hookName, fn);
  3853. };
  3854. }
  3855. function formatName(name) {
  3856. if (name === 'beforeDestroy') {
  3857. name = 'beforeUnmount';
  3858. }
  3859. else if (name === 'destroyed') {
  3860. name = 'unmounted';
  3861. }
  3862. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3863. }
  3864. function injectHook(instance, hookName, fn) {
  3865. const options = instance.$options;
  3866. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3867. }
  3868. const onBeforeMount = createLifeCycle('beforeMount');
  3869. const onMounted = createLifeCycle('mounted');
  3870. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3871. const onUpdated = createLifeCycle('updated');
  3872. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3873. const onUnmounted = createLifeCycle('destroyed');
  3874. const onActivated = createLifeCycle('activated');
  3875. const onDeactivated = createLifeCycle('deactivated');
  3876. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3877. const onRenderTracked = createLifeCycle('renderTracked');
  3878. const onRenderTriggered = createLifeCycle('renderTriggered');
  3879. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3880. function onErrorCaptured(hook, target = currentInstance) {
  3881. injectErrorCapturedHook(hook, target);
  3882. }
  3883. /**
  3884. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3885. */
  3886. const version = '2.7.14';
  3887. /**
  3888. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3889. */
  3890. function defineComponent(options) {
  3891. return options;
  3892. }
  3893. var vca = /*#__PURE__*/Object.freeze({
  3894. __proto__: null,
  3895. version: version,
  3896. defineComponent: defineComponent,
  3897. ref: ref$1,
  3898. shallowRef: shallowRef,
  3899. isRef: isRef,
  3900. toRef: toRef,
  3901. toRefs: toRefs,
  3902. unref: unref,
  3903. proxyRefs: proxyRefs,
  3904. customRef: customRef,
  3905. triggerRef: triggerRef,
  3906. reactive: reactive,
  3907. isReactive: isReactive,
  3908. isReadonly: isReadonly,
  3909. isShallow: isShallow,
  3910. isProxy: isProxy,
  3911. shallowReactive: shallowReactive,
  3912. markRaw: markRaw,
  3913. toRaw: toRaw,
  3914. readonly: readonly,
  3915. shallowReadonly: shallowReadonly,
  3916. computed: computed,
  3917. watch: watch,
  3918. watchEffect: watchEffect,
  3919. watchPostEffect: watchPostEffect,
  3920. watchSyncEffect: watchSyncEffect,
  3921. EffectScope: EffectScope,
  3922. effectScope: effectScope,
  3923. onScopeDispose: onScopeDispose,
  3924. getCurrentScope: getCurrentScope,
  3925. provide: provide,
  3926. inject: inject,
  3927. h: h,
  3928. getCurrentInstance: getCurrentInstance,
  3929. useSlots: useSlots,
  3930. useAttrs: useAttrs,
  3931. useListeners: useListeners,
  3932. mergeDefaults: mergeDefaults,
  3933. nextTick: nextTick,
  3934. set: set,
  3935. del: del,
  3936. useCssModule: useCssModule,
  3937. useCssVars: useCssVars,
  3938. defineAsyncComponent: defineAsyncComponent,
  3939. onBeforeMount: onBeforeMount,
  3940. onMounted: onMounted,
  3941. onBeforeUpdate: onBeforeUpdate,
  3942. onUpdated: onUpdated,
  3943. onBeforeUnmount: onBeforeUnmount,
  3944. onUnmounted: onUnmounted,
  3945. onActivated: onActivated,
  3946. onDeactivated: onDeactivated,
  3947. onServerPrefetch: onServerPrefetch,
  3948. onRenderTracked: onRenderTracked,
  3949. onRenderTriggered: onRenderTriggered,
  3950. onErrorCaptured: onErrorCaptured
  3951. });
  3952. const seenObjects = new _Set();
  3953. /**
  3954. * Recursively traverse an object to evoke all converted
  3955. * getters, so that every nested property inside the object
  3956. * is collected as a "deep" dependency.
  3957. */
  3958. function traverse(val) {
  3959. _traverse(val, seenObjects);
  3960. seenObjects.clear();
  3961. return val;
  3962. }
  3963. function _traverse(val, seen) {
  3964. let i, keys;
  3965. const isA = isArray(val);
  3966. if ((!isA && !isObject(val)) ||
  3967. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3968. Object.isFrozen(val) ||
  3969. val instanceof VNode) {
  3970. return;
  3971. }
  3972. if (val.__ob__) {
  3973. const depId = val.__ob__.dep.id;
  3974. if (seen.has(depId)) {
  3975. return;
  3976. }
  3977. seen.add(depId);
  3978. }
  3979. if (isA) {
  3980. i = val.length;
  3981. while (i--)
  3982. _traverse(val[i], seen);
  3983. }
  3984. else if (isRef(val)) {
  3985. _traverse(val.value, seen);
  3986. }
  3987. else {
  3988. keys = Object.keys(val);
  3989. i = keys.length;
  3990. while (i--)
  3991. _traverse(val[keys[i]], seen);
  3992. }
  3993. }
  3994. let uid$1 = 0;
  3995. /**
  3996. * A watcher parses an expression, collects dependencies,
  3997. * and fires callback when the expression value changes.
  3998. * This is used for both the $watch() api and directives.
  3999. * @internal
  4000. */
  4001. class Watcher {
  4002. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  4003. recordEffectScope(this,
  4004. // if the active effect scope is manually created (not a component scope),
  4005. // prioritize it
  4006. activeEffectScope && !activeEffectScope._vm
  4007. ? activeEffectScope
  4008. : vm
  4009. ? vm._scope
  4010. : undefined);
  4011. if ((this.vm = vm) && isRenderWatcher) {
  4012. vm._watcher = this;
  4013. }
  4014. // options
  4015. if (options) {
  4016. this.deep = !!options.deep;
  4017. this.user = !!options.user;
  4018. this.lazy = !!options.lazy;
  4019. this.sync = !!options.sync;
  4020. this.before = options.before;
  4021. {
  4022. this.onTrack = options.onTrack;
  4023. this.onTrigger = options.onTrigger;
  4024. }
  4025. }
  4026. else {
  4027. this.deep = this.user = this.lazy = this.sync = false;
  4028. }
  4029. this.cb = cb;
  4030. this.id = ++uid$1; // uid for batching
  4031. this.active = true;
  4032. this.post = false;
  4033. this.dirty = this.lazy; // for lazy watchers
  4034. this.deps = [];
  4035. this.newDeps = [];
  4036. this.depIds = new _Set();
  4037. this.newDepIds = new _Set();
  4038. this.expression = expOrFn.toString() ;
  4039. // parse expression for getter
  4040. if (isFunction(expOrFn)) {
  4041. this.getter = expOrFn;
  4042. }
  4043. else {
  4044. this.getter = parsePath(expOrFn);
  4045. if (!this.getter) {
  4046. this.getter = noop;
  4047. warn$2(`Failed watching path: "${expOrFn}" ` +
  4048. 'Watcher only accepts simple dot-delimited paths. ' +
  4049. 'For full control, use a function instead.', vm);
  4050. }
  4051. }
  4052. this.value = this.lazy ? undefined : this.get();
  4053. }
  4054. /**
  4055. * Evaluate the getter, and re-collect dependencies.
  4056. */
  4057. get() {
  4058. pushTarget(this);
  4059. let value;
  4060. const vm = this.vm;
  4061. try {
  4062. value = this.getter.call(vm, vm);
  4063. }
  4064. catch (e) {
  4065. if (this.user) {
  4066. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4067. }
  4068. else {
  4069. throw e;
  4070. }
  4071. }
  4072. finally {
  4073. // "touch" every property so they are all tracked as
  4074. // dependencies for deep watching
  4075. if (this.deep) {
  4076. traverse(value);
  4077. }
  4078. popTarget();
  4079. this.cleanupDeps();
  4080. }
  4081. return value;
  4082. }
  4083. /**
  4084. * Add a dependency to this directive.
  4085. */
  4086. addDep(dep) {
  4087. const id = dep.id;
  4088. if (!this.newDepIds.has(id)) {
  4089. this.newDepIds.add(id);
  4090. this.newDeps.push(dep);
  4091. if (!this.depIds.has(id)) {
  4092. dep.addSub(this);
  4093. }
  4094. }
  4095. }
  4096. /**
  4097. * Clean up for dependency collection.
  4098. */
  4099. cleanupDeps() {
  4100. let i = this.deps.length;
  4101. while (i--) {
  4102. const dep = this.deps[i];
  4103. if (!this.newDepIds.has(dep.id)) {
  4104. dep.removeSub(this);
  4105. }
  4106. }
  4107. let tmp = this.depIds;
  4108. this.depIds = this.newDepIds;
  4109. this.newDepIds = tmp;
  4110. this.newDepIds.clear();
  4111. tmp = this.deps;
  4112. this.deps = this.newDeps;
  4113. this.newDeps = tmp;
  4114. this.newDeps.length = 0;
  4115. }
  4116. /**
  4117. * Subscriber interface.
  4118. * Will be called when a dependency changes.
  4119. */
  4120. update() {
  4121. /* istanbul ignore else */
  4122. if (this.lazy) {
  4123. this.dirty = true;
  4124. }
  4125. else if (this.sync) {
  4126. this.run();
  4127. }
  4128. else {
  4129. queueWatcher(this);
  4130. }
  4131. }
  4132. /**
  4133. * Scheduler job interface.
  4134. * Will be called by the scheduler.
  4135. */
  4136. run() {
  4137. if (this.active) {
  4138. const value = this.get();
  4139. if (value !== this.value ||
  4140. // Deep watchers and watchers on Object/Arrays should fire even
  4141. // when the value is the same, because the value may
  4142. // have mutated.
  4143. isObject(value) ||
  4144. this.deep) {
  4145. // set new value
  4146. const oldValue = this.value;
  4147. this.value = value;
  4148. if (this.user) {
  4149. const info = `callback for watcher "${this.expression}"`;
  4150. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4151. }
  4152. else {
  4153. this.cb.call(this.vm, value, oldValue);
  4154. }
  4155. }
  4156. }
  4157. }
  4158. /**
  4159. * Evaluate the value of the watcher.
  4160. * This only gets called for lazy watchers.
  4161. */
  4162. evaluate() {
  4163. this.value = this.get();
  4164. this.dirty = false;
  4165. }
  4166. /**
  4167. * Depend on all deps collected by this watcher.
  4168. */
  4169. depend() {
  4170. let i = this.deps.length;
  4171. while (i--) {
  4172. this.deps[i].depend();
  4173. }
  4174. }
  4175. /**
  4176. * Remove self from all dependencies' subscriber list.
  4177. */
  4178. teardown() {
  4179. if (this.vm && !this.vm._isBeingDestroyed) {
  4180. remove$2(this.vm._scope.effects, this);
  4181. }
  4182. if (this.active) {
  4183. let i = this.deps.length;
  4184. while (i--) {
  4185. this.deps[i].removeSub(this);
  4186. }
  4187. this.active = false;
  4188. if (this.onStop) {
  4189. this.onStop();
  4190. }
  4191. }
  4192. }
  4193. }
  4194. const sharedPropertyDefinition = {
  4195. enumerable: true,
  4196. configurable: true,
  4197. get: noop,
  4198. set: noop
  4199. };
  4200. function proxy(target, sourceKey, key) {
  4201. sharedPropertyDefinition.get = function proxyGetter() {
  4202. return this[sourceKey][key];
  4203. };
  4204. sharedPropertyDefinition.set = function proxySetter(val) {
  4205. this[sourceKey][key] = val;
  4206. };
  4207. Object.defineProperty(target, key, sharedPropertyDefinition);
  4208. }
  4209. function initState(vm) {
  4210. const opts = vm.$options;
  4211. if (opts.props)
  4212. initProps$1(vm, opts.props);
  4213. // Composition API
  4214. initSetup(vm);
  4215. if (opts.methods)
  4216. initMethods(vm, opts.methods);
  4217. if (opts.data) {
  4218. initData(vm);
  4219. }
  4220. else {
  4221. const ob = observe((vm._data = {}));
  4222. ob && ob.vmCount++;
  4223. }
  4224. if (opts.computed)
  4225. initComputed$1(vm, opts.computed);
  4226. if (opts.watch && opts.watch !== nativeWatch) {
  4227. initWatch(vm, opts.watch);
  4228. }
  4229. }
  4230. function initProps$1(vm, propsOptions) {
  4231. const propsData = vm.$options.propsData || {};
  4232. const props = (vm._props = shallowReactive({}));
  4233. // cache prop keys so that future props updates can iterate using Array
  4234. // instead of dynamic object key enumeration.
  4235. const keys = (vm.$options._propKeys = []);
  4236. const isRoot = !vm.$parent;
  4237. // root instance props should be converted
  4238. if (!isRoot) {
  4239. toggleObserving(false);
  4240. }
  4241. for (const key in propsOptions) {
  4242. keys.push(key);
  4243. const value = validateProp(key, propsOptions, propsData, vm);
  4244. /* istanbul ignore else */
  4245. {
  4246. const hyphenatedKey = hyphenate(key);
  4247. if (isReservedAttribute(hyphenatedKey) ||
  4248. config.isReservedAttr(hyphenatedKey)) {
  4249. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4250. }
  4251. defineReactive(props, key, value, () => {
  4252. if (!isRoot && !isUpdatingChildComponent) {
  4253. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4254. `overwritten whenever the parent component re-renders. ` +
  4255. `Instead, use a data or computed property based on the prop's ` +
  4256. `value. Prop being mutated: "${key}"`, vm);
  4257. }
  4258. });
  4259. }
  4260. // static props are already proxied on the component's prototype
  4261. // during Vue.extend(). We only need to proxy props defined at
  4262. // instantiation here.
  4263. if (!(key in vm)) {
  4264. proxy(vm, `_props`, key);
  4265. }
  4266. }
  4267. toggleObserving(true);
  4268. }
  4269. function initData(vm) {
  4270. let data = vm.$options.data;
  4271. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4272. if (!isPlainObject(data)) {
  4273. data = {};
  4274. warn$2('data functions should return an object:\n' +
  4275. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4276. }
  4277. // proxy data on instance
  4278. const keys = Object.keys(data);
  4279. const props = vm.$options.props;
  4280. const methods = vm.$options.methods;
  4281. let i = keys.length;
  4282. while (i--) {
  4283. const key = keys[i];
  4284. {
  4285. if (methods && hasOwn(methods, key)) {
  4286. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4287. }
  4288. }
  4289. if (props && hasOwn(props, key)) {
  4290. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4291. `Use prop default value instead.`, vm);
  4292. }
  4293. else if (!isReserved(key)) {
  4294. proxy(vm, `_data`, key);
  4295. }
  4296. }
  4297. // observe data
  4298. const ob = observe(data);
  4299. ob && ob.vmCount++;
  4300. }
  4301. function getData(data, vm) {
  4302. // #7573 disable dep collection when invoking data getters
  4303. pushTarget();
  4304. try {
  4305. return data.call(vm, vm);
  4306. }
  4307. catch (e) {
  4308. handleError(e, vm, `data()`);
  4309. return {};
  4310. }
  4311. finally {
  4312. popTarget();
  4313. }
  4314. }
  4315. const computedWatcherOptions = { lazy: true };
  4316. function initComputed$1(vm, computed) {
  4317. // $flow-disable-line
  4318. const watchers = (vm._computedWatchers = Object.create(null));
  4319. // computed properties are just getters during SSR
  4320. const isSSR = isServerRendering();
  4321. for (const key in computed) {
  4322. const userDef = computed[key];
  4323. const getter = isFunction(userDef) ? userDef : userDef.get;
  4324. if (getter == null) {
  4325. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4326. }
  4327. if (!isSSR) {
  4328. // create internal watcher for the computed property.
  4329. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4330. }
  4331. // component-defined computed properties are already defined on the
  4332. // component prototype. We only need to define computed properties defined
  4333. // at instantiation here.
  4334. if (!(key in vm)) {
  4335. defineComputed(vm, key, userDef);
  4336. }
  4337. else {
  4338. if (key in vm.$data) {
  4339. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4340. }
  4341. else if (vm.$options.props && key in vm.$options.props) {
  4342. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4343. }
  4344. else if (vm.$options.methods && key in vm.$options.methods) {
  4345. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4346. }
  4347. }
  4348. }
  4349. }
  4350. function defineComputed(target, key, userDef) {
  4351. const shouldCache = !isServerRendering();
  4352. if (isFunction(userDef)) {
  4353. sharedPropertyDefinition.get = shouldCache
  4354. ? createComputedGetter(key)
  4355. : createGetterInvoker(userDef);
  4356. sharedPropertyDefinition.set = noop;
  4357. }
  4358. else {
  4359. sharedPropertyDefinition.get = userDef.get
  4360. ? shouldCache && userDef.cache !== false
  4361. ? createComputedGetter(key)
  4362. : createGetterInvoker(userDef.get)
  4363. : noop;
  4364. sharedPropertyDefinition.set = userDef.set || noop;
  4365. }
  4366. if (sharedPropertyDefinition.set === noop) {
  4367. sharedPropertyDefinition.set = function () {
  4368. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4369. };
  4370. }
  4371. Object.defineProperty(target, key, sharedPropertyDefinition);
  4372. }
  4373. function createComputedGetter(key) {
  4374. return function computedGetter() {
  4375. const watcher = this._computedWatchers && this._computedWatchers[key];
  4376. if (watcher) {
  4377. if (watcher.dirty) {
  4378. watcher.evaluate();
  4379. }
  4380. if (Dep.target) {
  4381. if (Dep.target.onTrack) {
  4382. Dep.target.onTrack({
  4383. effect: Dep.target,
  4384. target: this,
  4385. type: "get" /* TrackOpTypes.GET */,
  4386. key
  4387. });
  4388. }
  4389. watcher.depend();
  4390. }
  4391. return watcher.value;
  4392. }
  4393. };
  4394. }
  4395. function createGetterInvoker(fn) {
  4396. return function computedGetter() {
  4397. return fn.call(this, this);
  4398. };
  4399. }
  4400. function initMethods(vm, methods) {
  4401. const props = vm.$options.props;
  4402. for (const key in methods) {
  4403. {
  4404. if (typeof methods[key] !== 'function') {
  4405. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4406. `Did you reference the function correctly?`, vm);
  4407. }
  4408. if (props && hasOwn(props, key)) {
  4409. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4410. }
  4411. if (key in vm && isReserved(key)) {
  4412. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4413. `Avoid defining component methods that start with _ or $.`);
  4414. }
  4415. }
  4416. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4417. }
  4418. }
  4419. function initWatch(vm, watch) {
  4420. for (const key in watch) {
  4421. const handler = watch[key];
  4422. if (isArray(handler)) {
  4423. for (let i = 0; i < handler.length; i++) {
  4424. createWatcher(vm, key, handler[i]);
  4425. }
  4426. }
  4427. else {
  4428. createWatcher(vm, key, handler);
  4429. }
  4430. }
  4431. }
  4432. function createWatcher(vm, expOrFn, handler, options) {
  4433. if (isPlainObject(handler)) {
  4434. options = handler;
  4435. handler = handler.handler;
  4436. }
  4437. if (typeof handler === 'string') {
  4438. handler = vm[handler];
  4439. }
  4440. return vm.$watch(expOrFn, handler, options);
  4441. }
  4442. function stateMixin(Vue) {
  4443. // flow somehow has problems with directly declared definition object
  4444. // when using Object.defineProperty, so we have to procedurally build up
  4445. // the object here.
  4446. const dataDef = {};
  4447. dataDef.get = function () {
  4448. return this._data;
  4449. };
  4450. const propsDef = {};
  4451. propsDef.get = function () {
  4452. return this._props;
  4453. };
  4454. {
  4455. dataDef.set = function () {
  4456. warn$2('Avoid replacing instance root $data. ' +
  4457. 'Use nested data properties instead.', this);
  4458. };
  4459. propsDef.set = function () {
  4460. warn$2(`$props is readonly.`, this);
  4461. };
  4462. }
  4463. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4464. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4465. Vue.prototype.$set = set;
  4466. Vue.prototype.$delete = del;
  4467. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4468. const vm = this;
  4469. if (isPlainObject(cb)) {
  4470. return createWatcher(vm, expOrFn, cb, options);
  4471. }
  4472. options = options || {};
  4473. options.user = true;
  4474. const watcher = new Watcher(vm, expOrFn, cb, options);
  4475. if (options.immediate) {
  4476. const info = `callback for immediate watcher "${watcher.expression}"`;
  4477. pushTarget();
  4478. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4479. popTarget();
  4480. }
  4481. return function unwatchFn() {
  4482. watcher.teardown();
  4483. };
  4484. };
  4485. }
  4486. function initProvide(vm) {
  4487. const provideOption = vm.$options.provide;
  4488. if (provideOption) {
  4489. const provided = isFunction(provideOption)
  4490. ? provideOption.call(vm)
  4491. : provideOption;
  4492. if (!isObject(provided)) {
  4493. return;
  4494. }
  4495. const source = resolveProvided(vm);
  4496. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4497. // iterate the keys ourselves.
  4498. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4499. for (let i = 0; i < keys.length; i++) {
  4500. const key = keys[i];
  4501. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4502. }
  4503. }
  4504. }
  4505. function initInjections(vm) {
  4506. const result = resolveInject(vm.$options.inject, vm);
  4507. if (result) {
  4508. toggleObserving(false);
  4509. Object.keys(result).forEach(key => {
  4510. /* istanbul ignore else */
  4511. {
  4512. defineReactive(vm, key, result[key], () => {
  4513. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4514. `overwritten whenever the provided component re-renders. ` +
  4515. `injection being mutated: "${key}"`, vm);
  4516. });
  4517. }
  4518. });
  4519. toggleObserving(true);
  4520. }
  4521. }
  4522. function resolveInject(inject, vm) {
  4523. if (inject) {
  4524. // inject is :any because flow is not smart enough to figure out cached
  4525. const result = Object.create(null);
  4526. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4527. for (let i = 0; i < keys.length; i++) {
  4528. const key = keys[i];
  4529. // #6574 in case the inject object is observed...
  4530. if (key === '__ob__')
  4531. continue;
  4532. const provideKey = inject[key].from;
  4533. if (provideKey in vm._provided) {
  4534. result[key] = vm._provided[provideKey];
  4535. }
  4536. else if ('default' in inject[key]) {
  4537. const provideDefault = inject[key].default;
  4538. result[key] = isFunction(provideDefault)
  4539. ? provideDefault.call(vm)
  4540. : provideDefault;
  4541. }
  4542. else {
  4543. warn$2(`Injection "${key}" not found`, vm);
  4544. }
  4545. }
  4546. return result;
  4547. }
  4548. }
  4549. let uid = 0;
  4550. function initMixin$1(Vue) {
  4551. Vue.prototype._init = function (options) {
  4552. const vm = this;
  4553. // a uid
  4554. vm._uid = uid++;
  4555. let startTag, endTag;
  4556. /* istanbul ignore if */
  4557. if (config.performance && mark) {
  4558. startTag = `vue-perf-start:${vm._uid}`;
  4559. endTag = `vue-perf-end:${vm._uid}`;
  4560. mark(startTag);
  4561. }
  4562. // a flag to mark this as a Vue instance without having to do instanceof
  4563. // check
  4564. vm._isVue = true;
  4565. // avoid instances from being observed
  4566. vm.__v_skip = true;
  4567. // effect scope
  4568. vm._scope = new EffectScope(true /* detached */);
  4569. vm._scope._vm = true;
  4570. // merge options
  4571. if (options && options._isComponent) {
  4572. // optimize internal component instantiation
  4573. // since dynamic options merging is pretty slow, and none of the
  4574. // internal component options needs special treatment.
  4575. initInternalComponent(vm, options);
  4576. }
  4577. else {
  4578. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4579. }
  4580. /* istanbul ignore else */
  4581. {
  4582. initProxy(vm);
  4583. }
  4584. // expose real self
  4585. vm._self = vm;
  4586. initLifecycle(vm);
  4587. initEvents(vm);
  4588. initRender(vm);
  4589. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4590. initInjections(vm); // resolve injections before data/props
  4591. initState(vm);
  4592. initProvide(vm); // resolve provide after data/props
  4593. callHook$1(vm, 'created');
  4594. /* istanbul ignore if */
  4595. if (config.performance && mark) {
  4596. vm._name = formatComponentName(vm, false);
  4597. mark(endTag);
  4598. measure(`vue ${vm._name} init`, startTag, endTag);
  4599. }
  4600. if (vm.$options.el) {
  4601. vm.$mount(vm.$options.el);
  4602. }
  4603. };
  4604. }
  4605. function initInternalComponent(vm, options) {
  4606. const opts = (vm.$options = Object.create(vm.constructor.options));
  4607. // doing this because it's faster than dynamic enumeration.
  4608. const parentVnode = options._parentVnode;
  4609. opts.parent = options.parent;
  4610. opts._parentVnode = parentVnode;
  4611. const vnodeComponentOptions = parentVnode.componentOptions;
  4612. opts.propsData = vnodeComponentOptions.propsData;
  4613. opts._parentListeners = vnodeComponentOptions.listeners;
  4614. opts._renderChildren = vnodeComponentOptions.children;
  4615. opts._componentTag = vnodeComponentOptions.tag;
  4616. if (options.render) {
  4617. opts.render = options.render;
  4618. opts.staticRenderFns = options.staticRenderFns;
  4619. }
  4620. }
  4621. function resolveConstructorOptions(Ctor) {
  4622. let options = Ctor.options;
  4623. if (Ctor.super) {
  4624. const superOptions = resolveConstructorOptions(Ctor.super);
  4625. const cachedSuperOptions = Ctor.superOptions;
  4626. if (superOptions !== cachedSuperOptions) {
  4627. // super option changed,
  4628. // need to resolve new options.
  4629. Ctor.superOptions = superOptions;
  4630. // check if there are any late-modified/attached options (#4976)
  4631. const modifiedOptions = resolveModifiedOptions(Ctor);
  4632. // update base extend options
  4633. if (modifiedOptions) {
  4634. extend(Ctor.extendOptions, modifiedOptions);
  4635. }
  4636. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4637. if (options.name) {
  4638. options.components[options.name] = Ctor;
  4639. }
  4640. }
  4641. }
  4642. return options;
  4643. }
  4644. function resolveModifiedOptions(Ctor) {
  4645. let modified;
  4646. const latest = Ctor.options;
  4647. const sealed = Ctor.sealedOptions;
  4648. for (const key in latest) {
  4649. if (latest[key] !== sealed[key]) {
  4650. if (!modified)
  4651. modified = {};
  4652. modified[key] = latest[key];
  4653. }
  4654. }
  4655. return modified;
  4656. }
  4657. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4658. const options = Ctor.options;
  4659. // ensure the createElement function in functional components
  4660. // gets a unique context - this is necessary for correct named slot check
  4661. let contextVm;
  4662. if (hasOwn(parent, '_uid')) {
  4663. contextVm = Object.create(parent);
  4664. contextVm._original = parent;
  4665. }
  4666. else {
  4667. // the context vm passed in is a functional context as well.
  4668. // in this case we want to make sure we are able to get a hold to the
  4669. // real context instance.
  4670. contextVm = parent;
  4671. // @ts-ignore
  4672. parent = parent._original;
  4673. }
  4674. const isCompiled = isTrue(options._compiled);
  4675. const needNormalization = !isCompiled;
  4676. this.data = data;
  4677. this.props = props;
  4678. this.children = children;
  4679. this.parent = parent;
  4680. this.listeners = data.on || emptyObject;
  4681. this.injections = resolveInject(options.inject, parent);
  4682. this.slots = () => {
  4683. if (!this.$slots) {
  4684. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4685. }
  4686. return this.$slots;
  4687. };
  4688. Object.defineProperty(this, 'scopedSlots', {
  4689. enumerable: true,
  4690. get() {
  4691. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4692. }
  4693. });
  4694. // support for compiled functional template
  4695. if (isCompiled) {
  4696. // exposing $options for renderStatic()
  4697. this.$options = options;
  4698. // pre-resolve slots for renderSlot()
  4699. this.$slots = this.slots();
  4700. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4701. }
  4702. if (options._scopeId) {
  4703. this._c = (a, b, c, d) => {
  4704. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4705. if (vnode && !isArray(vnode)) {
  4706. vnode.fnScopeId = options._scopeId;
  4707. vnode.fnContext = parent;
  4708. }
  4709. return vnode;
  4710. };
  4711. }
  4712. else {
  4713. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4714. }
  4715. }
  4716. installRenderHelpers(FunctionalRenderContext.prototype);
  4717. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4718. const options = Ctor.options;
  4719. const props = {};
  4720. const propOptions = options.props;
  4721. if (isDef(propOptions)) {
  4722. for (const key in propOptions) {
  4723. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4724. }
  4725. }
  4726. else {
  4727. if (isDef(data.attrs))
  4728. mergeProps(props, data.attrs);
  4729. if (isDef(data.props))
  4730. mergeProps(props, data.props);
  4731. }
  4732. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4733. const vnode = options.render.call(null, renderContext._c, renderContext);
  4734. if (vnode instanceof VNode) {
  4735. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4736. }
  4737. else if (isArray(vnode)) {
  4738. const vnodes = normalizeChildren(vnode) || [];
  4739. const res = new Array(vnodes.length);
  4740. for (let i = 0; i < vnodes.length; i++) {
  4741. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4742. }
  4743. return res;
  4744. }
  4745. }
  4746. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4747. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4748. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4749. // that should not be matched to match.
  4750. const clone = cloneVNode(vnode);
  4751. clone.fnContext = contextVm;
  4752. clone.fnOptions = options;
  4753. {
  4754. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4755. renderContext;
  4756. }
  4757. if (data.slot) {
  4758. (clone.data || (clone.data = {})).slot = data.slot;
  4759. }
  4760. return clone;
  4761. }
  4762. function mergeProps(to, from) {
  4763. for (const key in from) {
  4764. to[camelize(key)] = from[key];
  4765. }
  4766. }
  4767. function getComponentName(options) {
  4768. return options.name || options.__name || options._componentTag;
  4769. }
  4770. // inline hooks to be invoked on component VNodes during patch
  4771. const componentVNodeHooks = {
  4772. init(vnode, hydrating) {
  4773. if (vnode.componentInstance &&
  4774. !vnode.componentInstance._isDestroyed &&
  4775. vnode.data.keepAlive) {
  4776. // kept-alive components, treat as a patch
  4777. const mountedNode = vnode; // work around flow
  4778. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4779. }
  4780. else {
  4781. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4782. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4783. }
  4784. },
  4785. prepatch(oldVnode, vnode) {
  4786. const options = vnode.componentOptions;
  4787. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4788. updateChildComponent(child, options.propsData, // updated props
  4789. options.listeners, // updated listeners
  4790. vnode, // new parent vnode
  4791. options.children // new children
  4792. );
  4793. },
  4794. insert(vnode) {
  4795. const { context, componentInstance } = vnode;
  4796. if (!componentInstance._isMounted) {
  4797. componentInstance._isMounted = true;
  4798. callHook$1(componentInstance, 'mounted');
  4799. }
  4800. if (vnode.data.keepAlive) {
  4801. if (context._isMounted) {
  4802. // vue-router#1212
  4803. // During updates, a kept-alive component's child components may
  4804. // change, so directly walking the tree here may call activated hooks
  4805. // on incorrect children. Instead we push them into a queue which will
  4806. // be processed after the whole patch process ended.
  4807. queueActivatedComponent(componentInstance);
  4808. }
  4809. else {
  4810. activateChildComponent(componentInstance, true /* direct */);
  4811. }
  4812. }
  4813. },
  4814. destroy(vnode) {
  4815. const { componentInstance } = vnode;
  4816. if (!componentInstance._isDestroyed) {
  4817. if (!vnode.data.keepAlive) {
  4818. componentInstance.$destroy();
  4819. }
  4820. else {
  4821. deactivateChildComponent(componentInstance, true /* direct */);
  4822. }
  4823. }
  4824. }
  4825. };
  4826. const hooksToMerge = Object.keys(componentVNodeHooks);
  4827. function createComponent(Ctor, data, context, children, tag) {
  4828. if (isUndef(Ctor)) {
  4829. return;
  4830. }
  4831. const baseCtor = context.$options._base;
  4832. // plain options object: turn it into a constructor
  4833. if (isObject(Ctor)) {
  4834. Ctor = baseCtor.extend(Ctor);
  4835. }
  4836. // if at this stage it's not a constructor or an async component factory,
  4837. // reject.
  4838. if (typeof Ctor !== 'function') {
  4839. {
  4840. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4841. }
  4842. return;
  4843. }
  4844. // async component
  4845. let asyncFactory;
  4846. // @ts-expect-error
  4847. if (isUndef(Ctor.cid)) {
  4848. asyncFactory = Ctor;
  4849. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4850. if (Ctor === undefined) {
  4851. // return a placeholder node for async component, which is rendered
  4852. // as a comment node but preserves all the raw information for the node.
  4853. // the information will be used for async server-rendering and hydration.
  4854. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4855. }
  4856. }
  4857. data = data || {};
  4858. // resolve constructor options in case global mixins are applied after
  4859. // component constructor creation
  4860. resolveConstructorOptions(Ctor);
  4861. // transform component v-model data into props & events
  4862. if (isDef(data.model)) {
  4863. // @ts-expect-error
  4864. transformModel(Ctor.options, data);
  4865. }
  4866. // extract props
  4867. // @ts-expect-error
  4868. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4869. // functional component
  4870. // @ts-expect-error
  4871. if (isTrue(Ctor.options.functional)) {
  4872. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4873. }
  4874. // extract listeners, since these needs to be treated as
  4875. // child component listeners instead of DOM listeners
  4876. const listeners = data.on;
  4877. // replace with listeners with .native modifier
  4878. // so it gets processed during parent component patch.
  4879. data.on = data.nativeOn;
  4880. // @ts-expect-error
  4881. if (isTrue(Ctor.options.abstract)) {
  4882. // abstract components do not keep anything
  4883. // other than props & listeners & slot
  4884. // work around flow
  4885. const slot = data.slot;
  4886. data = {};
  4887. if (slot) {
  4888. data.slot = slot;
  4889. }
  4890. }
  4891. // install component management hooks onto the placeholder node
  4892. installComponentHooks(data);
  4893. // return a placeholder vnode
  4894. // @ts-expect-error
  4895. const name = getComponentName(Ctor.options) || tag;
  4896. const vnode = new VNode(
  4897. // @ts-expect-error
  4898. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4899. // @ts-expect-error
  4900. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4901. return vnode;
  4902. }
  4903. function createComponentInstanceForVnode(
  4904. // we know it's MountedComponentVNode but flow doesn't
  4905. vnode,
  4906. // activeInstance in lifecycle state
  4907. parent) {
  4908. const options = {
  4909. _isComponent: true,
  4910. _parentVnode: vnode,
  4911. parent
  4912. };
  4913. // check inline-template render functions
  4914. const inlineTemplate = vnode.data.inlineTemplate;
  4915. if (isDef(inlineTemplate)) {
  4916. options.render = inlineTemplate.render;
  4917. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4918. }
  4919. return new vnode.componentOptions.Ctor(options);
  4920. }
  4921. function installComponentHooks(data) {
  4922. const hooks = data.hook || (data.hook = {});
  4923. for (let i = 0; i < hooksToMerge.length; i++) {
  4924. const key = hooksToMerge[i];
  4925. const existing = hooks[key];
  4926. const toMerge = componentVNodeHooks[key];
  4927. // @ts-expect-error
  4928. if (existing !== toMerge && !(existing && existing._merged)) {
  4929. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4930. }
  4931. }
  4932. }
  4933. function mergeHook(f1, f2) {
  4934. const merged = (a, b) => {
  4935. // flow complains about extra args which is why we use any
  4936. f1(a, b);
  4937. f2(a, b);
  4938. };
  4939. merged._merged = true;
  4940. return merged;
  4941. }
  4942. // transform component v-model info (value and callback) into
  4943. // prop and event handler respectively.
  4944. function transformModel(options, data) {
  4945. const prop = (options.model && options.model.prop) || 'value';
  4946. const event = (options.model && options.model.event) || 'input';
  4947. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4948. const on = data.on || (data.on = {});
  4949. const existing = on[event];
  4950. const callback = data.model.callback;
  4951. if (isDef(existing)) {
  4952. if (isArray(existing)
  4953. ? existing.indexOf(callback) === -1
  4954. : existing !== callback) {
  4955. on[event] = [callback].concat(existing);
  4956. }
  4957. }
  4958. else {
  4959. on[event] = callback;
  4960. }
  4961. }
  4962. let warn$2 = noop;
  4963. let tip = noop;
  4964. let generateComponentTrace; // work around flow check
  4965. let formatComponentName;
  4966. {
  4967. const hasConsole = typeof console !== 'undefined';
  4968. const classifyRE = /(?:^|[-_])(\w)/g;
  4969. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4970. warn$2 = (msg, vm = currentInstance) => {
  4971. const trace = vm ? generateComponentTrace(vm) : '';
  4972. if (config.warnHandler) {
  4973. config.warnHandler.call(null, msg, vm, trace);
  4974. }
  4975. else if (hasConsole && !config.silent) {
  4976. console.error(`[Vue warn]: ${msg}${trace}`);
  4977. }
  4978. };
  4979. tip = (msg, vm) => {
  4980. if (hasConsole && !config.silent) {
  4981. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4982. }
  4983. };
  4984. formatComponentName = (vm, includeFile) => {
  4985. if (vm.$root === vm) {
  4986. return '<Root>';
  4987. }
  4988. const options = isFunction(vm) && vm.cid != null
  4989. ? vm.options
  4990. : vm._isVue
  4991. ? vm.$options || vm.constructor.options
  4992. : vm;
  4993. let name = getComponentName(options);
  4994. const file = options.__file;
  4995. if (!name && file) {
  4996. const match = file.match(/([^/\\]+)\.vue$/);
  4997. name = match && match[1];
  4998. }
  4999. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  5000. (file && includeFile !== false ? ` at ${file}` : ''));
  5001. };
  5002. const repeat = (str, n) => {
  5003. let res = '';
  5004. while (n) {
  5005. if (n % 2 === 1)
  5006. res += str;
  5007. if (n > 1)
  5008. str += str;
  5009. n >>= 1;
  5010. }
  5011. return res;
  5012. };
  5013. generateComponentTrace = (vm) => {
  5014. if (vm._isVue && vm.$parent) {
  5015. const tree = [];
  5016. let currentRecursiveSequence = 0;
  5017. while (vm) {
  5018. if (tree.length > 0) {
  5019. const last = tree[tree.length - 1];
  5020. if (last.constructor === vm.constructor) {
  5021. currentRecursiveSequence++;
  5022. vm = vm.$parent;
  5023. continue;
  5024. }
  5025. else if (currentRecursiveSequence > 0) {
  5026. tree[tree.length - 1] = [last, currentRecursiveSequence];
  5027. currentRecursiveSequence = 0;
  5028. }
  5029. }
  5030. tree.push(vm);
  5031. vm = vm.$parent;
  5032. }
  5033. return ('\n\nfound in\n\n' +
  5034. tree
  5035. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  5036. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  5037. : formatComponentName(vm)}`)
  5038. .join('\n'));
  5039. }
  5040. else {
  5041. return `\n\n(found in ${formatComponentName(vm)})`;
  5042. }
  5043. };
  5044. }
  5045. /**
  5046. * Option overwriting strategies are functions that handle
  5047. * how to merge a parent option value and a child option
  5048. * value into the final value.
  5049. */
  5050. const strats = config.optionMergeStrategies;
  5051. /**
  5052. * Options with restrictions
  5053. */
  5054. {
  5055. strats.el = strats.propsData = function (parent, child, vm, key) {
  5056. if (!vm) {
  5057. warn$2(`option "${key}" can only be used during instance ` +
  5058. 'creation with the `new` keyword.');
  5059. }
  5060. return defaultStrat(parent, child);
  5061. };
  5062. }
  5063. /**
  5064. * Helper that recursively merges two data objects together.
  5065. */
  5066. function mergeData(to, from, recursive = true) {
  5067. if (!from)
  5068. return to;
  5069. let key, toVal, fromVal;
  5070. const keys = hasSymbol
  5071. ? Reflect.ownKeys(from)
  5072. : Object.keys(from);
  5073. for (let i = 0; i < keys.length; i++) {
  5074. key = keys[i];
  5075. // in case the object is already observed...
  5076. if (key === '__ob__')
  5077. continue;
  5078. toVal = to[key];
  5079. fromVal = from[key];
  5080. if (!recursive || !hasOwn(to, key)) {
  5081. set(to, key, fromVal);
  5082. }
  5083. else if (toVal !== fromVal &&
  5084. isPlainObject(toVal) &&
  5085. isPlainObject(fromVal)) {
  5086. mergeData(toVal, fromVal);
  5087. }
  5088. }
  5089. return to;
  5090. }
  5091. /**
  5092. * Data
  5093. */
  5094. function mergeDataOrFn(parentVal, childVal, vm) {
  5095. if (!vm) {
  5096. // in a Vue.extend merge, both should be functions
  5097. if (!childVal) {
  5098. return parentVal;
  5099. }
  5100. if (!parentVal) {
  5101. return childVal;
  5102. }
  5103. // when parentVal & childVal are both present,
  5104. // we need to return a function that returns the
  5105. // merged result of both functions... no need to
  5106. // check if parentVal is a function here because
  5107. // it has to be a function to pass previous merges.
  5108. return function mergedDataFn() {
  5109. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5110. };
  5111. }
  5112. else {
  5113. return function mergedInstanceDataFn() {
  5114. // instance merge
  5115. const instanceData = isFunction(childVal)
  5116. ? childVal.call(vm, vm)
  5117. : childVal;
  5118. const defaultData = isFunction(parentVal)
  5119. ? parentVal.call(vm, vm)
  5120. : parentVal;
  5121. if (instanceData) {
  5122. return mergeData(instanceData, defaultData);
  5123. }
  5124. else {
  5125. return defaultData;
  5126. }
  5127. };
  5128. }
  5129. }
  5130. strats.data = function (parentVal, childVal, vm) {
  5131. if (!vm) {
  5132. if (childVal && typeof childVal !== 'function') {
  5133. warn$2('The "data" option should be a function ' +
  5134. 'that returns a per-instance value in component ' +
  5135. 'definitions.', vm);
  5136. return parentVal;
  5137. }
  5138. return mergeDataOrFn(parentVal, childVal);
  5139. }
  5140. return mergeDataOrFn(parentVal, childVal, vm);
  5141. };
  5142. /**
  5143. * Hooks and props are merged as arrays.
  5144. */
  5145. function mergeLifecycleHook(parentVal, childVal) {
  5146. const res = childVal
  5147. ? parentVal
  5148. ? parentVal.concat(childVal)
  5149. : isArray(childVal)
  5150. ? childVal
  5151. : [childVal]
  5152. : parentVal;
  5153. return res ? dedupeHooks(res) : res;
  5154. }
  5155. function dedupeHooks(hooks) {
  5156. const res = [];
  5157. for (let i = 0; i < hooks.length; i++) {
  5158. if (res.indexOf(hooks[i]) === -1) {
  5159. res.push(hooks[i]);
  5160. }
  5161. }
  5162. return res;
  5163. }
  5164. LIFECYCLE_HOOKS.forEach(hook => {
  5165. strats[hook] = mergeLifecycleHook;
  5166. });
  5167. /**
  5168. * Assets
  5169. *
  5170. * When a vm is present (instance creation), we need to do
  5171. * a three-way merge between constructor options, instance
  5172. * options and parent options.
  5173. */
  5174. function mergeAssets(parentVal, childVal, vm, key) {
  5175. const res = Object.create(parentVal || null);
  5176. if (childVal) {
  5177. assertObjectType(key, childVal, vm);
  5178. return extend(res, childVal);
  5179. }
  5180. else {
  5181. return res;
  5182. }
  5183. }
  5184. ASSET_TYPES.forEach(function (type) {
  5185. strats[type + 's'] = mergeAssets;
  5186. });
  5187. /**
  5188. * Watchers.
  5189. *
  5190. * Watchers hashes should not overwrite one
  5191. * another, so we merge them as arrays.
  5192. */
  5193. strats.watch = function (parentVal, childVal, vm, key) {
  5194. // work around Firefox's Object.prototype.watch...
  5195. //@ts-expect-error work around
  5196. if (parentVal === nativeWatch)
  5197. parentVal = undefined;
  5198. //@ts-expect-error work around
  5199. if (childVal === nativeWatch)
  5200. childVal = undefined;
  5201. /* istanbul ignore if */
  5202. if (!childVal)
  5203. return Object.create(parentVal || null);
  5204. {
  5205. assertObjectType(key, childVal, vm);
  5206. }
  5207. if (!parentVal)
  5208. return childVal;
  5209. const ret = {};
  5210. extend(ret, parentVal);
  5211. for (const key in childVal) {
  5212. let parent = ret[key];
  5213. const child = childVal[key];
  5214. if (parent && !isArray(parent)) {
  5215. parent = [parent];
  5216. }
  5217. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5218. }
  5219. return ret;
  5220. };
  5221. /**
  5222. * Other object hashes.
  5223. */
  5224. strats.props =
  5225. strats.methods =
  5226. strats.inject =
  5227. strats.computed =
  5228. function (parentVal, childVal, vm, key) {
  5229. if (childVal && true) {
  5230. assertObjectType(key, childVal, vm);
  5231. }
  5232. if (!parentVal)
  5233. return childVal;
  5234. const ret = Object.create(null);
  5235. extend(ret, parentVal);
  5236. if (childVal)
  5237. extend(ret, childVal);
  5238. return ret;
  5239. };
  5240. strats.provide = function (parentVal, childVal) {
  5241. if (!parentVal)
  5242. return childVal;
  5243. return function () {
  5244. const ret = Object.create(null);
  5245. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5246. if (childVal) {
  5247. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5248. );
  5249. }
  5250. return ret;
  5251. };
  5252. };
  5253. /**
  5254. * Default strategy.
  5255. */
  5256. const defaultStrat = function (parentVal, childVal) {
  5257. return childVal === undefined ? parentVal : childVal;
  5258. };
  5259. /**
  5260. * Validate component names
  5261. */
  5262. function checkComponents(options) {
  5263. for (const key in options.components) {
  5264. validateComponentName(key);
  5265. }
  5266. }
  5267. function validateComponentName(name) {
  5268. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5269. warn$2('Invalid component name: "' +
  5270. name +
  5271. '". Component names ' +
  5272. 'should conform to valid custom element name in html5 specification.');
  5273. }
  5274. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5275. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5276. 'id: ' +
  5277. name);
  5278. }
  5279. }
  5280. /**
  5281. * Ensure all props option syntax are normalized into the
  5282. * Object-based format.
  5283. */
  5284. function normalizeProps(options, vm) {
  5285. const props = options.props;
  5286. if (!props)
  5287. return;
  5288. const res = {};
  5289. let i, val, name;
  5290. if (isArray(props)) {
  5291. i = props.length;
  5292. while (i--) {
  5293. val = props[i];
  5294. if (typeof val === 'string') {
  5295. name = camelize(val);
  5296. res[name] = { type: null };
  5297. }
  5298. else {
  5299. warn$2('props must be strings when using array syntax.');
  5300. }
  5301. }
  5302. }
  5303. else if (isPlainObject(props)) {
  5304. for (const key in props) {
  5305. val = props[key];
  5306. name = camelize(key);
  5307. res[name] = isPlainObject(val) ? val : { type: val };
  5308. }
  5309. }
  5310. else {
  5311. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5312. `but got ${toRawType(props)}.`, vm);
  5313. }
  5314. options.props = res;
  5315. }
  5316. /**
  5317. * Normalize all injections into Object-based format
  5318. */
  5319. function normalizeInject(options, vm) {
  5320. const inject = options.inject;
  5321. if (!inject)
  5322. return;
  5323. const normalized = (options.inject = {});
  5324. if (isArray(inject)) {
  5325. for (let i = 0; i < inject.length; i++) {
  5326. normalized[inject[i]] = { from: inject[i] };
  5327. }
  5328. }
  5329. else if (isPlainObject(inject)) {
  5330. for (const key in inject) {
  5331. const val = inject[key];
  5332. normalized[key] = isPlainObject(val)
  5333. ? extend({ from: key }, val)
  5334. : { from: val };
  5335. }
  5336. }
  5337. else {
  5338. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5339. `but got ${toRawType(inject)}.`, vm);
  5340. }
  5341. }
  5342. /**
  5343. * Normalize raw function directives into object format.
  5344. */
  5345. function normalizeDirectives$1(options) {
  5346. const dirs = options.directives;
  5347. if (dirs) {
  5348. for (const key in dirs) {
  5349. const def = dirs[key];
  5350. if (isFunction(def)) {
  5351. dirs[key] = { bind: def, update: def };
  5352. }
  5353. }
  5354. }
  5355. }
  5356. function assertObjectType(name, value, vm) {
  5357. if (!isPlainObject(value)) {
  5358. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5359. `but got ${toRawType(value)}.`, vm);
  5360. }
  5361. }
  5362. /**
  5363. * Merge two option objects into a new one.
  5364. * Core utility used in both instantiation and inheritance.
  5365. */
  5366. function mergeOptions(parent, child, vm) {
  5367. {
  5368. checkComponents(child);
  5369. }
  5370. if (isFunction(child)) {
  5371. // @ts-expect-error
  5372. child = child.options;
  5373. }
  5374. normalizeProps(child, vm);
  5375. normalizeInject(child, vm);
  5376. normalizeDirectives$1(child);
  5377. // Apply extends and mixins on the child options,
  5378. // but only if it is a raw options object that isn't
  5379. // the result of another mergeOptions call.
  5380. // Only merged options has the _base property.
  5381. if (!child._base) {
  5382. if (child.extends) {
  5383. parent = mergeOptions(parent, child.extends, vm);
  5384. }
  5385. if (child.mixins) {
  5386. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5387. parent = mergeOptions(parent, child.mixins[i], vm);
  5388. }
  5389. }
  5390. }
  5391. const options = {};
  5392. let key;
  5393. for (key in parent) {
  5394. mergeField(key);
  5395. }
  5396. for (key in child) {
  5397. if (!hasOwn(parent, key)) {
  5398. mergeField(key);
  5399. }
  5400. }
  5401. function mergeField(key) {
  5402. const strat = strats[key] || defaultStrat;
  5403. options[key] = strat(parent[key], child[key], vm, key);
  5404. }
  5405. return options;
  5406. }
  5407. /**
  5408. * Resolve an asset.
  5409. * This function is used because child instances need access
  5410. * to assets defined in its ancestor chain.
  5411. */
  5412. function resolveAsset(options, type, id, warnMissing) {
  5413. /* istanbul ignore if */
  5414. if (typeof id !== 'string') {
  5415. return;
  5416. }
  5417. const assets = options[type];
  5418. // check local registration variations first
  5419. if (hasOwn(assets, id))
  5420. return assets[id];
  5421. const camelizedId = camelize(id);
  5422. if (hasOwn(assets, camelizedId))
  5423. return assets[camelizedId];
  5424. const PascalCaseId = capitalize(camelizedId);
  5425. if (hasOwn(assets, PascalCaseId))
  5426. return assets[PascalCaseId];
  5427. // fallback to prototype chain
  5428. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5429. if (warnMissing && !res) {
  5430. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5431. }
  5432. return res;
  5433. }
  5434. function validateProp(key, propOptions, propsData, vm) {
  5435. const prop = propOptions[key];
  5436. const absent = !hasOwn(propsData, key);
  5437. let value = propsData[key];
  5438. // boolean casting
  5439. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5440. if (booleanIndex > -1) {
  5441. if (absent && !hasOwn(prop, 'default')) {
  5442. value = false;
  5443. }
  5444. else if (value === '' || value === hyphenate(key)) {
  5445. // only cast empty string / same name to boolean if
  5446. // boolean has higher priority
  5447. const stringIndex = getTypeIndex(String, prop.type);
  5448. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5449. value = true;
  5450. }
  5451. }
  5452. }
  5453. // check default value
  5454. if (value === undefined) {
  5455. value = getPropDefaultValue(vm, prop, key);
  5456. // since the default value is a fresh copy,
  5457. // make sure to observe it.
  5458. const prevShouldObserve = shouldObserve;
  5459. toggleObserving(true);
  5460. observe(value);
  5461. toggleObserving(prevShouldObserve);
  5462. }
  5463. {
  5464. assertProp(prop, key, value, vm, absent);
  5465. }
  5466. return value;
  5467. }
  5468. /**
  5469. * Get the default value of a prop.
  5470. */
  5471. function getPropDefaultValue(vm, prop, key) {
  5472. // no default, return undefined
  5473. if (!hasOwn(prop, 'default')) {
  5474. return undefined;
  5475. }
  5476. const def = prop.default;
  5477. // warn against non-factory defaults for Object & Array
  5478. if (isObject(def)) {
  5479. warn$2('Invalid default value for prop "' +
  5480. key +
  5481. '": ' +
  5482. 'Props with type Object/Array must use a factory function ' +
  5483. 'to return the default value.', vm);
  5484. }
  5485. // the raw prop value was also undefined from previous render,
  5486. // return previous default value to avoid unnecessary watcher trigger
  5487. if (vm &&
  5488. vm.$options.propsData &&
  5489. vm.$options.propsData[key] === undefined &&
  5490. vm._props[key] !== undefined) {
  5491. return vm._props[key];
  5492. }
  5493. // call factory function for non-Function types
  5494. // a value is Function if its prototype is function even across different execution context
  5495. return isFunction(def) && getType(prop.type) !== 'Function'
  5496. ? def.call(vm)
  5497. : def;
  5498. }
  5499. /**
  5500. * Assert whether a prop is valid.
  5501. */
  5502. function assertProp(prop, name, value, vm, absent) {
  5503. if (prop.required && absent) {
  5504. warn$2('Missing required prop: "' + name + '"', vm);
  5505. return;
  5506. }
  5507. if (value == null && !prop.required) {
  5508. return;
  5509. }
  5510. let type = prop.type;
  5511. let valid = !type || type === true;
  5512. const expectedTypes = [];
  5513. if (type) {
  5514. if (!isArray(type)) {
  5515. type = [type];
  5516. }
  5517. for (let i = 0; i < type.length && !valid; i++) {
  5518. const assertedType = assertType(value, type[i], vm);
  5519. expectedTypes.push(assertedType.expectedType || '');
  5520. valid = assertedType.valid;
  5521. }
  5522. }
  5523. const haveExpectedTypes = expectedTypes.some(t => t);
  5524. if (!valid && haveExpectedTypes) {
  5525. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5526. return;
  5527. }
  5528. const validator = prop.validator;
  5529. if (validator) {
  5530. if (!validator(value)) {
  5531. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5532. }
  5533. }
  5534. }
  5535. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5536. function assertType(value, type, vm) {
  5537. let valid;
  5538. const expectedType = getType(type);
  5539. if (simpleCheckRE.test(expectedType)) {
  5540. const t = typeof value;
  5541. valid = t === expectedType.toLowerCase();
  5542. // for primitive wrapper objects
  5543. if (!valid && t === 'object') {
  5544. valid = value instanceof type;
  5545. }
  5546. }
  5547. else if (expectedType === 'Object') {
  5548. valid = isPlainObject(value);
  5549. }
  5550. else if (expectedType === 'Array') {
  5551. valid = isArray(value);
  5552. }
  5553. else {
  5554. try {
  5555. valid = value instanceof type;
  5556. }
  5557. catch (e) {
  5558. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5559. valid = false;
  5560. }
  5561. }
  5562. return {
  5563. valid,
  5564. expectedType
  5565. };
  5566. }
  5567. const functionTypeCheckRE = /^\s*function (\w+)/;
  5568. /**
  5569. * Use function string name to check built-in types,
  5570. * because a simple equality check will fail when running
  5571. * across different vms / iframes.
  5572. */
  5573. function getType(fn) {
  5574. const match = fn && fn.toString().match(functionTypeCheckRE);
  5575. return match ? match[1] : '';
  5576. }
  5577. function isSameType(a, b) {
  5578. return getType(a) === getType(b);
  5579. }
  5580. function getTypeIndex(type, expectedTypes) {
  5581. if (!isArray(expectedTypes)) {
  5582. return isSameType(expectedTypes, type) ? 0 : -1;
  5583. }
  5584. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5585. if (isSameType(expectedTypes[i], type)) {
  5586. return i;
  5587. }
  5588. }
  5589. return -1;
  5590. }
  5591. function getInvalidTypeMessage(name, value, expectedTypes) {
  5592. let message = `Invalid prop: type check failed for prop "${name}".` +
  5593. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5594. const expectedType = expectedTypes[0];
  5595. const receivedType = toRawType(value);
  5596. // check if we need to specify expected value
  5597. if (expectedTypes.length === 1 &&
  5598. isExplicable(expectedType) &&
  5599. isExplicable(typeof value) &&
  5600. !isBoolean(expectedType, receivedType)) {
  5601. message += ` with value ${styleValue(value, expectedType)}`;
  5602. }
  5603. message += `, got ${receivedType} `;
  5604. // check if we need to specify received value
  5605. if (isExplicable(receivedType)) {
  5606. message += `with value ${styleValue(value, receivedType)}.`;
  5607. }
  5608. return message;
  5609. }
  5610. function styleValue(value, type) {
  5611. if (type === 'String') {
  5612. return `"${value}"`;
  5613. }
  5614. else if (type === 'Number') {
  5615. return `${Number(value)}`;
  5616. }
  5617. else {
  5618. return `${value}`;
  5619. }
  5620. }
  5621. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5622. function isExplicable(value) {
  5623. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5624. }
  5625. function isBoolean(...args) {
  5626. return args.some(elem => elem.toLowerCase() === 'boolean');
  5627. }
  5628. function Vue(options) {
  5629. if (!(this instanceof Vue)) {
  5630. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5631. }
  5632. this._init(options);
  5633. }
  5634. //@ts-expect-error Vue has function type
  5635. initMixin$1(Vue);
  5636. //@ts-expect-error Vue has function type
  5637. stateMixin(Vue);
  5638. //@ts-expect-error Vue has function type
  5639. eventsMixin(Vue);
  5640. //@ts-expect-error Vue has function type
  5641. lifecycleMixin(Vue);
  5642. //@ts-expect-error Vue has function type
  5643. renderMixin(Vue);
  5644. function initUse(Vue) {
  5645. Vue.use = function (plugin) {
  5646. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5647. if (installedPlugins.indexOf(plugin) > -1) {
  5648. return this;
  5649. }
  5650. // additional parameters
  5651. const args = toArray(arguments, 1);
  5652. args.unshift(this);
  5653. if (isFunction(plugin.install)) {
  5654. plugin.install.apply(plugin, args);
  5655. }
  5656. else if (isFunction(plugin)) {
  5657. plugin.apply(null, args);
  5658. }
  5659. installedPlugins.push(plugin);
  5660. return this;
  5661. };
  5662. }
  5663. function initMixin(Vue) {
  5664. Vue.mixin = function (mixin) {
  5665. this.options = mergeOptions(this.options, mixin);
  5666. return this;
  5667. };
  5668. }
  5669. function initExtend(Vue) {
  5670. /**
  5671. * Each instance constructor, including Vue, has a unique
  5672. * cid. This enables us to create wrapped "child
  5673. * constructors" for prototypal inheritance and cache them.
  5674. */
  5675. Vue.cid = 0;
  5676. let cid = 1;
  5677. /**
  5678. * Class inheritance
  5679. */
  5680. Vue.extend = function (extendOptions) {
  5681. extendOptions = extendOptions || {};
  5682. const Super = this;
  5683. const SuperId = Super.cid;
  5684. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5685. if (cachedCtors[SuperId]) {
  5686. return cachedCtors[SuperId];
  5687. }
  5688. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5689. if (name) {
  5690. validateComponentName(name);
  5691. }
  5692. const Sub = function VueComponent(options) {
  5693. this._init(options);
  5694. };
  5695. Sub.prototype = Object.create(Super.prototype);
  5696. Sub.prototype.constructor = Sub;
  5697. Sub.cid = cid++;
  5698. Sub.options = mergeOptions(Super.options, extendOptions);
  5699. Sub['super'] = Super;
  5700. // For props and computed properties, we define the proxy getters on
  5701. // the Vue instances at extension time, on the extended prototype. This
  5702. // avoids Object.defineProperty calls for each instance created.
  5703. if (Sub.options.props) {
  5704. initProps(Sub);
  5705. }
  5706. if (Sub.options.computed) {
  5707. initComputed(Sub);
  5708. }
  5709. // allow further extension/mixin/plugin usage
  5710. Sub.extend = Super.extend;
  5711. Sub.mixin = Super.mixin;
  5712. Sub.use = Super.use;
  5713. // create asset registers, so extended classes
  5714. // can have their private assets too.
  5715. ASSET_TYPES.forEach(function (type) {
  5716. Sub[type] = Super[type];
  5717. });
  5718. // enable recursive self-lookup
  5719. if (name) {
  5720. Sub.options.components[name] = Sub;
  5721. }
  5722. // keep a reference to the super options at extension time.
  5723. // later at instantiation we can check if Super's options have
  5724. // been updated.
  5725. Sub.superOptions = Super.options;
  5726. Sub.extendOptions = extendOptions;
  5727. Sub.sealedOptions = extend({}, Sub.options);
  5728. // cache constructor
  5729. cachedCtors[SuperId] = Sub;
  5730. return Sub;
  5731. };
  5732. }
  5733. function initProps(Comp) {
  5734. const props = Comp.options.props;
  5735. for (const key in props) {
  5736. proxy(Comp.prototype, `_props`, key);
  5737. }
  5738. }
  5739. function initComputed(Comp) {
  5740. const computed = Comp.options.computed;
  5741. for (const key in computed) {
  5742. defineComputed(Comp.prototype, key, computed[key]);
  5743. }
  5744. }
  5745. function initAssetRegisters(Vue) {
  5746. /**
  5747. * Create asset registration methods.
  5748. */
  5749. ASSET_TYPES.forEach(type => {
  5750. // @ts-expect-error function is not exact same type
  5751. Vue[type] = function (id, definition) {
  5752. if (!definition) {
  5753. return this.options[type + 's'][id];
  5754. }
  5755. else {
  5756. /* istanbul ignore if */
  5757. if (type === 'component') {
  5758. validateComponentName(id);
  5759. }
  5760. if (type === 'component' && isPlainObject(definition)) {
  5761. // @ts-expect-error
  5762. definition.name = definition.name || id;
  5763. definition = this.options._base.extend(definition);
  5764. }
  5765. if (type === 'directive' && isFunction(definition)) {
  5766. definition = { bind: definition, update: definition };
  5767. }
  5768. this.options[type + 's'][id] = definition;
  5769. return definition;
  5770. }
  5771. };
  5772. });
  5773. }
  5774. function _getComponentName(opts) {
  5775. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5776. }
  5777. function matches(pattern, name) {
  5778. if (isArray(pattern)) {
  5779. return pattern.indexOf(name) > -1;
  5780. }
  5781. else if (typeof pattern === 'string') {
  5782. return pattern.split(',').indexOf(name) > -1;
  5783. }
  5784. else if (isRegExp(pattern)) {
  5785. return pattern.test(name);
  5786. }
  5787. /* istanbul ignore next */
  5788. return false;
  5789. }
  5790. function pruneCache(keepAliveInstance, filter) {
  5791. const { cache, keys, _vnode } = keepAliveInstance;
  5792. for (const key in cache) {
  5793. const entry = cache[key];
  5794. if (entry) {
  5795. const name = entry.name;
  5796. if (name && !filter(name)) {
  5797. pruneCacheEntry(cache, key, keys, _vnode);
  5798. }
  5799. }
  5800. }
  5801. }
  5802. function pruneCacheEntry(cache, key, keys, current) {
  5803. const entry = cache[key];
  5804. if (entry && (!current || entry.tag !== current.tag)) {
  5805. // @ts-expect-error can be undefined
  5806. entry.componentInstance.$destroy();
  5807. }
  5808. cache[key] = null;
  5809. remove$2(keys, key);
  5810. }
  5811. const patternTypes = [String, RegExp, Array];
  5812. // TODO defineComponent
  5813. var KeepAlive = {
  5814. name: 'keep-alive',
  5815. abstract: true,
  5816. props: {
  5817. include: patternTypes,
  5818. exclude: patternTypes,
  5819. max: [String, Number]
  5820. },
  5821. methods: {
  5822. cacheVNode() {
  5823. const { cache, keys, vnodeToCache, keyToCache } = this;
  5824. if (vnodeToCache) {
  5825. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5826. cache[keyToCache] = {
  5827. name: _getComponentName(componentOptions),
  5828. tag,
  5829. componentInstance
  5830. };
  5831. keys.push(keyToCache);
  5832. // prune oldest entry
  5833. if (this.max && keys.length > parseInt(this.max)) {
  5834. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5835. }
  5836. this.vnodeToCache = null;
  5837. }
  5838. }
  5839. },
  5840. created() {
  5841. this.cache = Object.create(null);
  5842. this.keys = [];
  5843. },
  5844. destroyed() {
  5845. for (const key in this.cache) {
  5846. pruneCacheEntry(this.cache, key, this.keys);
  5847. }
  5848. },
  5849. mounted() {
  5850. this.cacheVNode();
  5851. this.$watch('include', val => {
  5852. pruneCache(this, name => matches(val, name));
  5853. });
  5854. this.$watch('exclude', val => {
  5855. pruneCache(this, name => !matches(val, name));
  5856. });
  5857. },
  5858. updated() {
  5859. this.cacheVNode();
  5860. },
  5861. render() {
  5862. const slot = this.$slots.default;
  5863. const vnode = getFirstComponentChild(slot);
  5864. const componentOptions = vnode && vnode.componentOptions;
  5865. if (componentOptions) {
  5866. // check pattern
  5867. const name = _getComponentName(componentOptions);
  5868. const { include, exclude } = this;
  5869. if (
  5870. // not included
  5871. (include && (!name || !matches(include, name))) ||
  5872. // excluded
  5873. (exclude && name && matches(exclude, name))) {
  5874. return vnode;
  5875. }
  5876. const { cache, keys } = this;
  5877. const key = vnode.key == null
  5878. ? // same constructor may get registered as different local components
  5879. // so cid alone is not enough (#3269)
  5880. componentOptions.Ctor.cid +
  5881. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5882. : vnode.key;
  5883. if (cache[key]) {
  5884. vnode.componentInstance = cache[key].componentInstance;
  5885. // make current key freshest
  5886. remove$2(keys, key);
  5887. keys.push(key);
  5888. }
  5889. else {
  5890. // delay setting the cache until update
  5891. this.vnodeToCache = vnode;
  5892. this.keyToCache = key;
  5893. }
  5894. // @ts-expect-error can vnode.data can be undefined
  5895. vnode.data.keepAlive = true;
  5896. }
  5897. return vnode || (slot && slot[0]);
  5898. }
  5899. };
  5900. var builtInComponents = {
  5901. KeepAlive
  5902. };
  5903. function initGlobalAPI(Vue) {
  5904. // config
  5905. const configDef = {};
  5906. configDef.get = () => config;
  5907. {
  5908. configDef.set = () => {
  5909. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5910. };
  5911. }
  5912. Object.defineProperty(Vue, 'config', configDef);
  5913. // exposed util methods.
  5914. // NOTE: these are not considered part of the public API - avoid relying on
  5915. // them unless you are aware of the risk.
  5916. Vue.util = {
  5917. warn: warn$2,
  5918. extend,
  5919. mergeOptions,
  5920. defineReactive
  5921. };
  5922. Vue.set = set;
  5923. Vue.delete = del;
  5924. Vue.nextTick = nextTick;
  5925. // 2.6 explicit observable API
  5926. Vue.observable = (obj) => {
  5927. observe(obj);
  5928. return obj;
  5929. };
  5930. Vue.options = Object.create(null);
  5931. ASSET_TYPES.forEach(type => {
  5932. Vue.options[type + 's'] = Object.create(null);
  5933. });
  5934. // this is used to identify the "base" constructor to extend all plain-object
  5935. // components with in Weex's multi-instance scenarios.
  5936. Vue.options._base = Vue;
  5937. extend(Vue.options.components, builtInComponents);
  5938. initUse(Vue);
  5939. initMixin(Vue);
  5940. initExtend(Vue);
  5941. initAssetRegisters(Vue);
  5942. }
  5943. initGlobalAPI(Vue);
  5944. Object.defineProperty(Vue.prototype, '$isServer', {
  5945. get: isServerRendering
  5946. });
  5947. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5948. get() {
  5949. /* istanbul ignore next */
  5950. return this.$vnode && this.$vnode.ssrContext;
  5951. }
  5952. });
  5953. // expose FunctionalRenderContext for ssr runtime helper installation
  5954. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5955. value: FunctionalRenderContext
  5956. });
  5957. Vue.version = version;
  5958. // these are reserved for web because they are directly compiled away
  5959. // during template compilation
  5960. const isReservedAttr = makeMap('style,class');
  5961. // attributes that should be using props for binding
  5962. const acceptValue = makeMap('input,textarea,option,select,progress');
  5963. const mustUseProp = (tag, type, attr) => {
  5964. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5965. (attr === 'selected' && tag === 'option') ||
  5966. (attr === 'checked' && tag === 'input') ||
  5967. (attr === 'muted' && tag === 'video'));
  5968. };
  5969. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5970. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5971. const convertEnumeratedValue = (key, value) => {
  5972. return isFalsyAttrValue(value) || value === 'false'
  5973. ? 'false'
  5974. : // allow arbitrary string value for contenteditable
  5975. key === 'contenteditable' && isValidContentEditableValue(value)
  5976. ? value
  5977. : 'true';
  5978. };
  5979. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5980. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5981. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5982. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5983. 'required,reversed,scoped,seamless,selected,sortable,' +
  5984. 'truespeed,typemustmatch,visible');
  5985. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5986. const isXlink = (name) => {
  5987. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5988. };
  5989. const getXlinkProp = (name) => {
  5990. return isXlink(name) ? name.slice(6, name.length) : '';
  5991. };
  5992. const isFalsyAttrValue = (val) => {
  5993. return val == null || val === false;
  5994. };
  5995. function genClassForVnode(vnode) {
  5996. let data = vnode.data;
  5997. let parentNode = vnode;
  5998. let childNode = vnode;
  5999. while (isDef(childNode.componentInstance)) {
  6000. childNode = childNode.componentInstance._vnode;
  6001. if (childNode && childNode.data) {
  6002. data = mergeClassData(childNode.data, data);
  6003. }
  6004. }
  6005. // @ts-expect-error parentNode.parent not VNodeWithData
  6006. while (isDef((parentNode = parentNode.parent))) {
  6007. if (parentNode && parentNode.data) {
  6008. data = mergeClassData(data, parentNode.data);
  6009. }
  6010. }
  6011. return renderClass(data.staticClass, data.class);
  6012. }
  6013. function mergeClassData(child, parent) {
  6014. return {
  6015. staticClass: concat(child.staticClass, parent.staticClass),
  6016. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6017. };
  6018. }
  6019. function renderClass(staticClass, dynamicClass) {
  6020. if (isDef(staticClass) || isDef(dynamicClass)) {
  6021. return concat(staticClass, stringifyClass(dynamicClass));
  6022. }
  6023. /* istanbul ignore next */
  6024. return '';
  6025. }
  6026. function concat(a, b) {
  6027. return a ? (b ? a + ' ' + b : a) : b || '';
  6028. }
  6029. function stringifyClass(value) {
  6030. if (Array.isArray(value)) {
  6031. return stringifyArray(value);
  6032. }
  6033. if (isObject(value)) {
  6034. return stringifyObject(value);
  6035. }
  6036. if (typeof value === 'string') {
  6037. return value;
  6038. }
  6039. /* istanbul ignore next */
  6040. return '';
  6041. }
  6042. function stringifyArray(value) {
  6043. let res = '';
  6044. let stringified;
  6045. for (let i = 0, l = value.length; i < l; i++) {
  6046. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6047. if (res)
  6048. res += ' ';
  6049. res += stringified;
  6050. }
  6051. }
  6052. return res;
  6053. }
  6054. function stringifyObject(value) {
  6055. let res = '';
  6056. for (const key in value) {
  6057. if (value[key]) {
  6058. if (res)
  6059. res += ' ';
  6060. res += key;
  6061. }
  6062. }
  6063. return res;
  6064. }
  6065. const namespaceMap = {
  6066. svg: 'http://www.w3.org/2000/svg',
  6067. math: 'http://www.w3.org/1998/Math/MathML'
  6068. };
  6069. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6070. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6071. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6072. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6073. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6074. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6075. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6076. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6077. 'output,progress,select,textarea,' +
  6078. 'details,dialog,menu,menuitem,summary,' +
  6079. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6080. // this map is intentionally selective, only covering SVG elements that may
  6081. // contain child elements.
  6082. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6083. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6084. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6085. const isPreTag = (tag) => tag === 'pre';
  6086. const isReservedTag = (tag) => {
  6087. return isHTMLTag(tag) || isSVG(tag);
  6088. };
  6089. function getTagNamespace(tag) {
  6090. if (isSVG(tag)) {
  6091. return 'svg';
  6092. }
  6093. // basic support for MathML
  6094. // note it doesn't support other MathML elements being component roots
  6095. if (tag === 'math') {
  6096. return 'math';
  6097. }
  6098. }
  6099. const unknownElementCache = Object.create(null);
  6100. function isUnknownElement(tag) {
  6101. /* istanbul ignore if */
  6102. if (!inBrowser) {
  6103. return true;
  6104. }
  6105. if (isReservedTag(tag)) {
  6106. return false;
  6107. }
  6108. tag = tag.toLowerCase();
  6109. /* istanbul ignore if */
  6110. if (unknownElementCache[tag] != null) {
  6111. return unknownElementCache[tag];
  6112. }
  6113. const el = document.createElement(tag);
  6114. if (tag.indexOf('-') > -1) {
  6115. // http://stackoverflow.com/a/28210364/1070244
  6116. return (unknownElementCache[tag] =
  6117. el.constructor === window.HTMLUnknownElement ||
  6118. el.constructor === window.HTMLElement);
  6119. }
  6120. else {
  6121. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6122. }
  6123. }
  6124. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6125. /**
  6126. * Query an element selector if it's not an element already.
  6127. */
  6128. function query(el) {
  6129. if (typeof el === 'string') {
  6130. const selected = document.querySelector(el);
  6131. if (!selected) {
  6132. warn$2('Cannot find element: ' + el);
  6133. return document.createElement('div');
  6134. }
  6135. return selected;
  6136. }
  6137. else {
  6138. return el;
  6139. }
  6140. }
  6141. function createElement(tagName, vnode) {
  6142. const elm = document.createElement(tagName);
  6143. if (tagName !== 'select') {
  6144. return elm;
  6145. }
  6146. // false or null will remove the attribute but undefined will not
  6147. if (vnode.data &&
  6148. vnode.data.attrs &&
  6149. vnode.data.attrs.multiple !== undefined) {
  6150. elm.setAttribute('multiple', 'multiple');
  6151. }
  6152. return elm;
  6153. }
  6154. function createElementNS(namespace, tagName) {
  6155. return document.createElementNS(namespaceMap[namespace], tagName);
  6156. }
  6157. function createTextNode(text) {
  6158. return document.createTextNode(text);
  6159. }
  6160. function createComment(text) {
  6161. return document.createComment(text);
  6162. }
  6163. function insertBefore(parentNode, newNode, referenceNode) {
  6164. parentNode.insertBefore(newNode, referenceNode);
  6165. }
  6166. function removeChild(node, child) {
  6167. node.removeChild(child);
  6168. }
  6169. function appendChild(node, child) {
  6170. node.appendChild(child);
  6171. }
  6172. function parentNode(node) {
  6173. return node.parentNode;
  6174. }
  6175. function nextSibling(node) {
  6176. return node.nextSibling;
  6177. }
  6178. function tagName(node) {
  6179. return node.tagName;
  6180. }
  6181. function setTextContent(node, text) {
  6182. node.textContent = text;
  6183. }
  6184. function setStyleScope(node, scopeId) {
  6185. node.setAttribute(scopeId, '');
  6186. }
  6187. var nodeOps = /*#__PURE__*/Object.freeze({
  6188. __proto__: null,
  6189. createElement: createElement,
  6190. createElementNS: createElementNS,
  6191. createTextNode: createTextNode,
  6192. createComment: createComment,
  6193. insertBefore: insertBefore,
  6194. removeChild: removeChild,
  6195. appendChild: appendChild,
  6196. parentNode: parentNode,
  6197. nextSibling: nextSibling,
  6198. tagName: tagName,
  6199. setTextContent: setTextContent,
  6200. setStyleScope: setStyleScope
  6201. });
  6202. var ref = {
  6203. create(_, vnode) {
  6204. registerRef(vnode);
  6205. },
  6206. update(oldVnode, vnode) {
  6207. if (oldVnode.data.ref !== vnode.data.ref) {
  6208. registerRef(oldVnode, true);
  6209. registerRef(vnode);
  6210. }
  6211. },
  6212. destroy(vnode) {
  6213. registerRef(vnode, true);
  6214. }
  6215. };
  6216. function registerRef(vnode, isRemoval) {
  6217. const ref = vnode.data.ref;
  6218. if (!isDef(ref))
  6219. return;
  6220. const vm = vnode.context;
  6221. const refValue = vnode.componentInstance || vnode.elm;
  6222. const value = isRemoval ? null : refValue;
  6223. const $refsValue = isRemoval ? undefined : refValue;
  6224. if (isFunction(ref)) {
  6225. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6226. return;
  6227. }
  6228. const isFor = vnode.data.refInFor;
  6229. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6230. const _isRef = isRef(ref);
  6231. const refs = vm.$refs;
  6232. if (_isString || _isRef) {
  6233. if (isFor) {
  6234. const existing = _isString ? refs[ref] : ref.value;
  6235. if (isRemoval) {
  6236. isArray(existing) && remove$2(existing, refValue);
  6237. }
  6238. else {
  6239. if (!isArray(existing)) {
  6240. if (_isString) {
  6241. refs[ref] = [refValue];
  6242. setSetupRef(vm, ref, refs[ref]);
  6243. }
  6244. else {
  6245. ref.value = [refValue];
  6246. }
  6247. }
  6248. else if (!existing.includes(refValue)) {
  6249. existing.push(refValue);
  6250. }
  6251. }
  6252. }
  6253. else if (_isString) {
  6254. if (isRemoval && refs[ref] !== refValue) {
  6255. return;
  6256. }
  6257. refs[ref] = $refsValue;
  6258. setSetupRef(vm, ref, value);
  6259. }
  6260. else if (_isRef) {
  6261. if (isRemoval && ref.value !== refValue) {
  6262. return;
  6263. }
  6264. ref.value = value;
  6265. }
  6266. else {
  6267. warn$2(`Invalid template ref type: ${typeof ref}`);
  6268. }
  6269. }
  6270. }
  6271. function setSetupRef({ _setupState }, key, val) {
  6272. if (_setupState && hasOwn(_setupState, key)) {
  6273. if (isRef(_setupState[key])) {
  6274. _setupState[key].value = val;
  6275. }
  6276. else {
  6277. _setupState[key] = val;
  6278. }
  6279. }
  6280. }
  6281. /**
  6282. * Virtual DOM patching algorithm based on Snabbdom by
  6283. * Simon Friis Vindum (@paldepind)
  6284. * Licensed under the MIT License
  6285. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6286. *
  6287. * modified by Evan You (@yyx990803)
  6288. *
  6289. * Not type-checking this because this file is perf-critical and the cost
  6290. * of making flow understand it is not worth it.
  6291. */
  6292. const emptyNode = new VNode('', {}, []);
  6293. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6294. function sameVnode(a, b) {
  6295. return (a.key === b.key &&
  6296. a.asyncFactory === b.asyncFactory &&
  6297. ((a.tag === b.tag &&
  6298. a.isComment === b.isComment &&
  6299. isDef(a.data) === isDef(b.data) &&
  6300. sameInputType(a, b)) ||
  6301. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6302. }
  6303. function sameInputType(a, b) {
  6304. if (a.tag !== 'input')
  6305. return true;
  6306. let i;
  6307. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6308. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6309. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6310. }
  6311. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6312. let i, key;
  6313. const map = {};
  6314. for (i = beginIdx; i <= endIdx; ++i) {
  6315. key = children[i].key;
  6316. if (isDef(key))
  6317. map[key] = i;
  6318. }
  6319. return map;
  6320. }
  6321. function createPatchFunction(backend) {
  6322. let i, j;
  6323. const cbs = {};
  6324. const { modules, nodeOps } = backend;
  6325. for (i = 0; i < hooks.length; ++i) {
  6326. cbs[hooks[i]] = [];
  6327. for (j = 0; j < modules.length; ++j) {
  6328. if (isDef(modules[j][hooks[i]])) {
  6329. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6330. }
  6331. }
  6332. }
  6333. function emptyNodeAt(elm) {
  6334. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6335. }
  6336. function createRmCb(childElm, listeners) {
  6337. function remove() {
  6338. if (--remove.listeners === 0) {
  6339. removeNode(childElm);
  6340. }
  6341. }
  6342. remove.listeners = listeners;
  6343. return remove;
  6344. }
  6345. function removeNode(el) {
  6346. const parent = nodeOps.parentNode(el);
  6347. // element may have already been removed due to v-html / v-text
  6348. if (isDef(parent)) {
  6349. nodeOps.removeChild(parent, el);
  6350. }
  6351. }
  6352. function isUnknownElement(vnode, inVPre) {
  6353. return (!inVPre &&
  6354. !vnode.ns &&
  6355. !(config.ignoredElements.length &&
  6356. config.ignoredElements.some(ignore => {
  6357. return isRegExp(ignore)
  6358. ? ignore.test(vnode.tag)
  6359. : ignore === vnode.tag;
  6360. })) &&
  6361. config.isUnknownElement(vnode.tag));
  6362. }
  6363. let creatingElmInVPre = 0;
  6364. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6365. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6366. // This vnode was used in a previous render!
  6367. // now it's used as a new node, overwriting its elm would cause
  6368. // potential patch errors down the road when it's used as an insertion
  6369. // reference node. Instead, we clone the node on-demand before creating
  6370. // associated DOM element for it.
  6371. vnode = ownerArray[index] = cloneVNode(vnode);
  6372. }
  6373. vnode.isRootInsert = !nested; // for transition enter check
  6374. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6375. return;
  6376. }
  6377. const data = vnode.data;
  6378. const children = vnode.children;
  6379. const tag = vnode.tag;
  6380. if (isDef(tag)) {
  6381. {
  6382. if (data && data.pre) {
  6383. creatingElmInVPre++;
  6384. }
  6385. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6386. warn$2('Unknown custom element: <' +
  6387. tag +
  6388. '> - did you ' +
  6389. 'register the component correctly? For recursive components, ' +
  6390. 'make sure to provide the "name" option.', vnode.context);
  6391. }
  6392. }
  6393. vnode.elm = vnode.ns
  6394. ? nodeOps.createElementNS(vnode.ns, tag)
  6395. : nodeOps.createElement(tag, vnode);
  6396. setScope(vnode);
  6397. createChildren(vnode, children, insertedVnodeQueue);
  6398. if (isDef(data)) {
  6399. invokeCreateHooks(vnode, insertedVnodeQueue);
  6400. }
  6401. insert(parentElm, vnode.elm, refElm);
  6402. if (data && data.pre) {
  6403. creatingElmInVPre--;
  6404. }
  6405. }
  6406. else if (isTrue(vnode.isComment)) {
  6407. vnode.elm = nodeOps.createComment(vnode.text);
  6408. insert(parentElm, vnode.elm, refElm);
  6409. }
  6410. else {
  6411. vnode.elm = nodeOps.createTextNode(vnode.text);
  6412. insert(parentElm, vnode.elm, refElm);
  6413. }
  6414. }
  6415. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6416. let i = vnode.data;
  6417. if (isDef(i)) {
  6418. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6419. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6420. i(vnode, false /* hydrating */);
  6421. }
  6422. // after calling the init hook, if the vnode is a child component
  6423. // it should've created a child instance and mounted it. the child
  6424. // component also has set the placeholder vnode's elm.
  6425. // in that case we can just return the element and be done.
  6426. if (isDef(vnode.componentInstance)) {
  6427. initComponent(vnode, insertedVnodeQueue);
  6428. insert(parentElm, vnode.elm, refElm);
  6429. if (isTrue(isReactivated)) {
  6430. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6431. }
  6432. return true;
  6433. }
  6434. }
  6435. }
  6436. function initComponent(vnode, insertedVnodeQueue) {
  6437. if (isDef(vnode.data.pendingInsert)) {
  6438. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6439. vnode.data.pendingInsert = null;
  6440. }
  6441. vnode.elm = vnode.componentInstance.$el;
  6442. if (isPatchable(vnode)) {
  6443. invokeCreateHooks(vnode, insertedVnodeQueue);
  6444. setScope(vnode);
  6445. }
  6446. else {
  6447. // empty component root.
  6448. // skip all element-related modules except for ref (#3455)
  6449. registerRef(vnode);
  6450. // make sure to invoke the insert hook
  6451. insertedVnodeQueue.push(vnode);
  6452. }
  6453. }
  6454. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6455. let i;
  6456. // hack for #4339: a reactivated component with inner transition
  6457. // does not trigger because the inner node's created hooks are not called
  6458. // again. It's not ideal to involve module-specific logic in here but
  6459. // there doesn't seem to be a better way to do it.
  6460. let innerNode = vnode;
  6461. while (innerNode.componentInstance) {
  6462. innerNode = innerNode.componentInstance._vnode;
  6463. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6464. for (i = 0; i < cbs.activate.length; ++i) {
  6465. cbs.activate[i](emptyNode, innerNode);
  6466. }
  6467. insertedVnodeQueue.push(innerNode);
  6468. break;
  6469. }
  6470. }
  6471. // unlike a newly created component,
  6472. // a reactivated keep-alive component doesn't insert itself
  6473. insert(parentElm, vnode.elm, refElm);
  6474. }
  6475. function insert(parent, elm, ref) {
  6476. if (isDef(parent)) {
  6477. if (isDef(ref)) {
  6478. if (nodeOps.parentNode(ref) === parent) {
  6479. nodeOps.insertBefore(parent, elm, ref);
  6480. }
  6481. }
  6482. else {
  6483. nodeOps.appendChild(parent, elm);
  6484. }
  6485. }
  6486. }
  6487. function createChildren(vnode, children, insertedVnodeQueue) {
  6488. if (isArray(children)) {
  6489. {
  6490. checkDuplicateKeys(children);
  6491. }
  6492. for (let i = 0; i < children.length; ++i) {
  6493. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6494. }
  6495. }
  6496. else if (isPrimitive(vnode.text)) {
  6497. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6498. }
  6499. }
  6500. function isPatchable(vnode) {
  6501. while (vnode.componentInstance) {
  6502. vnode = vnode.componentInstance._vnode;
  6503. }
  6504. return isDef(vnode.tag);
  6505. }
  6506. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6507. for (let i = 0; i < cbs.create.length; ++i) {
  6508. cbs.create[i](emptyNode, vnode);
  6509. }
  6510. i = vnode.data.hook; // Reuse variable
  6511. if (isDef(i)) {
  6512. if (isDef(i.create))
  6513. i.create(emptyNode, vnode);
  6514. if (isDef(i.insert))
  6515. insertedVnodeQueue.push(vnode);
  6516. }
  6517. }
  6518. // set scope id attribute for scoped CSS.
  6519. // this is implemented as a special case to avoid the overhead
  6520. // of going through the normal attribute patching process.
  6521. function setScope(vnode) {
  6522. let i;
  6523. if (isDef((i = vnode.fnScopeId))) {
  6524. nodeOps.setStyleScope(vnode.elm, i);
  6525. }
  6526. else {
  6527. let ancestor = vnode;
  6528. while (ancestor) {
  6529. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6530. nodeOps.setStyleScope(vnode.elm, i);
  6531. }
  6532. ancestor = ancestor.parent;
  6533. }
  6534. }
  6535. // for slot content they should also get the scopeId from the host instance.
  6536. if (isDef((i = activeInstance)) &&
  6537. i !== vnode.context &&
  6538. i !== vnode.fnContext &&
  6539. isDef((i = i.$options._scopeId))) {
  6540. nodeOps.setStyleScope(vnode.elm, i);
  6541. }
  6542. }
  6543. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6544. for (; startIdx <= endIdx; ++startIdx) {
  6545. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6546. }
  6547. }
  6548. function invokeDestroyHook(vnode) {
  6549. let i, j;
  6550. const data = vnode.data;
  6551. if (isDef(data)) {
  6552. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6553. i(vnode);
  6554. for (i = 0; i < cbs.destroy.length; ++i)
  6555. cbs.destroy[i](vnode);
  6556. }
  6557. if (isDef((i = vnode.children))) {
  6558. for (j = 0; j < vnode.children.length; ++j) {
  6559. invokeDestroyHook(vnode.children[j]);
  6560. }
  6561. }
  6562. }
  6563. function removeVnodes(vnodes, startIdx, endIdx) {
  6564. for (; startIdx <= endIdx; ++startIdx) {
  6565. const ch = vnodes[startIdx];
  6566. if (isDef(ch)) {
  6567. if (isDef(ch.tag)) {
  6568. removeAndInvokeRemoveHook(ch);
  6569. invokeDestroyHook(ch);
  6570. }
  6571. else {
  6572. // Text node
  6573. removeNode(ch.elm);
  6574. }
  6575. }
  6576. }
  6577. }
  6578. function removeAndInvokeRemoveHook(vnode, rm) {
  6579. if (isDef(rm) || isDef(vnode.data)) {
  6580. let i;
  6581. const listeners = cbs.remove.length + 1;
  6582. if (isDef(rm)) {
  6583. // we have a recursively passed down rm callback
  6584. // increase the listeners count
  6585. rm.listeners += listeners;
  6586. }
  6587. else {
  6588. // directly removing
  6589. rm = createRmCb(vnode.elm, listeners);
  6590. }
  6591. // recursively invoke hooks on child component root node
  6592. if (isDef((i = vnode.componentInstance)) &&
  6593. isDef((i = i._vnode)) &&
  6594. isDef(i.data)) {
  6595. removeAndInvokeRemoveHook(i, rm);
  6596. }
  6597. for (i = 0; i < cbs.remove.length; ++i) {
  6598. cbs.remove[i](vnode, rm);
  6599. }
  6600. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6601. i(vnode, rm);
  6602. }
  6603. else {
  6604. rm();
  6605. }
  6606. }
  6607. else {
  6608. removeNode(vnode.elm);
  6609. }
  6610. }
  6611. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6612. let oldStartIdx = 0;
  6613. let newStartIdx = 0;
  6614. let oldEndIdx = oldCh.length - 1;
  6615. let oldStartVnode = oldCh[0];
  6616. let oldEndVnode = oldCh[oldEndIdx];
  6617. let newEndIdx = newCh.length - 1;
  6618. let newStartVnode = newCh[0];
  6619. let newEndVnode = newCh[newEndIdx];
  6620. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6621. // removeOnly is a special flag used only by <transition-group>
  6622. // to ensure removed elements stay in correct relative positions
  6623. // during leaving transitions
  6624. const canMove = !removeOnly;
  6625. {
  6626. checkDuplicateKeys(newCh);
  6627. }
  6628. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6629. if (isUndef(oldStartVnode)) {
  6630. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6631. }
  6632. else if (isUndef(oldEndVnode)) {
  6633. oldEndVnode = oldCh[--oldEndIdx];
  6634. }
  6635. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6636. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6637. oldStartVnode = oldCh[++oldStartIdx];
  6638. newStartVnode = newCh[++newStartIdx];
  6639. }
  6640. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6641. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6642. oldEndVnode = oldCh[--oldEndIdx];
  6643. newEndVnode = newCh[--newEndIdx];
  6644. }
  6645. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6646. // Vnode moved right
  6647. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6648. canMove &&
  6649. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6650. oldStartVnode = oldCh[++oldStartIdx];
  6651. newEndVnode = newCh[--newEndIdx];
  6652. }
  6653. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6654. // Vnode moved left
  6655. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6656. canMove &&
  6657. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6658. oldEndVnode = oldCh[--oldEndIdx];
  6659. newStartVnode = newCh[++newStartIdx];
  6660. }
  6661. else {
  6662. if (isUndef(oldKeyToIdx))
  6663. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6664. idxInOld = isDef(newStartVnode.key)
  6665. ? oldKeyToIdx[newStartVnode.key]
  6666. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6667. if (isUndef(idxInOld)) {
  6668. // New element
  6669. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6670. }
  6671. else {
  6672. vnodeToMove = oldCh[idxInOld];
  6673. if (sameVnode(vnodeToMove, newStartVnode)) {
  6674. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6675. oldCh[idxInOld] = undefined;
  6676. canMove &&
  6677. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6678. }
  6679. else {
  6680. // same key but different element. treat as new element
  6681. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6682. }
  6683. }
  6684. newStartVnode = newCh[++newStartIdx];
  6685. }
  6686. }
  6687. if (oldStartIdx > oldEndIdx) {
  6688. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6689. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6690. }
  6691. else if (newStartIdx > newEndIdx) {
  6692. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6693. }
  6694. }
  6695. function checkDuplicateKeys(children) {
  6696. const seenKeys = {};
  6697. for (let i = 0; i < children.length; i++) {
  6698. const vnode = children[i];
  6699. const key = vnode.key;
  6700. if (isDef(key)) {
  6701. if (seenKeys[key]) {
  6702. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6703. }
  6704. else {
  6705. seenKeys[key] = true;
  6706. }
  6707. }
  6708. }
  6709. }
  6710. function findIdxInOld(node, oldCh, start, end) {
  6711. for (let i = start; i < end; i++) {
  6712. const c = oldCh[i];
  6713. if (isDef(c) && sameVnode(node, c))
  6714. return i;
  6715. }
  6716. }
  6717. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6718. if (oldVnode === vnode) {
  6719. return;
  6720. }
  6721. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6722. // clone reused vnode
  6723. vnode = ownerArray[index] = cloneVNode(vnode);
  6724. }
  6725. const elm = (vnode.elm = oldVnode.elm);
  6726. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6727. if (isDef(vnode.asyncFactory.resolved)) {
  6728. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6729. }
  6730. else {
  6731. vnode.isAsyncPlaceholder = true;
  6732. }
  6733. return;
  6734. }
  6735. // reuse element for static trees.
  6736. // note we only do this if the vnode is cloned -
  6737. // if the new node is not cloned it means the render functions have been
  6738. // reset by the hot-reload-api and we need to do a proper re-render.
  6739. if (isTrue(vnode.isStatic) &&
  6740. isTrue(oldVnode.isStatic) &&
  6741. vnode.key === oldVnode.key &&
  6742. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6743. vnode.componentInstance = oldVnode.componentInstance;
  6744. return;
  6745. }
  6746. let i;
  6747. const data = vnode.data;
  6748. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6749. i(oldVnode, vnode);
  6750. }
  6751. const oldCh = oldVnode.children;
  6752. const ch = vnode.children;
  6753. if (isDef(data) && isPatchable(vnode)) {
  6754. for (i = 0; i < cbs.update.length; ++i)
  6755. cbs.update[i](oldVnode, vnode);
  6756. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6757. i(oldVnode, vnode);
  6758. }
  6759. if (isUndef(vnode.text)) {
  6760. if (isDef(oldCh) && isDef(ch)) {
  6761. if (oldCh !== ch)
  6762. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6763. }
  6764. else if (isDef(ch)) {
  6765. {
  6766. checkDuplicateKeys(ch);
  6767. }
  6768. if (isDef(oldVnode.text))
  6769. nodeOps.setTextContent(elm, '');
  6770. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6771. }
  6772. else if (isDef(oldCh)) {
  6773. removeVnodes(oldCh, 0, oldCh.length - 1);
  6774. }
  6775. else if (isDef(oldVnode.text)) {
  6776. nodeOps.setTextContent(elm, '');
  6777. }
  6778. }
  6779. else if (oldVnode.text !== vnode.text) {
  6780. nodeOps.setTextContent(elm, vnode.text);
  6781. }
  6782. if (isDef(data)) {
  6783. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6784. i(oldVnode, vnode);
  6785. }
  6786. }
  6787. function invokeInsertHook(vnode, queue, initial) {
  6788. // delay insert hooks for component root nodes, invoke them after the
  6789. // element is really inserted
  6790. if (isTrue(initial) && isDef(vnode.parent)) {
  6791. vnode.parent.data.pendingInsert = queue;
  6792. }
  6793. else {
  6794. for (let i = 0; i < queue.length; ++i) {
  6795. queue[i].data.hook.insert(queue[i]);
  6796. }
  6797. }
  6798. }
  6799. let hydrationBailed = false;
  6800. // list of modules that can skip create hook during hydration because they
  6801. // are already rendered on the client or has no need for initialization
  6802. // Note: style is excluded because it relies on initial clone for future
  6803. // deep updates (#7063).
  6804. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6805. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6806. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6807. let i;
  6808. const { tag, data, children } = vnode;
  6809. inVPre = inVPre || (data && data.pre);
  6810. vnode.elm = elm;
  6811. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6812. vnode.isAsyncPlaceholder = true;
  6813. return true;
  6814. }
  6815. // assert node match
  6816. {
  6817. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6818. return false;
  6819. }
  6820. }
  6821. if (isDef(data)) {
  6822. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6823. i(vnode, true /* hydrating */);
  6824. if (isDef((i = vnode.componentInstance))) {
  6825. // child component. it should have hydrated its own tree.
  6826. initComponent(vnode, insertedVnodeQueue);
  6827. return true;
  6828. }
  6829. }
  6830. if (isDef(tag)) {
  6831. if (isDef(children)) {
  6832. // empty element, allow client to pick up and populate children
  6833. if (!elm.hasChildNodes()) {
  6834. createChildren(vnode, children, insertedVnodeQueue);
  6835. }
  6836. else {
  6837. // v-html and domProps: innerHTML
  6838. if (isDef((i = data)) &&
  6839. isDef((i = i.domProps)) &&
  6840. isDef((i = i.innerHTML))) {
  6841. if (i !== elm.innerHTML) {
  6842. /* istanbul ignore if */
  6843. if (typeof console !== 'undefined' &&
  6844. !hydrationBailed) {
  6845. hydrationBailed = true;
  6846. console.warn('Parent: ', elm);
  6847. console.warn('server innerHTML: ', i);
  6848. console.warn('client innerHTML: ', elm.innerHTML);
  6849. }
  6850. return false;
  6851. }
  6852. }
  6853. else {
  6854. // iterate and compare children lists
  6855. let childrenMatch = true;
  6856. let childNode = elm.firstChild;
  6857. for (let i = 0; i < children.length; i++) {
  6858. if (!childNode ||
  6859. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6860. childrenMatch = false;
  6861. break;
  6862. }
  6863. childNode = childNode.nextSibling;
  6864. }
  6865. // if childNode is not null, it means the actual childNodes list is
  6866. // longer than the virtual children list.
  6867. if (!childrenMatch || childNode) {
  6868. /* istanbul ignore if */
  6869. if (typeof console !== 'undefined' &&
  6870. !hydrationBailed) {
  6871. hydrationBailed = true;
  6872. console.warn('Parent: ', elm);
  6873. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6874. }
  6875. return false;
  6876. }
  6877. }
  6878. }
  6879. }
  6880. if (isDef(data)) {
  6881. let fullInvoke = false;
  6882. for (const key in data) {
  6883. if (!isRenderedModule(key)) {
  6884. fullInvoke = true;
  6885. invokeCreateHooks(vnode, insertedVnodeQueue);
  6886. break;
  6887. }
  6888. }
  6889. if (!fullInvoke && data['class']) {
  6890. // ensure collecting deps for deep class bindings for future updates
  6891. traverse(data['class']);
  6892. }
  6893. }
  6894. }
  6895. else if (elm.data !== vnode.text) {
  6896. elm.data = vnode.text;
  6897. }
  6898. return true;
  6899. }
  6900. function assertNodeMatch(node, vnode, inVPre) {
  6901. if (isDef(vnode.tag)) {
  6902. return (vnode.tag.indexOf('vue-component') === 0 ||
  6903. (!isUnknownElement(vnode, inVPre) &&
  6904. vnode.tag.toLowerCase() ===
  6905. (node.tagName && node.tagName.toLowerCase())));
  6906. }
  6907. else {
  6908. return node.nodeType === (vnode.isComment ? 8 : 3);
  6909. }
  6910. }
  6911. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6912. if (isUndef(vnode)) {
  6913. if (isDef(oldVnode))
  6914. invokeDestroyHook(oldVnode);
  6915. return;
  6916. }
  6917. let isInitialPatch = false;
  6918. const insertedVnodeQueue = [];
  6919. if (isUndef(oldVnode)) {
  6920. // empty mount (likely as component), create new root element
  6921. isInitialPatch = true;
  6922. createElm(vnode, insertedVnodeQueue);
  6923. }
  6924. else {
  6925. const isRealElement = isDef(oldVnode.nodeType);
  6926. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6927. // patch existing root node
  6928. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6929. }
  6930. else {
  6931. if (isRealElement) {
  6932. // mounting to a real element
  6933. // check if this is server-rendered content and if we can perform
  6934. // a successful hydration.
  6935. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6936. oldVnode.removeAttribute(SSR_ATTR);
  6937. hydrating = true;
  6938. }
  6939. if (isTrue(hydrating)) {
  6940. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6941. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6942. return oldVnode;
  6943. }
  6944. else {
  6945. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6946. 'server-rendered content. This is likely caused by incorrect ' +
  6947. 'HTML markup, for example nesting block-level elements inside ' +
  6948. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6949. 'full client-side render.');
  6950. }
  6951. }
  6952. // either not server-rendered, or hydration failed.
  6953. // create an empty node and replace it
  6954. oldVnode = emptyNodeAt(oldVnode);
  6955. }
  6956. // replacing existing element
  6957. const oldElm = oldVnode.elm;
  6958. const parentElm = nodeOps.parentNode(oldElm);
  6959. // create new node
  6960. createElm(vnode, insertedVnodeQueue,
  6961. // extremely rare edge case: do not insert if old element is in a
  6962. // leaving transition. Only happens when combining transition +
  6963. // keep-alive + HOCs. (#4590)
  6964. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6965. // update parent placeholder node element, recursively
  6966. if (isDef(vnode.parent)) {
  6967. let ancestor = vnode.parent;
  6968. const patchable = isPatchable(vnode);
  6969. while (ancestor) {
  6970. for (let i = 0; i < cbs.destroy.length; ++i) {
  6971. cbs.destroy[i](ancestor);
  6972. }
  6973. ancestor.elm = vnode.elm;
  6974. if (patchable) {
  6975. for (let i = 0; i < cbs.create.length; ++i) {
  6976. cbs.create[i](emptyNode, ancestor);
  6977. }
  6978. // #6513
  6979. // invoke insert hooks that may have been merged by create hooks.
  6980. // e.g. for directives that uses the "inserted" hook.
  6981. const insert = ancestor.data.hook.insert;
  6982. if (insert.merged) {
  6983. // start at index 1 to avoid re-invoking component mounted hook
  6984. for (let i = 1; i < insert.fns.length; i++) {
  6985. insert.fns[i]();
  6986. }
  6987. }
  6988. }
  6989. else {
  6990. registerRef(ancestor);
  6991. }
  6992. ancestor = ancestor.parent;
  6993. }
  6994. }
  6995. // destroy old node
  6996. if (isDef(parentElm)) {
  6997. removeVnodes([oldVnode], 0, 0);
  6998. }
  6999. else if (isDef(oldVnode.tag)) {
  7000. invokeDestroyHook(oldVnode);
  7001. }
  7002. }
  7003. }
  7004. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  7005. return vnode.elm;
  7006. };
  7007. }
  7008. var directives$1 = {
  7009. create: updateDirectives,
  7010. update: updateDirectives,
  7011. destroy: function unbindDirectives(vnode) {
  7012. // @ts-expect-error emptyNode is not VNodeWithData
  7013. updateDirectives(vnode, emptyNode);
  7014. }
  7015. };
  7016. function updateDirectives(oldVnode, vnode) {
  7017. if (oldVnode.data.directives || vnode.data.directives) {
  7018. _update(oldVnode, vnode);
  7019. }
  7020. }
  7021. function _update(oldVnode, vnode) {
  7022. const isCreate = oldVnode === emptyNode;
  7023. const isDestroy = vnode === emptyNode;
  7024. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7025. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7026. const dirsWithInsert = [];
  7027. const dirsWithPostpatch = [];
  7028. let key, oldDir, dir;
  7029. for (key in newDirs) {
  7030. oldDir = oldDirs[key];
  7031. dir = newDirs[key];
  7032. if (!oldDir) {
  7033. // new directive, bind
  7034. callHook(dir, 'bind', vnode, oldVnode);
  7035. if (dir.def && dir.def.inserted) {
  7036. dirsWithInsert.push(dir);
  7037. }
  7038. }
  7039. else {
  7040. // existing directive, update
  7041. dir.oldValue = oldDir.value;
  7042. dir.oldArg = oldDir.arg;
  7043. callHook(dir, 'update', vnode, oldVnode);
  7044. if (dir.def && dir.def.componentUpdated) {
  7045. dirsWithPostpatch.push(dir);
  7046. }
  7047. }
  7048. }
  7049. if (dirsWithInsert.length) {
  7050. const callInsert = () => {
  7051. for (let i = 0; i < dirsWithInsert.length; i++) {
  7052. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7053. }
  7054. };
  7055. if (isCreate) {
  7056. mergeVNodeHook(vnode, 'insert', callInsert);
  7057. }
  7058. else {
  7059. callInsert();
  7060. }
  7061. }
  7062. if (dirsWithPostpatch.length) {
  7063. mergeVNodeHook(vnode, 'postpatch', () => {
  7064. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7065. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7066. }
  7067. });
  7068. }
  7069. if (!isCreate) {
  7070. for (key in oldDirs) {
  7071. if (!newDirs[key]) {
  7072. // no longer present, unbind
  7073. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7074. }
  7075. }
  7076. }
  7077. }
  7078. const emptyModifiers = Object.create(null);
  7079. function normalizeDirectives(dirs, vm) {
  7080. const res = Object.create(null);
  7081. if (!dirs) {
  7082. // $flow-disable-line
  7083. return res;
  7084. }
  7085. let i, dir;
  7086. for (i = 0; i < dirs.length; i++) {
  7087. dir = dirs[i];
  7088. if (!dir.modifiers) {
  7089. // $flow-disable-line
  7090. dir.modifiers = emptyModifiers;
  7091. }
  7092. res[getRawDirName(dir)] = dir;
  7093. if (vm._setupState && vm._setupState.__sfc) {
  7094. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7095. if (typeof setupDef === 'function') {
  7096. dir.def = {
  7097. bind: setupDef,
  7098. update: setupDef,
  7099. };
  7100. }
  7101. else {
  7102. dir.def = setupDef;
  7103. }
  7104. }
  7105. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7106. }
  7107. // $flow-disable-line
  7108. return res;
  7109. }
  7110. function getRawDirName(dir) {
  7111. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7112. }
  7113. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7114. const fn = dir.def && dir.def[hook];
  7115. if (fn) {
  7116. try {
  7117. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7118. }
  7119. catch (e) {
  7120. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7121. }
  7122. }
  7123. }
  7124. var baseModules = [ref, directives$1];
  7125. function updateAttrs(oldVnode, vnode) {
  7126. const opts = vnode.componentOptions;
  7127. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7128. return;
  7129. }
  7130. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7131. return;
  7132. }
  7133. let key, cur, old;
  7134. const elm = vnode.elm;
  7135. const oldAttrs = oldVnode.data.attrs || {};
  7136. let attrs = vnode.data.attrs || {};
  7137. // clone observed objects, as the user probably wants to mutate it
  7138. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7139. attrs = vnode.data.attrs = extend({}, attrs);
  7140. }
  7141. for (key in attrs) {
  7142. cur = attrs[key];
  7143. old = oldAttrs[key];
  7144. if (old !== cur) {
  7145. setAttr(elm, key, cur, vnode.data.pre);
  7146. }
  7147. }
  7148. // #4391: in IE9, setting type can reset value for input[type=radio]
  7149. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7150. /* istanbul ignore if */
  7151. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7152. setAttr(elm, 'value', attrs.value);
  7153. }
  7154. for (key in oldAttrs) {
  7155. if (isUndef(attrs[key])) {
  7156. if (isXlink(key)) {
  7157. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7158. }
  7159. else if (!isEnumeratedAttr(key)) {
  7160. elm.removeAttribute(key);
  7161. }
  7162. }
  7163. }
  7164. }
  7165. function setAttr(el, key, value, isInPre) {
  7166. if (isInPre || el.tagName.indexOf('-') > -1) {
  7167. baseSetAttr(el, key, value);
  7168. }
  7169. else if (isBooleanAttr(key)) {
  7170. // set attribute for blank value
  7171. // e.g. <option disabled>Select one</option>
  7172. if (isFalsyAttrValue(value)) {
  7173. el.removeAttribute(key);
  7174. }
  7175. else {
  7176. // technically allowfullscreen is a boolean attribute for <iframe>,
  7177. // but Flash expects a value of "true" when used on <embed> tag
  7178. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7179. el.setAttribute(key, value);
  7180. }
  7181. }
  7182. else if (isEnumeratedAttr(key)) {
  7183. el.setAttribute(key, convertEnumeratedValue(key, value));
  7184. }
  7185. else if (isXlink(key)) {
  7186. if (isFalsyAttrValue(value)) {
  7187. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7188. }
  7189. else {
  7190. el.setAttributeNS(xlinkNS, key, value);
  7191. }
  7192. }
  7193. else {
  7194. baseSetAttr(el, key, value);
  7195. }
  7196. }
  7197. function baseSetAttr(el, key, value) {
  7198. if (isFalsyAttrValue(value)) {
  7199. el.removeAttribute(key);
  7200. }
  7201. else {
  7202. // #7138: IE10 & 11 fires input event when setting placeholder on
  7203. // <textarea>... block the first input event and remove the blocker
  7204. // immediately.
  7205. /* istanbul ignore if */
  7206. if (isIE &&
  7207. !isIE9 &&
  7208. el.tagName === 'TEXTAREA' &&
  7209. key === 'placeholder' &&
  7210. value !== '' &&
  7211. !el.__ieph) {
  7212. const blocker = e => {
  7213. e.stopImmediatePropagation();
  7214. el.removeEventListener('input', blocker);
  7215. };
  7216. el.addEventListener('input', blocker);
  7217. // $flow-disable-line
  7218. el.__ieph = true; /* IE placeholder patched */
  7219. }
  7220. el.setAttribute(key, value);
  7221. }
  7222. }
  7223. var attrs = {
  7224. create: updateAttrs,
  7225. update: updateAttrs
  7226. };
  7227. function updateClass(oldVnode, vnode) {
  7228. const el = vnode.elm;
  7229. const data = vnode.data;
  7230. const oldData = oldVnode.data;
  7231. if (isUndef(data.staticClass) &&
  7232. isUndef(data.class) &&
  7233. (isUndef(oldData) ||
  7234. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7235. return;
  7236. }
  7237. let cls = genClassForVnode(vnode);
  7238. // handle transition classes
  7239. const transitionClass = el._transitionClasses;
  7240. if (isDef(transitionClass)) {
  7241. cls = concat(cls, stringifyClass(transitionClass));
  7242. }
  7243. // set the class
  7244. if (cls !== el._prevClass) {
  7245. el.setAttribute('class', cls);
  7246. el._prevClass = cls;
  7247. }
  7248. }
  7249. var klass$1 = {
  7250. create: updateClass,
  7251. update: updateClass
  7252. };
  7253. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7254. function parseFilters(exp) {
  7255. let inSingle = false;
  7256. let inDouble = false;
  7257. let inTemplateString = false;
  7258. let inRegex = false;
  7259. let curly = 0;
  7260. let square = 0;
  7261. let paren = 0;
  7262. let lastFilterIndex = 0;
  7263. let c, prev, i, expression, filters;
  7264. for (i = 0; i < exp.length; i++) {
  7265. prev = c;
  7266. c = exp.charCodeAt(i);
  7267. if (inSingle) {
  7268. if (c === 0x27 && prev !== 0x5c)
  7269. inSingle = false;
  7270. }
  7271. else if (inDouble) {
  7272. if (c === 0x22 && prev !== 0x5c)
  7273. inDouble = false;
  7274. }
  7275. else if (inTemplateString) {
  7276. if (c === 0x60 && prev !== 0x5c)
  7277. inTemplateString = false;
  7278. }
  7279. else if (inRegex) {
  7280. if (c === 0x2f && prev !== 0x5c)
  7281. inRegex = false;
  7282. }
  7283. else if (c === 0x7c && // pipe
  7284. exp.charCodeAt(i + 1) !== 0x7c &&
  7285. exp.charCodeAt(i - 1) !== 0x7c &&
  7286. !curly &&
  7287. !square &&
  7288. !paren) {
  7289. if (expression === undefined) {
  7290. // first filter, end of expression
  7291. lastFilterIndex = i + 1;
  7292. expression = exp.slice(0, i).trim();
  7293. }
  7294. else {
  7295. pushFilter();
  7296. }
  7297. }
  7298. else {
  7299. switch (c) {
  7300. case 0x22:
  7301. inDouble = true;
  7302. break; // "
  7303. case 0x27:
  7304. inSingle = true;
  7305. break; // '
  7306. case 0x60:
  7307. inTemplateString = true;
  7308. break; // `
  7309. case 0x28:
  7310. paren++;
  7311. break; // (
  7312. case 0x29:
  7313. paren--;
  7314. break; // )
  7315. case 0x5b:
  7316. square++;
  7317. break; // [
  7318. case 0x5d:
  7319. square--;
  7320. break; // ]
  7321. case 0x7b:
  7322. curly++;
  7323. break; // {
  7324. case 0x7d:
  7325. curly--;
  7326. break; // }
  7327. }
  7328. if (c === 0x2f) {
  7329. // /
  7330. let j = i - 1;
  7331. let p;
  7332. // find first non-whitespace prev char
  7333. for (; j >= 0; j--) {
  7334. p = exp.charAt(j);
  7335. if (p !== ' ')
  7336. break;
  7337. }
  7338. if (!p || !validDivisionCharRE.test(p)) {
  7339. inRegex = true;
  7340. }
  7341. }
  7342. }
  7343. }
  7344. if (expression === undefined) {
  7345. expression = exp.slice(0, i).trim();
  7346. }
  7347. else if (lastFilterIndex !== 0) {
  7348. pushFilter();
  7349. }
  7350. function pushFilter() {
  7351. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7352. lastFilterIndex = i + 1;
  7353. }
  7354. if (filters) {
  7355. for (i = 0; i < filters.length; i++) {
  7356. expression = wrapFilter(expression, filters[i]);
  7357. }
  7358. }
  7359. return expression;
  7360. }
  7361. function wrapFilter(exp, filter) {
  7362. const i = filter.indexOf('(');
  7363. if (i < 0) {
  7364. // _f: resolveFilter
  7365. return `_f("${filter}")(${exp})`;
  7366. }
  7367. else {
  7368. const name = filter.slice(0, i);
  7369. const args = filter.slice(i + 1);
  7370. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7371. }
  7372. }
  7373. /* eslint-disable no-unused-vars */
  7374. function baseWarn(msg, range) {
  7375. console.error(`[Vue compiler]: ${msg}`);
  7376. }
  7377. /* eslint-enable no-unused-vars */
  7378. function pluckModuleFunction(modules, key) {
  7379. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7380. }
  7381. function addProp(el, name, value, range, dynamic) {
  7382. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7383. el.plain = false;
  7384. }
  7385. function addAttr(el, name, value, range, dynamic) {
  7386. const attrs = dynamic
  7387. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7388. : el.attrs || (el.attrs = []);
  7389. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7390. el.plain = false;
  7391. }
  7392. // add a raw attr (use this in preTransforms)
  7393. function addRawAttr(el, name, value, range) {
  7394. el.attrsMap[name] = value;
  7395. el.attrsList.push(rangeSetItem({ name, value }, range));
  7396. }
  7397. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7398. (el.directives || (el.directives = [])).push(rangeSetItem({
  7399. name,
  7400. rawName,
  7401. value,
  7402. arg,
  7403. isDynamicArg,
  7404. modifiers
  7405. }, range));
  7406. el.plain = false;
  7407. }
  7408. function prependModifierMarker(symbol, name, dynamic) {
  7409. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7410. }
  7411. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7412. modifiers = modifiers || emptyObject;
  7413. // warn prevent and passive modifier
  7414. /* istanbul ignore if */
  7415. if (warn && modifiers.prevent && modifiers.passive) {
  7416. warn("passive and prevent can't be used together. " +
  7417. "Passive handler can't prevent default event.", range);
  7418. }
  7419. // normalize click.right and click.middle since they don't actually fire
  7420. // this is technically browser-specific, but at least for now browsers are
  7421. // the only target envs that have right/middle clicks.
  7422. if (modifiers.right) {
  7423. if (dynamic) {
  7424. name = `(${name})==='click'?'contextmenu':(${name})`;
  7425. }
  7426. else if (name === 'click') {
  7427. name = 'contextmenu';
  7428. delete modifiers.right;
  7429. }
  7430. }
  7431. else if (modifiers.middle) {
  7432. if (dynamic) {
  7433. name = `(${name})==='click'?'mouseup':(${name})`;
  7434. }
  7435. else if (name === 'click') {
  7436. name = 'mouseup';
  7437. }
  7438. }
  7439. // check capture modifier
  7440. if (modifiers.capture) {
  7441. delete modifiers.capture;
  7442. name = prependModifierMarker('!', name, dynamic);
  7443. }
  7444. if (modifiers.once) {
  7445. delete modifiers.once;
  7446. name = prependModifierMarker('~', name, dynamic);
  7447. }
  7448. /* istanbul ignore if */
  7449. if (modifiers.passive) {
  7450. delete modifiers.passive;
  7451. name = prependModifierMarker('&', name, dynamic);
  7452. }
  7453. let events;
  7454. if (modifiers.native) {
  7455. delete modifiers.native;
  7456. events = el.nativeEvents || (el.nativeEvents = {});
  7457. }
  7458. else {
  7459. events = el.events || (el.events = {});
  7460. }
  7461. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7462. if (modifiers !== emptyObject) {
  7463. newHandler.modifiers = modifiers;
  7464. }
  7465. const handlers = events[name];
  7466. /* istanbul ignore if */
  7467. if (Array.isArray(handlers)) {
  7468. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7469. }
  7470. else if (handlers) {
  7471. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7472. }
  7473. else {
  7474. events[name] = newHandler;
  7475. }
  7476. el.plain = false;
  7477. }
  7478. function getRawBindingAttr(el, name) {
  7479. return (el.rawAttrsMap[':' + name] ||
  7480. el.rawAttrsMap['v-bind:' + name] ||
  7481. el.rawAttrsMap[name]);
  7482. }
  7483. function getBindingAttr(el, name, getStatic) {
  7484. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7485. if (dynamicValue != null) {
  7486. return parseFilters(dynamicValue);
  7487. }
  7488. else if (getStatic !== false) {
  7489. const staticValue = getAndRemoveAttr(el, name);
  7490. if (staticValue != null) {
  7491. return JSON.stringify(staticValue);
  7492. }
  7493. }
  7494. }
  7495. // note: this only removes the attr from the Array (attrsList) so that it
  7496. // doesn't get processed by processAttrs.
  7497. // By default it does NOT remove it from the map (attrsMap) because the map is
  7498. // needed during codegen.
  7499. function getAndRemoveAttr(el, name, removeFromMap) {
  7500. let val;
  7501. if ((val = el.attrsMap[name]) != null) {
  7502. const list = el.attrsList;
  7503. for (let i = 0, l = list.length; i < l; i++) {
  7504. if (list[i].name === name) {
  7505. list.splice(i, 1);
  7506. break;
  7507. }
  7508. }
  7509. }
  7510. if (removeFromMap) {
  7511. delete el.attrsMap[name];
  7512. }
  7513. return val;
  7514. }
  7515. function getAndRemoveAttrByRegex(el, name) {
  7516. const list = el.attrsList;
  7517. for (let i = 0, l = list.length; i < l; i++) {
  7518. const attr = list[i];
  7519. if (name.test(attr.name)) {
  7520. list.splice(i, 1);
  7521. return attr;
  7522. }
  7523. }
  7524. }
  7525. function rangeSetItem(item, range) {
  7526. if (range) {
  7527. if (range.start != null) {
  7528. item.start = range.start;
  7529. }
  7530. if (range.end != null) {
  7531. item.end = range.end;
  7532. }
  7533. }
  7534. return item;
  7535. }
  7536. /**
  7537. * Cross-platform code generation for component v-model
  7538. */
  7539. function genComponentModel(el, value, modifiers) {
  7540. const { number, trim } = modifiers || {};
  7541. const baseValueExpression = '$$v';
  7542. let valueExpression = baseValueExpression;
  7543. if (trim) {
  7544. valueExpression =
  7545. `(typeof ${baseValueExpression} === 'string'` +
  7546. `? ${baseValueExpression}.trim()` +
  7547. `: ${baseValueExpression})`;
  7548. }
  7549. if (number) {
  7550. valueExpression = `_n(${valueExpression})`;
  7551. }
  7552. const assignment = genAssignmentCode(value, valueExpression);
  7553. el.model = {
  7554. value: `(${value})`,
  7555. expression: JSON.stringify(value),
  7556. callback: `function (${baseValueExpression}) {${assignment}}`
  7557. };
  7558. }
  7559. /**
  7560. * Cross-platform codegen helper for generating v-model value assignment code.
  7561. */
  7562. function genAssignmentCode(value, assignment) {
  7563. const res = parseModel(value);
  7564. if (res.key === null) {
  7565. return `${value}=${assignment}`;
  7566. }
  7567. else {
  7568. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7569. }
  7570. }
  7571. /**
  7572. * Parse a v-model expression into a base path and a final key segment.
  7573. * Handles both dot-path and possible square brackets.
  7574. *
  7575. * Possible cases:
  7576. *
  7577. * - test
  7578. * - test[key]
  7579. * - test[test1[key]]
  7580. * - test["a"][key]
  7581. * - xxx.test[a[a].test1[key]]
  7582. * - test.xxx.a["asa"][test1[key]]
  7583. *
  7584. */
  7585. let len, str, chr, index, expressionPos, expressionEndPos;
  7586. function parseModel(val) {
  7587. // Fix https://github.com/vuejs/vue/pull/7730
  7588. // allow v-model="obj.val " (trailing whitespace)
  7589. val = val.trim();
  7590. len = val.length;
  7591. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7592. index = val.lastIndexOf('.');
  7593. if (index > -1) {
  7594. return {
  7595. exp: val.slice(0, index),
  7596. key: '"' + val.slice(index + 1) + '"'
  7597. };
  7598. }
  7599. else {
  7600. return {
  7601. exp: val,
  7602. key: null
  7603. };
  7604. }
  7605. }
  7606. str = val;
  7607. index = expressionPos = expressionEndPos = 0;
  7608. while (!eof()) {
  7609. chr = next();
  7610. /* istanbul ignore if */
  7611. if (isStringStart(chr)) {
  7612. parseString(chr);
  7613. }
  7614. else if (chr === 0x5b) {
  7615. parseBracket(chr);
  7616. }
  7617. }
  7618. return {
  7619. exp: val.slice(0, expressionPos),
  7620. key: val.slice(expressionPos + 1, expressionEndPos)
  7621. };
  7622. }
  7623. function next() {
  7624. return str.charCodeAt(++index);
  7625. }
  7626. function eof() {
  7627. return index >= len;
  7628. }
  7629. function isStringStart(chr) {
  7630. return chr === 0x22 || chr === 0x27;
  7631. }
  7632. function parseBracket(chr) {
  7633. let inBracket = 1;
  7634. expressionPos = index;
  7635. while (!eof()) {
  7636. chr = next();
  7637. if (isStringStart(chr)) {
  7638. parseString(chr);
  7639. continue;
  7640. }
  7641. if (chr === 0x5b)
  7642. inBracket++;
  7643. if (chr === 0x5d)
  7644. inBracket--;
  7645. if (inBracket === 0) {
  7646. expressionEndPos = index;
  7647. break;
  7648. }
  7649. }
  7650. }
  7651. function parseString(chr) {
  7652. const stringQuote = chr;
  7653. while (!eof()) {
  7654. chr = next();
  7655. if (chr === stringQuote) {
  7656. break;
  7657. }
  7658. }
  7659. }
  7660. let warn$1;
  7661. // in some cases, the event used has to be determined at runtime
  7662. // so we used some reserved tokens during compile.
  7663. const RANGE_TOKEN = '__r';
  7664. const CHECKBOX_RADIO_TOKEN = '__c';
  7665. function model$1(el, dir, _warn) {
  7666. warn$1 = _warn;
  7667. const value = dir.value;
  7668. const modifiers = dir.modifiers;
  7669. const tag = el.tag;
  7670. const type = el.attrsMap.type;
  7671. {
  7672. // inputs with type="file" are read only and setting the input's
  7673. // value will throw an error.
  7674. if (tag === 'input' && type === 'file') {
  7675. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7676. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7677. }
  7678. }
  7679. if (el.component) {
  7680. genComponentModel(el, value, modifiers);
  7681. // component v-model doesn't need extra runtime
  7682. return false;
  7683. }
  7684. else if (tag === 'select') {
  7685. genSelect(el, value, modifiers);
  7686. }
  7687. else if (tag === 'input' && type === 'checkbox') {
  7688. genCheckboxModel(el, value, modifiers);
  7689. }
  7690. else if (tag === 'input' && type === 'radio') {
  7691. genRadioModel(el, value, modifiers);
  7692. }
  7693. else if (tag === 'input' || tag === 'textarea') {
  7694. genDefaultModel(el, value, modifiers);
  7695. }
  7696. else if (!config.isReservedTag(tag)) {
  7697. genComponentModel(el, value, modifiers);
  7698. // component v-model doesn't need extra runtime
  7699. return false;
  7700. }
  7701. else {
  7702. warn$1(`<${el.tag} v-model="${value}">: ` +
  7703. `v-model is not supported on this element type. ` +
  7704. "If you are working with contenteditable, it's recommended to " +
  7705. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7706. }
  7707. // ensure runtime directive metadata
  7708. return true;
  7709. }
  7710. function genCheckboxModel(el, value, modifiers) {
  7711. const number = modifiers && modifiers.number;
  7712. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7713. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7714. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7715. addProp(el, 'checked', `Array.isArray(${value})` +
  7716. `?_i(${value},${valueBinding})>-1` +
  7717. (trueValueBinding === 'true'
  7718. ? `:(${value})`
  7719. : `:_q(${value},${trueValueBinding})`));
  7720. addHandler(el, 'change', `var $$a=${value},` +
  7721. '$$el=$event.target,' +
  7722. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7723. 'if(Array.isArray($$a)){' +
  7724. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7725. '$$i=_i($$a,$$v);' +
  7726. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7727. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7728. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7729. }
  7730. function genRadioModel(el, value, modifiers) {
  7731. const number = modifiers && modifiers.number;
  7732. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7733. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7734. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7735. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7736. }
  7737. function genSelect(el, value, modifiers) {
  7738. const number = modifiers && modifiers.number;
  7739. const selectedVal = `Array.prototype.filter` +
  7740. `.call($event.target.options,function(o){return o.selected})` +
  7741. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7742. `return ${number ? '_n(val)' : 'val'}})`;
  7743. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7744. let code = `var $$selectedVal = ${selectedVal};`;
  7745. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7746. addHandler(el, 'change', code, null, true);
  7747. }
  7748. function genDefaultModel(el, value, modifiers) {
  7749. const type = el.attrsMap.type;
  7750. // warn if v-bind:value conflicts with v-model
  7751. // except for inputs with v-bind:type
  7752. {
  7753. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7754. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7755. if (value && !typeBinding) {
  7756. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7757. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7758. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7759. }
  7760. }
  7761. const { lazy, number, trim } = modifiers || {};
  7762. const needCompositionGuard = !lazy && type !== 'range';
  7763. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7764. let valueExpression = '$event.target.value';
  7765. if (trim) {
  7766. valueExpression = `$event.target.value.trim()`;
  7767. }
  7768. if (number) {
  7769. valueExpression = `_n(${valueExpression})`;
  7770. }
  7771. let code = genAssignmentCode(value, valueExpression);
  7772. if (needCompositionGuard) {
  7773. code = `if($event.target.composing)return;${code}`;
  7774. }
  7775. addProp(el, 'value', `(${value})`);
  7776. addHandler(el, event, code, null, true);
  7777. if (trim || number) {
  7778. addHandler(el, 'blur', '$forceUpdate()');
  7779. }
  7780. }
  7781. // normalize v-model event tokens that can only be determined at runtime.
  7782. // it's important to place the event as the first in the array because
  7783. // the whole point is ensuring the v-model callback gets called before
  7784. // user-attached handlers.
  7785. function normalizeEvents(on) {
  7786. /* istanbul ignore if */
  7787. if (isDef(on[RANGE_TOKEN])) {
  7788. // IE input[type=range] only supports `change` event
  7789. const event = isIE ? 'change' : 'input';
  7790. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7791. delete on[RANGE_TOKEN];
  7792. }
  7793. // This was originally intended to fix #4521 but no longer necessary
  7794. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7795. /* istanbul ignore if */
  7796. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7797. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7798. delete on[CHECKBOX_RADIO_TOKEN];
  7799. }
  7800. }
  7801. let target;
  7802. function createOnceHandler(event, handler, capture) {
  7803. const _target = target; // save current target element in closure
  7804. return function onceHandler() {
  7805. const res = handler.apply(null, arguments);
  7806. if (res !== null) {
  7807. remove(event, onceHandler, capture, _target);
  7808. }
  7809. };
  7810. }
  7811. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7812. // implementation and does not fire microtasks in between event propagation, so
  7813. // safe to exclude.
  7814. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7815. function add(name, handler, capture, passive) {
  7816. // async edge case #6566: inner click event triggers patch, event handler
  7817. // attached to outer element during patch, and triggered again. This
  7818. // happens because browsers fire microtask ticks between event propagation.
  7819. // the solution is simple: we save the timestamp when a handler is attached,
  7820. // and the handler would only fire if the event passed to it was fired
  7821. // AFTER it was attached.
  7822. if (useMicrotaskFix) {
  7823. const attachedTimestamp = currentFlushTimestamp;
  7824. const original = handler;
  7825. //@ts-expect-error
  7826. handler = original._wrapper = function (e) {
  7827. if (
  7828. // no bubbling, should always fire.
  7829. // this is just a safety net in case event.timeStamp is unreliable in
  7830. // certain weird environments...
  7831. e.target === e.currentTarget ||
  7832. // event is fired after handler attachment
  7833. e.timeStamp >= attachedTimestamp ||
  7834. // bail for environments that have buggy event.timeStamp implementations
  7835. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7836. // #9681 QtWebEngine event.timeStamp is negative value
  7837. e.timeStamp <= 0 ||
  7838. // #9448 bail if event is fired in another document in a multi-page
  7839. // electron/nw.js app, since event.timeStamp will be using a different
  7840. // starting reference
  7841. e.target.ownerDocument !== document) {
  7842. return original.apply(this, arguments);
  7843. }
  7844. };
  7845. }
  7846. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7847. }
  7848. function remove(name, handler, capture, _target) {
  7849. (_target || target).removeEventListener(name,
  7850. //@ts-expect-error
  7851. handler._wrapper || handler, capture);
  7852. }
  7853. function updateDOMListeners(oldVnode, vnode) {
  7854. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7855. return;
  7856. }
  7857. const on = vnode.data.on || {};
  7858. const oldOn = oldVnode.data.on || {};
  7859. // vnode is empty when removing all listeners,
  7860. // and use old vnode dom element
  7861. target = vnode.elm || oldVnode.elm;
  7862. normalizeEvents(on);
  7863. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7864. target = undefined;
  7865. }
  7866. var events = {
  7867. create: updateDOMListeners,
  7868. update: updateDOMListeners,
  7869. // @ts-expect-error emptyNode has actually data
  7870. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7871. };
  7872. let svgContainer;
  7873. function updateDOMProps(oldVnode, vnode) {
  7874. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7875. return;
  7876. }
  7877. let key, cur;
  7878. const elm = vnode.elm;
  7879. const oldProps = oldVnode.data.domProps || {};
  7880. let props = vnode.data.domProps || {};
  7881. // clone observed objects, as the user probably wants to mutate it
  7882. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7883. props = vnode.data.domProps = extend({}, props);
  7884. }
  7885. for (key in oldProps) {
  7886. if (!(key in props)) {
  7887. elm[key] = '';
  7888. }
  7889. }
  7890. for (key in props) {
  7891. cur = props[key];
  7892. // ignore children if the node has textContent or innerHTML,
  7893. // as these will throw away existing DOM nodes and cause removal errors
  7894. // on subsequent patches (#3360)
  7895. if (key === 'textContent' || key === 'innerHTML') {
  7896. if (vnode.children)
  7897. vnode.children.length = 0;
  7898. if (cur === oldProps[key])
  7899. continue;
  7900. // #6601 work around Chrome version <= 55 bug where single textNode
  7901. // replaced by innerHTML/textContent retains its parentNode property
  7902. if (elm.childNodes.length === 1) {
  7903. elm.removeChild(elm.childNodes[0]);
  7904. }
  7905. }
  7906. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7907. // store value as _value as well since
  7908. // non-string values will be stringified
  7909. elm._value = cur;
  7910. // avoid resetting cursor position when value is the same
  7911. const strCur = isUndef(cur) ? '' : String(cur);
  7912. if (shouldUpdateValue(elm, strCur)) {
  7913. elm.value = strCur;
  7914. }
  7915. }
  7916. else if (key === 'innerHTML' &&
  7917. isSVG(elm.tagName) &&
  7918. isUndef(elm.innerHTML)) {
  7919. // IE doesn't support innerHTML for SVG elements
  7920. svgContainer = svgContainer || document.createElement('div');
  7921. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7922. const svg = svgContainer.firstChild;
  7923. while (elm.firstChild) {
  7924. elm.removeChild(elm.firstChild);
  7925. }
  7926. while (svg.firstChild) {
  7927. elm.appendChild(svg.firstChild);
  7928. }
  7929. }
  7930. else if (
  7931. // skip the update if old and new VDOM state is the same.
  7932. // `value` is handled separately because the DOM value may be temporarily
  7933. // out of sync with VDOM state due to focus, composition and modifiers.
  7934. // This #4521 by skipping the unnecessary `checked` update.
  7935. cur !== oldProps[key]) {
  7936. // some property updates can throw
  7937. // e.g. `value` on <progress> w/ non-finite value
  7938. try {
  7939. elm[key] = cur;
  7940. }
  7941. catch (e) { }
  7942. }
  7943. }
  7944. }
  7945. function shouldUpdateValue(elm, checkVal) {
  7946. return (
  7947. //@ts-expect-error
  7948. !elm.composing &&
  7949. (elm.tagName === 'OPTION' ||
  7950. isNotInFocusAndDirty(elm, checkVal) ||
  7951. isDirtyWithModifiers(elm, checkVal)));
  7952. }
  7953. function isNotInFocusAndDirty(elm, checkVal) {
  7954. // return true when textbox (.number and .trim) loses focus and its value is
  7955. // not equal to the updated value
  7956. let notInFocus = true;
  7957. // #6157
  7958. // work around IE bug when accessing document.activeElement in an iframe
  7959. try {
  7960. notInFocus = document.activeElement !== elm;
  7961. }
  7962. catch (e) { }
  7963. return notInFocus && elm.value !== checkVal;
  7964. }
  7965. function isDirtyWithModifiers(elm, newVal) {
  7966. const value = elm.value;
  7967. const modifiers = elm._vModifiers; // injected by v-model runtime
  7968. if (isDef(modifiers)) {
  7969. if (modifiers.number) {
  7970. return toNumber(value) !== toNumber(newVal);
  7971. }
  7972. if (modifiers.trim) {
  7973. return value.trim() !== newVal.trim();
  7974. }
  7975. }
  7976. return value !== newVal;
  7977. }
  7978. var domProps = {
  7979. create: updateDOMProps,
  7980. update: updateDOMProps
  7981. };
  7982. const parseStyleText = cached(function (cssText) {
  7983. const res = {};
  7984. const listDelimiter = /;(?![^(]*\))/g;
  7985. const propertyDelimiter = /:(.+)/;
  7986. cssText.split(listDelimiter).forEach(function (item) {
  7987. if (item) {
  7988. const tmp = item.split(propertyDelimiter);
  7989. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7990. }
  7991. });
  7992. return res;
  7993. });
  7994. // merge static and dynamic style data on the same vnode
  7995. function normalizeStyleData(data) {
  7996. const style = normalizeStyleBinding(data.style);
  7997. // static style is pre-processed into an object during compilation
  7998. // and is always a fresh object, so it's safe to merge into it
  7999. return data.staticStyle ? extend(data.staticStyle, style) : style;
  8000. }
  8001. // normalize possible array / string values into Object
  8002. function normalizeStyleBinding(bindingStyle) {
  8003. if (Array.isArray(bindingStyle)) {
  8004. return toObject(bindingStyle);
  8005. }
  8006. if (typeof bindingStyle === 'string') {
  8007. return parseStyleText(bindingStyle);
  8008. }
  8009. return bindingStyle;
  8010. }
  8011. /**
  8012. * parent component style should be after child's
  8013. * so that parent component's style could override it
  8014. */
  8015. function getStyle(vnode, checkChild) {
  8016. const res = {};
  8017. let styleData;
  8018. if (checkChild) {
  8019. let childNode = vnode;
  8020. while (childNode.componentInstance) {
  8021. childNode = childNode.componentInstance._vnode;
  8022. if (childNode &&
  8023. childNode.data &&
  8024. (styleData = normalizeStyleData(childNode.data))) {
  8025. extend(res, styleData);
  8026. }
  8027. }
  8028. }
  8029. if ((styleData = normalizeStyleData(vnode.data))) {
  8030. extend(res, styleData);
  8031. }
  8032. let parentNode = vnode;
  8033. // @ts-expect-error parentNode.parent not VNodeWithData
  8034. while ((parentNode = parentNode.parent)) {
  8035. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  8036. extend(res, styleData);
  8037. }
  8038. }
  8039. return res;
  8040. }
  8041. const cssVarRE = /^--/;
  8042. const importantRE = /\s*!important$/;
  8043. const setProp = (el, name, val) => {
  8044. /* istanbul ignore if */
  8045. if (cssVarRE.test(name)) {
  8046. el.style.setProperty(name, val);
  8047. }
  8048. else if (importantRE.test(val)) {
  8049. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8050. }
  8051. else {
  8052. const normalizedName = normalize(name);
  8053. if (Array.isArray(val)) {
  8054. // Support values array created by autoprefixer, e.g.
  8055. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8056. // Set them one by one, and the browser will only set those it can recognize
  8057. for (let i = 0, len = val.length; i < len; i++) {
  8058. el.style[normalizedName] = val[i];
  8059. }
  8060. }
  8061. else {
  8062. el.style[normalizedName] = val;
  8063. }
  8064. }
  8065. };
  8066. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8067. let emptyStyle;
  8068. const normalize = cached(function (prop) {
  8069. emptyStyle = emptyStyle || document.createElement('div').style;
  8070. prop = camelize(prop);
  8071. if (prop !== 'filter' && prop in emptyStyle) {
  8072. return prop;
  8073. }
  8074. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8075. for (let i = 0; i < vendorNames.length; i++) {
  8076. const name = vendorNames[i] + capName;
  8077. if (name in emptyStyle) {
  8078. return name;
  8079. }
  8080. }
  8081. });
  8082. function updateStyle(oldVnode, vnode) {
  8083. const data = vnode.data;
  8084. const oldData = oldVnode.data;
  8085. if (isUndef(data.staticStyle) &&
  8086. isUndef(data.style) &&
  8087. isUndef(oldData.staticStyle) &&
  8088. isUndef(oldData.style)) {
  8089. return;
  8090. }
  8091. let cur, name;
  8092. const el = vnode.elm;
  8093. const oldStaticStyle = oldData.staticStyle;
  8094. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8095. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8096. const oldStyle = oldStaticStyle || oldStyleBinding;
  8097. const style = normalizeStyleBinding(vnode.data.style) || {};
  8098. // store normalized style under a different key for next diff
  8099. // make sure to clone it if it's reactive, since the user likely wants
  8100. // to mutate it.
  8101. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8102. const newStyle = getStyle(vnode, true);
  8103. for (name in oldStyle) {
  8104. if (isUndef(newStyle[name])) {
  8105. setProp(el, name, '');
  8106. }
  8107. }
  8108. for (name in newStyle) {
  8109. cur = newStyle[name];
  8110. if (cur !== oldStyle[name]) {
  8111. // ie9 setting to null has no effect, must use empty string
  8112. setProp(el, name, cur == null ? '' : cur);
  8113. }
  8114. }
  8115. }
  8116. var style$1 = {
  8117. create: updateStyle,
  8118. update: updateStyle
  8119. };
  8120. const whitespaceRE$1 = /\s+/;
  8121. /**
  8122. * Add class with compatibility for SVG since classList is not supported on
  8123. * SVG elements in IE
  8124. */
  8125. function addClass(el, cls) {
  8126. /* istanbul ignore if */
  8127. if (!cls || !(cls = cls.trim())) {
  8128. return;
  8129. }
  8130. /* istanbul ignore else */
  8131. if (el.classList) {
  8132. if (cls.indexOf(' ') > -1) {
  8133. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8134. }
  8135. else {
  8136. el.classList.add(cls);
  8137. }
  8138. }
  8139. else {
  8140. const cur = ` ${el.getAttribute('class') || ''} `;
  8141. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8142. el.setAttribute('class', (cur + cls).trim());
  8143. }
  8144. }
  8145. }
  8146. /**
  8147. * Remove class with compatibility for SVG since classList is not supported on
  8148. * SVG elements in IE
  8149. */
  8150. function removeClass(el, cls) {
  8151. /* istanbul ignore if */
  8152. if (!cls || !(cls = cls.trim())) {
  8153. return;
  8154. }
  8155. /* istanbul ignore else */
  8156. if (el.classList) {
  8157. if (cls.indexOf(' ') > -1) {
  8158. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8159. }
  8160. else {
  8161. el.classList.remove(cls);
  8162. }
  8163. if (!el.classList.length) {
  8164. el.removeAttribute('class');
  8165. }
  8166. }
  8167. else {
  8168. let cur = ` ${el.getAttribute('class') || ''} `;
  8169. const tar = ' ' + cls + ' ';
  8170. while (cur.indexOf(tar) >= 0) {
  8171. cur = cur.replace(tar, ' ');
  8172. }
  8173. cur = cur.trim();
  8174. if (cur) {
  8175. el.setAttribute('class', cur);
  8176. }
  8177. else {
  8178. el.removeAttribute('class');
  8179. }
  8180. }
  8181. }
  8182. function resolveTransition(def) {
  8183. if (!def) {
  8184. return;
  8185. }
  8186. /* istanbul ignore else */
  8187. if (typeof def === 'object') {
  8188. const res = {};
  8189. if (def.css !== false) {
  8190. extend(res, autoCssTransition(def.name || 'v'));
  8191. }
  8192. extend(res, def);
  8193. return res;
  8194. }
  8195. else if (typeof def === 'string') {
  8196. return autoCssTransition(def);
  8197. }
  8198. }
  8199. const autoCssTransition = cached(name => {
  8200. return {
  8201. enterClass: `${name}-enter`,
  8202. enterToClass: `${name}-enter-to`,
  8203. enterActiveClass: `${name}-enter-active`,
  8204. leaveClass: `${name}-leave`,
  8205. leaveToClass: `${name}-leave-to`,
  8206. leaveActiveClass: `${name}-leave-active`
  8207. };
  8208. });
  8209. const hasTransition = inBrowser && !isIE9;
  8210. const TRANSITION = 'transition';
  8211. const ANIMATION = 'animation';
  8212. // Transition property/event sniffing
  8213. let transitionProp = 'transition';
  8214. let transitionEndEvent = 'transitionend';
  8215. let animationProp = 'animation';
  8216. let animationEndEvent = 'animationend';
  8217. if (hasTransition) {
  8218. /* istanbul ignore if */
  8219. if (window.ontransitionend === undefined &&
  8220. window.onwebkittransitionend !== undefined) {
  8221. transitionProp = 'WebkitTransition';
  8222. transitionEndEvent = 'webkitTransitionEnd';
  8223. }
  8224. if (window.onanimationend === undefined &&
  8225. window.onwebkitanimationend !== undefined) {
  8226. animationProp = 'WebkitAnimation';
  8227. animationEndEvent = 'webkitAnimationEnd';
  8228. }
  8229. }
  8230. // binding to window is necessary to make hot reload work in IE in strict mode
  8231. const raf = inBrowser
  8232. ? window.requestAnimationFrame
  8233. ? window.requestAnimationFrame.bind(window)
  8234. : setTimeout
  8235. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8236. function nextFrame(fn) {
  8237. raf(() => {
  8238. // @ts-expect-error
  8239. raf(fn);
  8240. });
  8241. }
  8242. function addTransitionClass(el, cls) {
  8243. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8244. if (transitionClasses.indexOf(cls) < 0) {
  8245. transitionClasses.push(cls);
  8246. addClass(el, cls);
  8247. }
  8248. }
  8249. function removeTransitionClass(el, cls) {
  8250. if (el._transitionClasses) {
  8251. remove$2(el._transitionClasses, cls);
  8252. }
  8253. removeClass(el, cls);
  8254. }
  8255. function whenTransitionEnds(el, expectedType, cb) {
  8256. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8257. if (!type)
  8258. return cb();
  8259. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8260. let ended = 0;
  8261. const end = () => {
  8262. el.removeEventListener(event, onEnd);
  8263. cb();
  8264. };
  8265. const onEnd = e => {
  8266. if (e.target === el) {
  8267. if (++ended >= propCount) {
  8268. end();
  8269. }
  8270. }
  8271. };
  8272. setTimeout(() => {
  8273. if (ended < propCount) {
  8274. end();
  8275. }
  8276. }, timeout + 1);
  8277. el.addEventListener(event, onEnd);
  8278. }
  8279. const transformRE = /\b(transform|all)(,|$)/;
  8280. function getTransitionInfo(el, expectedType) {
  8281. const styles = window.getComputedStyle(el);
  8282. // JSDOM may return undefined for transition properties
  8283. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8284. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8285. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8286. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8287. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8288. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8289. let type;
  8290. let timeout = 0;
  8291. let propCount = 0;
  8292. /* istanbul ignore if */
  8293. if (expectedType === TRANSITION) {
  8294. if (transitionTimeout > 0) {
  8295. type = TRANSITION;
  8296. timeout = transitionTimeout;
  8297. propCount = transitionDurations.length;
  8298. }
  8299. }
  8300. else if (expectedType === ANIMATION) {
  8301. if (animationTimeout > 0) {
  8302. type = ANIMATION;
  8303. timeout = animationTimeout;
  8304. propCount = animationDurations.length;
  8305. }
  8306. }
  8307. else {
  8308. timeout = Math.max(transitionTimeout, animationTimeout);
  8309. type =
  8310. timeout > 0
  8311. ? transitionTimeout > animationTimeout
  8312. ? TRANSITION
  8313. : ANIMATION
  8314. : null;
  8315. propCount = type
  8316. ? type === TRANSITION
  8317. ? transitionDurations.length
  8318. : animationDurations.length
  8319. : 0;
  8320. }
  8321. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8322. return {
  8323. type,
  8324. timeout,
  8325. propCount,
  8326. hasTransform
  8327. };
  8328. }
  8329. function getTimeout(delays, durations) {
  8330. /* istanbul ignore next */
  8331. while (delays.length < durations.length) {
  8332. delays = delays.concat(delays);
  8333. }
  8334. return Math.max.apply(null, durations.map((d, i) => {
  8335. return toMs(d) + toMs(delays[i]);
  8336. }));
  8337. }
  8338. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8339. // in a locale-dependent way, using a comma instead of a dot.
  8340. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8341. // as a floor function) causing unexpected behaviors
  8342. function toMs(s) {
  8343. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8344. }
  8345. function enter(vnode, toggleDisplay) {
  8346. const el = vnode.elm;
  8347. // call leave callback now
  8348. if (isDef(el._leaveCb)) {
  8349. el._leaveCb.cancelled = true;
  8350. el._leaveCb();
  8351. }
  8352. const data = resolveTransition(vnode.data.transition);
  8353. if (isUndef(data)) {
  8354. return;
  8355. }
  8356. /* istanbul ignore if */
  8357. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8358. return;
  8359. }
  8360. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8361. // activeInstance will always be the <transition> component managing this
  8362. // transition. One edge case to check is when the <transition> is placed
  8363. // as the root node of a child component. In that case we need to check
  8364. // <transition>'s parent for appear check.
  8365. let context = activeInstance;
  8366. let transitionNode = activeInstance.$vnode;
  8367. while (transitionNode && transitionNode.parent) {
  8368. context = transitionNode.context;
  8369. transitionNode = transitionNode.parent;
  8370. }
  8371. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8372. if (isAppear && !appear && appear !== '') {
  8373. return;
  8374. }
  8375. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8376. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8377. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8378. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8379. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8380. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8381. const enterCancelledHook = isAppear
  8382. ? appearCancelled || enterCancelled
  8383. : enterCancelled;
  8384. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8385. if (explicitEnterDuration != null) {
  8386. checkDuration(explicitEnterDuration, 'enter', vnode);
  8387. }
  8388. const expectsCSS = css !== false && !isIE9;
  8389. const userWantsControl = getHookArgumentsLength(enterHook);
  8390. const cb = (el._enterCb = once(() => {
  8391. if (expectsCSS) {
  8392. removeTransitionClass(el, toClass);
  8393. removeTransitionClass(el, activeClass);
  8394. }
  8395. // @ts-expect-error
  8396. if (cb.cancelled) {
  8397. if (expectsCSS) {
  8398. removeTransitionClass(el, startClass);
  8399. }
  8400. enterCancelledHook && enterCancelledHook(el);
  8401. }
  8402. else {
  8403. afterEnterHook && afterEnterHook(el);
  8404. }
  8405. el._enterCb = null;
  8406. }));
  8407. if (!vnode.data.show) {
  8408. // remove pending leave element on enter by injecting an insert hook
  8409. mergeVNodeHook(vnode, 'insert', () => {
  8410. const parent = el.parentNode;
  8411. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8412. if (pendingNode &&
  8413. pendingNode.tag === vnode.tag &&
  8414. pendingNode.elm._leaveCb) {
  8415. pendingNode.elm._leaveCb();
  8416. }
  8417. enterHook && enterHook(el, cb);
  8418. });
  8419. }
  8420. // start enter transition
  8421. beforeEnterHook && beforeEnterHook(el);
  8422. if (expectsCSS) {
  8423. addTransitionClass(el, startClass);
  8424. addTransitionClass(el, activeClass);
  8425. nextFrame(() => {
  8426. removeTransitionClass(el, startClass);
  8427. // @ts-expect-error
  8428. if (!cb.cancelled) {
  8429. addTransitionClass(el, toClass);
  8430. if (!userWantsControl) {
  8431. if (isValidDuration(explicitEnterDuration)) {
  8432. setTimeout(cb, explicitEnterDuration);
  8433. }
  8434. else {
  8435. whenTransitionEnds(el, type, cb);
  8436. }
  8437. }
  8438. }
  8439. });
  8440. }
  8441. if (vnode.data.show) {
  8442. toggleDisplay && toggleDisplay();
  8443. enterHook && enterHook(el, cb);
  8444. }
  8445. if (!expectsCSS && !userWantsControl) {
  8446. cb();
  8447. }
  8448. }
  8449. function leave(vnode, rm) {
  8450. const el = vnode.elm;
  8451. // call enter callback now
  8452. if (isDef(el._enterCb)) {
  8453. el._enterCb.cancelled = true;
  8454. el._enterCb();
  8455. }
  8456. const data = resolveTransition(vnode.data.transition);
  8457. if (isUndef(data) || el.nodeType !== 1) {
  8458. return rm();
  8459. }
  8460. /* istanbul ignore if */
  8461. if (isDef(el._leaveCb)) {
  8462. return;
  8463. }
  8464. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8465. const expectsCSS = css !== false && !isIE9;
  8466. const userWantsControl = getHookArgumentsLength(leave);
  8467. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8468. if (isDef(explicitLeaveDuration)) {
  8469. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8470. }
  8471. const cb = (el._leaveCb = once(() => {
  8472. if (el.parentNode && el.parentNode._pending) {
  8473. el.parentNode._pending[vnode.key] = null;
  8474. }
  8475. if (expectsCSS) {
  8476. removeTransitionClass(el, leaveToClass);
  8477. removeTransitionClass(el, leaveActiveClass);
  8478. }
  8479. // @ts-expect-error
  8480. if (cb.cancelled) {
  8481. if (expectsCSS) {
  8482. removeTransitionClass(el, leaveClass);
  8483. }
  8484. leaveCancelled && leaveCancelled(el);
  8485. }
  8486. else {
  8487. rm();
  8488. afterLeave && afterLeave(el);
  8489. }
  8490. el._leaveCb = null;
  8491. }));
  8492. if (delayLeave) {
  8493. delayLeave(performLeave);
  8494. }
  8495. else {
  8496. performLeave();
  8497. }
  8498. function performLeave() {
  8499. // the delayed leave may have already been cancelled
  8500. // @ts-expect-error
  8501. if (cb.cancelled) {
  8502. return;
  8503. }
  8504. // record leaving element
  8505. if (!vnode.data.show && el.parentNode) {
  8506. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8507. vnode;
  8508. }
  8509. beforeLeave && beforeLeave(el);
  8510. if (expectsCSS) {
  8511. addTransitionClass(el, leaveClass);
  8512. addTransitionClass(el, leaveActiveClass);
  8513. nextFrame(() => {
  8514. removeTransitionClass(el, leaveClass);
  8515. // @ts-expect-error
  8516. if (!cb.cancelled) {
  8517. addTransitionClass(el, leaveToClass);
  8518. if (!userWantsControl) {
  8519. if (isValidDuration(explicitLeaveDuration)) {
  8520. setTimeout(cb, explicitLeaveDuration);
  8521. }
  8522. else {
  8523. whenTransitionEnds(el, type, cb);
  8524. }
  8525. }
  8526. }
  8527. });
  8528. }
  8529. leave && leave(el, cb);
  8530. if (!expectsCSS && !userWantsControl) {
  8531. cb();
  8532. }
  8533. }
  8534. }
  8535. // only used in dev mode
  8536. function checkDuration(val, name, vnode) {
  8537. if (typeof val !== 'number') {
  8538. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8539. `got ${JSON.stringify(val)}.`, vnode.context);
  8540. }
  8541. else if (isNaN(val)) {
  8542. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8543. 'the duration expression might be incorrect.', vnode.context);
  8544. }
  8545. }
  8546. function isValidDuration(val) {
  8547. return typeof val === 'number' && !isNaN(val);
  8548. }
  8549. /**
  8550. * Normalize a transition hook's argument length. The hook may be:
  8551. * - a merged hook (invoker) with the original in .fns
  8552. * - a wrapped component method (check ._length)
  8553. * - a plain function (.length)
  8554. */
  8555. function getHookArgumentsLength(fn) {
  8556. if (isUndef(fn)) {
  8557. return false;
  8558. }
  8559. // @ts-expect-error
  8560. const invokerFns = fn.fns;
  8561. if (isDef(invokerFns)) {
  8562. // invoker
  8563. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8564. }
  8565. else {
  8566. // @ts-expect-error
  8567. return (fn._length || fn.length) > 1;
  8568. }
  8569. }
  8570. function _enter(_, vnode) {
  8571. if (vnode.data.show !== true) {
  8572. enter(vnode);
  8573. }
  8574. }
  8575. var transition = inBrowser
  8576. ? {
  8577. create: _enter,
  8578. activate: _enter,
  8579. remove(vnode, rm) {
  8580. /* istanbul ignore else */
  8581. if (vnode.data.show !== true) {
  8582. // @ts-expect-error
  8583. leave(vnode, rm);
  8584. }
  8585. else {
  8586. rm();
  8587. }
  8588. }
  8589. }
  8590. : {};
  8591. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8592. // the directive module should be applied last, after all
  8593. // built-in modules have been applied.
  8594. const modules$1 = platformModules.concat(baseModules);
  8595. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8596. /**
  8597. * Not type checking this file because flow doesn't like attaching
  8598. * properties to Elements.
  8599. */
  8600. /* istanbul ignore if */
  8601. if (isIE9) {
  8602. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8603. document.addEventListener('selectionchange', () => {
  8604. const el = document.activeElement;
  8605. // @ts-expect-error
  8606. if (el && el.vmodel) {
  8607. trigger(el, 'input');
  8608. }
  8609. });
  8610. }
  8611. const directive = {
  8612. inserted(el, binding, vnode, oldVnode) {
  8613. if (vnode.tag === 'select') {
  8614. // #6903
  8615. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8616. mergeVNodeHook(vnode, 'postpatch', () => {
  8617. directive.componentUpdated(el, binding, vnode);
  8618. });
  8619. }
  8620. else {
  8621. setSelected(el, binding, vnode.context);
  8622. }
  8623. el._vOptions = [].map.call(el.options, getValue);
  8624. }
  8625. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8626. el._vModifiers = binding.modifiers;
  8627. if (!binding.modifiers.lazy) {
  8628. el.addEventListener('compositionstart', onCompositionStart);
  8629. el.addEventListener('compositionend', onCompositionEnd);
  8630. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8631. // switching focus before confirming composition choice
  8632. // this also fixes the issue where some browsers e.g. iOS Chrome
  8633. // fires "change" instead of "input" on autocomplete.
  8634. el.addEventListener('change', onCompositionEnd);
  8635. /* istanbul ignore if */
  8636. if (isIE9) {
  8637. el.vmodel = true;
  8638. }
  8639. }
  8640. }
  8641. },
  8642. componentUpdated(el, binding, vnode) {
  8643. if (vnode.tag === 'select') {
  8644. setSelected(el, binding, vnode.context);
  8645. // in case the options rendered by v-for have changed,
  8646. // it's possible that the value is out-of-sync with the rendered options.
  8647. // detect such cases and filter out values that no longer has a matching
  8648. // option in the DOM.
  8649. const prevOptions = el._vOptions;
  8650. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8651. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8652. // trigger change event if
  8653. // no matching option found for at least one value
  8654. const needReset = el.multiple
  8655. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8656. : binding.value !== binding.oldValue &&
  8657. hasNoMatchingOption(binding.value, curOptions);
  8658. if (needReset) {
  8659. trigger(el, 'change');
  8660. }
  8661. }
  8662. }
  8663. }
  8664. };
  8665. function setSelected(el, binding, vm) {
  8666. actuallySetSelected(el, binding, vm);
  8667. /* istanbul ignore if */
  8668. if (isIE || isEdge) {
  8669. setTimeout(() => {
  8670. actuallySetSelected(el, binding, vm);
  8671. }, 0);
  8672. }
  8673. }
  8674. function actuallySetSelected(el, binding, vm) {
  8675. const value = binding.value;
  8676. const isMultiple = el.multiple;
  8677. if (isMultiple && !Array.isArray(value)) {
  8678. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8679. `expects an Array value for its binding, but got ${Object.prototype.toString
  8680. .call(value)
  8681. .slice(8, -1)}`, vm);
  8682. return;
  8683. }
  8684. let selected, option;
  8685. for (let i = 0, l = el.options.length; i < l; i++) {
  8686. option = el.options[i];
  8687. if (isMultiple) {
  8688. selected = looseIndexOf(value, getValue(option)) > -1;
  8689. if (option.selected !== selected) {
  8690. option.selected = selected;
  8691. }
  8692. }
  8693. else {
  8694. if (looseEqual(getValue(option), value)) {
  8695. if (el.selectedIndex !== i) {
  8696. el.selectedIndex = i;
  8697. }
  8698. return;
  8699. }
  8700. }
  8701. }
  8702. if (!isMultiple) {
  8703. el.selectedIndex = -1;
  8704. }
  8705. }
  8706. function hasNoMatchingOption(value, options) {
  8707. return options.every(o => !looseEqual(o, value));
  8708. }
  8709. function getValue(option) {
  8710. return '_value' in option ? option._value : option.value;
  8711. }
  8712. function onCompositionStart(e) {
  8713. e.target.composing = true;
  8714. }
  8715. function onCompositionEnd(e) {
  8716. // prevent triggering an input event for no reason
  8717. if (!e.target.composing)
  8718. return;
  8719. e.target.composing = false;
  8720. trigger(e.target, 'input');
  8721. }
  8722. function trigger(el, type) {
  8723. const e = document.createEvent('HTMLEvents');
  8724. e.initEvent(type, true, true);
  8725. el.dispatchEvent(e);
  8726. }
  8727. // recursively search for possible transition defined inside the component root
  8728. function locateNode(vnode) {
  8729. // @ts-expect-error
  8730. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8731. ? locateNode(vnode.componentInstance._vnode)
  8732. : vnode;
  8733. }
  8734. var show = {
  8735. bind(el, { value }, vnode) {
  8736. vnode = locateNode(vnode);
  8737. const transition = vnode.data && vnode.data.transition;
  8738. const originalDisplay = (el.__vOriginalDisplay =
  8739. el.style.display === 'none' ? '' : el.style.display);
  8740. if (value && transition) {
  8741. vnode.data.show = true;
  8742. enter(vnode, () => {
  8743. el.style.display = originalDisplay;
  8744. });
  8745. }
  8746. else {
  8747. el.style.display = value ? originalDisplay : 'none';
  8748. }
  8749. },
  8750. update(el, { value, oldValue }, vnode) {
  8751. /* istanbul ignore if */
  8752. if (!value === !oldValue)
  8753. return;
  8754. vnode = locateNode(vnode);
  8755. const transition = vnode.data && vnode.data.transition;
  8756. if (transition) {
  8757. vnode.data.show = true;
  8758. if (value) {
  8759. enter(vnode, () => {
  8760. el.style.display = el.__vOriginalDisplay;
  8761. });
  8762. }
  8763. else {
  8764. leave(vnode, () => {
  8765. el.style.display = 'none';
  8766. });
  8767. }
  8768. }
  8769. else {
  8770. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8771. }
  8772. },
  8773. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8774. if (!isDestroy) {
  8775. el.style.display = el.__vOriginalDisplay;
  8776. }
  8777. }
  8778. };
  8779. var platformDirectives = {
  8780. model: directive,
  8781. show
  8782. };
  8783. // Provides transition support for a single element/component.
  8784. const transitionProps = {
  8785. name: String,
  8786. appear: Boolean,
  8787. css: Boolean,
  8788. mode: String,
  8789. type: String,
  8790. enterClass: String,
  8791. leaveClass: String,
  8792. enterToClass: String,
  8793. leaveToClass: String,
  8794. enterActiveClass: String,
  8795. leaveActiveClass: String,
  8796. appearClass: String,
  8797. appearActiveClass: String,
  8798. appearToClass: String,
  8799. duration: [Number, String, Object]
  8800. };
  8801. // in case the child is also an abstract component, e.g. <keep-alive>
  8802. // we want to recursively retrieve the real component to be rendered
  8803. function getRealChild(vnode) {
  8804. const compOptions = vnode && vnode.componentOptions;
  8805. if (compOptions && compOptions.Ctor.options.abstract) {
  8806. return getRealChild(getFirstComponentChild(compOptions.children));
  8807. }
  8808. else {
  8809. return vnode;
  8810. }
  8811. }
  8812. function extractTransitionData(comp) {
  8813. const data = {};
  8814. const options = comp.$options;
  8815. // props
  8816. for (const key in options.propsData) {
  8817. data[key] = comp[key];
  8818. }
  8819. // events.
  8820. // extract listeners and pass them directly to the transition methods
  8821. const listeners = options._parentListeners;
  8822. for (const key in listeners) {
  8823. data[camelize(key)] = listeners[key];
  8824. }
  8825. return data;
  8826. }
  8827. function placeholder(h, rawChild) {
  8828. // @ts-expect-error
  8829. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8830. return h('keep-alive', {
  8831. props: rawChild.componentOptions.propsData
  8832. });
  8833. }
  8834. }
  8835. function hasParentTransition(vnode) {
  8836. while ((vnode = vnode.parent)) {
  8837. if (vnode.data.transition) {
  8838. return true;
  8839. }
  8840. }
  8841. }
  8842. function isSameChild(child, oldChild) {
  8843. return oldChild.key === child.key && oldChild.tag === child.tag;
  8844. }
  8845. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8846. const isVShowDirective = d => d.name === 'show';
  8847. var Transition = {
  8848. name: 'transition',
  8849. props: transitionProps,
  8850. abstract: true,
  8851. render(h) {
  8852. let children = this.$slots.default;
  8853. if (!children) {
  8854. return;
  8855. }
  8856. // filter out text nodes (possible whitespaces)
  8857. children = children.filter(isNotTextNode);
  8858. /* istanbul ignore if */
  8859. if (!children.length) {
  8860. return;
  8861. }
  8862. // warn multiple elements
  8863. if (children.length > 1) {
  8864. warn$2('<transition> can only be used on a single element. Use ' +
  8865. '<transition-group> for lists.', this.$parent);
  8866. }
  8867. const mode = this.mode;
  8868. // warn invalid mode
  8869. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8870. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8871. }
  8872. const rawChild = children[0];
  8873. // if this is a component root node and the component's
  8874. // parent container node also has transition, skip.
  8875. if (hasParentTransition(this.$vnode)) {
  8876. return rawChild;
  8877. }
  8878. // apply transition data to child
  8879. // use getRealChild() to ignore abstract components e.g. keep-alive
  8880. const child = getRealChild(rawChild);
  8881. /* istanbul ignore if */
  8882. if (!child) {
  8883. return rawChild;
  8884. }
  8885. if (this._leaving) {
  8886. return placeholder(h, rawChild);
  8887. }
  8888. // ensure a key that is unique to the vnode type and to this transition
  8889. // component instance. This key will be used to remove pending leaving nodes
  8890. // during entering.
  8891. const id = `__transition-${this._uid}-`;
  8892. child.key =
  8893. child.key == null
  8894. ? child.isComment
  8895. ? id + 'comment'
  8896. : id + child.tag
  8897. : isPrimitive(child.key)
  8898. ? String(child.key).indexOf(id) === 0
  8899. ? child.key
  8900. : id + child.key
  8901. : child.key;
  8902. const data = ((child.data || (child.data = {})).transition =
  8903. extractTransitionData(this));
  8904. const oldRawChild = this._vnode;
  8905. const oldChild = getRealChild(oldRawChild);
  8906. // mark v-show
  8907. // so that the transition module can hand over the control to the directive
  8908. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8909. child.data.show = true;
  8910. }
  8911. if (oldChild &&
  8912. oldChild.data &&
  8913. !isSameChild(child, oldChild) &&
  8914. !isAsyncPlaceholder(oldChild) &&
  8915. // #6687 component root is a comment node
  8916. !(oldChild.componentInstance &&
  8917. oldChild.componentInstance._vnode.isComment)) {
  8918. // replace old child transition data with fresh one
  8919. // important for dynamic transitions!
  8920. const oldData = (oldChild.data.transition = extend({}, data));
  8921. // handle transition mode
  8922. if (mode === 'out-in') {
  8923. // return placeholder node and queue update when leave finishes
  8924. this._leaving = true;
  8925. mergeVNodeHook(oldData, 'afterLeave', () => {
  8926. this._leaving = false;
  8927. this.$forceUpdate();
  8928. });
  8929. return placeholder(h, rawChild);
  8930. }
  8931. else if (mode === 'in-out') {
  8932. if (isAsyncPlaceholder(child)) {
  8933. return oldRawChild;
  8934. }
  8935. let delayedLeave;
  8936. const performLeave = () => {
  8937. delayedLeave();
  8938. };
  8939. mergeVNodeHook(data, 'afterEnter', performLeave);
  8940. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8941. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8942. delayedLeave = leave;
  8943. });
  8944. }
  8945. }
  8946. return rawChild;
  8947. }
  8948. };
  8949. // Provides transition support for list items.
  8950. const props = extend({
  8951. tag: String,
  8952. moveClass: String
  8953. }, transitionProps);
  8954. delete props.mode;
  8955. var TransitionGroup = {
  8956. props,
  8957. beforeMount() {
  8958. const update = this._update;
  8959. this._update = (vnode, hydrating) => {
  8960. const restoreActiveInstance = setActiveInstance(this);
  8961. // force removing pass
  8962. this.__patch__(this._vnode, this.kept, false, // hydrating
  8963. true // removeOnly (!important, avoids unnecessary moves)
  8964. );
  8965. this._vnode = this.kept;
  8966. restoreActiveInstance();
  8967. update.call(this, vnode, hydrating);
  8968. };
  8969. },
  8970. render(h) {
  8971. const tag = this.tag || this.$vnode.data.tag || 'span';
  8972. const map = Object.create(null);
  8973. const prevChildren = (this.prevChildren = this.children);
  8974. const rawChildren = this.$slots.default || [];
  8975. const children = (this.children = []);
  8976. const transitionData = extractTransitionData(this);
  8977. for (let i = 0; i < rawChildren.length; i++) {
  8978. const c = rawChildren[i];
  8979. if (c.tag) {
  8980. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8981. children.push(c);
  8982. map[c.key] = c;
  8983. (c.data || (c.data = {})).transition = transitionData;
  8984. }
  8985. else {
  8986. const opts = c.componentOptions;
  8987. const name = opts
  8988. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8989. : c.tag;
  8990. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8991. }
  8992. }
  8993. }
  8994. if (prevChildren) {
  8995. const kept = [];
  8996. const removed = [];
  8997. for (let i = 0; i < prevChildren.length; i++) {
  8998. const c = prevChildren[i];
  8999. c.data.transition = transitionData;
  9000. // @ts-expect-error .getBoundingClientRect is not typed in Node
  9001. c.data.pos = c.elm.getBoundingClientRect();
  9002. if (map[c.key]) {
  9003. kept.push(c);
  9004. }
  9005. else {
  9006. removed.push(c);
  9007. }
  9008. }
  9009. this.kept = h(tag, null, kept);
  9010. this.removed = removed;
  9011. }
  9012. return h(tag, null, children);
  9013. },
  9014. updated() {
  9015. const children = this.prevChildren;
  9016. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  9017. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  9018. return;
  9019. }
  9020. // we divide the work into three loops to avoid mixing DOM reads and writes
  9021. // in each iteration - which helps prevent layout thrashing.
  9022. children.forEach(callPendingCbs);
  9023. children.forEach(recordPosition);
  9024. children.forEach(applyTranslation);
  9025. // force reflow to put everything in position
  9026. // assign to this to avoid being removed in tree-shaking
  9027. // $flow-disable-line
  9028. this._reflow = document.body.offsetHeight;
  9029. children.forEach((c) => {
  9030. if (c.data.moved) {
  9031. const el = c.elm;
  9032. const s = el.style;
  9033. addTransitionClass(el, moveClass);
  9034. s.transform = s.WebkitTransform = s.transitionDuration = '';
  9035. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  9036. if (e && e.target !== el) {
  9037. return;
  9038. }
  9039. if (!e || /transform$/.test(e.propertyName)) {
  9040. el.removeEventListener(transitionEndEvent, cb);
  9041. el._moveCb = null;
  9042. removeTransitionClass(el, moveClass);
  9043. }
  9044. }));
  9045. }
  9046. });
  9047. },
  9048. methods: {
  9049. hasMove(el, moveClass) {
  9050. /* istanbul ignore if */
  9051. if (!hasTransition) {
  9052. return false;
  9053. }
  9054. /* istanbul ignore if */
  9055. if (this._hasMove) {
  9056. return this._hasMove;
  9057. }
  9058. // Detect whether an element with the move class applied has
  9059. // CSS transitions. Since the element may be inside an entering
  9060. // transition at this very moment, we make a clone of it and remove
  9061. // all other transition classes applied to ensure only the move class
  9062. // is applied.
  9063. const clone = el.cloneNode();
  9064. if (el._transitionClasses) {
  9065. el._transitionClasses.forEach((cls) => {
  9066. removeClass(clone, cls);
  9067. });
  9068. }
  9069. addClass(clone, moveClass);
  9070. clone.style.display = 'none';
  9071. this.$el.appendChild(clone);
  9072. const info = getTransitionInfo(clone);
  9073. this.$el.removeChild(clone);
  9074. return (this._hasMove = info.hasTransform);
  9075. }
  9076. }
  9077. };
  9078. function callPendingCbs(c) {
  9079. /* istanbul ignore if */
  9080. if (c.elm._moveCb) {
  9081. c.elm._moveCb();
  9082. }
  9083. /* istanbul ignore if */
  9084. if (c.elm._enterCb) {
  9085. c.elm._enterCb();
  9086. }
  9087. }
  9088. function recordPosition(c) {
  9089. c.data.newPos = c.elm.getBoundingClientRect();
  9090. }
  9091. function applyTranslation(c) {
  9092. const oldPos = c.data.pos;
  9093. const newPos = c.data.newPos;
  9094. const dx = oldPos.left - newPos.left;
  9095. const dy = oldPos.top - newPos.top;
  9096. if (dx || dy) {
  9097. c.data.moved = true;
  9098. const s = c.elm.style;
  9099. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9100. s.transitionDuration = '0s';
  9101. }
  9102. }
  9103. var platformComponents = {
  9104. Transition,
  9105. TransitionGroup
  9106. };
  9107. // install platform specific utils
  9108. Vue.config.mustUseProp = mustUseProp;
  9109. Vue.config.isReservedTag = isReservedTag;
  9110. Vue.config.isReservedAttr = isReservedAttr;
  9111. Vue.config.getTagNamespace = getTagNamespace;
  9112. Vue.config.isUnknownElement = isUnknownElement;
  9113. // install platform runtime directives & components
  9114. extend(Vue.options.directives, platformDirectives);
  9115. extend(Vue.options.components, platformComponents);
  9116. // install platform patch function
  9117. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9118. // public mount method
  9119. Vue.prototype.$mount = function (el, hydrating) {
  9120. el = el && inBrowser ? query(el) : undefined;
  9121. return mountComponent(this, el, hydrating);
  9122. };
  9123. // devtools global hook
  9124. /* istanbul ignore next */
  9125. if (inBrowser) {
  9126. setTimeout(() => {
  9127. if (config.devtools) {
  9128. if (devtools) {
  9129. devtools.emit('init', Vue);
  9130. }
  9131. else {
  9132. // @ts-expect-error
  9133. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9134. 'https://github.com/vuejs/vue-devtools');
  9135. }
  9136. }
  9137. if (config.productionTip !== false &&
  9138. typeof console !== 'undefined') {
  9139. // @ts-expect-error
  9140. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9141. `Make sure to turn on production mode when deploying for production.\n` +
  9142. `See more tips at https://vuejs.org/guide/deployment.html`);
  9143. }
  9144. }, 0);
  9145. }
  9146. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9147. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9148. const buildRegex = cached(delimiters => {
  9149. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9150. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9151. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9152. });
  9153. function parseText(text, delimiters) {
  9154. //@ts-expect-error
  9155. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9156. if (!tagRE.test(text)) {
  9157. return;
  9158. }
  9159. const tokens = [];
  9160. const rawTokens = [];
  9161. let lastIndex = (tagRE.lastIndex = 0);
  9162. let match, index, tokenValue;
  9163. while ((match = tagRE.exec(text))) {
  9164. index = match.index;
  9165. // push text token
  9166. if (index > lastIndex) {
  9167. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9168. tokens.push(JSON.stringify(tokenValue));
  9169. }
  9170. // tag token
  9171. const exp = parseFilters(match[1].trim());
  9172. tokens.push(`_s(${exp})`);
  9173. rawTokens.push({ '@binding': exp });
  9174. lastIndex = index + match[0].length;
  9175. }
  9176. if (lastIndex < text.length) {
  9177. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9178. tokens.push(JSON.stringify(tokenValue));
  9179. }
  9180. return {
  9181. expression: tokens.join('+'),
  9182. tokens: rawTokens
  9183. };
  9184. }
  9185. function transformNode$1(el, options) {
  9186. const warn = options.warn || baseWarn;
  9187. const staticClass = getAndRemoveAttr(el, 'class');
  9188. if (staticClass) {
  9189. const res = parseText(staticClass, options.delimiters);
  9190. if (res) {
  9191. warn(`class="${staticClass}": ` +
  9192. 'Interpolation inside attributes has been removed. ' +
  9193. 'Use v-bind or the colon shorthand instead. For example, ' +
  9194. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9195. }
  9196. }
  9197. if (staticClass) {
  9198. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9199. }
  9200. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9201. if (classBinding) {
  9202. el.classBinding = classBinding;
  9203. }
  9204. }
  9205. function genData$2(el) {
  9206. let data = '';
  9207. if (el.staticClass) {
  9208. data += `staticClass:${el.staticClass},`;
  9209. }
  9210. if (el.classBinding) {
  9211. data += `class:${el.classBinding},`;
  9212. }
  9213. return data;
  9214. }
  9215. var klass = {
  9216. staticKeys: ['staticClass'],
  9217. transformNode: transformNode$1,
  9218. genData: genData$2
  9219. };
  9220. function transformNode(el, options) {
  9221. const warn = options.warn || baseWarn;
  9222. const staticStyle = getAndRemoveAttr(el, 'style');
  9223. if (staticStyle) {
  9224. /* istanbul ignore if */
  9225. {
  9226. const res = parseText(staticStyle, options.delimiters);
  9227. if (res) {
  9228. warn(`style="${staticStyle}": ` +
  9229. 'Interpolation inside attributes has been removed. ' +
  9230. 'Use v-bind or the colon shorthand instead. For example, ' +
  9231. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9232. }
  9233. }
  9234. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9235. }
  9236. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9237. if (styleBinding) {
  9238. el.styleBinding = styleBinding;
  9239. }
  9240. }
  9241. function genData$1(el) {
  9242. let data = '';
  9243. if (el.staticStyle) {
  9244. data += `staticStyle:${el.staticStyle},`;
  9245. }
  9246. if (el.styleBinding) {
  9247. data += `style:(${el.styleBinding}),`;
  9248. }
  9249. return data;
  9250. }
  9251. var style = {
  9252. staticKeys: ['staticStyle'],
  9253. transformNode,
  9254. genData: genData$1
  9255. };
  9256. let decoder;
  9257. var he = {
  9258. decode(html) {
  9259. decoder = decoder || document.createElement('div');
  9260. decoder.innerHTML = html;
  9261. return decoder.textContent;
  9262. }
  9263. };
  9264. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9265. 'link,meta,param,source,track,wbr');
  9266. // Elements that you can, intentionally, leave open
  9267. // (and which close themselves)
  9268. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9269. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9270. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9271. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9272. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9273. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9274. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9275. 'title,tr,track');
  9276. /**
  9277. * Not type-checking this file because it's mostly vendor code.
  9278. */
  9279. // Regular Expressions for parsing tags and attributes
  9280. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9281. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9282. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9283. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9284. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9285. const startTagClose = /^\s*(\/?)>/;
  9286. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9287. const doctype = /^<!DOCTYPE [^>]+>/i;
  9288. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9289. const comment = /^<!\--/;
  9290. const conditionalComment = /^<!\[/;
  9291. // Special Elements (can contain anything)
  9292. const isPlainTextElement = makeMap('script,style,textarea', true);
  9293. const reCache = {};
  9294. const decodingMap = {
  9295. '&lt;': '<',
  9296. '&gt;': '>',
  9297. '&quot;': '"',
  9298. '&amp;': '&',
  9299. '&#10;': '\n',
  9300. '&#9;': '\t',
  9301. '&#39;': "'"
  9302. };
  9303. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9304. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9305. // #5992
  9306. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9307. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9308. function decodeAttr(value, shouldDecodeNewlines) {
  9309. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9310. return value.replace(re, match => decodingMap[match]);
  9311. }
  9312. function parseHTML(html, options) {
  9313. const stack = [];
  9314. const expectHTML = options.expectHTML;
  9315. const isUnaryTag = options.isUnaryTag || no;
  9316. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9317. let index = 0;
  9318. let last, lastTag;
  9319. while (html) {
  9320. last = html;
  9321. // Make sure we're not in a plaintext content element like script/style
  9322. if (!lastTag || !isPlainTextElement(lastTag)) {
  9323. let textEnd = html.indexOf('<');
  9324. if (textEnd === 0) {
  9325. // Comment:
  9326. if (comment.test(html)) {
  9327. const commentEnd = html.indexOf('-->');
  9328. if (commentEnd >= 0) {
  9329. if (options.shouldKeepComment && options.comment) {
  9330. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9331. }
  9332. advance(commentEnd + 3);
  9333. continue;
  9334. }
  9335. }
  9336. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9337. if (conditionalComment.test(html)) {
  9338. const conditionalEnd = html.indexOf(']>');
  9339. if (conditionalEnd >= 0) {
  9340. advance(conditionalEnd + 2);
  9341. continue;
  9342. }
  9343. }
  9344. // Doctype:
  9345. const doctypeMatch = html.match(doctype);
  9346. if (doctypeMatch) {
  9347. advance(doctypeMatch[0].length);
  9348. continue;
  9349. }
  9350. // End tag:
  9351. const endTagMatch = html.match(endTag);
  9352. if (endTagMatch) {
  9353. const curIndex = index;
  9354. advance(endTagMatch[0].length);
  9355. parseEndTag(endTagMatch[1], curIndex, index);
  9356. continue;
  9357. }
  9358. // Start tag:
  9359. const startTagMatch = parseStartTag();
  9360. if (startTagMatch) {
  9361. handleStartTag(startTagMatch);
  9362. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9363. advance(1);
  9364. }
  9365. continue;
  9366. }
  9367. }
  9368. let text, rest, next;
  9369. if (textEnd >= 0) {
  9370. rest = html.slice(textEnd);
  9371. while (!endTag.test(rest) &&
  9372. !startTagOpen.test(rest) &&
  9373. !comment.test(rest) &&
  9374. !conditionalComment.test(rest)) {
  9375. // < in plain text, be forgiving and treat it as text
  9376. next = rest.indexOf('<', 1);
  9377. if (next < 0)
  9378. break;
  9379. textEnd += next;
  9380. rest = html.slice(textEnd);
  9381. }
  9382. text = html.substring(0, textEnd);
  9383. }
  9384. if (textEnd < 0) {
  9385. text = html;
  9386. }
  9387. if (text) {
  9388. advance(text.length);
  9389. }
  9390. if (options.chars && text) {
  9391. options.chars(text, index - text.length, index);
  9392. }
  9393. }
  9394. else {
  9395. let endTagLength = 0;
  9396. const stackedTag = lastTag.toLowerCase();
  9397. const reStackedTag = reCache[stackedTag] ||
  9398. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9399. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9400. endTagLength = endTag.length;
  9401. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9402. text = text
  9403. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9404. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9405. }
  9406. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9407. text = text.slice(1);
  9408. }
  9409. if (options.chars) {
  9410. options.chars(text);
  9411. }
  9412. return '';
  9413. });
  9414. index += html.length - rest.length;
  9415. html = rest;
  9416. parseEndTag(stackedTag, index - endTagLength, index);
  9417. }
  9418. if (html === last) {
  9419. options.chars && options.chars(html);
  9420. if (!stack.length && options.warn) {
  9421. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9422. start: index + html.length
  9423. });
  9424. }
  9425. break;
  9426. }
  9427. }
  9428. // Clean up any remaining tags
  9429. parseEndTag();
  9430. function advance(n) {
  9431. index += n;
  9432. html = html.substring(n);
  9433. }
  9434. function parseStartTag() {
  9435. const start = html.match(startTagOpen);
  9436. if (start) {
  9437. const match = {
  9438. tagName: start[1],
  9439. attrs: [],
  9440. start: index
  9441. };
  9442. advance(start[0].length);
  9443. let end, attr;
  9444. while (!(end = html.match(startTagClose)) &&
  9445. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9446. attr.start = index;
  9447. advance(attr[0].length);
  9448. attr.end = index;
  9449. match.attrs.push(attr);
  9450. }
  9451. if (end) {
  9452. match.unarySlash = end[1];
  9453. advance(end[0].length);
  9454. match.end = index;
  9455. return match;
  9456. }
  9457. }
  9458. }
  9459. function handleStartTag(match) {
  9460. const tagName = match.tagName;
  9461. const unarySlash = match.unarySlash;
  9462. if (expectHTML) {
  9463. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9464. parseEndTag(lastTag);
  9465. }
  9466. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9467. parseEndTag(tagName);
  9468. }
  9469. }
  9470. const unary = isUnaryTag(tagName) || !!unarySlash;
  9471. const l = match.attrs.length;
  9472. const attrs = new Array(l);
  9473. for (let i = 0; i < l; i++) {
  9474. const args = match.attrs[i];
  9475. const value = args[3] || args[4] || args[5] || '';
  9476. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9477. ? options.shouldDecodeNewlinesForHref
  9478. : options.shouldDecodeNewlines;
  9479. attrs[i] = {
  9480. name: args[1],
  9481. value: decodeAttr(value, shouldDecodeNewlines)
  9482. };
  9483. if (options.outputSourceRange) {
  9484. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9485. attrs[i].end = args.end;
  9486. }
  9487. }
  9488. if (!unary) {
  9489. stack.push({
  9490. tag: tagName,
  9491. lowerCasedTag: tagName.toLowerCase(),
  9492. attrs: attrs,
  9493. start: match.start,
  9494. end: match.end
  9495. });
  9496. lastTag = tagName;
  9497. }
  9498. if (options.start) {
  9499. options.start(tagName, attrs, unary, match.start, match.end);
  9500. }
  9501. }
  9502. function parseEndTag(tagName, start, end) {
  9503. let pos, lowerCasedTagName;
  9504. if (start == null)
  9505. start = index;
  9506. if (end == null)
  9507. end = index;
  9508. // Find the closest opened tag of the same type
  9509. if (tagName) {
  9510. lowerCasedTagName = tagName.toLowerCase();
  9511. for (pos = stack.length - 1; pos >= 0; pos--) {
  9512. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9513. break;
  9514. }
  9515. }
  9516. }
  9517. else {
  9518. // If no tag name is provided, clean shop
  9519. pos = 0;
  9520. }
  9521. if (pos >= 0) {
  9522. // Close all the open elements, up the stack
  9523. for (let i = stack.length - 1; i >= pos; i--) {
  9524. if ((i > pos || !tagName) && options.warn) {
  9525. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9526. start: stack[i].start,
  9527. end: stack[i].end
  9528. });
  9529. }
  9530. if (options.end) {
  9531. options.end(stack[i].tag, start, end);
  9532. }
  9533. }
  9534. // Remove the open elements from the stack
  9535. stack.length = pos;
  9536. lastTag = pos && stack[pos - 1].tag;
  9537. }
  9538. else if (lowerCasedTagName === 'br') {
  9539. if (options.start) {
  9540. options.start(tagName, [], true, start, end);
  9541. }
  9542. }
  9543. else if (lowerCasedTagName === 'p') {
  9544. if (options.start) {
  9545. options.start(tagName, [], false, start, end);
  9546. }
  9547. if (options.end) {
  9548. options.end(tagName, start, end);
  9549. }
  9550. }
  9551. }
  9552. }
  9553. const onRE = /^@|^v-on:/;
  9554. const dirRE = /^v-|^@|^:|^#/;
  9555. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9556. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9557. const stripParensRE = /^\(|\)$/g;
  9558. const dynamicArgRE = /^\[.*\]$/;
  9559. const argRE = /:(.*)$/;
  9560. const bindRE = /^:|^\.|^v-bind:/;
  9561. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9562. const slotRE = /^v-slot(:|$)|^#/;
  9563. const lineBreakRE = /[\r\n]/;
  9564. const whitespaceRE = /[ \f\t\r\n]+/g;
  9565. const invalidAttributeRE = /[\s"'<>\/=]/;
  9566. const decodeHTMLCached = cached(he.decode);
  9567. const emptySlotScopeToken = `_empty_`;
  9568. // configurable state
  9569. let warn;
  9570. let delimiters;
  9571. let transforms;
  9572. let preTransforms;
  9573. let postTransforms;
  9574. let platformIsPreTag;
  9575. let platformMustUseProp;
  9576. let platformGetTagNamespace;
  9577. let maybeComponent;
  9578. function createASTElement(tag, attrs, parent) {
  9579. return {
  9580. type: 1,
  9581. tag,
  9582. attrsList: attrs,
  9583. attrsMap: makeAttrsMap(attrs),
  9584. rawAttrsMap: {},
  9585. parent,
  9586. children: []
  9587. };
  9588. }
  9589. /**
  9590. * Convert HTML string to AST.
  9591. */
  9592. function parse(template, options) {
  9593. warn = options.warn || baseWarn;
  9594. platformIsPreTag = options.isPreTag || no;
  9595. platformMustUseProp = options.mustUseProp || no;
  9596. platformGetTagNamespace = options.getTagNamespace || no;
  9597. const isReservedTag = options.isReservedTag || no;
  9598. maybeComponent = (el) => !!(el.component ||
  9599. el.attrsMap[':is'] ||
  9600. el.attrsMap['v-bind:is'] ||
  9601. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9602. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9603. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9604. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9605. delimiters = options.delimiters;
  9606. const stack = [];
  9607. const preserveWhitespace = options.preserveWhitespace !== false;
  9608. const whitespaceOption = options.whitespace;
  9609. let root;
  9610. let currentParent;
  9611. let inVPre = false;
  9612. let inPre = false;
  9613. let warned = false;
  9614. function warnOnce(msg, range) {
  9615. if (!warned) {
  9616. warned = true;
  9617. warn(msg, range);
  9618. }
  9619. }
  9620. function closeElement(element) {
  9621. trimEndingWhitespace(element);
  9622. if (!inVPre && !element.processed) {
  9623. element = processElement(element, options);
  9624. }
  9625. // tree management
  9626. if (!stack.length && element !== root) {
  9627. // allow root elements with v-if, v-else-if and v-else
  9628. if (root.if && (element.elseif || element.else)) {
  9629. {
  9630. checkRootConstraints(element);
  9631. }
  9632. addIfCondition(root, {
  9633. exp: element.elseif,
  9634. block: element
  9635. });
  9636. }
  9637. else {
  9638. warnOnce(`Component template should contain exactly one root element. ` +
  9639. `If you are using v-if on multiple elements, ` +
  9640. `use v-else-if to chain them instead.`, { start: element.start });
  9641. }
  9642. }
  9643. if (currentParent && !element.forbidden) {
  9644. if (element.elseif || element.else) {
  9645. processIfConditions(element, currentParent);
  9646. }
  9647. else {
  9648. if (element.slotScope) {
  9649. // scoped slot
  9650. // keep it in the children list so that v-else(-if) conditions can
  9651. // find it as the prev node.
  9652. const name = element.slotTarget || '"default"';
  9653. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9654. }
  9655. currentParent.children.push(element);
  9656. element.parent = currentParent;
  9657. }
  9658. }
  9659. // final children cleanup
  9660. // filter out scoped slots
  9661. element.children = element.children.filter(c => !c.slotScope);
  9662. // remove trailing whitespace node again
  9663. trimEndingWhitespace(element);
  9664. // check pre state
  9665. if (element.pre) {
  9666. inVPre = false;
  9667. }
  9668. if (platformIsPreTag(element.tag)) {
  9669. inPre = false;
  9670. }
  9671. // apply post-transforms
  9672. for (let i = 0; i < postTransforms.length; i++) {
  9673. postTransforms[i](element, options);
  9674. }
  9675. }
  9676. function trimEndingWhitespace(el) {
  9677. // remove trailing whitespace node
  9678. if (!inPre) {
  9679. let lastNode;
  9680. while ((lastNode = el.children[el.children.length - 1]) &&
  9681. lastNode.type === 3 &&
  9682. lastNode.text === ' ') {
  9683. el.children.pop();
  9684. }
  9685. }
  9686. }
  9687. function checkRootConstraints(el) {
  9688. if (el.tag === 'slot' || el.tag === 'template') {
  9689. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9690. 'contain multiple nodes.', { start: el.start });
  9691. }
  9692. if (el.attrsMap.hasOwnProperty('v-for')) {
  9693. warnOnce('Cannot use v-for on stateful component root element because ' +
  9694. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9695. }
  9696. }
  9697. parseHTML(template, {
  9698. warn,
  9699. expectHTML: options.expectHTML,
  9700. isUnaryTag: options.isUnaryTag,
  9701. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9702. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9703. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9704. shouldKeepComment: options.comments,
  9705. outputSourceRange: options.outputSourceRange,
  9706. start(tag, attrs, unary, start, end) {
  9707. // check namespace.
  9708. // inherit parent ns if there is one
  9709. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9710. // handle IE svg bug
  9711. /* istanbul ignore if */
  9712. if (isIE && ns === 'svg') {
  9713. attrs = guardIESVGBug(attrs);
  9714. }
  9715. let element = createASTElement(tag, attrs, currentParent);
  9716. if (ns) {
  9717. element.ns = ns;
  9718. }
  9719. {
  9720. if (options.outputSourceRange) {
  9721. element.start = start;
  9722. element.end = end;
  9723. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9724. cumulated[attr.name] = attr;
  9725. return cumulated;
  9726. }, {});
  9727. }
  9728. attrs.forEach(attr => {
  9729. if (invalidAttributeRE.test(attr.name)) {
  9730. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9731. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9732. ? {
  9733. start: attr.start + attr.name.indexOf(`[`),
  9734. end: attr.start + attr.name.length
  9735. }
  9736. : undefined);
  9737. }
  9738. });
  9739. }
  9740. if (isForbiddenTag(element) && !isServerRendering()) {
  9741. element.forbidden = true;
  9742. warn('Templates should only be responsible for mapping the state to the ' +
  9743. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9744. `<${tag}>` +
  9745. ', as they will not be parsed.', { start: element.start });
  9746. }
  9747. // apply pre-transforms
  9748. for (let i = 0; i < preTransforms.length; i++) {
  9749. element = preTransforms[i](element, options) || element;
  9750. }
  9751. if (!inVPre) {
  9752. processPre(element);
  9753. if (element.pre) {
  9754. inVPre = true;
  9755. }
  9756. }
  9757. if (platformIsPreTag(element.tag)) {
  9758. inPre = true;
  9759. }
  9760. if (inVPre) {
  9761. processRawAttrs(element);
  9762. }
  9763. else if (!element.processed) {
  9764. // structural directives
  9765. processFor(element);
  9766. processIf(element);
  9767. processOnce(element);
  9768. }
  9769. if (!root) {
  9770. root = element;
  9771. {
  9772. checkRootConstraints(root);
  9773. }
  9774. }
  9775. if (!unary) {
  9776. currentParent = element;
  9777. stack.push(element);
  9778. }
  9779. else {
  9780. closeElement(element);
  9781. }
  9782. },
  9783. end(tag, start, end) {
  9784. const element = stack[stack.length - 1];
  9785. // pop stack
  9786. stack.length -= 1;
  9787. currentParent = stack[stack.length - 1];
  9788. if (options.outputSourceRange) {
  9789. element.end = end;
  9790. }
  9791. closeElement(element);
  9792. },
  9793. chars(text, start, end) {
  9794. if (!currentParent) {
  9795. {
  9796. if (text === template) {
  9797. warnOnce('Component template requires a root element, rather than just text.', { start });
  9798. }
  9799. else if ((text = text.trim())) {
  9800. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9801. start
  9802. });
  9803. }
  9804. }
  9805. return;
  9806. }
  9807. // IE textarea placeholder bug
  9808. /* istanbul ignore if */
  9809. if (isIE &&
  9810. currentParent.tag === 'textarea' &&
  9811. currentParent.attrsMap.placeholder === text) {
  9812. return;
  9813. }
  9814. const children = currentParent.children;
  9815. if (inPre || text.trim()) {
  9816. text = isTextTag(currentParent)
  9817. ? text
  9818. : decodeHTMLCached(text);
  9819. }
  9820. else if (!children.length) {
  9821. // remove the whitespace-only node right after an opening tag
  9822. text = '';
  9823. }
  9824. else if (whitespaceOption) {
  9825. if (whitespaceOption === 'condense') {
  9826. // in condense mode, remove the whitespace node if it contains
  9827. // line break, otherwise condense to a single space
  9828. text = lineBreakRE.test(text) ? '' : ' ';
  9829. }
  9830. else {
  9831. text = ' ';
  9832. }
  9833. }
  9834. else {
  9835. text = preserveWhitespace ? ' ' : '';
  9836. }
  9837. if (text) {
  9838. if (!inPre && whitespaceOption === 'condense') {
  9839. // condense consecutive whitespaces into single space
  9840. text = text.replace(whitespaceRE, ' ');
  9841. }
  9842. let res;
  9843. let child;
  9844. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9845. child = {
  9846. type: 2,
  9847. expression: res.expression,
  9848. tokens: res.tokens,
  9849. text
  9850. };
  9851. }
  9852. else if (text !== ' ' ||
  9853. !children.length ||
  9854. children[children.length - 1].text !== ' ') {
  9855. child = {
  9856. type: 3,
  9857. text
  9858. };
  9859. }
  9860. if (child) {
  9861. if (options.outputSourceRange) {
  9862. child.start = start;
  9863. child.end = end;
  9864. }
  9865. children.push(child);
  9866. }
  9867. }
  9868. },
  9869. comment(text, start, end) {
  9870. // adding anything as a sibling to the root node is forbidden
  9871. // comments should still be allowed, but ignored
  9872. if (currentParent) {
  9873. const child = {
  9874. type: 3,
  9875. text,
  9876. isComment: true
  9877. };
  9878. if (options.outputSourceRange) {
  9879. child.start = start;
  9880. child.end = end;
  9881. }
  9882. currentParent.children.push(child);
  9883. }
  9884. }
  9885. });
  9886. return root;
  9887. }
  9888. function processPre(el) {
  9889. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9890. el.pre = true;
  9891. }
  9892. }
  9893. function processRawAttrs(el) {
  9894. const list = el.attrsList;
  9895. const len = list.length;
  9896. if (len) {
  9897. const attrs = (el.attrs = new Array(len));
  9898. for (let i = 0; i < len; i++) {
  9899. attrs[i] = {
  9900. name: list[i].name,
  9901. value: JSON.stringify(list[i].value)
  9902. };
  9903. if (list[i].start != null) {
  9904. attrs[i].start = list[i].start;
  9905. attrs[i].end = list[i].end;
  9906. }
  9907. }
  9908. }
  9909. else if (!el.pre) {
  9910. // non root node in pre blocks with no attributes
  9911. el.plain = true;
  9912. }
  9913. }
  9914. function processElement(element, options) {
  9915. processKey(element);
  9916. // determine whether this is a plain element after
  9917. // removing structural attributes
  9918. element.plain =
  9919. !element.key && !element.scopedSlots && !element.attrsList.length;
  9920. processRef(element);
  9921. processSlotContent(element);
  9922. processSlotOutlet(element);
  9923. processComponent(element);
  9924. for (let i = 0; i < transforms.length; i++) {
  9925. element = transforms[i](element, options) || element;
  9926. }
  9927. processAttrs(element);
  9928. return element;
  9929. }
  9930. function processKey(el) {
  9931. const exp = getBindingAttr(el, 'key');
  9932. if (exp) {
  9933. {
  9934. if (el.tag === 'template') {
  9935. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9936. }
  9937. if (el.for) {
  9938. const iterator = el.iterator2 || el.iterator1;
  9939. const parent = el.parent;
  9940. if (iterator &&
  9941. iterator === exp &&
  9942. parent &&
  9943. parent.tag === 'transition-group') {
  9944. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9945. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9946. }
  9947. }
  9948. }
  9949. el.key = exp;
  9950. }
  9951. }
  9952. function processRef(el) {
  9953. const ref = getBindingAttr(el, 'ref');
  9954. if (ref) {
  9955. el.ref = ref;
  9956. el.refInFor = checkInFor(el);
  9957. }
  9958. }
  9959. function processFor(el) {
  9960. let exp;
  9961. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9962. const res = parseFor(exp);
  9963. if (res) {
  9964. extend(el, res);
  9965. }
  9966. else {
  9967. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9968. }
  9969. }
  9970. }
  9971. function parseFor(exp) {
  9972. const inMatch = exp.match(forAliasRE);
  9973. if (!inMatch)
  9974. return;
  9975. const res = {};
  9976. res.for = inMatch[2].trim();
  9977. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9978. const iteratorMatch = alias.match(forIteratorRE);
  9979. if (iteratorMatch) {
  9980. res.alias = alias.replace(forIteratorRE, '').trim();
  9981. res.iterator1 = iteratorMatch[1].trim();
  9982. if (iteratorMatch[2]) {
  9983. res.iterator2 = iteratorMatch[2].trim();
  9984. }
  9985. }
  9986. else {
  9987. res.alias = alias;
  9988. }
  9989. return res;
  9990. }
  9991. function processIf(el) {
  9992. const exp = getAndRemoveAttr(el, 'v-if');
  9993. if (exp) {
  9994. el.if = exp;
  9995. addIfCondition(el, {
  9996. exp: exp,
  9997. block: el
  9998. });
  9999. }
  10000. else {
  10001. if (getAndRemoveAttr(el, 'v-else') != null) {
  10002. el.else = true;
  10003. }
  10004. const elseif = getAndRemoveAttr(el, 'v-else-if');
  10005. if (elseif) {
  10006. el.elseif = elseif;
  10007. }
  10008. }
  10009. }
  10010. function processIfConditions(el, parent) {
  10011. const prev = findPrevElement(parent.children);
  10012. if (prev && prev.if) {
  10013. addIfCondition(prev, {
  10014. exp: el.elseif,
  10015. block: el
  10016. });
  10017. }
  10018. else {
  10019. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  10020. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  10021. }
  10022. }
  10023. function findPrevElement(children) {
  10024. let i = children.length;
  10025. while (i--) {
  10026. if (children[i].type === 1) {
  10027. return children[i];
  10028. }
  10029. else {
  10030. if (children[i].text !== ' ') {
  10031. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  10032. `will be ignored.`, children[i]);
  10033. }
  10034. children.pop();
  10035. }
  10036. }
  10037. }
  10038. function addIfCondition(el, condition) {
  10039. if (!el.ifConditions) {
  10040. el.ifConditions = [];
  10041. }
  10042. el.ifConditions.push(condition);
  10043. }
  10044. function processOnce(el) {
  10045. const once = getAndRemoveAttr(el, 'v-once');
  10046. if (once != null) {
  10047. el.once = true;
  10048. }
  10049. }
  10050. // handle content being passed to a component as slot,
  10051. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10052. function processSlotContent(el) {
  10053. let slotScope;
  10054. if (el.tag === 'template') {
  10055. slotScope = getAndRemoveAttr(el, 'scope');
  10056. /* istanbul ignore if */
  10057. if (slotScope) {
  10058. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10059. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10060. `can also be used on plain elements in addition to <template> to ` +
  10061. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10062. }
  10063. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10064. }
  10065. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10066. /* istanbul ignore if */
  10067. if (el.attrsMap['v-for']) {
  10068. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10069. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10070. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10071. }
  10072. el.slotScope = slotScope;
  10073. }
  10074. // slot="xxx"
  10075. const slotTarget = getBindingAttr(el, 'slot');
  10076. if (slotTarget) {
  10077. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10078. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10079. // preserve slot as an attribute for native shadow DOM compat
  10080. // only for non-scoped slots.
  10081. if (el.tag !== 'template' && !el.slotScope) {
  10082. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10083. }
  10084. }
  10085. // 2.6 v-slot syntax
  10086. {
  10087. if (el.tag === 'template') {
  10088. // v-slot on <template>
  10089. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10090. if (slotBinding) {
  10091. {
  10092. if (el.slotTarget || el.slotScope) {
  10093. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10094. }
  10095. if (el.parent && !maybeComponent(el.parent)) {
  10096. warn(`<template v-slot> can only appear at the root level inside ` +
  10097. `the receiving component`, el);
  10098. }
  10099. }
  10100. const { name, dynamic } = getSlotName(slotBinding);
  10101. el.slotTarget = name;
  10102. el.slotTargetDynamic = dynamic;
  10103. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10104. }
  10105. }
  10106. else {
  10107. // v-slot on component, denotes default slot
  10108. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10109. if (slotBinding) {
  10110. {
  10111. if (!maybeComponent(el)) {
  10112. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10113. }
  10114. if (el.slotScope || el.slotTarget) {
  10115. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10116. }
  10117. if (el.scopedSlots) {
  10118. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10119. `<template> syntax when there are other named slots.`, slotBinding);
  10120. }
  10121. }
  10122. // add the component's children to its default slot
  10123. const slots = el.scopedSlots || (el.scopedSlots = {});
  10124. const { name, dynamic } = getSlotName(slotBinding);
  10125. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10126. slotContainer.slotTarget = name;
  10127. slotContainer.slotTargetDynamic = dynamic;
  10128. slotContainer.children = el.children.filter((c) => {
  10129. if (!c.slotScope) {
  10130. c.parent = slotContainer;
  10131. return true;
  10132. }
  10133. });
  10134. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10135. // remove children as they are returned from scopedSlots now
  10136. el.children = [];
  10137. // mark el non-plain so data gets generated
  10138. el.plain = false;
  10139. }
  10140. }
  10141. }
  10142. }
  10143. function getSlotName(binding) {
  10144. let name = binding.name.replace(slotRE, '');
  10145. if (!name) {
  10146. if (binding.name[0] !== '#') {
  10147. name = 'default';
  10148. }
  10149. else {
  10150. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10151. }
  10152. }
  10153. return dynamicArgRE.test(name)
  10154. ? // dynamic [name]
  10155. { name: name.slice(1, -1), dynamic: true }
  10156. : // static name
  10157. { name: `"${name}"`, dynamic: false };
  10158. }
  10159. // handle <slot/> outlets
  10160. function processSlotOutlet(el) {
  10161. if (el.tag === 'slot') {
  10162. el.slotName = getBindingAttr(el, 'name');
  10163. if (el.key) {
  10164. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10165. `and can possibly expand into multiple elements. ` +
  10166. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10167. }
  10168. }
  10169. }
  10170. function processComponent(el) {
  10171. let binding;
  10172. if ((binding = getBindingAttr(el, 'is'))) {
  10173. el.component = binding;
  10174. }
  10175. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10176. el.inlineTemplate = true;
  10177. }
  10178. }
  10179. function processAttrs(el) {
  10180. const list = el.attrsList;
  10181. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10182. for (i = 0, l = list.length; i < l; i++) {
  10183. name = rawName = list[i].name;
  10184. value = list[i].value;
  10185. if (dirRE.test(name)) {
  10186. // mark element as dynamic
  10187. el.hasBindings = true;
  10188. // modifiers
  10189. modifiers = parseModifiers(name.replace(dirRE, ''));
  10190. // support .foo shorthand syntax for the .prop modifier
  10191. if (modifiers) {
  10192. name = name.replace(modifierRE, '');
  10193. }
  10194. if (bindRE.test(name)) {
  10195. // v-bind
  10196. name = name.replace(bindRE, '');
  10197. value = parseFilters(value);
  10198. isDynamic = dynamicArgRE.test(name);
  10199. if (isDynamic) {
  10200. name = name.slice(1, -1);
  10201. }
  10202. if (value.trim().length === 0) {
  10203. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10204. }
  10205. if (modifiers) {
  10206. if (modifiers.prop && !isDynamic) {
  10207. name = camelize(name);
  10208. if (name === 'innerHtml')
  10209. name = 'innerHTML';
  10210. }
  10211. if (modifiers.camel && !isDynamic) {
  10212. name = camelize(name);
  10213. }
  10214. if (modifiers.sync) {
  10215. syncGen = genAssignmentCode(value, `$event`);
  10216. if (!isDynamic) {
  10217. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10218. if (hyphenate(name) !== camelize(name)) {
  10219. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10220. }
  10221. }
  10222. else {
  10223. // handler w/ dynamic event name
  10224. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10225. );
  10226. }
  10227. }
  10228. }
  10229. if ((modifiers && modifiers.prop) ||
  10230. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10231. addProp(el, name, value, list[i], isDynamic);
  10232. }
  10233. else {
  10234. addAttr(el, name, value, list[i], isDynamic);
  10235. }
  10236. }
  10237. else if (onRE.test(name)) {
  10238. // v-on
  10239. name = name.replace(onRE, '');
  10240. isDynamic = dynamicArgRE.test(name);
  10241. if (isDynamic) {
  10242. name = name.slice(1, -1);
  10243. }
  10244. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10245. }
  10246. else {
  10247. // normal directives
  10248. name = name.replace(dirRE, '');
  10249. // parse arg
  10250. const argMatch = name.match(argRE);
  10251. let arg = argMatch && argMatch[1];
  10252. isDynamic = false;
  10253. if (arg) {
  10254. name = name.slice(0, -(arg.length + 1));
  10255. if (dynamicArgRE.test(arg)) {
  10256. arg = arg.slice(1, -1);
  10257. isDynamic = true;
  10258. }
  10259. }
  10260. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10261. if (name === 'model') {
  10262. checkForAliasModel(el, value);
  10263. }
  10264. }
  10265. }
  10266. else {
  10267. // literal attribute
  10268. {
  10269. const res = parseText(value, delimiters);
  10270. if (res) {
  10271. warn(`${name}="${value}": ` +
  10272. 'Interpolation inside attributes has been removed. ' +
  10273. 'Use v-bind or the colon shorthand instead. For example, ' +
  10274. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10275. }
  10276. }
  10277. addAttr(el, name, JSON.stringify(value), list[i]);
  10278. // #6887 firefox doesn't update muted state if set via attribute
  10279. // even immediately after element creation
  10280. if (!el.component &&
  10281. name === 'muted' &&
  10282. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10283. addProp(el, name, 'true', list[i]);
  10284. }
  10285. }
  10286. }
  10287. }
  10288. function checkInFor(el) {
  10289. let parent = el;
  10290. while (parent) {
  10291. if (parent.for !== undefined) {
  10292. return true;
  10293. }
  10294. parent = parent.parent;
  10295. }
  10296. return false;
  10297. }
  10298. function parseModifiers(name) {
  10299. const match = name.match(modifierRE);
  10300. if (match) {
  10301. const ret = {};
  10302. match.forEach(m => {
  10303. ret[m.slice(1)] = true;
  10304. });
  10305. return ret;
  10306. }
  10307. }
  10308. function makeAttrsMap(attrs) {
  10309. const map = {};
  10310. for (let i = 0, l = attrs.length; i < l; i++) {
  10311. if (map[attrs[i].name] && !isIE && !isEdge) {
  10312. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10313. }
  10314. map[attrs[i].name] = attrs[i].value;
  10315. }
  10316. return map;
  10317. }
  10318. // for script (e.g. type="x/template") or style, do not decode content
  10319. function isTextTag(el) {
  10320. return el.tag === 'script' || el.tag === 'style';
  10321. }
  10322. function isForbiddenTag(el) {
  10323. return (el.tag === 'style' ||
  10324. (el.tag === 'script' &&
  10325. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10326. }
  10327. const ieNSBug = /^xmlns:NS\d+/;
  10328. const ieNSPrefix = /^NS\d+:/;
  10329. /* istanbul ignore next */
  10330. function guardIESVGBug(attrs) {
  10331. const res = [];
  10332. for (let i = 0; i < attrs.length; i++) {
  10333. const attr = attrs[i];
  10334. if (!ieNSBug.test(attr.name)) {
  10335. attr.name = attr.name.replace(ieNSPrefix, '');
  10336. res.push(attr);
  10337. }
  10338. }
  10339. return res;
  10340. }
  10341. function checkForAliasModel(el, value) {
  10342. let _el = el;
  10343. while (_el) {
  10344. if (_el.for && _el.alias === value) {
  10345. warn(`<${el.tag} v-model="${value}">: ` +
  10346. `You are binding v-model directly to a v-for iteration alias. ` +
  10347. `This will not be able to modify the v-for source array because ` +
  10348. `writing to the alias is like modifying a function local variable. ` +
  10349. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10350. }
  10351. _el = _el.parent;
  10352. }
  10353. }
  10354. /**
  10355. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10356. * Turn this:
  10357. * <input v-model="data[type]" :type="type">
  10358. * into this:
  10359. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10360. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10361. * <input v-else :type="type" v-model="data[type]">
  10362. */
  10363. function preTransformNode(el, options) {
  10364. if (el.tag === 'input') {
  10365. const map = el.attrsMap;
  10366. if (!map['v-model']) {
  10367. return;
  10368. }
  10369. let typeBinding;
  10370. if (map[':type'] || map['v-bind:type']) {
  10371. typeBinding = getBindingAttr(el, 'type');
  10372. }
  10373. if (!map.type && !typeBinding && map['v-bind']) {
  10374. typeBinding = `(${map['v-bind']}).type`;
  10375. }
  10376. if (typeBinding) {
  10377. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10378. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10379. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10380. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10381. // 1. checkbox
  10382. const branch0 = cloneASTElement(el);
  10383. // process for on the main node
  10384. processFor(branch0);
  10385. addRawAttr(branch0, 'type', 'checkbox');
  10386. processElement(branch0, options);
  10387. branch0.processed = true; // prevent it from double-processed
  10388. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10389. addIfCondition(branch0, {
  10390. exp: branch0.if,
  10391. block: branch0
  10392. });
  10393. // 2. add radio else-if condition
  10394. const branch1 = cloneASTElement(el);
  10395. getAndRemoveAttr(branch1, 'v-for', true);
  10396. addRawAttr(branch1, 'type', 'radio');
  10397. processElement(branch1, options);
  10398. addIfCondition(branch0, {
  10399. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10400. block: branch1
  10401. });
  10402. // 3. other
  10403. const branch2 = cloneASTElement(el);
  10404. getAndRemoveAttr(branch2, 'v-for', true);
  10405. addRawAttr(branch2, ':type', typeBinding);
  10406. processElement(branch2, options);
  10407. addIfCondition(branch0, {
  10408. exp: ifCondition,
  10409. block: branch2
  10410. });
  10411. if (hasElse) {
  10412. branch0.else = true;
  10413. }
  10414. else if (elseIfCondition) {
  10415. branch0.elseif = elseIfCondition;
  10416. }
  10417. return branch0;
  10418. }
  10419. }
  10420. }
  10421. function cloneASTElement(el) {
  10422. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10423. }
  10424. var model = {
  10425. preTransformNode
  10426. };
  10427. var modules = [klass, style, model];
  10428. function text(el, dir) {
  10429. if (dir.value) {
  10430. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10431. }
  10432. }
  10433. function html(el, dir) {
  10434. if (dir.value) {
  10435. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10436. }
  10437. }
  10438. var directives = {
  10439. model: model$1,
  10440. text,
  10441. html
  10442. };
  10443. const baseOptions = {
  10444. expectHTML: true,
  10445. modules,
  10446. directives,
  10447. isPreTag,
  10448. isUnaryTag,
  10449. mustUseProp,
  10450. canBeLeftOpenTag,
  10451. isReservedTag,
  10452. getTagNamespace,
  10453. staticKeys: genStaticKeys$1(modules)
  10454. };
  10455. let isStaticKey;
  10456. let isPlatformReservedTag;
  10457. const genStaticKeysCached = cached(genStaticKeys);
  10458. /**
  10459. * Goal of the optimizer: walk the generated template AST tree
  10460. * and detect sub-trees that are purely static, i.e. parts of
  10461. * the DOM that never needs to change.
  10462. *
  10463. * Once we detect these sub-trees, we can:
  10464. *
  10465. * 1. Hoist them into constants, so that we no longer need to
  10466. * create fresh nodes for them on each re-render;
  10467. * 2. Completely skip them in the patching process.
  10468. */
  10469. function optimize(root, options) {
  10470. if (!root)
  10471. return;
  10472. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10473. isPlatformReservedTag = options.isReservedTag || no;
  10474. // first pass: mark all non-static nodes.
  10475. markStatic(root);
  10476. // second pass: mark static roots.
  10477. markStaticRoots(root, false);
  10478. }
  10479. function genStaticKeys(keys) {
  10480. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10481. (keys ? ',' + keys : ''));
  10482. }
  10483. function markStatic(node) {
  10484. node.static = isStatic(node);
  10485. if (node.type === 1) {
  10486. // do not make component slot content static. this avoids
  10487. // 1. components not able to mutate slot nodes
  10488. // 2. static slot content fails for hot-reloading
  10489. if (!isPlatformReservedTag(node.tag) &&
  10490. node.tag !== 'slot' &&
  10491. node.attrsMap['inline-template'] == null) {
  10492. return;
  10493. }
  10494. for (let i = 0, l = node.children.length; i < l; i++) {
  10495. const child = node.children[i];
  10496. markStatic(child);
  10497. if (!child.static) {
  10498. node.static = false;
  10499. }
  10500. }
  10501. if (node.ifConditions) {
  10502. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10503. const block = node.ifConditions[i].block;
  10504. markStatic(block);
  10505. if (!block.static) {
  10506. node.static = false;
  10507. }
  10508. }
  10509. }
  10510. }
  10511. }
  10512. function markStaticRoots(node, isInFor) {
  10513. if (node.type === 1) {
  10514. if (node.static || node.once) {
  10515. node.staticInFor = isInFor;
  10516. }
  10517. // For a node to qualify as a static root, it should have children that
  10518. // are not just static text. Otherwise the cost of hoisting out will
  10519. // outweigh the benefits and it's better off to just always render it fresh.
  10520. if (node.static &&
  10521. node.children.length &&
  10522. !(node.children.length === 1 && node.children[0].type === 3)) {
  10523. node.staticRoot = true;
  10524. return;
  10525. }
  10526. else {
  10527. node.staticRoot = false;
  10528. }
  10529. if (node.children) {
  10530. for (let i = 0, l = node.children.length; i < l; i++) {
  10531. markStaticRoots(node.children[i], isInFor || !!node.for);
  10532. }
  10533. }
  10534. if (node.ifConditions) {
  10535. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10536. markStaticRoots(node.ifConditions[i].block, isInFor);
  10537. }
  10538. }
  10539. }
  10540. }
  10541. function isStatic(node) {
  10542. if (node.type === 2) {
  10543. // expression
  10544. return false;
  10545. }
  10546. if (node.type === 3) {
  10547. // text
  10548. return true;
  10549. }
  10550. return !!(node.pre ||
  10551. (!node.hasBindings && // no dynamic bindings
  10552. !node.if &&
  10553. !node.for && // not v-if or v-for or v-else
  10554. !isBuiltInTag(node.tag) && // not a built-in
  10555. isPlatformReservedTag(node.tag) && // not a component
  10556. !isDirectChildOfTemplateFor(node) &&
  10557. Object.keys(node).every(isStaticKey)));
  10558. }
  10559. function isDirectChildOfTemplateFor(node) {
  10560. while (node.parent) {
  10561. node = node.parent;
  10562. if (node.tag !== 'template') {
  10563. return false;
  10564. }
  10565. if (node.for) {
  10566. return true;
  10567. }
  10568. }
  10569. return false;
  10570. }
  10571. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10572. const fnInvokeRE = /\([^)]*?\);*$/;
  10573. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10574. // KeyboardEvent.keyCode aliases
  10575. const keyCodes = {
  10576. esc: 27,
  10577. tab: 9,
  10578. enter: 13,
  10579. space: 32,
  10580. up: 38,
  10581. left: 37,
  10582. right: 39,
  10583. down: 40,
  10584. delete: [8, 46]
  10585. };
  10586. // KeyboardEvent.key aliases
  10587. const keyNames = {
  10588. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10589. esc: ['Esc', 'Escape'],
  10590. tab: 'Tab',
  10591. enter: 'Enter',
  10592. // #9112: IE11 uses `Spacebar` for Space key name.
  10593. space: [' ', 'Spacebar'],
  10594. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10595. up: ['Up', 'ArrowUp'],
  10596. left: ['Left', 'ArrowLeft'],
  10597. right: ['Right', 'ArrowRight'],
  10598. down: ['Down', 'ArrowDown'],
  10599. // #9112: IE11 uses `Del` for Delete key name.
  10600. delete: ['Backspace', 'Delete', 'Del']
  10601. };
  10602. // #4868: modifiers that prevent the execution of the listener
  10603. // need to explicitly return null so that we can determine whether to remove
  10604. // the listener for .once
  10605. const genGuard = condition => `if(${condition})return null;`;
  10606. const modifierCode = {
  10607. stop: '$event.stopPropagation();',
  10608. prevent: '$event.preventDefault();',
  10609. self: genGuard(`$event.target !== $event.currentTarget`),
  10610. ctrl: genGuard(`!$event.ctrlKey`),
  10611. shift: genGuard(`!$event.shiftKey`),
  10612. alt: genGuard(`!$event.altKey`),
  10613. meta: genGuard(`!$event.metaKey`),
  10614. left: genGuard(`'button' in $event && $event.button !== 0`),
  10615. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10616. right: genGuard(`'button' in $event && $event.button !== 2`)
  10617. };
  10618. function genHandlers(events, isNative) {
  10619. const prefix = isNative ? 'nativeOn:' : 'on:';
  10620. let staticHandlers = ``;
  10621. let dynamicHandlers = ``;
  10622. for (const name in events) {
  10623. const handlerCode = genHandler(events[name]);
  10624. //@ts-expect-error
  10625. if (events[name] && events[name].dynamic) {
  10626. dynamicHandlers += `${name},${handlerCode},`;
  10627. }
  10628. else {
  10629. staticHandlers += `"${name}":${handlerCode},`;
  10630. }
  10631. }
  10632. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10633. if (dynamicHandlers) {
  10634. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10635. }
  10636. else {
  10637. return prefix + staticHandlers;
  10638. }
  10639. }
  10640. function genHandler(handler) {
  10641. if (!handler) {
  10642. return 'function(){}';
  10643. }
  10644. if (Array.isArray(handler)) {
  10645. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10646. }
  10647. const isMethodPath = simplePathRE.test(handler.value);
  10648. const isFunctionExpression = fnExpRE.test(handler.value);
  10649. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10650. if (!handler.modifiers) {
  10651. if (isMethodPath || isFunctionExpression) {
  10652. return handler.value;
  10653. }
  10654. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10655. }
  10656. else {
  10657. let code = '';
  10658. let genModifierCode = '';
  10659. const keys = [];
  10660. for (const key in handler.modifiers) {
  10661. if (modifierCode[key]) {
  10662. genModifierCode += modifierCode[key];
  10663. // left/right
  10664. if (keyCodes[key]) {
  10665. keys.push(key);
  10666. }
  10667. }
  10668. else if (key === 'exact') {
  10669. const modifiers = handler.modifiers;
  10670. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10671. .filter(keyModifier => !modifiers[keyModifier])
  10672. .map(keyModifier => `$event.${keyModifier}Key`)
  10673. .join('||'));
  10674. }
  10675. else {
  10676. keys.push(key);
  10677. }
  10678. }
  10679. if (keys.length) {
  10680. code += genKeyFilter(keys);
  10681. }
  10682. // Make sure modifiers like prevent and stop get executed after key filtering
  10683. if (genModifierCode) {
  10684. code += genModifierCode;
  10685. }
  10686. const handlerCode = isMethodPath
  10687. ? `return ${handler.value}.apply(null, arguments)`
  10688. : isFunctionExpression
  10689. ? `return (${handler.value}).apply(null, arguments)`
  10690. : isFunctionInvocation
  10691. ? `return ${handler.value}`
  10692. : handler.value;
  10693. return `function($event){${code}${handlerCode}}`;
  10694. }
  10695. }
  10696. function genKeyFilter(keys) {
  10697. return (
  10698. // make sure the key filters only apply to KeyboardEvents
  10699. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10700. // key events that do not have keyCode property...
  10701. `if(!$event.type.indexOf('key')&&` +
  10702. `${keys.map(genFilterCode).join('&&')})return null;`);
  10703. }
  10704. function genFilterCode(key) {
  10705. const keyVal = parseInt(key, 10);
  10706. if (keyVal) {
  10707. return `$event.keyCode!==${keyVal}`;
  10708. }
  10709. const keyCode = keyCodes[key];
  10710. const keyName = keyNames[key];
  10711. return (`_k($event.keyCode,` +
  10712. `${JSON.stringify(key)},` +
  10713. `${JSON.stringify(keyCode)},` +
  10714. `$event.key,` +
  10715. `${JSON.stringify(keyName)}` +
  10716. `)`);
  10717. }
  10718. function on(el, dir) {
  10719. if (dir.modifiers) {
  10720. warn$2(`v-on without argument does not support modifiers.`);
  10721. }
  10722. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10723. }
  10724. function bind(el, dir) {
  10725. el.wrapData = (code) => {
  10726. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10727. };
  10728. }
  10729. var baseDirectives = {
  10730. on,
  10731. bind,
  10732. cloak: noop
  10733. };
  10734. class CodegenState {
  10735. constructor(options) {
  10736. this.options = options;
  10737. this.warn = options.warn || baseWarn;
  10738. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10739. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10740. this.directives = extend(extend({}, baseDirectives), options.directives);
  10741. const isReservedTag = options.isReservedTag || no;
  10742. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10743. this.onceId = 0;
  10744. this.staticRenderFns = [];
  10745. this.pre = false;
  10746. }
  10747. }
  10748. function generate(ast, options) {
  10749. const state = new CodegenState(options);
  10750. // fix #11483, Root level <script> tags should not be rendered.
  10751. const code = ast
  10752. ? ast.tag === 'script'
  10753. ? 'null'
  10754. : genElement(ast, state)
  10755. : '_c("div")';
  10756. return {
  10757. render: `with(this){return ${code}}`,
  10758. staticRenderFns: state.staticRenderFns
  10759. };
  10760. }
  10761. function genElement(el, state) {
  10762. if (el.parent) {
  10763. el.pre = el.pre || el.parent.pre;
  10764. }
  10765. if (el.staticRoot && !el.staticProcessed) {
  10766. return genStatic(el, state);
  10767. }
  10768. else if (el.once && !el.onceProcessed) {
  10769. return genOnce(el, state);
  10770. }
  10771. else if (el.for && !el.forProcessed) {
  10772. return genFor(el, state);
  10773. }
  10774. else if (el.if && !el.ifProcessed) {
  10775. return genIf(el, state);
  10776. }
  10777. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10778. return genChildren(el, state) || 'void 0';
  10779. }
  10780. else if (el.tag === 'slot') {
  10781. return genSlot(el, state);
  10782. }
  10783. else {
  10784. // component or element
  10785. let code;
  10786. if (el.component) {
  10787. code = genComponent(el.component, el, state);
  10788. }
  10789. else {
  10790. let data;
  10791. const maybeComponent = state.maybeComponent(el);
  10792. if (!el.plain || (el.pre && maybeComponent)) {
  10793. data = genData(el, state);
  10794. }
  10795. let tag;
  10796. // check if this is a component in <script setup>
  10797. const bindings = state.options.bindings;
  10798. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10799. tag = checkBindingType(bindings, el.tag);
  10800. }
  10801. if (!tag)
  10802. tag = `'${el.tag}'`;
  10803. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10804. code = `_c(${tag}${data ? `,${data}` : '' // data
  10805. }${children ? `,${children}` : '' // children
  10806. })`;
  10807. }
  10808. // module transforms
  10809. for (let i = 0; i < state.transforms.length; i++) {
  10810. code = state.transforms[i](el, code);
  10811. }
  10812. return code;
  10813. }
  10814. }
  10815. function checkBindingType(bindings, key) {
  10816. const camelName = camelize(key);
  10817. const PascalName = capitalize(camelName);
  10818. const checkType = (type) => {
  10819. if (bindings[key] === type) {
  10820. return key;
  10821. }
  10822. if (bindings[camelName] === type) {
  10823. return camelName;
  10824. }
  10825. if (bindings[PascalName] === type) {
  10826. return PascalName;
  10827. }
  10828. };
  10829. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10830. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10831. if (fromConst) {
  10832. return fromConst;
  10833. }
  10834. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10835. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10836. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10837. if (fromMaybeRef) {
  10838. return fromMaybeRef;
  10839. }
  10840. }
  10841. // hoist static sub-trees out
  10842. function genStatic(el, state) {
  10843. el.staticProcessed = true;
  10844. // Some elements (templates) need to behave differently inside of a v-pre
  10845. // node. All pre nodes are static roots, so we can use this as a location to
  10846. // wrap a state change and reset it upon exiting the pre node.
  10847. const originalPreState = state.pre;
  10848. if (el.pre) {
  10849. state.pre = el.pre;
  10850. }
  10851. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10852. state.pre = originalPreState;
  10853. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10854. }
  10855. // v-once
  10856. function genOnce(el, state) {
  10857. el.onceProcessed = true;
  10858. if (el.if && !el.ifProcessed) {
  10859. return genIf(el, state);
  10860. }
  10861. else if (el.staticInFor) {
  10862. let key = '';
  10863. let parent = el.parent;
  10864. while (parent) {
  10865. if (parent.for) {
  10866. key = parent.key;
  10867. break;
  10868. }
  10869. parent = parent.parent;
  10870. }
  10871. if (!key) {
  10872. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10873. return genElement(el, state);
  10874. }
  10875. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10876. }
  10877. else {
  10878. return genStatic(el, state);
  10879. }
  10880. }
  10881. function genIf(el, state, altGen, altEmpty) {
  10882. el.ifProcessed = true; // avoid recursion
  10883. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10884. }
  10885. function genIfConditions(conditions, state, altGen, altEmpty) {
  10886. if (!conditions.length) {
  10887. return altEmpty || '_e()';
  10888. }
  10889. const condition = conditions.shift();
  10890. if (condition.exp) {
  10891. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10892. }
  10893. else {
  10894. return `${genTernaryExp(condition.block)}`;
  10895. }
  10896. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10897. function genTernaryExp(el) {
  10898. return altGen
  10899. ? altGen(el, state)
  10900. : el.once
  10901. ? genOnce(el, state)
  10902. : genElement(el, state);
  10903. }
  10904. }
  10905. function genFor(el, state, altGen, altHelper) {
  10906. const exp = el.for;
  10907. const alias = el.alias;
  10908. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10909. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10910. if (state.maybeComponent(el) &&
  10911. el.tag !== 'slot' &&
  10912. el.tag !== 'template' &&
  10913. !el.key) {
  10914. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10915. `v-for should have explicit keys. ` +
  10916. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10917. }
  10918. el.forProcessed = true; // avoid recursion
  10919. return (`${altHelper || '_l'}((${exp}),` +
  10920. `function(${alias}${iterator1}${iterator2}){` +
  10921. `return ${(altGen || genElement)(el, state)}` +
  10922. '})');
  10923. }
  10924. function genData(el, state) {
  10925. let data = '{';
  10926. // directives first.
  10927. // directives may mutate the el's other properties before they are generated.
  10928. const dirs = genDirectives(el, state);
  10929. if (dirs)
  10930. data += dirs + ',';
  10931. // key
  10932. if (el.key) {
  10933. data += `key:${el.key},`;
  10934. }
  10935. // ref
  10936. if (el.ref) {
  10937. data += `ref:${el.ref},`;
  10938. }
  10939. if (el.refInFor) {
  10940. data += `refInFor:true,`;
  10941. }
  10942. // pre
  10943. if (el.pre) {
  10944. data += `pre:true,`;
  10945. }
  10946. // record original tag name for components using "is" attribute
  10947. if (el.component) {
  10948. data += `tag:"${el.tag}",`;
  10949. }
  10950. // module data generation functions
  10951. for (let i = 0; i < state.dataGenFns.length; i++) {
  10952. data += state.dataGenFns[i](el);
  10953. }
  10954. // attributes
  10955. if (el.attrs) {
  10956. data += `attrs:${genProps(el.attrs)},`;
  10957. }
  10958. // DOM props
  10959. if (el.props) {
  10960. data += `domProps:${genProps(el.props)},`;
  10961. }
  10962. // event handlers
  10963. if (el.events) {
  10964. data += `${genHandlers(el.events, false)},`;
  10965. }
  10966. if (el.nativeEvents) {
  10967. data += `${genHandlers(el.nativeEvents, true)},`;
  10968. }
  10969. // slot target
  10970. // only for non-scoped slots
  10971. if (el.slotTarget && !el.slotScope) {
  10972. data += `slot:${el.slotTarget},`;
  10973. }
  10974. // scoped slots
  10975. if (el.scopedSlots) {
  10976. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10977. }
  10978. // component v-model
  10979. if (el.model) {
  10980. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10981. }
  10982. // inline-template
  10983. if (el.inlineTemplate) {
  10984. const inlineTemplate = genInlineTemplate(el, state);
  10985. if (inlineTemplate) {
  10986. data += `${inlineTemplate},`;
  10987. }
  10988. }
  10989. data = data.replace(/,$/, '') + '}';
  10990. // v-bind dynamic argument wrap
  10991. // v-bind with dynamic arguments must be applied using the same v-bind object
  10992. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10993. if (el.dynamicAttrs) {
  10994. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10995. }
  10996. // v-bind data wrap
  10997. if (el.wrapData) {
  10998. data = el.wrapData(data);
  10999. }
  11000. // v-on data wrap
  11001. if (el.wrapListeners) {
  11002. data = el.wrapListeners(data);
  11003. }
  11004. return data;
  11005. }
  11006. function genDirectives(el, state) {
  11007. const dirs = el.directives;
  11008. if (!dirs)
  11009. return;
  11010. let res = 'directives:[';
  11011. let hasRuntime = false;
  11012. let i, l, dir, needRuntime;
  11013. for (i = 0, l = dirs.length; i < l; i++) {
  11014. dir = dirs[i];
  11015. needRuntime = true;
  11016. const gen = state.directives[dir.name];
  11017. if (gen) {
  11018. // compile-time directive that manipulates AST.
  11019. // returns true if it also needs a runtime counterpart.
  11020. needRuntime = !!gen(el, dir, state.warn);
  11021. }
  11022. if (needRuntime) {
  11023. hasRuntime = true;
  11024. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11025. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11026. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11027. }
  11028. }
  11029. if (hasRuntime) {
  11030. return res.slice(0, -1) + ']';
  11031. }
  11032. }
  11033. function genInlineTemplate(el, state) {
  11034. const ast = el.children[0];
  11035. if ((el.children.length !== 1 || ast.type !== 1)) {
  11036. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11037. }
  11038. if (ast && ast.type === 1) {
  11039. const inlineRenderFns = generate(ast, state.options);
  11040. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11041. .map(code => `function(){${code}}`)
  11042. .join(',')}]}`;
  11043. }
  11044. }
  11045. function genScopedSlots(el, slots, state) {
  11046. // by default scoped slots are considered "stable", this allows child
  11047. // components with only scoped slots to skip forced updates from parent.
  11048. // but in some cases we have to bail-out of this optimization
  11049. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11050. let needsForceUpdate = el.for ||
  11051. Object.keys(slots).some(key => {
  11052. const slot = slots[key];
  11053. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11054. );
  11055. });
  11056. // #9534: if a component with scoped slots is inside a conditional branch,
  11057. // it's possible for the same component to be reused but with different
  11058. // compiled slot content. To avoid that, we generate a unique key based on
  11059. // the generated code of all the slot contents.
  11060. let needsKey = !!el.if;
  11061. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11062. // disconnected due to the intermediate scope variable)
  11063. // #9438, #9506
  11064. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11065. // and skip force updating ones that do not actually use scope variables.
  11066. if (!needsForceUpdate) {
  11067. let parent = el.parent;
  11068. while (parent) {
  11069. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11070. parent.for) {
  11071. needsForceUpdate = true;
  11072. break;
  11073. }
  11074. if (parent.if) {
  11075. needsKey = true;
  11076. }
  11077. parent = parent.parent;
  11078. }
  11079. }
  11080. const generatedSlots = Object.keys(slots)
  11081. .map(key => genScopedSlot(slots[key], state))
  11082. .join(',');
  11083. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11084. }
  11085. function hash(str) {
  11086. let hash = 5381;
  11087. let i = str.length;
  11088. while (i) {
  11089. hash = (hash * 33) ^ str.charCodeAt(--i);
  11090. }
  11091. return hash >>> 0;
  11092. }
  11093. function containsSlotChild(el) {
  11094. if (el.type === 1) {
  11095. if (el.tag === 'slot') {
  11096. return true;
  11097. }
  11098. return el.children.some(containsSlotChild);
  11099. }
  11100. return false;
  11101. }
  11102. function genScopedSlot(el, state) {
  11103. const isLegacySyntax = el.attrsMap['slot-scope'];
  11104. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11105. return genIf(el, state, genScopedSlot, `null`);
  11106. }
  11107. if (el.for && !el.forProcessed) {
  11108. return genFor(el, state, genScopedSlot);
  11109. }
  11110. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11111. const fn = `function(${slotScope}){` +
  11112. `return ${el.tag === 'template'
  11113. ? el.if && isLegacySyntax
  11114. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11115. : genChildren(el, state) || 'undefined'
  11116. : genElement(el, state)}}`;
  11117. // reverse proxy v-slot without scope on this.$slots
  11118. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11119. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11120. }
  11121. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11122. const children = el.children;
  11123. if (children.length) {
  11124. const el = children[0];
  11125. // optimize single v-for
  11126. if (children.length === 1 &&
  11127. el.for &&
  11128. el.tag !== 'template' &&
  11129. el.tag !== 'slot') {
  11130. const normalizationType = checkSkip
  11131. ? state.maybeComponent(el)
  11132. ? `,1`
  11133. : `,0`
  11134. : ``;
  11135. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11136. }
  11137. const normalizationType = checkSkip
  11138. ? getNormalizationType(children, state.maybeComponent)
  11139. : 0;
  11140. const gen = altGenNode || genNode;
  11141. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11142. }
  11143. }
  11144. // determine the normalization needed for the children array.
  11145. // 0: no normalization needed
  11146. // 1: simple normalization needed (possible 1-level deep nested array)
  11147. // 2: full normalization needed
  11148. function getNormalizationType(children, maybeComponent) {
  11149. let res = 0;
  11150. for (let i = 0; i < children.length; i++) {
  11151. const el = children[i];
  11152. if (el.type !== 1) {
  11153. continue;
  11154. }
  11155. if (needsNormalization(el) ||
  11156. (el.ifConditions &&
  11157. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11158. res = 2;
  11159. break;
  11160. }
  11161. if (maybeComponent(el) ||
  11162. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11163. res = 1;
  11164. }
  11165. }
  11166. return res;
  11167. }
  11168. function needsNormalization(el) {
  11169. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11170. }
  11171. function genNode(node, state) {
  11172. if (node.type === 1) {
  11173. return genElement(node, state);
  11174. }
  11175. else if (node.type === 3 && node.isComment) {
  11176. return genComment(node);
  11177. }
  11178. else {
  11179. return genText(node);
  11180. }
  11181. }
  11182. function genText(text) {
  11183. return `_v(${text.type === 2
  11184. ? text.expression // no need for () because already wrapped in _s()
  11185. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11186. }
  11187. function genComment(comment) {
  11188. return `_e(${JSON.stringify(comment.text)})`;
  11189. }
  11190. function genSlot(el, state) {
  11191. const slotName = el.slotName || '"default"';
  11192. const children = genChildren(el, state);
  11193. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11194. const attrs = el.attrs || el.dynamicAttrs
  11195. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11196. // slot props are camelized
  11197. name: camelize(attr.name),
  11198. value: attr.value,
  11199. dynamic: attr.dynamic
  11200. })))
  11201. : null;
  11202. const bind = el.attrsMap['v-bind'];
  11203. if ((attrs || bind) && !children) {
  11204. res += `,null`;
  11205. }
  11206. if (attrs) {
  11207. res += `,${attrs}`;
  11208. }
  11209. if (bind) {
  11210. res += `${attrs ? '' : ',null'},${bind}`;
  11211. }
  11212. return res + ')';
  11213. }
  11214. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11215. function genComponent(componentName, el, state) {
  11216. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11217. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11218. }
  11219. function genProps(props) {
  11220. let staticProps = ``;
  11221. let dynamicProps = ``;
  11222. for (let i = 0; i < props.length; i++) {
  11223. const prop = props[i];
  11224. const value = transformSpecialNewlines(prop.value);
  11225. if (prop.dynamic) {
  11226. dynamicProps += `${prop.name},${value},`;
  11227. }
  11228. else {
  11229. staticProps += `"${prop.name}":${value},`;
  11230. }
  11231. }
  11232. staticProps = `{${staticProps.slice(0, -1)}}`;
  11233. if (dynamicProps) {
  11234. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11235. }
  11236. else {
  11237. return staticProps;
  11238. }
  11239. }
  11240. // #3895, #4268
  11241. function transformSpecialNewlines(text) {
  11242. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11243. }
  11244. // these keywords should not appear inside expressions, but operators like
  11245. // typeof, instanceof and in are allowed
  11246. const prohibitedKeywordRE = new RegExp('\\b' +
  11247. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11248. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11249. 'extends,finally,continue,debugger,function,arguments')
  11250. .split(',')
  11251. .join('\\b|\\b') +
  11252. '\\b');
  11253. // these unary operators should not be used as property/method names
  11254. const unaryOperatorsRE = new RegExp('\\b' +
  11255. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11256. '\\s*\\([^\\)]*\\)');
  11257. // strip strings in expressions
  11258. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11259. // detect problematic expressions in a template
  11260. function detectErrors(ast, warn) {
  11261. if (ast) {
  11262. checkNode(ast, warn);
  11263. }
  11264. }
  11265. function checkNode(node, warn) {
  11266. if (node.type === 1) {
  11267. for (const name in node.attrsMap) {
  11268. if (dirRE.test(name)) {
  11269. const value = node.attrsMap[name];
  11270. if (value) {
  11271. const range = node.rawAttrsMap[name];
  11272. if (name === 'v-for') {
  11273. checkFor(node, `v-for="${value}"`, warn, range);
  11274. }
  11275. else if (name === 'v-slot' || name[0] === '#') {
  11276. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11277. }
  11278. else if (onRE.test(name)) {
  11279. checkEvent(value, `${name}="${value}"`, warn, range);
  11280. }
  11281. else {
  11282. checkExpression(value, `${name}="${value}"`, warn, range);
  11283. }
  11284. }
  11285. }
  11286. }
  11287. if (node.children) {
  11288. for (let i = 0; i < node.children.length; i++) {
  11289. checkNode(node.children[i], warn);
  11290. }
  11291. }
  11292. }
  11293. else if (node.type === 2) {
  11294. checkExpression(node.expression, node.text, warn, node);
  11295. }
  11296. }
  11297. function checkEvent(exp, text, warn, range) {
  11298. const stripped = exp.replace(stripStringRE, '');
  11299. const keywordMatch = stripped.match(unaryOperatorsRE);
  11300. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11301. warn(`avoid using JavaScript unary operator as property name: ` +
  11302. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11303. }
  11304. checkExpression(exp, text, warn, range);
  11305. }
  11306. function checkFor(node, text, warn, range) {
  11307. checkExpression(node.for || '', text, warn, range);
  11308. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11309. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11310. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11311. }
  11312. function checkIdentifier(ident, type, text, warn, range) {
  11313. if (typeof ident === 'string') {
  11314. try {
  11315. new Function(`var ${ident}=_`);
  11316. }
  11317. catch (e) {
  11318. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11319. }
  11320. }
  11321. }
  11322. function checkExpression(exp, text, warn, range) {
  11323. try {
  11324. new Function(`return ${exp}`);
  11325. }
  11326. catch (e) {
  11327. const keywordMatch = exp
  11328. .replace(stripStringRE, '')
  11329. .match(prohibitedKeywordRE);
  11330. if (keywordMatch) {
  11331. warn(`avoid using JavaScript keyword as property name: ` +
  11332. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11333. }
  11334. else {
  11335. warn(`invalid expression: ${e.message} in\n\n` +
  11336. ` ${exp}\n\n` +
  11337. ` Raw expression: ${text.trim()}\n`, range);
  11338. }
  11339. }
  11340. }
  11341. function checkFunctionParameterExpression(exp, text, warn, range) {
  11342. try {
  11343. new Function(exp, '');
  11344. }
  11345. catch (e) {
  11346. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11347. ` ${exp}\n\n` +
  11348. ` Raw expression: ${text.trim()}\n`, range);
  11349. }
  11350. }
  11351. const range = 2;
  11352. function generateCodeFrame(source, start = 0, end = source.length) {
  11353. const lines = source.split(/\r?\n/);
  11354. let count = 0;
  11355. const res = [];
  11356. for (let i = 0; i < lines.length; i++) {
  11357. count += lines[i].length + 1;
  11358. if (count >= start) {
  11359. for (let j = i - range; j <= i + range || end > count; j++) {
  11360. if (j < 0 || j >= lines.length)
  11361. continue;
  11362. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11363. const lineLength = lines[j].length;
  11364. if (j === i) {
  11365. // push underline
  11366. const pad = start - (count - lineLength) + 1;
  11367. const length = end > count ? lineLength - pad : end - start;
  11368. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11369. }
  11370. else if (j > i) {
  11371. if (end > count) {
  11372. const length = Math.min(end - count, lineLength);
  11373. res.push(` | ` + repeat(`^`, length));
  11374. }
  11375. count += lineLength + 1;
  11376. }
  11377. }
  11378. break;
  11379. }
  11380. }
  11381. return res.join('\n');
  11382. }
  11383. function repeat(str, n) {
  11384. let result = '';
  11385. if (n > 0) {
  11386. // eslint-disable-next-line no-constant-condition
  11387. while (true) {
  11388. // eslint-disable-line
  11389. if (n & 1)
  11390. result += str;
  11391. n >>>= 1;
  11392. if (n <= 0)
  11393. break;
  11394. str += str;
  11395. }
  11396. }
  11397. return result;
  11398. }
  11399. function createFunction(code, errors) {
  11400. try {
  11401. return new Function(code);
  11402. }
  11403. catch (err) {
  11404. errors.push({ err, code });
  11405. return noop;
  11406. }
  11407. }
  11408. function createCompileToFunctionFn(compile) {
  11409. const cache = Object.create(null);
  11410. return function compileToFunctions(template, options, vm) {
  11411. options = extend({}, options);
  11412. const warn = options.warn || warn$2;
  11413. delete options.warn;
  11414. /* istanbul ignore if */
  11415. {
  11416. // detect possible CSP restriction
  11417. try {
  11418. new Function('return 1');
  11419. }
  11420. catch (e) {
  11421. if (e.toString().match(/unsafe-eval|CSP/)) {
  11422. warn('It seems you are using the standalone build of Vue.js in an ' +
  11423. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11424. 'The template compiler cannot work in this environment. Consider ' +
  11425. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11426. 'templates into render functions.');
  11427. }
  11428. }
  11429. }
  11430. // check cache
  11431. const key = options.delimiters
  11432. ? String(options.delimiters) + template
  11433. : template;
  11434. if (cache[key]) {
  11435. return cache[key];
  11436. }
  11437. // compile
  11438. const compiled = compile(template, options);
  11439. // check compilation errors/tips
  11440. {
  11441. if (compiled.errors && compiled.errors.length) {
  11442. if (options.outputSourceRange) {
  11443. compiled.errors.forEach(e => {
  11444. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11445. generateCodeFrame(template, e.start, e.end), vm);
  11446. });
  11447. }
  11448. else {
  11449. warn(`Error compiling template:\n\n${template}\n\n` +
  11450. compiled.errors.map(e => `- ${e}`).join('\n') +
  11451. '\n', vm);
  11452. }
  11453. }
  11454. if (compiled.tips && compiled.tips.length) {
  11455. if (options.outputSourceRange) {
  11456. compiled.tips.forEach(e => tip(e.msg, vm));
  11457. }
  11458. else {
  11459. compiled.tips.forEach(msg => tip(msg, vm));
  11460. }
  11461. }
  11462. }
  11463. // turn code into functions
  11464. const res = {};
  11465. const fnGenErrors = [];
  11466. res.render = createFunction(compiled.render, fnGenErrors);
  11467. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11468. return createFunction(code, fnGenErrors);
  11469. });
  11470. // check function generation errors.
  11471. // this should only happen if there is a bug in the compiler itself.
  11472. // mostly for codegen development use
  11473. /* istanbul ignore if */
  11474. {
  11475. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11476. warn(`Failed to generate render function:\n\n` +
  11477. fnGenErrors
  11478. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11479. .join('\n'), vm);
  11480. }
  11481. }
  11482. return (cache[key] = res);
  11483. };
  11484. }
  11485. function createCompilerCreator(baseCompile) {
  11486. return function createCompiler(baseOptions) {
  11487. function compile(template, options) {
  11488. const finalOptions = Object.create(baseOptions);
  11489. const errors = [];
  11490. const tips = [];
  11491. let warn = (msg, range, tip) => {
  11492. (tip ? tips : errors).push(msg);
  11493. };
  11494. if (options) {
  11495. if (options.outputSourceRange) {
  11496. // $flow-disable-line
  11497. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11498. warn = (msg, range, tip) => {
  11499. const data = typeof msg === 'string' ? { msg } : msg;
  11500. if (range) {
  11501. if (range.start != null) {
  11502. data.start = range.start + leadingSpaceLength;
  11503. }
  11504. if (range.end != null) {
  11505. data.end = range.end + leadingSpaceLength;
  11506. }
  11507. }
  11508. (tip ? tips : errors).push(data);
  11509. };
  11510. }
  11511. // merge custom modules
  11512. if (options.modules) {
  11513. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11514. }
  11515. // merge custom directives
  11516. if (options.directives) {
  11517. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11518. }
  11519. // copy other options
  11520. for (const key in options) {
  11521. if (key !== 'modules' && key !== 'directives') {
  11522. finalOptions[key] = options[key];
  11523. }
  11524. }
  11525. }
  11526. finalOptions.warn = warn;
  11527. const compiled = baseCompile(template.trim(), finalOptions);
  11528. {
  11529. detectErrors(compiled.ast, warn);
  11530. }
  11531. compiled.errors = errors;
  11532. compiled.tips = tips;
  11533. return compiled;
  11534. }
  11535. return {
  11536. compile,
  11537. compileToFunctions: createCompileToFunctionFn(compile)
  11538. };
  11539. };
  11540. }
  11541. // `createCompilerCreator` allows creating compilers that use alternative
  11542. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11543. // Here we just export a default compiler using the default parts.
  11544. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11545. const ast = parse(template.trim(), options);
  11546. if (options.optimize !== false) {
  11547. optimize(ast, options);
  11548. }
  11549. const code = generate(ast, options);
  11550. return {
  11551. ast,
  11552. render: code.render,
  11553. staticRenderFns: code.staticRenderFns
  11554. };
  11555. });
  11556. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11557. // check whether current browser encodes a char inside attribute values
  11558. let div;
  11559. function getShouldDecode(href) {
  11560. div = div || document.createElement('div');
  11561. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11562. return div.innerHTML.indexOf('&#10;') > 0;
  11563. }
  11564. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11565. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11566. // #6828: chrome encodes content in a[href]
  11567. const shouldDecodeNewlinesForHref = inBrowser
  11568. ? getShouldDecode(true)
  11569. : false;
  11570. const idToTemplate = cached(id => {
  11571. const el = query(id);
  11572. return el && el.innerHTML;
  11573. });
  11574. const mount = Vue.prototype.$mount;
  11575. Vue.prototype.$mount = function (el, hydrating) {
  11576. el = el && query(el);
  11577. /* istanbul ignore if */
  11578. if (el === document.body || el === document.documentElement) {
  11579. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11580. return this;
  11581. }
  11582. const options = this.$options;
  11583. // resolve template/el and convert to render function
  11584. if (!options.render) {
  11585. let template = options.template;
  11586. if (template) {
  11587. if (typeof template === 'string') {
  11588. if (template.charAt(0) === '#') {
  11589. template = idToTemplate(template);
  11590. /* istanbul ignore if */
  11591. if (!template) {
  11592. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11593. }
  11594. }
  11595. }
  11596. else if (template.nodeType) {
  11597. template = template.innerHTML;
  11598. }
  11599. else {
  11600. {
  11601. warn$2('invalid template option:' + template, this);
  11602. }
  11603. return this;
  11604. }
  11605. }
  11606. else if (el) {
  11607. // @ts-expect-error
  11608. template = getOuterHTML(el);
  11609. }
  11610. if (template) {
  11611. /* istanbul ignore if */
  11612. if (config.performance && mark) {
  11613. mark('compile');
  11614. }
  11615. const { render, staticRenderFns } = compileToFunctions(template, {
  11616. outputSourceRange: true,
  11617. shouldDecodeNewlines,
  11618. shouldDecodeNewlinesForHref,
  11619. delimiters: options.delimiters,
  11620. comments: options.comments
  11621. }, this);
  11622. options.render = render;
  11623. options.staticRenderFns = staticRenderFns;
  11624. /* istanbul ignore if */
  11625. if (config.performance && mark) {
  11626. mark('compile end');
  11627. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11628. }
  11629. }
  11630. }
  11631. return mount.call(this, el, hydrating);
  11632. };
  11633. /**
  11634. * Get outerHTML of elements, taking care
  11635. * of SVG elements in IE as well.
  11636. */
  11637. function getOuterHTML(el) {
  11638. if (el.outerHTML) {
  11639. return el.outerHTML;
  11640. }
  11641. else {
  11642. const container = document.createElement('div');
  11643. container.appendChild(el.cloneNode(true));
  11644. return container.innerHTML;
  11645. }
  11646. }
  11647. Vue.compile = compileToFunctions;
  11648. // export type EffectScheduler = (...args: any[]) => any
  11649. /**
  11650. * @internal since we are not exposing this in Vue 2, it's used only for
  11651. * internal testing.
  11652. */
  11653. function effect(fn, scheduler) {
  11654. const watcher = new Watcher(currentInstance, fn, noop, {
  11655. sync: true
  11656. });
  11657. if (scheduler) {
  11658. watcher.update = () => {
  11659. scheduler(() => watcher.run());
  11660. };
  11661. }
  11662. }
  11663. extend(Vue, vca);
  11664. Vue.effect = effect;
  11665. module.exports = Vue;