vue.esm.browser.js 389 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731
  1. /*!
  2. * Vue.js v2.7.16
  3. * (c) 2014-2023 Evan You
  4. * Released under the MIT License.
  5. */
  6. const emptyObject = Object.freeze({});
  7. const isArray = Array.isArray;
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef(v) {
  11. return v === undefined || v === null;
  12. }
  13. function isDef(v) {
  14. return v !== undefined && v !== null;
  15. }
  16. function isTrue(v) {
  17. return v === true;
  18. }
  19. function isFalse(v) {
  20. return v === false;
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive(value) {
  26. return (typeof value === 'string' ||
  27. typeof value === 'number' ||
  28. // $flow-disable-line
  29. typeof value === 'symbol' ||
  30. typeof value === 'boolean');
  31. }
  32. function isFunction(value) {
  33. return typeof value === 'function';
  34. }
  35. /**
  36. * Quick object check - this is primarily used to tell
  37. * objects from primitive values when we know the value
  38. * is a JSON-compliant type.
  39. */
  40. function isObject(obj) {
  41. return obj !== null && typeof obj === 'object';
  42. }
  43. /**
  44. * Get the raw type string of a value, e.g., [object Object].
  45. */
  46. const _toString = Object.prototype.toString;
  47. function toRawType(value) {
  48. return _toString.call(value).slice(8, -1);
  49. }
  50. /**
  51. * Strict object type check. Only returns true
  52. * for plain JavaScript objects.
  53. */
  54. function isPlainObject(obj) {
  55. return _toString.call(obj) === '[object Object]';
  56. }
  57. function isRegExp(v) {
  58. return _toString.call(v) === '[object RegExp]';
  59. }
  60. /**
  61. * Check if val is a valid array index.
  62. */
  63. function isValidArrayIndex(val) {
  64. const n = parseFloat(String(val));
  65. return n >= 0 && Math.floor(n) === n && isFinite(val);
  66. }
  67. function isPromise(val) {
  68. return (isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function');
  71. }
  72. /**
  73. * Convert a value to a string that is actually rendered.
  74. */
  75. function toString(val) {
  76. return val == null
  77. ? ''
  78. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  79. ? JSON.stringify(val, replacer, 2)
  80. : String(val);
  81. }
  82. function replacer(_key, val) {
  83. // avoid circular deps from v3
  84. if (val && val.__v_isRef) {
  85. return val.value;
  86. }
  87. return val;
  88. }
  89. /**
  90. * Convert an input value to a number for persistence.
  91. * If the conversion fails, return original string.
  92. */
  93. function toNumber(val) {
  94. const n = parseFloat(val);
  95. return isNaN(n) ? val : n;
  96. }
  97. /**
  98. * Make a map and return a function for checking if a key
  99. * is in that map.
  100. */
  101. function makeMap(str, expectsLowerCase) {
  102. const map = Object.create(null);
  103. const list = str.split(',');
  104. for (let i = 0; i < list.length; i++) {
  105. map[list[i]] = true;
  106. }
  107. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  108. }
  109. /**
  110. * Check if a tag is a built-in tag.
  111. */
  112. const isBuiltInTag = makeMap('slot,component', true);
  113. /**
  114. * Check if an attribute is a reserved attribute.
  115. */
  116. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  117. /**
  118. * Remove an item from an array.
  119. */
  120. function remove$2(arr, item) {
  121. const len = arr.length;
  122. if (len) {
  123. // fast path for the only / last item
  124. if (item === arr[len - 1]) {
  125. arr.length = len - 1;
  126. return;
  127. }
  128. const index = arr.indexOf(item);
  129. if (index > -1) {
  130. return arr.splice(index, 1);
  131. }
  132. }
  133. }
  134. /**
  135. * Check whether an object has the property.
  136. */
  137. const hasOwnProperty = Object.prototype.hasOwnProperty;
  138. function hasOwn(obj, key) {
  139. return hasOwnProperty.call(obj, key);
  140. }
  141. /**
  142. * Create a cached version of a pure function.
  143. */
  144. function cached(fn) {
  145. const cache = Object.create(null);
  146. return function cachedFn(str) {
  147. const hit = cache[str];
  148. return hit || (cache[str] = fn(str));
  149. };
  150. }
  151. /**
  152. * Camelize a hyphen-delimited string.
  153. */
  154. const camelizeRE = /-(\w)/g;
  155. const camelize = cached((str) => {
  156. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  157. });
  158. /**
  159. * Capitalize a string.
  160. */
  161. const capitalize = cached((str) => {
  162. return str.charAt(0).toUpperCase() + str.slice(1);
  163. });
  164. /**
  165. * Hyphenate a camelCase string.
  166. */
  167. const hyphenateRE = /\B([A-Z])/g;
  168. const hyphenate = cached((str) => {
  169. return str.replace(hyphenateRE, '-$1').toLowerCase();
  170. });
  171. /**
  172. * Simple bind polyfill for environments that do not support it,
  173. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  174. * since native bind is now performant enough in most browsers.
  175. * But removing it would mean breaking code that was able to run in
  176. * PhantomJS 1.x, so this must be kept for backward compatibility.
  177. */
  178. /* istanbul ignore next */
  179. function polyfillBind(fn, ctx) {
  180. function boundFn(a) {
  181. const l = arguments.length;
  182. return l
  183. ? l > 1
  184. ? fn.apply(ctx, arguments)
  185. : fn.call(ctx, a)
  186. : fn.call(ctx);
  187. }
  188. boundFn._length = fn.length;
  189. return boundFn;
  190. }
  191. function nativeBind(fn, ctx) {
  192. return fn.bind(ctx);
  193. }
  194. // @ts-expect-error bind cannot be `undefined`
  195. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  196. /**
  197. * Convert an Array-like object to a real Array.
  198. */
  199. function toArray(list, start) {
  200. start = start || 0;
  201. let i = list.length - start;
  202. const ret = new Array(i);
  203. while (i--) {
  204. ret[i] = list[i + start];
  205. }
  206. return ret;
  207. }
  208. /**
  209. * Mix properties into target object.
  210. */
  211. function extend(to, _from) {
  212. for (const key in _from) {
  213. to[key] = _from[key];
  214. }
  215. return to;
  216. }
  217. /**
  218. * Merge an Array of Objects into a single Object.
  219. */
  220. function toObject(arr) {
  221. const res = {};
  222. for (let i = 0; i < arr.length; i++) {
  223. if (arr[i]) {
  224. extend(res, arr[i]);
  225. }
  226. }
  227. return res;
  228. }
  229. /* eslint-disable no-unused-vars */
  230. /**
  231. * Perform no operation.
  232. * Stubbing args to make Flow happy without leaving useless transpiled code
  233. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  234. */
  235. function noop(a, b, c) { }
  236. /**
  237. * Always return false.
  238. */
  239. const no = (a, b, c) => false;
  240. /* eslint-enable no-unused-vars */
  241. /**
  242. * Return the same value.
  243. */
  244. const identity = (_) => _;
  245. /**
  246. * Generate a string containing static keys from compiler modules.
  247. */
  248. function genStaticKeys$1(modules) {
  249. return modules
  250. .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
  251. .join(',');
  252. }
  253. /**
  254. * Check if two values are loosely equal - that is,
  255. * if they are plain objects, do they have the same shape?
  256. */
  257. function looseEqual(a, b) {
  258. if (a === b)
  259. return true;
  260. const isObjectA = isObject(a);
  261. const isObjectB = isObject(b);
  262. if (isObjectA && isObjectB) {
  263. try {
  264. const isArrayA = Array.isArray(a);
  265. const isArrayB = Array.isArray(b);
  266. if (isArrayA && isArrayB) {
  267. return (a.length === b.length &&
  268. a.every((e, i) => {
  269. return looseEqual(e, b[i]);
  270. }));
  271. }
  272. else if (a instanceof Date && b instanceof Date) {
  273. return a.getTime() === b.getTime();
  274. }
  275. else if (!isArrayA && !isArrayB) {
  276. const keysA = Object.keys(a);
  277. const keysB = Object.keys(b);
  278. return (keysA.length === keysB.length &&
  279. keysA.every(key => {
  280. return looseEqual(a[key], b[key]);
  281. }));
  282. }
  283. else {
  284. /* istanbul ignore next */
  285. return false;
  286. }
  287. }
  288. catch (e) {
  289. /* istanbul ignore next */
  290. return false;
  291. }
  292. }
  293. else if (!isObjectA && !isObjectB) {
  294. return String(a) === String(b);
  295. }
  296. else {
  297. return false;
  298. }
  299. }
  300. /**
  301. * Return the first index at which a loosely equal value can be
  302. * found in the array (if value is a plain object, the array must
  303. * contain an object of the same shape), or -1 if it is not present.
  304. */
  305. function looseIndexOf(arr, val) {
  306. for (let i = 0; i < arr.length; i++) {
  307. if (looseEqual(arr[i], val))
  308. return i;
  309. }
  310. return -1;
  311. }
  312. /**
  313. * Ensure a function is called only once.
  314. */
  315. function once(fn) {
  316. let called = false;
  317. return function () {
  318. if (!called) {
  319. called = true;
  320. fn.apply(this, arguments);
  321. }
  322. };
  323. }
  324. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  325. function hasChanged(x, y) {
  326. if (x === y) {
  327. return x === 0 && 1 / x !== 1 / y;
  328. }
  329. else {
  330. return x === x || y === y;
  331. }
  332. }
  333. const SSR_ATTR = 'data-server-rendered';
  334. const ASSET_TYPES = ['component', 'directive', 'filter'];
  335. const LIFECYCLE_HOOKS = [
  336. 'beforeCreate',
  337. 'created',
  338. 'beforeMount',
  339. 'mounted',
  340. 'beforeUpdate',
  341. 'updated',
  342. 'beforeDestroy',
  343. 'destroyed',
  344. 'activated',
  345. 'deactivated',
  346. 'errorCaptured',
  347. 'serverPrefetch',
  348. 'renderTracked',
  349. 'renderTriggered'
  350. ];
  351. var config = {
  352. /**
  353. * Option merge strategies (used in core/util/options)
  354. */
  355. // $flow-disable-line
  356. optionMergeStrategies: Object.create(null),
  357. /**
  358. * Whether to suppress warnings.
  359. */
  360. silent: false,
  361. /**
  362. * Show production mode tip message on boot?
  363. */
  364. productionTip: true,
  365. /**
  366. * Whether to enable devtools
  367. */
  368. devtools: true,
  369. /**
  370. * Whether to record perf
  371. */
  372. performance: false,
  373. /**
  374. * Error handler for watcher errors
  375. */
  376. errorHandler: null,
  377. /**
  378. * Warn handler for watcher warns
  379. */
  380. warnHandler: null,
  381. /**
  382. * Ignore certain custom elements
  383. */
  384. ignoredElements: [],
  385. /**
  386. * Custom user key aliases for v-on
  387. */
  388. // $flow-disable-line
  389. keyCodes: Object.create(null),
  390. /**
  391. * Check if a tag is reserved so that it cannot be registered as a
  392. * component. This is platform-dependent and may be overwritten.
  393. */
  394. isReservedTag: no,
  395. /**
  396. * Check if an attribute is reserved so that it cannot be used as a component
  397. * prop. This is platform-dependent and may be overwritten.
  398. */
  399. isReservedAttr: no,
  400. /**
  401. * Check if a tag is an unknown element.
  402. * Platform-dependent.
  403. */
  404. isUnknownElement: no,
  405. /**
  406. * Get the namespace of an element
  407. */
  408. getTagNamespace: noop,
  409. /**
  410. * Parse the real tag name for the specific platform.
  411. */
  412. parsePlatformTagName: identity,
  413. /**
  414. * Check if an attribute must be bound using property, e.g. value
  415. * Platform-dependent.
  416. */
  417. mustUseProp: no,
  418. /**
  419. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  420. * This will significantly reduce performance if set to false.
  421. */
  422. async: true,
  423. /**
  424. * Exposed for legacy reasons
  425. */
  426. _lifecycleHooks: LIFECYCLE_HOOKS
  427. };
  428. /**
  429. * unicode letters used for parsing html tags, component names and property paths.
  430. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  431. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  432. */
  433. 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/;
  434. /**
  435. * Check if a string starts with $ or _
  436. */
  437. function isReserved(str) {
  438. const c = (str + '').charCodeAt(0);
  439. return c === 0x24 || c === 0x5f;
  440. }
  441. /**
  442. * Define a property.
  443. */
  444. function def(obj, key, val, enumerable) {
  445. Object.defineProperty(obj, key, {
  446. value: val,
  447. enumerable: !!enumerable,
  448. writable: true,
  449. configurable: true
  450. });
  451. }
  452. /**
  453. * Parse simple path.
  454. */
  455. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  456. function parsePath(path) {
  457. if (bailRE.test(path)) {
  458. return;
  459. }
  460. const segments = path.split('.');
  461. return function (obj) {
  462. for (let i = 0; i < segments.length; i++) {
  463. if (!obj)
  464. return;
  465. obj = obj[segments[i]];
  466. }
  467. return obj;
  468. };
  469. }
  470. // can we use __proto__?
  471. const hasProto = '__proto__' in {};
  472. // Browser environment sniffing
  473. const inBrowser = typeof window !== 'undefined';
  474. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  475. const isIE = UA && /msie|trident/.test(UA);
  476. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  477. const isEdge = UA && UA.indexOf('edge/') > 0;
  478. UA && UA.indexOf('android') > 0;
  479. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  480. UA && /chrome\/\d+/.test(UA) && !isEdge;
  481. UA && /phantomjs/.test(UA);
  482. const isFF = UA && UA.match(/firefox\/(\d+)/);
  483. // Firefox has a "watch" function on Object.prototype...
  484. // @ts-expect-error firebox support
  485. const nativeWatch = {}.watch;
  486. let supportsPassive = false;
  487. if (inBrowser) {
  488. try {
  489. const opts = {};
  490. Object.defineProperty(opts, 'passive', {
  491. get() {
  492. /* istanbul ignore next */
  493. supportsPassive = true;
  494. }
  495. }); // https://github.com/facebook/flow/issues/285
  496. window.addEventListener('test-passive', null, opts);
  497. }
  498. catch (e) { }
  499. }
  500. // this needs to be lazy-evaled because vue may be required before
  501. // vue-server-renderer can set VUE_ENV
  502. let _isServer;
  503. const isServerRendering = () => {
  504. if (_isServer === undefined) {
  505. /* istanbul ignore if */
  506. if (!inBrowser && typeof global !== 'undefined') {
  507. // detect presence of vue-server-renderer and avoid
  508. // Webpack shimming the process
  509. _isServer =
  510. global['process'] && global['process'].env.VUE_ENV === 'server';
  511. }
  512. else {
  513. _isServer = false;
  514. }
  515. }
  516. return _isServer;
  517. };
  518. // detect devtools
  519. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  520. /* istanbul ignore next */
  521. function isNative(Ctor) {
  522. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  523. }
  524. const hasSymbol = typeof Symbol !== 'undefined' &&
  525. isNative(Symbol) &&
  526. typeof Reflect !== 'undefined' &&
  527. isNative(Reflect.ownKeys);
  528. let _Set; // $flow-disable-line
  529. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  530. // use native Set when available.
  531. _Set = Set;
  532. }
  533. else {
  534. // a non-standard Set polyfill that only works with primitive keys.
  535. _Set = class Set {
  536. constructor() {
  537. this.set = Object.create(null);
  538. }
  539. has(key) {
  540. return this.set[key] === true;
  541. }
  542. add(key) {
  543. this.set[key] = true;
  544. }
  545. clear() {
  546. this.set = Object.create(null);
  547. }
  548. };
  549. }
  550. let currentInstance = null;
  551. /**
  552. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  553. * relies on it). Do not use this internally, just use `currentInstance`.
  554. *
  555. * @internal this function needs manual type declaration because it relies
  556. * on previously manually authored types from Vue 2
  557. */
  558. function getCurrentInstance() {
  559. return currentInstance && { proxy: currentInstance };
  560. }
  561. /**
  562. * @internal
  563. */
  564. function setCurrentInstance(vm = null) {
  565. if (!vm)
  566. currentInstance && currentInstance._scope.off();
  567. currentInstance = vm;
  568. vm && vm._scope.on();
  569. }
  570. /**
  571. * @internal
  572. */
  573. class VNode {
  574. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  575. this.tag = tag;
  576. this.data = data;
  577. this.children = children;
  578. this.text = text;
  579. this.elm = elm;
  580. this.ns = undefined;
  581. this.context = context;
  582. this.fnContext = undefined;
  583. this.fnOptions = undefined;
  584. this.fnScopeId = undefined;
  585. this.key = data && data.key;
  586. this.componentOptions = componentOptions;
  587. this.componentInstance = undefined;
  588. this.parent = undefined;
  589. this.raw = false;
  590. this.isStatic = false;
  591. this.isRootInsert = true;
  592. this.isComment = false;
  593. this.isCloned = false;
  594. this.isOnce = false;
  595. this.asyncFactory = asyncFactory;
  596. this.asyncMeta = undefined;
  597. this.isAsyncPlaceholder = false;
  598. }
  599. // DEPRECATED: alias for componentInstance for backwards compat.
  600. /* istanbul ignore next */
  601. get child() {
  602. return this.componentInstance;
  603. }
  604. }
  605. const createEmptyVNode = (text = '') => {
  606. const node = new VNode();
  607. node.text = text;
  608. node.isComment = true;
  609. return node;
  610. };
  611. function createTextVNode(val) {
  612. return new VNode(undefined, undefined, undefined, String(val));
  613. }
  614. // optimized shallow clone
  615. // used for static nodes and slot nodes because they may be reused across
  616. // multiple renders, cloning them avoids errors when DOM manipulations rely
  617. // on their elm reference.
  618. function cloneVNode(vnode) {
  619. const cloned = new VNode(vnode.tag, vnode.data,
  620. // #7975
  621. // clone children array to avoid mutating original in case of cloning
  622. // a child.
  623. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  624. cloned.ns = vnode.ns;
  625. cloned.isStatic = vnode.isStatic;
  626. cloned.key = vnode.key;
  627. cloned.isComment = vnode.isComment;
  628. cloned.fnContext = vnode.fnContext;
  629. cloned.fnOptions = vnode.fnOptions;
  630. cloned.fnScopeId = vnode.fnScopeId;
  631. cloned.asyncMeta = vnode.asyncMeta;
  632. cloned.isCloned = true;
  633. return cloned;
  634. }
  635. /* not type checking this file because flow doesn't play well with Proxy */
  636. let initProxy;
  637. {
  638. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  639. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  640. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  641. 'require' // for Webpack/Browserify
  642. );
  643. const warnNonPresent = (target, key) => {
  644. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  645. 'referenced during render. Make sure that this property is reactive, ' +
  646. 'either in the data option, or for class-based components, by ' +
  647. 'initializing the property. ' +
  648. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  649. };
  650. const warnReservedPrefix = (target, key) => {
  651. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  652. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  653. 'prevent conflicts with Vue internals. ' +
  654. 'See: https://v2.vuejs.org/v2/api/#data', target);
  655. };
  656. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  657. if (hasProxy) {
  658. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  659. config.keyCodes = new Proxy(config.keyCodes, {
  660. set(target, key, value) {
  661. if (isBuiltInModifier(key)) {
  662. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  663. return false;
  664. }
  665. else {
  666. target[key] = value;
  667. return true;
  668. }
  669. }
  670. });
  671. }
  672. const hasHandler = {
  673. has(target, key) {
  674. const has = key in target;
  675. const isAllowed = allowedGlobals(key) ||
  676. (typeof key === 'string' &&
  677. key.charAt(0) === '_' &&
  678. !(key in target.$data));
  679. if (!has && !isAllowed) {
  680. if (key in target.$data)
  681. warnReservedPrefix(target, key);
  682. else
  683. warnNonPresent(target, key);
  684. }
  685. return has || !isAllowed;
  686. }
  687. };
  688. const getHandler = {
  689. get(target, key) {
  690. if (typeof key === 'string' && !(key in target)) {
  691. if (key in target.$data)
  692. warnReservedPrefix(target, key);
  693. else
  694. warnNonPresent(target, key);
  695. }
  696. return target[key];
  697. }
  698. };
  699. initProxy = function initProxy(vm) {
  700. if (hasProxy) {
  701. // determine which proxy handler to use
  702. const options = vm.$options;
  703. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  704. vm._renderProxy = new Proxy(vm, handlers);
  705. }
  706. else {
  707. vm._renderProxy = vm;
  708. }
  709. };
  710. }
  711. let uid$2 = 0;
  712. const pendingCleanupDeps = [];
  713. const cleanupDeps = () => {
  714. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  715. const dep = pendingCleanupDeps[i];
  716. dep.subs = dep.subs.filter(s => s);
  717. dep._pending = false;
  718. }
  719. pendingCleanupDeps.length = 0;
  720. };
  721. /**
  722. * A dep is an observable that can have multiple
  723. * directives subscribing to it.
  724. * @internal
  725. */
  726. class Dep {
  727. constructor() {
  728. // pending subs cleanup
  729. this._pending = false;
  730. this.id = uid$2++;
  731. this.subs = [];
  732. }
  733. addSub(sub) {
  734. this.subs.push(sub);
  735. }
  736. removeSub(sub) {
  737. // #12696 deps with massive amount of subscribers are extremely slow to
  738. // clean up in Chromium
  739. // to workaround this, we unset the sub for now, and clear them on
  740. // next scheduler flush.
  741. this.subs[this.subs.indexOf(sub)] = null;
  742. if (!this._pending) {
  743. this._pending = true;
  744. pendingCleanupDeps.push(this);
  745. }
  746. }
  747. depend(info) {
  748. if (Dep.target) {
  749. Dep.target.addDep(this);
  750. if (info && Dep.target.onTrack) {
  751. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  752. }
  753. }
  754. }
  755. notify(info) {
  756. // stabilize the subscriber list first
  757. const subs = this.subs.filter(s => s);
  758. if (!config.async) {
  759. // subs aren't sorted in scheduler if not running async
  760. // we need to sort them now to make sure they fire in correct
  761. // order
  762. subs.sort((a, b) => a.id - b.id);
  763. }
  764. for (let i = 0, l = subs.length; i < l; i++) {
  765. const sub = subs[i];
  766. if (info) {
  767. sub.onTrigger &&
  768. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  769. }
  770. sub.update();
  771. }
  772. }
  773. }
  774. // The current target watcher being evaluated.
  775. // This is globally unique because only one watcher
  776. // can be evaluated at a time.
  777. Dep.target = null;
  778. const targetStack = [];
  779. function pushTarget(target) {
  780. targetStack.push(target);
  781. Dep.target = target;
  782. }
  783. function popTarget() {
  784. targetStack.pop();
  785. Dep.target = targetStack[targetStack.length - 1];
  786. }
  787. /*
  788. * not type checking this file because flow doesn't play well with
  789. * dynamically accessing methods on Array prototype
  790. */
  791. const arrayProto = Array.prototype;
  792. const arrayMethods = Object.create(arrayProto);
  793. const methodsToPatch = [
  794. 'push',
  795. 'pop',
  796. 'shift',
  797. 'unshift',
  798. 'splice',
  799. 'sort',
  800. 'reverse'
  801. ];
  802. /**
  803. * Intercept mutating methods and emit events
  804. */
  805. methodsToPatch.forEach(function (method) {
  806. // cache original method
  807. const original = arrayProto[method];
  808. def(arrayMethods, method, function mutator(...args) {
  809. const result = original.apply(this, args);
  810. const ob = this.__ob__;
  811. let inserted;
  812. switch (method) {
  813. case 'push':
  814. case 'unshift':
  815. inserted = args;
  816. break;
  817. case 'splice':
  818. inserted = args.slice(2);
  819. break;
  820. }
  821. if (inserted)
  822. ob.observeArray(inserted);
  823. // notify change
  824. {
  825. ob.dep.notify({
  826. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  827. target: this,
  828. key: method
  829. });
  830. }
  831. return result;
  832. });
  833. });
  834. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  835. const NO_INITIAL_VALUE = {};
  836. /**
  837. * In some cases we may want to disable observation inside a component's
  838. * update computation.
  839. */
  840. let shouldObserve = true;
  841. function toggleObserving(value) {
  842. shouldObserve = value;
  843. }
  844. // ssr mock dep
  845. const mockDep = {
  846. notify: noop,
  847. depend: noop,
  848. addSub: noop,
  849. removeSub: noop
  850. };
  851. /**
  852. * Observer class that is attached to each observed
  853. * object. Once attached, the observer converts the target
  854. * object's property keys into getter/setters that
  855. * collect dependencies and dispatch updates.
  856. */
  857. class Observer {
  858. constructor(value, shallow = false, mock = false) {
  859. this.value = value;
  860. this.shallow = shallow;
  861. this.mock = mock;
  862. // this.value = value
  863. this.dep = mock ? mockDep : new Dep();
  864. this.vmCount = 0;
  865. def(value, '__ob__', this);
  866. if (isArray(value)) {
  867. if (!mock) {
  868. if (hasProto) {
  869. value.__proto__ = arrayMethods;
  870. /* eslint-enable no-proto */
  871. }
  872. else {
  873. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  874. const key = arrayKeys[i];
  875. def(value, key, arrayMethods[key]);
  876. }
  877. }
  878. }
  879. if (!shallow) {
  880. this.observeArray(value);
  881. }
  882. }
  883. else {
  884. /**
  885. * Walk through all properties and convert them into
  886. * getter/setters. This method should only be called when
  887. * value type is Object.
  888. */
  889. const keys = Object.keys(value);
  890. for (let i = 0; i < keys.length; i++) {
  891. const key = keys[i];
  892. defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
  893. }
  894. }
  895. }
  896. /**
  897. * Observe a list of Array items.
  898. */
  899. observeArray(value) {
  900. for (let i = 0, l = value.length; i < l; i++) {
  901. observe(value[i], false, this.mock);
  902. }
  903. }
  904. }
  905. // helpers
  906. /**
  907. * Attempt to create an observer instance for a value,
  908. * returns the new observer if successfully observed,
  909. * or the existing observer if the value already has one.
  910. */
  911. function observe(value, shallow, ssrMockReactivity) {
  912. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  913. return value.__ob__;
  914. }
  915. if (shouldObserve &&
  916. (ssrMockReactivity || !isServerRendering()) &&
  917. (isArray(value) || isPlainObject(value)) &&
  918. Object.isExtensible(value) &&
  919. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  920. !isRef(value) &&
  921. !(value instanceof VNode)) {
  922. return new Observer(value, shallow, ssrMockReactivity);
  923. }
  924. }
  925. /**
  926. * Define a reactive property on an Object.
  927. */
  928. function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) {
  929. const dep = new Dep();
  930. const property = Object.getOwnPropertyDescriptor(obj, key);
  931. if (property && property.configurable === false) {
  932. return;
  933. }
  934. // cater for pre-defined getter/setters
  935. const getter = property && property.get;
  936. const setter = property && property.set;
  937. if ((!getter || setter) &&
  938. (val === NO_INITIAL_VALUE || arguments.length === 2)) {
  939. val = obj[key];
  940. }
  941. let childOb = shallow ? val && val.__ob__ : observe(val, false, mock);
  942. Object.defineProperty(obj, key, {
  943. enumerable: true,
  944. configurable: true,
  945. get: function reactiveGetter() {
  946. const value = getter ? getter.call(obj) : val;
  947. if (Dep.target) {
  948. {
  949. dep.depend({
  950. target: obj,
  951. type: "get" /* TrackOpTypes.GET */,
  952. key
  953. });
  954. }
  955. if (childOb) {
  956. childOb.dep.depend();
  957. if (isArray(value)) {
  958. dependArray(value);
  959. }
  960. }
  961. }
  962. return isRef(value) && !shallow ? value.value : value;
  963. },
  964. set: function reactiveSetter(newVal) {
  965. const value = getter ? getter.call(obj) : val;
  966. if (!hasChanged(value, newVal)) {
  967. return;
  968. }
  969. if (customSetter) {
  970. customSetter();
  971. }
  972. if (setter) {
  973. setter.call(obj, newVal);
  974. }
  975. else if (getter) {
  976. // #7981: for accessor properties without setter
  977. return;
  978. }
  979. else if (!shallow && isRef(value) && !isRef(newVal)) {
  980. value.value = newVal;
  981. return;
  982. }
  983. else {
  984. val = newVal;
  985. }
  986. childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock);
  987. {
  988. dep.notify({
  989. type: "set" /* TriggerOpTypes.SET */,
  990. target: obj,
  991. key,
  992. newValue: newVal,
  993. oldValue: value
  994. });
  995. }
  996. }
  997. });
  998. return dep;
  999. }
  1000. function set(target, key, val) {
  1001. if ((isUndef(target) || isPrimitive(target))) {
  1002. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  1003. }
  1004. if (isReadonly(target)) {
  1005. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1006. return;
  1007. }
  1008. const ob = target.__ob__;
  1009. if (isArray(target) && isValidArrayIndex(key)) {
  1010. target.length = Math.max(target.length, key);
  1011. target.splice(key, 1, val);
  1012. // when mocking for SSR, array methods are not hijacked
  1013. if (ob && !ob.shallow && ob.mock) {
  1014. observe(val, false, true);
  1015. }
  1016. return val;
  1017. }
  1018. if (key in target && !(key in Object.prototype)) {
  1019. target[key] = val;
  1020. return val;
  1021. }
  1022. if (target._isVue || (ob && ob.vmCount)) {
  1023. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1024. 'at runtime - declare it upfront in the data option.');
  1025. return val;
  1026. }
  1027. if (!ob) {
  1028. target[key] = val;
  1029. return val;
  1030. }
  1031. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1032. {
  1033. ob.dep.notify({
  1034. type: "add" /* TriggerOpTypes.ADD */,
  1035. target: target,
  1036. key,
  1037. newValue: val,
  1038. oldValue: undefined
  1039. });
  1040. }
  1041. return val;
  1042. }
  1043. function del(target, key) {
  1044. if ((isUndef(target) || isPrimitive(target))) {
  1045. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1046. }
  1047. if (isArray(target) && isValidArrayIndex(key)) {
  1048. target.splice(key, 1);
  1049. return;
  1050. }
  1051. const ob = target.__ob__;
  1052. if (target._isVue || (ob && ob.vmCount)) {
  1053. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1054. '- just set it to null.');
  1055. return;
  1056. }
  1057. if (isReadonly(target)) {
  1058. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1059. return;
  1060. }
  1061. if (!hasOwn(target, key)) {
  1062. return;
  1063. }
  1064. delete target[key];
  1065. if (!ob) {
  1066. return;
  1067. }
  1068. {
  1069. ob.dep.notify({
  1070. type: "delete" /* TriggerOpTypes.DELETE */,
  1071. target: target,
  1072. key
  1073. });
  1074. }
  1075. }
  1076. /**
  1077. * Collect dependencies on array elements when the array is touched, since
  1078. * we cannot intercept array element access like property getters.
  1079. */
  1080. function dependArray(value) {
  1081. for (let e, i = 0, l = value.length; i < l; i++) {
  1082. e = value[i];
  1083. if (e && e.__ob__) {
  1084. e.__ob__.dep.depend();
  1085. }
  1086. if (isArray(e)) {
  1087. dependArray(e);
  1088. }
  1089. }
  1090. }
  1091. function reactive(target) {
  1092. makeReactive(target, false);
  1093. return target;
  1094. }
  1095. /**
  1096. * Return a shallowly-reactive copy of the original object, where only the root
  1097. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1098. * root level).
  1099. */
  1100. function shallowReactive(target) {
  1101. makeReactive(target, true);
  1102. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1103. return target;
  1104. }
  1105. function makeReactive(target, shallow) {
  1106. // if trying to observe a readonly proxy, return the readonly version.
  1107. if (!isReadonly(target)) {
  1108. {
  1109. if (isArray(target)) {
  1110. 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.`);
  1111. }
  1112. const existingOb = target && target.__ob__;
  1113. if (existingOb && existingOb.shallow !== shallow) {
  1114. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1115. }
  1116. }
  1117. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1118. if (!ob) {
  1119. if (target == null || isPrimitive(target)) {
  1120. warn$2(`value cannot be made reactive: ${String(target)}`);
  1121. }
  1122. if (isCollectionType(target)) {
  1123. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1124. }
  1125. }
  1126. }
  1127. }
  1128. function isReactive(value) {
  1129. if (isReadonly(value)) {
  1130. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1131. }
  1132. return !!(value && value.__ob__);
  1133. }
  1134. function isShallow(value) {
  1135. return !!(value && value.__v_isShallow);
  1136. }
  1137. function isReadonly(value) {
  1138. return !!(value && value.__v_isReadonly);
  1139. }
  1140. function isProxy(value) {
  1141. return isReactive(value) || isReadonly(value);
  1142. }
  1143. function toRaw(observed) {
  1144. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1145. return raw ? toRaw(raw) : observed;
  1146. }
  1147. function markRaw(value) {
  1148. // non-extensible objects won't be observed anyway
  1149. if (Object.isExtensible(value)) {
  1150. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1151. }
  1152. return value;
  1153. }
  1154. /**
  1155. * @internal
  1156. */
  1157. function isCollectionType(value) {
  1158. const type = toRawType(value);
  1159. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1160. }
  1161. /**
  1162. * @internal
  1163. */
  1164. const RefFlag = `__v_isRef`;
  1165. function isRef(r) {
  1166. return !!(r && r.__v_isRef === true);
  1167. }
  1168. function ref$1(value) {
  1169. return createRef(value, false);
  1170. }
  1171. function shallowRef(value) {
  1172. return createRef(value, true);
  1173. }
  1174. function createRef(rawValue, shallow) {
  1175. if (isRef(rawValue)) {
  1176. return rawValue;
  1177. }
  1178. const ref = {};
  1179. def(ref, RefFlag, true);
  1180. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1181. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1182. return ref;
  1183. }
  1184. function triggerRef(ref) {
  1185. if (!ref.dep) {
  1186. warn$2(`received object is not a triggerable ref.`);
  1187. }
  1188. {
  1189. ref.dep &&
  1190. ref.dep.notify({
  1191. type: "set" /* TriggerOpTypes.SET */,
  1192. target: ref,
  1193. key: 'value'
  1194. });
  1195. }
  1196. }
  1197. function unref(ref) {
  1198. return isRef(ref) ? ref.value : ref;
  1199. }
  1200. function proxyRefs(objectWithRefs) {
  1201. if (isReactive(objectWithRefs)) {
  1202. return objectWithRefs;
  1203. }
  1204. const proxy = {};
  1205. const keys = Object.keys(objectWithRefs);
  1206. for (let i = 0; i < keys.length; i++) {
  1207. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1208. }
  1209. return proxy;
  1210. }
  1211. function proxyWithRefUnwrap(target, source, key) {
  1212. Object.defineProperty(target, key, {
  1213. enumerable: true,
  1214. configurable: true,
  1215. get: () => {
  1216. const val = source[key];
  1217. if (isRef(val)) {
  1218. return val.value;
  1219. }
  1220. else {
  1221. const ob = val && val.__ob__;
  1222. if (ob)
  1223. ob.dep.depend();
  1224. return val;
  1225. }
  1226. },
  1227. set: value => {
  1228. const oldValue = source[key];
  1229. if (isRef(oldValue) && !isRef(value)) {
  1230. oldValue.value = value;
  1231. }
  1232. else {
  1233. source[key] = value;
  1234. }
  1235. }
  1236. });
  1237. }
  1238. function customRef(factory) {
  1239. const dep = new Dep();
  1240. const { get, set } = factory(() => {
  1241. {
  1242. dep.depend({
  1243. target: ref,
  1244. type: "get" /* TrackOpTypes.GET */,
  1245. key: 'value'
  1246. });
  1247. }
  1248. }, () => {
  1249. {
  1250. dep.notify({
  1251. target: ref,
  1252. type: "set" /* TriggerOpTypes.SET */,
  1253. key: 'value'
  1254. });
  1255. }
  1256. });
  1257. const ref = {
  1258. get value() {
  1259. return get();
  1260. },
  1261. set value(newVal) {
  1262. set(newVal);
  1263. }
  1264. };
  1265. def(ref, RefFlag, true);
  1266. return ref;
  1267. }
  1268. function toRefs(object) {
  1269. if (!isReactive(object)) {
  1270. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1271. }
  1272. const ret = isArray(object) ? new Array(object.length) : {};
  1273. for (const key in object) {
  1274. ret[key] = toRef(object, key);
  1275. }
  1276. return ret;
  1277. }
  1278. function toRef(object, key, defaultValue) {
  1279. const val = object[key];
  1280. if (isRef(val)) {
  1281. return val;
  1282. }
  1283. const ref = {
  1284. get value() {
  1285. const val = object[key];
  1286. return val === undefined ? defaultValue : val;
  1287. },
  1288. set value(newVal) {
  1289. object[key] = newVal;
  1290. }
  1291. };
  1292. def(ref, RefFlag, true);
  1293. return ref;
  1294. }
  1295. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1296. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1297. function readonly(target) {
  1298. return createReadonly(target, false);
  1299. }
  1300. function createReadonly(target, shallow) {
  1301. if (!isPlainObject(target)) {
  1302. {
  1303. if (isArray(target)) {
  1304. warn$2(`Vue 2 does not support readonly arrays.`);
  1305. }
  1306. else if (isCollectionType(target)) {
  1307. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1308. }
  1309. else {
  1310. warn$2(`value cannot be made readonly: ${typeof target}`);
  1311. }
  1312. }
  1313. return target;
  1314. }
  1315. if (!Object.isExtensible(target)) {
  1316. warn$2(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1317. }
  1318. // already a readonly object
  1319. if (isReadonly(target)) {
  1320. return target;
  1321. }
  1322. // already has a readonly proxy
  1323. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1324. const existingProxy = target[existingFlag];
  1325. if (existingProxy) {
  1326. return existingProxy;
  1327. }
  1328. const proxy = Object.create(Object.getPrototypeOf(target));
  1329. def(target, existingFlag, proxy);
  1330. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1331. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1332. if (isRef(target)) {
  1333. def(proxy, RefFlag, true);
  1334. }
  1335. if (shallow || isShallow(target)) {
  1336. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1337. }
  1338. const keys = Object.keys(target);
  1339. for (let i = 0; i < keys.length; i++) {
  1340. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1341. }
  1342. return proxy;
  1343. }
  1344. function defineReadonlyProperty(proxy, target, key, shallow) {
  1345. Object.defineProperty(proxy, key, {
  1346. enumerable: true,
  1347. configurable: true,
  1348. get() {
  1349. const val = target[key];
  1350. return shallow || !isPlainObject(val) ? val : readonly(val);
  1351. },
  1352. set() {
  1353. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1354. }
  1355. });
  1356. }
  1357. /**
  1358. * Returns a reactive-copy of the original object, where only the root level
  1359. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1360. * returned properties.
  1361. * This is used for creating the props proxy object for stateful components.
  1362. */
  1363. function shallowReadonly(target) {
  1364. return createReadonly(target, true);
  1365. }
  1366. function computed(getterOrOptions, debugOptions) {
  1367. let getter;
  1368. let setter;
  1369. const onlyGetter = isFunction(getterOrOptions);
  1370. if (onlyGetter) {
  1371. getter = getterOrOptions;
  1372. setter = () => {
  1373. warn$2('Write operation failed: computed value is readonly');
  1374. }
  1375. ;
  1376. }
  1377. else {
  1378. getter = getterOrOptions.get;
  1379. setter = getterOrOptions.set;
  1380. }
  1381. const watcher = isServerRendering()
  1382. ? null
  1383. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1384. if (watcher && debugOptions) {
  1385. watcher.onTrack = debugOptions.onTrack;
  1386. watcher.onTrigger = debugOptions.onTrigger;
  1387. }
  1388. const ref = {
  1389. // some libs rely on the presence effect for checking computed refs
  1390. // from normal refs, but the implementation doesn't matter
  1391. effect: watcher,
  1392. get value() {
  1393. if (watcher) {
  1394. if (watcher.dirty) {
  1395. watcher.evaluate();
  1396. }
  1397. if (Dep.target) {
  1398. if (Dep.target.onTrack) {
  1399. Dep.target.onTrack({
  1400. effect: Dep.target,
  1401. target: ref,
  1402. type: "get" /* TrackOpTypes.GET */,
  1403. key: 'value'
  1404. });
  1405. }
  1406. watcher.depend();
  1407. }
  1408. return watcher.value;
  1409. }
  1410. else {
  1411. return getter();
  1412. }
  1413. },
  1414. set value(newVal) {
  1415. setter(newVal);
  1416. }
  1417. };
  1418. def(ref, RefFlag, true);
  1419. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1420. return ref;
  1421. }
  1422. let mark;
  1423. let measure;
  1424. {
  1425. const perf = inBrowser && window.performance;
  1426. /* istanbul ignore if */
  1427. if (perf &&
  1428. // @ts-ignore
  1429. perf.mark &&
  1430. // @ts-ignore
  1431. perf.measure &&
  1432. // @ts-ignore
  1433. perf.clearMarks &&
  1434. // @ts-ignore
  1435. perf.clearMeasures) {
  1436. mark = tag => perf.mark(tag);
  1437. measure = (name, startTag, endTag) => {
  1438. perf.measure(name, startTag, endTag);
  1439. perf.clearMarks(startTag);
  1440. perf.clearMarks(endTag);
  1441. // perf.clearMeasures(name)
  1442. };
  1443. }
  1444. }
  1445. const normalizeEvent = cached((name) => {
  1446. const passive = name.charAt(0) === '&';
  1447. name = passive ? name.slice(1) : name;
  1448. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1449. name = once ? name.slice(1) : name;
  1450. const capture = name.charAt(0) === '!';
  1451. name = capture ? name.slice(1) : name;
  1452. return {
  1453. name,
  1454. once,
  1455. capture,
  1456. passive
  1457. };
  1458. });
  1459. function createFnInvoker(fns, vm) {
  1460. function invoker() {
  1461. const fns = invoker.fns;
  1462. if (isArray(fns)) {
  1463. const cloned = fns.slice();
  1464. for (let i = 0; i < cloned.length; i++) {
  1465. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1466. }
  1467. }
  1468. else {
  1469. // return handler return value for single handlers
  1470. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1471. }
  1472. }
  1473. invoker.fns = fns;
  1474. return invoker;
  1475. }
  1476. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1477. let name, cur, old, event;
  1478. for (name in on) {
  1479. cur = on[name];
  1480. old = oldOn[name];
  1481. event = normalizeEvent(name);
  1482. if (isUndef(cur)) {
  1483. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1484. }
  1485. else if (isUndef(old)) {
  1486. if (isUndef(cur.fns)) {
  1487. cur = on[name] = createFnInvoker(cur, vm);
  1488. }
  1489. if (isTrue(event.once)) {
  1490. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1491. }
  1492. add(event.name, cur, event.capture, event.passive, event.params);
  1493. }
  1494. else if (cur !== old) {
  1495. old.fns = cur;
  1496. on[name] = old;
  1497. }
  1498. }
  1499. for (name in oldOn) {
  1500. if (isUndef(on[name])) {
  1501. event = normalizeEvent(name);
  1502. remove(event.name, oldOn[name], event.capture);
  1503. }
  1504. }
  1505. }
  1506. function mergeVNodeHook(def, hookKey, hook) {
  1507. if (def instanceof VNode) {
  1508. def = def.data.hook || (def.data.hook = {});
  1509. }
  1510. let invoker;
  1511. const oldHook = def[hookKey];
  1512. function wrappedHook() {
  1513. hook.apply(this, arguments);
  1514. // important: remove merged hook to ensure it's called only once
  1515. // and prevent memory leak
  1516. remove$2(invoker.fns, wrappedHook);
  1517. }
  1518. if (isUndef(oldHook)) {
  1519. // no existing hook
  1520. invoker = createFnInvoker([wrappedHook]);
  1521. }
  1522. else {
  1523. /* istanbul ignore if */
  1524. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1525. // already a merged invoker
  1526. invoker = oldHook;
  1527. invoker.fns.push(wrappedHook);
  1528. }
  1529. else {
  1530. // existing plain hook
  1531. invoker = createFnInvoker([oldHook, wrappedHook]);
  1532. }
  1533. }
  1534. invoker.merged = true;
  1535. def[hookKey] = invoker;
  1536. }
  1537. function extractPropsFromVNodeData(data, Ctor, tag) {
  1538. // we are only extracting raw values here.
  1539. // validation and default values are handled in the child
  1540. // component itself.
  1541. const propOptions = Ctor.options.props;
  1542. if (isUndef(propOptions)) {
  1543. return;
  1544. }
  1545. const res = {};
  1546. const { attrs, props } = data;
  1547. if (isDef(attrs) || isDef(props)) {
  1548. for (const key in propOptions) {
  1549. const altKey = hyphenate(key);
  1550. {
  1551. const keyInLowerCase = key.toLowerCase();
  1552. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1553. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1554. `${formatComponentName(
  1555. // @ts-expect-error tag is string
  1556. tag || Ctor)}, but the declared prop name is` +
  1557. ` "${key}". ` +
  1558. `Note that HTML attributes are case-insensitive and camelCased ` +
  1559. `props need to use their kebab-case equivalents when using in-DOM ` +
  1560. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1561. }
  1562. }
  1563. checkProp(res, props, key, altKey, true) ||
  1564. checkProp(res, attrs, key, altKey, false);
  1565. }
  1566. }
  1567. return res;
  1568. }
  1569. function checkProp(res, hash, key, altKey, preserve) {
  1570. if (isDef(hash)) {
  1571. if (hasOwn(hash, key)) {
  1572. res[key] = hash[key];
  1573. if (!preserve) {
  1574. delete hash[key];
  1575. }
  1576. return true;
  1577. }
  1578. else if (hasOwn(hash, altKey)) {
  1579. res[key] = hash[altKey];
  1580. if (!preserve) {
  1581. delete hash[altKey];
  1582. }
  1583. return true;
  1584. }
  1585. }
  1586. return false;
  1587. }
  1588. // The template compiler attempts to minimize the need for normalization by
  1589. // statically analyzing the template at compile time.
  1590. //
  1591. // For plain HTML markup, normalization can be completely skipped because the
  1592. // generated render function is guaranteed to return Array<VNode>. There are
  1593. // two cases where extra normalization is needed:
  1594. // 1. When the children contains components - because a functional component
  1595. // may return an Array instead of a single root. In this case, just a simple
  1596. // normalization is needed - if any child is an Array, we flatten the whole
  1597. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1598. // because functional components already normalize their own children.
  1599. function simpleNormalizeChildren(children) {
  1600. for (let i = 0; i < children.length; i++) {
  1601. if (isArray(children[i])) {
  1602. return Array.prototype.concat.apply([], children);
  1603. }
  1604. }
  1605. return children;
  1606. }
  1607. // 2. When the children contains constructs that always generated nested Arrays,
  1608. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1609. // with hand-written render functions / JSX. In such cases a full normalization
  1610. // is needed to cater to all possible types of children values.
  1611. function normalizeChildren(children) {
  1612. return isPrimitive(children)
  1613. ? [createTextVNode(children)]
  1614. : isArray(children)
  1615. ? normalizeArrayChildren(children)
  1616. : undefined;
  1617. }
  1618. function isTextNode(node) {
  1619. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1620. }
  1621. function normalizeArrayChildren(children, nestedIndex) {
  1622. const res = [];
  1623. let i, c, lastIndex, last;
  1624. for (i = 0; i < children.length; i++) {
  1625. c = children[i];
  1626. if (isUndef(c) || typeof c === 'boolean')
  1627. continue;
  1628. lastIndex = res.length - 1;
  1629. last = res[lastIndex];
  1630. // nested
  1631. if (isArray(c)) {
  1632. if (c.length > 0) {
  1633. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1634. // merge adjacent text nodes
  1635. if (isTextNode(c[0]) && isTextNode(last)) {
  1636. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1637. c.shift();
  1638. }
  1639. res.push.apply(res, c);
  1640. }
  1641. }
  1642. else if (isPrimitive(c)) {
  1643. if (isTextNode(last)) {
  1644. // merge adjacent text nodes
  1645. // this is necessary for SSR hydration because text nodes are
  1646. // essentially merged when rendered to HTML strings
  1647. res[lastIndex] = createTextVNode(last.text + c);
  1648. }
  1649. else if (c !== '') {
  1650. // convert primitive to vnode
  1651. res.push(createTextVNode(c));
  1652. }
  1653. }
  1654. else {
  1655. if (isTextNode(c) && isTextNode(last)) {
  1656. // merge adjacent text nodes
  1657. res[lastIndex] = createTextVNode(last.text + c.text);
  1658. }
  1659. else {
  1660. // default key for nested array children (likely generated by v-for)
  1661. if (isTrue(children._isVList) &&
  1662. isDef(c.tag) &&
  1663. isUndef(c.key) &&
  1664. isDef(nestedIndex)) {
  1665. c.key = `__vlist${nestedIndex}_${i}__`;
  1666. }
  1667. res.push(c);
  1668. }
  1669. }
  1670. }
  1671. return res;
  1672. }
  1673. const SIMPLE_NORMALIZE = 1;
  1674. const ALWAYS_NORMALIZE = 2;
  1675. // wrapper function for providing a more flexible interface
  1676. // without getting yelled at by flow
  1677. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1678. if (isArray(data) || isPrimitive(data)) {
  1679. normalizationType = children;
  1680. children = data;
  1681. data = undefined;
  1682. }
  1683. if (isTrue(alwaysNormalize)) {
  1684. normalizationType = ALWAYS_NORMALIZE;
  1685. }
  1686. return _createElement(context, tag, data, children, normalizationType);
  1687. }
  1688. function _createElement(context, tag, data, children, normalizationType) {
  1689. if (isDef(data) && isDef(data.__ob__)) {
  1690. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1691. return createEmptyVNode();
  1692. }
  1693. // object syntax in v-bind
  1694. if (isDef(data) && isDef(data.is)) {
  1695. tag = data.is;
  1696. }
  1697. if (!tag) {
  1698. // in case of component :is set to falsy value
  1699. return createEmptyVNode();
  1700. }
  1701. // warn against non-primitive key
  1702. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1703. warn$2('Avoid using non-primitive value as key, ' +
  1704. 'use string/number value instead.', context);
  1705. }
  1706. // support single function children as default scoped slot
  1707. if (isArray(children) && isFunction(children[0])) {
  1708. data = data || {};
  1709. data.scopedSlots = { default: children[0] };
  1710. children.length = 0;
  1711. }
  1712. if (normalizationType === ALWAYS_NORMALIZE) {
  1713. children = normalizeChildren(children);
  1714. }
  1715. else if (normalizationType === SIMPLE_NORMALIZE) {
  1716. children = simpleNormalizeChildren(children);
  1717. }
  1718. let vnode, ns;
  1719. if (typeof tag === 'string') {
  1720. let Ctor;
  1721. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1722. if (config.isReservedTag(tag)) {
  1723. // platform built-in elements
  1724. if (isDef(data) &&
  1725. isDef(data.nativeOn) &&
  1726. data.tag !== 'component') {
  1727. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1728. }
  1729. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1730. }
  1731. else if ((!data || !data.pre) &&
  1732. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1733. // component
  1734. vnode = createComponent(Ctor, data, context, children, tag);
  1735. }
  1736. else {
  1737. // unknown or unlisted namespaced elements
  1738. // check at runtime because it may get assigned a namespace when its
  1739. // parent normalizes children
  1740. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1741. }
  1742. }
  1743. else {
  1744. // direct component options / constructor
  1745. vnode = createComponent(tag, data, context, children);
  1746. }
  1747. if (isArray(vnode)) {
  1748. return vnode;
  1749. }
  1750. else if (isDef(vnode)) {
  1751. if (isDef(ns))
  1752. applyNS(vnode, ns);
  1753. if (isDef(data))
  1754. registerDeepBindings(data);
  1755. return vnode;
  1756. }
  1757. else {
  1758. return createEmptyVNode();
  1759. }
  1760. }
  1761. function applyNS(vnode, ns, force) {
  1762. vnode.ns = ns;
  1763. if (vnode.tag === 'foreignObject') {
  1764. // use default namespace inside foreignObject
  1765. ns = undefined;
  1766. force = true;
  1767. }
  1768. if (isDef(vnode.children)) {
  1769. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1770. const child = vnode.children[i];
  1771. if (isDef(child.tag) &&
  1772. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1773. applyNS(child, ns, force);
  1774. }
  1775. }
  1776. }
  1777. }
  1778. // ref #5318
  1779. // necessary to ensure parent re-render when deep bindings like :style and
  1780. // :class are used on slot nodes
  1781. function registerDeepBindings(data) {
  1782. if (isObject(data.style)) {
  1783. traverse(data.style);
  1784. }
  1785. if (isObject(data.class)) {
  1786. traverse(data.class);
  1787. }
  1788. }
  1789. /**
  1790. * Runtime helper for rendering v-for lists.
  1791. */
  1792. function renderList(val, render) {
  1793. let ret = null, i, l, keys, key;
  1794. if (isArray(val) || typeof val === 'string') {
  1795. ret = new Array(val.length);
  1796. for (i = 0, l = val.length; i < l; i++) {
  1797. ret[i] = render(val[i], i);
  1798. }
  1799. }
  1800. else if (typeof val === 'number') {
  1801. ret = new Array(val);
  1802. for (i = 0; i < val; i++) {
  1803. ret[i] = render(i + 1, i);
  1804. }
  1805. }
  1806. else if (isObject(val)) {
  1807. if (hasSymbol && val[Symbol.iterator]) {
  1808. ret = [];
  1809. const iterator = val[Symbol.iterator]();
  1810. let result = iterator.next();
  1811. while (!result.done) {
  1812. ret.push(render(result.value, ret.length));
  1813. result = iterator.next();
  1814. }
  1815. }
  1816. else {
  1817. keys = Object.keys(val);
  1818. ret = new Array(keys.length);
  1819. for (i = 0, l = keys.length; i < l; i++) {
  1820. key = keys[i];
  1821. ret[i] = render(val[key], key, i);
  1822. }
  1823. }
  1824. }
  1825. if (!isDef(ret)) {
  1826. ret = [];
  1827. }
  1828. ret._isVList = true;
  1829. return ret;
  1830. }
  1831. /**
  1832. * Runtime helper for rendering <slot>
  1833. */
  1834. function renderSlot(name, fallbackRender, props, bindObject) {
  1835. const scopedSlotFn = this.$scopedSlots[name];
  1836. let nodes;
  1837. if (scopedSlotFn) {
  1838. // scoped slot
  1839. props = props || {};
  1840. if (bindObject) {
  1841. if (!isObject(bindObject)) {
  1842. warn$2('slot v-bind without argument expects an Object', this);
  1843. }
  1844. props = extend(extend({}, bindObject), props);
  1845. }
  1846. nodes =
  1847. scopedSlotFn(props) ||
  1848. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1849. }
  1850. else {
  1851. nodes =
  1852. this.$slots[name] ||
  1853. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1854. }
  1855. const target = props && props.slot;
  1856. if (target) {
  1857. return this.$createElement('template', { slot: target }, nodes);
  1858. }
  1859. else {
  1860. return nodes;
  1861. }
  1862. }
  1863. /**
  1864. * Runtime helper for resolving filters
  1865. */
  1866. function resolveFilter(id) {
  1867. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1868. }
  1869. function isKeyNotMatch(expect, actual) {
  1870. if (isArray(expect)) {
  1871. return expect.indexOf(actual) === -1;
  1872. }
  1873. else {
  1874. return expect !== actual;
  1875. }
  1876. }
  1877. /**
  1878. * Runtime helper for checking keyCodes from config.
  1879. * exposed as Vue.prototype._k
  1880. * passing in eventKeyName as last argument separately for backwards compat
  1881. */
  1882. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1883. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1884. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1885. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1886. }
  1887. else if (mappedKeyCode) {
  1888. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1889. }
  1890. else if (eventKeyName) {
  1891. return hyphenate(eventKeyName) !== key;
  1892. }
  1893. return eventKeyCode === undefined;
  1894. }
  1895. /**
  1896. * Runtime helper for merging v-bind="object" into a VNode's data.
  1897. */
  1898. function bindObjectProps(data, tag, value, asProp, isSync) {
  1899. if (value) {
  1900. if (!isObject(value)) {
  1901. warn$2('v-bind without argument expects an Object or Array value', this);
  1902. }
  1903. else {
  1904. if (isArray(value)) {
  1905. value = toObject(value);
  1906. }
  1907. let hash;
  1908. for (const key in value) {
  1909. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1910. hash = data;
  1911. }
  1912. else {
  1913. const type = data.attrs && data.attrs.type;
  1914. hash =
  1915. asProp || config.mustUseProp(tag, type, key)
  1916. ? data.domProps || (data.domProps = {})
  1917. : data.attrs || (data.attrs = {});
  1918. }
  1919. const camelizedKey = camelize(key);
  1920. const hyphenatedKey = hyphenate(key);
  1921. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1922. hash[key] = value[key];
  1923. if (isSync) {
  1924. const on = data.on || (data.on = {});
  1925. on[`update:${key}`] = function ($event) {
  1926. value[key] = $event;
  1927. };
  1928. }
  1929. }
  1930. }
  1931. }
  1932. }
  1933. return data;
  1934. }
  1935. /**
  1936. * Runtime helper for rendering static trees.
  1937. */
  1938. function renderStatic(index, isInFor) {
  1939. const cached = this._staticTrees || (this._staticTrees = []);
  1940. let tree = cached[index];
  1941. // if has already-rendered static tree and not inside v-for,
  1942. // we can reuse the same tree.
  1943. if (tree && !isInFor) {
  1944. return tree;
  1945. }
  1946. // otherwise, render a fresh tree.
  1947. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1948. );
  1949. markStatic$1(tree, `__static__${index}`, false);
  1950. return tree;
  1951. }
  1952. /**
  1953. * Runtime helper for v-once.
  1954. * Effectively it means marking the node as static with a unique key.
  1955. */
  1956. function markOnce(tree, index, key) {
  1957. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1958. return tree;
  1959. }
  1960. function markStatic$1(tree, key, isOnce) {
  1961. if (isArray(tree)) {
  1962. for (let i = 0; i < tree.length; i++) {
  1963. if (tree[i] && typeof tree[i] !== 'string') {
  1964. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1965. }
  1966. }
  1967. }
  1968. else {
  1969. markStaticNode(tree, key, isOnce);
  1970. }
  1971. }
  1972. function markStaticNode(node, key, isOnce) {
  1973. node.isStatic = true;
  1974. node.key = key;
  1975. node.isOnce = isOnce;
  1976. }
  1977. function bindObjectListeners(data, value) {
  1978. if (value) {
  1979. if (!isPlainObject(value)) {
  1980. warn$2('v-on without argument expects an Object value', this);
  1981. }
  1982. else {
  1983. const on = (data.on = data.on ? extend({}, data.on) : {});
  1984. for (const key in value) {
  1985. const existing = on[key];
  1986. const ours = value[key];
  1987. on[key] = existing ? [].concat(existing, ours) : ours;
  1988. }
  1989. }
  1990. }
  1991. return data;
  1992. }
  1993. function resolveScopedSlots(fns, res,
  1994. // the following are added in 2.6
  1995. hasDynamicKeys, contentHashKey) {
  1996. res = res || { $stable: !hasDynamicKeys };
  1997. for (let i = 0; i < fns.length; i++) {
  1998. const slot = fns[i];
  1999. if (isArray(slot)) {
  2000. resolveScopedSlots(slot, res, hasDynamicKeys);
  2001. }
  2002. else if (slot) {
  2003. // marker for reverse proxying v-slot without scope on this.$slots
  2004. // @ts-expect-error
  2005. if (slot.proxy) {
  2006. // @ts-expect-error
  2007. slot.fn.proxy = true;
  2008. }
  2009. res[slot.key] = slot.fn;
  2010. }
  2011. }
  2012. if (contentHashKey) {
  2013. res.$key = contentHashKey;
  2014. }
  2015. return res;
  2016. }
  2017. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2018. function bindDynamicKeys(baseObj, values) {
  2019. for (let i = 0; i < values.length; i += 2) {
  2020. const key = values[i];
  2021. if (typeof key === 'string' && key) {
  2022. baseObj[values[i]] = values[i + 1];
  2023. }
  2024. else if (key !== '' && key !== null) {
  2025. // null is a special value for explicitly removing a binding
  2026. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2027. }
  2028. }
  2029. return baseObj;
  2030. }
  2031. // helper to dynamically append modifier runtime markers to event names.
  2032. // ensure only append when value is already string, otherwise it will be cast
  2033. // to string and cause the type check to miss.
  2034. function prependModifier(value, symbol) {
  2035. return typeof value === 'string' ? symbol + value : value;
  2036. }
  2037. function installRenderHelpers(target) {
  2038. target._o = markOnce;
  2039. target._n = toNumber;
  2040. target._s = toString;
  2041. target._l = renderList;
  2042. target._t = renderSlot;
  2043. target._q = looseEqual;
  2044. target._i = looseIndexOf;
  2045. target._m = renderStatic;
  2046. target._f = resolveFilter;
  2047. target._k = checkKeyCodes;
  2048. target._b = bindObjectProps;
  2049. target._v = createTextVNode;
  2050. target._e = createEmptyVNode;
  2051. target._u = resolveScopedSlots;
  2052. target._g = bindObjectListeners;
  2053. target._d = bindDynamicKeys;
  2054. target._p = prependModifier;
  2055. }
  2056. /**
  2057. * Runtime helper for resolving raw children VNodes into a slot object.
  2058. */
  2059. function resolveSlots(children, context) {
  2060. if (!children || !children.length) {
  2061. return {};
  2062. }
  2063. const slots = {};
  2064. for (let i = 0, l = children.length; i < l; i++) {
  2065. const child = children[i];
  2066. const data = child.data;
  2067. // remove slot attribute if the node is resolved as a Vue slot node
  2068. if (data && data.attrs && data.attrs.slot) {
  2069. delete data.attrs.slot;
  2070. }
  2071. // named slots should only be respected if the vnode was rendered in the
  2072. // same context.
  2073. if ((child.context === context || child.fnContext === context) &&
  2074. data &&
  2075. data.slot != null) {
  2076. const name = data.slot;
  2077. const slot = slots[name] || (slots[name] = []);
  2078. if (child.tag === 'template') {
  2079. slot.push.apply(slot, child.children || []);
  2080. }
  2081. else {
  2082. slot.push(child);
  2083. }
  2084. }
  2085. else {
  2086. (slots.default || (slots.default = [])).push(child);
  2087. }
  2088. }
  2089. // ignore slots that contains only whitespace
  2090. for (const name in slots) {
  2091. if (slots[name].every(isWhitespace)) {
  2092. delete slots[name];
  2093. }
  2094. }
  2095. return slots;
  2096. }
  2097. function isWhitespace(node) {
  2098. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2099. }
  2100. function isAsyncPlaceholder(node) {
  2101. // @ts-expect-error not really boolean type
  2102. return node.isComment && node.asyncFactory;
  2103. }
  2104. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2105. let res;
  2106. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2107. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2108. const key = scopedSlots && scopedSlots.$key;
  2109. if (!scopedSlots) {
  2110. res = {};
  2111. }
  2112. else if (scopedSlots._normalized) {
  2113. // fast path 1: child component re-render only, parent did not change
  2114. return scopedSlots._normalized;
  2115. }
  2116. else if (isStable &&
  2117. prevScopedSlots &&
  2118. prevScopedSlots !== emptyObject &&
  2119. key === prevScopedSlots.$key &&
  2120. !hasNormalSlots &&
  2121. !prevScopedSlots.$hasNormal) {
  2122. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2123. // only need to normalize once
  2124. return prevScopedSlots;
  2125. }
  2126. else {
  2127. res = {};
  2128. for (const key in scopedSlots) {
  2129. if (scopedSlots[key] && key[0] !== '$') {
  2130. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2131. }
  2132. }
  2133. }
  2134. // expose normal slots on scopedSlots
  2135. for (const key in normalSlots) {
  2136. if (!(key in res)) {
  2137. res[key] = proxyNormalSlot(normalSlots, key);
  2138. }
  2139. }
  2140. // avoriaz seems to mock a non-extensible $scopedSlots object
  2141. // and when that is passed down this would cause an error
  2142. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2143. scopedSlots._normalized = res;
  2144. }
  2145. def(res, '$stable', isStable);
  2146. def(res, '$key', key);
  2147. def(res, '$hasNormal', hasNormalSlots);
  2148. return res;
  2149. }
  2150. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2151. const normalized = function () {
  2152. const cur = currentInstance;
  2153. setCurrentInstance(vm);
  2154. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2155. res =
  2156. res && typeof res === 'object' && !isArray(res)
  2157. ? [res] // single vnode
  2158. : normalizeChildren(res);
  2159. const vnode = res && res[0];
  2160. setCurrentInstance(cur);
  2161. return res &&
  2162. (!vnode ||
  2163. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2164. ? undefined
  2165. : res;
  2166. };
  2167. // this is a slot using the new v-slot syntax without scope. although it is
  2168. // compiled as a scoped slot, render fn users would expect it to be present
  2169. // on this.$slots because the usage is semantically a normal slot.
  2170. if (fn.proxy) {
  2171. Object.defineProperty(normalSlots, key, {
  2172. get: normalized,
  2173. enumerable: true,
  2174. configurable: true
  2175. });
  2176. }
  2177. return normalized;
  2178. }
  2179. function proxyNormalSlot(slots, key) {
  2180. return () => slots[key];
  2181. }
  2182. function initSetup(vm) {
  2183. const options = vm.$options;
  2184. const setup = options.setup;
  2185. if (setup) {
  2186. const ctx = (vm._setupContext = createSetupContext(vm));
  2187. setCurrentInstance(vm);
  2188. pushTarget();
  2189. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2190. popTarget();
  2191. setCurrentInstance();
  2192. if (isFunction(setupResult)) {
  2193. // render function
  2194. // @ts-ignore
  2195. options.render = setupResult;
  2196. }
  2197. else if (isObject(setupResult)) {
  2198. // bindings
  2199. if (setupResult instanceof VNode) {
  2200. warn$2(`setup() should not return VNodes directly - ` +
  2201. `return a render function instead.`);
  2202. }
  2203. vm._setupState = setupResult;
  2204. // __sfc indicates compiled bindings from <script setup>
  2205. if (!setupResult.__sfc) {
  2206. for (const key in setupResult) {
  2207. if (!isReserved(key)) {
  2208. proxyWithRefUnwrap(vm, setupResult, key);
  2209. }
  2210. else {
  2211. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2212. }
  2213. }
  2214. }
  2215. else {
  2216. // exposed for compiled render fn
  2217. const proxy = (vm._setupProxy = {});
  2218. for (const key in setupResult) {
  2219. if (key !== '__sfc') {
  2220. proxyWithRefUnwrap(proxy, setupResult, key);
  2221. }
  2222. }
  2223. }
  2224. }
  2225. else if (setupResult !== undefined) {
  2226. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2227. }
  2228. }
  2229. }
  2230. function createSetupContext(vm) {
  2231. let exposeCalled = false;
  2232. return {
  2233. get attrs() {
  2234. if (!vm._attrsProxy) {
  2235. const proxy = (vm._attrsProxy = {});
  2236. def(proxy, '_v_attr_proxy', true);
  2237. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2238. }
  2239. return vm._attrsProxy;
  2240. },
  2241. get listeners() {
  2242. if (!vm._listenersProxy) {
  2243. const proxy = (vm._listenersProxy = {});
  2244. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2245. }
  2246. return vm._listenersProxy;
  2247. },
  2248. get slots() {
  2249. return initSlotsProxy(vm);
  2250. },
  2251. emit: bind$1(vm.$emit, vm),
  2252. expose(exposed) {
  2253. {
  2254. if (exposeCalled) {
  2255. warn$2(`expose() should be called only once per setup().`, vm);
  2256. }
  2257. exposeCalled = true;
  2258. }
  2259. if (exposed) {
  2260. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2261. }
  2262. }
  2263. };
  2264. }
  2265. function syncSetupProxy(to, from, prev, instance, type) {
  2266. let changed = false;
  2267. for (const key in from) {
  2268. if (!(key in to)) {
  2269. changed = true;
  2270. defineProxyAttr(to, key, instance, type);
  2271. }
  2272. else if (from[key] !== prev[key]) {
  2273. changed = true;
  2274. }
  2275. }
  2276. for (const key in to) {
  2277. if (!(key in from)) {
  2278. changed = true;
  2279. delete to[key];
  2280. }
  2281. }
  2282. return changed;
  2283. }
  2284. function defineProxyAttr(proxy, key, instance, type) {
  2285. Object.defineProperty(proxy, key, {
  2286. enumerable: true,
  2287. configurable: true,
  2288. get() {
  2289. return instance[type][key];
  2290. }
  2291. });
  2292. }
  2293. function initSlotsProxy(vm) {
  2294. if (!vm._slotsProxy) {
  2295. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2296. }
  2297. return vm._slotsProxy;
  2298. }
  2299. function syncSetupSlots(to, from) {
  2300. for (const key in from) {
  2301. to[key] = from[key];
  2302. }
  2303. for (const key in to) {
  2304. if (!(key in from)) {
  2305. delete to[key];
  2306. }
  2307. }
  2308. }
  2309. /**
  2310. * @internal use manual type def because public setup context type relies on
  2311. * legacy VNode types
  2312. */
  2313. function useSlots() {
  2314. return getContext().slots;
  2315. }
  2316. /**
  2317. * @internal use manual type def because public setup context type relies on
  2318. * legacy VNode types
  2319. */
  2320. function useAttrs() {
  2321. return getContext().attrs;
  2322. }
  2323. /**
  2324. * Vue 2 only
  2325. * @internal use manual type def because public setup context type relies on
  2326. * legacy VNode types
  2327. */
  2328. function useListeners() {
  2329. return getContext().listeners;
  2330. }
  2331. function getContext() {
  2332. if (!currentInstance) {
  2333. warn$2(`useContext() called without active instance.`);
  2334. }
  2335. const vm = currentInstance;
  2336. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2337. }
  2338. /**
  2339. * Runtime helper for merging default declarations. Imported by compiled code
  2340. * only.
  2341. * @internal
  2342. */
  2343. function mergeDefaults(raw, defaults) {
  2344. const props = isArray(raw)
  2345. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2346. : raw;
  2347. for (const key in defaults) {
  2348. const opt = props[key];
  2349. if (opt) {
  2350. if (isArray(opt) || isFunction(opt)) {
  2351. props[key] = { type: opt, default: defaults[key] };
  2352. }
  2353. else {
  2354. opt.default = defaults[key];
  2355. }
  2356. }
  2357. else if (opt === null) {
  2358. props[key] = { default: defaults[key] };
  2359. }
  2360. else {
  2361. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2362. }
  2363. }
  2364. return props;
  2365. }
  2366. function initRender(vm) {
  2367. vm._vnode = null; // the root of the child tree
  2368. vm._staticTrees = null; // v-once cached trees
  2369. const options = vm.$options;
  2370. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2371. const renderContext = parentVnode && parentVnode.context;
  2372. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2373. vm.$scopedSlots = parentVnode
  2374. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2375. : emptyObject;
  2376. // bind the createElement fn to this instance
  2377. // so that we get proper render context inside it.
  2378. // args order: tag, data, children, normalizationType, alwaysNormalize
  2379. // internal version is used by render functions compiled from templates
  2380. // @ts-expect-error
  2381. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2382. // normalization is always applied for the public version, used in
  2383. // user-written render functions.
  2384. // @ts-expect-error
  2385. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2386. // $attrs & $listeners are exposed for easier HOC creation.
  2387. // they need to be reactive so that HOCs using them are always updated
  2388. const parentData = parentVnode && parentVnode.data;
  2389. /* istanbul ignore else */
  2390. {
  2391. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2392. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2393. }, true);
  2394. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2395. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2396. }, true);
  2397. }
  2398. }
  2399. let currentRenderingInstance = null;
  2400. function renderMixin(Vue) {
  2401. // install runtime convenience helpers
  2402. installRenderHelpers(Vue.prototype);
  2403. Vue.prototype.$nextTick = function (fn) {
  2404. return nextTick(fn, this);
  2405. };
  2406. Vue.prototype._render = function () {
  2407. const vm = this;
  2408. const { render, _parentVnode } = vm.$options;
  2409. if (_parentVnode && vm._isMounted) {
  2410. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2411. if (vm._slotsProxy) {
  2412. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2413. }
  2414. }
  2415. // set parent vnode. this allows render functions to have access
  2416. // to the data on the placeholder node.
  2417. vm.$vnode = _parentVnode;
  2418. // render self
  2419. const prevInst = currentInstance;
  2420. const prevRenderInst = currentRenderingInstance;
  2421. let vnode;
  2422. try {
  2423. setCurrentInstance(vm);
  2424. currentRenderingInstance = vm;
  2425. vnode = render.call(vm._renderProxy, vm.$createElement);
  2426. }
  2427. catch (e) {
  2428. handleError(e, vm, `render`);
  2429. // return error render result,
  2430. // or previous vnode to prevent render error causing blank component
  2431. /* istanbul ignore else */
  2432. if (vm.$options.renderError) {
  2433. try {
  2434. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2435. }
  2436. catch (e) {
  2437. handleError(e, vm, `renderError`);
  2438. vnode = vm._vnode;
  2439. }
  2440. }
  2441. else {
  2442. vnode = vm._vnode;
  2443. }
  2444. }
  2445. finally {
  2446. currentRenderingInstance = prevRenderInst;
  2447. setCurrentInstance(prevInst);
  2448. }
  2449. // if the returned array contains only a single node, allow it
  2450. if (isArray(vnode) && vnode.length === 1) {
  2451. vnode = vnode[0];
  2452. }
  2453. // return empty vnode in case the render function errored out
  2454. if (!(vnode instanceof VNode)) {
  2455. if (isArray(vnode)) {
  2456. warn$2('Multiple root nodes returned from render function. Render function ' +
  2457. 'should return a single root node.', vm);
  2458. }
  2459. vnode = createEmptyVNode();
  2460. }
  2461. // set parent
  2462. vnode.parent = _parentVnode;
  2463. return vnode;
  2464. };
  2465. }
  2466. function ensureCtor(comp, base) {
  2467. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2468. comp = comp.default;
  2469. }
  2470. return isObject(comp) ? base.extend(comp) : comp;
  2471. }
  2472. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2473. const node = createEmptyVNode();
  2474. node.asyncFactory = factory;
  2475. node.asyncMeta = { data, context, children, tag };
  2476. return node;
  2477. }
  2478. function resolveAsyncComponent(factory, baseCtor) {
  2479. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2480. return factory.errorComp;
  2481. }
  2482. if (isDef(factory.resolved)) {
  2483. return factory.resolved;
  2484. }
  2485. const owner = currentRenderingInstance;
  2486. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2487. // already pending
  2488. factory.owners.push(owner);
  2489. }
  2490. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2491. return factory.loadingComp;
  2492. }
  2493. if (owner && !isDef(factory.owners)) {
  2494. const owners = (factory.owners = [owner]);
  2495. let sync = true;
  2496. let timerLoading = null;
  2497. let timerTimeout = null;
  2498. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2499. const forceRender = (renderCompleted) => {
  2500. for (let i = 0, l = owners.length; i < l; i++) {
  2501. owners[i].$forceUpdate();
  2502. }
  2503. if (renderCompleted) {
  2504. owners.length = 0;
  2505. if (timerLoading !== null) {
  2506. clearTimeout(timerLoading);
  2507. timerLoading = null;
  2508. }
  2509. if (timerTimeout !== null) {
  2510. clearTimeout(timerTimeout);
  2511. timerTimeout = null;
  2512. }
  2513. }
  2514. };
  2515. const resolve = once((res) => {
  2516. // cache resolved
  2517. factory.resolved = ensureCtor(res, baseCtor);
  2518. // invoke callbacks only if this is not a synchronous resolve
  2519. // (async resolves are shimmed as synchronous during SSR)
  2520. if (!sync) {
  2521. forceRender(true);
  2522. }
  2523. else {
  2524. owners.length = 0;
  2525. }
  2526. });
  2527. const reject = once(reason => {
  2528. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2529. (reason ? `\nReason: ${reason}` : ''));
  2530. if (isDef(factory.errorComp)) {
  2531. factory.error = true;
  2532. forceRender(true);
  2533. }
  2534. });
  2535. const res = factory(resolve, reject);
  2536. if (isObject(res)) {
  2537. if (isPromise(res)) {
  2538. // () => Promise
  2539. if (isUndef(factory.resolved)) {
  2540. res.then(resolve, reject);
  2541. }
  2542. }
  2543. else if (isPromise(res.component)) {
  2544. res.component.then(resolve, reject);
  2545. if (isDef(res.error)) {
  2546. factory.errorComp = ensureCtor(res.error, baseCtor);
  2547. }
  2548. if (isDef(res.loading)) {
  2549. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2550. if (res.delay === 0) {
  2551. factory.loading = true;
  2552. }
  2553. else {
  2554. // @ts-expect-error NodeJS timeout type
  2555. timerLoading = setTimeout(() => {
  2556. timerLoading = null;
  2557. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2558. factory.loading = true;
  2559. forceRender(false);
  2560. }
  2561. }, res.delay || 200);
  2562. }
  2563. }
  2564. if (isDef(res.timeout)) {
  2565. // @ts-expect-error NodeJS timeout type
  2566. timerTimeout = setTimeout(() => {
  2567. timerTimeout = null;
  2568. if (isUndef(factory.resolved)) {
  2569. reject(`timeout (${res.timeout}ms)` );
  2570. }
  2571. }, res.timeout);
  2572. }
  2573. }
  2574. }
  2575. sync = false;
  2576. // return in case resolved synchronously
  2577. return factory.loading ? factory.loadingComp : factory.resolved;
  2578. }
  2579. }
  2580. function getFirstComponentChild(children) {
  2581. if (isArray(children)) {
  2582. for (let i = 0; i < children.length; i++) {
  2583. const c = children[i];
  2584. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2585. return c;
  2586. }
  2587. }
  2588. }
  2589. }
  2590. function initEvents(vm) {
  2591. vm._events = Object.create(null);
  2592. vm._hasHookEvent = false;
  2593. // init parent attached events
  2594. const listeners = vm.$options._parentListeners;
  2595. if (listeners) {
  2596. updateComponentListeners(vm, listeners);
  2597. }
  2598. }
  2599. let target$1;
  2600. function add$1(event, fn) {
  2601. target$1.$on(event, fn);
  2602. }
  2603. function remove$1(event, fn) {
  2604. target$1.$off(event, fn);
  2605. }
  2606. function createOnceHandler$1(event, fn) {
  2607. const _target = target$1;
  2608. return function onceHandler() {
  2609. const res = fn.apply(null, arguments);
  2610. if (res !== null) {
  2611. _target.$off(event, onceHandler);
  2612. }
  2613. };
  2614. }
  2615. function updateComponentListeners(vm, listeners, oldListeners) {
  2616. target$1 = vm;
  2617. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2618. target$1 = undefined;
  2619. }
  2620. function eventsMixin(Vue) {
  2621. const hookRE = /^hook:/;
  2622. Vue.prototype.$on = function (event, fn) {
  2623. const vm = this;
  2624. if (isArray(event)) {
  2625. for (let i = 0, l = event.length; i < l; i++) {
  2626. vm.$on(event[i], fn);
  2627. }
  2628. }
  2629. else {
  2630. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2631. // optimize hook:event cost by using a boolean flag marked at registration
  2632. // instead of a hash lookup
  2633. if (hookRE.test(event)) {
  2634. vm._hasHookEvent = true;
  2635. }
  2636. }
  2637. return vm;
  2638. };
  2639. Vue.prototype.$once = function (event, fn) {
  2640. const vm = this;
  2641. function on() {
  2642. vm.$off(event, on);
  2643. fn.apply(vm, arguments);
  2644. }
  2645. on.fn = fn;
  2646. vm.$on(event, on);
  2647. return vm;
  2648. };
  2649. Vue.prototype.$off = function (event, fn) {
  2650. const vm = this;
  2651. // all
  2652. if (!arguments.length) {
  2653. vm._events = Object.create(null);
  2654. return vm;
  2655. }
  2656. // array of events
  2657. if (isArray(event)) {
  2658. for (let i = 0, l = event.length; i < l; i++) {
  2659. vm.$off(event[i], fn);
  2660. }
  2661. return vm;
  2662. }
  2663. // specific event
  2664. const cbs = vm._events[event];
  2665. if (!cbs) {
  2666. return vm;
  2667. }
  2668. if (!fn) {
  2669. vm._events[event] = null;
  2670. return vm;
  2671. }
  2672. // specific handler
  2673. let cb;
  2674. let i = cbs.length;
  2675. while (i--) {
  2676. cb = cbs[i];
  2677. if (cb === fn || cb.fn === fn) {
  2678. cbs.splice(i, 1);
  2679. break;
  2680. }
  2681. }
  2682. return vm;
  2683. };
  2684. Vue.prototype.$emit = function (event) {
  2685. const vm = this;
  2686. {
  2687. const lowerCaseEvent = event.toLowerCase();
  2688. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2689. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2690. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2691. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2692. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2693. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2694. }
  2695. }
  2696. let cbs = vm._events[event];
  2697. if (cbs) {
  2698. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2699. const args = toArray(arguments, 1);
  2700. const info = `event handler for "${event}"`;
  2701. for (let i = 0, l = cbs.length; i < l; i++) {
  2702. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2703. }
  2704. }
  2705. return vm;
  2706. };
  2707. }
  2708. let activeEffectScope;
  2709. class EffectScope {
  2710. constructor(detached = false) {
  2711. this.detached = detached;
  2712. /**
  2713. * @internal
  2714. */
  2715. this.active = true;
  2716. /**
  2717. * @internal
  2718. */
  2719. this.effects = [];
  2720. /**
  2721. * @internal
  2722. */
  2723. this.cleanups = [];
  2724. this.parent = activeEffectScope;
  2725. if (!detached && activeEffectScope) {
  2726. this.index =
  2727. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  2728. }
  2729. }
  2730. run(fn) {
  2731. if (this.active) {
  2732. const currentEffectScope = activeEffectScope;
  2733. try {
  2734. activeEffectScope = this;
  2735. return fn();
  2736. }
  2737. finally {
  2738. activeEffectScope = currentEffectScope;
  2739. }
  2740. }
  2741. else {
  2742. warn$2(`cannot run an inactive effect scope.`);
  2743. }
  2744. }
  2745. /**
  2746. * This should only be called on non-detached scopes
  2747. * @internal
  2748. */
  2749. on() {
  2750. activeEffectScope = this;
  2751. }
  2752. /**
  2753. * This should only be called on non-detached scopes
  2754. * @internal
  2755. */
  2756. off() {
  2757. activeEffectScope = this.parent;
  2758. }
  2759. stop(fromParent) {
  2760. if (this.active) {
  2761. let i, l;
  2762. for (i = 0, l = this.effects.length; i < l; i++) {
  2763. this.effects[i].teardown();
  2764. }
  2765. for (i = 0, l = this.cleanups.length; i < l; i++) {
  2766. this.cleanups[i]();
  2767. }
  2768. if (this.scopes) {
  2769. for (i = 0, l = this.scopes.length; i < l; i++) {
  2770. this.scopes[i].stop(true);
  2771. }
  2772. }
  2773. // nested scope, dereference from parent to avoid memory leaks
  2774. if (!this.detached && this.parent && !fromParent) {
  2775. // optimized O(1) removal
  2776. const last = this.parent.scopes.pop();
  2777. if (last && last !== this) {
  2778. this.parent.scopes[this.index] = last;
  2779. last.index = this.index;
  2780. }
  2781. }
  2782. this.parent = undefined;
  2783. this.active = false;
  2784. }
  2785. }
  2786. }
  2787. function effectScope(detached) {
  2788. return new EffectScope(detached);
  2789. }
  2790. /**
  2791. * @internal
  2792. */
  2793. function recordEffectScope(effect, scope = activeEffectScope) {
  2794. if (scope && scope.active) {
  2795. scope.effects.push(effect);
  2796. }
  2797. }
  2798. function getCurrentScope() {
  2799. return activeEffectScope;
  2800. }
  2801. function onScopeDispose(fn) {
  2802. if (activeEffectScope) {
  2803. activeEffectScope.cleanups.push(fn);
  2804. }
  2805. else {
  2806. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  2807. ` to be associated with.`);
  2808. }
  2809. }
  2810. let activeInstance = null;
  2811. let isUpdatingChildComponent = false;
  2812. function setActiveInstance(vm) {
  2813. const prevActiveInstance = activeInstance;
  2814. activeInstance = vm;
  2815. return () => {
  2816. activeInstance = prevActiveInstance;
  2817. };
  2818. }
  2819. function initLifecycle(vm) {
  2820. const options = vm.$options;
  2821. // locate first non-abstract parent
  2822. let parent = options.parent;
  2823. if (parent && !options.abstract) {
  2824. while (parent.$options.abstract && parent.$parent) {
  2825. parent = parent.$parent;
  2826. }
  2827. parent.$children.push(vm);
  2828. }
  2829. vm.$parent = parent;
  2830. vm.$root = parent ? parent.$root : vm;
  2831. vm.$children = [];
  2832. vm.$refs = {};
  2833. vm._provided = parent ? parent._provided : Object.create(null);
  2834. vm._watcher = null;
  2835. vm._inactive = null;
  2836. vm._directInactive = false;
  2837. vm._isMounted = false;
  2838. vm._isDestroyed = false;
  2839. vm._isBeingDestroyed = false;
  2840. }
  2841. function lifecycleMixin(Vue) {
  2842. Vue.prototype._update = function (vnode, hydrating) {
  2843. const vm = this;
  2844. const prevEl = vm.$el;
  2845. const prevVnode = vm._vnode;
  2846. const restoreActiveInstance = setActiveInstance(vm);
  2847. vm._vnode = vnode;
  2848. // Vue.prototype.__patch__ is injected in entry points
  2849. // based on the rendering backend used.
  2850. if (!prevVnode) {
  2851. // initial render
  2852. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2853. }
  2854. else {
  2855. // updates
  2856. vm.$el = vm.__patch__(prevVnode, vnode);
  2857. }
  2858. restoreActiveInstance();
  2859. // update __vue__ reference
  2860. if (prevEl) {
  2861. prevEl.__vue__ = null;
  2862. }
  2863. if (vm.$el) {
  2864. vm.$el.__vue__ = vm;
  2865. }
  2866. // if parent is an HOC, update its $el as well
  2867. let wrapper = vm;
  2868. while (wrapper &&
  2869. wrapper.$vnode &&
  2870. wrapper.$parent &&
  2871. wrapper.$vnode === wrapper.$parent._vnode) {
  2872. wrapper.$parent.$el = wrapper.$el;
  2873. wrapper = wrapper.$parent;
  2874. }
  2875. // updated hook is called by the scheduler to ensure that children are
  2876. // updated in a parent's updated hook.
  2877. };
  2878. Vue.prototype.$forceUpdate = function () {
  2879. const vm = this;
  2880. if (vm._watcher) {
  2881. vm._watcher.update();
  2882. }
  2883. };
  2884. Vue.prototype.$destroy = function () {
  2885. const vm = this;
  2886. if (vm._isBeingDestroyed) {
  2887. return;
  2888. }
  2889. callHook$1(vm, 'beforeDestroy');
  2890. vm._isBeingDestroyed = true;
  2891. // remove self from parent
  2892. const parent = vm.$parent;
  2893. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2894. remove$2(parent.$children, vm);
  2895. }
  2896. // teardown scope. this includes both the render watcher and other
  2897. // watchers created
  2898. vm._scope.stop();
  2899. // remove reference from data ob
  2900. // frozen object may not have observer.
  2901. if (vm._data.__ob__) {
  2902. vm._data.__ob__.vmCount--;
  2903. }
  2904. // call the last hook...
  2905. vm._isDestroyed = true;
  2906. // invoke destroy hooks on current rendered tree
  2907. vm.__patch__(vm._vnode, null);
  2908. // fire destroyed hook
  2909. callHook$1(vm, 'destroyed');
  2910. // turn off all instance listeners.
  2911. vm.$off();
  2912. // remove __vue__ reference
  2913. if (vm.$el) {
  2914. vm.$el.__vue__ = null;
  2915. }
  2916. // release circular reference (#6759)
  2917. if (vm.$vnode) {
  2918. vm.$vnode.parent = null;
  2919. }
  2920. };
  2921. }
  2922. function mountComponent(vm, el, hydrating) {
  2923. vm.$el = el;
  2924. if (!vm.$options.render) {
  2925. // @ts-expect-error invalid type
  2926. vm.$options.render = createEmptyVNode;
  2927. {
  2928. /* istanbul ignore if */
  2929. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2930. vm.$options.el ||
  2931. el) {
  2932. warn$2('You are using the runtime-only build of Vue where the template ' +
  2933. 'compiler is not available. Either pre-compile the templates into ' +
  2934. 'render functions, or use the compiler-included build.', vm);
  2935. }
  2936. else {
  2937. warn$2('Failed to mount component: template or render function not defined.', vm);
  2938. }
  2939. }
  2940. }
  2941. callHook$1(vm, 'beforeMount');
  2942. let updateComponent;
  2943. /* istanbul ignore if */
  2944. if (config.performance && mark) {
  2945. updateComponent = () => {
  2946. const name = vm._name;
  2947. const id = vm._uid;
  2948. const startTag = `vue-perf-start:${id}`;
  2949. const endTag = `vue-perf-end:${id}`;
  2950. mark(startTag);
  2951. const vnode = vm._render();
  2952. mark(endTag);
  2953. measure(`vue ${name} render`, startTag, endTag);
  2954. mark(startTag);
  2955. vm._update(vnode, hydrating);
  2956. mark(endTag);
  2957. measure(`vue ${name} patch`, startTag, endTag);
  2958. };
  2959. }
  2960. else {
  2961. updateComponent = () => {
  2962. vm._update(vm._render(), hydrating);
  2963. };
  2964. }
  2965. const watcherOptions = {
  2966. before() {
  2967. if (vm._isMounted && !vm._isDestroyed) {
  2968. callHook$1(vm, 'beforeUpdate');
  2969. }
  2970. }
  2971. };
  2972. {
  2973. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2974. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2975. }
  2976. // we set this to vm._watcher inside the watcher's constructor
  2977. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2978. // component's mounted hook), which relies on vm._watcher being already defined
  2979. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2980. hydrating = false;
  2981. // flush buffer for flush: "pre" watchers queued in setup()
  2982. const preWatchers = vm._preWatchers;
  2983. if (preWatchers) {
  2984. for (let i = 0; i < preWatchers.length; i++) {
  2985. preWatchers[i].run();
  2986. }
  2987. }
  2988. // manually mounted instance, call mounted on self
  2989. // mounted is called for render-created child components in its inserted hook
  2990. if (vm.$vnode == null) {
  2991. vm._isMounted = true;
  2992. callHook$1(vm, 'mounted');
  2993. }
  2994. return vm;
  2995. }
  2996. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2997. {
  2998. isUpdatingChildComponent = true;
  2999. }
  3000. // determine whether component has slot children
  3001. // we need to do this before overwriting $options._renderChildren.
  3002. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3003. // dynamic slot names). Static scoped slots compiled from template has the
  3004. // "$stable" marker.
  3005. const newScopedSlots = parentVnode.data.scopedSlots;
  3006. const oldScopedSlots = vm.$scopedSlots;
  3007. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3008. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3009. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3010. (!newScopedSlots && vm.$scopedSlots.$key));
  3011. // Any static slot children from the parent may have changed during parent's
  3012. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3013. // update is necessary to ensure correctness.
  3014. let needsForceUpdate = !!(renderChildren || // has new static slots
  3015. vm.$options._renderChildren || // has old static slots
  3016. hasDynamicScopedSlot);
  3017. const prevVNode = vm.$vnode;
  3018. vm.$options._parentVnode = parentVnode;
  3019. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3020. if (vm._vnode) {
  3021. // update child tree's parent
  3022. vm._vnode.parent = parentVnode;
  3023. }
  3024. vm.$options._renderChildren = renderChildren;
  3025. // update $attrs and $listeners hash
  3026. // these are also reactive so they may trigger child update if the child
  3027. // used them during render
  3028. const attrs = parentVnode.data.attrs || emptyObject;
  3029. if (vm._attrsProxy) {
  3030. // force update if attrs are accessed and has changed since it may be
  3031. // passed to a child component.
  3032. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3033. needsForceUpdate = true;
  3034. }
  3035. }
  3036. vm.$attrs = attrs;
  3037. // update listeners
  3038. listeners = listeners || emptyObject;
  3039. const prevListeners = vm.$options._parentListeners;
  3040. if (vm._listenersProxy) {
  3041. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3042. }
  3043. vm.$listeners = vm.$options._parentListeners = listeners;
  3044. updateComponentListeners(vm, listeners, prevListeners);
  3045. // update props
  3046. if (propsData && vm.$options.props) {
  3047. toggleObserving(false);
  3048. const props = vm._props;
  3049. const propKeys = vm.$options._propKeys || [];
  3050. for (let i = 0; i < propKeys.length; i++) {
  3051. const key = propKeys[i];
  3052. const propOptions = vm.$options.props; // wtf flow?
  3053. props[key] = validateProp(key, propOptions, propsData, vm);
  3054. }
  3055. toggleObserving(true);
  3056. // keep a copy of raw propsData
  3057. vm.$options.propsData = propsData;
  3058. }
  3059. // resolve slots + force update if has children
  3060. if (needsForceUpdate) {
  3061. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3062. vm.$forceUpdate();
  3063. }
  3064. {
  3065. isUpdatingChildComponent = false;
  3066. }
  3067. }
  3068. function isInInactiveTree(vm) {
  3069. while (vm && (vm = vm.$parent)) {
  3070. if (vm._inactive)
  3071. return true;
  3072. }
  3073. return false;
  3074. }
  3075. function activateChildComponent(vm, direct) {
  3076. if (direct) {
  3077. vm._directInactive = false;
  3078. if (isInInactiveTree(vm)) {
  3079. return;
  3080. }
  3081. }
  3082. else if (vm._directInactive) {
  3083. return;
  3084. }
  3085. if (vm._inactive || vm._inactive === null) {
  3086. vm._inactive = false;
  3087. for (let i = 0; i < vm.$children.length; i++) {
  3088. activateChildComponent(vm.$children[i]);
  3089. }
  3090. callHook$1(vm, 'activated');
  3091. }
  3092. }
  3093. function deactivateChildComponent(vm, direct) {
  3094. if (direct) {
  3095. vm._directInactive = true;
  3096. if (isInInactiveTree(vm)) {
  3097. return;
  3098. }
  3099. }
  3100. if (!vm._inactive) {
  3101. vm._inactive = true;
  3102. for (let i = 0; i < vm.$children.length; i++) {
  3103. deactivateChildComponent(vm.$children[i]);
  3104. }
  3105. callHook$1(vm, 'deactivated');
  3106. }
  3107. }
  3108. function callHook$1(vm, hook, args, setContext = true) {
  3109. // #7573 disable dep collection when invoking lifecycle hooks
  3110. pushTarget();
  3111. const prevInst = currentInstance;
  3112. const prevScope = getCurrentScope();
  3113. setContext && setCurrentInstance(vm);
  3114. const handlers = vm.$options[hook];
  3115. const info = `${hook} hook`;
  3116. if (handlers) {
  3117. for (let i = 0, j = handlers.length; i < j; i++) {
  3118. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3119. }
  3120. }
  3121. if (vm._hasHookEvent) {
  3122. vm.$emit('hook:' + hook);
  3123. }
  3124. if (setContext) {
  3125. setCurrentInstance(prevInst);
  3126. prevScope && prevScope.on();
  3127. }
  3128. popTarget();
  3129. }
  3130. const MAX_UPDATE_COUNT = 100;
  3131. const queue = [];
  3132. const activatedChildren = [];
  3133. let has = {};
  3134. let circular = {};
  3135. let waiting = false;
  3136. let flushing = false;
  3137. let index$1 = 0;
  3138. /**
  3139. * Reset the scheduler's state.
  3140. */
  3141. function resetSchedulerState() {
  3142. index$1 = queue.length = activatedChildren.length = 0;
  3143. has = {};
  3144. {
  3145. circular = {};
  3146. }
  3147. waiting = flushing = false;
  3148. }
  3149. // Async edge case #6566 requires saving the timestamp when event listeners are
  3150. // attached. However, calling performance.now() has a perf overhead especially
  3151. // if the page has thousands of event listeners. Instead, we take a timestamp
  3152. // every time the scheduler flushes and use that for all event listeners
  3153. // attached during that flush.
  3154. let currentFlushTimestamp = 0;
  3155. // Async edge case fix requires storing an event listener's attach timestamp.
  3156. let getNow = Date.now;
  3157. // Determine what event timestamp the browser is using. Annoyingly, the
  3158. // timestamp can either be hi-res (relative to page load) or low-res
  3159. // (relative to UNIX epoch), so in order to compare time we have to use the
  3160. // same timestamp type when saving the flush timestamp.
  3161. // All IE versions use low-res event timestamps, and have problematic clock
  3162. // implementations (#9632)
  3163. if (inBrowser && !isIE) {
  3164. const performance = window.performance;
  3165. if (performance &&
  3166. typeof performance.now === 'function' &&
  3167. getNow() > document.createEvent('Event').timeStamp) {
  3168. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3169. // smaller than it, it means the event is using a hi-res timestamp,
  3170. // and we need to use the hi-res version for event listener timestamps as
  3171. // well.
  3172. getNow = () => performance.now();
  3173. }
  3174. }
  3175. const sortCompareFn = (a, b) => {
  3176. if (a.post) {
  3177. if (!b.post)
  3178. return 1;
  3179. }
  3180. else if (b.post) {
  3181. return -1;
  3182. }
  3183. return a.id - b.id;
  3184. };
  3185. /**
  3186. * Flush both queues and run the watchers.
  3187. */
  3188. function flushSchedulerQueue() {
  3189. currentFlushTimestamp = getNow();
  3190. flushing = true;
  3191. let watcher, id;
  3192. // Sort queue before flush.
  3193. // This ensures that:
  3194. // 1. Components are updated from parent to child. (because parent is always
  3195. // created before the child)
  3196. // 2. A component's user watchers are run before its render watcher (because
  3197. // user watchers are created before the render watcher)
  3198. // 3. If a component is destroyed during a parent component's watcher run,
  3199. // its watchers can be skipped.
  3200. queue.sort(sortCompareFn);
  3201. // do not cache length because more watchers might be pushed
  3202. // as we run existing watchers
  3203. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3204. watcher = queue[index$1];
  3205. if (watcher.before) {
  3206. watcher.before();
  3207. }
  3208. id = watcher.id;
  3209. has[id] = null;
  3210. watcher.run();
  3211. // in dev build, check and stop circular updates.
  3212. if (has[id] != null) {
  3213. circular[id] = (circular[id] || 0) + 1;
  3214. if (circular[id] > MAX_UPDATE_COUNT) {
  3215. warn$2('You may have an infinite update loop ' +
  3216. (watcher.user
  3217. ? `in watcher with expression "${watcher.expression}"`
  3218. : `in a component render function.`), watcher.vm);
  3219. break;
  3220. }
  3221. }
  3222. }
  3223. // keep copies of post queues before resetting state
  3224. const activatedQueue = activatedChildren.slice();
  3225. const updatedQueue = queue.slice();
  3226. resetSchedulerState();
  3227. // call component updated and activated hooks
  3228. callActivatedHooks(activatedQueue);
  3229. callUpdatedHooks(updatedQueue);
  3230. cleanupDeps();
  3231. // devtool hook
  3232. /* istanbul ignore if */
  3233. if (devtools && config.devtools) {
  3234. devtools.emit('flush');
  3235. }
  3236. }
  3237. function callUpdatedHooks(queue) {
  3238. let i = queue.length;
  3239. while (i--) {
  3240. const watcher = queue[i];
  3241. const vm = watcher.vm;
  3242. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3243. callHook$1(vm, 'updated');
  3244. }
  3245. }
  3246. }
  3247. /**
  3248. * Queue a kept-alive component that was activated during patch.
  3249. * The queue will be processed after the entire tree has been patched.
  3250. */
  3251. function queueActivatedComponent(vm) {
  3252. // setting _inactive to false here so that a render function can
  3253. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3254. vm._inactive = false;
  3255. activatedChildren.push(vm);
  3256. }
  3257. function callActivatedHooks(queue) {
  3258. for (let i = 0; i < queue.length; i++) {
  3259. queue[i]._inactive = true;
  3260. activateChildComponent(queue[i], true /* true */);
  3261. }
  3262. }
  3263. /**
  3264. * Push a watcher into the watcher queue.
  3265. * Jobs with duplicate IDs will be skipped unless it's
  3266. * pushed when the queue is being flushed.
  3267. */
  3268. function queueWatcher(watcher) {
  3269. const id = watcher.id;
  3270. if (has[id] != null) {
  3271. return;
  3272. }
  3273. if (watcher === Dep.target && watcher.noRecurse) {
  3274. return;
  3275. }
  3276. has[id] = true;
  3277. if (!flushing) {
  3278. queue.push(watcher);
  3279. }
  3280. else {
  3281. // if already flushing, splice the watcher based on its id
  3282. // if already past its id, it will be run next immediately.
  3283. let i = queue.length - 1;
  3284. while (i > index$1 && queue[i].id > watcher.id) {
  3285. i--;
  3286. }
  3287. queue.splice(i + 1, 0, watcher);
  3288. }
  3289. // queue the flush
  3290. if (!waiting) {
  3291. waiting = true;
  3292. if (!config.async) {
  3293. flushSchedulerQueue();
  3294. return;
  3295. }
  3296. nextTick(flushSchedulerQueue);
  3297. }
  3298. }
  3299. const WATCHER = `watcher`;
  3300. const WATCHER_CB = `${WATCHER} callback`;
  3301. const WATCHER_GETTER = `${WATCHER} getter`;
  3302. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3303. // Simple effect.
  3304. function watchEffect(effect, options) {
  3305. return doWatch(effect, null, options);
  3306. }
  3307. function watchPostEffect(effect, options) {
  3308. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3309. }
  3310. function watchSyncEffect(effect, options) {
  3311. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3312. }
  3313. // initial value for watchers to trigger on undefined initial values
  3314. const INITIAL_WATCHER_VALUE = {};
  3315. // implementation
  3316. function watch(source, cb, options) {
  3317. if (typeof cb !== 'function') {
  3318. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3319. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3320. `supports \`watch(source, cb, options?) signature.`);
  3321. }
  3322. return doWatch(source, cb, options);
  3323. }
  3324. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3325. if (!cb) {
  3326. if (immediate !== undefined) {
  3327. warn$2(`watch() "immediate" option is only respected when using the ` +
  3328. `watch(source, callback, options?) signature.`);
  3329. }
  3330. if (deep !== undefined) {
  3331. warn$2(`watch() "deep" option is only respected when using the ` +
  3332. `watch(source, callback, options?) signature.`);
  3333. }
  3334. }
  3335. const warnInvalidSource = (s) => {
  3336. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3337. `function, a ref, a reactive object, or an array of these types.`);
  3338. };
  3339. const instance = currentInstance;
  3340. const call = (fn, type, args = null) => {
  3341. const res = invokeWithErrorHandling(fn, null, args, instance, type);
  3342. if (deep && res && res.__ob__)
  3343. res.__ob__.dep.depend();
  3344. return res;
  3345. };
  3346. let getter;
  3347. let forceTrigger = false;
  3348. let isMultiSource = false;
  3349. if (isRef(source)) {
  3350. getter = () => source.value;
  3351. forceTrigger = isShallow(source);
  3352. }
  3353. else if (isReactive(source)) {
  3354. getter = () => {
  3355. source.__ob__.dep.depend();
  3356. return source;
  3357. };
  3358. deep = true;
  3359. }
  3360. else if (isArray(source)) {
  3361. isMultiSource = true;
  3362. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3363. getter = () => source.map(s => {
  3364. if (isRef(s)) {
  3365. return s.value;
  3366. }
  3367. else if (isReactive(s)) {
  3368. s.__ob__.dep.depend();
  3369. return traverse(s);
  3370. }
  3371. else if (isFunction(s)) {
  3372. return call(s, WATCHER_GETTER);
  3373. }
  3374. else {
  3375. warnInvalidSource(s);
  3376. }
  3377. });
  3378. }
  3379. else if (isFunction(source)) {
  3380. if (cb) {
  3381. // getter with cb
  3382. getter = () => call(source, WATCHER_GETTER);
  3383. }
  3384. else {
  3385. // no cb -> simple effect
  3386. getter = () => {
  3387. if (instance && instance._isDestroyed) {
  3388. return;
  3389. }
  3390. if (cleanup) {
  3391. cleanup();
  3392. }
  3393. return call(source, WATCHER, [onCleanup]);
  3394. };
  3395. }
  3396. }
  3397. else {
  3398. getter = noop;
  3399. warnInvalidSource(source);
  3400. }
  3401. if (cb && deep) {
  3402. const baseGetter = getter;
  3403. getter = () => traverse(baseGetter());
  3404. }
  3405. let cleanup;
  3406. let onCleanup = (fn) => {
  3407. cleanup = watcher.onStop = () => {
  3408. call(fn, WATCHER_CLEANUP);
  3409. };
  3410. };
  3411. // in SSR there is no need to setup an actual effect, and it should be noop
  3412. // unless it's eager
  3413. if (isServerRendering()) {
  3414. // we will also not call the invalidate callback (+ runner is not set up)
  3415. onCleanup = noop;
  3416. if (!cb) {
  3417. getter();
  3418. }
  3419. else if (immediate) {
  3420. call(cb, WATCHER_CB, [
  3421. getter(),
  3422. isMultiSource ? [] : undefined,
  3423. onCleanup
  3424. ]);
  3425. }
  3426. return noop;
  3427. }
  3428. const watcher = new Watcher(currentInstance, getter, noop, {
  3429. lazy: true
  3430. });
  3431. watcher.noRecurse = !cb;
  3432. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3433. // overwrite default run
  3434. watcher.run = () => {
  3435. if (!watcher.active) {
  3436. return;
  3437. }
  3438. if (cb) {
  3439. // watch(source, cb)
  3440. const newValue = watcher.get();
  3441. if (deep ||
  3442. forceTrigger ||
  3443. (isMultiSource
  3444. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3445. : hasChanged(newValue, oldValue))) {
  3446. // cleanup before running cb again
  3447. if (cleanup) {
  3448. cleanup();
  3449. }
  3450. call(cb, WATCHER_CB, [
  3451. newValue,
  3452. // pass undefined as the old value when it's changed for the first time
  3453. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3454. onCleanup
  3455. ]);
  3456. oldValue = newValue;
  3457. }
  3458. }
  3459. else {
  3460. // watchEffect
  3461. watcher.get();
  3462. }
  3463. };
  3464. if (flush === 'sync') {
  3465. watcher.update = watcher.run;
  3466. }
  3467. else if (flush === 'post') {
  3468. watcher.post = true;
  3469. watcher.update = () => queueWatcher(watcher);
  3470. }
  3471. else {
  3472. // pre
  3473. watcher.update = () => {
  3474. if (instance && instance === currentInstance && !instance._isMounted) {
  3475. // pre-watcher triggered before
  3476. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3477. if (buffer.indexOf(watcher) < 0)
  3478. buffer.push(watcher);
  3479. }
  3480. else {
  3481. queueWatcher(watcher);
  3482. }
  3483. };
  3484. }
  3485. {
  3486. watcher.onTrack = onTrack;
  3487. watcher.onTrigger = onTrigger;
  3488. }
  3489. // initial run
  3490. if (cb) {
  3491. if (immediate) {
  3492. watcher.run();
  3493. }
  3494. else {
  3495. oldValue = watcher.get();
  3496. }
  3497. }
  3498. else if (flush === 'post' && instance) {
  3499. instance.$once('hook:mounted', () => watcher.get());
  3500. }
  3501. else {
  3502. watcher.get();
  3503. }
  3504. return () => {
  3505. watcher.teardown();
  3506. };
  3507. }
  3508. function provide(key, value) {
  3509. if (!currentInstance) {
  3510. {
  3511. warn$2(`provide() can only be used inside setup().`);
  3512. }
  3513. }
  3514. else {
  3515. // TS doesn't allow symbol as index type
  3516. resolveProvided(currentInstance)[key] = value;
  3517. }
  3518. }
  3519. function resolveProvided(vm) {
  3520. // by default an instance inherits its parent's provides object
  3521. // but when it needs to provide values of its own, it creates its
  3522. // own provides object using parent provides object as prototype.
  3523. // this way in `inject` we can simply look up injections from direct
  3524. // parent and let the prototype chain do the work.
  3525. const existing = vm._provided;
  3526. const parentProvides = vm.$parent && vm.$parent._provided;
  3527. if (parentProvides === existing) {
  3528. return (vm._provided = Object.create(parentProvides));
  3529. }
  3530. else {
  3531. return existing;
  3532. }
  3533. }
  3534. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3535. // fallback to `currentRenderingInstance` so that this can be called in
  3536. // a functional component
  3537. const instance = currentInstance;
  3538. if (instance) {
  3539. // #2400
  3540. // to support `app.use` plugins,
  3541. // fallback to appContext's `provides` if the instance is at root
  3542. const provides = instance.$parent && instance.$parent._provided;
  3543. if (provides && key in provides) {
  3544. // TS doesn't allow symbol as index type
  3545. return provides[key];
  3546. }
  3547. else if (arguments.length > 1) {
  3548. return treatDefaultAsFactory && isFunction(defaultValue)
  3549. ? defaultValue.call(instance)
  3550. : defaultValue;
  3551. }
  3552. else {
  3553. warn$2(`injection "${String(key)}" not found.`);
  3554. }
  3555. }
  3556. else {
  3557. warn$2(`inject() can only be used inside setup() or functional components.`);
  3558. }
  3559. }
  3560. /**
  3561. * @internal this function needs manual public type declaration because it relies
  3562. * on previously manually authored types from Vue 2
  3563. */
  3564. function h(type, props, children) {
  3565. if (!currentInstance) {
  3566. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3567. `component instance, e.g. synchronously in a component's render or setup function.`);
  3568. }
  3569. return createElement$1(currentInstance, type, props, children, 2, true);
  3570. }
  3571. function handleError(err, vm, info) {
  3572. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3573. // See: https://github.com/vuejs/vuex/issues/1505
  3574. pushTarget();
  3575. try {
  3576. if (vm) {
  3577. let cur = vm;
  3578. while ((cur = cur.$parent)) {
  3579. const hooks = cur.$options.errorCaptured;
  3580. if (hooks) {
  3581. for (let i = 0; i < hooks.length; i++) {
  3582. try {
  3583. const capture = hooks[i].call(cur, err, vm, info) === false;
  3584. if (capture)
  3585. return;
  3586. }
  3587. catch (e) {
  3588. globalHandleError(e, cur, 'errorCaptured hook');
  3589. }
  3590. }
  3591. }
  3592. }
  3593. }
  3594. globalHandleError(err, vm, info);
  3595. }
  3596. finally {
  3597. popTarget();
  3598. }
  3599. }
  3600. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3601. let res;
  3602. try {
  3603. res = args ? handler.apply(context, args) : handler.call(context);
  3604. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3605. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3606. res._handled = true;
  3607. }
  3608. }
  3609. catch (e) {
  3610. handleError(e, vm, info);
  3611. }
  3612. return res;
  3613. }
  3614. function globalHandleError(err, vm, info) {
  3615. if (config.errorHandler) {
  3616. try {
  3617. return config.errorHandler.call(null, err, vm, info);
  3618. }
  3619. catch (e) {
  3620. // if the user intentionally throws the original error in the handler,
  3621. // do not log it twice
  3622. if (e !== err) {
  3623. logError(e, null, 'config.errorHandler');
  3624. }
  3625. }
  3626. }
  3627. logError(err, vm, info);
  3628. }
  3629. function logError(err, vm, info) {
  3630. {
  3631. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3632. }
  3633. /* istanbul ignore else */
  3634. if (inBrowser && typeof console !== 'undefined') {
  3635. console.error(err);
  3636. }
  3637. else {
  3638. throw err;
  3639. }
  3640. }
  3641. /* globals MutationObserver */
  3642. let isUsingMicroTask = false;
  3643. const callbacks = [];
  3644. let pending = false;
  3645. function flushCallbacks() {
  3646. pending = false;
  3647. const copies = callbacks.slice(0);
  3648. callbacks.length = 0;
  3649. for (let i = 0; i < copies.length; i++) {
  3650. copies[i]();
  3651. }
  3652. }
  3653. // Here we have async deferring wrappers using microtasks.
  3654. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3655. // However, it has subtle problems when state is changed right before repaint
  3656. // (e.g. #6813, out-in transitions).
  3657. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3658. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3659. // So we now use microtasks everywhere, again.
  3660. // A major drawback of this tradeoff is that there are some scenarios
  3661. // where microtasks have too high a priority and fire in between supposedly
  3662. // sequential events (e.g. #4521, #6690, which have workarounds)
  3663. // or even between bubbling of the same event (#6566).
  3664. let timerFunc;
  3665. // The nextTick behavior leverages the microtask queue, which can be accessed
  3666. // via either native Promise.then or MutationObserver.
  3667. // MutationObserver has wider support, however it is seriously bugged in
  3668. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3669. // completely stops working after triggering a few times... so, if native
  3670. // Promise is available, we will use it:
  3671. /* istanbul ignore next, $flow-disable-line */
  3672. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3673. const p = Promise.resolve();
  3674. timerFunc = () => {
  3675. p.then(flushCallbacks);
  3676. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3677. // it can get stuck in a weird state where callbacks are pushed into the
  3678. // microtask queue but the queue isn't being flushed, until the browser
  3679. // needs to do some other work, e.g. handle a timer. Therefore we can
  3680. // "force" the microtask queue to be flushed by adding an empty timer.
  3681. if (isIOS)
  3682. setTimeout(noop);
  3683. };
  3684. isUsingMicroTask = true;
  3685. }
  3686. else if (!isIE &&
  3687. typeof MutationObserver !== 'undefined' &&
  3688. (isNative(MutationObserver) ||
  3689. // PhantomJS and iOS 7.x
  3690. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3691. // Use MutationObserver where native Promise is not available,
  3692. // e.g. PhantomJS, iOS7, Android 4.4
  3693. // (#6466 MutationObserver is unreliable in IE11)
  3694. let counter = 1;
  3695. const observer = new MutationObserver(flushCallbacks);
  3696. const textNode = document.createTextNode(String(counter));
  3697. observer.observe(textNode, {
  3698. characterData: true
  3699. });
  3700. timerFunc = () => {
  3701. counter = (counter + 1) % 2;
  3702. textNode.data = String(counter);
  3703. };
  3704. isUsingMicroTask = true;
  3705. }
  3706. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3707. // Fallback to setImmediate.
  3708. // Technically it leverages the (macro) task queue,
  3709. // but it is still a better choice than setTimeout.
  3710. timerFunc = () => {
  3711. setImmediate(flushCallbacks);
  3712. };
  3713. }
  3714. else {
  3715. // Fallback to setTimeout.
  3716. timerFunc = () => {
  3717. setTimeout(flushCallbacks, 0);
  3718. };
  3719. }
  3720. /**
  3721. * @internal
  3722. */
  3723. function nextTick(cb, ctx) {
  3724. let _resolve;
  3725. callbacks.push(() => {
  3726. if (cb) {
  3727. try {
  3728. cb.call(ctx);
  3729. }
  3730. catch (e) {
  3731. handleError(e, ctx, 'nextTick');
  3732. }
  3733. }
  3734. else if (_resolve) {
  3735. _resolve(ctx);
  3736. }
  3737. });
  3738. if (!pending) {
  3739. pending = true;
  3740. timerFunc();
  3741. }
  3742. // $flow-disable-line
  3743. if (!cb && typeof Promise !== 'undefined') {
  3744. return new Promise(resolve => {
  3745. _resolve = resolve;
  3746. });
  3747. }
  3748. }
  3749. function useCssModule(name = '$style') {
  3750. /* istanbul ignore else */
  3751. {
  3752. {
  3753. warn$2(`useCssModule() is not supported in the global build.`);
  3754. }
  3755. return emptyObject;
  3756. }
  3757. }
  3758. /**
  3759. * Runtime helper for SFC's CSS variable injection feature.
  3760. * @private
  3761. */
  3762. function useCssVars(getter) {
  3763. if (!inBrowser && !false)
  3764. return;
  3765. const instance = currentInstance;
  3766. if (!instance) {
  3767. warn$2(`useCssVars is called without current active component instance.`);
  3768. return;
  3769. }
  3770. watchPostEffect(() => {
  3771. const el = instance.$el;
  3772. const vars = getter(instance, instance._setupProxy);
  3773. if (el && el.nodeType === 1) {
  3774. const style = el.style;
  3775. for (const key in vars) {
  3776. style.setProperty(`--${key}`, vars[key]);
  3777. }
  3778. }
  3779. });
  3780. }
  3781. /**
  3782. * v3-compatible async component API.
  3783. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3784. * because it relies on existing manual types
  3785. */
  3786. function defineAsyncComponent(source) {
  3787. if (isFunction(source)) {
  3788. source = { loader: source };
  3789. }
  3790. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3791. suspensible = false, // in Vue 3 default is true
  3792. onError: userOnError } = source;
  3793. if (suspensible) {
  3794. warn$2(`The suspensible option for async components is not supported in Vue2. It is ignored.`);
  3795. }
  3796. let pendingRequest = null;
  3797. let retries = 0;
  3798. const retry = () => {
  3799. retries++;
  3800. pendingRequest = null;
  3801. return load();
  3802. };
  3803. const load = () => {
  3804. let thisRequest;
  3805. return (pendingRequest ||
  3806. (thisRequest = pendingRequest =
  3807. loader()
  3808. .catch(err => {
  3809. err = err instanceof Error ? err : new Error(String(err));
  3810. if (userOnError) {
  3811. return new Promise((resolve, reject) => {
  3812. const userRetry = () => resolve(retry());
  3813. const userFail = () => reject(err);
  3814. userOnError(err, userRetry, userFail, retries + 1);
  3815. });
  3816. }
  3817. else {
  3818. throw err;
  3819. }
  3820. })
  3821. .then((comp) => {
  3822. if (thisRequest !== pendingRequest && pendingRequest) {
  3823. return pendingRequest;
  3824. }
  3825. if (!comp) {
  3826. warn$2(`Async component loader resolved to undefined. ` +
  3827. `If you are using retry(), make sure to return its return value.`);
  3828. }
  3829. // interop module default
  3830. if (comp &&
  3831. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3832. comp = comp.default;
  3833. }
  3834. if (comp && !isObject(comp) && !isFunction(comp)) {
  3835. throw new Error(`Invalid async component load result: ${comp}`);
  3836. }
  3837. return comp;
  3838. })));
  3839. };
  3840. return () => {
  3841. const component = load();
  3842. return {
  3843. component,
  3844. delay,
  3845. timeout,
  3846. error: errorComponent,
  3847. loading: loadingComponent
  3848. };
  3849. };
  3850. }
  3851. function createLifeCycle(hookName) {
  3852. return (fn, target = currentInstance) => {
  3853. if (!target) {
  3854. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3855. `associated with. ` +
  3856. `Lifecycle injection APIs can only be used during execution of setup().`);
  3857. return;
  3858. }
  3859. return injectHook(target, hookName, fn);
  3860. };
  3861. }
  3862. function formatName(name) {
  3863. if (name === 'beforeDestroy') {
  3864. name = 'beforeUnmount';
  3865. }
  3866. else if (name === 'destroyed') {
  3867. name = 'unmounted';
  3868. }
  3869. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3870. }
  3871. function injectHook(instance, hookName, fn) {
  3872. const options = instance.$options;
  3873. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3874. }
  3875. const onBeforeMount = createLifeCycle('beforeMount');
  3876. const onMounted = createLifeCycle('mounted');
  3877. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3878. const onUpdated = createLifeCycle('updated');
  3879. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3880. const onUnmounted = createLifeCycle('destroyed');
  3881. const onActivated = createLifeCycle('activated');
  3882. const onDeactivated = createLifeCycle('deactivated');
  3883. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3884. const onRenderTracked = createLifeCycle('renderTracked');
  3885. const onRenderTriggered = createLifeCycle('renderTriggered');
  3886. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3887. function onErrorCaptured(hook, target = currentInstance) {
  3888. injectErrorCapturedHook(hook, target);
  3889. }
  3890. /**
  3891. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3892. */
  3893. const version = '2.7.16';
  3894. /**
  3895. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3896. */
  3897. function defineComponent(options) {
  3898. return options;
  3899. }
  3900. const seenObjects = new _Set();
  3901. /**
  3902. * Recursively traverse an object to evoke all converted
  3903. * getters, so that every nested property inside the object
  3904. * is collected as a "deep" dependency.
  3905. */
  3906. function traverse(val) {
  3907. _traverse(val, seenObjects);
  3908. seenObjects.clear();
  3909. return val;
  3910. }
  3911. function _traverse(val, seen) {
  3912. let i, keys;
  3913. const isA = isArray(val);
  3914. if ((!isA && !isObject(val)) ||
  3915. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3916. Object.isFrozen(val) ||
  3917. val instanceof VNode) {
  3918. return;
  3919. }
  3920. if (val.__ob__) {
  3921. const depId = val.__ob__.dep.id;
  3922. if (seen.has(depId)) {
  3923. return;
  3924. }
  3925. seen.add(depId);
  3926. }
  3927. if (isA) {
  3928. i = val.length;
  3929. while (i--)
  3930. _traverse(val[i], seen);
  3931. }
  3932. else if (isRef(val)) {
  3933. _traverse(val.value, seen);
  3934. }
  3935. else {
  3936. keys = Object.keys(val);
  3937. i = keys.length;
  3938. while (i--)
  3939. _traverse(val[keys[i]], seen);
  3940. }
  3941. }
  3942. let uid$1 = 0;
  3943. /**
  3944. * A watcher parses an expression, collects dependencies,
  3945. * and fires callback when the expression value changes.
  3946. * This is used for both the $watch() api and directives.
  3947. * @internal
  3948. */
  3949. class Watcher {
  3950. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3951. recordEffectScope(this,
  3952. // if the active effect scope is manually created (not a component scope),
  3953. // prioritize it
  3954. activeEffectScope && !activeEffectScope._vm
  3955. ? activeEffectScope
  3956. : vm
  3957. ? vm._scope
  3958. : undefined);
  3959. if ((this.vm = vm) && isRenderWatcher) {
  3960. vm._watcher = this;
  3961. }
  3962. // options
  3963. if (options) {
  3964. this.deep = !!options.deep;
  3965. this.user = !!options.user;
  3966. this.lazy = !!options.lazy;
  3967. this.sync = !!options.sync;
  3968. this.before = options.before;
  3969. {
  3970. this.onTrack = options.onTrack;
  3971. this.onTrigger = options.onTrigger;
  3972. }
  3973. }
  3974. else {
  3975. this.deep = this.user = this.lazy = this.sync = false;
  3976. }
  3977. this.cb = cb;
  3978. this.id = ++uid$1; // uid for batching
  3979. this.active = true;
  3980. this.post = false;
  3981. this.dirty = this.lazy; // for lazy watchers
  3982. this.deps = [];
  3983. this.newDeps = [];
  3984. this.depIds = new _Set();
  3985. this.newDepIds = new _Set();
  3986. this.expression = expOrFn.toString() ;
  3987. // parse expression for getter
  3988. if (isFunction(expOrFn)) {
  3989. this.getter = expOrFn;
  3990. }
  3991. else {
  3992. this.getter = parsePath(expOrFn);
  3993. if (!this.getter) {
  3994. this.getter = noop;
  3995. warn$2(`Failed watching path: "${expOrFn}" ` +
  3996. 'Watcher only accepts simple dot-delimited paths. ' +
  3997. 'For full control, use a function instead.', vm);
  3998. }
  3999. }
  4000. this.value = this.lazy ? undefined : this.get();
  4001. }
  4002. /**
  4003. * Evaluate the getter, and re-collect dependencies.
  4004. */
  4005. get() {
  4006. pushTarget(this);
  4007. let value;
  4008. const vm = this.vm;
  4009. try {
  4010. value = this.getter.call(vm, vm);
  4011. }
  4012. catch (e) {
  4013. if (this.user) {
  4014. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4015. }
  4016. else {
  4017. throw e;
  4018. }
  4019. }
  4020. finally {
  4021. // "touch" every property so they are all tracked as
  4022. // dependencies for deep watching
  4023. if (this.deep) {
  4024. traverse(value);
  4025. }
  4026. popTarget();
  4027. this.cleanupDeps();
  4028. }
  4029. return value;
  4030. }
  4031. /**
  4032. * Add a dependency to this directive.
  4033. */
  4034. addDep(dep) {
  4035. const id = dep.id;
  4036. if (!this.newDepIds.has(id)) {
  4037. this.newDepIds.add(id);
  4038. this.newDeps.push(dep);
  4039. if (!this.depIds.has(id)) {
  4040. dep.addSub(this);
  4041. }
  4042. }
  4043. }
  4044. /**
  4045. * Clean up for dependency collection.
  4046. */
  4047. cleanupDeps() {
  4048. let i = this.deps.length;
  4049. while (i--) {
  4050. const dep = this.deps[i];
  4051. if (!this.newDepIds.has(dep.id)) {
  4052. dep.removeSub(this);
  4053. }
  4054. }
  4055. let tmp = this.depIds;
  4056. this.depIds = this.newDepIds;
  4057. this.newDepIds = tmp;
  4058. this.newDepIds.clear();
  4059. tmp = this.deps;
  4060. this.deps = this.newDeps;
  4061. this.newDeps = tmp;
  4062. this.newDeps.length = 0;
  4063. }
  4064. /**
  4065. * Subscriber interface.
  4066. * Will be called when a dependency changes.
  4067. */
  4068. update() {
  4069. /* istanbul ignore else */
  4070. if (this.lazy) {
  4071. this.dirty = true;
  4072. }
  4073. else if (this.sync) {
  4074. this.run();
  4075. }
  4076. else {
  4077. queueWatcher(this);
  4078. }
  4079. }
  4080. /**
  4081. * Scheduler job interface.
  4082. * Will be called by the scheduler.
  4083. */
  4084. run() {
  4085. if (this.active) {
  4086. const value = this.get();
  4087. if (value !== this.value ||
  4088. // Deep watchers and watchers on Object/Arrays should fire even
  4089. // when the value is the same, because the value may
  4090. // have mutated.
  4091. isObject(value) ||
  4092. this.deep) {
  4093. // set new value
  4094. const oldValue = this.value;
  4095. this.value = value;
  4096. if (this.user) {
  4097. const info = `callback for watcher "${this.expression}"`;
  4098. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4099. }
  4100. else {
  4101. this.cb.call(this.vm, value, oldValue);
  4102. }
  4103. }
  4104. }
  4105. }
  4106. /**
  4107. * Evaluate the value of the watcher.
  4108. * This only gets called for lazy watchers.
  4109. */
  4110. evaluate() {
  4111. this.value = this.get();
  4112. this.dirty = false;
  4113. }
  4114. /**
  4115. * Depend on all deps collected by this watcher.
  4116. */
  4117. depend() {
  4118. let i = this.deps.length;
  4119. while (i--) {
  4120. this.deps[i].depend();
  4121. }
  4122. }
  4123. /**
  4124. * Remove self from all dependencies' subscriber list.
  4125. */
  4126. teardown() {
  4127. if (this.vm && !this.vm._isBeingDestroyed) {
  4128. remove$2(this.vm._scope.effects, this);
  4129. }
  4130. if (this.active) {
  4131. let i = this.deps.length;
  4132. while (i--) {
  4133. this.deps[i].removeSub(this);
  4134. }
  4135. this.active = false;
  4136. if (this.onStop) {
  4137. this.onStop();
  4138. }
  4139. }
  4140. }
  4141. }
  4142. const sharedPropertyDefinition = {
  4143. enumerable: true,
  4144. configurable: true,
  4145. get: noop,
  4146. set: noop
  4147. };
  4148. function proxy(target, sourceKey, key) {
  4149. sharedPropertyDefinition.get = function proxyGetter() {
  4150. return this[sourceKey][key];
  4151. };
  4152. sharedPropertyDefinition.set = function proxySetter(val) {
  4153. this[sourceKey][key] = val;
  4154. };
  4155. Object.defineProperty(target, key, sharedPropertyDefinition);
  4156. }
  4157. function initState(vm) {
  4158. const opts = vm.$options;
  4159. if (opts.props)
  4160. initProps$1(vm, opts.props);
  4161. // Composition API
  4162. initSetup(vm);
  4163. if (opts.methods)
  4164. initMethods(vm, opts.methods);
  4165. if (opts.data) {
  4166. initData(vm);
  4167. }
  4168. else {
  4169. const ob = observe((vm._data = {}));
  4170. ob && ob.vmCount++;
  4171. }
  4172. if (opts.computed)
  4173. initComputed$1(vm, opts.computed);
  4174. if (opts.watch && opts.watch !== nativeWatch) {
  4175. initWatch(vm, opts.watch);
  4176. }
  4177. }
  4178. function initProps$1(vm, propsOptions) {
  4179. const propsData = vm.$options.propsData || {};
  4180. const props = (vm._props = shallowReactive({}));
  4181. // cache prop keys so that future props updates can iterate using Array
  4182. // instead of dynamic object key enumeration.
  4183. const keys = (vm.$options._propKeys = []);
  4184. const isRoot = !vm.$parent;
  4185. // root instance props should be converted
  4186. if (!isRoot) {
  4187. toggleObserving(false);
  4188. }
  4189. for (const key in propsOptions) {
  4190. keys.push(key);
  4191. const value = validateProp(key, propsOptions, propsData, vm);
  4192. /* istanbul ignore else */
  4193. {
  4194. const hyphenatedKey = hyphenate(key);
  4195. if (isReservedAttribute(hyphenatedKey) ||
  4196. config.isReservedAttr(hyphenatedKey)) {
  4197. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4198. }
  4199. defineReactive(props, key, value, () => {
  4200. if (!isRoot && !isUpdatingChildComponent) {
  4201. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4202. `overwritten whenever the parent component re-renders. ` +
  4203. `Instead, use a data or computed property based on the prop's ` +
  4204. `value. Prop being mutated: "${key}"`, vm);
  4205. }
  4206. }, true /* shallow */);
  4207. }
  4208. // static props are already proxied on the component's prototype
  4209. // during Vue.extend(). We only need to proxy props defined at
  4210. // instantiation here.
  4211. if (!(key in vm)) {
  4212. proxy(vm, `_props`, key);
  4213. }
  4214. }
  4215. toggleObserving(true);
  4216. }
  4217. function initData(vm) {
  4218. let data = vm.$options.data;
  4219. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4220. if (!isPlainObject(data)) {
  4221. data = {};
  4222. warn$2('data functions should return an object:\n' +
  4223. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4224. }
  4225. // proxy data on instance
  4226. const keys = Object.keys(data);
  4227. const props = vm.$options.props;
  4228. const methods = vm.$options.methods;
  4229. let i = keys.length;
  4230. while (i--) {
  4231. const key = keys[i];
  4232. {
  4233. if (methods && hasOwn(methods, key)) {
  4234. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4235. }
  4236. }
  4237. if (props && hasOwn(props, key)) {
  4238. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4239. `Use prop default value instead.`, vm);
  4240. }
  4241. else if (!isReserved(key)) {
  4242. proxy(vm, `_data`, key);
  4243. }
  4244. }
  4245. // observe data
  4246. const ob = observe(data);
  4247. ob && ob.vmCount++;
  4248. }
  4249. function getData(data, vm) {
  4250. // #7573 disable dep collection when invoking data getters
  4251. pushTarget();
  4252. try {
  4253. return data.call(vm, vm);
  4254. }
  4255. catch (e) {
  4256. handleError(e, vm, `data()`);
  4257. return {};
  4258. }
  4259. finally {
  4260. popTarget();
  4261. }
  4262. }
  4263. const computedWatcherOptions = { lazy: true };
  4264. function initComputed$1(vm, computed) {
  4265. // $flow-disable-line
  4266. const watchers = (vm._computedWatchers = Object.create(null));
  4267. // computed properties are just getters during SSR
  4268. const isSSR = isServerRendering();
  4269. for (const key in computed) {
  4270. const userDef = computed[key];
  4271. const getter = isFunction(userDef) ? userDef : userDef.get;
  4272. if (getter == null) {
  4273. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4274. }
  4275. if (!isSSR) {
  4276. // create internal watcher for the computed property.
  4277. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4278. }
  4279. // component-defined computed properties are already defined on the
  4280. // component prototype. We only need to define computed properties defined
  4281. // at instantiation here.
  4282. if (!(key in vm)) {
  4283. defineComputed(vm, key, userDef);
  4284. }
  4285. else {
  4286. if (key in vm.$data) {
  4287. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4288. }
  4289. else if (vm.$options.props && key in vm.$options.props) {
  4290. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4291. }
  4292. else if (vm.$options.methods && key in vm.$options.methods) {
  4293. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4294. }
  4295. }
  4296. }
  4297. }
  4298. function defineComputed(target, key, userDef) {
  4299. const shouldCache = !isServerRendering();
  4300. if (isFunction(userDef)) {
  4301. sharedPropertyDefinition.get = shouldCache
  4302. ? createComputedGetter(key)
  4303. : createGetterInvoker(userDef);
  4304. sharedPropertyDefinition.set = noop;
  4305. }
  4306. else {
  4307. sharedPropertyDefinition.get = userDef.get
  4308. ? shouldCache && userDef.cache !== false
  4309. ? createComputedGetter(key)
  4310. : createGetterInvoker(userDef.get)
  4311. : noop;
  4312. sharedPropertyDefinition.set = userDef.set || noop;
  4313. }
  4314. if (sharedPropertyDefinition.set === noop) {
  4315. sharedPropertyDefinition.set = function () {
  4316. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4317. };
  4318. }
  4319. Object.defineProperty(target, key, sharedPropertyDefinition);
  4320. }
  4321. function createComputedGetter(key) {
  4322. return function computedGetter() {
  4323. const watcher = this._computedWatchers && this._computedWatchers[key];
  4324. if (watcher) {
  4325. if (watcher.dirty) {
  4326. watcher.evaluate();
  4327. }
  4328. if (Dep.target) {
  4329. if (Dep.target.onTrack) {
  4330. Dep.target.onTrack({
  4331. effect: Dep.target,
  4332. target: this,
  4333. type: "get" /* TrackOpTypes.GET */,
  4334. key
  4335. });
  4336. }
  4337. watcher.depend();
  4338. }
  4339. return watcher.value;
  4340. }
  4341. };
  4342. }
  4343. function createGetterInvoker(fn) {
  4344. return function computedGetter() {
  4345. return fn.call(this, this);
  4346. };
  4347. }
  4348. function initMethods(vm, methods) {
  4349. const props = vm.$options.props;
  4350. for (const key in methods) {
  4351. {
  4352. if (typeof methods[key] !== 'function') {
  4353. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4354. `Did you reference the function correctly?`, vm);
  4355. }
  4356. if (props && hasOwn(props, key)) {
  4357. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4358. }
  4359. if (key in vm && isReserved(key)) {
  4360. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4361. `Avoid defining component methods that start with _ or $.`);
  4362. }
  4363. }
  4364. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4365. }
  4366. }
  4367. function initWatch(vm, watch) {
  4368. for (const key in watch) {
  4369. const handler = watch[key];
  4370. if (isArray(handler)) {
  4371. for (let i = 0; i < handler.length; i++) {
  4372. createWatcher(vm, key, handler[i]);
  4373. }
  4374. }
  4375. else {
  4376. createWatcher(vm, key, handler);
  4377. }
  4378. }
  4379. }
  4380. function createWatcher(vm, expOrFn, handler, options) {
  4381. if (isPlainObject(handler)) {
  4382. options = handler;
  4383. handler = handler.handler;
  4384. }
  4385. if (typeof handler === 'string') {
  4386. handler = vm[handler];
  4387. }
  4388. return vm.$watch(expOrFn, handler, options);
  4389. }
  4390. function stateMixin(Vue) {
  4391. // flow somehow has problems with directly declared definition object
  4392. // when using Object.defineProperty, so we have to procedurally build up
  4393. // the object here.
  4394. const dataDef = {};
  4395. dataDef.get = function () {
  4396. return this._data;
  4397. };
  4398. const propsDef = {};
  4399. propsDef.get = function () {
  4400. return this._props;
  4401. };
  4402. {
  4403. dataDef.set = function () {
  4404. warn$2('Avoid replacing instance root $data. ' +
  4405. 'Use nested data properties instead.', this);
  4406. };
  4407. propsDef.set = function () {
  4408. warn$2(`$props is readonly.`, this);
  4409. };
  4410. }
  4411. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4412. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4413. Vue.prototype.$set = set;
  4414. Vue.prototype.$delete = del;
  4415. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4416. const vm = this;
  4417. if (isPlainObject(cb)) {
  4418. return createWatcher(vm, expOrFn, cb, options);
  4419. }
  4420. options = options || {};
  4421. options.user = true;
  4422. const watcher = new Watcher(vm, expOrFn, cb, options);
  4423. if (options.immediate) {
  4424. const info = `callback for immediate watcher "${watcher.expression}"`;
  4425. pushTarget();
  4426. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4427. popTarget();
  4428. }
  4429. return function unwatchFn() {
  4430. watcher.teardown();
  4431. };
  4432. };
  4433. }
  4434. function initProvide(vm) {
  4435. const provideOption = vm.$options.provide;
  4436. if (provideOption) {
  4437. const provided = isFunction(provideOption)
  4438. ? provideOption.call(vm)
  4439. : provideOption;
  4440. if (!isObject(provided)) {
  4441. return;
  4442. }
  4443. const source = resolveProvided(vm);
  4444. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4445. // iterate the keys ourselves.
  4446. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4447. for (let i = 0; i < keys.length; i++) {
  4448. const key = keys[i];
  4449. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4450. }
  4451. }
  4452. }
  4453. function initInjections(vm) {
  4454. const result = resolveInject(vm.$options.inject, vm);
  4455. if (result) {
  4456. toggleObserving(false);
  4457. Object.keys(result).forEach(key => {
  4458. /* istanbul ignore else */
  4459. {
  4460. defineReactive(vm, key, result[key], () => {
  4461. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4462. `overwritten whenever the provided component re-renders. ` +
  4463. `injection being mutated: "${key}"`, vm);
  4464. });
  4465. }
  4466. });
  4467. toggleObserving(true);
  4468. }
  4469. }
  4470. function resolveInject(inject, vm) {
  4471. if (inject) {
  4472. // inject is :any because flow is not smart enough to figure out cached
  4473. const result = Object.create(null);
  4474. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4475. for (let i = 0; i < keys.length; i++) {
  4476. const key = keys[i];
  4477. // #6574 in case the inject object is observed...
  4478. if (key === '__ob__')
  4479. continue;
  4480. const provideKey = inject[key].from;
  4481. if (provideKey in vm._provided) {
  4482. result[key] = vm._provided[provideKey];
  4483. }
  4484. else if ('default' in inject[key]) {
  4485. const provideDefault = inject[key].default;
  4486. result[key] = isFunction(provideDefault)
  4487. ? provideDefault.call(vm)
  4488. : provideDefault;
  4489. }
  4490. else {
  4491. warn$2(`Injection "${key}" not found`, vm);
  4492. }
  4493. }
  4494. return result;
  4495. }
  4496. }
  4497. let uid = 0;
  4498. function initMixin$1(Vue) {
  4499. Vue.prototype._init = function (options) {
  4500. const vm = this;
  4501. // a uid
  4502. vm._uid = uid++;
  4503. let startTag, endTag;
  4504. /* istanbul ignore if */
  4505. if (config.performance && mark) {
  4506. startTag = `vue-perf-start:${vm._uid}`;
  4507. endTag = `vue-perf-end:${vm._uid}`;
  4508. mark(startTag);
  4509. }
  4510. // a flag to mark this as a Vue instance without having to do instanceof
  4511. // check
  4512. vm._isVue = true;
  4513. // avoid instances from being observed
  4514. vm.__v_skip = true;
  4515. // effect scope
  4516. vm._scope = new EffectScope(true /* detached */);
  4517. // #13134 edge case where a child component is manually created during the
  4518. // render of a parent component
  4519. vm._scope.parent = undefined;
  4520. vm._scope._vm = true;
  4521. // merge options
  4522. if (options && options._isComponent) {
  4523. // optimize internal component instantiation
  4524. // since dynamic options merging is pretty slow, and none of the
  4525. // internal component options needs special treatment.
  4526. initInternalComponent(vm, options);
  4527. }
  4528. else {
  4529. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4530. }
  4531. /* istanbul ignore else */
  4532. {
  4533. initProxy(vm);
  4534. }
  4535. // expose real self
  4536. vm._self = vm;
  4537. initLifecycle(vm);
  4538. initEvents(vm);
  4539. initRender(vm);
  4540. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4541. initInjections(vm); // resolve injections before data/props
  4542. initState(vm);
  4543. initProvide(vm); // resolve provide after data/props
  4544. callHook$1(vm, 'created');
  4545. /* istanbul ignore if */
  4546. if (config.performance && mark) {
  4547. vm._name = formatComponentName(vm, false);
  4548. mark(endTag);
  4549. measure(`vue ${vm._name} init`, startTag, endTag);
  4550. }
  4551. if (vm.$options.el) {
  4552. vm.$mount(vm.$options.el);
  4553. }
  4554. };
  4555. }
  4556. function initInternalComponent(vm, options) {
  4557. const opts = (vm.$options = Object.create(vm.constructor.options));
  4558. // doing this because it's faster than dynamic enumeration.
  4559. const parentVnode = options._parentVnode;
  4560. opts.parent = options.parent;
  4561. opts._parentVnode = parentVnode;
  4562. const vnodeComponentOptions = parentVnode.componentOptions;
  4563. opts.propsData = vnodeComponentOptions.propsData;
  4564. opts._parentListeners = vnodeComponentOptions.listeners;
  4565. opts._renderChildren = vnodeComponentOptions.children;
  4566. opts._componentTag = vnodeComponentOptions.tag;
  4567. if (options.render) {
  4568. opts.render = options.render;
  4569. opts.staticRenderFns = options.staticRenderFns;
  4570. }
  4571. }
  4572. function resolveConstructorOptions(Ctor) {
  4573. let options = Ctor.options;
  4574. if (Ctor.super) {
  4575. const superOptions = resolveConstructorOptions(Ctor.super);
  4576. const cachedSuperOptions = Ctor.superOptions;
  4577. if (superOptions !== cachedSuperOptions) {
  4578. // super option changed,
  4579. // need to resolve new options.
  4580. Ctor.superOptions = superOptions;
  4581. // check if there are any late-modified/attached options (#4976)
  4582. const modifiedOptions = resolveModifiedOptions(Ctor);
  4583. // update base extend options
  4584. if (modifiedOptions) {
  4585. extend(Ctor.extendOptions, modifiedOptions);
  4586. }
  4587. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4588. if (options.name) {
  4589. options.components[options.name] = Ctor;
  4590. }
  4591. }
  4592. }
  4593. return options;
  4594. }
  4595. function resolveModifiedOptions(Ctor) {
  4596. let modified;
  4597. const latest = Ctor.options;
  4598. const sealed = Ctor.sealedOptions;
  4599. for (const key in latest) {
  4600. if (latest[key] !== sealed[key]) {
  4601. if (!modified)
  4602. modified = {};
  4603. modified[key] = latest[key];
  4604. }
  4605. }
  4606. return modified;
  4607. }
  4608. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4609. const options = Ctor.options;
  4610. // ensure the createElement function in functional components
  4611. // gets a unique context - this is necessary for correct named slot check
  4612. let contextVm;
  4613. if (hasOwn(parent, '_uid')) {
  4614. contextVm = Object.create(parent);
  4615. contextVm._original = parent;
  4616. }
  4617. else {
  4618. // the context vm passed in is a functional context as well.
  4619. // in this case we want to make sure we are able to get a hold to the
  4620. // real context instance.
  4621. contextVm = parent;
  4622. // @ts-ignore
  4623. parent = parent._original;
  4624. }
  4625. const isCompiled = isTrue(options._compiled);
  4626. const needNormalization = !isCompiled;
  4627. this.data = data;
  4628. this.props = props;
  4629. this.children = children;
  4630. this.parent = parent;
  4631. this.listeners = data.on || emptyObject;
  4632. this.injections = resolveInject(options.inject, parent);
  4633. this.slots = () => {
  4634. if (!this.$slots) {
  4635. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4636. }
  4637. return this.$slots;
  4638. };
  4639. Object.defineProperty(this, 'scopedSlots', {
  4640. enumerable: true,
  4641. get() {
  4642. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4643. }
  4644. });
  4645. // support for compiled functional template
  4646. if (isCompiled) {
  4647. // exposing $options for renderStatic()
  4648. this.$options = options;
  4649. // pre-resolve slots for renderSlot()
  4650. this.$slots = this.slots();
  4651. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4652. }
  4653. if (options._scopeId) {
  4654. this._c = (a, b, c, d) => {
  4655. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4656. if (vnode && !isArray(vnode)) {
  4657. vnode.fnScopeId = options._scopeId;
  4658. vnode.fnContext = parent;
  4659. }
  4660. return vnode;
  4661. };
  4662. }
  4663. else {
  4664. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4665. }
  4666. }
  4667. installRenderHelpers(FunctionalRenderContext.prototype);
  4668. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4669. const options = Ctor.options;
  4670. const props = {};
  4671. const propOptions = options.props;
  4672. if (isDef(propOptions)) {
  4673. for (const key in propOptions) {
  4674. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4675. }
  4676. }
  4677. else {
  4678. if (isDef(data.attrs))
  4679. mergeProps(props, data.attrs);
  4680. if (isDef(data.props))
  4681. mergeProps(props, data.props);
  4682. }
  4683. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4684. const vnode = options.render.call(null, renderContext._c, renderContext);
  4685. if (vnode instanceof VNode) {
  4686. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4687. }
  4688. else if (isArray(vnode)) {
  4689. const vnodes = normalizeChildren(vnode) || [];
  4690. const res = new Array(vnodes.length);
  4691. for (let i = 0; i < vnodes.length; i++) {
  4692. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4693. }
  4694. return res;
  4695. }
  4696. }
  4697. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4698. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4699. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4700. // that should not be matched to match.
  4701. const clone = cloneVNode(vnode);
  4702. clone.fnContext = contextVm;
  4703. clone.fnOptions = options;
  4704. {
  4705. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4706. renderContext;
  4707. }
  4708. if (data.slot) {
  4709. (clone.data || (clone.data = {})).slot = data.slot;
  4710. }
  4711. return clone;
  4712. }
  4713. function mergeProps(to, from) {
  4714. for (const key in from) {
  4715. to[camelize(key)] = from[key];
  4716. }
  4717. }
  4718. function getComponentName(options) {
  4719. return options.name || options.__name || options._componentTag;
  4720. }
  4721. // inline hooks to be invoked on component VNodes during patch
  4722. const componentVNodeHooks = {
  4723. init(vnode, hydrating) {
  4724. if (vnode.componentInstance &&
  4725. !vnode.componentInstance._isDestroyed &&
  4726. vnode.data.keepAlive) {
  4727. // kept-alive components, treat as a patch
  4728. const mountedNode = vnode; // work around flow
  4729. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4730. }
  4731. else {
  4732. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4733. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4734. }
  4735. },
  4736. prepatch(oldVnode, vnode) {
  4737. const options = vnode.componentOptions;
  4738. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4739. updateChildComponent(child, options.propsData, // updated props
  4740. options.listeners, // updated listeners
  4741. vnode, // new parent vnode
  4742. options.children // new children
  4743. );
  4744. },
  4745. insert(vnode) {
  4746. const { context, componentInstance } = vnode;
  4747. if (!componentInstance._isMounted) {
  4748. componentInstance._isMounted = true;
  4749. callHook$1(componentInstance, 'mounted');
  4750. }
  4751. if (vnode.data.keepAlive) {
  4752. if (context._isMounted) {
  4753. // vue-router#1212
  4754. // During updates, a kept-alive component's child components may
  4755. // change, so directly walking the tree here may call activated hooks
  4756. // on incorrect children. Instead we push them into a queue which will
  4757. // be processed after the whole patch process ended.
  4758. queueActivatedComponent(componentInstance);
  4759. }
  4760. else {
  4761. activateChildComponent(componentInstance, true /* direct */);
  4762. }
  4763. }
  4764. },
  4765. destroy(vnode) {
  4766. const { componentInstance } = vnode;
  4767. if (!componentInstance._isDestroyed) {
  4768. if (!vnode.data.keepAlive) {
  4769. componentInstance.$destroy();
  4770. }
  4771. else {
  4772. deactivateChildComponent(componentInstance, true /* direct */);
  4773. }
  4774. }
  4775. }
  4776. };
  4777. const hooksToMerge = Object.keys(componentVNodeHooks);
  4778. function createComponent(Ctor, data, context, children, tag) {
  4779. if (isUndef(Ctor)) {
  4780. return;
  4781. }
  4782. const baseCtor = context.$options._base;
  4783. // plain options object: turn it into a constructor
  4784. if (isObject(Ctor)) {
  4785. Ctor = baseCtor.extend(Ctor);
  4786. }
  4787. // if at this stage it's not a constructor or an async component factory,
  4788. // reject.
  4789. if (typeof Ctor !== 'function') {
  4790. {
  4791. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4792. }
  4793. return;
  4794. }
  4795. // async component
  4796. let asyncFactory;
  4797. // @ts-expect-error
  4798. if (isUndef(Ctor.cid)) {
  4799. asyncFactory = Ctor;
  4800. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4801. if (Ctor === undefined) {
  4802. // return a placeholder node for async component, which is rendered
  4803. // as a comment node but preserves all the raw information for the node.
  4804. // the information will be used for async server-rendering and hydration.
  4805. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4806. }
  4807. }
  4808. data = data || {};
  4809. // resolve constructor options in case global mixins are applied after
  4810. // component constructor creation
  4811. resolveConstructorOptions(Ctor);
  4812. // transform component v-model data into props & events
  4813. if (isDef(data.model)) {
  4814. // @ts-expect-error
  4815. transformModel(Ctor.options, data);
  4816. }
  4817. // extract props
  4818. // @ts-expect-error
  4819. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4820. // functional component
  4821. // @ts-expect-error
  4822. if (isTrue(Ctor.options.functional)) {
  4823. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4824. }
  4825. // extract listeners, since these needs to be treated as
  4826. // child component listeners instead of DOM listeners
  4827. const listeners = data.on;
  4828. // replace with listeners with .native modifier
  4829. // so it gets processed during parent component patch.
  4830. data.on = data.nativeOn;
  4831. // @ts-expect-error
  4832. if (isTrue(Ctor.options.abstract)) {
  4833. // abstract components do not keep anything
  4834. // other than props & listeners & slot
  4835. // work around flow
  4836. const slot = data.slot;
  4837. data = {};
  4838. if (slot) {
  4839. data.slot = slot;
  4840. }
  4841. }
  4842. // install component management hooks onto the placeholder node
  4843. installComponentHooks(data);
  4844. // return a placeholder vnode
  4845. // @ts-expect-error
  4846. const name = getComponentName(Ctor.options) || tag;
  4847. const vnode = new VNode(
  4848. // @ts-expect-error
  4849. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4850. // @ts-expect-error
  4851. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4852. return vnode;
  4853. }
  4854. function createComponentInstanceForVnode(
  4855. // we know it's MountedComponentVNode but flow doesn't
  4856. vnode,
  4857. // activeInstance in lifecycle state
  4858. parent) {
  4859. const options = {
  4860. _isComponent: true,
  4861. _parentVnode: vnode,
  4862. parent
  4863. };
  4864. // check inline-template render functions
  4865. const inlineTemplate = vnode.data.inlineTemplate;
  4866. if (isDef(inlineTemplate)) {
  4867. options.render = inlineTemplate.render;
  4868. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4869. }
  4870. return new vnode.componentOptions.Ctor(options);
  4871. }
  4872. function installComponentHooks(data) {
  4873. const hooks = data.hook || (data.hook = {});
  4874. for (let i = 0; i < hooksToMerge.length; i++) {
  4875. const key = hooksToMerge[i];
  4876. const existing = hooks[key];
  4877. const toMerge = componentVNodeHooks[key];
  4878. // @ts-expect-error
  4879. if (existing !== toMerge && !(existing && existing._merged)) {
  4880. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4881. }
  4882. }
  4883. }
  4884. function mergeHook(f1, f2) {
  4885. const merged = (a, b) => {
  4886. // flow complains about extra args which is why we use any
  4887. f1(a, b);
  4888. f2(a, b);
  4889. };
  4890. merged._merged = true;
  4891. return merged;
  4892. }
  4893. // transform component v-model info (value and callback) into
  4894. // prop and event handler respectively.
  4895. function transformModel(options, data) {
  4896. const prop = (options.model && options.model.prop) || 'value';
  4897. const event = (options.model && options.model.event) || 'input';
  4898. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4899. const on = data.on || (data.on = {});
  4900. const existing = on[event];
  4901. const callback = data.model.callback;
  4902. if (isDef(existing)) {
  4903. if (isArray(existing)
  4904. ? existing.indexOf(callback) === -1
  4905. : existing !== callback) {
  4906. on[event] = [callback].concat(existing);
  4907. }
  4908. }
  4909. else {
  4910. on[event] = callback;
  4911. }
  4912. }
  4913. let warn$2 = noop;
  4914. let tip = noop;
  4915. let generateComponentTrace; // work around flow check
  4916. let formatComponentName;
  4917. {
  4918. const hasConsole = typeof console !== 'undefined';
  4919. const classifyRE = /(?:^|[-_])(\w)/g;
  4920. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4921. warn$2 = (msg, vm = currentInstance) => {
  4922. const trace = vm ? generateComponentTrace(vm) : '';
  4923. if (config.warnHandler) {
  4924. config.warnHandler.call(null, msg, vm, trace);
  4925. }
  4926. else if (hasConsole && !config.silent) {
  4927. console.error(`[Vue warn]: ${msg}${trace}`);
  4928. }
  4929. };
  4930. tip = (msg, vm) => {
  4931. if (hasConsole && !config.silent) {
  4932. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4933. }
  4934. };
  4935. formatComponentName = (vm, includeFile) => {
  4936. if (vm.$root === vm) {
  4937. return '<Root>';
  4938. }
  4939. const options = isFunction(vm) && vm.cid != null
  4940. ? vm.options
  4941. : vm._isVue
  4942. ? vm.$options || vm.constructor.options
  4943. : vm;
  4944. let name = getComponentName(options);
  4945. const file = options.__file;
  4946. if (!name && file) {
  4947. const match = file.match(/([^/\\]+)\.vue$/);
  4948. name = match && match[1];
  4949. }
  4950. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4951. (file && includeFile !== false ? ` at ${file}` : ''));
  4952. };
  4953. const repeat = (str, n) => {
  4954. let res = '';
  4955. while (n) {
  4956. if (n % 2 === 1)
  4957. res += str;
  4958. if (n > 1)
  4959. str += str;
  4960. n >>= 1;
  4961. }
  4962. return res;
  4963. };
  4964. generateComponentTrace = (vm) => {
  4965. if (vm._isVue && vm.$parent) {
  4966. const tree = [];
  4967. let currentRecursiveSequence = 0;
  4968. while (vm) {
  4969. if (tree.length > 0) {
  4970. const last = tree[tree.length - 1];
  4971. if (last.constructor === vm.constructor) {
  4972. currentRecursiveSequence++;
  4973. vm = vm.$parent;
  4974. continue;
  4975. }
  4976. else if (currentRecursiveSequence > 0) {
  4977. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4978. currentRecursiveSequence = 0;
  4979. }
  4980. }
  4981. tree.push(vm);
  4982. vm = vm.$parent;
  4983. }
  4984. return ('\n\nfound in\n\n' +
  4985. tree
  4986. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4987. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4988. : formatComponentName(vm)}`)
  4989. .join('\n'));
  4990. }
  4991. else {
  4992. return `\n\n(found in ${formatComponentName(vm)})`;
  4993. }
  4994. };
  4995. }
  4996. /**
  4997. * Option overwriting strategies are functions that handle
  4998. * how to merge a parent option value and a child option
  4999. * value into the final value.
  5000. */
  5001. const strats = config.optionMergeStrategies;
  5002. /**
  5003. * Options with restrictions
  5004. */
  5005. {
  5006. strats.el = strats.propsData = function (parent, child, vm, key) {
  5007. if (!vm) {
  5008. warn$2(`option "${key}" can only be used during instance ` +
  5009. 'creation with the `new` keyword.');
  5010. }
  5011. return defaultStrat(parent, child);
  5012. };
  5013. }
  5014. /**
  5015. * Helper that recursively merges two data objects together.
  5016. */
  5017. function mergeData(to, from, recursive = true) {
  5018. if (!from)
  5019. return to;
  5020. let key, toVal, fromVal;
  5021. const keys = hasSymbol
  5022. ? Reflect.ownKeys(from)
  5023. : Object.keys(from);
  5024. for (let i = 0; i < keys.length; i++) {
  5025. key = keys[i];
  5026. // in case the object is already observed...
  5027. if (key === '__ob__')
  5028. continue;
  5029. toVal = to[key];
  5030. fromVal = from[key];
  5031. if (!recursive || !hasOwn(to, key)) {
  5032. set(to, key, fromVal);
  5033. }
  5034. else if (toVal !== fromVal &&
  5035. isPlainObject(toVal) &&
  5036. isPlainObject(fromVal)) {
  5037. mergeData(toVal, fromVal);
  5038. }
  5039. }
  5040. return to;
  5041. }
  5042. /**
  5043. * Data
  5044. */
  5045. function mergeDataOrFn(parentVal, childVal, vm) {
  5046. if (!vm) {
  5047. // in a Vue.extend merge, both should be functions
  5048. if (!childVal) {
  5049. return parentVal;
  5050. }
  5051. if (!parentVal) {
  5052. return childVal;
  5053. }
  5054. // when parentVal & childVal are both present,
  5055. // we need to return a function that returns the
  5056. // merged result of both functions... no need to
  5057. // check if parentVal is a function here because
  5058. // it has to be a function to pass previous merges.
  5059. return function mergedDataFn() {
  5060. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5061. };
  5062. }
  5063. else {
  5064. return function mergedInstanceDataFn() {
  5065. // instance merge
  5066. const instanceData = isFunction(childVal)
  5067. ? childVal.call(vm, vm)
  5068. : childVal;
  5069. const defaultData = isFunction(parentVal)
  5070. ? parentVal.call(vm, vm)
  5071. : parentVal;
  5072. if (instanceData) {
  5073. return mergeData(instanceData, defaultData);
  5074. }
  5075. else {
  5076. return defaultData;
  5077. }
  5078. };
  5079. }
  5080. }
  5081. strats.data = function (parentVal, childVal, vm) {
  5082. if (!vm) {
  5083. if (childVal && typeof childVal !== 'function') {
  5084. warn$2('The "data" option should be a function ' +
  5085. 'that returns a per-instance value in component ' +
  5086. 'definitions.', vm);
  5087. return parentVal;
  5088. }
  5089. return mergeDataOrFn(parentVal, childVal);
  5090. }
  5091. return mergeDataOrFn(parentVal, childVal, vm);
  5092. };
  5093. /**
  5094. * Hooks and props are merged as arrays.
  5095. */
  5096. function mergeLifecycleHook(parentVal, childVal) {
  5097. const res = childVal
  5098. ? parentVal
  5099. ? parentVal.concat(childVal)
  5100. : isArray(childVal)
  5101. ? childVal
  5102. : [childVal]
  5103. : parentVal;
  5104. return res ? dedupeHooks(res) : res;
  5105. }
  5106. function dedupeHooks(hooks) {
  5107. const res = [];
  5108. for (let i = 0; i < hooks.length; i++) {
  5109. if (res.indexOf(hooks[i]) === -1) {
  5110. res.push(hooks[i]);
  5111. }
  5112. }
  5113. return res;
  5114. }
  5115. LIFECYCLE_HOOKS.forEach(hook => {
  5116. strats[hook] = mergeLifecycleHook;
  5117. });
  5118. /**
  5119. * Assets
  5120. *
  5121. * When a vm is present (instance creation), we need to do
  5122. * a three-way merge between constructor options, instance
  5123. * options and parent options.
  5124. */
  5125. function mergeAssets(parentVal, childVal, vm, key) {
  5126. const res = Object.create(parentVal || null);
  5127. if (childVal) {
  5128. assertObjectType(key, childVal, vm);
  5129. return extend(res, childVal);
  5130. }
  5131. else {
  5132. return res;
  5133. }
  5134. }
  5135. ASSET_TYPES.forEach(function (type) {
  5136. strats[type + 's'] = mergeAssets;
  5137. });
  5138. /**
  5139. * Watchers.
  5140. *
  5141. * Watchers hashes should not overwrite one
  5142. * another, so we merge them as arrays.
  5143. */
  5144. strats.watch = function (parentVal, childVal, vm, key) {
  5145. // work around Firefox's Object.prototype.watch...
  5146. //@ts-expect-error work around
  5147. if (parentVal === nativeWatch)
  5148. parentVal = undefined;
  5149. //@ts-expect-error work around
  5150. if (childVal === nativeWatch)
  5151. childVal = undefined;
  5152. /* istanbul ignore if */
  5153. if (!childVal)
  5154. return Object.create(parentVal || null);
  5155. {
  5156. assertObjectType(key, childVal, vm);
  5157. }
  5158. if (!parentVal)
  5159. return childVal;
  5160. const ret = {};
  5161. extend(ret, parentVal);
  5162. for (const key in childVal) {
  5163. let parent = ret[key];
  5164. const child = childVal[key];
  5165. if (parent && !isArray(parent)) {
  5166. parent = [parent];
  5167. }
  5168. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5169. }
  5170. return ret;
  5171. };
  5172. /**
  5173. * Other object hashes.
  5174. */
  5175. strats.props =
  5176. strats.methods =
  5177. strats.inject =
  5178. strats.computed =
  5179. function (parentVal, childVal, vm, key) {
  5180. if (childVal && true) {
  5181. assertObjectType(key, childVal, vm);
  5182. }
  5183. if (!parentVal)
  5184. return childVal;
  5185. const ret = Object.create(null);
  5186. extend(ret, parentVal);
  5187. if (childVal)
  5188. extend(ret, childVal);
  5189. return ret;
  5190. };
  5191. strats.provide = function (parentVal, childVal) {
  5192. if (!parentVal)
  5193. return childVal;
  5194. return function () {
  5195. const ret = Object.create(null);
  5196. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5197. if (childVal) {
  5198. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5199. );
  5200. }
  5201. return ret;
  5202. };
  5203. };
  5204. /**
  5205. * Default strategy.
  5206. */
  5207. const defaultStrat = function (parentVal, childVal) {
  5208. return childVal === undefined ? parentVal : childVal;
  5209. };
  5210. /**
  5211. * Validate component names
  5212. */
  5213. function checkComponents(options) {
  5214. for (const key in options.components) {
  5215. validateComponentName(key);
  5216. }
  5217. }
  5218. function validateComponentName(name) {
  5219. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5220. warn$2('Invalid component name: "' +
  5221. name +
  5222. '". Component names ' +
  5223. 'should conform to valid custom element name in html5 specification.');
  5224. }
  5225. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5226. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5227. 'id: ' +
  5228. name);
  5229. }
  5230. }
  5231. /**
  5232. * Ensure all props option syntax are normalized into the
  5233. * Object-based format.
  5234. */
  5235. function normalizeProps(options, vm) {
  5236. const props = options.props;
  5237. if (!props)
  5238. return;
  5239. const res = {};
  5240. let i, val, name;
  5241. if (isArray(props)) {
  5242. i = props.length;
  5243. while (i--) {
  5244. val = props[i];
  5245. if (typeof val === 'string') {
  5246. name = camelize(val);
  5247. res[name] = { type: null };
  5248. }
  5249. else {
  5250. warn$2('props must be strings when using array syntax.');
  5251. }
  5252. }
  5253. }
  5254. else if (isPlainObject(props)) {
  5255. for (const key in props) {
  5256. val = props[key];
  5257. name = camelize(key);
  5258. res[name] = isPlainObject(val) ? val : { type: val };
  5259. }
  5260. }
  5261. else {
  5262. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5263. `but got ${toRawType(props)}.`, vm);
  5264. }
  5265. options.props = res;
  5266. }
  5267. /**
  5268. * Normalize all injections into Object-based format
  5269. */
  5270. function normalizeInject(options, vm) {
  5271. const inject = options.inject;
  5272. if (!inject)
  5273. return;
  5274. const normalized = (options.inject = {});
  5275. if (isArray(inject)) {
  5276. for (let i = 0; i < inject.length; i++) {
  5277. normalized[inject[i]] = { from: inject[i] };
  5278. }
  5279. }
  5280. else if (isPlainObject(inject)) {
  5281. for (const key in inject) {
  5282. const val = inject[key];
  5283. normalized[key] = isPlainObject(val)
  5284. ? extend({ from: key }, val)
  5285. : { from: val };
  5286. }
  5287. }
  5288. else {
  5289. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5290. `but got ${toRawType(inject)}.`, vm);
  5291. }
  5292. }
  5293. /**
  5294. * Normalize raw function directives into object format.
  5295. */
  5296. function normalizeDirectives$1(options) {
  5297. const dirs = options.directives;
  5298. if (dirs) {
  5299. for (const key in dirs) {
  5300. const def = dirs[key];
  5301. if (isFunction(def)) {
  5302. dirs[key] = { bind: def, update: def };
  5303. }
  5304. }
  5305. }
  5306. }
  5307. function assertObjectType(name, value, vm) {
  5308. if (!isPlainObject(value)) {
  5309. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5310. `but got ${toRawType(value)}.`, vm);
  5311. }
  5312. }
  5313. /**
  5314. * Merge two option objects into a new one.
  5315. * Core utility used in both instantiation and inheritance.
  5316. */
  5317. function mergeOptions(parent, child, vm) {
  5318. {
  5319. checkComponents(child);
  5320. }
  5321. if (isFunction(child)) {
  5322. // @ts-expect-error
  5323. child = child.options;
  5324. }
  5325. normalizeProps(child, vm);
  5326. normalizeInject(child, vm);
  5327. normalizeDirectives$1(child);
  5328. // Apply extends and mixins on the child options,
  5329. // but only if it is a raw options object that isn't
  5330. // the result of another mergeOptions call.
  5331. // Only merged options has the _base property.
  5332. if (!child._base) {
  5333. if (child.extends) {
  5334. parent = mergeOptions(parent, child.extends, vm);
  5335. }
  5336. if (child.mixins) {
  5337. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5338. parent = mergeOptions(parent, child.mixins[i], vm);
  5339. }
  5340. }
  5341. }
  5342. const options = {};
  5343. let key;
  5344. for (key in parent) {
  5345. mergeField(key);
  5346. }
  5347. for (key in child) {
  5348. if (!hasOwn(parent, key)) {
  5349. mergeField(key);
  5350. }
  5351. }
  5352. function mergeField(key) {
  5353. const strat = strats[key] || defaultStrat;
  5354. options[key] = strat(parent[key], child[key], vm, key);
  5355. }
  5356. return options;
  5357. }
  5358. /**
  5359. * Resolve an asset.
  5360. * This function is used because child instances need access
  5361. * to assets defined in its ancestor chain.
  5362. */
  5363. function resolveAsset(options, type, id, warnMissing) {
  5364. /* istanbul ignore if */
  5365. if (typeof id !== 'string') {
  5366. return;
  5367. }
  5368. const assets = options[type];
  5369. // check local registration variations first
  5370. if (hasOwn(assets, id))
  5371. return assets[id];
  5372. const camelizedId = camelize(id);
  5373. if (hasOwn(assets, camelizedId))
  5374. return assets[camelizedId];
  5375. const PascalCaseId = capitalize(camelizedId);
  5376. if (hasOwn(assets, PascalCaseId))
  5377. return assets[PascalCaseId];
  5378. // fallback to prototype chain
  5379. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5380. if (warnMissing && !res) {
  5381. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5382. }
  5383. return res;
  5384. }
  5385. function validateProp(key, propOptions, propsData, vm) {
  5386. const prop = propOptions[key];
  5387. const absent = !hasOwn(propsData, key);
  5388. let value = propsData[key];
  5389. // boolean casting
  5390. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5391. if (booleanIndex > -1) {
  5392. if (absent && !hasOwn(prop, 'default')) {
  5393. value = false;
  5394. }
  5395. else if (value === '' || value === hyphenate(key)) {
  5396. // only cast empty string / same name to boolean if
  5397. // boolean has higher priority
  5398. const stringIndex = getTypeIndex(String, prop.type);
  5399. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5400. value = true;
  5401. }
  5402. }
  5403. }
  5404. // check default value
  5405. if (value === undefined) {
  5406. value = getPropDefaultValue(vm, prop, key);
  5407. // since the default value is a fresh copy,
  5408. // make sure to observe it.
  5409. const prevShouldObserve = shouldObserve;
  5410. toggleObserving(true);
  5411. observe(value);
  5412. toggleObserving(prevShouldObserve);
  5413. }
  5414. {
  5415. assertProp(prop, key, value, vm, absent);
  5416. }
  5417. return value;
  5418. }
  5419. /**
  5420. * Get the default value of a prop.
  5421. */
  5422. function getPropDefaultValue(vm, prop, key) {
  5423. // no default, return undefined
  5424. if (!hasOwn(prop, 'default')) {
  5425. return undefined;
  5426. }
  5427. const def = prop.default;
  5428. // warn against non-factory defaults for Object & Array
  5429. if (isObject(def)) {
  5430. warn$2('Invalid default value for prop "' +
  5431. key +
  5432. '": ' +
  5433. 'Props with type Object/Array must use a factory function ' +
  5434. 'to return the default value.', vm);
  5435. }
  5436. // the raw prop value was also undefined from previous render,
  5437. // return previous default value to avoid unnecessary watcher trigger
  5438. if (vm &&
  5439. vm.$options.propsData &&
  5440. vm.$options.propsData[key] === undefined &&
  5441. vm._props[key] !== undefined) {
  5442. return vm._props[key];
  5443. }
  5444. // call factory function for non-Function types
  5445. // a value is Function if its prototype is function even across different execution context
  5446. return isFunction(def) && getType(prop.type) !== 'Function'
  5447. ? def.call(vm)
  5448. : def;
  5449. }
  5450. /**
  5451. * Assert whether a prop is valid.
  5452. */
  5453. function assertProp(prop, name, value, vm, absent) {
  5454. if (prop.required && absent) {
  5455. warn$2('Missing required prop: "' + name + '"', vm);
  5456. return;
  5457. }
  5458. if (value == null && !prop.required) {
  5459. return;
  5460. }
  5461. let type = prop.type;
  5462. let valid = !type || type === true;
  5463. const expectedTypes = [];
  5464. if (type) {
  5465. if (!isArray(type)) {
  5466. type = [type];
  5467. }
  5468. for (let i = 0; i < type.length && !valid; i++) {
  5469. const assertedType = assertType(value, type[i], vm);
  5470. expectedTypes.push(assertedType.expectedType || '');
  5471. valid = assertedType.valid;
  5472. }
  5473. }
  5474. const haveExpectedTypes = expectedTypes.some(t => t);
  5475. if (!valid && haveExpectedTypes) {
  5476. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5477. return;
  5478. }
  5479. const validator = prop.validator;
  5480. if (validator) {
  5481. if (!validator(value)) {
  5482. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5483. }
  5484. }
  5485. }
  5486. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5487. function assertType(value, type, vm) {
  5488. let valid;
  5489. const expectedType = getType(type);
  5490. if (simpleCheckRE.test(expectedType)) {
  5491. const t = typeof value;
  5492. valid = t === expectedType.toLowerCase();
  5493. // for primitive wrapper objects
  5494. if (!valid && t === 'object') {
  5495. valid = value instanceof type;
  5496. }
  5497. }
  5498. else if (expectedType === 'Object') {
  5499. valid = isPlainObject(value);
  5500. }
  5501. else if (expectedType === 'Array') {
  5502. valid = isArray(value);
  5503. }
  5504. else {
  5505. try {
  5506. valid = value instanceof type;
  5507. }
  5508. catch (e) {
  5509. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5510. valid = false;
  5511. }
  5512. }
  5513. return {
  5514. valid,
  5515. expectedType
  5516. };
  5517. }
  5518. const functionTypeCheckRE = /^\s*function (\w+)/;
  5519. /**
  5520. * Use function string name to check built-in types,
  5521. * because a simple equality check will fail when running
  5522. * across different vms / iframes.
  5523. */
  5524. function getType(fn) {
  5525. const match = fn && fn.toString().match(functionTypeCheckRE);
  5526. return match ? match[1] : '';
  5527. }
  5528. function isSameType(a, b) {
  5529. return getType(a) === getType(b);
  5530. }
  5531. function getTypeIndex(type, expectedTypes) {
  5532. if (!isArray(expectedTypes)) {
  5533. return isSameType(expectedTypes, type) ? 0 : -1;
  5534. }
  5535. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5536. if (isSameType(expectedTypes[i], type)) {
  5537. return i;
  5538. }
  5539. }
  5540. return -1;
  5541. }
  5542. function getInvalidTypeMessage(name, value, expectedTypes) {
  5543. let message = `Invalid prop: type check failed for prop "${name}".` +
  5544. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5545. const expectedType = expectedTypes[0];
  5546. const receivedType = toRawType(value);
  5547. // check if we need to specify expected value
  5548. if (expectedTypes.length === 1 &&
  5549. isExplicable(expectedType) &&
  5550. isExplicable(typeof value) &&
  5551. !isBoolean(expectedType, receivedType)) {
  5552. message += ` with value ${styleValue(value, expectedType)}`;
  5553. }
  5554. message += `, got ${receivedType} `;
  5555. // check if we need to specify received value
  5556. if (isExplicable(receivedType)) {
  5557. message += `with value ${styleValue(value, receivedType)}.`;
  5558. }
  5559. return message;
  5560. }
  5561. function styleValue(value, type) {
  5562. if (type === 'String') {
  5563. return `"${value}"`;
  5564. }
  5565. else if (type === 'Number') {
  5566. return `${Number(value)}`;
  5567. }
  5568. else {
  5569. return `${value}`;
  5570. }
  5571. }
  5572. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5573. function isExplicable(value) {
  5574. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5575. }
  5576. function isBoolean(...args) {
  5577. return args.some(elem => elem.toLowerCase() === 'boolean');
  5578. }
  5579. function Vue(options) {
  5580. if (!(this instanceof Vue)) {
  5581. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5582. }
  5583. this._init(options);
  5584. }
  5585. //@ts-expect-error Vue has function type
  5586. initMixin$1(Vue);
  5587. //@ts-expect-error Vue has function type
  5588. stateMixin(Vue);
  5589. //@ts-expect-error Vue has function type
  5590. eventsMixin(Vue);
  5591. //@ts-expect-error Vue has function type
  5592. lifecycleMixin(Vue);
  5593. //@ts-expect-error Vue has function type
  5594. renderMixin(Vue);
  5595. function initUse(Vue) {
  5596. Vue.use = function (plugin) {
  5597. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5598. if (installedPlugins.indexOf(plugin) > -1) {
  5599. return this;
  5600. }
  5601. // additional parameters
  5602. const args = toArray(arguments, 1);
  5603. args.unshift(this);
  5604. if (isFunction(plugin.install)) {
  5605. plugin.install.apply(plugin, args);
  5606. }
  5607. else if (isFunction(plugin)) {
  5608. plugin.apply(null, args);
  5609. }
  5610. installedPlugins.push(plugin);
  5611. return this;
  5612. };
  5613. }
  5614. function initMixin(Vue) {
  5615. Vue.mixin = function (mixin) {
  5616. this.options = mergeOptions(this.options, mixin);
  5617. return this;
  5618. };
  5619. }
  5620. function initExtend(Vue) {
  5621. /**
  5622. * Each instance constructor, including Vue, has a unique
  5623. * cid. This enables us to create wrapped "child
  5624. * constructors" for prototypal inheritance and cache them.
  5625. */
  5626. Vue.cid = 0;
  5627. let cid = 1;
  5628. /**
  5629. * Class inheritance
  5630. */
  5631. Vue.extend = function (extendOptions) {
  5632. extendOptions = extendOptions || {};
  5633. const Super = this;
  5634. const SuperId = Super.cid;
  5635. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5636. if (cachedCtors[SuperId]) {
  5637. return cachedCtors[SuperId];
  5638. }
  5639. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5640. if (name) {
  5641. validateComponentName(name);
  5642. }
  5643. const Sub = function VueComponent(options) {
  5644. this._init(options);
  5645. };
  5646. Sub.prototype = Object.create(Super.prototype);
  5647. Sub.prototype.constructor = Sub;
  5648. Sub.cid = cid++;
  5649. Sub.options = mergeOptions(Super.options, extendOptions);
  5650. Sub['super'] = Super;
  5651. // For props and computed properties, we define the proxy getters on
  5652. // the Vue instances at extension time, on the extended prototype. This
  5653. // avoids Object.defineProperty calls for each instance created.
  5654. if (Sub.options.props) {
  5655. initProps(Sub);
  5656. }
  5657. if (Sub.options.computed) {
  5658. initComputed(Sub);
  5659. }
  5660. // allow further extension/mixin/plugin usage
  5661. Sub.extend = Super.extend;
  5662. Sub.mixin = Super.mixin;
  5663. Sub.use = Super.use;
  5664. // create asset registers, so extended classes
  5665. // can have their private assets too.
  5666. ASSET_TYPES.forEach(function (type) {
  5667. Sub[type] = Super[type];
  5668. });
  5669. // enable recursive self-lookup
  5670. if (name) {
  5671. Sub.options.components[name] = Sub;
  5672. }
  5673. // keep a reference to the super options at extension time.
  5674. // later at instantiation we can check if Super's options have
  5675. // been updated.
  5676. Sub.superOptions = Super.options;
  5677. Sub.extendOptions = extendOptions;
  5678. Sub.sealedOptions = extend({}, Sub.options);
  5679. // cache constructor
  5680. cachedCtors[SuperId] = Sub;
  5681. return Sub;
  5682. };
  5683. }
  5684. function initProps(Comp) {
  5685. const props = Comp.options.props;
  5686. for (const key in props) {
  5687. proxy(Comp.prototype, `_props`, key);
  5688. }
  5689. }
  5690. function initComputed(Comp) {
  5691. const computed = Comp.options.computed;
  5692. for (const key in computed) {
  5693. defineComputed(Comp.prototype, key, computed[key]);
  5694. }
  5695. }
  5696. function initAssetRegisters(Vue) {
  5697. /**
  5698. * Create asset registration methods.
  5699. */
  5700. ASSET_TYPES.forEach(type => {
  5701. // @ts-expect-error function is not exact same type
  5702. Vue[type] = function (id, definition) {
  5703. if (!definition) {
  5704. return this.options[type + 's'][id];
  5705. }
  5706. else {
  5707. /* istanbul ignore if */
  5708. if (type === 'component') {
  5709. validateComponentName(id);
  5710. }
  5711. if (type === 'component' && isPlainObject(definition)) {
  5712. // @ts-expect-error
  5713. definition.name = definition.name || id;
  5714. definition = this.options._base.extend(definition);
  5715. }
  5716. if (type === 'directive' && isFunction(definition)) {
  5717. definition = { bind: definition, update: definition };
  5718. }
  5719. this.options[type + 's'][id] = definition;
  5720. return definition;
  5721. }
  5722. };
  5723. });
  5724. }
  5725. function _getComponentName(opts) {
  5726. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5727. }
  5728. function matches(pattern, name) {
  5729. if (isArray(pattern)) {
  5730. return pattern.indexOf(name) > -1;
  5731. }
  5732. else if (typeof pattern === 'string') {
  5733. return pattern.split(',').indexOf(name) > -1;
  5734. }
  5735. else if (isRegExp(pattern)) {
  5736. return pattern.test(name);
  5737. }
  5738. /* istanbul ignore next */
  5739. return false;
  5740. }
  5741. function pruneCache(keepAliveInstance, filter) {
  5742. const { cache, keys, _vnode, $vnode } = keepAliveInstance;
  5743. for (const key in cache) {
  5744. const entry = cache[key];
  5745. if (entry) {
  5746. const name = entry.name;
  5747. if (name && !filter(name)) {
  5748. pruneCacheEntry(cache, key, keys, _vnode);
  5749. }
  5750. }
  5751. }
  5752. $vnode.componentOptions.children = undefined;
  5753. }
  5754. function pruneCacheEntry(cache, key, keys, current) {
  5755. const entry = cache[key];
  5756. if (entry && (!current || entry.tag !== current.tag)) {
  5757. // @ts-expect-error can be undefined
  5758. entry.componentInstance.$destroy();
  5759. }
  5760. cache[key] = null;
  5761. remove$2(keys, key);
  5762. }
  5763. const patternTypes = [String, RegExp, Array];
  5764. // TODO defineComponent
  5765. var KeepAlive = {
  5766. name: 'keep-alive',
  5767. abstract: true,
  5768. props: {
  5769. include: patternTypes,
  5770. exclude: patternTypes,
  5771. max: [String, Number]
  5772. },
  5773. methods: {
  5774. cacheVNode() {
  5775. const { cache, keys, vnodeToCache, keyToCache } = this;
  5776. if (vnodeToCache) {
  5777. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5778. cache[keyToCache] = {
  5779. name: _getComponentName(componentOptions),
  5780. tag,
  5781. componentInstance
  5782. };
  5783. keys.push(keyToCache);
  5784. // prune oldest entry
  5785. if (this.max && keys.length > parseInt(this.max)) {
  5786. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5787. }
  5788. this.vnodeToCache = null;
  5789. }
  5790. }
  5791. },
  5792. created() {
  5793. this.cache = Object.create(null);
  5794. this.keys = [];
  5795. },
  5796. destroyed() {
  5797. for (const key in this.cache) {
  5798. pruneCacheEntry(this.cache, key, this.keys);
  5799. }
  5800. },
  5801. mounted() {
  5802. this.cacheVNode();
  5803. this.$watch('include', val => {
  5804. pruneCache(this, name => matches(val, name));
  5805. });
  5806. this.$watch('exclude', val => {
  5807. pruneCache(this, name => !matches(val, name));
  5808. });
  5809. },
  5810. updated() {
  5811. this.cacheVNode();
  5812. },
  5813. render() {
  5814. const slot = this.$slots.default;
  5815. const vnode = getFirstComponentChild(slot);
  5816. const componentOptions = vnode && vnode.componentOptions;
  5817. if (componentOptions) {
  5818. // check pattern
  5819. const name = _getComponentName(componentOptions);
  5820. const { include, exclude } = this;
  5821. if (
  5822. // not included
  5823. (include && (!name || !matches(include, name))) ||
  5824. // excluded
  5825. (exclude && name && matches(exclude, name))) {
  5826. return vnode;
  5827. }
  5828. const { cache, keys } = this;
  5829. const key = vnode.key == null
  5830. ? // same constructor may get registered as different local components
  5831. // so cid alone is not enough (#3269)
  5832. componentOptions.Ctor.cid +
  5833. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5834. : vnode.key;
  5835. if (cache[key]) {
  5836. vnode.componentInstance = cache[key].componentInstance;
  5837. // make current key freshest
  5838. remove$2(keys, key);
  5839. keys.push(key);
  5840. }
  5841. else {
  5842. // delay setting the cache until update
  5843. this.vnodeToCache = vnode;
  5844. this.keyToCache = key;
  5845. }
  5846. // @ts-expect-error can vnode.data can be undefined
  5847. vnode.data.keepAlive = true;
  5848. }
  5849. return vnode || (slot && slot[0]);
  5850. }
  5851. };
  5852. var builtInComponents = {
  5853. KeepAlive
  5854. };
  5855. function initGlobalAPI(Vue) {
  5856. // config
  5857. const configDef = {};
  5858. configDef.get = () => config;
  5859. {
  5860. configDef.set = () => {
  5861. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5862. };
  5863. }
  5864. Object.defineProperty(Vue, 'config', configDef);
  5865. // exposed util methods.
  5866. // NOTE: these are not considered part of the public API - avoid relying on
  5867. // them unless you are aware of the risk.
  5868. Vue.util = {
  5869. warn: warn$2,
  5870. extend,
  5871. mergeOptions,
  5872. defineReactive
  5873. };
  5874. Vue.set = set;
  5875. Vue.delete = del;
  5876. Vue.nextTick = nextTick;
  5877. // 2.6 explicit observable API
  5878. Vue.observable = (obj) => {
  5879. observe(obj);
  5880. return obj;
  5881. };
  5882. Vue.options = Object.create(null);
  5883. ASSET_TYPES.forEach(type => {
  5884. Vue.options[type + 's'] = Object.create(null);
  5885. });
  5886. // this is used to identify the "base" constructor to extend all plain-object
  5887. // components with in Weex's multi-instance scenarios.
  5888. Vue.options._base = Vue;
  5889. extend(Vue.options.components, builtInComponents);
  5890. initUse(Vue);
  5891. initMixin(Vue);
  5892. initExtend(Vue);
  5893. initAssetRegisters(Vue);
  5894. }
  5895. initGlobalAPI(Vue);
  5896. Object.defineProperty(Vue.prototype, '$isServer', {
  5897. get: isServerRendering
  5898. });
  5899. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5900. get() {
  5901. /* istanbul ignore next */
  5902. return this.$vnode && this.$vnode.ssrContext;
  5903. }
  5904. });
  5905. // expose FunctionalRenderContext for ssr runtime helper installation
  5906. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5907. value: FunctionalRenderContext
  5908. });
  5909. Vue.version = version;
  5910. // these are reserved for web because they are directly compiled away
  5911. // during template compilation
  5912. const isReservedAttr = makeMap('style,class');
  5913. // attributes that should be using props for binding
  5914. const acceptValue = makeMap('input,textarea,option,select,progress');
  5915. const mustUseProp = (tag, type, attr) => {
  5916. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5917. (attr === 'selected' && tag === 'option') ||
  5918. (attr === 'checked' && tag === 'input') ||
  5919. (attr === 'muted' && tag === 'video'));
  5920. };
  5921. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5922. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5923. const convertEnumeratedValue = (key, value) => {
  5924. return isFalsyAttrValue(value) || value === 'false'
  5925. ? 'false'
  5926. : // allow arbitrary string value for contenteditable
  5927. key === 'contenteditable' && isValidContentEditableValue(value)
  5928. ? value
  5929. : 'true';
  5930. };
  5931. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5932. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5933. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5934. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5935. 'required,reversed,scoped,seamless,selected,sortable,' +
  5936. 'truespeed,typemustmatch,visible');
  5937. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5938. const isXlink = (name) => {
  5939. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5940. };
  5941. const getXlinkProp = (name) => {
  5942. return isXlink(name) ? name.slice(6, name.length) : '';
  5943. };
  5944. const isFalsyAttrValue = (val) => {
  5945. return val == null || val === false;
  5946. };
  5947. function genClassForVnode(vnode) {
  5948. let data = vnode.data;
  5949. let parentNode = vnode;
  5950. let childNode = vnode;
  5951. while (isDef(childNode.componentInstance)) {
  5952. childNode = childNode.componentInstance._vnode;
  5953. if (childNode && childNode.data) {
  5954. data = mergeClassData(childNode.data, data);
  5955. }
  5956. }
  5957. // @ts-expect-error parentNode.parent not VNodeWithData
  5958. while (isDef((parentNode = parentNode.parent))) {
  5959. if (parentNode && parentNode.data) {
  5960. data = mergeClassData(data, parentNode.data);
  5961. }
  5962. }
  5963. return renderClass(data.staticClass, data.class);
  5964. }
  5965. function mergeClassData(child, parent) {
  5966. return {
  5967. staticClass: concat(child.staticClass, parent.staticClass),
  5968. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  5969. };
  5970. }
  5971. function renderClass(staticClass, dynamicClass) {
  5972. if (isDef(staticClass) || isDef(dynamicClass)) {
  5973. return concat(staticClass, stringifyClass(dynamicClass));
  5974. }
  5975. /* istanbul ignore next */
  5976. return '';
  5977. }
  5978. function concat(a, b) {
  5979. return a ? (b ? a + ' ' + b : a) : b || '';
  5980. }
  5981. function stringifyClass(value) {
  5982. if (Array.isArray(value)) {
  5983. return stringifyArray(value);
  5984. }
  5985. if (isObject(value)) {
  5986. return stringifyObject(value);
  5987. }
  5988. if (typeof value === 'string') {
  5989. return value;
  5990. }
  5991. /* istanbul ignore next */
  5992. return '';
  5993. }
  5994. function stringifyArray(value) {
  5995. let res = '';
  5996. let stringified;
  5997. for (let i = 0, l = value.length; i < l; i++) {
  5998. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  5999. if (res)
  6000. res += ' ';
  6001. res += stringified;
  6002. }
  6003. }
  6004. return res;
  6005. }
  6006. function stringifyObject(value) {
  6007. let res = '';
  6008. for (const key in value) {
  6009. if (value[key]) {
  6010. if (res)
  6011. res += ' ';
  6012. res += key;
  6013. }
  6014. }
  6015. return res;
  6016. }
  6017. const namespaceMap = {
  6018. svg: 'http://www.w3.org/2000/svg',
  6019. math: 'http://www.w3.org/1998/Math/MathML'
  6020. };
  6021. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6022. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6023. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6024. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6025. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6026. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6027. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6028. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6029. 'output,progress,select,textarea,' +
  6030. 'details,dialog,menu,menuitem,summary,' +
  6031. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6032. // this map is intentionally selective, only covering SVG elements that may
  6033. // contain child elements.
  6034. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6035. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6036. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6037. const isPreTag = (tag) => tag === 'pre';
  6038. const isReservedTag = (tag) => {
  6039. return isHTMLTag(tag) || isSVG(tag);
  6040. };
  6041. function getTagNamespace(tag) {
  6042. if (isSVG(tag)) {
  6043. return 'svg';
  6044. }
  6045. // basic support for MathML
  6046. // note it doesn't support other MathML elements being component roots
  6047. if (tag === 'math') {
  6048. return 'math';
  6049. }
  6050. }
  6051. const unknownElementCache = Object.create(null);
  6052. function isUnknownElement(tag) {
  6053. /* istanbul ignore if */
  6054. if (!inBrowser) {
  6055. return true;
  6056. }
  6057. if (isReservedTag(tag)) {
  6058. return false;
  6059. }
  6060. tag = tag.toLowerCase();
  6061. /* istanbul ignore if */
  6062. if (unknownElementCache[tag] != null) {
  6063. return unknownElementCache[tag];
  6064. }
  6065. const el = document.createElement(tag);
  6066. if (tag.indexOf('-') > -1) {
  6067. // https://stackoverflow.com/a/28210364/1070244
  6068. return (unknownElementCache[tag] =
  6069. el.constructor === window.HTMLUnknownElement ||
  6070. el.constructor === window.HTMLElement);
  6071. }
  6072. else {
  6073. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6074. }
  6075. }
  6076. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6077. /**
  6078. * Query an element selector if it's not an element already.
  6079. */
  6080. function query(el) {
  6081. if (typeof el === 'string') {
  6082. const selected = document.querySelector(el);
  6083. if (!selected) {
  6084. warn$2('Cannot find element: ' + el);
  6085. return document.createElement('div');
  6086. }
  6087. return selected;
  6088. }
  6089. else {
  6090. return el;
  6091. }
  6092. }
  6093. function createElement(tagName, vnode) {
  6094. const elm = document.createElement(tagName);
  6095. if (tagName !== 'select') {
  6096. return elm;
  6097. }
  6098. // false or null will remove the attribute but undefined will not
  6099. if (vnode.data &&
  6100. vnode.data.attrs &&
  6101. vnode.data.attrs.multiple !== undefined) {
  6102. elm.setAttribute('multiple', 'multiple');
  6103. }
  6104. return elm;
  6105. }
  6106. function createElementNS(namespace, tagName) {
  6107. return document.createElementNS(namespaceMap[namespace], tagName);
  6108. }
  6109. function createTextNode(text) {
  6110. return document.createTextNode(text);
  6111. }
  6112. function createComment(text) {
  6113. return document.createComment(text);
  6114. }
  6115. function insertBefore(parentNode, newNode, referenceNode) {
  6116. parentNode.insertBefore(newNode, referenceNode);
  6117. }
  6118. function removeChild(node, child) {
  6119. node.removeChild(child);
  6120. }
  6121. function appendChild(node, child) {
  6122. node.appendChild(child);
  6123. }
  6124. function parentNode(node) {
  6125. return node.parentNode;
  6126. }
  6127. function nextSibling(node) {
  6128. return node.nextSibling;
  6129. }
  6130. function tagName(node) {
  6131. return node.tagName;
  6132. }
  6133. function setTextContent(node, text) {
  6134. node.textContent = text;
  6135. }
  6136. function setStyleScope(node, scopeId) {
  6137. node.setAttribute(scopeId, '');
  6138. }
  6139. var nodeOps = /*#__PURE__*/Object.freeze({
  6140. __proto__: null,
  6141. createElement: createElement,
  6142. createElementNS: createElementNS,
  6143. createTextNode: createTextNode,
  6144. createComment: createComment,
  6145. insertBefore: insertBefore,
  6146. removeChild: removeChild,
  6147. appendChild: appendChild,
  6148. parentNode: parentNode,
  6149. nextSibling: nextSibling,
  6150. tagName: tagName,
  6151. setTextContent: setTextContent,
  6152. setStyleScope: setStyleScope
  6153. });
  6154. var ref = {
  6155. create(_, vnode) {
  6156. registerRef(vnode);
  6157. },
  6158. update(oldVnode, vnode) {
  6159. if (oldVnode.data.ref !== vnode.data.ref) {
  6160. registerRef(oldVnode, true);
  6161. registerRef(vnode);
  6162. }
  6163. },
  6164. destroy(vnode) {
  6165. registerRef(vnode, true);
  6166. }
  6167. };
  6168. function registerRef(vnode, isRemoval) {
  6169. const ref = vnode.data.ref;
  6170. if (!isDef(ref))
  6171. return;
  6172. const vm = vnode.context;
  6173. const refValue = vnode.componentInstance || vnode.elm;
  6174. const value = isRemoval ? null : refValue;
  6175. const $refsValue = isRemoval ? undefined : refValue;
  6176. if (isFunction(ref)) {
  6177. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6178. return;
  6179. }
  6180. const isFor = vnode.data.refInFor;
  6181. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6182. const _isRef = isRef(ref);
  6183. const refs = vm.$refs;
  6184. if (_isString || _isRef) {
  6185. if (isFor) {
  6186. const existing = _isString ? refs[ref] : ref.value;
  6187. if (isRemoval) {
  6188. isArray(existing) && remove$2(existing, refValue);
  6189. }
  6190. else {
  6191. if (!isArray(existing)) {
  6192. if (_isString) {
  6193. refs[ref] = [refValue];
  6194. setSetupRef(vm, ref, refs[ref]);
  6195. }
  6196. else {
  6197. ref.value = [refValue];
  6198. }
  6199. }
  6200. else if (!existing.includes(refValue)) {
  6201. existing.push(refValue);
  6202. }
  6203. }
  6204. }
  6205. else if (_isString) {
  6206. if (isRemoval && refs[ref] !== refValue) {
  6207. return;
  6208. }
  6209. refs[ref] = $refsValue;
  6210. setSetupRef(vm, ref, value);
  6211. }
  6212. else if (_isRef) {
  6213. if (isRemoval && ref.value !== refValue) {
  6214. return;
  6215. }
  6216. ref.value = value;
  6217. }
  6218. else {
  6219. warn$2(`Invalid template ref type: ${typeof ref}`);
  6220. }
  6221. }
  6222. }
  6223. function setSetupRef({ _setupState }, key, val) {
  6224. if (_setupState && hasOwn(_setupState, key)) {
  6225. if (isRef(_setupState[key])) {
  6226. _setupState[key].value = val;
  6227. }
  6228. else {
  6229. _setupState[key] = val;
  6230. }
  6231. }
  6232. }
  6233. /**
  6234. * Virtual DOM patching algorithm based on Snabbdom by
  6235. * Simon Friis Vindum (@paldepind)
  6236. * Licensed under the MIT License
  6237. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6238. *
  6239. * modified by Evan You (@yyx990803)
  6240. *
  6241. * Not type-checking this because this file is perf-critical and the cost
  6242. * of making flow understand it is not worth it.
  6243. */
  6244. const emptyNode = new VNode('', {}, []);
  6245. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6246. function sameVnode(a, b) {
  6247. return (a.key === b.key &&
  6248. a.asyncFactory === b.asyncFactory &&
  6249. ((a.tag === b.tag &&
  6250. a.isComment === b.isComment &&
  6251. isDef(a.data) === isDef(b.data) &&
  6252. sameInputType(a, b)) ||
  6253. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6254. }
  6255. function sameInputType(a, b) {
  6256. if (a.tag !== 'input')
  6257. return true;
  6258. let i;
  6259. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6260. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6261. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6262. }
  6263. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6264. let i, key;
  6265. const map = {};
  6266. for (i = beginIdx; i <= endIdx; ++i) {
  6267. key = children[i].key;
  6268. if (isDef(key))
  6269. map[key] = i;
  6270. }
  6271. return map;
  6272. }
  6273. function createPatchFunction(backend) {
  6274. let i, j;
  6275. const cbs = {};
  6276. const { modules, nodeOps } = backend;
  6277. for (i = 0; i < hooks.length; ++i) {
  6278. cbs[hooks[i]] = [];
  6279. for (j = 0; j < modules.length; ++j) {
  6280. if (isDef(modules[j][hooks[i]])) {
  6281. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6282. }
  6283. }
  6284. }
  6285. function emptyNodeAt(elm) {
  6286. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6287. }
  6288. function createRmCb(childElm, listeners) {
  6289. function remove() {
  6290. if (--remove.listeners === 0) {
  6291. removeNode(childElm);
  6292. }
  6293. }
  6294. remove.listeners = listeners;
  6295. return remove;
  6296. }
  6297. function removeNode(el) {
  6298. const parent = nodeOps.parentNode(el);
  6299. // element may have already been removed due to v-html / v-text
  6300. if (isDef(parent)) {
  6301. nodeOps.removeChild(parent, el);
  6302. }
  6303. }
  6304. function isUnknownElement(vnode, inVPre) {
  6305. return (!inVPre &&
  6306. !vnode.ns &&
  6307. !(config.ignoredElements.length &&
  6308. config.ignoredElements.some(ignore => {
  6309. return isRegExp(ignore)
  6310. ? ignore.test(vnode.tag)
  6311. : ignore === vnode.tag;
  6312. })) &&
  6313. config.isUnknownElement(vnode.tag));
  6314. }
  6315. let creatingElmInVPre = 0;
  6316. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6317. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6318. // This vnode was used in a previous render!
  6319. // now it's used as a new node, overwriting its elm would cause
  6320. // potential patch errors down the road when it's used as an insertion
  6321. // reference node. Instead, we clone the node on-demand before creating
  6322. // associated DOM element for it.
  6323. vnode = ownerArray[index] = cloneVNode(vnode);
  6324. }
  6325. vnode.isRootInsert = !nested; // for transition enter check
  6326. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6327. return;
  6328. }
  6329. const data = vnode.data;
  6330. const children = vnode.children;
  6331. const tag = vnode.tag;
  6332. if (isDef(tag)) {
  6333. {
  6334. if (data && data.pre) {
  6335. creatingElmInVPre++;
  6336. }
  6337. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6338. warn$2('Unknown custom element: <' +
  6339. tag +
  6340. '> - did you ' +
  6341. 'register the component correctly? For recursive components, ' +
  6342. 'make sure to provide the "name" option.', vnode.context);
  6343. }
  6344. }
  6345. vnode.elm = vnode.ns
  6346. ? nodeOps.createElementNS(vnode.ns, tag)
  6347. : nodeOps.createElement(tag, vnode);
  6348. setScope(vnode);
  6349. createChildren(vnode, children, insertedVnodeQueue);
  6350. if (isDef(data)) {
  6351. invokeCreateHooks(vnode, insertedVnodeQueue);
  6352. }
  6353. insert(parentElm, vnode.elm, refElm);
  6354. if (data && data.pre) {
  6355. creatingElmInVPre--;
  6356. }
  6357. }
  6358. else if (isTrue(vnode.isComment)) {
  6359. vnode.elm = nodeOps.createComment(vnode.text);
  6360. insert(parentElm, vnode.elm, refElm);
  6361. }
  6362. else {
  6363. vnode.elm = nodeOps.createTextNode(vnode.text);
  6364. insert(parentElm, vnode.elm, refElm);
  6365. }
  6366. }
  6367. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6368. let i = vnode.data;
  6369. if (isDef(i)) {
  6370. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6371. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6372. i(vnode, false /* hydrating */);
  6373. }
  6374. // after calling the init hook, if the vnode is a child component
  6375. // it should've created a child instance and mounted it. the child
  6376. // component also has set the placeholder vnode's elm.
  6377. // in that case we can just return the element and be done.
  6378. if (isDef(vnode.componentInstance)) {
  6379. initComponent(vnode, insertedVnodeQueue);
  6380. insert(parentElm, vnode.elm, refElm);
  6381. if (isTrue(isReactivated)) {
  6382. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6383. }
  6384. return true;
  6385. }
  6386. }
  6387. }
  6388. function initComponent(vnode, insertedVnodeQueue) {
  6389. if (isDef(vnode.data.pendingInsert)) {
  6390. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6391. vnode.data.pendingInsert = null;
  6392. }
  6393. vnode.elm = vnode.componentInstance.$el;
  6394. if (isPatchable(vnode)) {
  6395. invokeCreateHooks(vnode, insertedVnodeQueue);
  6396. setScope(vnode);
  6397. }
  6398. else {
  6399. // empty component root.
  6400. // skip all element-related modules except for ref (#3455)
  6401. registerRef(vnode);
  6402. // make sure to invoke the insert hook
  6403. insertedVnodeQueue.push(vnode);
  6404. }
  6405. }
  6406. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6407. let i;
  6408. // hack for #4339: a reactivated component with inner transition
  6409. // does not trigger because the inner node's created hooks are not called
  6410. // again. It's not ideal to involve module-specific logic in here but
  6411. // there doesn't seem to be a better way to do it.
  6412. let innerNode = vnode;
  6413. while (innerNode.componentInstance) {
  6414. innerNode = innerNode.componentInstance._vnode;
  6415. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6416. for (i = 0; i < cbs.activate.length; ++i) {
  6417. cbs.activate[i](emptyNode, innerNode);
  6418. }
  6419. insertedVnodeQueue.push(innerNode);
  6420. break;
  6421. }
  6422. }
  6423. // unlike a newly created component,
  6424. // a reactivated keep-alive component doesn't insert itself
  6425. insert(parentElm, vnode.elm, refElm);
  6426. }
  6427. function insert(parent, elm, ref) {
  6428. if (isDef(parent)) {
  6429. if (isDef(ref)) {
  6430. if (nodeOps.parentNode(ref) === parent) {
  6431. nodeOps.insertBefore(parent, elm, ref);
  6432. }
  6433. }
  6434. else {
  6435. nodeOps.appendChild(parent, elm);
  6436. }
  6437. }
  6438. }
  6439. function createChildren(vnode, children, insertedVnodeQueue) {
  6440. if (isArray(children)) {
  6441. {
  6442. checkDuplicateKeys(children);
  6443. }
  6444. for (let i = 0; i < children.length; ++i) {
  6445. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6446. }
  6447. }
  6448. else if (isPrimitive(vnode.text)) {
  6449. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6450. }
  6451. }
  6452. function isPatchable(vnode) {
  6453. while (vnode.componentInstance) {
  6454. vnode = vnode.componentInstance._vnode;
  6455. }
  6456. return isDef(vnode.tag);
  6457. }
  6458. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6459. for (let i = 0; i < cbs.create.length; ++i) {
  6460. cbs.create[i](emptyNode, vnode);
  6461. }
  6462. i = vnode.data.hook; // Reuse variable
  6463. if (isDef(i)) {
  6464. if (isDef(i.create))
  6465. i.create(emptyNode, vnode);
  6466. if (isDef(i.insert))
  6467. insertedVnodeQueue.push(vnode);
  6468. }
  6469. }
  6470. // set scope id attribute for scoped CSS.
  6471. // this is implemented as a special case to avoid the overhead
  6472. // of going through the normal attribute patching process.
  6473. function setScope(vnode) {
  6474. let i;
  6475. if (isDef((i = vnode.fnScopeId))) {
  6476. nodeOps.setStyleScope(vnode.elm, i);
  6477. }
  6478. else {
  6479. let ancestor = vnode;
  6480. while (ancestor) {
  6481. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6482. nodeOps.setStyleScope(vnode.elm, i);
  6483. }
  6484. ancestor = ancestor.parent;
  6485. }
  6486. }
  6487. // for slot content they should also get the scopeId from the host instance.
  6488. if (isDef((i = activeInstance)) &&
  6489. i !== vnode.context &&
  6490. i !== vnode.fnContext &&
  6491. isDef((i = i.$options._scopeId))) {
  6492. nodeOps.setStyleScope(vnode.elm, i);
  6493. }
  6494. }
  6495. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6496. for (; startIdx <= endIdx; ++startIdx) {
  6497. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6498. }
  6499. }
  6500. function invokeDestroyHook(vnode) {
  6501. let i, j;
  6502. const data = vnode.data;
  6503. if (isDef(data)) {
  6504. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6505. i(vnode);
  6506. for (i = 0; i < cbs.destroy.length; ++i)
  6507. cbs.destroy[i](vnode);
  6508. }
  6509. if (isDef((i = vnode.children))) {
  6510. for (j = 0; j < vnode.children.length; ++j) {
  6511. invokeDestroyHook(vnode.children[j]);
  6512. }
  6513. }
  6514. }
  6515. function removeVnodes(vnodes, startIdx, endIdx) {
  6516. for (; startIdx <= endIdx; ++startIdx) {
  6517. const ch = vnodes[startIdx];
  6518. if (isDef(ch)) {
  6519. if (isDef(ch.tag)) {
  6520. removeAndInvokeRemoveHook(ch);
  6521. invokeDestroyHook(ch);
  6522. }
  6523. else {
  6524. // Text node
  6525. removeNode(ch.elm);
  6526. }
  6527. }
  6528. }
  6529. }
  6530. function removeAndInvokeRemoveHook(vnode, rm) {
  6531. if (isDef(rm) || isDef(vnode.data)) {
  6532. let i;
  6533. const listeners = cbs.remove.length + 1;
  6534. if (isDef(rm)) {
  6535. // we have a recursively passed down rm callback
  6536. // increase the listeners count
  6537. rm.listeners += listeners;
  6538. }
  6539. else {
  6540. // directly removing
  6541. rm = createRmCb(vnode.elm, listeners);
  6542. }
  6543. // recursively invoke hooks on child component root node
  6544. if (isDef((i = vnode.componentInstance)) &&
  6545. isDef((i = i._vnode)) &&
  6546. isDef(i.data)) {
  6547. removeAndInvokeRemoveHook(i, rm);
  6548. }
  6549. for (i = 0; i < cbs.remove.length; ++i) {
  6550. cbs.remove[i](vnode, rm);
  6551. }
  6552. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6553. i(vnode, rm);
  6554. }
  6555. else {
  6556. rm();
  6557. }
  6558. }
  6559. else {
  6560. removeNode(vnode.elm);
  6561. }
  6562. }
  6563. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6564. let oldStartIdx = 0;
  6565. let newStartIdx = 0;
  6566. let oldEndIdx = oldCh.length - 1;
  6567. let oldStartVnode = oldCh[0];
  6568. let oldEndVnode = oldCh[oldEndIdx];
  6569. let newEndIdx = newCh.length - 1;
  6570. let newStartVnode = newCh[0];
  6571. let newEndVnode = newCh[newEndIdx];
  6572. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6573. // removeOnly is a special flag used only by <transition-group>
  6574. // to ensure removed elements stay in correct relative positions
  6575. // during leaving transitions
  6576. const canMove = !removeOnly;
  6577. {
  6578. checkDuplicateKeys(newCh);
  6579. }
  6580. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6581. if (isUndef(oldStartVnode)) {
  6582. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6583. }
  6584. else if (isUndef(oldEndVnode)) {
  6585. oldEndVnode = oldCh[--oldEndIdx];
  6586. }
  6587. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6588. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6589. oldStartVnode = oldCh[++oldStartIdx];
  6590. newStartVnode = newCh[++newStartIdx];
  6591. }
  6592. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6593. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6594. oldEndVnode = oldCh[--oldEndIdx];
  6595. newEndVnode = newCh[--newEndIdx];
  6596. }
  6597. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6598. // Vnode moved right
  6599. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6600. canMove &&
  6601. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6602. oldStartVnode = oldCh[++oldStartIdx];
  6603. newEndVnode = newCh[--newEndIdx];
  6604. }
  6605. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6606. // Vnode moved left
  6607. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6608. canMove &&
  6609. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6610. oldEndVnode = oldCh[--oldEndIdx];
  6611. newStartVnode = newCh[++newStartIdx];
  6612. }
  6613. else {
  6614. if (isUndef(oldKeyToIdx))
  6615. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6616. idxInOld = isDef(newStartVnode.key)
  6617. ? oldKeyToIdx[newStartVnode.key]
  6618. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6619. if (isUndef(idxInOld)) {
  6620. // New element
  6621. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6622. }
  6623. else {
  6624. vnodeToMove = oldCh[idxInOld];
  6625. if (sameVnode(vnodeToMove, newStartVnode)) {
  6626. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6627. oldCh[idxInOld] = undefined;
  6628. canMove &&
  6629. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6630. }
  6631. else {
  6632. // same key but different element. treat as new element
  6633. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6634. }
  6635. }
  6636. newStartVnode = newCh[++newStartIdx];
  6637. }
  6638. }
  6639. if (oldStartIdx > oldEndIdx) {
  6640. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6641. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6642. }
  6643. else if (newStartIdx > newEndIdx) {
  6644. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6645. }
  6646. }
  6647. function checkDuplicateKeys(children) {
  6648. const seenKeys = {};
  6649. for (let i = 0; i < children.length; i++) {
  6650. const vnode = children[i];
  6651. const key = vnode.key;
  6652. if (isDef(key)) {
  6653. if (seenKeys[key]) {
  6654. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6655. }
  6656. else {
  6657. seenKeys[key] = true;
  6658. }
  6659. }
  6660. }
  6661. }
  6662. function findIdxInOld(node, oldCh, start, end) {
  6663. for (let i = start; i < end; i++) {
  6664. const c = oldCh[i];
  6665. if (isDef(c) && sameVnode(node, c))
  6666. return i;
  6667. }
  6668. }
  6669. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6670. if (oldVnode === vnode) {
  6671. return;
  6672. }
  6673. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6674. // clone reused vnode
  6675. vnode = ownerArray[index] = cloneVNode(vnode);
  6676. }
  6677. const elm = (vnode.elm = oldVnode.elm);
  6678. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6679. if (isDef(vnode.asyncFactory.resolved)) {
  6680. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6681. }
  6682. else {
  6683. vnode.isAsyncPlaceholder = true;
  6684. }
  6685. return;
  6686. }
  6687. // reuse element for static trees.
  6688. // note we only do this if the vnode is cloned -
  6689. // if the new node is not cloned it means the render functions have been
  6690. // reset by the hot-reload-api and we need to do a proper re-render.
  6691. if (isTrue(vnode.isStatic) &&
  6692. isTrue(oldVnode.isStatic) &&
  6693. vnode.key === oldVnode.key &&
  6694. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6695. vnode.componentInstance = oldVnode.componentInstance;
  6696. return;
  6697. }
  6698. let i;
  6699. const data = vnode.data;
  6700. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6701. i(oldVnode, vnode);
  6702. }
  6703. const oldCh = oldVnode.children;
  6704. const ch = vnode.children;
  6705. if (isDef(data) && isPatchable(vnode)) {
  6706. for (i = 0; i < cbs.update.length; ++i)
  6707. cbs.update[i](oldVnode, vnode);
  6708. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6709. i(oldVnode, vnode);
  6710. }
  6711. if (isUndef(vnode.text)) {
  6712. if (isDef(oldCh) && isDef(ch)) {
  6713. if (oldCh !== ch)
  6714. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6715. }
  6716. else if (isDef(ch)) {
  6717. {
  6718. checkDuplicateKeys(ch);
  6719. }
  6720. if (isDef(oldVnode.text))
  6721. nodeOps.setTextContent(elm, '');
  6722. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6723. }
  6724. else if (isDef(oldCh)) {
  6725. removeVnodes(oldCh, 0, oldCh.length - 1);
  6726. }
  6727. else if (isDef(oldVnode.text)) {
  6728. nodeOps.setTextContent(elm, '');
  6729. }
  6730. }
  6731. else if (oldVnode.text !== vnode.text) {
  6732. nodeOps.setTextContent(elm, vnode.text);
  6733. }
  6734. if (isDef(data)) {
  6735. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6736. i(oldVnode, vnode);
  6737. }
  6738. }
  6739. function invokeInsertHook(vnode, queue, initial) {
  6740. // delay insert hooks for component root nodes, invoke them after the
  6741. // element is really inserted
  6742. if (isTrue(initial) && isDef(vnode.parent)) {
  6743. vnode.parent.data.pendingInsert = queue;
  6744. }
  6745. else {
  6746. for (let i = 0; i < queue.length; ++i) {
  6747. queue[i].data.hook.insert(queue[i]);
  6748. }
  6749. }
  6750. }
  6751. let hydrationBailed = false;
  6752. // list of modules that can skip create hook during hydration because they
  6753. // are already rendered on the client or has no need for initialization
  6754. // Note: style is excluded because it relies on initial clone for future
  6755. // deep updates (#7063).
  6756. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6757. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6758. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6759. let i;
  6760. const { tag, data, children } = vnode;
  6761. inVPre = inVPre || (data && data.pre);
  6762. vnode.elm = elm;
  6763. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6764. vnode.isAsyncPlaceholder = true;
  6765. return true;
  6766. }
  6767. // assert node match
  6768. {
  6769. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6770. return false;
  6771. }
  6772. }
  6773. if (isDef(data)) {
  6774. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6775. i(vnode, true /* hydrating */);
  6776. if (isDef((i = vnode.componentInstance))) {
  6777. // child component. it should have hydrated its own tree.
  6778. initComponent(vnode, insertedVnodeQueue);
  6779. return true;
  6780. }
  6781. }
  6782. if (isDef(tag)) {
  6783. if (isDef(children)) {
  6784. // empty element, allow client to pick up and populate children
  6785. if (!elm.hasChildNodes()) {
  6786. createChildren(vnode, children, insertedVnodeQueue);
  6787. }
  6788. else {
  6789. // v-html and domProps: innerHTML
  6790. if (isDef((i = data)) &&
  6791. isDef((i = i.domProps)) &&
  6792. isDef((i = i.innerHTML))) {
  6793. if (i !== elm.innerHTML) {
  6794. /* istanbul ignore if */
  6795. if (typeof console !== 'undefined' &&
  6796. !hydrationBailed) {
  6797. hydrationBailed = true;
  6798. console.warn('Parent: ', elm);
  6799. console.warn('server innerHTML: ', i);
  6800. console.warn('client innerHTML: ', elm.innerHTML);
  6801. }
  6802. return false;
  6803. }
  6804. }
  6805. else {
  6806. // iterate and compare children lists
  6807. let childrenMatch = true;
  6808. let childNode = elm.firstChild;
  6809. for (let i = 0; i < children.length; i++) {
  6810. if (!childNode ||
  6811. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6812. childrenMatch = false;
  6813. break;
  6814. }
  6815. childNode = childNode.nextSibling;
  6816. }
  6817. // if childNode is not null, it means the actual childNodes list is
  6818. // longer than the virtual children list.
  6819. if (!childrenMatch || childNode) {
  6820. /* istanbul ignore if */
  6821. if (typeof console !== 'undefined' &&
  6822. !hydrationBailed) {
  6823. hydrationBailed = true;
  6824. console.warn('Parent: ', elm);
  6825. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6826. }
  6827. return false;
  6828. }
  6829. }
  6830. }
  6831. }
  6832. if (isDef(data)) {
  6833. let fullInvoke = false;
  6834. for (const key in data) {
  6835. if (!isRenderedModule(key)) {
  6836. fullInvoke = true;
  6837. invokeCreateHooks(vnode, insertedVnodeQueue);
  6838. break;
  6839. }
  6840. }
  6841. if (!fullInvoke && data['class']) {
  6842. // ensure collecting deps for deep class bindings for future updates
  6843. traverse(data['class']);
  6844. }
  6845. }
  6846. }
  6847. else if (elm.data !== vnode.text) {
  6848. elm.data = vnode.text;
  6849. }
  6850. return true;
  6851. }
  6852. function assertNodeMatch(node, vnode, inVPre) {
  6853. if (isDef(vnode.tag)) {
  6854. return (vnode.tag.indexOf('vue-component') === 0 ||
  6855. (!isUnknownElement(vnode, inVPre) &&
  6856. vnode.tag.toLowerCase() ===
  6857. (node.tagName && node.tagName.toLowerCase())));
  6858. }
  6859. else {
  6860. return node.nodeType === (vnode.isComment ? 8 : 3);
  6861. }
  6862. }
  6863. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6864. if (isUndef(vnode)) {
  6865. if (isDef(oldVnode))
  6866. invokeDestroyHook(oldVnode);
  6867. return;
  6868. }
  6869. let isInitialPatch = false;
  6870. const insertedVnodeQueue = [];
  6871. if (isUndef(oldVnode)) {
  6872. // empty mount (likely as component), create new root element
  6873. isInitialPatch = true;
  6874. createElm(vnode, insertedVnodeQueue);
  6875. }
  6876. else {
  6877. const isRealElement = isDef(oldVnode.nodeType);
  6878. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6879. // patch existing root node
  6880. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6881. }
  6882. else {
  6883. if (isRealElement) {
  6884. // mounting to a real element
  6885. // check if this is server-rendered content and if we can perform
  6886. // a successful hydration.
  6887. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6888. oldVnode.removeAttribute(SSR_ATTR);
  6889. hydrating = true;
  6890. }
  6891. if (isTrue(hydrating)) {
  6892. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6893. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6894. return oldVnode;
  6895. }
  6896. else {
  6897. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6898. 'server-rendered content. This is likely caused by incorrect ' +
  6899. 'HTML markup, for example nesting block-level elements inside ' +
  6900. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6901. 'full client-side render.');
  6902. }
  6903. }
  6904. // either not server-rendered, or hydration failed.
  6905. // create an empty node and replace it
  6906. oldVnode = emptyNodeAt(oldVnode);
  6907. }
  6908. // replacing existing element
  6909. const oldElm = oldVnode.elm;
  6910. const parentElm = nodeOps.parentNode(oldElm);
  6911. // create new node
  6912. createElm(vnode, insertedVnodeQueue,
  6913. // extremely rare edge case: do not insert if old element is in a
  6914. // leaving transition. Only happens when combining transition +
  6915. // keep-alive + HOCs. (#4590)
  6916. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6917. // update parent placeholder node element, recursively
  6918. if (isDef(vnode.parent)) {
  6919. let ancestor = vnode.parent;
  6920. const patchable = isPatchable(vnode);
  6921. while (ancestor) {
  6922. for (let i = 0; i < cbs.destroy.length; ++i) {
  6923. cbs.destroy[i](ancestor);
  6924. }
  6925. ancestor.elm = vnode.elm;
  6926. if (patchable) {
  6927. for (let i = 0; i < cbs.create.length; ++i) {
  6928. cbs.create[i](emptyNode, ancestor);
  6929. }
  6930. // #6513
  6931. // invoke insert hooks that may have been merged by create hooks.
  6932. // e.g. for directives that uses the "inserted" hook.
  6933. const insert = ancestor.data.hook.insert;
  6934. if (insert.merged) {
  6935. // start at index 1 to avoid re-invoking component mounted hook
  6936. // clone insert hooks to avoid being mutated during iteration.
  6937. // e.g. for customed directives under transition group.
  6938. const cloned = insert.fns.slice(1);
  6939. for (let i = 0; i < cloned.length; i++) {
  6940. cloned[i]();
  6941. }
  6942. }
  6943. }
  6944. else {
  6945. registerRef(ancestor);
  6946. }
  6947. ancestor = ancestor.parent;
  6948. }
  6949. }
  6950. // destroy old node
  6951. if (isDef(parentElm)) {
  6952. removeVnodes([oldVnode], 0, 0);
  6953. }
  6954. else if (isDef(oldVnode.tag)) {
  6955. invokeDestroyHook(oldVnode);
  6956. }
  6957. }
  6958. }
  6959. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6960. return vnode.elm;
  6961. };
  6962. }
  6963. var directives$1 = {
  6964. create: updateDirectives,
  6965. update: updateDirectives,
  6966. destroy: function unbindDirectives(vnode) {
  6967. // @ts-expect-error emptyNode is not VNodeWithData
  6968. updateDirectives(vnode, emptyNode);
  6969. }
  6970. };
  6971. function updateDirectives(oldVnode, vnode) {
  6972. if (oldVnode.data.directives || vnode.data.directives) {
  6973. _update(oldVnode, vnode);
  6974. }
  6975. }
  6976. function _update(oldVnode, vnode) {
  6977. const isCreate = oldVnode === emptyNode;
  6978. const isDestroy = vnode === emptyNode;
  6979. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  6980. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  6981. const dirsWithInsert = [];
  6982. const dirsWithPostpatch = [];
  6983. let key, oldDir, dir;
  6984. for (key in newDirs) {
  6985. oldDir = oldDirs[key];
  6986. dir = newDirs[key];
  6987. if (!oldDir) {
  6988. // new directive, bind
  6989. callHook(dir, 'bind', vnode, oldVnode);
  6990. if (dir.def && dir.def.inserted) {
  6991. dirsWithInsert.push(dir);
  6992. }
  6993. }
  6994. else {
  6995. // existing directive, update
  6996. dir.oldValue = oldDir.value;
  6997. dir.oldArg = oldDir.arg;
  6998. callHook(dir, 'update', vnode, oldVnode);
  6999. if (dir.def && dir.def.componentUpdated) {
  7000. dirsWithPostpatch.push(dir);
  7001. }
  7002. }
  7003. }
  7004. if (dirsWithInsert.length) {
  7005. const callInsert = () => {
  7006. for (let i = 0; i < dirsWithInsert.length; i++) {
  7007. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7008. }
  7009. };
  7010. if (isCreate) {
  7011. mergeVNodeHook(vnode, 'insert', callInsert);
  7012. }
  7013. else {
  7014. callInsert();
  7015. }
  7016. }
  7017. if (dirsWithPostpatch.length) {
  7018. mergeVNodeHook(vnode, 'postpatch', () => {
  7019. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7020. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7021. }
  7022. });
  7023. }
  7024. if (!isCreate) {
  7025. for (key in oldDirs) {
  7026. if (!newDirs[key]) {
  7027. // no longer present, unbind
  7028. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7029. }
  7030. }
  7031. }
  7032. }
  7033. const emptyModifiers = Object.create(null);
  7034. function normalizeDirectives(dirs, vm) {
  7035. const res = Object.create(null);
  7036. if (!dirs) {
  7037. // $flow-disable-line
  7038. return res;
  7039. }
  7040. let i, dir;
  7041. for (i = 0; i < dirs.length; i++) {
  7042. dir = dirs[i];
  7043. if (!dir.modifiers) {
  7044. // $flow-disable-line
  7045. dir.modifiers = emptyModifiers;
  7046. }
  7047. res[getRawDirName(dir)] = dir;
  7048. if (vm._setupState && vm._setupState.__sfc) {
  7049. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7050. if (typeof setupDef === 'function') {
  7051. dir.def = {
  7052. bind: setupDef,
  7053. update: setupDef,
  7054. };
  7055. }
  7056. else {
  7057. dir.def = setupDef;
  7058. }
  7059. }
  7060. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7061. }
  7062. // $flow-disable-line
  7063. return res;
  7064. }
  7065. function getRawDirName(dir) {
  7066. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7067. }
  7068. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7069. const fn = dir.def && dir.def[hook];
  7070. if (fn) {
  7071. try {
  7072. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7073. }
  7074. catch (e) {
  7075. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7076. }
  7077. }
  7078. }
  7079. var baseModules = [ref, directives$1];
  7080. function updateAttrs(oldVnode, vnode) {
  7081. const opts = vnode.componentOptions;
  7082. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7083. return;
  7084. }
  7085. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7086. return;
  7087. }
  7088. let key, cur, old;
  7089. const elm = vnode.elm;
  7090. const oldAttrs = oldVnode.data.attrs || {};
  7091. let attrs = vnode.data.attrs || {};
  7092. // clone observed objects, as the user probably wants to mutate it
  7093. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7094. attrs = vnode.data.attrs = extend({}, attrs);
  7095. }
  7096. for (key in attrs) {
  7097. cur = attrs[key];
  7098. old = oldAttrs[key];
  7099. if (old !== cur) {
  7100. setAttr(elm, key, cur, vnode.data.pre);
  7101. }
  7102. }
  7103. // #4391: in IE9, setting type can reset value for input[type=radio]
  7104. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7105. /* istanbul ignore if */
  7106. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7107. setAttr(elm, 'value', attrs.value);
  7108. }
  7109. for (key in oldAttrs) {
  7110. if (isUndef(attrs[key])) {
  7111. if (isXlink(key)) {
  7112. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7113. }
  7114. else if (!isEnumeratedAttr(key)) {
  7115. elm.removeAttribute(key);
  7116. }
  7117. }
  7118. }
  7119. }
  7120. function setAttr(el, key, value, isInPre) {
  7121. if (isInPre || el.tagName.indexOf('-') > -1) {
  7122. baseSetAttr(el, key, value);
  7123. }
  7124. else if (isBooleanAttr(key)) {
  7125. // set attribute for blank value
  7126. // e.g. <option disabled>Select one</option>
  7127. if (isFalsyAttrValue(value)) {
  7128. el.removeAttribute(key);
  7129. }
  7130. else {
  7131. // technically allowfullscreen is a boolean attribute for <iframe>,
  7132. // but Flash expects a value of "true" when used on <embed> tag
  7133. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7134. el.setAttribute(key, value);
  7135. }
  7136. }
  7137. else if (isEnumeratedAttr(key)) {
  7138. el.setAttribute(key, convertEnumeratedValue(key, value));
  7139. }
  7140. else if (isXlink(key)) {
  7141. if (isFalsyAttrValue(value)) {
  7142. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7143. }
  7144. else {
  7145. el.setAttributeNS(xlinkNS, key, value);
  7146. }
  7147. }
  7148. else {
  7149. baseSetAttr(el, key, value);
  7150. }
  7151. }
  7152. function baseSetAttr(el, key, value) {
  7153. if (isFalsyAttrValue(value)) {
  7154. el.removeAttribute(key);
  7155. }
  7156. else {
  7157. // #7138: IE10 & 11 fires input event when setting placeholder on
  7158. // <textarea>... block the first input event and remove the blocker
  7159. // immediately.
  7160. /* istanbul ignore if */
  7161. if (isIE &&
  7162. !isIE9 &&
  7163. el.tagName === 'TEXTAREA' &&
  7164. key === 'placeholder' &&
  7165. value !== '' &&
  7166. !el.__ieph) {
  7167. const blocker = e => {
  7168. e.stopImmediatePropagation();
  7169. el.removeEventListener('input', blocker);
  7170. };
  7171. el.addEventListener('input', blocker);
  7172. // $flow-disable-line
  7173. el.__ieph = true; /* IE placeholder patched */
  7174. }
  7175. el.setAttribute(key, value);
  7176. }
  7177. }
  7178. var attrs = {
  7179. create: updateAttrs,
  7180. update: updateAttrs
  7181. };
  7182. function updateClass(oldVnode, vnode) {
  7183. const el = vnode.elm;
  7184. const data = vnode.data;
  7185. const oldData = oldVnode.data;
  7186. if (isUndef(data.staticClass) &&
  7187. isUndef(data.class) &&
  7188. (isUndef(oldData) ||
  7189. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7190. return;
  7191. }
  7192. let cls = genClassForVnode(vnode);
  7193. // handle transition classes
  7194. const transitionClass = el._transitionClasses;
  7195. if (isDef(transitionClass)) {
  7196. cls = concat(cls, stringifyClass(transitionClass));
  7197. }
  7198. // set the class
  7199. if (cls !== el._prevClass) {
  7200. el.setAttribute('class', cls);
  7201. el._prevClass = cls;
  7202. }
  7203. }
  7204. var klass$1 = {
  7205. create: updateClass,
  7206. update: updateClass
  7207. };
  7208. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7209. function parseFilters(exp) {
  7210. let inSingle = false;
  7211. let inDouble = false;
  7212. let inTemplateString = false;
  7213. let inRegex = false;
  7214. let curly = 0;
  7215. let square = 0;
  7216. let paren = 0;
  7217. let lastFilterIndex = 0;
  7218. let c, prev, i, expression, filters;
  7219. for (i = 0; i < exp.length; i++) {
  7220. prev = c;
  7221. c = exp.charCodeAt(i);
  7222. if (inSingle) {
  7223. if (c === 0x27 && prev !== 0x5c)
  7224. inSingle = false;
  7225. }
  7226. else if (inDouble) {
  7227. if (c === 0x22 && prev !== 0x5c)
  7228. inDouble = false;
  7229. }
  7230. else if (inTemplateString) {
  7231. if (c === 0x60 && prev !== 0x5c)
  7232. inTemplateString = false;
  7233. }
  7234. else if (inRegex) {
  7235. if (c === 0x2f && prev !== 0x5c)
  7236. inRegex = false;
  7237. }
  7238. else if (c === 0x7c && // pipe
  7239. exp.charCodeAt(i + 1) !== 0x7c &&
  7240. exp.charCodeAt(i - 1) !== 0x7c &&
  7241. !curly &&
  7242. !square &&
  7243. !paren) {
  7244. if (expression === undefined) {
  7245. // first filter, end of expression
  7246. lastFilterIndex = i + 1;
  7247. expression = exp.slice(0, i).trim();
  7248. }
  7249. else {
  7250. pushFilter();
  7251. }
  7252. }
  7253. else {
  7254. switch (c) {
  7255. case 0x22:
  7256. inDouble = true;
  7257. break; // "
  7258. case 0x27:
  7259. inSingle = true;
  7260. break; // '
  7261. case 0x60:
  7262. inTemplateString = true;
  7263. break; // `
  7264. case 0x28:
  7265. paren++;
  7266. break; // (
  7267. case 0x29:
  7268. paren--;
  7269. break; // )
  7270. case 0x5b:
  7271. square++;
  7272. break; // [
  7273. case 0x5d:
  7274. square--;
  7275. break; // ]
  7276. case 0x7b:
  7277. curly++;
  7278. break; // {
  7279. case 0x7d:
  7280. curly--;
  7281. break; // }
  7282. }
  7283. if (c === 0x2f) {
  7284. // /
  7285. let j = i - 1;
  7286. let p;
  7287. // find first non-whitespace prev char
  7288. for (; j >= 0; j--) {
  7289. p = exp.charAt(j);
  7290. if (p !== ' ')
  7291. break;
  7292. }
  7293. if (!p || !validDivisionCharRE.test(p)) {
  7294. inRegex = true;
  7295. }
  7296. }
  7297. }
  7298. }
  7299. if (expression === undefined) {
  7300. expression = exp.slice(0, i).trim();
  7301. }
  7302. else if (lastFilterIndex !== 0) {
  7303. pushFilter();
  7304. }
  7305. function pushFilter() {
  7306. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7307. lastFilterIndex = i + 1;
  7308. }
  7309. if (filters) {
  7310. for (i = 0; i < filters.length; i++) {
  7311. expression = wrapFilter(expression, filters[i]);
  7312. }
  7313. }
  7314. return expression;
  7315. }
  7316. function wrapFilter(exp, filter) {
  7317. const i = filter.indexOf('(');
  7318. if (i < 0) {
  7319. // _f: resolveFilter
  7320. return `_f("${filter}")(${exp})`;
  7321. }
  7322. else {
  7323. const name = filter.slice(0, i);
  7324. const args = filter.slice(i + 1);
  7325. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7326. }
  7327. }
  7328. /* eslint-disable no-unused-vars */
  7329. function baseWarn(msg, range) {
  7330. console.error(`[Vue compiler]: ${msg}`);
  7331. }
  7332. /* eslint-enable no-unused-vars */
  7333. function pluckModuleFunction(modules, key) {
  7334. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7335. }
  7336. function addProp(el, name, value, range, dynamic) {
  7337. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7338. el.plain = false;
  7339. }
  7340. function addAttr(el, name, value, range, dynamic) {
  7341. const attrs = dynamic
  7342. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7343. : el.attrs || (el.attrs = []);
  7344. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7345. el.plain = false;
  7346. }
  7347. // add a raw attr (use this in preTransforms)
  7348. function addRawAttr(el, name, value, range) {
  7349. el.attrsMap[name] = value;
  7350. el.attrsList.push(rangeSetItem({ name, value }, range));
  7351. }
  7352. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7353. (el.directives || (el.directives = [])).push(rangeSetItem({
  7354. name,
  7355. rawName,
  7356. value,
  7357. arg,
  7358. isDynamicArg,
  7359. modifiers
  7360. }, range));
  7361. el.plain = false;
  7362. }
  7363. function prependModifierMarker(symbol, name, dynamic) {
  7364. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7365. }
  7366. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7367. modifiers = modifiers || emptyObject;
  7368. // warn prevent and passive modifier
  7369. /* istanbul ignore if */
  7370. if (warn && modifiers.prevent && modifiers.passive) {
  7371. warn("passive and prevent can't be used together. " +
  7372. "Passive handler can't prevent default event.", range);
  7373. }
  7374. // normalize click.right and click.middle since they don't actually fire
  7375. // this is technically browser-specific, but at least for now browsers are
  7376. // the only target envs that have right/middle clicks.
  7377. if (modifiers.right) {
  7378. if (dynamic) {
  7379. name = `(${name})==='click'?'contextmenu':(${name})`;
  7380. }
  7381. else if (name === 'click') {
  7382. name = 'contextmenu';
  7383. delete modifiers.right;
  7384. }
  7385. }
  7386. else if (modifiers.middle) {
  7387. if (dynamic) {
  7388. name = `(${name})==='click'?'mouseup':(${name})`;
  7389. }
  7390. else if (name === 'click') {
  7391. name = 'mouseup';
  7392. }
  7393. }
  7394. // check capture modifier
  7395. if (modifiers.capture) {
  7396. delete modifiers.capture;
  7397. name = prependModifierMarker('!', name, dynamic);
  7398. }
  7399. if (modifiers.once) {
  7400. delete modifiers.once;
  7401. name = prependModifierMarker('~', name, dynamic);
  7402. }
  7403. /* istanbul ignore if */
  7404. if (modifiers.passive) {
  7405. delete modifiers.passive;
  7406. name = prependModifierMarker('&', name, dynamic);
  7407. }
  7408. let events;
  7409. if (modifiers.native) {
  7410. delete modifiers.native;
  7411. events = el.nativeEvents || (el.nativeEvents = {});
  7412. }
  7413. else {
  7414. events = el.events || (el.events = {});
  7415. }
  7416. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7417. if (modifiers !== emptyObject) {
  7418. newHandler.modifiers = modifiers;
  7419. }
  7420. const handlers = events[name];
  7421. /* istanbul ignore if */
  7422. if (Array.isArray(handlers)) {
  7423. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7424. }
  7425. else if (handlers) {
  7426. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7427. }
  7428. else {
  7429. events[name] = newHandler;
  7430. }
  7431. el.plain = false;
  7432. }
  7433. function getRawBindingAttr(el, name) {
  7434. return (el.rawAttrsMap[':' + name] ||
  7435. el.rawAttrsMap['v-bind:' + name] ||
  7436. el.rawAttrsMap[name]);
  7437. }
  7438. function getBindingAttr(el, name, getStatic) {
  7439. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7440. if (dynamicValue != null) {
  7441. return parseFilters(dynamicValue);
  7442. }
  7443. else if (getStatic !== false) {
  7444. const staticValue = getAndRemoveAttr(el, name);
  7445. if (staticValue != null) {
  7446. return JSON.stringify(staticValue);
  7447. }
  7448. }
  7449. }
  7450. // note: this only removes the attr from the Array (attrsList) so that it
  7451. // doesn't get processed by processAttrs.
  7452. // By default it does NOT remove it from the map (attrsMap) because the map is
  7453. // needed during codegen.
  7454. function getAndRemoveAttr(el, name, removeFromMap) {
  7455. let val;
  7456. if ((val = el.attrsMap[name]) != null) {
  7457. const list = el.attrsList;
  7458. for (let i = 0, l = list.length; i < l; i++) {
  7459. if (list[i].name === name) {
  7460. list.splice(i, 1);
  7461. break;
  7462. }
  7463. }
  7464. }
  7465. if (removeFromMap) {
  7466. delete el.attrsMap[name];
  7467. }
  7468. return val;
  7469. }
  7470. function getAndRemoveAttrByRegex(el, name) {
  7471. const list = el.attrsList;
  7472. for (let i = 0, l = list.length; i < l; i++) {
  7473. const attr = list[i];
  7474. if (name.test(attr.name)) {
  7475. list.splice(i, 1);
  7476. return attr;
  7477. }
  7478. }
  7479. }
  7480. function rangeSetItem(item, range) {
  7481. if (range) {
  7482. if (range.start != null) {
  7483. item.start = range.start;
  7484. }
  7485. if (range.end != null) {
  7486. item.end = range.end;
  7487. }
  7488. }
  7489. return item;
  7490. }
  7491. /**
  7492. * Cross-platform code generation for component v-model
  7493. */
  7494. function genComponentModel(el, value, modifiers) {
  7495. const { number, trim } = modifiers || {};
  7496. const baseValueExpression = '$$v';
  7497. let valueExpression = baseValueExpression;
  7498. if (trim) {
  7499. valueExpression =
  7500. `(typeof ${baseValueExpression} === 'string'` +
  7501. `? ${baseValueExpression}.trim()` +
  7502. `: ${baseValueExpression})`;
  7503. }
  7504. if (number) {
  7505. valueExpression = `_n(${valueExpression})`;
  7506. }
  7507. const assignment = genAssignmentCode(value, valueExpression);
  7508. el.model = {
  7509. value: `(${value})`,
  7510. expression: JSON.stringify(value),
  7511. callback: `function (${baseValueExpression}) {${assignment}}`
  7512. };
  7513. }
  7514. /**
  7515. * Cross-platform codegen helper for generating v-model value assignment code.
  7516. */
  7517. function genAssignmentCode(value, assignment) {
  7518. const res = parseModel(value);
  7519. if (res.key === null) {
  7520. return `${value}=${assignment}`;
  7521. }
  7522. else {
  7523. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7524. }
  7525. }
  7526. /**
  7527. * Parse a v-model expression into a base path and a final key segment.
  7528. * Handles both dot-path and possible square brackets.
  7529. *
  7530. * Possible cases:
  7531. *
  7532. * - test
  7533. * - test[key]
  7534. * - test[test1[key]]
  7535. * - test["a"][key]
  7536. * - xxx.test[a[a].test1[key]]
  7537. * - test.xxx.a["asa"][test1[key]]
  7538. *
  7539. */
  7540. let len, str, chr, index, expressionPos, expressionEndPos;
  7541. function parseModel(val) {
  7542. // Fix https://github.com/vuejs/vue/pull/7730
  7543. // allow v-model="obj.val " (trailing whitespace)
  7544. val = val.trim();
  7545. len = val.length;
  7546. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7547. index = val.lastIndexOf('.');
  7548. if (index > -1) {
  7549. return {
  7550. exp: val.slice(0, index),
  7551. key: '"' + val.slice(index + 1) + '"'
  7552. };
  7553. }
  7554. else {
  7555. return {
  7556. exp: val,
  7557. key: null
  7558. };
  7559. }
  7560. }
  7561. str = val;
  7562. index = expressionPos = expressionEndPos = 0;
  7563. while (!eof()) {
  7564. chr = next();
  7565. /* istanbul ignore if */
  7566. if (isStringStart(chr)) {
  7567. parseString(chr);
  7568. }
  7569. else if (chr === 0x5b) {
  7570. parseBracket(chr);
  7571. }
  7572. }
  7573. return {
  7574. exp: val.slice(0, expressionPos),
  7575. key: val.slice(expressionPos + 1, expressionEndPos)
  7576. };
  7577. }
  7578. function next() {
  7579. return str.charCodeAt(++index);
  7580. }
  7581. function eof() {
  7582. return index >= len;
  7583. }
  7584. function isStringStart(chr) {
  7585. return chr === 0x22 || chr === 0x27;
  7586. }
  7587. function parseBracket(chr) {
  7588. let inBracket = 1;
  7589. expressionPos = index;
  7590. while (!eof()) {
  7591. chr = next();
  7592. if (isStringStart(chr)) {
  7593. parseString(chr);
  7594. continue;
  7595. }
  7596. if (chr === 0x5b)
  7597. inBracket++;
  7598. if (chr === 0x5d)
  7599. inBracket--;
  7600. if (inBracket === 0) {
  7601. expressionEndPos = index;
  7602. break;
  7603. }
  7604. }
  7605. }
  7606. function parseString(chr) {
  7607. const stringQuote = chr;
  7608. while (!eof()) {
  7609. chr = next();
  7610. if (chr === stringQuote) {
  7611. break;
  7612. }
  7613. }
  7614. }
  7615. let warn$1;
  7616. // in some cases, the event used has to be determined at runtime
  7617. // so we used some reserved tokens during compile.
  7618. const RANGE_TOKEN = '__r';
  7619. const CHECKBOX_RADIO_TOKEN = '__c';
  7620. function model$1(el, dir, _warn) {
  7621. warn$1 = _warn;
  7622. const value = dir.value;
  7623. const modifiers = dir.modifiers;
  7624. const tag = el.tag;
  7625. const type = el.attrsMap.type;
  7626. {
  7627. // inputs with type="file" are read only and setting the input's
  7628. // value will throw an error.
  7629. if (tag === 'input' && type === 'file') {
  7630. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7631. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7632. }
  7633. }
  7634. if (el.component) {
  7635. genComponentModel(el, value, modifiers);
  7636. // component v-model doesn't need extra runtime
  7637. return false;
  7638. }
  7639. else if (tag === 'select') {
  7640. genSelect(el, value, modifiers);
  7641. }
  7642. else if (tag === 'input' && type === 'checkbox') {
  7643. genCheckboxModel(el, value, modifiers);
  7644. }
  7645. else if (tag === 'input' && type === 'radio') {
  7646. genRadioModel(el, value, modifiers);
  7647. }
  7648. else if (tag === 'input' || tag === 'textarea') {
  7649. genDefaultModel(el, value, modifiers);
  7650. }
  7651. else if (!config.isReservedTag(tag)) {
  7652. genComponentModel(el, value, modifiers);
  7653. // component v-model doesn't need extra runtime
  7654. return false;
  7655. }
  7656. else {
  7657. warn$1(`<${el.tag} v-model="${value}">: ` +
  7658. `v-model is not supported on this element type. ` +
  7659. "If you are working with contenteditable, it's recommended to " +
  7660. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7661. }
  7662. // ensure runtime directive metadata
  7663. return true;
  7664. }
  7665. function genCheckboxModel(el, value, modifiers) {
  7666. const number = modifiers && modifiers.number;
  7667. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7668. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7669. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7670. addProp(el, 'checked', `Array.isArray(${value})` +
  7671. `?_i(${value},${valueBinding})>-1` +
  7672. (trueValueBinding === 'true'
  7673. ? `:(${value})`
  7674. : `:_q(${value},${trueValueBinding})`));
  7675. addHandler(el, 'change', `var $$a=${value},` +
  7676. '$$el=$event.target,' +
  7677. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7678. 'if(Array.isArray($$a)){' +
  7679. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7680. '$$i=_i($$a,$$v);' +
  7681. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7682. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7683. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7684. }
  7685. function genRadioModel(el, value, modifiers) {
  7686. const number = modifiers && modifiers.number;
  7687. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7688. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7689. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7690. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7691. }
  7692. function genSelect(el, value, modifiers) {
  7693. const number = modifiers && modifiers.number;
  7694. const selectedVal = `Array.prototype.filter` +
  7695. `.call($event.target.options,function(o){return o.selected})` +
  7696. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7697. `return ${number ? '_n(val)' : 'val'}})`;
  7698. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7699. let code = `var $$selectedVal = ${selectedVal};`;
  7700. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7701. addHandler(el, 'change', code, null, true);
  7702. }
  7703. function genDefaultModel(el, value, modifiers) {
  7704. const type = el.attrsMap.type;
  7705. // warn if v-bind:value conflicts with v-model
  7706. // except for inputs with v-bind:type
  7707. {
  7708. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7709. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7710. if (value && !typeBinding) {
  7711. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7712. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7713. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7714. }
  7715. }
  7716. const { lazy, number, trim } = modifiers || {};
  7717. const needCompositionGuard = !lazy && type !== 'range';
  7718. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7719. let valueExpression = '$event.target.value';
  7720. if (trim) {
  7721. valueExpression = `$event.target.value.trim()`;
  7722. }
  7723. if (number) {
  7724. valueExpression = `_n(${valueExpression})`;
  7725. }
  7726. let code = genAssignmentCode(value, valueExpression);
  7727. if (needCompositionGuard) {
  7728. code = `if($event.target.composing)return;${code}`;
  7729. }
  7730. addProp(el, 'value', `(${value})`);
  7731. addHandler(el, event, code, null, true);
  7732. if (trim || number) {
  7733. addHandler(el, 'blur', '$forceUpdate()');
  7734. }
  7735. }
  7736. // normalize v-model event tokens that can only be determined at runtime.
  7737. // it's important to place the event as the first in the array because
  7738. // the whole point is ensuring the v-model callback gets called before
  7739. // user-attached handlers.
  7740. function normalizeEvents(on) {
  7741. /* istanbul ignore if */
  7742. if (isDef(on[RANGE_TOKEN])) {
  7743. // IE input[type=range] only supports `change` event
  7744. const event = isIE ? 'change' : 'input';
  7745. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7746. delete on[RANGE_TOKEN];
  7747. }
  7748. // This was originally intended to fix #4521 but no longer necessary
  7749. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7750. /* istanbul ignore if */
  7751. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7752. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7753. delete on[CHECKBOX_RADIO_TOKEN];
  7754. }
  7755. }
  7756. let target;
  7757. function createOnceHandler(event, handler, capture) {
  7758. const _target = target; // save current target element in closure
  7759. return function onceHandler() {
  7760. const res = handler.apply(null, arguments);
  7761. if (res !== null) {
  7762. remove(event, onceHandler, capture, _target);
  7763. }
  7764. };
  7765. }
  7766. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7767. // implementation and does not fire microtasks in between event propagation, so
  7768. // safe to exclude.
  7769. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7770. function add(name, handler, capture, passive) {
  7771. // async edge case #6566: inner click event triggers patch, event handler
  7772. // attached to outer element during patch, and triggered again. This
  7773. // happens because browsers fire microtask ticks between event propagation.
  7774. // the solution is simple: we save the timestamp when a handler is attached,
  7775. // and the handler would only fire if the event passed to it was fired
  7776. // AFTER it was attached.
  7777. if (useMicrotaskFix) {
  7778. const attachedTimestamp = currentFlushTimestamp;
  7779. const original = handler;
  7780. //@ts-expect-error
  7781. handler = original._wrapper = function (e) {
  7782. if (
  7783. // no bubbling, should always fire.
  7784. // this is just a safety net in case event.timeStamp is unreliable in
  7785. // certain weird environments...
  7786. e.target === e.currentTarget ||
  7787. // event is fired after handler attachment
  7788. e.timeStamp >= attachedTimestamp ||
  7789. // bail for environments that have buggy event.timeStamp implementations
  7790. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7791. // #9681 QtWebEngine event.timeStamp is negative value
  7792. e.timeStamp <= 0 ||
  7793. // #9448 bail if event is fired in another document in a multi-page
  7794. // electron/nw.js app, since event.timeStamp will be using a different
  7795. // starting reference
  7796. e.target.ownerDocument !== document) {
  7797. return original.apply(this, arguments);
  7798. }
  7799. };
  7800. }
  7801. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7802. }
  7803. function remove(name, handler, capture, _target) {
  7804. (_target || target).removeEventListener(name,
  7805. //@ts-expect-error
  7806. handler._wrapper || handler, capture);
  7807. }
  7808. function updateDOMListeners(oldVnode, vnode) {
  7809. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7810. return;
  7811. }
  7812. const on = vnode.data.on || {};
  7813. const oldOn = oldVnode.data.on || {};
  7814. // vnode is empty when removing all listeners,
  7815. // and use old vnode dom element
  7816. target = vnode.elm || oldVnode.elm;
  7817. normalizeEvents(on);
  7818. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7819. target = undefined;
  7820. }
  7821. var events = {
  7822. create: updateDOMListeners,
  7823. update: updateDOMListeners,
  7824. // @ts-expect-error emptyNode has actually data
  7825. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7826. };
  7827. let svgContainer;
  7828. function updateDOMProps(oldVnode, vnode) {
  7829. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7830. return;
  7831. }
  7832. let key, cur;
  7833. const elm = vnode.elm;
  7834. const oldProps = oldVnode.data.domProps || {};
  7835. let props = vnode.data.domProps || {};
  7836. // clone observed objects, as the user probably wants to mutate it
  7837. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7838. props = vnode.data.domProps = extend({}, props);
  7839. }
  7840. for (key in oldProps) {
  7841. if (!(key in props)) {
  7842. elm[key] = '';
  7843. }
  7844. }
  7845. for (key in props) {
  7846. cur = props[key];
  7847. // ignore children if the node has textContent or innerHTML,
  7848. // as these will throw away existing DOM nodes and cause removal errors
  7849. // on subsequent patches (#3360)
  7850. if (key === 'textContent' || key === 'innerHTML') {
  7851. if (vnode.children)
  7852. vnode.children.length = 0;
  7853. if (cur === oldProps[key])
  7854. continue;
  7855. // #6601 work around Chrome version <= 55 bug where single textNode
  7856. // replaced by innerHTML/textContent retains its parentNode property
  7857. if (elm.childNodes.length === 1) {
  7858. elm.removeChild(elm.childNodes[0]);
  7859. }
  7860. }
  7861. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7862. // store value as _value as well since
  7863. // non-string values will be stringified
  7864. elm._value = cur;
  7865. // avoid resetting cursor position when value is the same
  7866. const strCur = isUndef(cur) ? '' : String(cur);
  7867. if (shouldUpdateValue(elm, strCur)) {
  7868. elm.value = strCur;
  7869. }
  7870. }
  7871. else if (key === 'innerHTML' &&
  7872. isSVG(elm.tagName) &&
  7873. isUndef(elm.innerHTML)) {
  7874. // IE doesn't support innerHTML for SVG elements
  7875. svgContainer = svgContainer || document.createElement('div');
  7876. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7877. const svg = svgContainer.firstChild;
  7878. while (elm.firstChild) {
  7879. elm.removeChild(elm.firstChild);
  7880. }
  7881. while (svg.firstChild) {
  7882. elm.appendChild(svg.firstChild);
  7883. }
  7884. }
  7885. else if (
  7886. // skip the update if old and new VDOM state is the same.
  7887. // `value` is handled separately because the DOM value may be temporarily
  7888. // out of sync with VDOM state due to focus, composition and modifiers.
  7889. // This #4521 by skipping the unnecessary `checked` update.
  7890. cur !== oldProps[key]) {
  7891. // some property updates can throw
  7892. // e.g. `value` on <progress> w/ non-finite value
  7893. try {
  7894. elm[key] = cur;
  7895. }
  7896. catch (e) { }
  7897. }
  7898. }
  7899. }
  7900. function shouldUpdateValue(elm, checkVal) {
  7901. return (
  7902. //@ts-expect-error
  7903. !elm.composing &&
  7904. (elm.tagName === 'OPTION' ||
  7905. isNotInFocusAndDirty(elm, checkVal) ||
  7906. isDirtyWithModifiers(elm, checkVal)));
  7907. }
  7908. function isNotInFocusAndDirty(elm, checkVal) {
  7909. // return true when textbox (.number and .trim) loses focus and its value is
  7910. // not equal to the updated value
  7911. let notInFocus = true;
  7912. // #6157
  7913. // work around IE bug when accessing document.activeElement in an iframe
  7914. try {
  7915. notInFocus = document.activeElement !== elm;
  7916. }
  7917. catch (e) { }
  7918. return notInFocus && elm.value !== checkVal;
  7919. }
  7920. function isDirtyWithModifiers(elm, newVal) {
  7921. const value = elm.value;
  7922. const modifiers = elm._vModifiers; // injected by v-model runtime
  7923. if (isDef(modifiers)) {
  7924. if (modifiers.number) {
  7925. return toNumber(value) !== toNumber(newVal);
  7926. }
  7927. if (modifiers.trim) {
  7928. return value.trim() !== newVal.trim();
  7929. }
  7930. }
  7931. return value !== newVal;
  7932. }
  7933. var domProps = {
  7934. create: updateDOMProps,
  7935. update: updateDOMProps
  7936. };
  7937. const parseStyleText = cached(function (cssText) {
  7938. const res = {};
  7939. const listDelimiter = /;(?![^(]*\))/g;
  7940. const propertyDelimiter = /:(.+)/;
  7941. cssText.split(listDelimiter).forEach(function (item) {
  7942. if (item) {
  7943. const tmp = item.split(propertyDelimiter);
  7944. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7945. }
  7946. });
  7947. return res;
  7948. });
  7949. // merge static and dynamic style data on the same vnode
  7950. function normalizeStyleData(data) {
  7951. const style = normalizeStyleBinding(data.style);
  7952. // static style is pre-processed into an object during compilation
  7953. // and is always a fresh object, so it's safe to merge into it
  7954. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7955. }
  7956. // normalize possible array / string values into Object
  7957. function normalizeStyleBinding(bindingStyle) {
  7958. if (Array.isArray(bindingStyle)) {
  7959. return toObject(bindingStyle);
  7960. }
  7961. if (typeof bindingStyle === 'string') {
  7962. return parseStyleText(bindingStyle);
  7963. }
  7964. return bindingStyle;
  7965. }
  7966. /**
  7967. * parent component style should be after child's
  7968. * so that parent component's style could override it
  7969. */
  7970. function getStyle(vnode, checkChild) {
  7971. const res = {};
  7972. let styleData;
  7973. if (checkChild) {
  7974. let childNode = vnode;
  7975. while (childNode.componentInstance) {
  7976. childNode = childNode.componentInstance._vnode;
  7977. if (childNode &&
  7978. childNode.data &&
  7979. (styleData = normalizeStyleData(childNode.data))) {
  7980. extend(res, styleData);
  7981. }
  7982. }
  7983. }
  7984. if ((styleData = normalizeStyleData(vnode.data))) {
  7985. extend(res, styleData);
  7986. }
  7987. let parentNode = vnode;
  7988. // @ts-expect-error parentNode.parent not VNodeWithData
  7989. while ((parentNode = parentNode.parent)) {
  7990. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7991. extend(res, styleData);
  7992. }
  7993. }
  7994. return res;
  7995. }
  7996. const cssVarRE = /^--/;
  7997. const importantRE = /\s*!important$/;
  7998. const setProp = (el, name, val) => {
  7999. /* istanbul ignore if */
  8000. if (cssVarRE.test(name)) {
  8001. el.style.setProperty(name, val);
  8002. }
  8003. else if (importantRE.test(val)) {
  8004. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8005. }
  8006. else {
  8007. const normalizedName = normalize(name);
  8008. if (Array.isArray(val)) {
  8009. // Support values array created by autoprefixer, e.g.
  8010. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8011. // Set them one by one, and the browser will only set those it can recognize
  8012. for (let i = 0, len = val.length; i < len; i++) {
  8013. el.style[normalizedName] = val[i];
  8014. }
  8015. }
  8016. else {
  8017. el.style[normalizedName] = val;
  8018. }
  8019. }
  8020. };
  8021. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8022. let emptyStyle;
  8023. const normalize = cached(function (prop) {
  8024. emptyStyle = emptyStyle || document.createElement('div').style;
  8025. prop = camelize(prop);
  8026. if (prop !== 'filter' && prop in emptyStyle) {
  8027. return prop;
  8028. }
  8029. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8030. for (let i = 0; i < vendorNames.length; i++) {
  8031. const name = vendorNames[i] + capName;
  8032. if (name in emptyStyle) {
  8033. return name;
  8034. }
  8035. }
  8036. });
  8037. function updateStyle(oldVnode, vnode) {
  8038. const data = vnode.data;
  8039. const oldData = oldVnode.data;
  8040. if (isUndef(data.staticStyle) &&
  8041. isUndef(data.style) &&
  8042. isUndef(oldData.staticStyle) &&
  8043. isUndef(oldData.style)) {
  8044. return;
  8045. }
  8046. let cur, name;
  8047. const el = vnode.elm;
  8048. const oldStaticStyle = oldData.staticStyle;
  8049. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8050. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8051. const oldStyle = oldStaticStyle || oldStyleBinding;
  8052. const style = normalizeStyleBinding(vnode.data.style) || {};
  8053. // store normalized style under a different key for next diff
  8054. // make sure to clone it if it's reactive, since the user likely wants
  8055. // to mutate it.
  8056. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8057. const newStyle = getStyle(vnode, true);
  8058. for (name in oldStyle) {
  8059. if (isUndef(newStyle[name])) {
  8060. setProp(el, name, '');
  8061. }
  8062. }
  8063. for (name in newStyle) {
  8064. cur = newStyle[name];
  8065. // ie9 setting to null has no effect, must use empty string
  8066. setProp(el, name, cur == null ? '' : cur);
  8067. }
  8068. }
  8069. var style$1 = {
  8070. create: updateStyle,
  8071. update: updateStyle
  8072. };
  8073. const whitespaceRE$1 = /\s+/;
  8074. /**
  8075. * Add class with compatibility for SVG since classList is not supported on
  8076. * SVG elements in IE
  8077. */
  8078. function addClass(el, cls) {
  8079. /* istanbul ignore if */
  8080. if (!cls || !(cls = cls.trim())) {
  8081. return;
  8082. }
  8083. /* istanbul ignore else */
  8084. if (el.classList) {
  8085. if (cls.indexOf(' ') > -1) {
  8086. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8087. }
  8088. else {
  8089. el.classList.add(cls);
  8090. }
  8091. }
  8092. else {
  8093. const cur = ` ${el.getAttribute('class') || ''} `;
  8094. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8095. el.setAttribute('class', (cur + cls).trim());
  8096. }
  8097. }
  8098. }
  8099. /**
  8100. * Remove class with compatibility for SVG since classList is not supported on
  8101. * SVG elements in IE
  8102. */
  8103. function removeClass(el, cls) {
  8104. /* istanbul ignore if */
  8105. if (!cls || !(cls = cls.trim())) {
  8106. return;
  8107. }
  8108. /* istanbul ignore else */
  8109. if (el.classList) {
  8110. if (cls.indexOf(' ') > -1) {
  8111. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8112. }
  8113. else {
  8114. el.classList.remove(cls);
  8115. }
  8116. if (!el.classList.length) {
  8117. el.removeAttribute('class');
  8118. }
  8119. }
  8120. else {
  8121. let cur = ` ${el.getAttribute('class') || ''} `;
  8122. const tar = ' ' + cls + ' ';
  8123. while (cur.indexOf(tar) >= 0) {
  8124. cur = cur.replace(tar, ' ');
  8125. }
  8126. cur = cur.trim();
  8127. if (cur) {
  8128. el.setAttribute('class', cur);
  8129. }
  8130. else {
  8131. el.removeAttribute('class');
  8132. }
  8133. }
  8134. }
  8135. function resolveTransition(def) {
  8136. if (!def) {
  8137. return;
  8138. }
  8139. /* istanbul ignore else */
  8140. if (typeof def === 'object') {
  8141. const res = {};
  8142. if (def.css !== false) {
  8143. extend(res, autoCssTransition(def.name || 'v'));
  8144. }
  8145. extend(res, def);
  8146. return res;
  8147. }
  8148. else if (typeof def === 'string') {
  8149. return autoCssTransition(def);
  8150. }
  8151. }
  8152. const autoCssTransition = cached(name => {
  8153. return {
  8154. enterClass: `${name}-enter`,
  8155. enterToClass: `${name}-enter-to`,
  8156. enterActiveClass: `${name}-enter-active`,
  8157. leaveClass: `${name}-leave`,
  8158. leaveToClass: `${name}-leave-to`,
  8159. leaveActiveClass: `${name}-leave-active`
  8160. };
  8161. });
  8162. const hasTransition = inBrowser && !isIE9;
  8163. const TRANSITION = 'transition';
  8164. const ANIMATION = 'animation';
  8165. // Transition property/event sniffing
  8166. let transitionProp = 'transition';
  8167. let transitionEndEvent = 'transitionend';
  8168. let animationProp = 'animation';
  8169. let animationEndEvent = 'animationend';
  8170. if (hasTransition) {
  8171. /* istanbul ignore if */
  8172. if (window.ontransitionend === undefined &&
  8173. window.onwebkittransitionend !== undefined) {
  8174. transitionProp = 'WebkitTransition';
  8175. transitionEndEvent = 'webkitTransitionEnd';
  8176. }
  8177. if (window.onanimationend === undefined &&
  8178. window.onwebkitanimationend !== undefined) {
  8179. animationProp = 'WebkitAnimation';
  8180. animationEndEvent = 'webkitAnimationEnd';
  8181. }
  8182. }
  8183. // binding to window is necessary to make hot reload work in IE in strict mode
  8184. const raf = inBrowser
  8185. ? window.requestAnimationFrame
  8186. ? window.requestAnimationFrame.bind(window)
  8187. : setTimeout
  8188. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8189. function nextFrame(fn) {
  8190. raf(() => {
  8191. // @ts-expect-error
  8192. raf(fn);
  8193. });
  8194. }
  8195. function addTransitionClass(el, cls) {
  8196. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8197. if (transitionClasses.indexOf(cls) < 0) {
  8198. transitionClasses.push(cls);
  8199. addClass(el, cls);
  8200. }
  8201. }
  8202. function removeTransitionClass(el, cls) {
  8203. if (el._transitionClasses) {
  8204. remove$2(el._transitionClasses, cls);
  8205. }
  8206. removeClass(el, cls);
  8207. }
  8208. function whenTransitionEnds(el, expectedType, cb) {
  8209. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8210. if (!type)
  8211. return cb();
  8212. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8213. let ended = 0;
  8214. const end = () => {
  8215. el.removeEventListener(event, onEnd);
  8216. cb();
  8217. };
  8218. const onEnd = e => {
  8219. if (e.target === el) {
  8220. if (++ended >= propCount) {
  8221. end();
  8222. }
  8223. }
  8224. };
  8225. setTimeout(() => {
  8226. if (ended < propCount) {
  8227. end();
  8228. }
  8229. }, timeout + 1);
  8230. el.addEventListener(event, onEnd);
  8231. }
  8232. const transformRE = /\b(transform|all)(,|$)/;
  8233. function getTransitionInfo(el, expectedType) {
  8234. const styles = window.getComputedStyle(el);
  8235. // JSDOM may return undefined for transition properties
  8236. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8237. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8238. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8239. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8240. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8241. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8242. let type;
  8243. let timeout = 0;
  8244. let propCount = 0;
  8245. /* istanbul ignore if */
  8246. if (expectedType === TRANSITION) {
  8247. if (transitionTimeout > 0) {
  8248. type = TRANSITION;
  8249. timeout = transitionTimeout;
  8250. propCount = transitionDurations.length;
  8251. }
  8252. }
  8253. else if (expectedType === ANIMATION) {
  8254. if (animationTimeout > 0) {
  8255. type = ANIMATION;
  8256. timeout = animationTimeout;
  8257. propCount = animationDurations.length;
  8258. }
  8259. }
  8260. else {
  8261. timeout = Math.max(transitionTimeout, animationTimeout);
  8262. type =
  8263. timeout > 0
  8264. ? transitionTimeout > animationTimeout
  8265. ? TRANSITION
  8266. : ANIMATION
  8267. : null;
  8268. propCount = type
  8269. ? type === TRANSITION
  8270. ? transitionDurations.length
  8271. : animationDurations.length
  8272. : 0;
  8273. }
  8274. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8275. return {
  8276. type,
  8277. timeout,
  8278. propCount,
  8279. hasTransform
  8280. };
  8281. }
  8282. function getTimeout(delays, durations) {
  8283. /* istanbul ignore next */
  8284. while (delays.length < durations.length) {
  8285. delays = delays.concat(delays);
  8286. }
  8287. return Math.max.apply(null, durations.map((d, i) => {
  8288. return toMs(d) + toMs(delays[i]);
  8289. }));
  8290. }
  8291. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8292. // in a locale-dependent way, using a comma instead of a dot.
  8293. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8294. // as a floor function) causing unexpected behaviors
  8295. function toMs(s) {
  8296. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8297. }
  8298. function enter(vnode, toggleDisplay) {
  8299. const el = vnode.elm;
  8300. // call leave callback now
  8301. if (isDef(el._leaveCb)) {
  8302. el._leaveCb.cancelled = true;
  8303. el._leaveCb();
  8304. }
  8305. const data = resolveTransition(vnode.data.transition);
  8306. if (isUndef(data)) {
  8307. return;
  8308. }
  8309. /* istanbul ignore if */
  8310. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8311. return;
  8312. }
  8313. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8314. // activeInstance will always be the <transition> component managing this
  8315. // transition. One edge case to check is when the <transition> is placed
  8316. // as the root node of a child component. In that case we need to check
  8317. // <transition>'s parent for appear check.
  8318. let context = activeInstance;
  8319. let transitionNode = activeInstance.$vnode;
  8320. while (transitionNode && transitionNode.parent) {
  8321. context = transitionNode.context;
  8322. transitionNode = transitionNode.parent;
  8323. }
  8324. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8325. if (isAppear && !appear && appear !== '') {
  8326. return;
  8327. }
  8328. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8329. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8330. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8331. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8332. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8333. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8334. const enterCancelledHook = isAppear
  8335. ? appearCancelled || enterCancelled
  8336. : enterCancelled;
  8337. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8338. if (explicitEnterDuration != null) {
  8339. checkDuration(explicitEnterDuration, 'enter', vnode);
  8340. }
  8341. const expectsCSS = css !== false && !isIE9;
  8342. const userWantsControl = getHookArgumentsLength(enterHook);
  8343. const cb = (el._enterCb = once(() => {
  8344. if (expectsCSS) {
  8345. removeTransitionClass(el, toClass);
  8346. removeTransitionClass(el, activeClass);
  8347. }
  8348. // @ts-expect-error
  8349. if (cb.cancelled) {
  8350. if (expectsCSS) {
  8351. removeTransitionClass(el, startClass);
  8352. }
  8353. enterCancelledHook && enterCancelledHook(el);
  8354. }
  8355. else {
  8356. afterEnterHook && afterEnterHook(el);
  8357. }
  8358. el._enterCb = null;
  8359. }));
  8360. if (!vnode.data.show) {
  8361. // remove pending leave element on enter by injecting an insert hook
  8362. mergeVNodeHook(vnode, 'insert', () => {
  8363. const parent = el.parentNode;
  8364. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8365. if (pendingNode &&
  8366. pendingNode.tag === vnode.tag &&
  8367. pendingNode.elm._leaveCb) {
  8368. pendingNode.elm._leaveCb();
  8369. }
  8370. enterHook && enterHook(el, cb);
  8371. });
  8372. }
  8373. // start enter transition
  8374. beforeEnterHook && beforeEnterHook(el);
  8375. if (expectsCSS) {
  8376. addTransitionClass(el, startClass);
  8377. addTransitionClass(el, activeClass);
  8378. nextFrame(() => {
  8379. removeTransitionClass(el, startClass);
  8380. // @ts-expect-error
  8381. if (!cb.cancelled) {
  8382. addTransitionClass(el, toClass);
  8383. if (!userWantsControl) {
  8384. if (isValidDuration(explicitEnterDuration)) {
  8385. setTimeout(cb, explicitEnterDuration);
  8386. }
  8387. else {
  8388. whenTransitionEnds(el, type, cb);
  8389. }
  8390. }
  8391. }
  8392. });
  8393. }
  8394. if (vnode.data.show) {
  8395. toggleDisplay && toggleDisplay();
  8396. enterHook && enterHook(el, cb);
  8397. }
  8398. if (!expectsCSS && !userWantsControl) {
  8399. cb();
  8400. }
  8401. }
  8402. function leave(vnode, rm) {
  8403. const el = vnode.elm;
  8404. // call enter callback now
  8405. if (isDef(el._enterCb)) {
  8406. el._enterCb.cancelled = true;
  8407. el._enterCb();
  8408. }
  8409. const data = resolveTransition(vnode.data.transition);
  8410. if (isUndef(data) || el.nodeType !== 1) {
  8411. return rm();
  8412. }
  8413. /* istanbul ignore if */
  8414. if (isDef(el._leaveCb)) {
  8415. return;
  8416. }
  8417. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8418. const expectsCSS = css !== false && !isIE9;
  8419. const userWantsControl = getHookArgumentsLength(leave);
  8420. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8421. if (isDef(explicitLeaveDuration)) {
  8422. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8423. }
  8424. const cb = (el._leaveCb = once(() => {
  8425. if (el.parentNode && el.parentNode._pending) {
  8426. el.parentNode._pending[vnode.key] = null;
  8427. }
  8428. if (expectsCSS) {
  8429. removeTransitionClass(el, leaveToClass);
  8430. removeTransitionClass(el, leaveActiveClass);
  8431. }
  8432. // @ts-expect-error
  8433. if (cb.cancelled) {
  8434. if (expectsCSS) {
  8435. removeTransitionClass(el, leaveClass);
  8436. }
  8437. leaveCancelled && leaveCancelled(el);
  8438. }
  8439. else {
  8440. rm();
  8441. afterLeave && afterLeave(el);
  8442. }
  8443. el._leaveCb = null;
  8444. }));
  8445. if (delayLeave) {
  8446. delayLeave(performLeave);
  8447. }
  8448. else {
  8449. performLeave();
  8450. }
  8451. function performLeave() {
  8452. // the delayed leave may have already been cancelled
  8453. // @ts-expect-error
  8454. if (cb.cancelled) {
  8455. return;
  8456. }
  8457. // record leaving element
  8458. if (!vnode.data.show && el.parentNode) {
  8459. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8460. vnode;
  8461. }
  8462. beforeLeave && beforeLeave(el);
  8463. if (expectsCSS) {
  8464. addTransitionClass(el, leaveClass);
  8465. addTransitionClass(el, leaveActiveClass);
  8466. nextFrame(() => {
  8467. removeTransitionClass(el, leaveClass);
  8468. // @ts-expect-error
  8469. if (!cb.cancelled) {
  8470. addTransitionClass(el, leaveToClass);
  8471. if (!userWantsControl) {
  8472. if (isValidDuration(explicitLeaveDuration)) {
  8473. setTimeout(cb, explicitLeaveDuration);
  8474. }
  8475. else {
  8476. whenTransitionEnds(el, type, cb);
  8477. }
  8478. }
  8479. }
  8480. });
  8481. }
  8482. leave && leave(el, cb);
  8483. if (!expectsCSS && !userWantsControl) {
  8484. cb();
  8485. }
  8486. }
  8487. }
  8488. // only used in dev mode
  8489. function checkDuration(val, name, vnode) {
  8490. if (typeof val !== 'number') {
  8491. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8492. `got ${JSON.stringify(val)}.`, vnode.context);
  8493. }
  8494. else if (isNaN(val)) {
  8495. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8496. 'the duration expression might be incorrect.', vnode.context);
  8497. }
  8498. }
  8499. function isValidDuration(val) {
  8500. return typeof val === 'number' && !isNaN(val);
  8501. }
  8502. /**
  8503. * Normalize a transition hook's argument length. The hook may be:
  8504. * - a merged hook (invoker) with the original in .fns
  8505. * - a wrapped component method (check ._length)
  8506. * - a plain function (.length)
  8507. */
  8508. function getHookArgumentsLength(fn) {
  8509. if (isUndef(fn)) {
  8510. return false;
  8511. }
  8512. // @ts-expect-error
  8513. const invokerFns = fn.fns;
  8514. if (isDef(invokerFns)) {
  8515. // invoker
  8516. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8517. }
  8518. else {
  8519. // @ts-expect-error
  8520. return (fn._length || fn.length) > 1;
  8521. }
  8522. }
  8523. function _enter(_, vnode) {
  8524. if (vnode.data.show !== true) {
  8525. enter(vnode);
  8526. }
  8527. }
  8528. var transition = inBrowser
  8529. ? {
  8530. create: _enter,
  8531. activate: _enter,
  8532. remove(vnode, rm) {
  8533. /* istanbul ignore else */
  8534. if (vnode.data.show !== true) {
  8535. // @ts-expect-error
  8536. leave(vnode, rm);
  8537. }
  8538. else {
  8539. rm();
  8540. }
  8541. }
  8542. }
  8543. : {};
  8544. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8545. // the directive module should be applied last, after all
  8546. // built-in modules have been applied.
  8547. const modules$1 = platformModules.concat(baseModules);
  8548. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8549. /**
  8550. * Not type checking this file because flow doesn't like attaching
  8551. * properties to Elements.
  8552. */
  8553. /* istanbul ignore if */
  8554. if (isIE9) {
  8555. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8556. document.addEventListener('selectionchange', () => {
  8557. const el = document.activeElement;
  8558. // @ts-expect-error
  8559. if (el && el.vmodel) {
  8560. trigger(el, 'input');
  8561. }
  8562. });
  8563. }
  8564. const directive = {
  8565. inserted(el, binding, vnode, oldVnode) {
  8566. if (vnode.tag === 'select') {
  8567. // #6903
  8568. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8569. mergeVNodeHook(vnode, 'postpatch', () => {
  8570. directive.componentUpdated(el, binding, vnode);
  8571. });
  8572. }
  8573. else {
  8574. setSelected(el, binding, vnode.context);
  8575. }
  8576. el._vOptions = [].map.call(el.options, getValue);
  8577. }
  8578. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8579. el._vModifiers = binding.modifiers;
  8580. if (!binding.modifiers.lazy) {
  8581. el.addEventListener('compositionstart', onCompositionStart);
  8582. el.addEventListener('compositionend', onCompositionEnd);
  8583. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8584. // switching focus before confirming composition choice
  8585. // this also fixes the issue where some browsers e.g. iOS Chrome
  8586. // fires "change" instead of "input" on autocomplete.
  8587. el.addEventListener('change', onCompositionEnd);
  8588. /* istanbul ignore if */
  8589. if (isIE9) {
  8590. el.vmodel = true;
  8591. }
  8592. }
  8593. }
  8594. },
  8595. componentUpdated(el, binding, vnode) {
  8596. if (vnode.tag === 'select') {
  8597. setSelected(el, binding, vnode.context);
  8598. // in case the options rendered by v-for have changed,
  8599. // it's possible that the value is out-of-sync with the rendered options.
  8600. // detect such cases and filter out values that no longer has a matching
  8601. // option in the DOM.
  8602. const prevOptions = el._vOptions;
  8603. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8604. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8605. // trigger change event if
  8606. // no matching option found for at least one value
  8607. const needReset = el.multiple
  8608. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8609. : binding.value !== binding.oldValue &&
  8610. hasNoMatchingOption(binding.value, curOptions);
  8611. if (needReset) {
  8612. trigger(el, 'change');
  8613. }
  8614. }
  8615. }
  8616. }
  8617. };
  8618. function setSelected(el, binding, vm) {
  8619. actuallySetSelected(el, binding, vm);
  8620. /* istanbul ignore if */
  8621. if (isIE || isEdge) {
  8622. setTimeout(() => {
  8623. actuallySetSelected(el, binding, vm);
  8624. }, 0);
  8625. }
  8626. }
  8627. function actuallySetSelected(el, binding, vm) {
  8628. const value = binding.value;
  8629. const isMultiple = el.multiple;
  8630. if (isMultiple && !Array.isArray(value)) {
  8631. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8632. `expects an Array value for its binding, but got ${Object.prototype.toString
  8633. .call(value)
  8634. .slice(8, -1)}`, vm);
  8635. return;
  8636. }
  8637. let selected, option;
  8638. for (let i = 0, l = el.options.length; i < l; i++) {
  8639. option = el.options[i];
  8640. if (isMultiple) {
  8641. selected = looseIndexOf(value, getValue(option)) > -1;
  8642. if (option.selected !== selected) {
  8643. option.selected = selected;
  8644. }
  8645. }
  8646. else {
  8647. if (looseEqual(getValue(option), value)) {
  8648. if (el.selectedIndex !== i) {
  8649. el.selectedIndex = i;
  8650. }
  8651. return;
  8652. }
  8653. }
  8654. }
  8655. if (!isMultiple) {
  8656. el.selectedIndex = -1;
  8657. }
  8658. }
  8659. function hasNoMatchingOption(value, options) {
  8660. return options.every(o => !looseEqual(o, value));
  8661. }
  8662. function getValue(option) {
  8663. return '_value' in option ? option._value : option.value;
  8664. }
  8665. function onCompositionStart(e) {
  8666. e.target.composing = true;
  8667. }
  8668. function onCompositionEnd(e) {
  8669. // prevent triggering an input event for no reason
  8670. if (!e.target.composing)
  8671. return;
  8672. e.target.composing = false;
  8673. trigger(e.target, 'input');
  8674. }
  8675. function trigger(el, type) {
  8676. const e = document.createEvent('HTMLEvents');
  8677. e.initEvent(type, true, true);
  8678. el.dispatchEvent(e);
  8679. }
  8680. // recursively search for possible transition defined inside the component root
  8681. function locateNode(vnode) {
  8682. // @ts-expect-error
  8683. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8684. ? locateNode(vnode.componentInstance._vnode)
  8685. : vnode;
  8686. }
  8687. var show = {
  8688. bind(el, { value }, vnode) {
  8689. vnode = locateNode(vnode);
  8690. const transition = vnode.data && vnode.data.transition;
  8691. const originalDisplay = (el.__vOriginalDisplay =
  8692. el.style.display === 'none' ? '' : el.style.display);
  8693. if (value && transition) {
  8694. vnode.data.show = true;
  8695. enter(vnode, () => {
  8696. el.style.display = originalDisplay;
  8697. });
  8698. }
  8699. else {
  8700. el.style.display = value ? originalDisplay : 'none';
  8701. }
  8702. },
  8703. update(el, { value, oldValue }, vnode) {
  8704. /* istanbul ignore if */
  8705. if (!value === !oldValue)
  8706. return;
  8707. vnode = locateNode(vnode);
  8708. const transition = vnode.data && vnode.data.transition;
  8709. if (transition) {
  8710. vnode.data.show = true;
  8711. if (value) {
  8712. enter(vnode, () => {
  8713. el.style.display = el.__vOriginalDisplay;
  8714. });
  8715. }
  8716. else {
  8717. leave(vnode, () => {
  8718. el.style.display = 'none';
  8719. });
  8720. }
  8721. }
  8722. else {
  8723. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8724. }
  8725. },
  8726. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8727. if (!isDestroy) {
  8728. el.style.display = el.__vOriginalDisplay;
  8729. }
  8730. }
  8731. };
  8732. var platformDirectives = {
  8733. model: directive,
  8734. show
  8735. };
  8736. // Provides transition support for a single element/component.
  8737. const transitionProps = {
  8738. name: String,
  8739. appear: Boolean,
  8740. css: Boolean,
  8741. mode: String,
  8742. type: String,
  8743. enterClass: String,
  8744. leaveClass: String,
  8745. enterToClass: String,
  8746. leaveToClass: String,
  8747. enterActiveClass: String,
  8748. leaveActiveClass: String,
  8749. appearClass: String,
  8750. appearActiveClass: String,
  8751. appearToClass: String,
  8752. duration: [Number, String, Object]
  8753. };
  8754. // in case the child is also an abstract component, e.g. <keep-alive>
  8755. // we want to recursively retrieve the real component to be rendered
  8756. function getRealChild(vnode) {
  8757. const compOptions = vnode && vnode.componentOptions;
  8758. if (compOptions && compOptions.Ctor.options.abstract) {
  8759. return getRealChild(getFirstComponentChild(compOptions.children));
  8760. }
  8761. else {
  8762. return vnode;
  8763. }
  8764. }
  8765. function extractTransitionData(comp) {
  8766. const data = {};
  8767. const options = comp.$options;
  8768. // props
  8769. for (const key in options.propsData) {
  8770. data[key] = comp[key];
  8771. }
  8772. // events.
  8773. // extract listeners and pass them directly to the transition methods
  8774. const listeners = options._parentListeners;
  8775. for (const key in listeners) {
  8776. data[camelize(key)] = listeners[key];
  8777. }
  8778. return data;
  8779. }
  8780. function placeholder(h, rawChild) {
  8781. // @ts-expect-error
  8782. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8783. return h('keep-alive', {
  8784. props: rawChild.componentOptions.propsData
  8785. });
  8786. }
  8787. }
  8788. function hasParentTransition(vnode) {
  8789. while ((vnode = vnode.parent)) {
  8790. if (vnode.data.transition) {
  8791. return true;
  8792. }
  8793. }
  8794. }
  8795. function isSameChild(child, oldChild) {
  8796. return oldChild.key === child.key && oldChild.tag === child.tag;
  8797. }
  8798. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8799. const isVShowDirective = d => d.name === 'show';
  8800. var Transition = {
  8801. name: 'transition',
  8802. props: transitionProps,
  8803. abstract: true,
  8804. render(h) {
  8805. let children = this.$slots.default;
  8806. if (!children) {
  8807. return;
  8808. }
  8809. // filter out text nodes (possible whitespaces)
  8810. children = children.filter(isNotTextNode);
  8811. /* istanbul ignore if */
  8812. if (!children.length) {
  8813. return;
  8814. }
  8815. // warn multiple elements
  8816. if (children.length > 1) {
  8817. warn$2('<transition> can only be used on a single element. Use ' +
  8818. '<transition-group> for lists.', this.$parent);
  8819. }
  8820. const mode = this.mode;
  8821. // warn invalid mode
  8822. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8823. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8824. }
  8825. const rawChild = children[0];
  8826. // if this is a component root node and the component's
  8827. // parent container node also has transition, skip.
  8828. if (hasParentTransition(this.$vnode)) {
  8829. return rawChild;
  8830. }
  8831. // apply transition data to child
  8832. // use getRealChild() to ignore abstract components e.g. keep-alive
  8833. const child = getRealChild(rawChild);
  8834. /* istanbul ignore if */
  8835. if (!child) {
  8836. return rawChild;
  8837. }
  8838. if (this._leaving) {
  8839. return placeholder(h, rawChild);
  8840. }
  8841. // ensure a key that is unique to the vnode type and to this transition
  8842. // component instance. This key will be used to remove pending leaving nodes
  8843. // during entering.
  8844. const id = `__transition-${this._uid}-`;
  8845. child.key =
  8846. child.key == null
  8847. ? child.isComment
  8848. ? id + 'comment'
  8849. : id + child.tag
  8850. : isPrimitive(child.key)
  8851. ? String(child.key).indexOf(id) === 0
  8852. ? child.key
  8853. : id + child.key
  8854. : child.key;
  8855. const data = ((child.data || (child.data = {})).transition =
  8856. extractTransitionData(this));
  8857. const oldRawChild = this._vnode;
  8858. const oldChild = getRealChild(oldRawChild);
  8859. // mark v-show
  8860. // so that the transition module can hand over the control to the directive
  8861. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8862. child.data.show = true;
  8863. }
  8864. if (oldChild &&
  8865. oldChild.data &&
  8866. !isSameChild(child, oldChild) &&
  8867. !isAsyncPlaceholder(oldChild) &&
  8868. // #6687 component root is a comment node
  8869. !(oldChild.componentInstance &&
  8870. oldChild.componentInstance._vnode.isComment)) {
  8871. // replace old child transition data with fresh one
  8872. // important for dynamic transitions!
  8873. const oldData = (oldChild.data.transition = extend({}, data));
  8874. // handle transition mode
  8875. if (mode === 'out-in') {
  8876. // return placeholder node and queue update when leave finishes
  8877. this._leaving = true;
  8878. mergeVNodeHook(oldData, 'afterLeave', () => {
  8879. this._leaving = false;
  8880. this.$forceUpdate();
  8881. });
  8882. return placeholder(h, rawChild);
  8883. }
  8884. else if (mode === 'in-out') {
  8885. if (isAsyncPlaceholder(child)) {
  8886. return oldRawChild;
  8887. }
  8888. let delayedLeave;
  8889. const performLeave = () => {
  8890. delayedLeave();
  8891. };
  8892. mergeVNodeHook(data, 'afterEnter', performLeave);
  8893. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8894. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8895. delayedLeave = leave;
  8896. });
  8897. }
  8898. }
  8899. return rawChild;
  8900. }
  8901. };
  8902. // Provides transition support for list items.
  8903. const props = extend({
  8904. tag: String,
  8905. moveClass: String
  8906. }, transitionProps);
  8907. delete props.mode;
  8908. var TransitionGroup = {
  8909. props,
  8910. beforeMount() {
  8911. const update = this._update;
  8912. this._update = (vnode, hydrating) => {
  8913. const restoreActiveInstance = setActiveInstance(this);
  8914. // force removing pass
  8915. this.__patch__(this._vnode, this.kept, false, // hydrating
  8916. true // removeOnly (!important, avoids unnecessary moves)
  8917. );
  8918. this._vnode = this.kept;
  8919. restoreActiveInstance();
  8920. update.call(this, vnode, hydrating);
  8921. };
  8922. },
  8923. render(h) {
  8924. const tag = this.tag || this.$vnode.data.tag || 'span';
  8925. const map = Object.create(null);
  8926. const prevChildren = (this.prevChildren = this.children);
  8927. const rawChildren = this.$slots.default || [];
  8928. const children = (this.children = []);
  8929. const transitionData = extractTransitionData(this);
  8930. for (let i = 0; i < rawChildren.length; i++) {
  8931. const c = rawChildren[i];
  8932. if (c.tag) {
  8933. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8934. children.push(c);
  8935. map[c.key] = c;
  8936. (c.data || (c.data = {})).transition = transitionData;
  8937. }
  8938. else {
  8939. const opts = c.componentOptions;
  8940. const name = opts
  8941. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8942. : c.tag;
  8943. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8944. }
  8945. }
  8946. }
  8947. if (prevChildren) {
  8948. const kept = [];
  8949. const removed = [];
  8950. for (let i = 0; i < prevChildren.length; i++) {
  8951. const c = prevChildren[i];
  8952. c.data.transition = transitionData;
  8953. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8954. c.data.pos = c.elm.getBoundingClientRect();
  8955. if (map[c.key]) {
  8956. kept.push(c);
  8957. }
  8958. else {
  8959. removed.push(c);
  8960. }
  8961. }
  8962. this.kept = h(tag, null, kept);
  8963. this.removed = removed;
  8964. }
  8965. return h(tag, null, children);
  8966. },
  8967. updated() {
  8968. const children = this.prevChildren;
  8969. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8970. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8971. return;
  8972. }
  8973. // we divide the work into three loops to avoid mixing DOM reads and writes
  8974. // in each iteration - which helps prevent layout thrashing.
  8975. children.forEach(callPendingCbs);
  8976. children.forEach(recordPosition);
  8977. children.forEach(applyTranslation);
  8978. // force reflow to put everything in position
  8979. // assign to this to avoid being removed in tree-shaking
  8980. // $flow-disable-line
  8981. this._reflow = document.body.offsetHeight;
  8982. children.forEach((c) => {
  8983. if (c.data.moved) {
  8984. const el = c.elm;
  8985. const s = el.style;
  8986. addTransitionClass(el, moveClass);
  8987. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8988. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8989. if (e && e.target !== el) {
  8990. return;
  8991. }
  8992. if (!e || /transform$/.test(e.propertyName)) {
  8993. el.removeEventListener(transitionEndEvent, cb);
  8994. el._moveCb = null;
  8995. removeTransitionClass(el, moveClass);
  8996. }
  8997. }));
  8998. }
  8999. });
  9000. },
  9001. methods: {
  9002. hasMove(el, moveClass) {
  9003. /* istanbul ignore if */
  9004. if (!hasTransition) {
  9005. return false;
  9006. }
  9007. /* istanbul ignore if */
  9008. if (this._hasMove) {
  9009. return this._hasMove;
  9010. }
  9011. // Detect whether an element with the move class applied has
  9012. // CSS transitions. Since the element may be inside an entering
  9013. // transition at this very moment, we make a clone of it and remove
  9014. // all other transition classes applied to ensure only the move class
  9015. // is applied.
  9016. const clone = el.cloneNode();
  9017. if (el._transitionClasses) {
  9018. el._transitionClasses.forEach((cls) => {
  9019. removeClass(clone, cls);
  9020. });
  9021. }
  9022. addClass(clone, moveClass);
  9023. clone.style.display = 'none';
  9024. this.$el.appendChild(clone);
  9025. const info = getTransitionInfo(clone);
  9026. this.$el.removeChild(clone);
  9027. return (this._hasMove = info.hasTransform);
  9028. }
  9029. }
  9030. };
  9031. function callPendingCbs(c) {
  9032. /* istanbul ignore if */
  9033. if (c.elm._moveCb) {
  9034. c.elm._moveCb();
  9035. }
  9036. /* istanbul ignore if */
  9037. if (c.elm._enterCb) {
  9038. c.elm._enterCb();
  9039. }
  9040. }
  9041. function recordPosition(c) {
  9042. c.data.newPos = c.elm.getBoundingClientRect();
  9043. }
  9044. function applyTranslation(c) {
  9045. const oldPos = c.data.pos;
  9046. const newPos = c.data.newPos;
  9047. const dx = oldPos.left - newPos.left;
  9048. const dy = oldPos.top - newPos.top;
  9049. if (dx || dy) {
  9050. c.data.moved = true;
  9051. const s = c.elm.style;
  9052. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9053. s.transitionDuration = '0s';
  9054. }
  9055. }
  9056. var platformComponents = {
  9057. Transition,
  9058. TransitionGroup
  9059. };
  9060. // install platform specific utils
  9061. Vue.config.mustUseProp = mustUseProp;
  9062. Vue.config.isReservedTag = isReservedTag;
  9063. Vue.config.isReservedAttr = isReservedAttr;
  9064. Vue.config.getTagNamespace = getTagNamespace;
  9065. Vue.config.isUnknownElement = isUnknownElement;
  9066. // install platform runtime directives & components
  9067. extend(Vue.options.directives, platformDirectives);
  9068. extend(Vue.options.components, platformComponents);
  9069. // install platform patch function
  9070. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9071. // public mount method
  9072. Vue.prototype.$mount = function (el, hydrating) {
  9073. el = el && inBrowser ? query(el) : undefined;
  9074. return mountComponent(this, el, hydrating);
  9075. };
  9076. // devtools global hook
  9077. /* istanbul ignore next */
  9078. if (inBrowser) {
  9079. setTimeout(() => {
  9080. if (config.devtools) {
  9081. if (devtools) {
  9082. devtools.emit('init', Vue);
  9083. }
  9084. else {
  9085. // @ts-expect-error
  9086. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9087. 'https://github.com/vuejs/vue-devtools');
  9088. }
  9089. }
  9090. if (config.productionTip !== false &&
  9091. typeof console !== 'undefined') {
  9092. // @ts-expect-error
  9093. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9094. `Make sure to turn on production mode when deploying for production.\n` +
  9095. `See more tips at https://vuejs.org/guide/deployment.html`);
  9096. }
  9097. }, 0);
  9098. }
  9099. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9100. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9101. const buildRegex = cached(delimiters => {
  9102. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9103. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9104. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9105. });
  9106. function parseText(text, delimiters) {
  9107. //@ts-expect-error
  9108. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9109. if (!tagRE.test(text)) {
  9110. return;
  9111. }
  9112. const tokens = [];
  9113. const rawTokens = [];
  9114. let lastIndex = (tagRE.lastIndex = 0);
  9115. let match, index, tokenValue;
  9116. while ((match = tagRE.exec(text))) {
  9117. index = match.index;
  9118. // push text token
  9119. if (index > lastIndex) {
  9120. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9121. tokens.push(JSON.stringify(tokenValue));
  9122. }
  9123. // tag token
  9124. const exp = parseFilters(match[1].trim());
  9125. tokens.push(`_s(${exp})`);
  9126. rawTokens.push({ '@binding': exp });
  9127. lastIndex = index + match[0].length;
  9128. }
  9129. if (lastIndex < text.length) {
  9130. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9131. tokens.push(JSON.stringify(tokenValue));
  9132. }
  9133. return {
  9134. expression: tokens.join('+'),
  9135. tokens: rawTokens
  9136. };
  9137. }
  9138. function transformNode$1(el, options) {
  9139. const warn = options.warn || baseWarn;
  9140. const staticClass = getAndRemoveAttr(el, 'class');
  9141. if (staticClass) {
  9142. const res = parseText(staticClass, options.delimiters);
  9143. if (res) {
  9144. warn(`class="${staticClass}": ` +
  9145. 'Interpolation inside attributes has been removed. ' +
  9146. 'Use v-bind or the colon shorthand instead. For example, ' +
  9147. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9148. }
  9149. }
  9150. if (staticClass) {
  9151. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9152. }
  9153. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9154. if (classBinding) {
  9155. el.classBinding = classBinding;
  9156. }
  9157. }
  9158. function genData$2(el) {
  9159. let data = '';
  9160. if (el.staticClass) {
  9161. data += `staticClass:${el.staticClass},`;
  9162. }
  9163. if (el.classBinding) {
  9164. data += `class:${el.classBinding},`;
  9165. }
  9166. return data;
  9167. }
  9168. var klass = {
  9169. staticKeys: ['staticClass'],
  9170. transformNode: transformNode$1,
  9171. genData: genData$2
  9172. };
  9173. function transformNode(el, options) {
  9174. const warn = options.warn || baseWarn;
  9175. const staticStyle = getAndRemoveAttr(el, 'style');
  9176. if (staticStyle) {
  9177. /* istanbul ignore if */
  9178. {
  9179. const res = parseText(staticStyle, options.delimiters);
  9180. if (res) {
  9181. warn(`style="${staticStyle}": ` +
  9182. 'Interpolation inside attributes has been removed. ' +
  9183. 'Use v-bind or the colon shorthand instead. For example, ' +
  9184. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9185. }
  9186. }
  9187. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9188. }
  9189. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9190. if (styleBinding) {
  9191. el.styleBinding = styleBinding;
  9192. }
  9193. }
  9194. function genData$1(el) {
  9195. let data = '';
  9196. if (el.staticStyle) {
  9197. data += `staticStyle:${el.staticStyle},`;
  9198. }
  9199. if (el.styleBinding) {
  9200. data += `style:(${el.styleBinding}),`;
  9201. }
  9202. return data;
  9203. }
  9204. var style = {
  9205. staticKeys: ['staticStyle'],
  9206. transformNode,
  9207. genData: genData$1
  9208. };
  9209. let decoder;
  9210. var he = {
  9211. decode(html) {
  9212. decoder = decoder || document.createElement('div');
  9213. decoder.innerHTML = html;
  9214. return decoder.textContent;
  9215. }
  9216. };
  9217. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9218. 'link,meta,param,source,track,wbr');
  9219. // Elements that you can, intentionally, leave open
  9220. // (and which close themselves)
  9221. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9222. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9223. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9224. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9225. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9226. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9227. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9228. 'title,tr,track');
  9229. /**
  9230. * Not type-checking this file because it's mostly vendor code.
  9231. */
  9232. // Regular Expressions for parsing tags and attributes
  9233. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9234. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9235. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9236. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9237. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9238. const startTagClose = /^\s*(\/?)>/;
  9239. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9240. const doctype = /^<!DOCTYPE [^>]+>/i;
  9241. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9242. const comment = /^<!\--/;
  9243. const conditionalComment = /^<!\[/;
  9244. // Special Elements (can contain anything)
  9245. const isPlainTextElement = makeMap('script,style,textarea', true);
  9246. const reCache = {};
  9247. const decodingMap = {
  9248. '&lt;': '<',
  9249. '&gt;': '>',
  9250. '&quot;': '"',
  9251. '&amp;': '&',
  9252. '&#10;': '\n',
  9253. '&#9;': '\t',
  9254. '&#39;': "'"
  9255. };
  9256. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9257. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9258. // #5992
  9259. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9260. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9261. function decodeAttr(value, shouldDecodeNewlines) {
  9262. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9263. return value.replace(re, match => decodingMap[match]);
  9264. }
  9265. function parseHTML(html, options) {
  9266. const stack = [];
  9267. const expectHTML = options.expectHTML;
  9268. const isUnaryTag = options.isUnaryTag || no;
  9269. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9270. let index = 0;
  9271. let last, lastTag;
  9272. while (html) {
  9273. last = html;
  9274. // Make sure we're not in a plaintext content element like script/style
  9275. if (!lastTag || !isPlainTextElement(lastTag)) {
  9276. let textEnd = html.indexOf('<');
  9277. if (textEnd === 0) {
  9278. // Comment:
  9279. if (comment.test(html)) {
  9280. const commentEnd = html.indexOf('-->');
  9281. if (commentEnd >= 0) {
  9282. if (options.shouldKeepComment && options.comment) {
  9283. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9284. }
  9285. advance(commentEnd + 3);
  9286. continue;
  9287. }
  9288. }
  9289. // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9290. if (conditionalComment.test(html)) {
  9291. const conditionalEnd = html.indexOf(']>');
  9292. if (conditionalEnd >= 0) {
  9293. advance(conditionalEnd + 2);
  9294. continue;
  9295. }
  9296. }
  9297. // Doctype:
  9298. const doctypeMatch = html.match(doctype);
  9299. if (doctypeMatch) {
  9300. advance(doctypeMatch[0].length);
  9301. continue;
  9302. }
  9303. // End tag:
  9304. const endTagMatch = html.match(endTag);
  9305. if (endTagMatch) {
  9306. const curIndex = index;
  9307. advance(endTagMatch[0].length);
  9308. parseEndTag(endTagMatch[1], curIndex, index);
  9309. continue;
  9310. }
  9311. // Start tag:
  9312. const startTagMatch = parseStartTag();
  9313. if (startTagMatch) {
  9314. handleStartTag(startTagMatch);
  9315. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9316. advance(1);
  9317. }
  9318. continue;
  9319. }
  9320. }
  9321. let text, rest, next;
  9322. if (textEnd >= 0) {
  9323. rest = html.slice(textEnd);
  9324. while (!endTag.test(rest) &&
  9325. !startTagOpen.test(rest) &&
  9326. !comment.test(rest) &&
  9327. !conditionalComment.test(rest)) {
  9328. // < in plain text, be forgiving and treat it as text
  9329. next = rest.indexOf('<', 1);
  9330. if (next < 0)
  9331. break;
  9332. textEnd += next;
  9333. rest = html.slice(textEnd);
  9334. }
  9335. text = html.substring(0, textEnd);
  9336. }
  9337. if (textEnd < 0) {
  9338. text = html;
  9339. }
  9340. if (text) {
  9341. advance(text.length);
  9342. }
  9343. if (options.chars && text) {
  9344. options.chars(text, index - text.length, index);
  9345. }
  9346. }
  9347. else {
  9348. let endTagLength = 0;
  9349. const stackedTag = lastTag.toLowerCase();
  9350. const reStackedTag = reCache[stackedTag] ||
  9351. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9352. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9353. endTagLength = endTag.length;
  9354. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9355. text = text
  9356. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9357. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9358. }
  9359. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9360. text = text.slice(1);
  9361. }
  9362. if (options.chars) {
  9363. options.chars(text);
  9364. }
  9365. return '';
  9366. });
  9367. index += html.length - rest.length;
  9368. html = rest;
  9369. parseEndTag(stackedTag, index - endTagLength, index);
  9370. }
  9371. if (html === last) {
  9372. options.chars && options.chars(html);
  9373. if (!stack.length && options.warn) {
  9374. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9375. start: index + html.length
  9376. });
  9377. }
  9378. break;
  9379. }
  9380. }
  9381. // Clean up any remaining tags
  9382. parseEndTag();
  9383. function advance(n) {
  9384. index += n;
  9385. html = html.substring(n);
  9386. }
  9387. function parseStartTag() {
  9388. const start = html.match(startTagOpen);
  9389. if (start) {
  9390. const match = {
  9391. tagName: start[1],
  9392. attrs: [],
  9393. start: index
  9394. };
  9395. advance(start[0].length);
  9396. let end, attr;
  9397. while (!(end = html.match(startTagClose)) &&
  9398. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9399. attr.start = index;
  9400. advance(attr[0].length);
  9401. attr.end = index;
  9402. match.attrs.push(attr);
  9403. }
  9404. if (end) {
  9405. match.unarySlash = end[1];
  9406. advance(end[0].length);
  9407. match.end = index;
  9408. return match;
  9409. }
  9410. }
  9411. }
  9412. function handleStartTag(match) {
  9413. const tagName = match.tagName;
  9414. const unarySlash = match.unarySlash;
  9415. if (expectHTML) {
  9416. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9417. parseEndTag(lastTag);
  9418. }
  9419. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9420. parseEndTag(tagName);
  9421. }
  9422. }
  9423. const unary = isUnaryTag(tagName) || !!unarySlash;
  9424. const l = match.attrs.length;
  9425. const attrs = new Array(l);
  9426. for (let i = 0; i < l; i++) {
  9427. const args = match.attrs[i];
  9428. const value = args[3] || args[4] || args[5] || '';
  9429. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9430. ? options.shouldDecodeNewlinesForHref
  9431. : options.shouldDecodeNewlines;
  9432. attrs[i] = {
  9433. name: args[1],
  9434. value: decodeAttr(value, shouldDecodeNewlines)
  9435. };
  9436. if (options.outputSourceRange) {
  9437. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9438. attrs[i].end = args.end;
  9439. }
  9440. }
  9441. if (!unary) {
  9442. stack.push({
  9443. tag: tagName,
  9444. lowerCasedTag: tagName.toLowerCase(),
  9445. attrs: attrs,
  9446. start: match.start,
  9447. end: match.end
  9448. });
  9449. lastTag = tagName;
  9450. }
  9451. if (options.start) {
  9452. options.start(tagName, attrs, unary, match.start, match.end);
  9453. }
  9454. }
  9455. function parseEndTag(tagName, start, end) {
  9456. let pos, lowerCasedTagName;
  9457. if (start == null)
  9458. start = index;
  9459. if (end == null)
  9460. end = index;
  9461. // Find the closest opened tag of the same type
  9462. if (tagName) {
  9463. lowerCasedTagName = tagName.toLowerCase();
  9464. for (pos = stack.length - 1; pos >= 0; pos--) {
  9465. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9466. break;
  9467. }
  9468. }
  9469. }
  9470. else {
  9471. // If no tag name is provided, clean shop
  9472. pos = 0;
  9473. }
  9474. if (pos >= 0) {
  9475. // Close all the open elements, up the stack
  9476. for (let i = stack.length - 1; i >= pos; i--) {
  9477. if ((i > pos || !tagName) && options.warn) {
  9478. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9479. start: stack[i].start,
  9480. end: stack[i].end
  9481. });
  9482. }
  9483. if (options.end) {
  9484. options.end(stack[i].tag, start, end);
  9485. }
  9486. }
  9487. // Remove the open elements from the stack
  9488. stack.length = pos;
  9489. lastTag = pos && stack[pos - 1].tag;
  9490. }
  9491. else if (lowerCasedTagName === 'br') {
  9492. if (options.start) {
  9493. options.start(tagName, [], true, start, end);
  9494. }
  9495. }
  9496. else if (lowerCasedTagName === 'p') {
  9497. if (options.start) {
  9498. options.start(tagName, [], false, start, end);
  9499. }
  9500. if (options.end) {
  9501. options.end(tagName, start, end);
  9502. }
  9503. }
  9504. }
  9505. }
  9506. const onRE = /^@|^v-on:/;
  9507. const dirRE = /^v-|^@|^:|^#/;
  9508. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9509. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9510. const stripParensRE = /^\(|\)$/g;
  9511. const dynamicArgRE = /^\[.*\]$/;
  9512. const argRE = /:(.*)$/;
  9513. const bindRE = /^:|^\.|^v-bind:/;
  9514. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9515. const slotRE = /^v-slot(:|$)|^#/;
  9516. const lineBreakRE = /[\r\n]/;
  9517. const whitespaceRE = /[ \f\t\r\n]+/g;
  9518. const invalidAttributeRE = /[\s"'<>\/=]/;
  9519. const decodeHTMLCached = cached(he.decode);
  9520. const emptySlotScopeToken = `_empty_`;
  9521. // configurable state
  9522. let warn;
  9523. let delimiters;
  9524. let transforms;
  9525. let preTransforms;
  9526. let postTransforms;
  9527. let platformIsPreTag;
  9528. let platformMustUseProp;
  9529. let platformGetTagNamespace;
  9530. let maybeComponent;
  9531. function createASTElement(tag, attrs, parent) {
  9532. return {
  9533. type: 1,
  9534. tag,
  9535. attrsList: attrs,
  9536. attrsMap: makeAttrsMap(attrs),
  9537. rawAttrsMap: {},
  9538. parent,
  9539. children: []
  9540. };
  9541. }
  9542. /**
  9543. * Convert HTML string to AST.
  9544. */
  9545. function parse(template, options) {
  9546. warn = options.warn || baseWarn;
  9547. platformIsPreTag = options.isPreTag || no;
  9548. platformMustUseProp = options.mustUseProp || no;
  9549. platformGetTagNamespace = options.getTagNamespace || no;
  9550. const isReservedTag = options.isReservedTag || no;
  9551. maybeComponent = (el) => !!(el.component ||
  9552. el.attrsMap[':is'] ||
  9553. el.attrsMap['v-bind:is'] ||
  9554. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9555. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9556. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9557. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9558. delimiters = options.delimiters;
  9559. const stack = [];
  9560. const preserveWhitespace = options.preserveWhitespace !== false;
  9561. const whitespaceOption = options.whitespace;
  9562. let root;
  9563. let currentParent;
  9564. let inVPre = false;
  9565. let inPre = false;
  9566. let warned = false;
  9567. function warnOnce(msg, range) {
  9568. if (!warned) {
  9569. warned = true;
  9570. warn(msg, range);
  9571. }
  9572. }
  9573. function closeElement(element) {
  9574. trimEndingWhitespace(element);
  9575. if (!inVPre && !element.processed) {
  9576. element = processElement(element, options);
  9577. }
  9578. // tree management
  9579. if (!stack.length && element !== root) {
  9580. // allow root elements with v-if, v-else-if and v-else
  9581. if (root.if && (element.elseif || element.else)) {
  9582. {
  9583. checkRootConstraints(element);
  9584. }
  9585. addIfCondition(root, {
  9586. exp: element.elseif,
  9587. block: element
  9588. });
  9589. }
  9590. else {
  9591. warnOnce(`Component template should contain exactly one root element. ` +
  9592. `If you are using v-if on multiple elements, ` +
  9593. `use v-else-if to chain them instead.`, { start: element.start });
  9594. }
  9595. }
  9596. if (currentParent && !element.forbidden) {
  9597. if (element.elseif || element.else) {
  9598. processIfConditions(element, currentParent);
  9599. }
  9600. else {
  9601. if (element.slotScope) {
  9602. // scoped slot
  9603. // keep it in the children list so that v-else(-if) conditions can
  9604. // find it as the prev node.
  9605. const name = element.slotTarget || '"default"';
  9606. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9607. }
  9608. currentParent.children.push(element);
  9609. element.parent = currentParent;
  9610. }
  9611. }
  9612. // final children cleanup
  9613. // filter out scoped slots
  9614. element.children = element.children.filter(c => !c.slotScope);
  9615. // remove trailing whitespace node again
  9616. trimEndingWhitespace(element);
  9617. // check pre state
  9618. if (element.pre) {
  9619. inVPre = false;
  9620. }
  9621. if (platformIsPreTag(element.tag)) {
  9622. inPre = false;
  9623. }
  9624. // apply post-transforms
  9625. for (let i = 0; i < postTransforms.length; i++) {
  9626. postTransforms[i](element, options);
  9627. }
  9628. }
  9629. function trimEndingWhitespace(el) {
  9630. // remove trailing whitespace node
  9631. if (!inPre) {
  9632. let lastNode;
  9633. while ((lastNode = el.children[el.children.length - 1]) &&
  9634. lastNode.type === 3 &&
  9635. lastNode.text === ' ') {
  9636. el.children.pop();
  9637. }
  9638. }
  9639. }
  9640. function checkRootConstraints(el) {
  9641. if (el.tag === 'slot' || el.tag === 'template') {
  9642. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9643. 'contain multiple nodes.', { start: el.start });
  9644. }
  9645. if (el.attrsMap.hasOwnProperty('v-for')) {
  9646. warnOnce('Cannot use v-for on stateful component root element because ' +
  9647. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9648. }
  9649. }
  9650. parseHTML(template, {
  9651. warn,
  9652. expectHTML: options.expectHTML,
  9653. isUnaryTag: options.isUnaryTag,
  9654. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9655. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9656. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9657. shouldKeepComment: options.comments,
  9658. outputSourceRange: options.outputSourceRange,
  9659. start(tag, attrs, unary, start, end) {
  9660. // check namespace.
  9661. // inherit parent ns if there is one
  9662. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9663. // handle IE svg bug
  9664. /* istanbul ignore if */
  9665. if (isIE && ns === 'svg') {
  9666. attrs = guardIESVGBug(attrs);
  9667. }
  9668. let element = createASTElement(tag, attrs, currentParent);
  9669. if (ns) {
  9670. element.ns = ns;
  9671. }
  9672. {
  9673. if (options.outputSourceRange) {
  9674. element.start = start;
  9675. element.end = end;
  9676. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9677. cumulated[attr.name] = attr;
  9678. return cumulated;
  9679. }, {});
  9680. }
  9681. attrs.forEach(attr => {
  9682. if (invalidAttributeRE.test(attr.name)) {
  9683. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9684. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9685. ? {
  9686. start: attr.start + attr.name.indexOf(`[`),
  9687. end: attr.start + attr.name.length
  9688. }
  9689. : undefined);
  9690. }
  9691. });
  9692. }
  9693. if (isForbiddenTag(element) && !isServerRendering()) {
  9694. element.forbidden = true;
  9695. warn('Templates should only be responsible for mapping the state to the ' +
  9696. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9697. `<${tag}>` +
  9698. ', as they will not be parsed.', { start: element.start });
  9699. }
  9700. // apply pre-transforms
  9701. for (let i = 0; i < preTransforms.length; i++) {
  9702. element = preTransforms[i](element, options) || element;
  9703. }
  9704. if (!inVPre) {
  9705. processPre(element);
  9706. if (element.pre) {
  9707. inVPre = true;
  9708. }
  9709. }
  9710. if (platformIsPreTag(element.tag)) {
  9711. inPre = true;
  9712. }
  9713. if (inVPre) {
  9714. processRawAttrs(element);
  9715. }
  9716. else if (!element.processed) {
  9717. // structural directives
  9718. processFor(element);
  9719. processIf(element);
  9720. processOnce(element);
  9721. }
  9722. if (!root) {
  9723. root = element;
  9724. {
  9725. checkRootConstraints(root);
  9726. }
  9727. }
  9728. if (!unary) {
  9729. currentParent = element;
  9730. stack.push(element);
  9731. }
  9732. else {
  9733. closeElement(element);
  9734. }
  9735. },
  9736. end(tag, start, end) {
  9737. const element = stack[stack.length - 1];
  9738. // pop stack
  9739. stack.length -= 1;
  9740. currentParent = stack[stack.length - 1];
  9741. if (options.outputSourceRange) {
  9742. element.end = end;
  9743. }
  9744. closeElement(element);
  9745. },
  9746. chars(text, start, end) {
  9747. if (!currentParent) {
  9748. {
  9749. if (text === template) {
  9750. warnOnce('Component template requires a root element, rather than just text.', { start });
  9751. }
  9752. else if ((text = text.trim())) {
  9753. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9754. start
  9755. });
  9756. }
  9757. }
  9758. return;
  9759. }
  9760. // IE textarea placeholder bug
  9761. /* istanbul ignore if */
  9762. if (isIE &&
  9763. currentParent.tag === 'textarea' &&
  9764. currentParent.attrsMap.placeholder === text) {
  9765. return;
  9766. }
  9767. const children = currentParent.children;
  9768. if (inPre || text.trim()) {
  9769. text = isTextTag(currentParent)
  9770. ? text
  9771. : decodeHTMLCached(text);
  9772. }
  9773. else if (!children.length) {
  9774. // remove the whitespace-only node right after an opening tag
  9775. text = '';
  9776. }
  9777. else if (whitespaceOption) {
  9778. if (whitespaceOption === 'condense') {
  9779. // in condense mode, remove the whitespace node if it contains
  9780. // line break, otherwise condense to a single space
  9781. text = lineBreakRE.test(text) ? '' : ' ';
  9782. }
  9783. else {
  9784. text = ' ';
  9785. }
  9786. }
  9787. else {
  9788. text = preserveWhitespace ? ' ' : '';
  9789. }
  9790. if (text) {
  9791. if (!inPre && whitespaceOption === 'condense') {
  9792. // condense consecutive whitespaces into single space
  9793. text = text.replace(whitespaceRE, ' ');
  9794. }
  9795. let res;
  9796. let child;
  9797. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9798. child = {
  9799. type: 2,
  9800. expression: res.expression,
  9801. tokens: res.tokens,
  9802. text
  9803. };
  9804. }
  9805. else if (text !== ' ' ||
  9806. !children.length ||
  9807. children[children.length - 1].text !== ' ') {
  9808. child = {
  9809. type: 3,
  9810. text
  9811. };
  9812. }
  9813. if (child) {
  9814. if (options.outputSourceRange) {
  9815. child.start = start;
  9816. child.end = end;
  9817. }
  9818. children.push(child);
  9819. }
  9820. }
  9821. },
  9822. comment(text, start, end) {
  9823. // adding anything as a sibling to the root node is forbidden
  9824. // comments should still be allowed, but ignored
  9825. if (currentParent) {
  9826. const child = {
  9827. type: 3,
  9828. text,
  9829. isComment: true
  9830. };
  9831. if (options.outputSourceRange) {
  9832. child.start = start;
  9833. child.end = end;
  9834. }
  9835. currentParent.children.push(child);
  9836. }
  9837. }
  9838. });
  9839. return root;
  9840. }
  9841. function processPre(el) {
  9842. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9843. el.pre = true;
  9844. }
  9845. }
  9846. function processRawAttrs(el) {
  9847. const list = el.attrsList;
  9848. const len = list.length;
  9849. if (len) {
  9850. const attrs = (el.attrs = new Array(len));
  9851. for (let i = 0; i < len; i++) {
  9852. attrs[i] = {
  9853. name: list[i].name,
  9854. value: JSON.stringify(list[i].value)
  9855. };
  9856. if (list[i].start != null) {
  9857. attrs[i].start = list[i].start;
  9858. attrs[i].end = list[i].end;
  9859. }
  9860. }
  9861. }
  9862. else if (!el.pre) {
  9863. // non root node in pre blocks with no attributes
  9864. el.plain = true;
  9865. }
  9866. }
  9867. function processElement(element, options) {
  9868. processKey(element);
  9869. // determine whether this is a plain element after
  9870. // removing structural attributes
  9871. element.plain =
  9872. !element.key && !element.scopedSlots && !element.attrsList.length;
  9873. processRef(element);
  9874. processSlotContent(element);
  9875. processSlotOutlet(element);
  9876. processComponent(element);
  9877. for (let i = 0; i < transforms.length; i++) {
  9878. element = transforms[i](element, options) || element;
  9879. }
  9880. processAttrs(element);
  9881. return element;
  9882. }
  9883. function processKey(el) {
  9884. const exp = getBindingAttr(el, 'key');
  9885. if (exp) {
  9886. {
  9887. if (el.tag === 'template') {
  9888. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9889. }
  9890. if (el.for) {
  9891. const iterator = el.iterator2 || el.iterator1;
  9892. const parent = el.parent;
  9893. if (iterator &&
  9894. iterator === exp &&
  9895. parent &&
  9896. parent.tag === 'transition-group') {
  9897. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9898. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9899. }
  9900. }
  9901. }
  9902. el.key = exp;
  9903. }
  9904. }
  9905. function processRef(el) {
  9906. const ref = getBindingAttr(el, 'ref');
  9907. if (ref) {
  9908. el.ref = ref;
  9909. el.refInFor = checkInFor(el);
  9910. }
  9911. }
  9912. function processFor(el) {
  9913. let exp;
  9914. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9915. const res = parseFor(exp);
  9916. if (res) {
  9917. extend(el, res);
  9918. }
  9919. else {
  9920. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9921. }
  9922. }
  9923. }
  9924. function parseFor(exp) {
  9925. const inMatch = exp.match(forAliasRE);
  9926. if (!inMatch)
  9927. return;
  9928. const res = {};
  9929. res.for = inMatch[2].trim();
  9930. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9931. const iteratorMatch = alias.match(forIteratorRE);
  9932. if (iteratorMatch) {
  9933. res.alias = alias.replace(forIteratorRE, '').trim();
  9934. res.iterator1 = iteratorMatch[1].trim();
  9935. if (iteratorMatch[2]) {
  9936. res.iterator2 = iteratorMatch[2].trim();
  9937. }
  9938. }
  9939. else {
  9940. res.alias = alias;
  9941. }
  9942. return res;
  9943. }
  9944. function processIf(el) {
  9945. const exp = getAndRemoveAttr(el, 'v-if');
  9946. if (exp) {
  9947. el.if = exp;
  9948. addIfCondition(el, {
  9949. exp: exp,
  9950. block: el
  9951. });
  9952. }
  9953. else {
  9954. if (getAndRemoveAttr(el, 'v-else') != null) {
  9955. el.else = true;
  9956. }
  9957. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9958. if (elseif) {
  9959. el.elseif = elseif;
  9960. }
  9961. }
  9962. }
  9963. function processIfConditions(el, parent) {
  9964. const prev = findPrevElement(parent.children);
  9965. if (prev && prev.if) {
  9966. addIfCondition(prev, {
  9967. exp: el.elseif,
  9968. block: el
  9969. });
  9970. }
  9971. else {
  9972. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  9973. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  9974. }
  9975. }
  9976. function findPrevElement(children) {
  9977. let i = children.length;
  9978. while (i--) {
  9979. if (children[i].type === 1) {
  9980. return children[i];
  9981. }
  9982. else {
  9983. if (children[i].text !== ' ') {
  9984. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9985. `will be ignored.`, children[i]);
  9986. }
  9987. children.pop();
  9988. }
  9989. }
  9990. }
  9991. function addIfCondition(el, condition) {
  9992. if (!el.ifConditions) {
  9993. el.ifConditions = [];
  9994. }
  9995. el.ifConditions.push(condition);
  9996. }
  9997. function processOnce(el) {
  9998. const once = getAndRemoveAttr(el, 'v-once');
  9999. if (once != null) {
  10000. el.once = true;
  10001. }
  10002. }
  10003. // handle content being passed to a component as slot,
  10004. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10005. function processSlotContent(el) {
  10006. let slotScope;
  10007. if (el.tag === 'template') {
  10008. slotScope = getAndRemoveAttr(el, 'scope');
  10009. /* istanbul ignore if */
  10010. if (slotScope) {
  10011. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10012. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10013. `can also be used on plain elements in addition to <template> to ` +
  10014. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10015. }
  10016. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10017. }
  10018. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10019. /* istanbul ignore if */
  10020. if (el.attrsMap['v-for']) {
  10021. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10022. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10023. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10024. }
  10025. el.slotScope = slotScope;
  10026. }
  10027. // slot="xxx"
  10028. const slotTarget = getBindingAttr(el, 'slot');
  10029. if (slotTarget) {
  10030. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10031. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10032. // preserve slot as an attribute for native shadow DOM compat
  10033. // only for non-scoped slots.
  10034. if (el.tag !== 'template' && !el.slotScope) {
  10035. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10036. }
  10037. }
  10038. // 2.6 v-slot syntax
  10039. {
  10040. if (el.tag === 'template') {
  10041. // v-slot on <template>
  10042. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10043. if (slotBinding) {
  10044. {
  10045. if (el.slotTarget || el.slotScope) {
  10046. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10047. }
  10048. if (el.parent && !maybeComponent(el.parent)) {
  10049. warn(`<template v-slot> can only appear at the root level inside ` +
  10050. `the receiving component`, el);
  10051. }
  10052. }
  10053. const { name, dynamic } = getSlotName(slotBinding);
  10054. el.slotTarget = name;
  10055. el.slotTargetDynamic = dynamic;
  10056. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10057. }
  10058. }
  10059. else {
  10060. // v-slot on component, denotes default slot
  10061. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10062. if (slotBinding) {
  10063. {
  10064. if (!maybeComponent(el)) {
  10065. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10066. }
  10067. if (el.slotScope || el.slotTarget) {
  10068. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10069. }
  10070. if (el.scopedSlots) {
  10071. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10072. `<template> syntax when there are other named slots.`, slotBinding);
  10073. }
  10074. }
  10075. // add the component's children to its default slot
  10076. const slots = el.scopedSlots || (el.scopedSlots = {});
  10077. const { name, dynamic } = getSlotName(slotBinding);
  10078. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10079. slotContainer.slotTarget = name;
  10080. slotContainer.slotTargetDynamic = dynamic;
  10081. slotContainer.children = el.children.filter((c) => {
  10082. if (!c.slotScope) {
  10083. c.parent = slotContainer;
  10084. return true;
  10085. }
  10086. });
  10087. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10088. // remove children as they are returned from scopedSlots now
  10089. el.children = [];
  10090. // mark el non-plain so data gets generated
  10091. el.plain = false;
  10092. }
  10093. }
  10094. }
  10095. }
  10096. function getSlotName(binding) {
  10097. let name = binding.name.replace(slotRE, '');
  10098. if (!name) {
  10099. if (binding.name[0] !== '#') {
  10100. name = 'default';
  10101. }
  10102. else {
  10103. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10104. }
  10105. }
  10106. return dynamicArgRE.test(name)
  10107. ? // dynamic [name]
  10108. { name: name.slice(1, -1), dynamic: true }
  10109. : // static name
  10110. { name: `"${name}"`, dynamic: false };
  10111. }
  10112. // handle <slot/> outlets
  10113. function processSlotOutlet(el) {
  10114. if (el.tag === 'slot') {
  10115. el.slotName = getBindingAttr(el, 'name');
  10116. if (el.key) {
  10117. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10118. `and can possibly expand into multiple elements. ` +
  10119. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10120. }
  10121. }
  10122. }
  10123. function processComponent(el) {
  10124. let binding;
  10125. if ((binding = getBindingAttr(el, 'is'))) {
  10126. el.component = binding;
  10127. }
  10128. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10129. el.inlineTemplate = true;
  10130. }
  10131. }
  10132. function processAttrs(el) {
  10133. const list = el.attrsList;
  10134. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10135. for (i = 0, l = list.length; i < l; i++) {
  10136. name = rawName = list[i].name;
  10137. value = list[i].value;
  10138. if (dirRE.test(name)) {
  10139. // mark element as dynamic
  10140. el.hasBindings = true;
  10141. // modifiers
  10142. modifiers = parseModifiers(name.replace(dirRE, ''));
  10143. // support .foo shorthand syntax for the .prop modifier
  10144. if (modifiers) {
  10145. name = name.replace(modifierRE, '');
  10146. }
  10147. if (bindRE.test(name)) {
  10148. // v-bind
  10149. name = name.replace(bindRE, '');
  10150. value = parseFilters(value);
  10151. isDynamic = dynamicArgRE.test(name);
  10152. if (isDynamic) {
  10153. name = name.slice(1, -1);
  10154. }
  10155. if (value.trim().length === 0) {
  10156. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10157. }
  10158. if (modifiers) {
  10159. if (modifiers.prop && !isDynamic) {
  10160. name = camelize(name);
  10161. if (name === 'innerHtml')
  10162. name = 'innerHTML';
  10163. }
  10164. if (modifiers.camel && !isDynamic) {
  10165. name = camelize(name);
  10166. }
  10167. if (modifiers.sync) {
  10168. syncGen = genAssignmentCode(value, `$event`);
  10169. if (!isDynamic) {
  10170. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10171. if (hyphenate(name) !== camelize(name)) {
  10172. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10173. }
  10174. }
  10175. else {
  10176. // handler w/ dynamic event name
  10177. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10178. );
  10179. }
  10180. }
  10181. }
  10182. if ((modifiers && modifiers.prop) ||
  10183. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10184. addProp(el, name, value, list[i], isDynamic);
  10185. }
  10186. else {
  10187. addAttr(el, name, value, list[i], isDynamic);
  10188. }
  10189. }
  10190. else if (onRE.test(name)) {
  10191. // v-on
  10192. name = name.replace(onRE, '');
  10193. isDynamic = dynamicArgRE.test(name);
  10194. if (isDynamic) {
  10195. name = name.slice(1, -1);
  10196. }
  10197. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10198. }
  10199. else {
  10200. // normal directives
  10201. name = name.replace(dirRE, '');
  10202. // parse arg
  10203. const argMatch = name.match(argRE);
  10204. let arg = argMatch && argMatch[1];
  10205. isDynamic = false;
  10206. if (arg) {
  10207. name = name.slice(0, -(arg.length + 1));
  10208. if (dynamicArgRE.test(arg)) {
  10209. arg = arg.slice(1, -1);
  10210. isDynamic = true;
  10211. }
  10212. }
  10213. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10214. if (name === 'model') {
  10215. checkForAliasModel(el, value);
  10216. }
  10217. }
  10218. }
  10219. else {
  10220. // literal attribute
  10221. {
  10222. const res = parseText(value, delimiters);
  10223. if (res) {
  10224. warn(`${name}="${value}": ` +
  10225. 'Interpolation inside attributes has been removed. ' +
  10226. 'Use v-bind or the colon shorthand instead. For example, ' +
  10227. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10228. }
  10229. }
  10230. addAttr(el, name, JSON.stringify(value), list[i]);
  10231. // #6887 firefox doesn't update muted state if set via attribute
  10232. // even immediately after element creation
  10233. if (!el.component &&
  10234. name === 'muted' &&
  10235. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10236. addProp(el, name, 'true', list[i]);
  10237. }
  10238. }
  10239. }
  10240. }
  10241. function checkInFor(el) {
  10242. let parent = el;
  10243. while (parent) {
  10244. if (parent.for !== undefined) {
  10245. return true;
  10246. }
  10247. parent = parent.parent;
  10248. }
  10249. return false;
  10250. }
  10251. function parseModifiers(name) {
  10252. const match = name.match(modifierRE);
  10253. if (match) {
  10254. const ret = {};
  10255. match.forEach(m => {
  10256. ret[m.slice(1)] = true;
  10257. });
  10258. return ret;
  10259. }
  10260. }
  10261. function makeAttrsMap(attrs) {
  10262. const map = {};
  10263. for (let i = 0, l = attrs.length; i < l; i++) {
  10264. if (map[attrs[i].name] && !isIE && !isEdge) {
  10265. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10266. }
  10267. map[attrs[i].name] = attrs[i].value;
  10268. }
  10269. return map;
  10270. }
  10271. // for script (e.g. type="x/template") or style, do not decode content
  10272. function isTextTag(el) {
  10273. return el.tag === 'script' || el.tag === 'style';
  10274. }
  10275. function isForbiddenTag(el) {
  10276. return (el.tag === 'style' ||
  10277. (el.tag === 'script' &&
  10278. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10279. }
  10280. const ieNSBug = /^xmlns:NS\d+/;
  10281. const ieNSPrefix = /^NS\d+:/;
  10282. /* istanbul ignore next */
  10283. function guardIESVGBug(attrs) {
  10284. const res = [];
  10285. for (let i = 0; i < attrs.length; i++) {
  10286. const attr = attrs[i];
  10287. if (!ieNSBug.test(attr.name)) {
  10288. attr.name = attr.name.replace(ieNSPrefix, '');
  10289. res.push(attr);
  10290. }
  10291. }
  10292. return res;
  10293. }
  10294. function checkForAliasModel(el, value) {
  10295. let _el = el;
  10296. while (_el) {
  10297. if (_el.for && _el.alias === value) {
  10298. warn(`<${el.tag} v-model="${value}">: ` +
  10299. `You are binding v-model directly to a v-for iteration alias. ` +
  10300. `This will not be able to modify the v-for source array because ` +
  10301. `writing to the alias is like modifying a function local variable. ` +
  10302. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10303. }
  10304. _el = _el.parent;
  10305. }
  10306. }
  10307. /**
  10308. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10309. * Turn this:
  10310. * <input v-model="data[type]" :type="type">
  10311. * into this:
  10312. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10313. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10314. * <input v-else :type="type" v-model="data[type]">
  10315. */
  10316. function preTransformNode(el, options) {
  10317. if (el.tag === 'input') {
  10318. const map = el.attrsMap;
  10319. if (!map['v-model']) {
  10320. return;
  10321. }
  10322. let typeBinding;
  10323. if (map[':type'] || map['v-bind:type']) {
  10324. typeBinding = getBindingAttr(el, 'type');
  10325. }
  10326. if (!map.type && !typeBinding && map['v-bind']) {
  10327. typeBinding = `(${map['v-bind']}).type`;
  10328. }
  10329. if (typeBinding) {
  10330. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10331. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10332. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10333. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10334. // 1. checkbox
  10335. const branch0 = cloneASTElement(el);
  10336. // process for on the main node
  10337. processFor(branch0);
  10338. addRawAttr(branch0, 'type', 'checkbox');
  10339. processElement(branch0, options);
  10340. branch0.processed = true; // prevent it from double-processed
  10341. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10342. addIfCondition(branch0, {
  10343. exp: branch0.if,
  10344. block: branch0
  10345. });
  10346. // 2. add radio else-if condition
  10347. const branch1 = cloneASTElement(el);
  10348. getAndRemoveAttr(branch1, 'v-for', true);
  10349. addRawAttr(branch1, 'type', 'radio');
  10350. processElement(branch1, options);
  10351. addIfCondition(branch0, {
  10352. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10353. block: branch1
  10354. });
  10355. // 3. other
  10356. const branch2 = cloneASTElement(el);
  10357. getAndRemoveAttr(branch2, 'v-for', true);
  10358. addRawAttr(branch2, ':type', typeBinding);
  10359. processElement(branch2, options);
  10360. addIfCondition(branch0, {
  10361. exp: ifCondition,
  10362. block: branch2
  10363. });
  10364. if (hasElse) {
  10365. branch0.else = true;
  10366. }
  10367. else if (elseIfCondition) {
  10368. branch0.elseif = elseIfCondition;
  10369. }
  10370. return branch0;
  10371. }
  10372. }
  10373. }
  10374. function cloneASTElement(el) {
  10375. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10376. }
  10377. var model = {
  10378. preTransformNode
  10379. };
  10380. var modules = [klass, style, model];
  10381. function text(el, dir) {
  10382. if (dir.value) {
  10383. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10384. }
  10385. }
  10386. function html(el, dir) {
  10387. if (dir.value) {
  10388. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10389. }
  10390. }
  10391. var directives = {
  10392. model: model$1,
  10393. text,
  10394. html
  10395. };
  10396. const baseOptions = {
  10397. expectHTML: true,
  10398. modules,
  10399. directives,
  10400. isPreTag,
  10401. isUnaryTag,
  10402. mustUseProp,
  10403. canBeLeftOpenTag,
  10404. isReservedTag,
  10405. getTagNamespace,
  10406. staticKeys: genStaticKeys$1(modules)
  10407. };
  10408. let isStaticKey;
  10409. let isPlatformReservedTag;
  10410. const genStaticKeysCached = cached(genStaticKeys);
  10411. /**
  10412. * Goal of the optimizer: walk the generated template AST tree
  10413. * and detect sub-trees that are purely static, i.e. parts of
  10414. * the DOM that never needs to change.
  10415. *
  10416. * Once we detect these sub-trees, we can:
  10417. *
  10418. * 1. Hoist them into constants, so that we no longer need to
  10419. * create fresh nodes for them on each re-render;
  10420. * 2. Completely skip them in the patching process.
  10421. */
  10422. function optimize(root, options) {
  10423. if (!root)
  10424. return;
  10425. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10426. isPlatformReservedTag = options.isReservedTag || no;
  10427. // first pass: mark all non-static nodes.
  10428. markStatic(root);
  10429. // second pass: mark static roots.
  10430. markStaticRoots(root, false);
  10431. }
  10432. function genStaticKeys(keys) {
  10433. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10434. (keys ? ',' + keys : ''));
  10435. }
  10436. function markStatic(node) {
  10437. node.static = isStatic(node);
  10438. if (node.type === 1) {
  10439. // do not make component slot content static. this avoids
  10440. // 1. components not able to mutate slot nodes
  10441. // 2. static slot content fails for hot-reloading
  10442. if (!isPlatformReservedTag(node.tag) &&
  10443. node.tag !== 'slot' &&
  10444. node.attrsMap['inline-template'] == null) {
  10445. return;
  10446. }
  10447. for (let i = 0, l = node.children.length; i < l; i++) {
  10448. const child = node.children[i];
  10449. markStatic(child);
  10450. if (!child.static) {
  10451. node.static = false;
  10452. }
  10453. }
  10454. if (node.ifConditions) {
  10455. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10456. const block = node.ifConditions[i].block;
  10457. markStatic(block);
  10458. if (!block.static) {
  10459. node.static = false;
  10460. }
  10461. }
  10462. }
  10463. }
  10464. }
  10465. function markStaticRoots(node, isInFor) {
  10466. if (node.type === 1) {
  10467. if (node.static || node.once) {
  10468. node.staticInFor = isInFor;
  10469. }
  10470. // For a node to qualify as a static root, it should have children that
  10471. // are not just static text. Otherwise the cost of hoisting out will
  10472. // outweigh the benefits and it's better off to just always render it fresh.
  10473. if (node.static &&
  10474. node.children.length &&
  10475. !(node.children.length === 1 && node.children[0].type === 3)) {
  10476. node.staticRoot = true;
  10477. return;
  10478. }
  10479. else {
  10480. node.staticRoot = false;
  10481. }
  10482. if (node.children) {
  10483. for (let i = 0, l = node.children.length; i < l; i++) {
  10484. markStaticRoots(node.children[i], isInFor || !!node.for);
  10485. }
  10486. }
  10487. if (node.ifConditions) {
  10488. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10489. markStaticRoots(node.ifConditions[i].block, isInFor);
  10490. }
  10491. }
  10492. }
  10493. }
  10494. function isStatic(node) {
  10495. if (node.type === 2) {
  10496. // expression
  10497. return false;
  10498. }
  10499. if (node.type === 3) {
  10500. // text
  10501. return true;
  10502. }
  10503. return !!(node.pre ||
  10504. (!node.hasBindings && // no dynamic bindings
  10505. !node.if &&
  10506. !node.for && // not v-if or v-for or v-else
  10507. !isBuiltInTag(node.tag) && // not a built-in
  10508. isPlatformReservedTag(node.tag) && // not a component
  10509. !isDirectChildOfTemplateFor(node) &&
  10510. Object.keys(node).every(isStaticKey)));
  10511. }
  10512. function isDirectChildOfTemplateFor(node) {
  10513. while (node.parent) {
  10514. node = node.parent;
  10515. if (node.tag !== 'template') {
  10516. return false;
  10517. }
  10518. if (node.for) {
  10519. return true;
  10520. }
  10521. }
  10522. return false;
  10523. }
  10524. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10525. const fnInvokeRE = /\([^)]*?\);*$/;
  10526. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10527. // KeyboardEvent.keyCode aliases
  10528. const keyCodes = {
  10529. esc: 27,
  10530. tab: 9,
  10531. enter: 13,
  10532. space: 32,
  10533. up: 38,
  10534. left: 37,
  10535. right: 39,
  10536. down: 40,
  10537. delete: [8, 46]
  10538. };
  10539. // KeyboardEvent.key aliases
  10540. const keyNames = {
  10541. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10542. esc: ['Esc', 'Escape'],
  10543. tab: 'Tab',
  10544. enter: 'Enter',
  10545. // #9112: IE11 uses `Spacebar` for Space key name.
  10546. space: [' ', 'Spacebar'],
  10547. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10548. up: ['Up', 'ArrowUp'],
  10549. left: ['Left', 'ArrowLeft'],
  10550. right: ['Right', 'ArrowRight'],
  10551. down: ['Down', 'ArrowDown'],
  10552. // #9112: IE11 uses `Del` for Delete key name.
  10553. delete: ['Backspace', 'Delete', 'Del']
  10554. };
  10555. // #4868: modifiers that prevent the execution of the listener
  10556. // need to explicitly return null so that we can determine whether to remove
  10557. // the listener for .once
  10558. const genGuard = condition => `if(${condition})return null;`;
  10559. const modifierCode = {
  10560. stop: '$event.stopPropagation();',
  10561. prevent: '$event.preventDefault();',
  10562. self: genGuard(`$event.target !== $event.currentTarget`),
  10563. ctrl: genGuard(`!$event.ctrlKey`),
  10564. shift: genGuard(`!$event.shiftKey`),
  10565. alt: genGuard(`!$event.altKey`),
  10566. meta: genGuard(`!$event.metaKey`),
  10567. left: genGuard(`'button' in $event && $event.button !== 0`),
  10568. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10569. right: genGuard(`'button' in $event && $event.button !== 2`)
  10570. };
  10571. function genHandlers(events, isNative) {
  10572. const prefix = isNative ? 'nativeOn:' : 'on:';
  10573. let staticHandlers = ``;
  10574. let dynamicHandlers = ``;
  10575. for (const name in events) {
  10576. const handlerCode = genHandler(events[name]);
  10577. //@ts-expect-error
  10578. if (events[name] && events[name].dynamic) {
  10579. dynamicHandlers += `${name},${handlerCode},`;
  10580. }
  10581. else {
  10582. staticHandlers += `"${name}":${handlerCode},`;
  10583. }
  10584. }
  10585. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10586. if (dynamicHandlers) {
  10587. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10588. }
  10589. else {
  10590. return prefix + staticHandlers;
  10591. }
  10592. }
  10593. function genHandler(handler) {
  10594. if (!handler) {
  10595. return 'function(){}';
  10596. }
  10597. if (Array.isArray(handler)) {
  10598. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10599. }
  10600. const isMethodPath = simplePathRE.test(handler.value);
  10601. const isFunctionExpression = fnExpRE.test(handler.value);
  10602. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10603. if (!handler.modifiers) {
  10604. if (isMethodPath || isFunctionExpression) {
  10605. return handler.value;
  10606. }
  10607. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10608. }
  10609. else {
  10610. let code = '';
  10611. let genModifierCode = '';
  10612. const keys = [];
  10613. for (const key in handler.modifiers) {
  10614. if (modifierCode[key]) {
  10615. genModifierCode += modifierCode[key];
  10616. // left/right
  10617. if (keyCodes[key]) {
  10618. keys.push(key);
  10619. }
  10620. }
  10621. else if (key === 'exact') {
  10622. const modifiers = handler.modifiers;
  10623. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10624. .filter(keyModifier => !modifiers[keyModifier])
  10625. .map(keyModifier => `$event.${keyModifier}Key`)
  10626. .join('||'));
  10627. }
  10628. else {
  10629. keys.push(key);
  10630. }
  10631. }
  10632. if (keys.length) {
  10633. code += genKeyFilter(keys);
  10634. }
  10635. // Make sure modifiers like prevent and stop get executed after key filtering
  10636. if (genModifierCode) {
  10637. code += genModifierCode;
  10638. }
  10639. const handlerCode = isMethodPath
  10640. ? `return ${handler.value}.apply(null, arguments)`
  10641. : isFunctionExpression
  10642. ? `return (${handler.value}).apply(null, arguments)`
  10643. : isFunctionInvocation
  10644. ? `return ${handler.value}`
  10645. : handler.value;
  10646. return `function($event){${code}${handlerCode}}`;
  10647. }
  10648. }
  10649. function genKeyFilter(keys) {
  10650. return (
  10651. // make sure the key filters only apply to KeyboardEvents
  10652. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10653. // key events that do not have keyCode property...
  10654. `if(!$event.type.indexOf('key')&&` +
  10655. `${keys.map(genFilterCode).join('&&')})return null;`);
  10656. }
  10657. function genFilterCode(key) {
  10658. const keyVal = parseInt(key, 10);
  10659. if (keyVal) {
  10660. return `$event.keyCode!==${keyVal}`;
  10661. }
  10662. const keyCode = keyCodes[key];
  10663. const keyName = keyNames[key];
  10664. return (`_k($event.keyCode,` +
  10665. `${JSON.stringify(key)},` +
  10666. `${JSON.stringify(keyCode)},` +
  10667. `$event.key,` +
  10668. `${JSON.stringify(keyName)}` +
  10669. `)`);
  10670. }
  10671. function on(el, dir) {
  10672. if (dir.modifiers) {
  10673. warn$2(`v-on without argument does not support modifiers.`);
  10674. }
  10675. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10676. }
  10677. function bind(el, dir) {
  10678. el.wrapData = (code) => {
  10679. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10680. };
  10681. }
  10682. var baseDirectives = {
  10683. on,
  10684. bind,
  10685. cloak: noop
  10686. };
  10687. class CodegenState {
  10688. constructor(options) {
  10689. this.options = options;
  10690. this.warn = options.warn || baseWarn;
  10691. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10692. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10693. this.directives = extend(extend({}, baseDirectives), options.directives);
  10694. const isReservedTag = options.isReservedTag || no;
  10695. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10696. this.onceId = 0;
  10697. this.staticRenderFns = [];
  10698. this.pre = false;
  10699. }
  10700. }
  10701. function generate(ast, options) {
  10702. const state = new CodegenState(options);
  10703. // fix #11483, Root level <script> tags should not be rendered.
  10704. const code = ast
  10705. ? ast.tag === 'script'
  10706. ? 'null'
  10707. : genElement(ast, state)
  10708. : '_c("div")';
  10709. return {
  10710. render: `with(this){return ${code}}`,
  10711. staticRenderFns: state.staticRenderFns
  10712. };
  10713. }
  10714. function genElement(el, state) {
  10715. if (el.parent) {
  10716. el.pre = el.pre || el.parent.pre;
  10717. }
  10718. if (el.staticRoot && !el.staticProcessed) {
  10719. return genStatic(el, state);
  10720. }
  10721. else if (el.once && !el.onceProcessed) {
  10722. return genOnce(el, state);
  10723. }
  10724. else if (el.for && !el.forProcessed) {
  10725. return genFor(el, state);
  10726. }
  10727. else if (el.if && !el.ifProcessed) {
  10728. return genIf(el, state);
  10729. }
  10730. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10731. return genChildren(el, state) || 'void 0';
  10732. }
  10733. else if (el.tag === 'slot') {
  10734. return genSlot(el, state);
  10735. }
  10736. else {
  10737. // component or element
  10738. let code;
  10739. if (el.component) {
  10740. code = genComponent(el.component, el, state);
  10741. }
  10742. else {
  10743. let data;
  10744. const maybeComponent = state.maybeComponent(el);
  10745. if (!el.plain || (el.pre && maybeComponent)) {
  10746. data = genData(el, state);
  10747. }
  10748. let tag;
  10749. // check if this is a component in <script setup>
  10750. const bindings = state.options.bindings;
  10751. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10752. tag = checkBindingType(bindings, el.tag);
  10753. }
  10754. if (!tag)
  10755. tag = `'${el.tag}'`;
  10756. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10757. code = `_c(${tag}${data ? `,${data}` : '' // data
  10758. }${children ? `,${children}` : '' // children
  10759. })`;
  10760. }
  10761. // module transforms
  10762. for (let i = 0; i < state.transforms.length; i++) {
  10763. code = state.transforms[i](el, code);
  10764. }
  10765. return code;
  10766. }
  10767. }
  10768. function checkBindingType(bindings, key) {
  10769. const camelName = camelize(key);
  10770. const PascalName = capitalize(camelName);
  10771. const checkType = (type) => {
  10772. if (bindings[key] === type) {
  10773. return key;
  10774. }
  10775. if (bindings[camelName] === type) {
  10776. return camelName;
  10777. }
  10778. if (bindings[PascalName] === type) {
  10779. return PascalName;
  10780. }
  10781. };
  10782. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10783. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10784. if (fromConst) {
  10785. return fromConst;
  10786. }
  10787. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10788. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10789. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10790. if (fromMaybeRef) {
  10791. return fromMaybeRef;
  10792. }
  10793. }
  10794. // hoist static sub-trees out
  10795. function genStatic(el, state) {
  10796. el.staticProcessed = true;
  10797. // Some elements (templates) need to behave differently inside of a v-pre
  10798. // node. All pre nodes are static roots, so we can use this as a location to
  10799. // wrap a state change and reset it upon exiting the pre node.
  10800. const originalPreState = state.pre;
  10801. if (el.pre) {
  10802. state.pre = el.pre;
  10803. }
  10804. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10805. state.pre = originalPreState;
  10806. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10807. }
  10808. // v-once
  10809. function genOnce(el, state) {
  10810. el.onceProcessed = true;
  10811. if (el.if && !el.ifProcessed) {
  10812. return genIf(el, state);
  10813. }
  10814. else if (el.staticInFor) {
  10815. let key = '';
  10816. let parent = el.parent;
  10817. while (parent) {
  10818. if (parent.for) {
  10819. key = parent.key;
  10820. break;
  10821. }
  10822. parent = parent.parent;
  10823. }
  10824. if (!key) {
  10825. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10826. return genElement(el, state);
  10827. }
  10828. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10829. }
  10830. else {
  10831. return genStatic(el, state);
  10832. }
  10833. }
  10834. function genIf(el, state, altGen, altEmpty) {
  10835. el.ifProcessed = true; // avoid recursion
  10836. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10837. }
  10838. function genIfConditions(conditions, state, altGen, altEmpty) {
  10839. if (!conditions.length) {
  10840. return altEmpty || '_e()';
  10841. }
  10842. const condition = conditions.shift();
  10843. if (condition.exp) {
  10844. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10845. }
  10846. else {
  10847. return `${genTernaryExp(condition.block)}`;
  10848. }
  10849. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10850. function genTernaryExp(el) {
  10851. return altGen
  10852. ? altGen(el, state)
  10853. : el.once
  10854. ? genOnce(el, state)
  10855. : genElement(el, state);
  10856. }
  10857. }
  10858. function genFor(el, state, altGen, altHelper) {
  10859. const exp = el.for;
  10860. const alias = el.alias;
  10861. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10862. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10863. if (state.maybeComponent(el) &&
  10864. el.tag !== 'slot' &&
  10865. el.tag !== 'template' &&
  10866. !el.key) {
  10867. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10868. `v-for should have explicit keys. ` +
  10869. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10870. }
  10871. el.forProcessed = true; // avoid recursion
  10872. return (`${altHelper || '_l'}((${exp}),` +
  10873. `function(${alias}${iterator1}${iterator2}){` +
  10874. `return ${(altGen || genElement)(el, state)}` +
  10875. '})');
  10876. }
  10877. function genData(el, state) {
  10878. let data = '{';
  10879. // directives first.
  10880. // directives may mutate the el's other properties before they are generated.
  10881. const dirs = genDirectives(el, state);
  10882. if (dirs)
  10883. data += dirs + ',';
  10884. // key
  10885. if (el.key) {
  10886. data += `key:${el.key},`;
  10887. }
  10888. // ref
  10889. if (el.ref) {
  10890. data += `ref:${el.ref},`;
  10891. }
  10892. if (el.refInFor) {
  10893. data += `refInFor:true,`;
  10894. }
  10895. // pre
  10896. if (el.pre) {
  10897. data += `pre:true,`;
  10898. }
  10899. // record original tag name for components using "is" attribute
  10900. if (el.component) {
  10901. data += `tag:"${el.tag}",`;
  10902. }
  10903. // module data generation functions
  10904. for (let i = 0; i < state.dataGenFns.length; i++) {
  10905. data += state.dataGenFns[i](el);
  10906. }
  10907. // attributes
  10908. if (el.attrs) {
  10909. data += `attrs:${genProps(el.attrs)},`;
  10910. }
  10911. // DOM props
  10912. if (el.props) {
  10913. data += `domProps:${genProps(el.props)},`;
  10914. }
  10915. // event handlers
  10916. if (el.events) {
  10917. data += `${genHandlers(el.events, false)},`;
  10918. }
  10919. if (el.nativeEvents) {
  10920. data += `${genHandlers(el.nativeEvents, true)},`;
  10921. }
  10922. // slot target
  10923. // only for non-scoped slots
  10924. if (el.slotTarget && !el.slotScope) {
  10925. data += `slot:${el.slotTarget},`;
  10926. }
  10927. // scoped slots
  10928. if (el.scopedSlots) {
  10929. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10930. }
  10931. // component v-model
  10932. if (el.model) {
  10933. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10934. }
  10935. // inline-template
  10936. if (el.inlineTemplate) {
  10937. const inlineTemplate = genInlineTemplate(el, state);
  10938. if (inlineTemplate) {
  10939. data += `${inlineTemplate},`;
  10940. }
  10941. }
  10942. data = data.replace(/,$/, '') + '}';
  10943. // v-bind dynamic argument wrap
  10944. // v-bind with dynamic arguments must be applied using the same v-bind object
  10945. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10946. if (el.dynamicAttrs) {
  10947. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10948. }
  10949. // v-bind data wrap
  10950. if (el.wrapData) {
  10951. data = el.wrapData(data);
  10952. }
  10953. // v-on data wrap
  10954. if (el.wrapListeners) {
  10955. data = el.wrapListeners(data);
  10956. }
  10957. return data;
  10958. }
  10959. function genDirectives(el, state) {
  10960. const dirs = el.directives;
  10961. if (!dirs)
  10962. return;
  10963. let res = 'directives:[';
  10964. let hasRuntime = false;
  10965. let i, l, dir, needRuntime;
  10966. for (i = 0, l = dirs.length; i < l; i++) {
  10967. dir = dirs[i];
  10968. needRuntime = true;
  10969. const gen = state.directives[dir.name];
  10970. if (gen) {
  10971. // compile-time directive that manipulates AST.
  10972. // returns true if it also needs a runtime counterpart.
  10973. needRuntime = !!gen(el, dir, state.warn);
  10974. }
  10975. if (needRuntime) {
  10976. hasRuntime = true;
  10977. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  10978. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  10979. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  10980. }
  10981. }
  10982. if (hasRuntime) {
  10983. return res.slice(0, -1) + ']';
  10984. }
  10985. }
  10986. function genInlineTemplate(el, state) {
  10987. const ast = el.children[0];
  10988. if ((el.children.length !== 1 || ast.type !== 1)) {
  10989. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  10990. }
  10991. if (ast && ast.type === 1) {
  10992. const inlineRenderFns = generate(ast, state.options);
  10993. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  10994. .map(code => `function(){${code}}`)
  10995. .join(',')}]}`;
  10996. }
  10997. }
  10998. function genScopedSlots(el, slots, state) {
  10999. // by default scoped slots are considered "stable", this allows child
  11000. // components with only scoped slots to skip forced updates from parent.
  11001. // but in some cases we have to bail-out of this optimization
  11002. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11003. let needsForceUpdate = el.for ||
  11004. Object.keys(slots).some(key => {
  11005. const slot = slots[key];
  11006. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11007. );
  11008. });
  11009. // #9534: if a component with scoped slots is inside a conditional branch,
  11010. // it's possible for the same component to be reused but with different
  11011. // compiled slot content. To avoid that, we generate a unique key based on
  11012. // the generated code of all the slot contents.
  11013. let needsKey = !!el.if;
  11014. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11015. // disconnected due to the intermediate scope variable)
  11016. // #9438, #9506
  11017. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11018. // and skip force updating ones that do not actually use scope variables.
  11019. if (!needsForceUpdate) {
  11020. let parent = el.parent;
  11021. while (parent) {
  11022. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11023. parent.for) {
  11024. needsForceUpdate = true;
  11025. break;
  11026. }
  11027. if (parent.if) {
  11028. needsKey = true;
  11029. }
  11030. parent = parent.parent;
  11031. }
  11032. }
  11033. const generatedSlots = Object.keys(slots)
  11034. .map(key => genScopedSlot(slots[key], state))
  11035. .join(',');
  11036. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11037. }
  11038. function hash(str) {
  11039. let hash = 5381;
  11040. let i = str.length;
  11041. while (i) {
  11042. hash = (hash * 33) ^ str.charCodeAt(--i);
  11043. }
  11044. return hash >>> 0;
  11045. }
  11046. function containsSlotChild(el) {
  11047. if (el.type === 1) {
  11048. if (el.tag === 'slot') {
  11049. return true;
  11050. }
  11051. return el.children.some(containsSlotChild);
  11052. }
  11053. return false;
  11054. }
  11055. function genScopedSlot(el, state) {
  11056. const isLegacySyntax = el.attrsMap['slot-scope'];
  11057. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11058. return genIf(el, state, genScopedSlot, `null`);
  11059. }
  11060. if (el.for && !el.forProcessed) {
  11061. return genFor(el, state, genScopedSlot);
  11062. }
  11063. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11064. const fn = `function(${slotScope}){` +
  11065. `return ${el.tag === 'template'
  11066. ? el.if && isLegacySyntax
  11067. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11068. : genChildren(el, state) || 'undefined'
  11069. : genElement(el, state)}}`;
  11070. // reverse proxy v-slot without scope on this.$slots
  11071. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11072. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11073. }
  11074. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11075. const children = el.children;
  11076. if (children.length) {
  11077. const el = children[0];
  11078. // optimize single v-for
  11079. if (children.length === 1 &&
  11080. el.for &&
  11081. el.tag !== 'template' &&
  11082. el.tag !== 'slot') {
  11083. const normalizationType = checkSkip
  11084. ? state.maybeComponent(el)
  11085. ? `,1`
  11086. : `,0`
  11087. : ``;
  11088. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11089. }
  11090. const normalizationType = checkSkip
  11091. ? getNormalizationType(children, state.maybeComponent)
  11092. : 0;
  11093. const gen = altGenNode || genNode;
  11094. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11095. }
  11096. }
  11097. // determine the normalization needed for the children array.
  11098. // 0: no normalization needed
  11099. // 1: simple normalization needed (possible 1-level deep nested array)
  11100. // 2: full normalization needed
  11101. function getNormalizationType(children, maybeComponent) {
  11102. let res = 0;
  11103. for (let i = 0; i < children.length; i++) {
  11104. const el = children[i];
  11105. if (el.type !== 1) {
  11106. continue;
  11107. }
  11108. if (needsNormalization(el) ||
  11109. (el.ifConditions &&
  11110. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11111. res = 2;
  11112. break;
  11113. }
  11114. if (maybeComponent(el) ||
  11115. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11116. res = 1;
  11117. }
  11118. }
  11119. return res;
  11120. }
  11121. function needsNormalization(el) {
  11122. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11123. }
  11124. function genNode(node, state) {
  11125. if (node.type === 1) {
  11126. return genElement(node, state);
  11127. }
  11128. else if (node.type === 3 && node.isComment) {
  11129. return genComment(node);
  11130. }
  11131. else {
  11132. return genText(node);
  11133. }
  11134. }
  11135. function genText(text) {
  11136. return `_v(${text.type === 2
  11137. ? text.expression // no need for () because already wrapped in _s()
  11138. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11139. }
  11140. function genComment(comment) {
  11141. return `_e(${JSON.stringify(comment.text)})`;
  11142. }
  11143. function genSlot(el, state) {
  11144. const slotName = el.slotName || '"default"';
  11145. const children = genChildren(el, state);
  11146. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11147. const attrs = el.attrs || el.dynamicAttrs
  11148. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11149. // slot props are camelized
  11150. name: camelize(attr.name),
  11151. value: attr.value,
  11152. dynamic: attr.dynamic
  11153. })))
  11154. : null;
  11155. const bind = el.attrsMap['v-bind'];
  11156. if ((attrs || bind) && !children) {
  11157. res += `,null`;
  11158. }
  11159. if (attrs) {
  11160. res += `,${attrs}`;
  11161. }
  11162. if (bind) {
  11163. res += `${attrs ? '' : ',null'},${bind}`;
  11164. }
  11165. return res + ')';
  11166. }
  11167. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11168. function genComponent(componentName, el, state) {
  11169. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11170. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11171. }
  11172. function genProps(props) {
  11173. let staticProps = ``;
  11174. let dynamicProps = ``;
  11175. for (let i = 0; i < props.length; i++) {
  11176. const prop = props[i];
  11177. const value = transformSpecialNewlines(prop.value);
  11178. if (prop.dynamic) {
  11179. dynamicProps += `${prop.name},${value},`;
  11180. }
  11181. else {
  11182. staticProps += `"${prop.name}":${value},`;
  11183. }
  11184. }
  11185. staticProps = `{${staticProps.slice(0, -1)}}`;
  11186. if (dynamicProps) {
  11187. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11188. }
  11189. else {
  11190. return staticProps;
  11191. }
  11192. }
  11193. // #3895, #4268
  11194. function transformSpecialNewlines(text) {
  11195. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11196. }
  11197. // these keywords should not appear inside expressions, but operators like
  11198. // typeof, instanceof and in are allowed
  11199. const prohibitedKeywordRE = new RegExp('\\b' +
  11200. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11201. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11202. 'extends,finally,continue,debugger,function,arguments')
  11203. .split(',')
  11204. .join('\\b|\\b') +
  11205. '\\b');
  11206. // these unary operators should not be used as property/method names
  11207. const unaryOperatorsRE = new RegExp('\\b' +
  11208. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11209. '\\s*\\([^\\)]*\\)');
  11210. // strip strings in expressions
  11211. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11212. // detect problematic expressions in a template
  11213. function detectErrors(ast, warn) {
  11214. if (ast) {
  11215. checkNode(ast, warn);
  11216. }
  11217. }
  11218. function checkNode(node, warn) {
  11219. if (node.type === 1) {
  11220. for (const name in node.attrsMap) {
  11221. if (dirRE.test(name)) {
  11222. const value = node.attrsMap[name];
  11223. if (value) {
  11224. const range = node.rawAttrsMap[name];
  11225. if (name === 'v-for') {
  11226. checkFor(node, `v-for="${value}"`, warn, range);
  11227. }
  11228. else if (name === 'v-slot' || name[0] === '#') {
  11229. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11230. }
  11231. else if (onRE.test(name)) {
  11232. checkEvent(value, `${name}="${value}"`, warn, range);
  11233. }
  11234. else {
  11235. checkExpression(value, `${name}="${value}"`, warn, range);
  11236. }
  11237. }
  11238. }
  11239. }
  11240. if (node.children) {
  11241. for (let i = 0; i < node.children.length; i++) {
  11242. checkNode(node.children[i], warn);
  11243. }
  11244. }
  11245. }
  11246. else if (node.type === 2) {
  11247. checkExpression(node.expression, node.text, warn, node);
  11248. }
  11249. }
  11250. function checkEvent(exp, text, warn, range) {
  11251. const stripped = exp.replace(stripStringRE, '');
  11252. const keywordMatch = stripped.match(unaryOperatorsRE);
  11253. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11254. warn(`avoid using JavaScript unary operator as property name: ` +
  11255. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11256. }
  11257. checkExpression(exp, text, warn, range);
  11258. }
  11259. function checkFor(node, text, warn, range) {
  11260. checkExpression(node.for || '', text, warn, range);
  11261. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11262. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11263. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11264. }
  11265. function checkIdentifier(ident, type, text, warn, range) {
  11266. if (typeof ident === 'string') {
  11267. try {
  11268. new Function(`var ${ident}=_`);
  11269. }
  11270. catch (e) {
  11271. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11272. }
  11273. }
  11274. }
  11275. function checkExpression(exp, text, warn, range) {
  11276. try {
  11277. new Function(`return ${exp}`);
  11278. }
  11279. catch (e) {
  11280. const keywordMatch = exp
  11281. .replace(stripStringRE, '')
  11282. .match(prohibitedKeywordRE);
  11283. if (keywordMatch) {
  11284. warn(`avoid using JavaScript keyword as property name: ` +
  11285. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11286. }
  11287. else {
  11288. warn(`invalid expression: ${e.message} in\n\n` +
  11289. ` ${exp}\n\n` +
  11290. ` Raw expression: ${text.trim()}\n`, range);
  11291. }
  11292. }
  11293. }
  11294. function checkFunctionParameterExpression(exp, text, warn, range) {
  11295. try {
  11296. new Function(exp, '');
  11297. }
  11298. catch (e) {
  11299. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11300. ` ${exp}\n\n` +
  11301. ` Raw expression: ${text.trim()}\n`, range);
  11302. }
  11303. }
  11304. const range = 2;
  11305. function generateCodeFrame(source, start = 0, end = source.length) {
  11306. const lines = source.split(/\r?\n/);
  11307. let count = 0;
  11308. const res = [];
  11309. for (let i = 0; i < lines.length; i++) {
  11310. count += lines[i].length + 1;
  11311. if (count >= start) {
  11312. for (let j = i - range; j <= i + range || end > count; j++) {
  11313. if (j < 0 || j >= lines.length)
  11314. continue;
  11315. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11316. const lineLength = lines[j].length;
  11317. if (j === i) {
  11318. // push underline
  11319. const pad = start - (count - lineLength) + 1;
  11320. const length = end > count ? lineLength - pad : end - start;
  11321. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11322. }
  11323. else if (j > i) {
  11324. if (end > count) {
  11325. const length = Math.min(end - count, lineLength);
  11326. res.push(` | ` + repeat(`^`, length));
  11327. }
  11328. count += lineLength + 1;
  11329. }
  11330. }
  11331. break;
  11332. }
  11333. }
  11334. return res.join('\n');
  11335. }
  11336. function repeat(str, n) {
  11337. let result = '';
  11338. if (n > 0) {
  11339. // eslint-disable-next-line no-constant-condition
  11340. while (true) {
  11341. // eslint-disable-line
  11342. if (n & 1)
  11343. result += str;
  11344. n >>>= 1;
  11345. if (n <= 0)
  11346. break;
  11347. str += str;
  11348. }
  11349. }
  11350. return result;
  11351. }
  11352. function createFunction(code, errors) {
  11353. try {
  11354. return new Function(code);
  11355. }
  11356. catch (err) {
  11357. errors.push({ err, code });
  11358. return noop;
  11359. }
  11360. }
  11361. function createCompileToFunctionFn(compile) {
  11362. const cache = Object.create(null);
  11363. return function compileToFunctions(template, options, vm) {
  11364. options = extend({}, options);
  11365. const warn = options.warn || warn$2;
  11366. delete options.warn;
  11367. /* istanbul ignore if */
  11368. {
  11369. // detect possible CSP restriction
  11370. try {
  11371. new Function('return 1');
  11372. }
  11373. catch (e) {
  11374. if (e.toString().match(/unsafe-eval|CSP/)) {
  11375. warn('It seems you are using the standalone build of Vue.js in an ' +
  11376. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11377. 'The template compiler cannot work in this environment. Consider ' +
  11378. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11379. 'templates into render functions.');
  11380. }
  11381. }
  11382. }
  11383. // check cache
  11384. const key = options.delimiters
  11385. ? String(options.delimiters) + template
  11386. : template;
  11387. if (cache[key]) {
  11388. return cache[key];
  11389. }
  11390. // compile
  11391. const compiled = compile(template, options);
  11392. // check compilation errors/tips
  11393. {
  11394. if (compiled.errors && compiled.errors.length) {
  11395. if (options.outputSourceRange) {
  11396. compiled.errors.forEach(e => {
  11397. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11398. generateCodeFrame(template, e.start, e.end), vm);
  11399. });
  11400. }
  11401. else {
  11402. warn(`Error compiling template:\n\n${template}\n\n` +
  11403. compiled.errors.map(e => `- ${e}`).join('\n') +
  11404. '\n', vm);
  11405. }
  11406. }
  11407. if (compiled.tips && compiled.tips.length) {
  11408. if (options.outputSourceRange) {
  11409. compiled.tips.forEach(e => tip(e.msg, vm));
  11410. }
  11411. else {
  11412. compiled.tips.forEach(msg => tip(msg, vm));
  11413. }
  11414. }
  11415. }
  11416. // turn code into functions
  11417. const res = {};
  11418. const fnGenErrors = [];
  11419. res.render = createFunction(compiled.render, fnGenErrors);
  11420. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11421. return createFunction(code, fnGenErrors);
  11422. });
  11423. // check function generation errors.
  11424. // this should only happen if there is a bug in the compiler itself.
  11425. // mostly for codegen development use
  11426. /* istanbul ignore if */
  11427. {
  11428. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11429. warn(`Failed to generate render function:\n\n` +
  11430. fnGenErrors
  11431. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11432. .join('\n'), vm);
  11433. }
  11434. }
  11435. return (cache[key] = res);
  11436. };
  11437. }
  11438. function createCompilerCreator(baseCompile) {
  11439. return function createCompiler(baseOptions) {
  11440. function compile(template, options) {
  11441. const finalOptions = Object.create(baseOptions);
  11442. const errors = [];
  11443. const tips = [];
  11444. let warn = (msg, range, tip) => {
  11445. (tip ? tips : errors).push(msg);
  11446. };
  11447. if (options) {
  11448. if (options.outputSourceRange) {
  11449. // $flow-disable-line
  11450. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11451. warn = (msg, range, tip) => {
  11452. const data = typeof msg === 'string' ? { msg } : msg;
  11453. if (range) {
  11454. if (range.start != null) {
  11455. data.start = range.start + leadingSpaceLength;
  11456. }
  11457. if (range.end != null) {
  11458. data.end = range.end + leadingSpaceLength;
  11459. }
  11460. }
  11461. (tip ? tips : errors).push(data);
  11462. };
  11463. }
  11464. // merge custom modules
  11465. if (options.modules) {
  11466. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11467. }
  11468. // merge custom directives
  11469. if (options.directives) {
  11470. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11471. }
  11472. // copy other options
  11473. for (const key in options) {
  11474. if (key !== 'modules' && key !== 'directives') {
  11475. finalOptions[key] = options[key];
  11476. }
  11477. }
  11478. }
  11479. finalOptions.warn = warn;
  11480. const compiled = baseCompile(template.trim(), finalOptions);
  11481. {
  11482. detectErrors(compiled.ast, warn);
  11483. }
  11484. compiled.errors = errors;
  11485. compiled.tips = tips;
  11486. return compiled;
  11487. }
  11488. return {
  11489. compile,
  11490. compileToFunctions: createCompileToFunctionFn(compile)
  11491. };
  11492. };
  11493. }
  11494. // `createCompilerCreator` allows creating compilers that use alternative
  11495. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11496. // Here we just export a default compiler using the default parts.
  11497. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11498. const ast = parse(template.trim(), options);
  11499. if (options.optimize !== false) {
  11500. optimize(ast, options);
  11501. }
  11502. const code = generate(ast, options);
  11503. return {
  11504. ast,
  11505. render: code.render,
  11506. staticRenderFns: code.staticRenderFns
  11507. };
  11508. });
  11509. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11510. // check whether current browser encodes a char inside attribute values
  11511. let div;
  11512. function getShouldDecode(href) {
  11513. div = div || document.createElement('div');
  11514. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11515. return div.innerHTML.indexOf('&#10;') > 0;
  11516. }
  11517. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11518. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11519. // #6828: chrome encodes content in a[href]
  11520. const shouldDecodeNewlinesForHref = inBrowser
  11521. ? getShouldDecode(true)
  11522. : false;
  11523. const idToTemplate = cached(id => {
  11524. const el = query(id);
  11525. return el && el.innerHTML;
  11526. });
  11527. const mount = Vue.prototype.$mount;
  11528. Vue.prototype.$mount = function (el, hydrating) {
  11529. el = el && query(el);
  11530. /* istanbul ignore if */
  11531. if (el === document.body || el === document.documentElement) {
  11532. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11533. return this;
  11534. }
  11535. const options = this.$options;
  11536. // resolve template/el and convert to render function
  11537. if (!options.render) {
  11538. let template = options.template;
  11539. if (template) {
  11540. if (typeof template === 'string') {
  11541. if (template.charAt(0) === '#') {
  11542. template = idToTemplate(template);
  11543. /* istanbul ignore if */
  11544. if (!template) {
  11545. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11546. }
  11547. }
  11548. }
  11549. else if (template.nodeType) {
  11550. template = template.innerHTML;
  11551. }
  11552. else {
  11553. {
  11554. warn$2('invalid template option:' + template, this);
  11555. }
  11556. return this;
  11557. }
  11558. }
  11559. else if (el) {
  11560. // @ts-expect-error
  11561. template = getOuterHTML(el);
  11562. }
  11563. if (template) {
  11564. /* istanbul ignore if */
  11565. if (config.performance && mark) {
  11566. mark('compile');
  11567. }
  11568. const { render, staticRenderFns } = compileToFunctions(template, {
  11569. outputSourceRange: true,
  11570. shouldDecodeNewlines,
  11571. shouldDecodeNewlinesForHref,
  11572. delimiters: options.delimiters,
  11573. comments: options.comments
  11574. }, this);
  11575. options.render = render;
  11576. options.staticRenderFns = staticRenderFns;
  11577. /* istanbul ignore if */
  11578. if (config.performance && mark) {
  11579. mark('compile end');
  11580. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11581. }
  11582. }
  11583. }
  11584. return mount.call(this, el, hydrating);
  11585. };
  11586. /**
  11587. * Get outerHTML of elements, taking care
  11588. * of SVG elements in IE as well.
  11589. */
  11590. function getOuterHTML(el) {
  11591. if (el.outerHTML) {
  11592. return el.outerHTML;
  11593. }
  11594. else {
  11595. const container = document.createElement('div');
  11596. container.appendChild(el.cloneNode(true));
  11597. return container.innerHTML;
  11598. }
  11599. }
  11600. Vue.compile = compileToFunctions;
  11601. export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };