vue.common.dev.js 389 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782
  1. /*!
  2. * Vue.js v2.7.12
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray(list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret;
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend(to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to;
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject(arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res;
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop(a, b, c) { }
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys$1(modules) {
  243. return modules
  244. .reduce((keys, m) => {
  245. return keys.concat(m.staticKeys || []);
  246. }, [])
  247. .join(',');
  248. }
  249. /**
  250. * Check if two values are loosely equal - that is,
  251. * if they are plain objects, do they have the same shape?
  252. */
  253. function looseEqual(a, b) {
  254. if (a === b)
  255. return true;
  256. const isObjectA = isObject(a);
  257. const isObjectB = isObject(b);
  258. if (isObjectA && isObjectB) {
  259. try {
  260. const isArrayA = Array.isArray(a);
  261. const isArrayB = Array.isArray(b);
  262. if (isArrayA && isArrayB) {
  263. return (a.length === b.length &&
  264. a.every((e, i) => {
  265. return looseEqual(e, b[i]);
  266. }));
  267. }
  268. else if (a instanceof Date && b instanceof Date) {
  269. return a.getTime() === b.getTime();
  270. }
  271. else if (!isArrayA && !isArrayB) {
  272. const keysA = Object.keys(a);
  273. const keysB = Object.keys(b);
  274. return (keysA.length === keysB.length &&
  275. keysA.every(key => {
  276. return looseEqual(a[key], b[key]);
  277. }));
  278. }
  279. else {
  280. /* istanbul ignore next */
  281. return false;
  282. }
  283. }
  284. catch (e) {
  285. /* istanbul ignore next */
  286. return false;
  287. }
  288. }
  289. else if (!isObjectA && !isObjectB) {
  290. return String(a) === String(b);
  291. }
  292. else {
  293. return false;
  294. }
  295. }
  296. /**
  297. * Return the first index at which a loosely equal value can be
  298. * found in the array (if value is a plain object, the array must
  299. * contain an object of the same shape), or -1 if it is not present.
  300. */
  301. function looseIndexOf(arr, val) {
  302. for (let i = 0; i < arr.length; i++) {
  303. if (looseEqual(arr[i], val))
  304. return i;
  305. }
  306. return -1;
  307. }
  308. /**
  309. * Ensure a function is called only once.
  310. */
  311. function once(fn) {
  312. let called = false;
  313. return function () {
  314. if (!called) {
  315. called = true;
  316. fn.apply(this, arguments);
  317. }
  318. };
  319. }
  320. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  321. function hasChanged(x, y) {
  322. if (x === y) {
  323. return x === 0 && 1 / x !== 1 / y;
  324. }
  325. else {
  326. return x === x || y === y;
  327. }
  328. }
  329. const SSR_ATTR = 'data-server-rendered';
  330. const ASSET_TYPES = ['component', 'directive', 'filter'];
  331. const LIFECYCLE_HOOKS = [
  332. 'beforeCreate',
  333. 'created',
  334. 'beforeMount',
  335. 'mounted',
  336. 'beforeUpdate',
  337. 'updated',
  338. 'beforeDestroy',
  339. 'destroyed',
  340. 'activated',
  341. 'deactivated',
  342. 'errorCaptured',
  343. 'serverPrefetch',
  344. 'renderTracked',
  345. 'renderTriggered'
  346. ];
  347. var config = {
  348. /**
  349. * Option merge strategies (used in core/util/options)
  350. */
  351. // $flow-disable-line
  352. optionMergeStrategies: Object.create(null),
  353. /**
  354. * Whether to suppress warnings.
  355. */
  356. silent: false,
  357. /**
  358. * Show production mode tip message on boot?
  359. */
  360. productionTip: true,
  361. /**
  362. * Whether to enable devtools
  363. */
  364. devtools: true,
  365. /**
  366. * Whether to record perf
  367. */
  368. performance: false,
  369. /**
  370. * Error handler for watcher errors
  371. */
  372. errorHandler: null,
  373. /**
  374. * Warn handler for watcher warns
  375. */
  376. warnHandler: null,
  377. /**
  378. * Ignore certain custom elements
  379. */
  380. ignoredElements: [],
  381. /**
  382. * Custom user key aliases for v-on
  383. */
  384. // $flow-disable-line
  385. keyCodes: Object.create(null),
  386. /**
  387. * Check if a tag is reserved so that it cannot be registered as a
  388. * component. This is platform-dependent and may be overwritten.
  389. */
  390. isReservedTag: no,
  391. /**
  392. * Check if an attribute is reserved so that it cannot be used as a component
  393. * prop. This is platform-dependent and may be overwritten.
  394. */
  395. isReservedAttr: no,
  396. /**
  397. * Check if a tag is an unknown element.
  398. * Platform-dependent.
  399. */
  400. isUnknownElement: no,
  401. /**
  402. * Get the namespace of an element
  403. */
  404. getTagNamespace: noop,
  405. /**
  406. * Parse the real tag name for the specific platform.
  407. */
  408. parsePlatformTagName: identity,
  409. /**
  410. * Check if an attribute must be bound using property, e.g. value
  411. * Platform-dependent.
  412. */
  413. mustUseProp: no,
  414. /**
  415. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  416. * This will significantly reduce performance if set to false.
  417. */
  418. async: true,
  419. /**
  420. * Exposed for legacy reasons
  421. */
  422. _lifecycleHooks: LIFECYCLE_HOOKS
  423. };
  424. /**
  425. * unicode letters used for parsing html tags, component names and property paths.
  426. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  427. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  428. */
  429. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  430. /**
  431. * Check if a string starts with $ or _
  432. */
  433. function isReserved(str) {
  434. const c = (str + '').charCodeAt(0);
  435. return c === 0x24 || c === 0x5f;
  436. }
  437. /**
  438. * Define a property.
  439. */
  440. function def(obj, key, val, enumerable) {
  441. Object.defineProperty(obj, key, {
  442. value: val,
  443. enumerable: !!enumerable,
  444. writable: true,
  445. configurable: true
  446. });
  447. }
  448. /**
  449. * Parse simple path.
  450. */
  451. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  452. function parsePath(path) {
  453. if (bailRE.test(path)) {
  454. return;
  455. }
  456. const segments = path.split('.');
  457. return function (obj) {
  458. for (let i = 0; i < segments.length; i++) {
  459. if (!obj)
  460. return;
  461. obj = obj[segments[i]];
  462. }
  463. return obj;
  464. };
  465. }
  466. // can we use __proto__?
  467. const hasProto = '__proto__' in {};
  468. // Browser environment sniffing
  469. const inBrowser = typeof window !== 'undefined';
  470. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  471. const isIE = UA && /msie|trident/.test(UA);
  472. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  473. const isEdge = UA && UA.indexOf('edge/') > 0;
  474. UA && UA.indexOf('android') > 0;
  475. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  476. UA && /chrome\/\d+/.test(UA) && !isEdge;
  477. UA && /phantomjs/.test(UA);
  478. const isFF = UA && UA.match(/firefox\/(\d+)/);
  479. // Firefox has a "watch" function on Object.prototype...
  480. // @ts-expect-error firebox support
  481. const nativeWatch = {}.watch;
  482. let supportsPassive = false;
  483. if (inBrowser) {
  484. try {
  485. const opts = {};
  486. Object.defineProperty(opts, 'passive', {
  487. get() {
  488. /* istanbul ignore next */
  489. supportsPassive = true;
  490. }
  491. }); // https://github.com/facebook/flow/issues/285
  492. window.addEventListener('test-passive', null, opts);
  493. }
  494. catch (e) { }
  495. }
  496. // this needs to be lazy-evaled because vue may be required before
  497. // vue-server-renderer can set VUE_ENV
  498. let _isServer;
  499. const isServerRendering = () => {
  500. if (_isServer === undefined) {
  501. /* istanbul ignore if */
  502. if (!inBrowser && typeof global !== 'undefined') {
  503. // detect presence of vue-server-renderer and avoid
  504. // Webpack shimming the process
  505. _isServer =
  506. global['process'] && global['process'].env.VUE_ENV === 'server';
  507. }
  508. else {
  509. _isServer = false;
  510. }
  511. }
  512. return _isServer;
  513. };
  514. // detect devtools
  515. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  516. /* istanbul ignore next */
  517. function isNative(Ctor) {
  518. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  519. }
  520. const hasSymbol = typeof Symbol !== 'undefined' &&
  521. isNative(Symbol) &&
  522. typeof Reflect !== 'undefined' &&
  523. isNative(Reflect.ownKeys);
  524. let _Set; // $flow-disable-line
  525. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  526. // use native Set when available.
  527. _Set = Set;
  528. }
  529. else {
  530. // a non-standard Set polyfill that only works with primitive keys.
  531. _Set = class Set {
  532. constructor() {
  533. this.set = Object.create(null);
  534. }
  535. has(key) {
  536. return this.set[key] === true;
  537. }
  538. add(key) {
  539. this.set[key] = true;
  540. }
  541. clear() {
  542. this.set = Object.create(null);
  543. }
  544. };
  545. }
  546. let currentInstance = null;
  547. /**
  548. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  549. * relies on it). Do not use this internally, just use `currentInstance`.
  550. *
  551. * @internal this function needs manual type declaration because it relies
  552. * on previously manually authored types from Vue 2
  553. */
  554. function getCurrentInstance() {
  555. return currentInstance && { proxy: currentInstance };
  556. }
  557. /**
  558. * @internal
  559. */
  560. function setCurrentInstance(vm = null) {
  561. if (!vm)
  562. currentInstance && currentInstance._scope.off();
  563. currentInstance = vm;
  564. vm && vm._scope.on();
  565. }
  566. /**
  567. * @internal
  568. */
  569. class VNode {
  570. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  571. this.tag = tag;
  572. this.data = data;
  573. this.children = children;
  574. this.text = text;
  575. this.elm = elm;
  576. this.ns = undefined;
  577. this.context = context;
  578. this.fnContext = undefined;
  579. this.fnOptions = undefined;
  580. this.fnScopeId = undefined;
  581. this.key = data && data.key;
  582. this.componentOptions = componentOptions;
  583. this.componentInstance = undefined;
  584. this.parent = undefined;
  585. this.raw = false;
  586. this.isStatic = false;
  587. this.isRootInsert = true;
  588. this.isComment = false;
  589. this.isCloned = false;
  590. this.isOnce = false;
  591. this.asyncFactory = asyncFactory;
  592. this.asyncMeta = undefined;
  593. this.isAsyncPlaceholder = false;
  594. }
  595. // DEPRECATED: alias for componentInstance for backwards compat.
  596. /* istanbul ignore next */
  597. get child() {
  598. return this.componentInstance;
  599. }
  600. }
  601. const createEmptyVNode = (text = '') => {
  602. const node = new VNode();
  603. node.text = text;
  604. node.isComment = true;
  605. return node;
  606. };
  607. function createTextVNode(val) {
  608. return new VNode(undefined, undefined, undefined, String(val));
  609. }
  610. // optimized shallow clone
  611. // used for static nodes and slot nodes because they may be reused across
  612. // multiple renders, cloning them avoids errors when DOM manipulations rely
  613. // on their elm reference.
  614. function cloneVNode(vnode) {
  615. const cloned = new VNode(vnode.tag, vnode.data,
  616. // #7975
  617. // clone children array to avoid mutating original in case of cloning
  618. // a child.
  619. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  620. cloned.ns = vnode.ns;
  621. cloned.isStatic = vnode.isStatic;
  622. cloned.key = vnode.key;
  623. cloned.isComment = vnode.isComment;
  624. cloned.fnContext = vnode.fnContext;
  625. cloned.fnOptions = vnode.fnOptions;
  626. cloned.fnScopeId = vnode.fnScopeId;
  627. cloned.asyncMeta = vnode.asyncMeta;
  628. cloned.isCloned = true;
  629. return cloned;
  630. }
  631. /* not type checking this file because flow doesn't play well with Proxy */
  632. let initProxy;
  633. {
  634. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  635. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  636. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  637. 'require' // for Webpack/Browserify
  638. );
  639. const warnNonPresent = (target, key) => {
  640. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  641. 'referenced during render. Make sure that this property is reactive, ' +
  642. 'either in the data option, or for class-based components, by ' +
  643. 'initializing the property. ' +
  644. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  645. };
  646. const warnReservedPrefix = (target, key) => {
  647. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  648. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  649. 'prevent conflicts with Vue internals. ' +
  650. 'See: https://v2.vuejs.org/v2/api/#data', target);
  651. };
  652. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  653. if (hasProxy) {
  654. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  655. config.keyCodes = new Proxy(config.keyCodes, {
  656. set(target, key, value) {
  657. if (isBuiltInModifier(key)) {
  658. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  659. return false;
  660. }
  661. else {
  662. target[key] = value;
  663. return true;
  664. }
  665. }
  666. });
  667. }
  668. const hasHandler = {
  669. has(target, key) {
  670. const has = key in target;
  671. const isAllowed = allowedGlobals(key) ||
  672. (typeof key === 'string' &&
  673. key.charAt(0) === '_' &&
  674. !(key in target.$data));
  675. if (!has && !isAllowed) {
  676. if (key in target.$data)
  677. warnReservedPrefix(target, key);
  678. else
  679. warnNonPresent(target, key);
  680. }
  681. return has || !isAllowed;
  682. }
  683. };
  684. const getHandler = {
  685. get(target, key) {
  686. if (typeof key === 'string' && !(key in target)) {
  687. if (key in target.$data)
  688. warnReservedPrefix(target, key);
  689. else
  690. warnNonPresent(target, key);
  691. }
  692. return target[key];
  693. }
  694. };
  695. initProxy = function initProxy(vm) {
  696. if (hasProxy) {
  697. // determine which proxy handler to use
  698. const options = vm.$options;
  699. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  700. vm._renderProxy = new Proxy(vm, handlers);
  701. }
  702. else {
  703. vm._renderProxy = vm;
  704. }
  705. };
  706. }
  707. let uid$2 = 0;
  708. const pendingCleanupDeps = [];
  709. const cleanupDeps = () => {
  710. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  711. const dep = pendingCleanupDeps[i];
  712. dep.subs = dep.subs.filter(s => s);
  713. dep._pending = false;
  714. }
  715. pendingCleanupDeps.length = 0;
  716. };
  717. /**
  718. * A dep is an observable that can have multiple
  719. * directives subscribing to it.
  720. * @internal
  721. */
  722. class Dep {
  723. constructor() {
  724. // pending subs cleanup
  725. this._pending = false;
  726. this.id = uid$2++;
  727. this.subs = [];
  728. }
  729. addSub(sub) {
  730. this.subs.push(sub);
  731. }
  732. removeSub(sub) {
  733. // #12696 deps with massive amount of subscribers are extremely slow to
  734. // clean up in Chromium
  735. // to workaround this, we unset the sub for now, and clear them on
  736. // next scheduler flush.
  737. this.subs[this.subs.indexOf(sub)] = null;
  738. if (!this._pending) {
  739. this._pending = true;
  740. pendingCleanupDeps.push(this);
  741. }
  742. }
  743. depend(info) {
  744. if (Dep.target) {
  745. Dep.target.addDep(this);
  746. if (info && Dep.target.onTrack) {
  747. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  748. }
  749. }
  750. }
  751. notify(info) {
  752. // stabilize the subscriber list first
  753. const subs = this.subs.filter(s => s);
  754. if (!config.async) {
  755. // subs aren't sorted in scheduler if not running async
  756. // we need to sort them now to make sure they fire in correct
  757. // order
  758. subs.sort((a, b) => a.id - b.id);
  759. }
  760. for (let i = 0, l = subs.length; i < l; i++) {
  761. const sub = subs[i];
  762. if (info) {
  763. sub.onTrigger &&
  764. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  765. }
  766. sub.update();
  767. }
  768. }
  769. }
  770. // The current target watcher being evaluated.
  771. // This is globally unique because only one watcher
  772. // can be evaluated at a time.
  773. Dep.target = null;
  774. const targetStack = [];
  775. function pushTarget(target) {
  776. targetStack.push(target);
  777. Dep.target = target;
  778. }
  779. function popTarget() {
  780. targetStack.pop();
  781. Dep.target = targetStack[targetStack.length - 1];
  782. }
  783. /*
  784. * not type checking this file because flow doesn't play well with
  785. * dynamically accessing methods on Array prototype
  786. */
  787. const arrayProto = Array.prototype;
  788. const arrayMethods = Object.create(arrayProto);
  789. const methodsToPatch = [
  790. 'push',
  791. 'pop',
  792. 'shift',
  793. 'unshift',
  794. 'splice',
  795. 'sort',
  796. 'reverse'
  797. ];
  798. /**
  799. * Intercept mutating methods and emit events
  800. */
  801. methodsToPatch.forEach(function (method) {
  802. // cache original method
  803. const original = arrayProto[method];
  804. def(arrayMethods, method, function mutator(...args) {
  805. const result = original.apply(this, args);
  806. const ob = this.__ob__;
  807. let inserted;
  808. switch (method) {
  809. case 'push':
  810. case 'unshift':
  811. inserted = args;
  812. break;
  813. case 'splice':
  814. inserted = args.slice(2);
  815. break;
  816. }
  817. if (inserted)
  818. ob.observeArray(inserted);
  819. // notify change
  820. {
  821. ob.dep.notify({
  822. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  823. target: this,
  824. key: method
  825. });
  826. }
  827. return result;
  828. });
  829. });
  830. const rawMap = new WeakMap();
  831. function reactive(target) {
  832. makeReactive(target, false);
  833. return target;
  834. }
  835. /**
  836. * Return a shallowly-reactive copy of the original object, where only the root
  837. * level properties are reactive. It also does not auto-unwrap refs (even at the
  838. * root level).
  839. */
  840. function shallowReactive(target) {
  841. makeReactive(target, true);
  842. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  843. return target;
  844. }
  845. function makeReactive(target, shallow) {
  846. // if trying to observe a readonly proxy, return the readonly version.
  847. if (!isReadonly(target)) {
  848. {
  849. if (isArray(target)) {
  850. 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.`);
  851. }
  852. const existingOb = target && target.__ob__;
  853. if (existingOb && existingOb.shallow !== shallow) {
  854. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  855. }
  856. }
  857. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  858. if (!ob) {
  859. if (target == null || isPrimitive(target)) {
  860. warn$2(`value cannot be made reactive: ${String(target)}`);
  861. }
  862. if (isCollectionType(target)) {
  863. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  864. }
  865. }
  866. }
  867. }
  868. function isReactive(value) {
  869. if (isReadonly(value)) {
  870. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  871. }
  872. return !!(value && value.__ob__);
  873. }
  874. function isShallow(value) {
  875. return !!(value && value.__v_isShallow);
  876. }
  877. function isReadonly(value) {
  878. return !!(value && value.__v_isReadonly);
  879. }
  880. function isProxy(value) {
  881. return isReactive(value) || isReadonly(value);
  882. }
  883. function toRaw(observed) {
  884. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  885. return raw ? toRaw(raw) : observed;
  886. }
  887. function markRaw(value) {
  888. if (isObject(value)) {
  889. rawMap.set(value, true);
  890. }
  891. return value;
  892. }
  893. /**
  894. * @internal
  895. */
  896. function isCollectionType(value) {
  897. const type = toRawType(value);
  898. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  899. }
  900. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  901. const NO_INIITIAL_VALUE = {};
  902. /**
  903. * In some cases we may want to disable observation inside a component's
  904. * update computation.
  905. */
  906. let shouldObserve = true;
  907. function toggleObserving(value) {
  908. shouldObserve = value;
  909. }
  910. // ssr mock dep
  911. const mockDep = {
  912. notify: noop,
  913. depend: noop,
  914. addSub: noop,
  915. removeSub: noop
  916. };
  917. /**
  918. * Observer class that is attached to each observed
  919. * object. Once attached, the observer converts the target
  920. * object's property keys into getter/setters that
  921. * collect dependencies and dispatch updates.
  922. */
  923. class Observer {
  924. constructor(value, shallow = false, mock = false) {
  925. this.value = value;
  926. this.shallow = shallow;
  927. this.mock = mock;
  928. // this.value = value
  929. this.dep = mock ? mockDep : new Dep();
  930. this.vmCount = 0;
  931. def(value, '__ob__', this);
  932. if (isArray(value)) {
  933. if (!mock) {
  934. if (hasProto) {
  935. value.__proto__ = arrayMethods;
  936. /* eslint-enable no-proto */
  937. }
  938. else {
  939. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  940. const key = arrayKeys[i];
  941. def(value, key, arrayMethods[key]);
  942. }
  943. }
  944. }
  945. if (!shallow) {
  946. this.observeArray(value);
  947. }
  948. }
  949. else {
  950. /**
  951. * Walk through all properties and convert them into
  952. * getter/setters. This method should only be called when
  953. * value type is Object.
  954. */
  955. const keys = Object.keys(value);
  956. for (let i = 0; i < keys.length; i++) {
  957. const key = keys[i];
  958. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  959. }
  960. }
  961. }
  962. /**
  963. * Observe a list of Array items.
  964. */
  965. observeArray(value) {
  966. for (let i = 0, l = value.length; i < l; i++) {
  967. observe(value[i], false, this.mock);
  968. }
  969. }
  970. }
  971. // helpers
  972. /**
  973. * Attempt to create an observer instance for a value,
  974. * returns the new observer if successfully observed,
  975. * or the existing observer if the value already has one.
  976. */
  977. function observe(value, shallow, ssrMockReactivity) {
  978. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  979. return value.__ob__;
  980. }
  981. if (shouldObserve &&
  982. (ssrMockReactivity || !isServerRendering()) &&
  983. (isArray(value) || isPlainObject(value)) &&
  984. Object.isExtensible(value) &&
  985. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  986. !rawMap.has(value) &&
  987. !isRef(value) &&
  988. !(value instanceof VNode)) {
  989. return new Observer(value, shallow, ssrMockReactivity);
  990. }
  991. }
  992. /**
  993. * Define a reactive property on an Object.
  994. */
  995. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  996. const dep = new Dep();
  997. const property = Object.getOwnPropertyDescriptor(obj, key);
  998. if (property && property.configurable === false) {
  999. return;
  1000. }
  1001. // cater for pre-defined getter/setters
  1002. const getter = property && property.get;
  1003. const setter = property && property.set;
  1004. if ((!getter || setter) &&
  1005. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  1006. val = obj[key];
  1007. }
  1008. let childOb = !shallow && observe(val, false, mock);
  1009. Object.defineProperty(obj, key, {
  1010. enumerable: true,
  1011. configurable: true,
  1012. get: function reactiveGetter() {
  1013. const value = getter ? getter.call(obj) : val;
  1014. if (Dep.target) {
  1015. {
  1016. dep.depend({
  1017. target: obj,
  1018. type: "get" /* TrackOpTypes.GET */,
  1019. key
  1020. });
  1021. }
  1022. if (childOb) {
  1023. childOb.dep.depend();
  1024. if (isArray(value)) {
  1025. dependArray(value);
  1026. }
  1027. }
  1028. }
  1029. return isRef(value) && !shallow ? value.value : value;
  1030. },
  1031. set: function reactiveSetter(newVal) {
  1032. const value = getter ? getter.call(obj) : val;
  1033. if (!hasChanged(value, newVal)) {
  1034. return;
  1035. }
  1036. if (customSetter) {
  1037. customSetter();
  1038. }
  1039. if (setter) {
  1040. setter.call(obj, newVal);
  1041. }
  1042. else if (getter) {
  1043. // #7981: for accessor properties without setter
  1044. return;
  1045. }
  1046. else if (!shallow && isRef(value) && !isRef(newVal)) {
  1047. value.value = newVal;
  1048. return;
  1049. }
  1050. else {
  1051. val = newVal;
  1052. }
  1053. childOb = !shallow && observe(newVal, false, mock);
  1054. {
  1055. dep.notify({
  1056. type: "set" /* TriggerOpTypes.SET */,
  1057. target: obj,
  1058. key,
  1059. newValue: newVal,
  1060. oldValue: value
  1061. });
  1062. }
  1063. }
  1064. });
  1065. return dep;
  1066. }
  1067. function set(target, key, val) {
  1068. if ((isUndef(target) || isPrimitive(target))) {
  1069. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  1070. }
  1071. if (isReadonly(target)) {
  1072. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1073. return;
  1074. }
  1075. const ob = target.__ob__;
  1076. if (isArray(target) && isValidArrayIndex(key)) {
  1077. target.length = Math.max(target.length, key);
  1078. target.splice(key, 1, val);
  1079. // when mocking for SSR, array methods are not hijacked
  1080. if (ob && !ob.shallow && ob.mock) {
  1081. observe(val, false, true);
  1082. }
  1083. return val;
  1084. }
  1085. if (key in target && !(key in Object.prototype)) {
  1086. target[key] = val;
  1087. return val;
  1088. }
  1089. if (target._isVue || (ob && ob.vmCount)) {
  1090. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1091. 'at runtime - declare it upfront in the data option.');
  1092. return val;
  1093. }
  1094. if (!ob) {
  1095. target[key] = val;
  1096. return val;
  1097. }
  1098. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1099. {
  1100. ob.dep.notify({
  1101. type: "add" /* TriggerOpTypes.ADD */,
  1102. target: target,
  1103. key,
  1104. newValue: val,
  1105. oldValue: undefined
  1106. });
  1107. }
  1108. return val;
  1109. }
  1110. function del(target, key) {
  1111. if ((isUndef(target) || isPrimitive(target))) {
  1112. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1113. }
  1114. if (isArray(target) && isValidArrayIndex(key)) {
  1115. target.splice(key, 1);
  1116. return;
  1117. }
  1118. const ob = target.__ob__;
  1119. if (target._isVue || (ob && ob.vmCount)) {
  1120. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1121. '- just set it to null.');
  1122. return;
  1123. }
  1124. if (isReadonly(target)) {
  1125. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1126. return;
  1127. }
  1128. if (!hasOwn(target, key)) {
  1129. return;
  1130. }
  1131. delete target[key];
  1132. if (!ob) {
  1133. return;
  1134. }
  1135. {
  1136. ob.dep.notify({
  1137. type: "delete" /* TriggerOpTypes.DELETE */,
  1138. target: target,
  1139. key
  1140. });
  1141. }
  1142. }
  1143. /**
  1144. * Collect dependencies on array elements when the array is touched, since
  1145. * we cannot intercept array element access like property getters.
  1146. */
  1147. function dependArray(value) {
  1148. for (let e, i = 0, l = value.length; i < l; i++) {
  1149. e = value[i];
  1150. if (e && e.__ob__) {
  1151. e.__ob__.dep.depend();
  1152. }
  1153. if (isArray(e)) {
  1154. dependArray(e);
  1155. }
  1156. }
  1157. }
  1158. /**
  1159. * @internal
  1160. */
  1161. const RefFlag = `__v_isRef`;
  1162. function isRef(r) {
  1163. return !!(r && r.__v_isRef === true);
  1164. }
  1165. function ref$1(value) {
  1166. return createRef(value, false);
  1167. }
  1168. function shallowRef(value) {
  1169. return createRef(value, true);
  1170. }
  1171. function createRef(rawValue, shallow) {
  1172. if (isRef(rawValue)) {
  1173. return rawValue;
  1174. }
  1175. const ref = {};
  1176. def(ref, RefFlag, true);
  1177. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1178. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1179. return ref;
  1180. }
  1181. function triggerRef(ref) {
  1182. if (!ref.dep) {
  1183. warn$2(`received object is not a triggerable ref.`);
  1184. }
  1185. {
  1186. ref.dep &&
  1187. ref.dep.notify({
  1188. type: "set" /* TriggerOpTypes.SET */,
  1189. target: ref,
  1190. key: 'value'
  1191. });
  1192. }
  1193. }
  1194. function unref(ref) {
  1195. return isRef(ref) ? ref.value : ref;
  1196. }
  1197. function proxyRefs(objectWithRefs) {
  1198. if (isReactive(objectWithRefs)) {
  1199. return objectWithRefs;
  1200. }
  1201. const proxy = {};
  1202. const keys = Object.keys(objectWithRefs);
  1203. for (let i = 0; i < keys.length; i++) {
  1204. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1205. }
  1206. return proxy;
  1207. }
  1208. function proxyWithRefUnwrap(target, source, key) {
  1209. Object.defineProperty(target, key, {
  1210. enumerable: true,
  1211. configurable: true,
  1212. get: () => {
  1213. const val = source[key];
  1214. if (isRef(val)) {
  1215. return val.value;
  1216. }
  1217. else {
  1218. const ob = val && val.__ob__;
  1219. if (ob)
  1220. ob.dep.depend();
  1221. return val;
  1222. }
  1223. },
  1224. set: value => {
  1225. const oldValue = source[key];
  1226. if (isRef(oldValue) && !isRef(value)) {
  1227. oldValue.value = value;
  1228. }
  1229. else {
  1230. source[key] = value;
  1231. }
  1232. }
  1233. });
  1234. }
  1235. function customRef(factory) {
  1236. const dep = new Dep();
  1237. const { get, set } = factory(() => {
  1238. {
  1239. dep.depend({
  1240. target: ref,
  1241. type: "get" /* TrackOpTypes.GET */,
  1242. key: 'value'
  1243. });
  1244. }
  1245. }, () => {
  1246. {
  1247. dep.notify({
  1248. target: ref,
  1249. type: "set" /* TriggerOpTypes.SET */,
  1250. key: 'value'
  1251. });
  1252. }
  1253. });
  1254. const ref = {
  1255. get value() {
  1256. return get();
  1257. },
  1258. set value(newVal) {
  1259. set(newVal);
  1260. }
  1261. };
  1262. def(ref, RefFlag, true);
  1263. return ref;
  1264. }
  1265. function toRefs(object) {
  1266. if (!isReactive(object)) {
  1267. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1268. }
  1269. const ret = isArray(object) ? new Array(object.length) : {};
  1270. for (const key in object) {
  1271. ret[key] = toRef(object, key);
  1272. }
  1273. return ret;
  1274. }
  1275. function toRef(object, key, defaultValue) {
  1276. const val = object[key];
  1277. if (isRef(val)) {
  1278. return val;
  1279. }
  1280. const ref = {
  1281. get value() {
  1282. const val = object[key];
  1283. return val === undefined ? defaultValue : val;
  1284. },
  1285. set value(newVal) {
  1286. object[key] = newVal;
  1287. }
  1288. };
  1289. def(ref, RefFlag, true);
  1290. return ref;
  1291. }
  1292. const rawToReadonlyMap = new WeakMap();
  1293. const rawToShallowReadonlyMap = new WeakMap();
  1294. function readonly(target) {
  1295. return createReadonly(target, false);
  1296. }
  1297. function createReadonly(target, shallow) {
  1298. if (!isPlainObject(target)) {
  1299. {
  1300. if (isArray(target)) {
  1301. warn$2(`Vue 2 does not support readonly arrays.`);
  1302. }
  1303. else if (isCollectionType(target)) {
  1304. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1305. }
  1306. else {
  1307. warn$2(`value cannot be made readonly: ${typeof target}`);
  1308. }
  1309. }
  1310. return target;
  1311. }
  1312. // already a readonly object
  1313. if (isReadonly(target)) {
  1314. return target;
  1315. }
  1316. // already has a readonly proxy
  1317. const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap;
  1318. const existingProxy = map.get(target);
  1319. if (existingProxy) {
  1320. return existingProxy;
  1321. }
  1322. const proxy = Object.create(Object.getPrototypeOf(target));
  1323. map.set(target, proxy);
  1324. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1325. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1326. if (isRef(target)) {
  1327. def(proxy, RefFlag, true);
  1328. }
  1329. if (shallow || isShallow(target)) {
  1330. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1331. }
  1332. const keys = Object.keys(target);
  1333. for (let i = 0; i < keys.length; i++) {
  1334. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1335. }
  1336. return proxy;
  1337. }
  1338. function defineReadonlyProperty(proxy, target, key, shallow) {
  1339. Object.defineProperty(proxy, key, {
  1340. enumerable: true,
  1341. configurable: true,
  1342. get() {
  1343. const val = target[key];
  1344. return shallow || !isPlainObject(val) ? val : readonly(val);
  1345. },
  1346. set() {
  1347. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1348. }
  1349. });
  1350. }
  1351. /**
  1352. * Returns a reactive-copy of the original object, where only the root level
  1353. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1354. * returned properties.
  1355. * This is used for creating the props proxy object for stateful components.
  1356. */
  1357. function shallowReadonly(target) {
  1358. return createReadonly(target, true);
  1359. }
  1360. function computed(getterOrOptions, debugOptions) {
  1361. let getter;
  1362. let setter;
  1363. const onlyGetter = isFunction(getterOrOptions);
  1364. if (onlyGetter) {
  1365. getter = getterOrOptions;
  1366. setter = () => {
  1367. warn$2('Write operation failed: computed value is readonly');
  1368. }
  1369. ;
  1370. }
  1371. else {
  1372. getter = getterOrOptions.get;
  1373. setter = getterOrOptions.set;
  1374. }
  1375. const watcher = isServerRendering()
  1376. ? null
  1377. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1378. if (watcher && debugOptions) {
  1379. watcher.onTrack = debugOptions.onTrack;
  1380. watcher.onTrigger = debugOptions.onTrigger;
  1381. }
  1382. const ref = {
  1383. // some libs rely on the presence effect for checking computed refs
  1384. // from normal refs, but the implementation doesn't matter
  1385. effect: watcher,
  1386. get value() {
  1387. if (watcher) {
  1388. if (watcher.dirty) {
  1389. watcher.evaluate();
  1390. }
  1391. if (Dep.target) {
  1392. if (Dep.target.onTrack) {
  1393. Dep.target.onTrack({
  1394. effect: Dep.target,
  1395. target: ref,
  1396. type: "get" /* TrackOpTypes.GET */,
  1397. key: 'value'
  1398. });
  1399. }
  1400. watcher.depend();
  1401. }
  1402. return watcher.value;
  1403. }
  1404. else {
  1405. return getter();
  1406. }
  1407. },
  1408. set value(newVal) {
  1409. setter(newVal);
  1410. }
  1411. };
  1412. def(ref, RefFlag, true);
  1413. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1414. return ref;
  1415. }
  1416. let mark;
  1417. let measure;
  1418. {
  1419. const perf = inBrowser && window.performance;
  1420. /* istanbul ignore if */
  1421. if (perf &&
  1422. // @ts-ignore
  1423. perf.mark &&
  1424. // @ts-ignore
  1425. perf.measure &&
  1426. // @ts-ignore
  1427. perf.clearMarks &&
  1428. // @ts-ignore
  1429. perf.clearMeasures) {
  1430. mark = tag => perf.mark(tag);
  1431. measure = (name, startTag, endTag) => {
  1432. perf.measure(name, startTag, endTag);
  1433. perf.clearMarks(startTag);
  1434. perf.clearMarks(endTag);
  1435. // perf.clearMeasures(name)
  1436. };
  1437. }
  1438. }
  1439. const normalizeEvent = cached((name) => {
  1440. const passive = name.charAt(0) === '&';
  1441. name = passive ? name.slice(1) : name;
  1442. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1443. name = once ? name.slice(1) : name;
  1444. const capture = name.charAt(0) === '!';
  1445. name = capture ? name.slice(1) : name;
  1446. return {
  1447. name,
  1448. once,
  1449. capture,
  1450. passive
  1451. };
  1452. });
  1453. function createFnInvoker(fns, vm) {
  1454. function invoker() {
  1455. const fns = invoker.fns;
  1456. if (isArray(fns)) {
  1457. const cloned = fns.slice();
  1458. for (let i = 0; i < cloned.length; i++) {
  1459. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1460. }
  1461. }
  1462. else {
  1463. // return handler return value for single handlers
  1464. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1465. }
  1466. }
  1467. invoker.fns = fns;
  1468. return invoker;
  1469. }
  1470. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1471. let name, cur, old, event;
  1472. for (name in on) {
  1473. cur = on[name];
  1474. old = oldOn[name];
  1475. event = normalizeEvent(name);
  1476. if (isUndef(cur)) {
  1477. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1478. }
  1479. else if (isUndef(old)) {
  1480. if (isUndef(cur.fns)) {
  1481. cur = on[name] = createFnInvoker(cur, vm);
  1482. }
  1483. if (isTrue(event.once)) {
  1484. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1485. }
  1486. add(event.name, cur, event.capture, event.passive, event.params);
  1487. }
  1488. else if (cur !== old) {
  1489. old.fns = cur;
  1490. on[name] = old;
  1491. }
  1492. }
  1493. for (name in oldOn) {
  1494. if (isUndef(on[name])) {
  1495. event = normalizeEvent(name);
  1496. remove(event.name, oldOn[name], event.capture);
  1497. }
  1498. }
  1499. }
  1500. function mergeVNodeHook(def, hookKey, hook) {
  1501. if (def instanceof VNode) {
  1502. def = def.data.hook || (def.data.hook = {});
  1503. }
  1504. let invoker;
  1505. const oldHook = def[hookKey];
  1506. function wrappedHook() {
  1507. hook.apply(this, arguments);
  1508. // important: remove merged hook to ensure it's called only once
  1509. // and prevent memory leak
  1510. remove$2(invoker.fns, wrappedHook);
  1511. }
  1512. if (isUndef(oldHook)) {
  1513. // no existing hook
  1514. invoker = createFnInvoker([wrappedHook]);
  1515. }
  1516. else {
  1517. /* istanbul ignore if */
  1518. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1519. // already a merged invoker
  1520. invoker = oldHook;
  1521. invoker.fns.push(wrappedHook);
  1522. }
  1523. else {
  1524. // existing plain hook
  1525. invoker = createFnInvoker([oldHook, wrappedHook]);
  1526. }
  1527. }
  1528. invoker.merged = true;
  1529. def[hookKey] = invoker;
  1530. }
  1531. function extractPropsFromVNodeData(data, Ctor, tag) {
  1532. // we are only extracting raw values here.
  1533. // validation and default values are handled in the child
  1534. // component itself.
  1535. const propOptions = Ctor.options.props;
  1536. if (isUndef(propOptions)) {
  1537. return;
  1538. }
  1539. const res = {};
  1540. const { attrs, props } = data;
  1541. if (isDef(attrs) || isDef(props)) {
  1542. for (const key in propOptions) {
  1543. const altKey = hyphenate(key);
  1544. {
  1545. const keyInLowerCase = key.toLowerCase();
  1546. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1547. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1548. `${formatComponentName(
  1549. // @ts-expect-error tag is string
  1550. tag || Ctor)}, but the declared prop name is` +
  1551. ` "${key}". ` +
  1552. `Note that HTML attributes are case-insensitive and camelCased ` +
  1553. `props need to use their kebab-case equivalents when using in-DOM ` +
  1554. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1555. }
  1556. }
  1557. checkProp(res, props, key, altKey, true) ||
  1558. checkProp(res, attrs, key, altKey, false);
  1559. }
  1560. }
  1561. return res;
  1562. }
  1563. function checkProp(res, hash, key, altKey, preserve) {
  1564. if (isDef(hash)) {
  1565. if (hasOwn(hash, key)) {
  1566. res[key] = hash[key];
  1567. if (!preserve) {
  1568. delete hash[key];
  1569. }
  1570. return true;
  1571. }
  1572. else if (hasOwn(hash, altKey)) {
  1573. res[key] = hash[altKey];
  1574. if (!preserve) {
  1575. delete hash[altKey];
  1576. }
  1577. return true;
  1578. }
  1579. }
  1580. return false;
  1581. }
  1582. // The template compiler attempts to minimize the need for normalization by
  1583. // statically analyzing the template at compile time.
  1584. //
  1585. // For plain HTML markup, normalization can be completely skipped because the
  1586. // generated render function is guaranteed to return Array<VNode>. There are
  1587. // two cases where extra normalization is needed:
  1588. // 1. When the children contains components - because a functional component
  1589. // may return an Array instead of a single root. In this case, just a simple
  1590. // normalization is needed - if any child is an Array, we flatten the whole
  1591. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1592. // because functional components already normalize their own children.
  1593. function simpleNormalizeChildren(children) {
  1594. for (let i = 0; i < children.length; i++) {
  1595. if (isArray(children[i])) {
  1596. return Array.prototype.concat.apply([], children);
  1597. }
  1598. }
  1599. return children;
  1600. }
  1601. // 2. When the children contains constructs that always generated nested Arrays,
  1602. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1603. // with hand-written render functions / JSX. In such cases a full normalization
  1604. // is needed to cater to all possible types of children values.
  1605. function normalizeChildren(children) {
  1606. return isPrimitive(children)
  1607. ? [createTextVNode(children)]
  1608. : isArray(children)
  1609. ? normalizeArrayChildren(children)
  1610. : undefined;
  1611. }
  1612. function isTextNode(node) {
  1613. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1614. }
  1615. function normalizeArrayChildren(children, nestedIndex) {
  1616. const res = [];
  1617. let i, c, lastIndex, last;
  1618. for (i = 0; i < children.length; i++) {
  1619. c = children[i];
  1620. if (isUndef(c) || typeof c === 'boolean')
  1621. continue;
  1622. lastIndex = res.length - 1;
  1623. last = res[lastIndex];
  1624. // nested
  1625. if (isArray(c)) {
  1626. if (c.length > 0) {
  1627. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1628. // merge adjacent text nodes
  1629. if (isTextNode(c[0]) && isTextNode(last)) {
  1630. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1631. c.shift();
  1632. }
  1633. res.push.apply(res, c);
  1634. }
  1635. }
  1636. else if (isPrimitive(c)) {
  1637. if (isTextNode(last)) {
  1638. // merge adjacent text nodes
  1639. // this is necessary for SSR hydration because text nodes are
  1640. // essentially merged when rendered to HTML strings
  1641. res[lastIndex] = createTextVNode(last.text + c);
  1642. }
  1643. else if (c !== '') {
  1644. // convert primitive to vnode
  1645. res.push(createTextVNode(c));
  1646. }
  1647. }
  1648. else {
  1649. if (isTextNode(c) && isTextNode(last)) {
  1650. // merge adjacent text nodes
  1651. res[lastIndex] = createTextVNode(last.text + c.text);
  1652. }
  1653. else {
  1654. // default key for nested array children (likely generated by v-for)
  1655. if (isTrue(children._isVList) &&
  1656. isDef(c.tag) &&
  1657. isUndef(c.key) &&
  1658. isDef(nestedIndex)) {
  1659. c.key = `__vlist${nestedIndex}_${i}__`;
  1660. }
  1661. res.push(c);
  1662. }
  1663. }
  1664. }
  1665. return res;
  1666. }
  1667. const SIMPLE_NORMALIZE = 1;
  1668. const ALWAYS_NORMALIZE = 2;
  1669. // wrapper function for providing a more flexible interface
  1670. // without getting yelled at by flow
  1671. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1672. if (isArray(data) || isPrimitive(data)) {
  1673. normalizationType = children;
  1674. children = data;
  1675. data = undefined;
  1676. }
  1677. if (isTrue(alwaysNormalize)) {
  1678. normalizationType = ALWAYS_NORMALIZE;
  1679. }
  1680. return _createElement(context, tag, data, children, normalizationType);
  1681. }
  1682. function _createElement(context, tag, data, children, normalizationType) {
  1683. if (isDef(data) && isDef(data.__ob__)) {
  1684. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1685. return createEmptyVNode();
  1686. }
  1687. // object syntax in v-bind
  1688. if (isDef(data) && isDef(data.is)) {
  1689. tag = data.is;
  1690. }
  1691. if (!tag) {
  1692. // in case of component :is set to falsy value
  1693. return createEmptyVNode();
  1694. }
  1695. // warn against non-primitive key
  1696. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1697. warn$2('Avoid using non-primitive value as key, ' +
  1698. 'use string/number value instead.', context);
  1699. }
  1700. // support single function children as default scoped slot
  1701. if (isArray(children) && isFunction(children[0])) {
  1702. data = data || {};
  1703. data.scopedSlots = { default: children[0] };
  1704. children.length = 0;
  1705. }
  1706. if (normalizationType === ALWAYS_NORMALIZE) {
  1707. children = normalizeChildren(children);
  1708. }
  1709. else if (normalizationType === SIMPLE_NORMALIZE) {
  1710. children = simpleNormalizeChildren(children);
  1711. }
  1712. let vnode, ns;
  1713. if (typeof tag === 'string') {
  1714. let Ctor;
  1715. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1716. if (config.isReservedTag(tag)) {
  1717. // platform built-in elements
  1718. if (isDef(data) &&
  1719. isDef(data.nativeOn) &&
  1720. data.tag !== 'component') {
  1721. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1722. }
  1723. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1724. }
  1725. else if ((!data || !data.pre) &&
  1726. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1727. // component
  1728. vnode = createComponent(Ctor, data, context, children, tag);
  1729. }
  1730. else {
  1731. // unknown or unlisted namespaced elements
  1732. // check at runtime because it may get assigned a namespace when its
  1733. // parent normalizes children
  1734. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1735. }
  1736. }
  1737. else {
  1738. // direct component options / constructor
  1739. vnode = createComponent(tag, data, context, children);
  1740. }
  1741. if (isArray(vnode)) {
  1742. return vnode;
  1743. }
  1744. else if (isDef(vnode)) {
  1745. if (isDef(ns))
  1746. applyNS(vnode, ns);
  1747. if (isDef(data))
  1748. registerDeepBindings(data);
  1749. return vnode;
  1750. }
  1751. else {
  1752. return createEmptyVNode();
  1753. }
  1754. }
  1755. function applyNS(vnode, ns, force) {
  1756. vnode.ns = ns;
  1757. if (vnode.tag === 'foreignObject') {
  1758. // use default namespace inside foreignObject
  1759. ns = undefined;
  1760. force = true;
  1761. }
  1762. if (isDef(vnode.children)) {
  1763. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1764. const child = vnode.children[i];
  1765. if (isDef(child.tag) &&
  1766. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1767. applyNS(child, ns, force);
  1768. }
  1769. }
  1770. }
  1771. }
  1772. // ref #5318
  1773. // necessary to ensure parent re-render when deep bindings like :style and
  1774. // :class are used on slot nodes
  1775. function registerDeepBindings(data) {
  1776. if (isObject(data.style)) {
  1777. traverse(data.style);
  1778. }
  1779. if (isObject(data.class)) {
  1780. traverse(data.class);
  1781. }
  1782. }
  1783. /**
  1784. * Runtime helper for rendering v-for lists.
  1785. */
  1786. function renderList(val, render) {
  1787. let ret = null, i, l, keys, key;
  1788. if (isArray(val) || typeof val === 'string') {
  1789. ret = new Array(val.length);
  1790. for (i = 0, l = val.length; i < l; i++) {
  1791. ret[i] = render(val[i], i);
  1792. }
  1793. }
  1794. else if (typeof val === 'number') {
  1795. ret = new Array(val);
  1796. for (i = 0; i < val; i++) {
  1797. ret[i] = render(i + 1, i);
  1798. }
  1799. }
  1800. else if (isObject(val)) {
  1801. if (hasSymbol && val[Symbol.iterator]) {
  1802. ret = [];
  1803. const iterator = val[Symbol.iterator]();
  1804. let result = iterator.next();
  1805. while (!result.done) {
  1806. ret.push(render(result.value, ret.length));
  1807. result = iterator.next();
  1808. }
  1809. }
  1810. else {
  1811. keys = Object.keys(val);
  1812. ret = new Array(keys.length);
  1813. for (i = 0, l = keys.length; i < l; i++) {
  1814. key = keys[i];
  1815. ret[i] = render(val[key], key, i);
  1816. }
  1817. }
  1818. }
  1819. if (!isDef(ret)) {
  1820. ret = [];
  1821. }
  1822. ret._isVList = true;
  1823. return ret;
  1824. }
  1825. /**
  1826. * Runtime helper for rendering <slot>
  1827. */
  1828. function renderSlot(name, fallbackRender, props, bindObject) {
  1829. const scopedSlotFn = this.$scopedSlots[name];
  1830. let nodes;
  1831. if (scopedSlotFn) {
  1832. // scoped slot
  1833. props = props || {};
  1834. if (bindObject) {
  1835. if (!isObject(bindObject)) {
  1836. warn$2('slot v-bind without argument expects an Object', this);
  1837. }
  1838. props = extend(extend({}, bindObject), props);
  1839. }
  1840. nodes =
  1841. scopedSlotFn(props) ||
  1842. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1843. }
  1844. else {
  1845. nodes =
  1846. this.$slots[name] ||
  1847. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1848. }
  1849. const target = props && props.slot;
  1850. if (target) {
  1851. return this.$createElement('template', { slot: target }, nodes);
  1852. }
  1853. else {
  1854. return nodes;
  1855. }
  1856. }
  1857. /**
  1858. * Runtime helper for resolving filters
  1859. */
  1860. function resolveFilter(id) {
  1861. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1862. }
  1863. function isKeyNotMatch(expect, actual) {
  1864. if (isArray(expect)) {
  1865. return expect.indexOf(actual) === -1;
  1866. }
  1867. else {
  1868. return expect !== actual;
  1869. }
  1870. }
  1871. /**
  1872. * Runtime helper for checking keyCodes from config.
  1873. * exposed as Vue.prototype._k
  1874. * passing in eventKeyName as last argument separately for backwards compat
  1875. */
  1876. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1877. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1878. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1879. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1880. }
  1881. else if (mappedKeyCode) {
  1882. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1883. }
  1884. else if (eventKeyName) {
  1885. return hyphenate(eventKeyName) !== key;
  1886. }
  1887. return eventKeyCode === undefined;
  1888. }
  1889. /**
  1890. * Runtime helper for merging v-bind="object" into a VNode's data.
  1891. */
  1892. function bindObjectProps(data, tag, value, asProp, isSync) {
  1893. if (value) {
  1894. if (!isObject(value)) {
  1895. warn$2('v-bind without argument expects an Object or Array value', this);
  1896. }
  1897. else {
  1898. if (isArray(value)) {
  1899. value = toObject(value);
  1900. }
  1901. let hash;
  1902. for (const key in value) {
  1903. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1904. hash = data;
  1905. }
  1906. else {
  1907. const type = data.attrs && data.attrs.type;
  1908. hash =
  1909. asProp || config.mustUseProp(tag, type, key)
  1910. ? data.domProps || (data.domProps = {})
  1911. : data.attrs || (data.attrs = {});
  1912. }
  1913. const camelizedKey = camelize(key);
  1914. const hyphenatedKey = hyphenate(key);
  1915. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1916. hash[key] = value[key];
  1917. if (isSync) {
  1918. const on = data.on || (data.on = {});
  1919. on[`update:${key}`] = function ($event) {
  1920. value[key] = $event;
  1921. };
  1922. }
  1923. }
  1924. }
  1925. }
  1926. }
  1927. return data;
  1928. }
  1929. /**
  1930. * Runtime helper for rendering static trees.
  1931. */
  1932. function renderStatic(index, isInFor) {
  1933. const cached = this._staticTrees || (this._staticTrees = []);
  1934. let tree = cached[index];
  1935. // if has already-rendered static tree and not inside v-for,
  1936. // we can reuse the same tree.
  1937. if (tree && !isInFor) {
  1938. return tree;
  1939. }
  1940. // otherwise, render a fresh tree.
  1941. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1942. );
  1943. markStatic$1(tree, `__static__${index}`, false);
  1944. return tree;
  1945. }
  1946. /**
  1947. * Runtime helper for v-once.
  1948. * Effectively it means marking the node as static with a unique key.
  1949. */
  1950. function markOnce(tree, index, key) {
  1951. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1952. return tree;
  1953. }
  1954. function markStatic$1(tree, key, isOnce) {
  1955. if (isArray(tree)) {
  1956. for (let i = 0; i < tree.length; i++) {
  1957. if (tree[i] && typeof tree[i] !== 'string') {
  1958. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1959. }
  1960. }
  1961. }
  1962. else {
  1963. markStaticNode(tree, key, isOnce);
  1964. }
  1965. }
  1966. function markStaticNode(node, key, isOnce) {
  1967. node.isStatic = true;
  1968. node.key = key;
  1969. node.isOnce = isOnce;
  1970. }
  1971. function bindObjectListeners(data, value) {
  1972. if (value) {
  1973. if (!isPlainObject(value)) {
  1974. warn$2('v-on without argument expects an Object value', this);
  1975. }
  1976. else {
  1977. const on = (data.on = data.on ? extend({}, data.on) : {});
  1978. for (const key in value) {
  1979. const existing = on[key];
  1980. const ours = value[key];
  1981. on[key] = existing ? [].concat(existing, ours) : ours;
  1982. }
  1983. }
  1984. }
  1985. return data;
  1986. }
  1987. function resolveScopedSlots(fns, res,
  1988. // the following are added in 2.6
  1989. hasDynamicKeys, contentHashKey) {
  1990. res = res || { $stable: !hasDynamicKeys };
  1991. for (let i = 0; i < fns.length; i++) {
  1992. const slot = fns[i];
  1993. if (isArray(slot)) {
  1994. resolveScopedSlots(slot, res, hasDynamicKeys);
  1995. }
  1996. else if (slot) {
  1997. // marker for reverse proxying v-slot without scope on this.$slots
  1998. // @ts-expect-error
  1999. if (slot.proxy) {
  2000. // @ts-expect-error
  2001. slot.fn.proxy = true;
  2002. }
  2003. res[slot.key] = slot.fn;
  2004. }
  2005. }
  2006. if (contentHashKey) {
  2007. res.$key = contentHashKey;
  2008. }
  2009. return res;
  2010. }
  2011. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2012. function bindDynamicKeys(baseObj, values) {
  2013. for (let i = 0; i < values.length; i += 2) {
  2014. const key = values[i];
  2015. if (typeof key === 'string' && key) {
  2016. baseObj[values[i]] = values[i + 1];
  2017. }
  2018. else if (key !== '' && key !== null) {
  2019. // null is a special value for explicitly removing a binding
  2020. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2021. }
  2022. }
  2023. return baseObj;
  2024. }
  2025. // helper to dynamically append modifier runtime markers to event names.
  2026. // ensure only append when value is already string, otherwise it will be cast
  2027. // to string and cause the type check to miss.
  2028. function prependModifier(value, symbol) {
  2029. return typeof value === 'string' ? symbol + value : value;
  2030. }
  2031. function installRenderHelpers(target) {
  2032. target._o = markOnce;
  2033. target._n = toNumber;
  2034. target._s = toString;
  2035. target._l = renderList;
  2036. target._t = renderSlot;
  2037. target._q = looseEqual;
  2038. target._i = looseIndexOf;
  2039. target._m = renderStatic;
  2040. target._f = resolveFilter;
  2041. target._k = checkKeyCodes;
  2042. target._b = bindObjectProps;
  2043. target._v = createTextVNode;
  2044. target._e = createEmptyVNode;
  2045. target._u = resolveScopedSlots;
  2046. target._g = bindObjectListeners;
  2047. target._d = bindDynamicKeys;
  2048. target._p = prependModifier;
  2049. }
  2050. /**
  2051. * Runtime helper for resolving raw children VNodes into a slot object.
  2052. */
  2053. function resolveSlots(children, context) {
  2054. if (!children || !children.length) {
  2055. return {};
  2056. }
  2057. const slots = {};
  2058. for (let i = 0, l = children.length; i < l; i++) {
  2059. const child = children[i];
  2060. const data = child.data;
  2061. // remove slot attribute if the node is resolved as a Vue slot node
  2062. if (data && data.attrs && data.attrs.slot) {
  2063. delete data.attrs.slot;
  2064. }
  2065. // named slots should only be respected if the vnode was rendered in the
  2066. // same context.
  2067. if ((child.context === context || child.fnContext === context) &&
  2068. data &&
  2069. data.slot != null) {
  2070. const name = data.slot;
  2071. const slot = slots[name] || (slots[name] = []);
  2072. if (child.tag === 'template') {
  2073. slot.push.apply(slot, child.children || []);
  2074. }
  2075. else {
  2076. slot.push(child);
  2077. }
  2078. }
  2079. else {
  2080. (slots.default || (slots.default = [])).push(child);
  2081. }
  2082. }
  2083. // ignore slots that contains only whitespace
  2084. for (const name in slots) {
  2085. if (slots[name].every(isWhitespace)) {
  2086. delete slots[name];
  2087. }
  2088. }
  2089. return slots;
  2090. }
  2091. function isWhitespace(node) {
  2092. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2093. }
  2094. function isAsyncPlaceholder(node) {
  2095. // @ts-expect-error not really boolean type
  2096. return node.isComment && node.asyncFactory;
  2097. }
  2098. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2099. let res;
  2100. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2101. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2102. const key = scopedSlots && scopedSlots.$key;
  2103. if (!scopedSlots) {
  2104. res = {};
  2105. }
  2106. else if (scopedSlots._normalized) {
  2107. // fast path 1: child component re-render only, parent did not change
  2108. return scopedSlots._normalized;
  2109. }
  2110. else if (isStable &&
  2111. prevScopedSlots &&
  2112. prevScopedSlots !== emptyObject &&
  2113. key === prevScopedSlots.$key &&
  2114. !hasNormalSlots &&
  2115. !prevScopedSlots.$hasNormal) {
  2116. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2117. // only need to normalize once
  2118. return prevScopedSlots;
  2119. }
  2120. else {
  2121. res = {};
  2122. for (const key in scopedSlots) {
  2123. if (scopedSlots[key] && key[0] !== '$') {
  2124. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2125. }
  2126. }
  2127. }
  2128. // expose normal slots on scopedSlots
  2129. for (const key in normalSlots) {
  2130. if (!(key in res)) {
  2131. res[key] = proxyNormalSlot(normalSlots, key);
  2132. }
  2133. }
  2134. // avoriaz seems to mock a non-extensible $scopedSlots object
  2135. // and when that is passed down this would cause an error
  2136. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2137. scopedSlots._normalized = res;
  2138. }
  2139. def(res, '$stable', isStable);
  2140. def(res, '$key', key);
  2141. def(res, '$hasNormal', hasNormalSlots);
  2142. return res;
  2143. }
  2144. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2145. const normalized = function () {
  2146. const cur = currentInstance;
  2147. setCurrentInstance(vm);
  2148. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2149. res =
  2150. res && typeof res === 'object' && !isArray(res)
  2151. ? [res] // single vnode
  2152. : normalizeChildren(res);
  2153. const vnode = res && res[0];
  2154. setCurrentInstance(cur);
  2155. return res &&
  2156. (!vnode ||
  2157. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2158. ? undefined
  2159. : res;
  2160. };
  2161. // this is a slot using the new v-slot syntax without scope. although it is
  2162. // compiled as a scoped slot, render fn users would expect it to be present
  2163. // on this.$slots because the usage is semantically a normal slot.
  2164. if (fn.proxy) {
  2165. Object.defineProperty(normalSlots, key, {
  2166. get: normalized,
  2167. enumerable: true,
  2168. configurable: true
  2169. });
  2170. }
  2171. return normalized;
  2172. }
  2173. function proxyNormalSlot(slots, key) {
  2174. return () => slots[key];
  2175. }
  2176. function initSetup(vm) {
  2177. const options = vm.$options;
  2178. const setup = options.setup;
  2179. if (setup) {
  2180. const ctx = (vm._setupContext = createSetupContext(vm));
  2181. setCurrentInstance(vm);
  2182. pushTarget();
  2183. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2184. popTarget();
  2185. setCurrentInstance();
  2186. if (isFunction(setupResult)) {
  2187. // render function
  2188. // @ts-ignore
  2189. options.render = setupResult;
  2190. }
  2191. else if (isObject(setupResult)) {
  2192. // bindings
  2193. if (setupResult instanceof VNode) {
  2194. warn$2(`setup() should not return VNodes directly - ` +
  2195. `return a render function instead.`);
  2196. }
  2197. vm._setupState = setupResult;
  2198. // __sfc indicates compiled bindings from <script setup>
  2199. if (!setupResult.__sfc) {
  2200. for (const key in setupResult) {
  2201. if (!isReserved(key)) {
  2202. proxyWithRefUnwrap(vm, setupResult, key);
  2203. }
  2204. else {
  2205. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2206. }
  2207. }
  2208. }
  2209. else {
  2210. // exposed for compiled render fn
  2211. const proxy = (vm._setupProxy = {});
  2212. for (const key in setupResult) {
  2213. if (key !== '__sfc') {
  2214. proxyWithRefUnwrap(proxy, setupResult, key);
  2215. }
  2216. }
  2217. }
  2218. }
  2219. else if (setupResult !== undefined) {
  2220. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2221. }
  2222. }
  2223. }
  2224. function createSetupContext(vm) {
  2225. let exposeCalled = false;
  2226. return {
  2227. get attrs() {
  2228. if (!vm._attrsProxy) {
  2229. const proxy = (vm._attrsProxy = {});
  2230. def(proxy, '_v_attr_proxy', true);
  2231. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2232. }
  2233. return vm._attrsProxy;
  2234. },
  2235. get listeners() {
  2236. if (!vm._listenersProxy) {
  2237. const proxy = (vm._listenersProxy = {});
  2238. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2239. }
  2240. return vm._listenersProxy;
  2241. },
  2242. get slots() {
  2243. return initSlotsProxy(vm);
  2244. },
  2245. emit: bind$1(vm.$emit, vm),
  2246. expose(exposed) {
  2247. {
  2248. if (exposeCalled) {
  2249. warn$2(`expose() should be called only once per setup().`, vm);
  2250. }
  2251. exposeCalled = true;
  2252. }
  2253. if (exposed) {
  2254. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2255. }
  2256. }
  2257. };
  2258. }
  2259. function syncSetupProxy(to, from, prev, instance, type) {
  2260. let changed = false;
  2261. for (const key in from) {
  2262. if (!(key in to)) {
  2263. changed = true;
  2264. defineProxyAttr(to, key, instance, type);
  2265. }
  2266. else if (from[key] !== prev[key]) {
  2267. changed = true;
  2268. }
  2269. }
  2270. for (const key in to) {
  2271. if (!(key in from)) {
  2272. changed = true;
  2273. delete to[key];
  2274. }
  2275. }
  2276. return changed;
  2277. }
  2278. function defineProxyAttr(proxy, key, instance, type) {
  2279. Object.defineProperty(proxy, key, {
  2280. enumerable: true,
  2281. configurable: true,
  2282. get() {
  2283. return instance[type][key];
  2284. }
  2285. });
  2286. }
  2287. function initSlotsProxy(vm) {
  2288. if (!vm._slotsProxy) {
  2289. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2290. }
  2291. return vm._slotsProxy;
  2292. }
  2293. function syncSetupSlots(to, from) {
  2294. for (const key in from) {
  2295. to[key] = from[key];
  2296. }
  2297. for (const key in to) {
  2298. if (!(key in from)) {
  2299. delete to[key];
  2300. }
  2301. }
  2302. }
  2303. /**
  2304. * @internal use manual type def because public setup context type relies on
  2305. * legacy VNode types
  2306. */
  2307. function useSlots() {
  2308. return getContext().slots;
  2309. }
  2310. /**
  2311. * @internal use manual type def because public setup context type relies on
  2312. * legacy VNode types
  2313. */
  2314. function useAttrs() {
  2315. return getContext().attrs;
  2316. }
  2317. /**
  2318. * Vue 2 only
  2319. * @internal use manual type def because public setup context type relies on
  2320. * legacy VNode types
  2321. */
  2322. function useListeners() {
  2323. return getContext().listeners;
  2324. }
  2325. function getContext() {
  2326. if (!currentInstance) {
  2327. warn$2(`useContext() called without active instance.`);
  2328. }
  2329. const vm = currentInstance;
  2330. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2331. }
  2332. /**
  2333. * Runtime helper for merging default declarations. Imported by compiled code
  2334. * only.
  2335. * @internal
  2336. */
  2337. function mergeDefaults(raw, defaults) {
  2338. const props = isArray(raw)
  2339. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2340. : raw;
  2341. for (const key in defaults) {
  2342. const opt = props[key];
  2343. if (opt) {
  2344. if (isArray(opt) || isFunction(opt)) {
  2345. props[key] = { type: opt, default: defaults[key] };
  2346. }
  2347. else {
  2348. opt.default = defaults[key];
  2349. }
  2350. }
  2351. else if (opt === null) {
  2352. props[key] = { default: defaults[key] };
  2353. }
  2354. else {
  2355. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2356. }
  2357. }
  2358. return props;
  2359. }
  2360. function initRender(vm) {
  2361. vm._vnode = null; // the root of the child tree
  2362. vm._staticTrees = null; // v-once cached trees
  2363. const options = vm.$options;
  2364. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2365. const renderContext = parentVnode && parentVnode.context;
  2366. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2367. vm.$scopedSlots = parentVnode
  2368. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2369. : emptyObject;
  2370. // bind the createElement fn to this instance
  2371. // so that we get proper render context inside it.
  2372. // args order: tag, data, children, normalizationType, alwaysNormalize
  2373. // internal version is used by render functions compiled from templates
  2374. // @ts-expect-error
  2375. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2376. // normalization is always applied for the public version, used in
  2377. // user-written render functions.
  2378. // @ts-expect-error
  2379. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2380. // $attrs & $listeners are exposed for easier HOC creation.
  2381. // they need to be reactive so that HOCs using them are always updated
  2382. const parentData = parentVnode && parentVnode.data;
  2383. /* istanbul ignore else */
  2384. {
  2385. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2386. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2387. }, true);
  2388. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2389. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2390. }, true);
  2391. }
  2392. }
  2393. let currentRenderingInstance = null;
  2394. function renderMixin(Vue) {
  2395. // install runtime convenience helpers
  2396. installRenderHelpers(Vue.prototype);
  2397. Vue.prototype.$nextTick = function (fn) {
  2398. return nextTick(fn, this);
  2399. };
  2400. Vue.prototype._render = function () {
  2401. const vm = this;
  2402. const { render, _parentVnode } = vm.$options;
  2403. if (_parentVnode && vm._isMounted) {
  2404. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2405. if (vm._slotsProxy) {
  2406. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2407. }
  2408. }
  2409. // set parent vnode. this allows render functions to have access
  2410. // to the data on the placeholder node.
  2411. vm.$vnode = _parentVnode;
  2412. // render self
  2413. let vnode;
  2414. try {
  2415. // There's no need to maintain a stack because all render fns are called
  2416. // separately from one another. Nested component's render fns are called
  2417. // when parent component is patched.
  2418. setCurrentInstance(vm);
  2419. currentRenderingInstance = vm;
  2420. vnode = render.call(vm._renderProxy, vm.$createElement);
  2421. }
  2422. catch (e) {
  2423. handleError(e, vm, `render`);
  2424. // return error render result,
  2425. // or previous vnode to prevent render error causing blank component
  2426. /* istanbul ignore else */
  2427. if (vm.$options.renderError) {
  2428. try {
  2429. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2430. }
  2431. catch (e) {
  2432. handleError(e, vm, `renderError`);
  2433. vnode = vm._vnode;
  2434. }
  2435. }
  2436. else {
  2437. vnode = vm._vnode;
  2438. }
  2439. }
  2440. finally {
  2441. currentRenderingInstance = null;
  2442. setCurrentInstance();
  2443. }
  2444. // if the returned array contains only a single node, allow it
  2445. if (isArray(vnode) && vnode.length === 1) {
  2446. vnode = vnode[0];
  2447. }
  2448. // return empty vnode in case the render function errored out
  2449. if (!(vnode instanceof VNode)) {
  2450. if (isArray(vnode)) {
  2451. warn$2('Multiple root nodes returned from render function. Render function ' +
  2452. 'should return a single root node.', vm);
  2453. }
  2454. vnode = createEmptyVNode();
  2455. }
  2456. // set parent
  2457. vnode.parent = _parentVnode;
  2458. return vnode;
  2459. };
  2460. }
  2461. function ensureCtor(comp, base) {
  2462. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2463. comp = comp.default;
  2464. }
  2465. return isObject(comp) ? base.extend(comp) : comp;
  2466. }
  2467. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2468. const node = createEmptyVNode();
  2469. node.asyncFactory = factory;
  2470. node.asyncMeta = { data, context, children, tag };
  2471. return node;
  2472. }
  2473. function resolveAsyncComponent(factory, baseCtor) {
  2474. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2475. return factory.errorComp;
  2476. }
  2477. if (isDef(factory.resolved)) {
  2478. return factory.resolved;
  2479. }
  2480. const owner = currentRenderingInstance;
  2481. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2482. // already pending
  2483. factory.owners.push(owner);
  2484. }
  2485. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2486. return factory.loadingComp;
  2487. }
  2488. if (owner && !isDef(factory.owners)) {
  2489. const owners = (factory.owners = [owner]);
  2490. let sync = true;
  2491. let timerLoading = null;
  2492. let timerTimeout = null;
  2493. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2494. const forceRender = (renderCompleted) => {
  2495. for (let i = 0, l = owners.length; i < l; i++) {
  2496. owners[i].$forceUpdate();
  2497. }
  2498. if (renderCompleted) {
  2499. owners.length = 0;
  2500. if (timerLoading !== null) {
  2501. clearTimeout(timerLoading);
  2502. timerLoading = null;
  2503. }
  2504. if (timerTimeout !== null) {
  2505. clearTimeout(timerTimeout);
  2506. timerTimeout = null;
  2507. }
  2508. }
  2509. };
  2510. const resolve = once((res) => {
  2511. // cache resolved
  2512. factory.resolved = ensureCtor(res, baseCtor);
  2513. // invoke callbacks only if this is not a synchronous resolve
  2514. // (async resolves are shimmed as synchronous during SSR)
  2515. if (!sync) {
  2516. forceRender(true);
  2517. }
  2518. else {
  2519. owners.length = 0;
  2520. }
  2521. });
  2522. const reject = once(reason => {
  2523. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2524. (reason ? `\nReason: ${reason}` : ''));
  2525. if (isDef(factory.errorComp)) {
  2526. factory.error = true;
  2527. forceRender(true);
  2528. }
  2529. });
  2530. const res = factory(resolve, reject);
  2531. if (isObject(res)) {
  2532. if (isPromise(res)) {
  2533. // () => Promise
  2534. if (isUndef(factory.resolved)) {
  2535. res.then(resolve, reject);
  2536. }
  2537. }
  2538. else if (isPromise(res.component)) {
  2539. res.component.then(resolve, reject);
  2540. if (isDef(res.error)) {
  2541. factory.errorComp = ensureCtor(res.error, baseCtor);
  2542. }
  2543. if (isDef(res.loading)) {
  2544. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2545. if (res.delay === 0) {
  2546. factory.loading = true;
  2547. }
  2548. else {
  2549. // @ts-expect-error NodeJS timeout type
  2550. timerLoading = setTimeout(() => {
  2551. timerLoading = null;
  2552. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2553. factory.loading = true;
  2554. forceRender(false);
  2555. }
  2556. }, res.delay || 200);
  2557. }
  2558. }
  2559. if (isDef(res.timeout)) {
  2560. // @ts-expect-error NodeJS timeout type
  2561. timerTimeout = setTimeout(() => {
  2562. timerTimeout = null;
  2563. if (isUndef(factory.resolved)) {
  2564. reject(`timeout (${res.timeout}ms)` );
  2565. }
  2566. }, res.timeout);
  2567. }
  2568. }
  2569. }
  2570. sync = false;
  2571. // return in case resolved synchronously
  2572. return factory.loading ? factory.loadingComp : factory.resolved;
  2573. }
  2574. }
  2575. function getFirstComponentChild(children) {
  2576. if (isArray(children)) {
  2577. for (let i = 0; i < children.length; i++) {
  2578. const c = children[i];
  2579. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2580. return c;
  2581. }
  2582. }
  2583. }
  2584. }
  2585. function initEvents(vm) {
  2586. vm._events = Object.create(null);
  2587. vm._hasHookEvent = false;
  2588. // init parent attached events
  2589. const listeners = vm.$options._parentListeners;
  2590. if (listeners) {
  2591. updateComponentListeners(vm, listeners);
  2592. }
  2593. }
  2594. let target$1;
  2595. function add$1(event, fn) {
  2596. target$1.$on(event, fn);
  2597. }
  2598. function remove$1(event, fn) {
  2599. target$1.$off(event, fn);
  2600. }
  2601. function createOnceHandler$1(event, fn) {
  2602. const _target = target$1;
  2603. return function onceHandler() {
  2604. const res = fn.apply(null, arguments);
  2605. if (res !== null) {
  2606. _target.$off(event, onceHandler);
  2607. }
  2608. };
  2609. }
  2610. function updateComponentListeners(vm, listeners, oldListeners) {
  2611. target$1 = vm;
  2612. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2613. target$1 = undefined;
  2614. }
  2615. function eventsMixin(Vue) {
  2616. const hookRE = /^hook:/;
  2617. Vue.prototype.$on = function (event, fn) {
  2618. const vm = this;
  2619. if (isArray(event)) {
  2620. for (let i = 0, l = event.length; i < l; i++) {
  2621. vm.$on(event[i], fn);
  2622. }
  2623. }
  2624. else {
  2625. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2626. // optimize hook:event cost by using a boolean flag marked at registration
  2627. // instead of a hash lookup
  2628. if (hookRE.test(event)) {
  2629. vm._hasHookEvent = true;
  2630. }
  2631. }
  2632. return vm;
  2633. };
  2634. Vue.prototype.$once = function (event, fn) {
  2635. const vm = this;
  2636. function on() {
  2637. vm.$off(event, on);
  2638. fn.apply(vm, arguments);
  2639. }
  2640. on.fn = fn;
  2641. vm.$on(event, on);
  2642. return vm;
  2643. };
  2644. Vue.prototype.$off = function (event, fn) {
  2645. const vm = this;
  2646. // all
  2647. if (!arguments.length) {
  2648. vm._events = Object.create(null);
  2649. return vm;
  2650. }
  2651. // array of events
  2652. if (isArray(event)) {
  2653. for (let i = 0, l = event.length; i < l; i++) {
  2654. vm.$off(event[i], fn);
  2655. }
  2656. return vm;
  2657. }
  2658. // specific event
  2659. const cbs = vm._events[event];
  2660. if (!cbs) {
  2661. return vm;
  2662. }
  2663. if (!fn) {
  2664. vm._events[event] = null;
  2665. return vm;
  2666. }
  2667. // specific handler
  2668. let cb;
  2669. let i = cbs.length;
  2670. while (i--) {
  2671. cb = cbs[i];
  2672. if (cb === fn || cb.fn === fn) {
  2673. cbs.splice(i, 1);
  2674. break;
  2675. }
  2676. }
  2677. return vm;
  2678. };
  2679. Vue.prototype.$emit = function (event) {
  2680. const vm = this;
  2681. {
  2682. const lowerCaseEvent = event.toLowerCase();
  2683. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2684. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2685. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2686. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2687. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2688. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2689. }
  2690. }
  2691. let cbs = vm._events[event];
  2692. if (cbs) {
  2693. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2694. const args = toArray(arguments, 1);
  2695. const info = `event handler for "${event}"`;
  2696. for (let i = 0, l = cbs.length; i < l; i++) {
  2697. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2698. }
  2699. }
  2700. return vm;
  2701. };
  2702. }
  2703. let activeInstance = null;
  2704. let isUpdatingChildComponent = false;
  2705. function setActiveInstance(vm) {
  2706. const prevActiveInstance = activeInstance;
  2707. activeInstance = vm;
  2708. return () => {
  2709. activeInstance = prevActiveInstance;
  2710. };
  2711. }
  2712. function initLifecycle(vm) {
  2713. const options = vm.$options;
  2714. // locate first non-abstract parent
  2715. let parent = options.parent;
  2716. if (parent && !options.abstract) {
  2717. while (parent.$options.abstract && parent.$parent) {
  2718. parent = parent.$parent;
  2719. }
  2720. parent.$children.push(vm);
  2721. }
  2722. vm.$parent = parent;
  2723. vm.$root = parent ? parent.$root : vm;
  2724. vm.$children = [];
  2725. vm.$refs = {};
  2726. vm._provided = parent ? parent._provided : Object.create(null);
  2727. vm._watcher = null;
  2728. vm._inactive = null;
  2729. vm._directInactive = false;
  2730. vm._isMounted = false;
  2731. vm._isDestroyed = false;
  2732. vm._isBeingDestroyed = false;
  2733. }
  2734. function lifecycleMixin(Vue) {
  2735. Vue.prototype._update = function (vnode, hydrating) {
  2736. const vm = this;
  2737. const prevEl = vm.$el;
  2738. const prevVnode = vm._vnode;
  2739. const restoreActiveInstance = setActiveInstance(vm);
  2740. vm._vnode = vnode;
  2741. // Vue.prototype.__patch__ is injected in entry points
  2742. // based on the rendering backend used.
  2743. if (!prevVnode) {
  2744. // initial render
  2745. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2746. }
  2747. else {
  2748. // updates
  2749. vm.$el = vm.__patch__(prevVnode, vnode);
  2750. }
  2751. restoreActiveInstance();
  2752. // update __vue__ reference
  2753. if (prevEl) {
  2754. prevEl.__vue__ = null;
  2755. }
  2756. if (vm.$el) {
  2757. vm.$el.__vue__ = vm;
  2758. }
  2759. // if parent is an HOC, update its $el as well
  2760. let wrapper = vm;
  2761. while (wrapper &&
  2762. wrapper.$vnode &&
  2763. wrapper.$parent &&
  2764. wrapper.$vnode === wrapper.$parent._vnode) {
  2765. wrapper.$parent.$el = wrapper.$el;
  2766. wrapper = wrapper.$parent;
  2767. }
  2768. // updated hook is called by the scheduler to ensure that children are
  2769. // updated in a parent's updated hook.
  2770. };
  2771. Vue.prototype.$forceUpdate = function () {
  2772. const vm = this;
  2773. if (vm._watcher) {
  2774. vm._watcher.update();
  2775. }
  2776. };
  2777. Vue.prototype.$destroy = function () {
  2778. const vm = this;
  2779. if (vm._isBeingDestroyed) {
  2780. return;
  2781. }
  2782. callHook$1(vm, 'beforeDestroy');
  2783. vm._isBeingDestroyed = true;
  2784. // remove self from parent
  2785. const parent = vm.$parent;
  2786. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2787. remove$2(parent.$children, vm);
  2788. }
  2789. // teardown scope. this includes both the render watcher and other
  2790. // watchers created
  2791. vm._scope.stop();
  2792. // remove reference from data ob
  2793. // frozen object may not have observer.
  2794. if (vm._data.__ob__) {
  2795. vm._data.__ob__.vmCount--;
  2796. }
  2797. // call the last hook...
  2798. vm._isDestroyed = true;
  2799. // invoke destroy hooks on current rendered tree
  2800. vm.__patch__(vm._vnode, null);
  2801. // fire destroyed hook
  2802. callHook$1(vm, 'destroyed');
  2803. // turn off all instance listeners.
  2804. vm.$off();
  2805. // remove __vue__ reference
  2806. if (vm.$el) {
  2807. vm.$el.__vue__ = null;
  2808. }
  2809. // release circular reference (#6759)
  2810. if (vm.$vnode) {
  2811. vm.$vnode.parent = null;
  2812. }
  2813. };
  2814. }
  2815. function mountComponent(vm, el, hydrating) {
  2816. vm.$el = el;
  2817. if (!vm.$options.render) {
  2818. // @ts-expect-error invalid type
  2819. vm.$options.render = createEmptyVNode;
  2820. {
  2821. /* istanbul ignore if */
  2822. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2823. vm.$options.el ||
  2824. el) {
  2825. warn$2('You are using the runtime-only build of Vue where the template ' +
  2826. 'compiler is not available. Either pre-compile the templates into ' +
  2827. 'render functions, or use the compiler-included build.', vm);
  2828. }
  2829. else {
  2830. warn$2('Failed to mount component: template or render function not defined.', vm);
  2831. }
  2832. }
  2833. }
  2834. callHook$1(vm, 'beforeMount');
  2835. let updateComponent;
  2836. /* istanbul ignore if */
  2837. if (config.performance && mark) {
  2838. updateComponent = () => {
  2839. const name = vm._name;
  2840. const id = vm._uid;
  2841. const startTag = `vue-perf-start:${id}`;
  2842. const endTag = `vue-perf-end:${id}`;
  2843. mark(startTag);
  2844. const vnode = vm._render();
  2845. mark(endTag);
  2846. measure(`vue ${name} render`, startTag, endTag);
  2847. mark(startTag);
  2848. vm._update(vnode, hydrating);
  2849. mark(endTag);
  2850. measure(`vue ${name} patch`, startTag, endTag);
  2851. };
  2852. }
  2853. else {
  2854. updateComponent = () => {
  2855. vm._update(vm._render(), hydrating);
  2856. };
  2857. }
  2858. const watcherOptions = {
  2859. before() {
  2860. if (vm._isMounted && !vm._isDestroyed) {
  2861. callHook$1(vm, 'beforeUpdate');
  2862. }
  2863. }
  2864. };
  2865. {
  2866. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2867. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2868. }
  2869. // we set this to vm._watcher inside the watcher's constructor
  2870. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2871. // component's mounted hook), which relies on vm._watcher being already defined
  2872. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2873. hydrating = false;
  2874. // flush buffer for flush: "pre" watchers queued in setup()
  2875. const preWatchers = vm._preWatchers;
  2876. if (preWatchers) {
  2877. for (let i = 0; i < preWatchers.length; i++) {
  2878. preWatchers[i].run();
  2879. }
  2880. }
  2881. // manually mounted instance, call mounted on self
  2882. // mounted is called for render-created child components in its inserted hook
  2883. if (vm.$vnode == null) {
  2884. vm._isMounted = true;
  2885. callHook$1(vm, 'mounted');
  2886. }
  2887. return vm;
  2888. }
  2889. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2890. {
  2891. isUpdatingChildComponent = true;
  2892. }
  2893. // determine whether component has slot children
  2894. // we need to do this before overwriting $options._renderChildren.
  2895. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2896. // dynamic slot names). Static scoped slots compiled from template has the
  2897. // "$stable" marker.
  2898. const newScopedSlots = parentVnode.data.scopedSlots;
  2899. const oldScopedSlots = vm.$scopedSlots;
  2900. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  2901. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  2902. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  2903. (!newScopedSlots && vm.$scopedSlots.$key));
  2904. // Any static slot children from the parent may have changed during parent's
  2905. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  2906. // update is necessary to ensure correctness.
  2907. let needsForceUpdate = !!(renderChildren || // has new static slots
  2908. vm.$options._renderChildren || // has old static slots
  2909. hasDynamicScopedSlot);
  2910. const prevVNode = vm.$vnode;
  2911. vm.$options._parentVnode = parentVnode;
  2912. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2913. if (vm._vnode) {
  2914. // update child tree's parent
  2915. vm._vnode.parent = parentVnode;
  2916. }
  2917. vm.$options._renderChildren = renderChildren;
  2918. // update $attrs and $listeners hash
  2919. // these are also reactive so they may trigger child update if the child
  2920. // used them during render
  2921. const attrs = parentVnode.data.attrs || emptyObject;
  2922. if (vm._attrsProxy) {
  2923. // force update if attrs are accessed and has changed since it may be
  2924. // passed to a child component.
  2925. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  2926. needsForceUpdate = true;
  2927. }
  2928. }
  2929. vm.$attrs = attrs;
  2930. // update listeners
  2931. listeners = listeners || emptyObject;
  2932. const prevListeners = vm.$options._parentListeners;
  2933. if (vm._listenersProxy) {
  2934. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  2935. }
  2936. vm.$listeners = vm.$options._parentListeners = listeners;
  2937. updateComponentListeners(vm, listeners, prevListeners);
  2938. // update props
  2939. if (propsData && vm.$options.props) {
  2940. toggleObserving(false);
  2941. const props = vm._props;
  2942. const propKeys = vm.$options._propKeys || [];
  2943. for (let i = 0; i < propKeys.length; i++) {
  2944. const key = propKeys[i];
  2945. const propOptions = vm.$options.props; // wtf flow?
  2946. props[key] = validateProp(key, propOptions, propsData, vm);
  2947. }
  2948. toggleObserving(true);
  2949. // keep a copy of raw propsData
  2950. vm.$options.propsData = propsData;
  2951. }
  2952. // resolve slots + force update if has children
  2953. if (needsForceUpdate) {
  2954. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2955. vm.$forceUpdate();
  2956. }
  2957. {
  2958. isUpdatingChildComponent = false;
  2959. }
  2960. }
  2961. function isInInactiveTree(vm) {
  2962. while (vm && (vm = vm.$parent)) {
  2963. if (vm._inactive)
  2964. return true;
  2965. }
  2966. return false;
  2967. }
  2968. function activateChildComponent(vm, direct) {
  2969. if (direct) {
  2970. vm._directInactive = false;
  2971. if (isInInactiveTree(vm)) {
  2972. return;
  2973. }
  2974. }
  2975. else if (vm._directInactive) {
  2976. return;
  2977. }
  2978. if (vm._inactive || vm._inactive === null) {
  2979. vm._inactive = false;
  2980. for (let i = 0; i < vm.$children.length; i++) {
  2981. activateChildComponent(vm.$children[i]);
  2982. }
  2983. callHook$1(vm, 'activated');
  2984. }
  2985. }
  2986. function deactivateChildComponent(vm, direct) {
  2987. if (direct) {
  2988. vm._directInactive = true;
  2989. if (isInInactiveTree(vm)) {
  2990. return;
  2991. }
  2992. }
  2993. if (!vm._inactive) {
  2994. vm._inactive = true;
  2995. for (let i = 0; i < vm.$children.length; i++) {
  2996. deactivateChildComponent(vm.$children[i]);
  2997. }
  2998. callHook$1(vm, 'deactivated');
  2999. }
  3000. }
  3001. function callHook$1(vm, hook, args, setContext = true) {
  3002. // #7573 disable dep collection when invoking lifecycle hooks
  3003. pushTarget();
  3004. const prev = currentInstance;
  3005. setContext && setCurrentInstance(vm);
  3006. const handlers = vm.$options[hook];
  3007. const info = `${hook} hook`;
  3008. if (handlers) {
  3009. for (let i = 0, j = handlers.length; i < j; i++) {
  3010. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3011. }
  3012. }
  3013. if (vm._hasHookEvent) {
  3014. vm.$emit('hook:' + hook);
  3015. }
  3016. setContext && setCurrentInstance(prev);
  3017. popTarget();
  3018. }
  3019. const MAX_UPDATE_COUNT = 100;
  3020. const queue = [];
  3021. const activatedChildren = [];
  3022. let has = {};
  3023. let circular = {};
  3024. let waiting = false;
  3025. let flushing = false;
  3026. let index$1 = 0;
  3027. /**
  3028. * Reset the scheduler's state.
  3029. */
  3030. function resetSchedulerState() {
  3031. index$1 = queue.length = activatedChildren.length = 0;
  3032. has = {};
  3033. {
  3034. circular = {};
  3035. }
  3036. waiting = flushing = false;
  3037. }
  3038. // Async edge case #6566 requires saving the timestamp when event listeners are
  3039. // attached. However, calling performance.now() has a perf overhead especially
  3040. // if the page has thousands of event listeners. Instead, we take a timestamp
  3041. // every time the scheduler flushes and use that for all event listeners
  3042. // attached during that flush.
  3043. let currentFlushTimestamp = 0;
  3044. // Async edge case fix requires storing an event listener's attach timestamp.
  3045. let getNow = Date.now;
  3046. // Determine what event timestamp the browser is using. Annoyingly, the
  3047. // timestamp can either be hi-res (relative to page load) or low-res
  3048. // (relative to UNIX epoch), so in order to compare time we have to use the
  3049. // same timestamp type when saving the flush timestamp.
  3050. // All IE versions use low-res event timestamps, and have problematic clock
  3051. // implementations (#9632)
  3052. if (inBrowser && !isIE) {
  3053. const performance = window.performance;
  3054. if (performance &&
  3055. typeof performance.now === 'function' &&
  3056. getNow() > document.createEvent('Event').timeStamp) {
  3057. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3058. // smaller than it, it means the event is using a hi-res timestamp,
  3059. // and we need to use the hi-res version for event listener timestamps as
  3060. // well.
  3061. getNow = () => performance.now();
  3062. }
  3063. }
  3064. const sortCompareFn = (a, b) => {
  3065. if (a.post) {
  3066. if (!b.post)
  3067. return 1;
  3068. }
  3069. else if (b.post) {
  3070. return -1;
  3071. }
  3072. return a.id - b.id;
  3073. };
  3074. /**
  3075. * Flush both queues and run the watchers.
  3076. */
  3077. function flushSchedulerQueue() {
  3078. currentFlushTimestamp = getNow();
  3079. flushing = true;
  3080. let watcher, id;
  3081. // Sort queue before flush.
  3082. // This ensures that:
  3083. // 1. Components are updated from parent to child. (because parent is always
  3084. // created before the child)
  3085. // 2. A component's user watchers are run before its render watcher (because
  3086. // user watchers are created before the render watcher)
  3087. // 3. If a component is destroyed during a parent component's watcher run,
  3088. // its watchers can be skipped.
  3089. queue.sort(sortCompareFn);
  3090. // do not cache length because more watchers might be pushed
  3091. // as we run existing watchers
  3092. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3093. watcher = queue[index$1];
  3094. if (watcher.before) {
  3095. watcher.before();
  3096. }
  3097. id = watcher.id;
  3098. has[id] = null;
  3099. watcher.run();
  3100. // in dev build, check and stop circular updates.
  3101. if (has[id] != null) {
  3102. circular[id] = (circular[id] || 0) + 1;
  3103. if (circular[id] > MAX_UPDATE_COUNT) {
  3104. warn$2('You may have an infinite update loop ' +
  3105. (watcher.user
  3106. ? `in watcher with expression "${watcher.expression}"`
  3107. : `in a component render function.`), watcher.vm);
  3108. break;
  3109. }
  3110. }
  3111. }
  3112. // keep copies of post queues before resetting state
  3113. const activatedQueue = activatedChildren.slice();
  3114. const updatedQueue = queue.slice();
  3115. resetSchedulerState();
  3116. // call component updated and activated hooks
  3117. callActivatedHooks(activatedQueue);
  3118. callUpdatedHooks(updatedQueue);
  3119. cleanupDeps();
  3120. // devtool hook
  3121. /* istanbul ignore if */
  3122. if (devtools && config.devtools) {
  3123. devtools.emit('flush');
  3124. }
  3125. }
  3126. function callUpdatedHooks(queue) {
  3127. let i = queue.length;
  3128. while (i--) {
  3129. const watcher = queue[i];
  3130. const vm = watcher.vm;
  3131. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3132. callHook$1(vm, 'updated');
  3133. }
  3134. }
  3135. }
  3136. /**
  3137. * Queue a kept-alive component that was activated during patch.
  3138. * The queue will be processed after the entire tree has been patched.
  3139. */
  3140. function queueActivatedComponent(vm) {
  3141. // setting _inactive to false here so that a render function can
  3142. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3143. vm._inactive = false;
  3144. activatedChildren.push(vm);
  3145. }
  3146. function callActivatedHooks(queue) {
  3147. for (let i = 0; i < queue.length; i++) {
  3148. queue[i]._inactive = true;
  3149. activateChildComponent(queue[i], true /* true */);
  3150. }
  3151. }
  3152. /**
  3153. * Push a watcher into the watcher queue.
  3154. * Jobs with duplicate IDs will be skipped unless it's
  3155. * pushed when the queue is being flushed.
  3156. */
  3157. function queueWatcher(watcher) {
  3158. const id = watcher.id;
  3159. if (has[id] != null) {
  3160. return;
  3161. }
  3162. if (watcher === Dep.target && watcher.noRecurse) {
  3163. return;
  3164. }
  3165. has[id] = true;
  3166. if (!flushing) {
  3167. queue.push(watcher);
  3168. }
  3169. else {
  3170. // if already flushing, splice the watcher based on its id
  3171. // if already past its id, it will be run next immediately.
  3172. let i = queue.length - 1;
  3173. while (i > index$1 && queue[i].id > watcher.id) {
  3174. i--;
  3175. }
  3176. queue.splice(i + 1, 0, watcher);
  3177. }
  3178. // queue the flush
  3179. if (!waiting) {
  3180. waiting = true;
  3181. if (!config.async) {
  3182. flushSchedulerQueue();
  3183. return;
  3184. }
  3185. nextTick(flushSchedulerQueue);
  3186. }
  3187. }
  3188. const WATCHER = `watcher`;
  3189. const WATCHER_CB = `${WATCHER} callback`;
  3190. const WATCHER_GETTER = `${WATCHER} getter`;
  3191. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3192. // Simple effect.
  3193. function watchEffect(effect, options) {
  3194. return doWatch(effect, null, options);
  3195. }
  3196. function watchPostEffect(effect, options) {
  3197. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3198. }
  3199. function watchSyncEffect(effect, options) {
  3200. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3201. }
  3202. // initial value for watchers to trigger on undefined initial values
  3203. const INITIAL_WATCHER_VALUE = {};
  3204. // implementation
  3205. function watch(source, cb, options) {
  3206. if (typeof cb !== 'function') {
  3207. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3208. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3209. `supports \`watch(source, cb, options?) signature.`);
  3210. }
  3211. return doWatch(source, cb, options);
  3212. }
  3213. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3214. if (!cb) {
  3215. if (immediate !== undefined) {
  3216. warn$2(`watch() "immediate" option is only respected when using the ` +
  3217. `watch(source, callback, options?) signature.`);
  3218. }
  3219. if (deep !== undefined) {
  3220. warn$2(`watch() "deep" option is only respected when using the ` +
  3221. `watch(source, callback, options?) signature.`);
  3222. }
  3223. }
  3224. const warnInvalidSource = (s) => {
  3225. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3226. `function, a ref, a reactive object, or an array of these types.`);
  3227. };
  3228. const instance = currentInstance;
  3229. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3230. let getter;
  3231. let forceTrigger = false;
  3232. let isMultiSource = false;
  3233. if (isRef(source)) {
  3234. getter = () => source.value;
  3235. forceTrigger = isShallow(source);
  3236. }
  3237. else if (isReactive(source)) {
  3238. getter = () => {
  3239. source.__ob__.dep.depend();
  3240. return source;
  3241. };
  3242. deep = true;
  3243. }
  3244. else if (isArray(source)) {
  3245. isMultiSource = true;
  3246. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3247. getter = () => source.map(s => {
  3248. if (isRef(s)) {
  3249. return s.value;
  3250. }
  3251. else if (isReactive(s)) {
  3252. return traverse(s);
  3253. }
  3254. else if (isFunction(s)) {
  3255. return call(s, WATCHER_GETTER);
  3256. }
  3257. else {
  3258. warnInvalidSource(s);
  3259. }
  3260. });
  3261. }
  3262. else if (isFunction(source)) {
  3263. if (cb) {
  3264. // getter with cb
  3265. getter = () => call(source, WATCHER_GETTER);
  3266. }
  3267. else {
  3268. // no cb -> simple effect
  3269. getter = () => {
  3270. if (instance && instance._isDestroyed) {
  3271. return;
  3272. }
  3273. if (cleanup) {
  3274. cleanup();
  3275. }
  3276. return call(source, WATCHER, [onCleanup]);
  3277. };
  3278. }
  3279. }
  3280. else {
  3281. getter = noop;
  3282. warnInvalidSource(source);
  3283. }
  3284. if (cb && deep) {
  3285. const baseGetter = getter;
  3286. getter = () => traverse(baseGetter());
  3287. }
  3288. let cleanup;
  3289. let onCleanup = (fn) => {
  3290. cleanup = watcher.onStop = () => {
  3291. call(fn, WATCHER_CLEANUP);
  3292. };
  3293. };
  3294. // in SSR there is no need to setup an actual effect, and it should be noop
  3295. // unless it's eager
  3296. if (isServerRendering()) {
  3297. // we will also not call the invalidate callback (+ runner is not set up)
  3298. onCleanup = noop;
  3299. if (!cb) {
  3300. getter();
  3301. }
  3302. else if (immediate) {
  3303. call(cb, WATCHER_CB, [
  3304. getter(),
  3305. isMultiSource ? [] : undefined,
  3306. onCleanup
  3307. ]);
  3308. }
  3309. return noop;
  3310. }
  3311. const watcher = new Watcher(currentInstance, getter, noop, {
  3312. lazy: true
  3313. });
  3314. watcher.noRecurse = !cb;
  3315. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3316. // overwrite default run
  3317. watcher.run = () => {
  3318. if (!watcher.active) {
  3319. return;
  3320. }
  3321. if (cb) {
  3322. // watch(source, cb)
  3323. const newValue = watcher.get();
  3324. if (deep ||
  3325. forceTrigger ||
  3326. (isMultiSource
  3327. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3328. : hasChanged(newValue, oldValue))) {
  3329. // cleanup before running cb again
  3330. if (cleanup) {
  3331. cleanup();
  3332. }
  3333. call(cb, WATCHER_CB, [
  3334. newValue,
  3335. // pass undefined as the old value when it's changed for the first time
  3336. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3337. onCleanup
  3338. ]);
  3339. oldValue = newValue;
  3340. }
  3341. }
  3342. else {
  3343. // watchEffect
  3344. watcher.get();
  3345. }
  3346. };
  3347. if (flush === 'sync') {
  3348. watcher.update = watcher.run;
  3349. }
  3350. else if (flush === 'post') {
  3351. watcher.post = true;
  3352. watcher.update = () => queueWatcher(watcher);
  3353. }
  3354. else {
  3355. // pre
  3356. watcher.update = () => {
  3357. if (instance && instance === currentInstance && !instance._isMounted) {
  3358. // pre-watcher triggered before
  3359. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3360. if (buffer.indexOf(watcher) < 0)
  3361. buffer.push(watcher);
  3362. }
  3363. else {
  3364. queueWatcher(watcher);
  3365. }
  3366. };
  3367. }
  3368. {
  3369. watcher.onTrack = onTrack;
  3370. watcher.onTrigger = onTrigger;
  3371. }
  3372. // initial run
  3373. if (cb) {
  3374. if (immediate) {
  3375. watcher.run();
  3376. }
  3377. else {
  3378. oldValue = watcher.get();
  3379. }
  3380. }
  3381. else if (flush === 'post' && instance) {
  3382. instance.$once('hook:mounted', () => watcher.get());
  3383. }
  3384. else {
  3385. watcher.get();
  3386. }
  3387. return () => {
  3388. watcher.teardown();
  3389. };
  3390. }
  3391. let activeEffectScope;
  3392. class EffectScope {
  3393. constructor(detached = false) {
  3394. /**
  3395. * @internal
  3396. */
  3397. this.active = true;
  3398. /**
  3399. * @internal
  3400. */
  3401. this.effects = [];
  3402. /**
  3403. * @internal
  3404. */
  3405. this.cleanups = [];
  3406. if (!detached && activeEffectScope) {
  3407. this.parent = activeEffectScope;
  3408. this.index =
  3409. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  3410. }
  3411. }
  3412. run(fn) {
  3413. if (this.active) {
  3414. const currentEffectScope = activeEffectScope;
  3415. try {
  3416. activeEffectScope = this;
  3417. return fn();
  3418. }
  3419. finally {
  3420. activeEffectScope = currentEffectScope;
  3421. }
  3422. }
  3423. else {
  3424. warn$2(`cannot run an inactive effect scope.`);
  3425. }
  3426. }
  3427. /**
  3428. * This should only be called on non-detached scopes
  3429. * @internal
  3430. */
  3431. on() {
  3432. activeEffectScope = this;
  3433. }
  3434. /**
  3435. * This should only be called on non-detached scopes
  3436. * @internal
  3437. */
  3438. off() {
  3439. activeEffectScope = this.parent;
  3440. }
  3441. stop(fromParent) {
  3442. if (this.active) {
  3443. let i, l;
  3444. for (i = 0, l = this.effects.length; i < l; i++) {
  3445. this.effects[i].teardown();
  3446. }
  3447. for (i = 0, l = this.cleanups.length; i < l; i++) {
  3448. this.cleanups[i]();
  3449. }
  3450. if (this.scopes) {
  3451. for (i = 0, l = this.scopes.length; i < l; i++) {
  3452. this.scopes[i].stop(true);
  3453. }
  3454. }
  3455. // nested scope, dereference from parent to avoid memory leaks
  3456. if (this.parent && !fromParent) {
  3457. // optimized O(1) removal
  3458. const last = this.parent.scopes.pop();
  3459. if (last && last !== this) {
  3460. this.parent.scopes[this.index] = last;
  3461. last.index = this.index;
  3462. }
  3463. }
  3464. this.active = false;
  3465. }
  3466. }
  3467. }
  3468. function effectScope(detached) {
  3469. return new EffectScope(detached);
  3470. }
  3471. /**
  3472. * @internal
  3473. */
  3474. function recordEffectScope(effect, scope = activeEffectScope) {
  3475. if (scope && scope.active) {
  3476. scope.effects.push(effect);
  3477. }
  3478. }
  3479. function getCurrentScope() {
  3480. return activeEffectScope;
  3481. }
  3482. function onScopeDispose(fn) {
  3483. if (activeEffectScope) {
  3484. activeEffectScope.cleanups.push(fn);
  3485. }
  3486. else {
  3487. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  3488. ` to be associated with.`);
  3489. }
  3490. }
  3491. function provide(key, value) {
  3492. if (!currentInstance) {
  3493. {
  3494. warn$2(`provide() can only be used inside setup().`);
  3495. }
  3496. }
  3497. else {
  3498. // TS doesn't allow symbol as index type
  3499. resolveProvided(currentInstance)[key] = value;
  3500. }
  3501. }
  3502. function resolveProvided(vm) {
  3503. // by default an instance inherits its parent's provides object
  3504. // but when it needs to provide values of its own, it creates its
  3505. // own provides object using parent provides object as prototype.
  3506. // this way in `inject` we can simply look up injections from direct
  3507. // parent and let the prototype chain do the work.
  3508. const existing = vm._provided;
  3509. const parentProvides = vm.$parent && vm.$parent._provided;
  3510. if (parentProvides === existing) {
  3511. return (vm._provided = Object.create(parentProvides));
  3512. }
  3513. else {
  3514. return existing;
  3515. }
  3516. }
  3517. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3518. // fallback to `currentRenderingInstance` so that this can be called in
  3519. // a functional component
  3520. const instance = currentInstance;
  3521. if (instance) {
  3522. // #2400
  3523. // to support `app.use` plugins,
  3524. // fallback to appContext's `provides` if the instance is at root
  3525. const provides = instance.$parent && instance.$parent._provided;
  3526. if (provides && key in provides) {
  3527. // TS doesn't allow symbol as index type
  3528. return provides[key];
  3529. }
  3530. else if (arguments.length > 1) {
  3531. return treatDefaultAsFactory && isFunction(defaultValue)
  3532. ? defaultValue.call(instance)
  3533. : defaultValue;
  3534. }
  3535. else {
  3536. warn$2(`injection "${String(key)}" not found.`);
  3537. }
  3538. }
  3539. else {
  3540. warn$2(`inject() can only be used inside setup() or functional components.`);
  3541. }
  3542. }
  3543. /**
  3544. * @internal this function needs manual public type declaration because it relies
  3545. * on previously manually authored types from Vue 2
  3546. */
  3547. function h(type, props, children) {
  3548. if (!currentInstance) {
  3549. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3550. `component instance, e.g. synchronously in a component's render or setup function.`);
  3551. }
  3552. return createElement$1(currentInstance, type, props, children, 2, true);
  3553. }
  3554. function handleError(err, vm, info) {
  3555. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3556. // See: https://github.com/vuejs/vuex/issues/1505
  3557. pushTarget();
  3558. try {
  3559. if (vm) {
  3560. let cur = vm;
  3561. while ((cur = cur.$parent)) {
  3562. const hooks = cur.$options.errorCaptured;
  3563. if (hooks) {
  3564. for (let i = 0; i < hooks.length; i++) {
  3565. try {
  3566. const capture = hooks[i].call(cur, err, vm, info) === false;
  3567. if (capture)
  3568. return;
  3569. }
  3570. catch (e) {
  3571. globalHandleError(e, cur, 'errorCaptured hook');
  3572. }
  3573. }
  3574. }
  3575. }
  3576. }
  3577. globalHandleError(err, vm, info);
  3578. }
  3579. finally {
  3580. popTarget();
  3581. }
  3582. }
  3583. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3584. let res;
  3585. try {
  3586. res = args ? handler.apply(context, args) : handler.call(context);
  3587. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3588. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3589. res._handled = true;
  3590. }
  3591. }
  3592. catch (e) {
  3593. handleError(e, vm, info);
  3594. }
  3595. return res;
  3596. }
  3597. function globalHandleError(err, vm, info) {
  3598. if (config.errorHandler) {
  3599. try {
  3600. return config.errorHandler.call(null, err, vm, info);
  3601. }
  3602. catch (e) {
  3603. // if the user intentionally throws the original error in the handler,
  3604. // do not log it twice
  3605. if (e !== err) {
  3606. logError(e, null, 'config.errorHandler');
  3607. }
  3608. }
  3609. }
  3610. logError(err, vm, info);
  3611. }
  3612. function logError(err, vm, info) {
  3613. {
  3614. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3615. }
  3616. /* istanbul ignore else */
  3617. if (inBrowser && typeof console !== 'undefined') {
  3618. console.error(err);
  3619. }
  3620. else {
  3621. throw err;
  3622. }
  3623. }
  3624. /* globals MutationObserver */
  3625. let isUsingMicroTask = false;
  3626. const callbacks = [];
  3627. let pending = false;
  3628. function flushCallbacks() {
  3629. pending = false;
  3630. const copies = callbacks.slice(0);
  3631. callbacks.length = 0;
  3632. for (let i = 0; i < copies.length; i++) {
  3633. copies[i]();
  3634. }
  3635. }
  3636. // Here we have async deferring wrappers using microtasks.
  3637. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3638. // However, it has subtle problems when state is changed right before repaint
  3639. // (e.g. #6813, out-in transitions).
  3640. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3641. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3642. // So we now use microtasks everywhere, again.
  3643. // A major drawback of this tradeoff is that there are some scenarios
  3644. // where microtasks have too high a priority and fire in between supposedly
  3645. // sequential events (e.g. #4521, #6690, which have workarounds)
  3646. // or even between bubbling of the same event (#6566).
  3647. let timerFunc;
  3648. // The nextTick behavior leverages the microtask queue, which can be accessed
  3649. // via either native Promise.then or MutationObserver.
  3650. // MutationObserver has wider support, however it is seriously bugged in
  3651. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3652. // completely stops working after triggering a few times... so, if native
  3653. // Promise is available, we will use it:
  3654. /* istanbul ignore next, $flow-disable-line */
  3655. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3656. const p = Promise.resolve();
  3657. timerFunc = () => {
  3658. p.then(flushCallbacks);
  3659. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3660. // it can get stuck in a weird state where callbacks are pushed into the
  3661. // microtask queue but the queue isn't being flushed, until the browser
  3662. // needs to do some other work, e.g. handle a timer. Therefore we can
  3663. // "force" the microtask queue to be flushed by adding an empty timer.
  3664. if (isIOS)
  3665. setTimeout(noop);
  3666. };
  3667. isUsingMicroTask = true;
  3668. }
  3669. else if (!isIE &&
  3670. typeof MutationObserver !== 'undefined' &&
  3671. (isNative(MutationObserver) ||
  3672. // PhantomJS and iOS 7.x
  3673. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3674. // Use MutationObserver where native Promise is not available,
  3675. // e.g. PhantomJS, iOS7, Android 4.4
  3676. // (#6466 MutationObserver is unreliable in IE11)
  3677. let counter = 1;
  3678. const observer = new MutationObserver(flushCallbacks);
  3679. const textNode = document.createTextNode(String(counter));
  3680. observer.observe(textNode, {
  3681. characterData: true
  3682. });
  3683. timerFunc = () => {
  3684. counter = (counter + 1) % 2;
  3685. textNode.data = String(counter);
  3686. };
  3687. isUsingMicroTask = true;
  3688. }
  3689. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3690. // Fallback to setImmediate.
  3691. // Technically it leverages the (macro) task queue,
  3692. // but it is still a better choice than setTimeout.
  3693. timerFunc = () => {
  3694. setImmediate(flushCallbacks);
  3695. };
  3696. }
  3697. else {
  3698. // Fallback to setTimeout.
  3699. timerFunc = () => {
  3700. setTimeout(flushCallbacks, 0);
  3701. };
  3702. }
  3703. /**
  3704. * @internal
  3705. */
  3706. function nextTick(cb, ctx) {
  3707. let _resolve;
  3708. callbacks.push(() => {
  3709. if (cb) {
  3710. try {
  3711. cb.call(ctx);
  3712. }
  3713. catch (e) {
  3714. handleError(e, ctx, 'nextTick');
  3715. }
  3716. }
  3717. else if (_resolve) {
  3718. _resolve(ctx);
  3719. }
  3720. });
  3721. if (!pending) {
  3722. pending = true;
  3723. timerFunc();
  3724. }
  3725. // $flow-disable-line
  3726. if (!cb && typeof Promise !== 'undefined') {
  3727. return new Promise(resolve => {
  3728. _resolve = resolve;
  3729. });
  3730. }
  3731. }
  3732. function useCssModule(name = '$style') {
  3733. /* istanbul ignore else */
  3734. {
  3735. if (!currentInstance) {
  3736. warn$2(`useCssModule must be called inside setup()`);
  3737. return emptyObject;
  3738. }
  3739. const mod = currentInstance[name];
  3740. if (!mod) {
  3741. warn$2(`Current instance does not have CSS module named "${name}".`);
  3742. return emptyObject;
  3743. }
  3744. return mod;
  3745. }
  3746. }
  3747. /**
  3748. * Runtime helper for SFC's CSS variable injection feature.
  3749. * @private
  3750. */
  3751. function useCssVars(getter) {
  3752. if (!inBrowser && !false)
  3753. return;
  3754. const instance = currentInstance;
  3755. if (!instance) {
  3756. warn$2(`useCssVars is called without current active component instance.`);
  3757. return;
  3758. }
  3759. watchPostEffect(() => {
  3760. const el = instance.$el;
  3761. const vars = getter(instance, instance._setupProxy);
  3762. if (el && el.nodeType === 1) {
  3763. const style = el.style;
  3764. for (const key in vars) {
  3765. style.setProperty(`--${key}`, vars[key]);
  3766. }
  3767. }
  3768. });
  3769. }
  3770. /**
  3771. * v3-compatible async component API.
  3772. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3773. * because it relies on existing manual types
  3774. */
  3775. function defineAsyncComponent(source) {
  3776. if (isFunction(source)) {
  3777. source = { loader: source };
  3778. }
  3779. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3780. suspensible = false, // in Vue 3 default is true
  3781. onError: userOnError } = source;
  3782. if (suspensible) {
  3783. warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3784. }
  3785. let pendingRequest = null;
  3786. let retries = 0;
  3787. const retry = () => {
  3788. retries++;
  3789. pendingRequest = null;
  3790. return load();
  3791. };
  3792. const load = () => {
  3793. let thisRequest;
  3794. return (pendingRequest ||
  3795. (thisRequest = pendingRequest =
  3796. loader()
  3797. .catch(err => {
  3798. err = err instanceof Error ? err : new Error(String(err));
  3799. if (userOnError) {
  3800. return new Promise((resolve, reject) => {
  3801. const userRetry = () => resolve(retry());
  3802. const userFail = () => reject(err);
  3803. userOnError(err, userRetry, userFail, retries + 1);
  3804. });
  3805. }
  3806. else {
  3807. throw err;
  3808. }
  3809. })
  3810. .then((comp) => {
  3811. if (thisRequest !== pendingRequest && pendingRequest) {
  3812. return pendingRequest;
  3813. }
  3814. if (!comp) {
  3815. warn$2(`Async component loader resolved to undefined. ` +
  3816. `If you are using retry(), make sure to return its return value.`);
  3817. }
  3818. // interop module default
  3819. if (comp &&
  3820. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3821. comp = comp.default;
  3822. }
  3823. if (comp && !isObject(comp) && !isFunction(comp)) {
  3824. throw new Error(`Invalid async component load result: ${comp}`);
  3825. }
  3826. return comp;
  3827. })));
  3828. };
  3829. return () => {
  3830. const component = load();
  3831. return {
  3832. component,
  3833. delay,
  3834. timeout,
  3835. error: errorComponent,
  3836. loading: loadingComponent
  3837. };
  3838. };
  3839. }
  3840. function createLifeCycle(hookName) {
  3841. return (fn, target = currentInstance) => {
  3842. if (!target) {
  3843. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3844. `associated with. ` +
  3845. `Lifecycle injection APIs can only be used during execution of setup().`);
  3846. return;
  3847. }
  3848. return injectHook(target, hookName, fn);
  3849. };
  3850. }
  3851. function formatName(name) {
  3852. if (name === 'beforeDestroy') {
  3853. name = 'beforeUnmount';
  3854. }
  3855. else if (name === 'destroyed') {
  3856. name = 'unmounted';
  3857. }
  3858. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3859. }
  3860. function injectHook(instance, hookName, fn) {
  3861. const options = instance.$options;
  3862. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3863. }
  3864. const onBeforeMount = createLifeCycle('beforeMount');
  3865. const onMounted = createLifeCycle('mounted');
  3866. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3867. const onUpdated = createLifeCycle('updated');
  3868. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3869. const onUnmounted = createLifeCycle('destroyed');
  3870. const onActivated = createLifeCycle('activated');
  3871. const onDeactivated = createLifeCycle('deactivated');
  3872. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3873. const onRenderTracked = createLifeCycle('renderTracked');
  3874. const onRenderTriggered = createLifeCycle('renderTriggered');
  3875. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3876. function onErrorCaptured(hook, target = currentInstance) {
  3877. injectErrorCapturedHook(hook, target);
  3878. }
  3879. /**
  3880. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3881. */
  3882. const version = '2.7.12';
  3883. /**
  3884. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3885. */
  3886. function defineComponent(options) {
  3887. return options;
  3888. }
  3889. var vca = /*#__PURE__*/Object.freeze({
  3890. __proto__: null,
  3891. version: version,
  3892. defineComponent: defineComponent,
  3893. ref: ref$1,
  3894. shallowRef: shallowRef,
  3895. isRef: isRef,
  3896. toRef: toRef,
  3897. toRefs: toRefs,
  3898. unref: unref,
  3899. proxyRefs: proxyRefs,
  3900. customRef: customRef,
  3901. triggerRef: triggerRef,
  3902. reactive: reactive,
  3903. isReactive: isReactive,
  3904. isReadonly: isReadonly,
  3905. isShallow: isShallow,
  3906. isProxy: isProxy,
  3907. shallowReactive: shallowReactive,
  3908. markRaw: markRaw,
  3909. toRaw: toRaw,
  3910. readonly: readonly,
  3911. shallowReadonly: shallowReadonly,
  3912. computed: computed,
  3913. watch: watch,
  3914. watchEffect: watchEffect,
  3915. watchPostEffect: watchPostEffect,
  3916. watchSyncEffect: watchSyncEffect,
  3917. EffectScope: EffectScope,
  3918. effectScope: effectScope,
  3919. onScopeDispose: onScopeDispose,
  3920. getCurrentScope: getCurrentScope,
  3921. provide: provide,
  3922. inject: inject,
  3923. h: h,
  3924. getCurrentInstance: getCurrentInstance,
  3925. useSlots: useSlots,
  3926. useAttrs: useAttrs,
  3927. useListeners: useListeners,
  3928. mergeDefaults: mergeDefaults,
  3929. nextTick: nextTick,
  3930. set: set,
  3931. del: del,
  3932. useCssModule: useCssModule,
  3933. useCssVars: useCssVars,
  3934. defineAsyncComponent: defineAsyncComponent,
  3935. onBeforeMount: onBeforeMount,
  3936. onMounted: onMounted,
  3937. onBeforeUpdate: onBeforeUpdate,
  3938. onUpdated: onUpdated,
  3939. onBeforeUnmount: onBeforeUnmount,
  3940. onUnmounted: onUnmounted,
  3941. onActivated: onActivated,
  3942. onDeactivated: onDeactivated,
  3943. onServerPrefetch: onServerPrefetch,
  3944. onRenderTracked: onRenderTracked,
  3945. onRenderTriggered: onRenderTriggered,
  3946. onErrorCaptured: onErrorCaptured
  3947. });
  3948. const seenObjects = new _Set();
  3949. /**
  3950. * Recursively traverse an object to evoke all converted
  3951. * getters, so that every nested property inside the object
  3952. * is collected as a "deep" dependency.
  3953. */
  3954. function traverse(val) {
  3955. _traverse(val, seenObjects);
  3956. seenObjects.clear();
  3957. return val;
  3958. }
  3959. function _traverse(val, seen) {
  3960. let i, keys;
  3961. const isA = isArray(val);
  3962. if ((!isA && !isObject(val)) ||
  3963. Object.isFrozen(val) ||
  3964. val instanceof VNode) {
  3965. return;
  3966. }
  3967. if (val.__ob__) {
  3968. const depId = val.__ob__.dep.id;
  3969. if (seen.has(depId)) {
  3970. return;
  3971. }
  3972. seen.add(depId);
  3973. }
  3974. if (isA) {
  3975. i = val.length;
  3976. while (i--)
  3977. _traverse(val[i], seen);
  3978. }
  3979. else if (isRef(val)) {
  3980. _traverse(val.value, seen);
  3981. }
  3982. else {
  3983. keys = Object.keys(val);
  3984. i = keys.length;
  3985. while (i--)
  3986. _traverse(val[keys[i]], seen);
  3987. }
  3988. }
  3989. let uid$1 = 0;
  3990. /**
  3991. * A watcher parses an expression, collects dependencies,
  3992. * and fires callback when the expression value changes.
  3993. * This is used for both the $watch() api and directives.
  3994. * @internal
  3995. */
  3996. class Watcher {
  3997. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3998. recordEffectScope(this,
  3999. // if the active effect scope is manually created (not a component scope),
  4000. // prioritize it
  4001. activeEffectScope && !activeEffectScope._vm
  4002. ? activeEffectScope
  4003. : vm
  4004. ? vm._scope
  4005. : undefined);
  4006. if ((this.vm = vm) && isRenderWatcher) {
  4007. vm._watcher = this;
  4008. }
  4009. // options
  4010. if (options) {
  4011. this.deep = !!options.deep;
  4012. this.user = !!options.user;
  4013. this.lazy = !!options.lazy;
  4014. this.sync = !!options.sync;
  4015. this.before = options.before;
  4016. {
  4017. this.onTrack = options.onTrack;
  4018. this.onTrigger = options.onTrigger;
  4019. }
  4020. }
  4021. else {
  4022. this.deep = this.user = this.lazy = this.sync = false;
  4023. }
  4024. this.cb = cb;
  4025. this.id = ++uid$1; // uid for batching
  4026. this.active = true;
  4027. this.post = false;
  4028. this.dirty = this.lazy; // for lazy watchers
  4029. this.deps = [];
  4030. this.newDeps = [];
  4031. this.depIds = new _Set();
  4032. this.newDepIds = new _Set();
  4033. this.expression = expOrFn.toString() ;
  4034. // parse expression for getter
  4035. if (isFunction(expOrFn)) {
  4036. this.getter = expOrFn;
  4037. }
  4038. else {
  4039. this.getter = parsePath(expOrFn);
  4040. if (!this.getter) {
  4041. this.getter = noop;
  4042. warn$2(`Failed watching path: "${expOrFn}" ` +
  4043. 'Watcher only accepts simple dot-delimited paths. ' +
  4044. 'For full control, use a function instead.', vm);
  4045. }
  4046. }
  4047. this.value = this.lazy ? undefined : this.get();
  4048. }
  4049. /**
  4050. * Evaluate the getter, and re-collect dependencies.
  4051. */
  4052. get() {
  4053. pushTarget(this);
  4054. let value;
  4055. const vm = this.vm;
  4056. try {
  4057. value = this.getter.call(vm, vm);
  4058. }
  4059. catch (e) {
  4060. if (this.user) {
  4061. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4062. }
  4063. else {
  4064. throw e;
  4065. }
  4066. }
  4067. finally {
  4068. // "touch" every property so they are all tracked as
  4069. // dependencies for deep watching
  4070. if (this.deep) {
  4071. traverse(value);
  4072. }
  4073. popTarget();
  4074. this.cleanupDeps();
  4075. }
  4076. return value;
  4077. }
  4078. /**
  4079. * Add a dependency to this directive.
  4080. */
  4081. addDep(dep) {
  4082. const id = dep.id;
  4083. if (!this.newDepIds.has(id)) {
  4084. this.newDepIds.add(id);
  4085. this.newDeps.push(dep);
  4086. if (!this.depIds.has(id)) {
  4087. dep.addSub(this);
  4088. }
  4089. }
  4090. }
  4091. /**
  4092. * Clean up for dependency collection.
  4093. */
  4094. cleanupDeps() {
  4095. let i = this.deps.length;
  4096. while (i--) {
  4097. const dep = this.deps[i];
  4098. if (!this.newDepIds.has(dep.id)) {
  4099. dep.removeSub(this);
  4100. }
  4101. }
  4102. let tmp = this.depIds;
  4103. this.depIds = this.newDepIds;
  4104. this.newDepIds = tmp;
  4105. this.newDepIds.clear();
  4106. tmp = this.deps;
  4107. this.deps = this.newDeps;
  4108. this.newDeps = tmp;
  4109. this.newDeps.length = 0;
  4110. }
  4111. /**
  4112. * Subscriber interface.
  4113. * Will be called when a dependency changes.
  4114. */
  4115. update() {
  4116. /* istanbul ignore else */
  4117. if (this.lazy) {
  4118. this.dirty = true;
  4119. }
  4120. else if (this.sync) {
  4121. this.run();
  4122. }
  4123. else {
  4124. queueWatcher(this);
  4125. }
  4126. }
  4127. /**
  4128. * Scheduler job interface.
  4129. * Will be called by the scheduler.
  4130. */
  4131. run() {
  4132. if (this.active) {
  4133. const value = this.get();
  4134. if (value !== this.value ||
  4135. // Deep watchers and watchers on Object/Arrays should fire even
  4136. // when the value is the same, because the value may
  4137. // have mutated.
  4138. isObject(value) ||
  4139. this.deep) {
  4140. // set new value
  4141. const oldValue = this.value;
  4142. this.value = value;
  4143. if (this.user) {
  4144. const info = `callback for watcher "${this.expression}"`;
  4145. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4146. }
  4147. else {
  4148. this.cb.call(this.vm, value, oldValue);
  4149. }
  4150. }
  4151. }
  4152. }
  4153. /**
  4154. * Evaluate the value of the watcher.
  4155. * This only gets called for lazy watchers.
  4156. */
  4157. evaluate() {
  4158. this.value = this.get();
  4159. this.dirty = false;
  4160. }
  4161. /**
  4162. * Depend on all deps collected by this watcher.
  4163. */
  4164. depend() {
  4165. let i = this.deps.length;
  4166. while (i--) {
  4167. this.deps[i].depend();
  4168. }
  4169. }
  4170. /**
  4171. * Remove self from all dependencies' subscriber list.
  4172. */
  4173. teardown() {
  4174. if (this.vm && !this.vm._isBeingDestroyed) {
  4175. remove$2(this.vm._scope.effects, this);
  4176. }
  4177. if (this.active) {
  4178. let i = this.deps.length;
  4179. while (i--) {
  4180. this.deps[i].removeSub(this);
  4181. }
  4182. this.active = false;
  4183. if (this.onStop) {
  4184. this.onStop();
  4185. }
  4186. }
  4187. }
  4188. }
  4189. const sharedPropertyDefinition = {
  4190. enumerable: true,
  4191. configurable: true,
  4192. get: noop,
  4193. set: noop
  4194. };
  4195. function proxy(target, sourceKey, key) {
  4196. sharedPropertyDefinition.get = function proxyGetter() {
  4197. return this[sourceKey][key];
  4198. };
  4199. sharedPropertyDefinition.set = function proxySetter(val) {
  4200. this[sourceKey][key] = val;
  4201. };
  4202. Object.defineProperty(target, key, sharedPropertyDefinition);
  4203. }
  4204. function initState(vm) {
  4205. const opts = vm.$options;
  4206. if (opts.props)
  4207. initProps$1(vm, opts.props);
  4208. // Composition API
  4209. initSetup(vm);
  4210. if (opts.methods)
  4211. initMethods(vm, opts.methods);
  4212. if (opts.data) {
  4213. initData(vm);
  4214. }
  4215. else {
  4216. const ob = observe((vm._data = {}));
  4217. ob && ob.vmCount++;
  4218. }
  4219. if (opts.computed)
  4220. initComputed$1(vm, opts.computed);
  4221. if (opts.watch && opts.watch !== nativeWatch) {
  4222. initWatch(vm, opts.watch);
  4223. }
  4224. }
  4225. function initProps$1(vm, propsOptions) {
  4226. const propsData = vm.$options.propsData || {};
  4227. const props = (vm._props = shallowReactive({}));
  4228. // cache prop keys so that future props updates can iterate using Array
  4229. // instead of dynamic object key enumeration.
  4230. const keys = (vm.$options._propKeys = []);
  4231. const isRoot = !vm.$parent;
  4232. // root instance props should be converted
  4233. if (!isRoot) {
  4234. toggleObserving(false);
  4235. }
  4236. for (const key in propsOptions) {
  4237. keys.push(key);
  4238. const value = validateProp(key, propsOptions, propsData, vm);
  4239. /* istanbul ignore else */
  4240. {
  4241. const hyphenatedKey = hyphenate(key);
  4242. if (isReservedAttribute(hyphenatedKey) ||
  4243. config.isReservedAttr(hyphenatedKey)) {
  4244. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4245. }
  4246. defineReactive(props, key, value, () => {
  4247. if (!isRoot && !isUpdatingChildComponent) {
  4248. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4249. `overwritten whenever the parent component re-renders. ` +
  4250. `Instead, use a data or computed property based on the prop's ` +
  4251. `value. Prop being mutated: "${key}"`, vm);
  4252. }
  4253. });
  4254. }
  4255. // static props are already proxied on the component's prototype
  4256. // during Vue.extend(). We only need to proxy props defined at
  4257. // instantiation here.
  4258. if (!(key in vm)) {
  4259. proxy(vm, `_props`, key);
  4260. }
  4261. }
  4262. toggleObserving(true);
  4263. }
  4264. function initData(vm) {
  4265. let data = vm.$options.data;
  4266. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4267. if (!isPlainObject(data)) {
  4268. data = {};
  4269. warn$2('data functions should return an object:\n' +
  4270. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4271. }
  4272. // proxy data on instance
  4273. const keys = Object.keys(data);
  4274. const props = vm.$options.props;
  4275. const methods = vm.$options.methods;
  4276. let i = keys.length;
  4277. while (i--) {
  4278. const key = keys[i];
  4279. {
  4280. if (methods && hasOwn(methods, key)) {
  4281. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4282. }
  4283. }
  4284. if (props && hasOwn(props, key)) {
  4285. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4286. `Use prop default value instead.`, vm);
  4287. }
  4288. else if (!isReserved(key)) {
  4289. proxy(vm, `_data`, key);
  4290. }
  4291. }
  4292. // observe data
  4293. const ob = observe(data);
  4294. ob && ob.vmCount++;
  4295. }
  4296. function getData(data, vm) {
  4297. // #7573 disable dep collection when invoking data getters
  4298. pushTarget();
  4299. try {
  4300. return data.call(vm, vm);
  4301. }
  4302. catch (e) {
  4303. handleError(e, vm, `data()`);
  4304. return {};
  4305. }
  4306. finally {
  4307. popTarget();
  4308. }
  4309. }
  4310. const computedWatcherOptions = { lazy: true };
  4311. function initComputed$1(vm, computed) {
  4312. // $flow-disable-line
  4313. const watchers = (vm._computedWatchers = Object.create(null));
  4314. // computed properties are just getters during SSR
  4315. const isSSR = isServerRendering();
  4316. for (const key in computed) {
  4317. const userDef = computed[key];
  4318. const getter = isFunction(userDef) ? userDef : userDef.get;
  4319. if (getter == null) {
  4320. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4321. }
  4322. if (!isSSR) {
  4323. // create internal watcher for the computed property.
  4324. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4325. }
  4326. // component-defined computed properties are already defined on the
  4327. // component prototype. We only need to define computed properties defined
  4328. // at instantiation here.
  4329. if (!(key in vm)) {
  4330. defineComputed(vm, key, userDef);
  4331. }
  4332. else {
  4333. if (key in vm.$data) {
  4334. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4335. }
  4336. else if (vm.$options.props && key in vm.$options.props) {
  4337. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4338. }
  4339. else if (vm.$options.methods && key in vm.$options.methods) {
  4340. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4341. }
  4342. }
  4343. }
  4344. }
  4345. function defineComputed(target, key, userDef) {
  4346. const shouldCache = !isServerRendering();
  4347. if (isFunction(userDef)) {
  4348. sharedPropertyDefinition.get = shouldCache
  4349. ? createComputedGetter(key)
  4350. : createGetterInvoker(userDef);
  4351. sharedPropertyDefinition.set = noop;
  4352. }
  4353. else {
  4354. sharedPropertyDefinition.get = userDef.get
  4355. ? shouldCache && userDef.cache !== false
  4356. ? createComputedGetter(key)
  4357. : createGetterInvoker(userDef.get)
  4358. : noop;
  4359. sharedPropertyDefinition.set = userDef.set || noop;
  4360. }
  4361. if (sharedPropertyDefinition.set === noop) {
  4362. sharedPropertyDefinition.set = function () {
  4363. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4364. };
  4365. }
  4366. Object.defineProperty(target, key, sharedPropertyDefinition);
  4367. }
  4368. function createComputedGetter(key) {
  4369. return function computedGetter() {
  4370. const watcher = this._computedWatchers && this._computedWatchers[key];
  4371. if (watcher) {
  4372. if (watcher.dirty) {
  4373. watcher.evaluate();
  4374. }
  4375. if (Dep.target) {
  4376. if (Dep.target.onTrack) {
  4377. Dep.target.onTrack({
  4378. effect: Dep.target,
  4379. target: this,
  4380. type: "get" /* TrackOpTypes.GET */,
  4381. key
  4382. });
  4383. }
  4384. watcher.depend();
  4385. }
  4386. return watcher.value;
  4387. }
  4388. };
  4389. }
  4390. function createGetterInvoker(fn) {
  4391. return function computedGetter() {
  4392. return fn.call(this, this);
  4393. };
  4394. }
  4395. function initMethods(vm, methods) {
  4396. const props = vm.$options.props;
  4397. for (const key in methods) {
  4398. {
  4399. if (typeof methods[key] !== 'function') {
  4400. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4401. `Did you reference the function correctly?`, vm);
  4402. }
  4403. if (props && hasOwn(props, key)) {
  4404. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4405. }
  4406. if (key in vm && isReserved(key)) {
  4407. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4408. `Avoid defining component methods that start with _ or $.`);
  4409. }
  4410. }
  4411. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4412. }
  4413. }
  4414. function initWatch(vm, watch) {
  4415. for (const key in watch) {
  4416. const handler = watch[key];
  4417. if (isArray(handler)) {
  4418. for (let i = 0; i < handler.length; i++) {
  4419. createWatcher(vm, key, handler[i]);
  4420. }
  4421. }
  4422. else {
  4423. createWatcher(vm, key, handler);
  4424. }
  4425. }
  4426. }
  4427. function createWatcher(vm, expOrFn, handler, options) {
  4428. if (isPlainObject(handler)) {
  4429. options = handler;
  4430. handler = handler.handler;
  4431. }
  4432. if (typeof handler === 'string') {
  4433. handler = vm[handler];
  4434. }
  4435. return vm.$watch(expOrFn, handler, options);
  4436. }
  4437. function stateMixin(Vue) {
  4438. // flow somehow has problems with directly declared definition object
  4439. // when using Object.defineProperty, so we have to procedurally build up
  4440. // the object here.
  4441. const dataDef = {};
  4442. dataDef.get = function () {
  4443. return this._data;
  4444. };
  4445. const propsDef = {};
  4446. propsDef.get = function () {
  4447. return this._props;
  4448. };
  4449. {
  4450. dataDef.set = function () {
  4451. warn$2('Avoid replacing instance root $data. ' +
  4452. 'Use nested data properties instead.', this);
  4453. };
  4454. propsDef.set = function () {
  4455. warn$2(`$props is readonly.`, this);
  4456. };
  4457. }
  4458. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4459. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4460. Vue.prototype.$set = set;
  4461. Vue.prototype.$delete = del;
  4462. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4463. const vm = this;
  4464. if (isPlainObject(cb)) {
  4465. return createWatcher(vm, expOrFn, cb, options);
  4466. }
  4467. options = options || {};
  4468. options.user = true;
  4469. const watcher = new Watcher(vm, expOrFn, cb, options);
  4470. if (options.immediate) {
  4471. const info = `callback for immediate watcher "${watcher.expression}"`;
  4472. pushTarget();
  4473. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4474. popTarget();
  4475. }
  4476. return function unwatchFn() {
  4477. watcher.teardown();
  4478. };
  4479. };
  4480. }
  4481. function initProvide(vm) {
  4482. const provideOption = vm.$options.provide;
  4483. if (provideOption) {
  4484. const provided = isFunction(provideOption)
  4485. ? provideOption.call(vm)
  4486. : provideOption;
  4487. if (!isObject(provided)) {
  4488. return;
  4489. }
  4490. const source = resolveProvided(vm);
  4491. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4492. // iterate the keys ourselves.
  4493. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4494. for (let i = 0; i < keys.length; i++) {
  4495. const key = keys[i];
  4496. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4497. }
  4498. }
  4499. }
  4500. function initInjections(vm) {
  4501. const result = resolveInject(vm.$options.inject, vm);
  4502. if (result) {
  4503. toggleObserving(false);
  4504. Object.keys(result).forEach(key => {
  4505. /* istanbul ignore else */
  4506. {
  4507. defineReactive(vm, key, result[key], () => {
  4508. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4509. `overwritten whenever the provided component re-renders. ` +
  4510. `injection being mutated: "${key}"`, vm);
  4511. });
  4512. }
  4513. });
  4514. toggleObserving(true);
  4515. }
  4516. }
  4517. function resolveInject(inject, vm) {
  4518. if (inject) {
  4519. // inject is :any because flow is not smart enough to figure out cached
  4520. const result = Object.create(null);
  4521. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4522. for (let i = 0; i < keys.length; i++) {
  4523. const key = keys[i];
  4524. // #6574 in case the inject object is observed...
  4525. if (key === '__ob__')
  4526. continue;
  4527. const provideKey = inject[key].from;
  4528. if (provideKey in vm._provided) {
  4529. result[key] = vm._provided[provideKey];
  4530. }
  4531. else if ('default' in inject[key]) {
  4532. const provideDefault = inject[key].default;
  4533. result[key] = isFunction(provideDefault)
  4534. ? provideDefault.call(vm)
  4535. : provideDefault;
  4536. }
  4537. else {
  4538. warn$2(`Injection "${key}" not found`, vm);
  4539. }
  4540. }
  4541. return result;
  4542. }
  4543. }
  4544. let uid = 0;
  4545. function initMixin$1(Vue) {
  4546. Vue.prototype._init = function (options) {
  4547. const vm = this;
  4548. // a uid
  4549. vm._uid = uid++;
  4550. let startTag, endTag;
  4551. /* istanbul ignore if */
  4552. if (config.performance && mark) {
  4553. startTag = `vue-perf-start:${vm._uid}`;
  4554. endTag = `vue-perf-end:${vm._uid}`;
  4555. mark(startTag);
  4556. }
  4557. // a flag to mark this as a Vue instance without having to do instanceof
  4558. // check
  4559. vm._isVue = true;
  4560. // avoid instances from being observed
  4561. vm.__v_skip = true;
  4562. // effect scope
  4563. vm._scope = new EffectScope(true /* detached */);
  4564. vm._scope._vm = true;
  4565. // merge options
  4566. if (options && options._isComponent) {
  4567. // optimize internal component instantiation
  4568. // since dynamic options merging is pretty slow, and none of the
  4569. // internal component options needs special treatment.
  4570. initInternalComponent(vm, options);
  4571. }
  4572. else {
  4573. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4574. }
  4575. /* istanbul ignore else */
  4576. {
  4577. initProxy(vm);
  4578. }
  4579. // expose real self
  4580. vm._self = vm;
  4581. initLifecycle(vm);
  4582. initEvents(vm);
  4583. initRender(vm);
  4584. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4585. initInjections(vm); // resolve injections before data/props
  4586. initState(vm);
  4587. initProvide(vm); // resolve provide after data/props
  4588. callHook$1(vm, 'created');
  4589. /* istanbul ignore if */
  4590. if (config.performance && mark) {
  4591. vm._name = formatComponentName(vm, false);
  4592. mark(endTag);
  4593. measure(`vue ${vm._name} init`, startTag, endTag);
  4594. }
  4595. if (vm.$options.el) {
  4596. vm.$mount(vm.$options.el);
  4597. }
  4598. };
  4599. }
  4600. function initInternalComponent(vm, options) {
  4601. const opts = (vm.$options = Object.create(vm.constructor.options));
  4602. // doing this because it's faster than dynamic enumeration.
  4603. const parentVnode = options._parentVnode;
  4604. opts.parent = options.parent;
  4605. opts._parentVnode = parentVnode;
  4606. const vnodeComponentOptions = parentVnode.componentOptions;
  4607. opts.propsData = vnodeComponentOptions.propsData;
  4608. opts._parentListeners = vnodeComponentOptions.listeners;
  4609. opts._renderChildren = vnodeComponentOptions.children;
  4610. opts._componentTag = vnodeComponentOptions.tag;
  4611. if (options.render) {
  4612. opts.render = options.render;
  4613. opts.staticRenderFns = options.staticRenderFns;
  4614. }
  4615. }
  4616. function resolveConstructorOptions(Ctor) {
  4617. let options = Ctor.options;
  4618. if (Ctor.super) {
  4619. const superOptions = resolveConstructorOptions(Ctor.super);
  4620. const cachedSuperOptions = Ctor.superOptions;
  4621. if (superOptions !== cachedSuperOptions) {
  4622. // super option changed,
  4623. // need to resolve new options.
  4624. Ctor.superOptions = superOptions;
  4625. // check if there are any late-modified/attached options (#4976)
  4626. const modifiedOptions = resolveModifiedOptions(Ctor);
  4627. // update base extend options
  4628. if (modifiedOptions) {
  4629. extend(Ctor.extendOptions, modifiedOptions);
  4630. }
  4631. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4632. if (options.name) {
  4633. options.components[options.name] = Ctor;
  4634. }
  4635. }
  4636. }
  4637. return options;
  4638. }
  4639. function resolveModifiedOptions(Ctor) {
  4640. let modified;
  4641. const latest = Ctor.options;
  4642. const sealed = Ctor.sealedOptions;
  4643. for (const key in latest) {
  4644. if (latest[key] !== sealed[key]) {
  4645. if (!modified)
  4646. modified = {};
  4647. modified[key] = latest[key];
  4648. }
  4649. }
  4650. return modified;
  4651. }
  4652. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4653. const options = Ctor.options;
  4654. // ensure the createElement function in functional components
  4655. // gets a unique context - this is necessary for correct named slot check
  4656. let contextVm;
  4657. if (hasOwn(parent, '_uid')) {
  4658. contextVm = Object.create(parent);
  4659. contextVm._original = parent;
  4660. }
  4661. else {
  4662. // the context vm passed in is a functional context as well.
  4663. // in this case we want to make sure we are able to get a hold to the
  4664. // real context instance.
  4665. contextVm = parent;
  4666. // @ts-ignore
  4667. parent = parent._original;
  4668. }
  4669. const isCompiled = isTrue(options._compiled);
  4670. const needNormalization = !isCompiled;
  4671. this.data = data;
  4672. this.props = props;
  4673. this.children = children;
  4674. this.parent = parent;
  4675. this.listeners = data.on || emptyObject;
  4676. this.injections = resolveInject(options.inject, parent);
  4677. this.slots = () => {
  4678. if (!this.$slots) {
  4679. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4680. }
  4681. return this.$slots;
  4682. };
  4683. Object.defineProperty(this, 'scopedSlots', {
  4684. enumerable: true,
  4685. get() {
  4686. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4687. }
  4688. });
  4689. // support for compiled functional template
  4690. if (isCompiled) {
  4691. // exposing $options for renderStatic()
  4692. this.$options = options;
  4693. // pre-resolve slots for renderSlot()
  4694. this.$slots = this.slots();
  4695. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4696. }
  4697. if (options._scopeId) {
  4698. this._c = (a, b, c, d) => {
  4699. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4700. if (vnode && !isArray(vnode)) {
  4701. vnode.fnScopeId = options._scopeId;
  4702. vnode.fnContext = parent;
  4703. }
  4704. return vnode;
  4705. };
  4706. }
  4707. else {
  4708. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4709. }
  4710. }
  4711. installRenderHelpers(FunctionalRenderContext.prototype);
  4712. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4713. const options = Ctor.options;
  4714. const props = {};
  4715. const propOptions = options.props;
  4716. if (isDef(propOptions)) {
  4717. for (const key in propOptions) {
  4718. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4719. }
  4720. }
  4721. else {
  4722. if (isDef(data.attrs))
  4723. mergeProps(props, data.attrs);
  4724. if (isDef(data.props))
  4725. mergeProps(props, data.props);
  4726. }
  4727. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4728. const vnode = options.render.call(null, renderContext._c, renderContext);
  4729. if (vnode instanceof VNode) {
  4730. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4731. }
  4732. else if (isArray(vnode)) {
  4733. const vnodes = normalizeChildren(vnode) || [];
  4734. const res = new Array(vnodes.length);
  4735. for (let i = 0; i < vnodes.length; i++) {
  4736. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4737. }
  4738. return res;
  4739. }
  4740. }
  4741. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4742. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4743. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4744. // that should not be matched to match.
  4745. const clone = cloneVNode(vnode);
  4746. clone.fnContext = contextVm;
  4747. clone.fnOptions = options;
  4748. {
  4749. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4750. renderContext;
  4751. }
  4752. if (data.slot) {
  4753. (clone.data || (clone.data = {})).slot = data.slot;
  4754. }
  4755. return clone;
  4756. }
  4757. function mergeProps(to, from) {
  4758. for (const key in from) {
  4759. to[camelize(key)] = from[key];
  4760. }
  4761. }
  4762. function getComponentName(options) {
  4763. return options.name || options.__name || options._componentTag;
  4764. }
  4765. // inline hooks to be invoked on component VNodes during patch
  4766. const componentVNodeHooks = {
  4767. init(vnode, hydrating) {
  4768. if (vnode.componentInstance &&
  4769. !vnode.componentInstance._isDestroyed &&
  4770. vnode.data.keepAlive) {
  4771. // kept-alive components, treat as a patch
  4772. const mountedNode = vnode; // work around flow
  4773. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4774. }
  4775. else {
  4776. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4777. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4778. }
  4779. },
  4780. prepatch(oldVnode, vnode) {
  4781. const options = vnode.componentOptions;
  4782. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4783. updateChildComponent(child, options.propsData, // updated props
  4784. options.listeners, // updated listeners
  4785. vnode, // new parent vnode
  4786. options.children // new children
  4787. );
  4788. },
  4789. insert(vnode) {
  4790. const { context, componentInstance } = vnode;
  4791. if (!componentInstance._isMounted) {
  4792. componentInstance._isMounted = true;
  4793. callHook$1(componentInstance, 'mounted');
  4794. }
  4795. if (vnode.data.keepAlive) {
  4796. if (context._isMounted) {
  4797. // vue-router#1212
  4798. // During updates, a kept-alive component's child components may
  4799. // change, so directly walking the tree here may call activated hooks
  4800. // on incorrect children. Instead we push them into a queue which will
  4801. // be processed after the whole patch process ended.
  4802. queueActivatedComponent(componentInstance);
  4803. }
  4804. else {
  4805. activateChildComponent(componentInstance, true /* direct */);
  4806. }
  4807. }
  4808. },
  4809. destroy(vnode) {
  4810. const { componentInstance } = vnode;
  4811. if (!componentInstance._isDestroyed) {
  4812. if (!vnode.data.keepAlive) {
  4813. componentInstance.$destroy();
  4814. }
  4815. else {
  4816. deactivateChildComponent(componentInstance, true /* direct */);
  4817. }
  4818. }
  4819. }
  4820. };
  4821. const hooksToMerge = Object.keys(componentVNodeHooks);
  4822. function createComponent(Ctor, data, context, children, tag) {
  4823. if (isUndef(Ctor)) {
  4824. return;
  4825. }
  4826. const baseCtor = context.$options._base;
  4827. // plain options object: turn it into a constructor
  4828. if (isObject(Ctor)) {
  4829. Ctor = baseCtor.extend(Ctor);
  4830. }
  4831. // if at this stage it's not a constructor or an async component factory,
  4832. // reject.
  4833. if (typeof Ctor !== 'function') {
  4834. {
  4835. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4836. }
  4837. return;
  4838. }
  4839. // async component
  4840. let asyncFactory;
  4841. // @ts-expect-error
  4842. if (isUndef(Ctor.cid)) {
  4843. asyncFactory = Ctor;
  4844. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4845. if (Ctor === undefined) {
  4846. // return a placeholder node for async component, which is rendered
  4847. // as a comment node but preserves all the raw information for the node.
  4848. // the information will be used for async server-rendering and hydration.
  4849. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4850. }
  4851. }
  4852. data = data || {};
  4853. // resolve constructor options in case global mixins are applied after
  4854. // component constructor creation
  4855. resolveConstructorOptions(Ctor);
  4856. // transform component v-model data into props & events
  4857. if (isDef(data.model)) {
  4858. // @ts-expect-error
  4859. transformModel(Ctor.options, data);
  4860. }
  4861. // extract props
  4862. // @ts-expect-error
  4863. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4864. // functional component
  4865. // @ts-expect-error
  4866. if (isTrue(Ctor.options.functional)) {
  4867. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4868. }
  4869. // extract listeners, since these needs to be treated as
  4870. // child component listeners instead of DOM listeners
  4871. const listeners = data.on;
  4872. // replace with listeners with .native modifier
  4873. // so it gets processed during parent component patch.
  4874. data.on = data.nativeOn;
  4875. // @ts-expect-error
  4876. if (isTrue(Ctor.options.abstract)) {
  4877. // abstract components do not keep anything
  4878. // other than props & listeners & slot
  4879. // work around flow
  4880. const slot = data.slot;
  4881. data = {};
  4882. if (slot) {
  4883. data.slot = slot;
  4884. }
  4885. }
  4886. // install component management hooks onto the placeholder node
  4887. installComponentHooks(data);
  4888. // return a placeholder vnode
  4889. // @ts-expect-error
  4890. const name = getComponentName(Ctor.options) || tag;
  4891. const vnode = new VNode(
  4892. // @ts-expect-error
  4893. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4894. // @ts-expect-error
  4895. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4896. return vnode;
  4897. }
  4898. function createComponentInstanceForVnode(
  4899. // we know it's MountedComponentVNode but flow doesn't
  4900. vnode,
  4901. // activeInstance in lifecycle state
  4902. parent) {
  4903. const options = {
  4904. _isComponent: true,
  4905. _parentVnode: vnode,
  4906. parent
  4907. };
  4908. // check inline-template render functions
  4909. const inlineTemplate = vnode.data.inlineTemplate;
  4910. if (isDef(inlineTemplate)) {
  4911. options.render = inlineTemplate.render;
  4912. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4913. }
  4914. return new vnode.componentOptions.Ctor(options);
  4915. }
  4916. function installComponentHooks(data) {
  4917. const hooks = data.hook || (data.hook = {});
  4918. for (let i = 0; i < hooksToMerge.length; i++) {
  4919. const key = hooksToMerge[i];
  4920. const existing = hooks[key];
  4921. const toMerge = componentVNodeHooks[key];
  4922. // @ts-expect-error
  4923. if (existing !== toMerge && !(existing && existing._merged)) {
  4924. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4925. }
  4926. }
  4927. }
  4928. function mergeHook(f1, f2) {
  4929. const merged = (a, b) => {
  4930. // flow complains about extra args which is why we use any
  4931. f1(a, b);
  4932. f2(a, b);
  4933. };
  4934. merged._merged = true;
  4935. return merged;
  4936. }
  4937. // transform component v-model info (value and callback) into
  4938. // prop and event handler respectively.
  4939. function transformModel(options, data) {
  4940. const prop = (options.model && options.model.prop) || 'value';
  4941. const event = (options.model && options.model.event) || 'input';
  4942. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4943. const on = data.on || (data.on = {});
  4944. const existing = on[event];
  4945. const callback = data.model.callback;
  4946. if (isDef(existing)) {
  4947. if (isArray(existing)
  4948. ? existing.indexOf(callback) === -1
  4949. : existing !== callback) {
  4950. on[event] = [callback].concat(existing);
  4951. }
  4952. }
  4953. else {
  4954. on[event] = callback;
  4955. }
  4956. }
  4957. let warn$2 = noop;
  4958. let tip = noop;
  4959. let generateComponentTrace; // work around flow check
  4960. let formatComponentName;
  4961. {
  4962. const hasConsole = typeof console !== 'undefined';
  4963. const classifyRE = /(?:^|[-_])(\w)/g;
  4964. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4965. warn$2 = (msg, vm = currentInstance) => {
  4966. const trace = vm ? generateComponentTrace(vm) : '';
  4967. if (config.warnHandler) {
  4968. config.warnHandler.call(null, msg, vm, trace);
  4969. }
  4970. else if (hasConsole && !config.silent) {
  4971. console.error(`[Vue warn]: ${msg}${trace}`);
  4972. }
  4973. };
  4974. tip = (msg, vm) => {
  4975. if (hasConsole && !config.silent) {
  4976. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4977. }
  4978. };
  4979. formatComponentName = (vm, includeFile) => {
  4980. if (vm.$root === vm) {
  4981. return '<Root>';
  4982. }
  4983. const options = isFunction(vm) && vm.cid != null
  4984. ? vm.options
  4985. : vm._isVue
  4986. ? vm.$options || vm.constructor.options
  4987. : vm;
  4988. let name = getComponentName(options);
  4989. const file = options.__file;
  4990. if (!name && file) {
  4991. const match = file.match(/([^/\\]+)\.vue$/);
  4992. name = match && match[1];
  4993. }
  4994. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4995. (file && includeFile !== false ? ` at ${file}` : ''));
  4996. };
  4997. const repeat = (str, n) => {
  4998. let res = '';
  4999. while (n) {
  5000. if (n % 2 === 1)
  5001. res += str;
  5002. if (n > 1)
  5003. str += str;
  5004. n >>= 1;
  5005. }
  5006. return res;
  5007. };
  5008. generateComponentTrace = (vm) => {
  5009. if (vm._isVue && vm.$parent) {
  5010. const tree = [];
  5011. let currentRecursiveSequence = 0;
  5012. while (vm) {
  5013. if (tree.length > 0) {
  5014. const last = tree[tree.length - 1];
  5015. if (last.constructor === vm.constructor) {
  5016. currentRecursiveSequence++;
  5017. vm = vm.$parent;
  5018. continue;
  5019. }
  5020. else if (currentRecursiveSequence > 0) {
  5021. tree[tree.length - 1] = [last, currentRecursiveSequence];
  5022. currentRecursiveSequence = 0;
  5023. }
  5024. }
  5025. tree.push(vm);
  5026. vm = vm.$parent;
  5027. }
  5028. return ('\n\nfound in\n\n' +
  5029. tree
  5030. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  5031. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  5032. : formatComponentName(vm)}`)
  5033. .join('\n'));
  5034. }
  5035. else {
  5036. return `\n\n(found in ${formatComponentName(vm)})`;
  5037. }
  5038. };
  5039. }
  5040. /**
  5041. * Option overwriting strategies are functions that handle
  5042. * how to merge a parent option value and a child option
  5043. * value into the final value.
  5044. */
  5045. const strats = config.optionMergeStrategies;
  5046. /**
  5047. * Options with restrictions
  5048. */
  5049. {
  5050. strats.el = strats.propsData = function (parent, child, vm, key) {
  5051. if (!vm) {
  5052. warn$2(`option "${key}" can only be used during instance ` +
  5053. 'creation with the `new` keyword.');
  5054. }
  5055. return defaultStrat(parent, child);
  5056. };
  5057. }
  5058. /**
  5059. * Helper that recursively merges two data objects together.
  5060. */
  5061. function mergeData(to, from) {
  5062. if (!from)
  5063. return to;
  5064. let key, toVal, fromVal;
  5065. const keys = hasSymbol
  5066. ? Reflect.ownKeys(from)
  5067. : Object.keys(from);
  5068. for (let i = 0; i < keys.length; i++) {
  5069. key = keys[i];
  5070. // in case the object is already observed...
  5071. if (key === '__ob__')
  5072. continue;
  5073. toVal = to[key];
  5074. fromVal = from[key];
  5075. if (!hasOwn(to, key)) {
  5076. set(to, key, fromVal);
  5077. }
  5078. else if (toVal !== fromVal &&
  5079. isPlainObject(toVal) &&
  5080. isPlainObject(fromVal)) {
  5081. mergeData(toVal, fromVal);
  5082. }
  5083. }
  5084. return to;
  5085. }
  5086. /**
  5087. * Data
  5088. */
  5089. function mergeDataOrFn(parentVal, childVal, vm) {
  5090. if (!vm) {
  5091. // in a Vue.extend merge, both should be functions
  5092. if (!childVal) {
  5093. return parentVal;
  5094. }
  5095. if (!parentVal) {
  5096. return childVal;
  5097. }
  5098. // when parentVal & childVal are both present,
  5099. // we need to return a function that returns the
  5100. // merged result of both functions... no need to
  5101. // check if parentVal is a function here because
  5102. // it has to be a function to pass previous merges.
  5103. return function mergedDataFn() {
  5104. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5105. };
  5106. }
  5107. else {
  5108. return function mergedInstanceDataFn() {
  5109. // instance merge
  5110. const instanceData = isFunction(childVal)
  5111. ? childVal.call(vm, vm)
  5112. : childVal;
  5113. const defaultData = isFunction(parentVal)
  5114. ? parentVal.call(vm, vm)
  5115. : parentVal;
  5116. if (instanceData) {
  5117. return mergeData(instanceData, defaultData);
  5118. }
  5119. else {
  5120. return defaultData;
  5121. }
  5122. };
  5123. }
  5124. }
  5125. strats.data = function (parentVal, childVal, vm) {
  5126. if (!vm) {
  5127. if (childVal && typeof childVal !== 'function') {
  5128. warn$2('The "data" option should be a function ' +
  5129. 'that returns a per-instance value in component ' +
  5130. 'definitions.', vm);
  5131. return parentVal;
  5132. }
  5133. return mergeDataOrFn(parentVal, childVal);
  5134. }
  5135. return mergeDataOrFn(parentVal, childVal, vm);
  5136. };
  5137. /**
  5138. * Hooks and props are merged as arrays.
  5139. */
  5140. function mergeLifecycleHook(parentVal, childVal) {
  5141. const res = childVal
  5142. ? parentVal
  5143. ? parentVal.concat(childVal)
  5144. : isArray(childVal)
  5145. ? childVal
  5146. : [childVal]
  5147. : parentVal;
  5148. return res ? dedupeHooks(res) : res;
  5149. }
  5150. function dedupeHooks(hooks) {
  5151. const res = [];
  5152. for (let i = 0; i < hooks.length; i++) {
  5153. if (res.indexOf(hooks[i]) === -1) {
  5154. res.push(hooks[i]);
  5155. }
  5156. }
  5157. return res;
  5158. }
  5159. LIFECYCLE_HOOKS.forEach(hook => {
  5160. strats[hook] = mergeLifecycleHook;
  5161. });
  5162. /**
  5163. * Assets
  5164. *
  5165. * When a vm is present (instance creation), we need to do
  5166. * a three-way merge between constructor options, instance
  5167. * options and parent options.
  5168. */
  5169. function mergeAssets(parentVal, childVal, vm, key) {
  5170. const res = Object.create(parentVal || null);
  5171. if (childVal) {
  5172. assertObjectType(key, childVal, vm);
  5173. return extend(res, childVal);
  5174. }
  5175. else {
  5176. return res;
  5177. }
  5178. }
  5179. ASSET_TYPES.forEach(function (type) {
  5180. strats[type + 's'] = mergeAssets;
  5181. });
  5182. /**
  5183. * Watchers.
  5184. *
  5185. * Watchers hashes should not overwrite one
  5186. * another, so we merge them as arrays.
  5187. */
  5188. strats.watch = function (parentVal, childVal, vm, key) {
  5189. // work around Firefox's Object.prototype.watch...
  5190. //@ts-expect-error work around
  5191. if (parentVal === nativeWatch)
  5192. parentVal = undefined;
  5193. //@ts-expect-error work around
  5194. if (childVal === nativeWatch)
  5195. childVal = undefined;
  5196. /* istanbul ignore if */
  5197. if (!childVal)
  5198. return Object.create(parentVal || null);
  5199. {
  5200. assertObjectType(key, childVal, vm);
  5201. }
  5202. if (!parentVal)
  5203. return childVal;
  5204. const ret = {};
  5205. extend(ret, parentVal);
  5206. for (const key in childVal) {
  5207. let parent = ret[key];
  5208. const child = childVal[key];
  5209. if (parent && !isArray(parent)) {
  5210. parent = [parent];
  5211. }
  5212. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5213. }
  5214. return ret;
  5215. };
  5216. /**
  5217. * Other object hashes.
  5218. */
  5219. strats.props =
  5220. strats.methods =
  5221. strats.inject =
  5222. strats.computed =
  5223. function (parentVal, childVal, vm, key) {
  5224. if (childVal && true) {
  5225. assertObjectType(key, childVal, vm);
  5226. }
  5227. if (!parentVal)
  5228. return childVal;
  5229. const ret = Object.create(null);
  5230. extend(ret, parentVal);
  5231. if (childVal)
  5232. extend(ret, childVal);
  5233. return ret;
  5234. };
  5235. strats.provide = mergeDataOrFn;
  5236. /**
  5237. * Default strategy.
  5238. */
  5239. const defaultStrat = function (parentVal, childVal) {
  5240. return childVal === undefined ? parentVal : childVal;
  5241. };
  5242. /**
  5243. * Validate component names
  5244. */
  5245. function checkComponents(options) {
  5246. for (const key in options.components) {
  5247. validateComponentName(key);
  5248. }
  5249. }
  5250. function validateComponentName(name) {
  5251. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5252. warn$2('Invalid component name: "' +
  5253. name +
  5254. '". Component names ' +
  5255. 'should conform to valid custom element name in html5 specification.');
  5256. }
  5257. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5258. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5259. 'id: ' +
  5260. name);
  5261. }
  5262. }
  5263. /**
  5264. * Ensure all props option syntax are normalized into the
  5265. * Object-based format.
  5266. */
  5267. function normalizeProps(options, vm) {
  5268. const props = options.props;
  5269. if (!props)
  5270. return;
  5271. const res = {};
  5272. let i, val, name;
  5273. if (isArray(props)) {
  5274. i = props.length;
  5275. while (i--) {
  5276. val = props[i];
  5277. if (typeof val === 'string') {
  5278. name = camelize(val);
  5279. res[name] = { type: null };
  5280. }
  5281. else {
  5282. warn$2('props must be strings when using array syntax.');
  5283. }
  5284. }
  5285. }
  5286. else if (isPlainObject(props)) {
  5287. for (const key in props) {
  5288. val = props[key];
  5289. name = camelize(key);
  5290. res[name] = isPlainObject(val) ? val : { type: val };
  5291. }
  5292. }
  5293. else {
  5294. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5295. `but got ${toRawType(props)}.`, vm);
  5296. }
  5297. options.props = res;
  5298. }
  5299. /**
  5300. * Normalize all injections into Object-based format
  5301. */
  5302. function normalizeInject(options, vm) {
  5303. const inject = options.inject;
  5304. if (!inject)
  5305. return;
  5306. const normalized = (options.inject = {});
  5307. if (isArray(inject)) {
  5308. for (let i = 0; i < inject.length; i++) {
  5309. normalized[inject[i]] = { from: inject[i] };
  5310. }
  5311. }
  5312. else if (isPlainObject(inject)) {
  5313. for (const key in inject) {
  5314. const val = inject[key];
  5315. normalized[key] = isPlainObject(val)
  5316. ? extend({ from: key }, val)
  5317. : { from: val };
  5318. }
  5319. }
  5320. else {
  5321. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5322. `but got ${toRawType(inject)}.`, vm);
  5323. }
  5324. }
  5325. /**
  5326. * Normalize raw function directives into object format.
  5327. */
  5328. function normalizeDirectives$1(options) {
  5329. const dirs = options.directives;
  5330. if (dirs) {
  5331. for (const key in dirs) {
  5332. const def = dirs[key];
  5333. if (isFunction(def)) {
  5334. dirs[key] = { bind: def, update: def };
  5335. }
  5336. }
  5337. }
  5338. }
  5339. function assertObjectType(name, value, vm) {
  5340. if (!isPlainObject(value)) {
  5341. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5342. `but got ${toRawType(value)}.`, vm);
  5343. }
  5344. }
  5345. /**
  5346. * Merge two option objects into a new one.
  5347. * Core utility used in both instantiation and inheritance.
  5348. */
  5349. function mergeOptions(parent, child, vm) {
  5350. {
  5351. checkComponents(child);
  5352. }
  5353. if (isFunction(child)) {
  5354. // @ts-expect-error
  5355. child = child.options;
  5356. }
  5357. normalizeProps(child, vm);
  5358. normalizeInject(child, vm);
  5359. normalizeDirectives$1(child);
  5360. // Apply extends and mixins on the child options,
  5361. // but only if it is a raw options object that isn't
  5362. // the result of another mergeOptions call.
  5363. // Only merged options has the _base property.
  5364. if (!child._base) {
  5365. if (child.extends) {
  5366. parent = mergeOptions(parent, child.extends, vm);
  5367. }
  5368. if (child.mixins) {
  5369. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5370. parent = mergeOptions(parent, child.mixins[i], vm);
  5371. }
  5372. }
  5373. }
  5374. const options = {};
  5375. let key;
  5376. for (key in parent) {
  5377. mergeField(key);
  5378. }
  5379. for (key in child) {
  5380. if (!hasOwn(parent, key)) {
  5381. mergeField(key);
  5382. }
  5383. }
  5384. function mergeField(key) {
  5385. const strat = strats[key] || defaultStrat;
  5386. options[key] = strat(parent[key], child[key], vm, key);
  5387. }
  5388. return options;
  5389. }
  5390. /**
  5391. * Resolve an asset.
  5392. * This function is used because child instances need access
  5393. * to assets defined in its ancestor chain.
  5394. */
  5395. function resolveAsset(options, type, id, warnMissing) {
  5396. /* istanbul ignore if */
  5397. if (typeof id !== 'string') {
  5398. return;
  5399. }
  5400. const assets = options[type];
  5401. // check local registration variations first
  5402. if (hasOwn(assets, id))
  5403. return assets[id];
  5404. const camelizedId = camelize(id);
  5405. if (hasOwn(assets, camelizedId))
  5406. return assets[camelizedId];
  5407. const PascalCaseId = capitalize(camelizedId);
  5408. if (hasOwn(assets, PascalCaseId))
  5409. return assets[PascalCaseId];
  5410. // fallback to prototype chain
  5411. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5412. if (warnMissing && !res) {
  5413. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5414. }
  5415. return res;
  5416. }
  5417. function validateProp(key, propOptions, propsData, vm) {
  5418. const prop = propOptions[key];
  5419. const absent = !hasOwn(propsData, key);
  5420. let value = propsData[key];
  5421. // boolean casting
  5422. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5423. if (booleanIndex > -1) {
  5424. if (absent && !hasOwn(prop, 'default')) {
  5425. value = false;
  5426. }
  5427. else if (value === '' || value === hyphenate(key)) {
  5428. // only cast empty string / same name to boolean if
  5429. // boolean has higher priority
  5430. const stringIndex = getTypeIndex(String, prop.type);
  5431. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5432. value = true;
  5433. }
  5434. }
  5435. }
  5436. // check default value
  5437. if (value === undefined) {
  5438. value = getPropDefaultValue(vm, prop, key);
  5439. // since the default value is a fresh copy,
  5440. // make sure to observe it.
  5441. const prevShouldObserve = shouldObserve;
  5442. toggleObserving(true);
  5443. observe(value);
  5444. toggleObserving(prevShouldObserve);
  5445. }
  5446. {
  5447. assertProp(prop, key, value, vm, absent);
  5448. }
  5449. return value;
  5450. }
  5451. /**
  5452. * Get the default value of a prop.
  5453. */
  5454. function getPropDefaultValue(vm, prop, key) {
  5455. // no default, return undefined
  5456. if (!hasOwn(prop, 'default')) {
  5457. return undefined;
  5458. }
  5459. const def = prop.default;
  5460. // warn against non-factory defaults for Object & Array
  5461. if (isObject(def)) {
  5462. warn$2('Invalid default value for prop "' +
  5463. key +
  5464. '": ' +
  5465. 'Props with type Object/Array must use a factory function ' +
  5466. 'to return the default value.', vm);
  5467. }
  5468. // the raw prop value was also undefined from previous render,
  5469. // return previous default value to avoid unnecessary watcher trigger
  5470. if (vm &&
  5471. vm.$options.propsData &&
  5472. vm.$options.propsData[key] === undefined &&
  5473. vm._props[key] !== undefined) {
  5474. return vm._props[key];
  5475. }
  5476. // call factory function for non-Function types
  5477. // a value is Function if its prototype is function even across different execution context
  5478. return isFunction(def) && getType(prop.type) !== 'Function'
  5479. ? def.call(vm)
  5480. : def;
  5481. }
  5482. /**
  5483. * Assert whether a prop is valid.
  5484. */
  5485. function assertProp(prop, name, value, vm, absent) {
  5486. if (prop.required && absent) {
  5487. warn$2('Missing required prop: "' + name + '"', vm);
  5488. return;
  5489. }
  5490. if (value == null && !prop.required) {
  5491. return;
  5492. }
  5493. let type = prop.type;
  5494. let valid = !type || type === true;
  5495. const expectedTypes = [];
  5496. if (type) {
  5497. if (!isArray(type)) {
  5498. type = [type];
  5499. }
  5500. for (let i = 0; i < type.length && !valid; i++) {
  5501. const assertedType = assertType(value, type[i], vm);
  5502. expectedTypes.push(assertedType.expectedType || '');
  5503. valid = assertedType.valid;
  5504. }
  5505. }
  5506. const haveExpectedTypes = expectedTypes.some(t => t);
  5507. if (!valid && haveExpectedTypes) {
  5508. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5509. return;
  5510. }
  5511. const validator = prop.validator;
  5512. if (validator) {
  5513. if (!validator(value)) {
  5514. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5515. }
  5516. }
  5517. }
  5518. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5519. function assertType(value, type, vm) {
  5520. let valid;
  5521. const expectedType = getType(type);
  5522. if (simpleCheckRE.test(expectedType)) {
  5523. const t = typeof value;
  5524. valid = t === expectedType.toLowerCase();
  5525. // for primitive wrapper objects
  5526. if (!valid && t === 'object') {
  5527. valid = value instanceof type;
  5528. }
  5529. }
  5530. else if (expectedType === 'Object') {
  5531. valid = isPlainObject(value);
  5532. }
  5533. else if (expectedType === 'Array') {
  5534. valid = isArray(value);
  5535. }
  5536. else {
  5537. try {
  5538. valid = value instanceof type;
  5539. }
  5540. catch (e) {
  5541. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5542. valid = false;
  5543. }
  5544. }
  5545. return {
  5546. valid,
  5547. expectedType
  5548. };
  5549. }
  5550. const functionTypeCheckRE = /^\s*function (\w+)/;
  5551. /**
  5552. * Use function string name to check built-in types,
  5553. * because a simple equality check will fail when running
  5554. * across different vms / iframes.
  5555. */
  5556. function getType(fn) {
  5557. const match = fn && fn.toString().match(functionTypeCheckRE);
  5558. return match ? match[1] : '';
  5559. }
  5560. function isSameType(a, b) {
  5561. return getType(a) === getType(b);
  5562. }
  5563. function getTypeIndex(type, expectedTypes) {
  5564. if (!isArray(expectedTypes)) {
  5565. return isSameType(expectedTypes, type) ? 0 : -1;
  5566. }
  5567. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5568. if (isSameType(expectedTypes[i], type)) {
  5569. return i;
  5570. }
  5571. }
  5572. return -1;
  5573. }
  5574. function getInvalidTypeMessage(name, value, expectedTypes) {
  5575. let message = `Invalid prop: type check failed for prop "${name}".` +
  5576. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5577. const expectedType = expectedTypes[0];
  5578. const receivedType = toRawType(value);
  5579. // check if we need to specify expected value
  5580. if (expectedTypes.length === 1 &&
  5581. isExplicable(expectedType) &&
  5582. isExplicable(typeof value) &&
  5583. !isBoolean(expectedType, receivedType)) {
  5584. message += ` with value ${styleValue(value, expectedType)}`;
  5585. }
  5586. message += `, got ${receivedType} `;
  5587. // check if we need to specify received value
  5588. if (isExplicable(receivedType)) {
  5589. message += `with value ${styleValue(value, receivedType)}.`;
  5590. }
  5591. return message;
  5592. }
  5593. function styleValue(value, type) {
  5594. if (type === 'String') {
  5595. return `"${value}"`;
  5596. }
  5597. else if (type === 'Number') {
  5598. return `${Number(value)}`;
  5599. }
  5600. else {
  5601. return `${value}`;
  5602. }
  5603. }
  5604. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5605. function isExplicable(value) {
  5606. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5607. }
  5608. function isBoolean(...args) {
  5609. return args.some(elem => elem.toLowerCase() === 'boolean');
  5610. }
  5611. function Vue(options) {
  5612. if (!(this instanceof Vue)) {
  5613. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5614. }
  5615. this._init(options);
  5616. }
  5617. //@ts-expect-error Vue has function type
  5618. initMixin$1(Vue);
  5619. //@ts-expect-error Vue has function type
  5620. stateMixin(Vue);
  5621. //@ts-expect-error Vue has function type
  5622. eventsMixin(Vue);
  5623. //@ts-expect-error Vue has function type
  5624. lifecycleMixin(Vue);
  5625. //@ts-expect-error Vue has function type
  5626. renderMixin(Vue);
  5627. function initUse(Vue) {
  5628. Vue.use = function (plugin) {
  5629. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5630. if (installedPlugins.indexOf(plugin) > -1) {
  5631. return this;
  5632. }
  5633. // additional parameters
  5634. const args = toArray(arguments, 1);
  5635. args.unshift(this);
  5636. if (isFunction(plugin.install)) {
  5637. plugin.install.apply(plugin, args);
  5638. }
  5639. else if (isFunction(plugin)) {
  5640. plugin.apply(null, args);
  5641. }
  5642. installedPlugins.push(plugin);
  5643. return this;
  5644. };
  5645. }
  5646. function initMixin(Vue) {
  5647. Vue.mixin = function (mixin) {
  5648. this.options = mergeOptions(this.options, mixin);
  5649. return this;
  5650. };
  5651. }
  5652. function initExtend(Vue) {
  5653. /**
  5654. * Each instance constructor, including Vue, has a unique
  5655. * cid. This enables us to create wrapped "child
  5656. * constructors" for prototypal inheritance and cache them.
  5657. */
  5658. Vue.cid = 0;
  5659. let cid = 1;
  5660. /**
  5661. * Class inheritance
  5662. */
  5663. Vue.extend = function (extendOptions) {
  5664. extendOptions = extendOptions || {};
  5665. const Super = this;
  5666. const SuperId = Super.cid;
  5667. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5668. if (cachedCtors[SuperId]) {
  5669. return cachedCtors[SuperId];
  5670. }
  5671. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5672. if (name) {
  5673. validateComponentName(name);
  5674. }
  5675. const Sub = function VueComponent(options) {
  5676. this._init(options);
  5677. };
  5678. Sub.prototype = Object.create(Super.prototype);
  5679. Sub.prototype.constructor = Sub;
  5680. Sub.cid = cid++;
  5681. Sub.options = mergeOptions(Super.options, extendOptions);
  5682. Sub['super'] = Super;
  5683. // For props and computed properties, we define the proxy getters on
  5684. // the Vue instances at extension time, on the extended prototype. This
  5685. // avoids Object.defineProperty calls for each instance created.
  5686. if (Sub.options.props) {
  5687. initProps(Sub);
  5688. }
  5689. if (Sub.options.computed) {
  5690. initComputed(Sub);
  5691. }
  5692. // allow further extension/mixin/plugin usage
  5693. Sub.extend = Super.extend;
  5694. Sub.mixin = Super.mixin;
  5695. Sub.use = Super.use;
  5696. // create asset registers, so extended classes
  5697. // can have their private assets too.
  5698. ASSET_TYPES.forEach(function (type) {
  5699. Sub[type] = Super[type];
  5700. });
  5701. // enable recursive self-lookup
  5702. if (name) {
  5703. Sub.options.components[name] = Sub;
  5704. }
  5705. // keep a reference to the super options at extension time.
  5706. // later at instantiation we can check if Super's options have
  5707. // been updated.
  5708. Sub.superOptions = Super.options;
  5709. Sub.extendOptions = extendOptions;
  5710. Sub.sealedOptions = extend({}, Sub.options);
  5711. // cache constructor
  5712. cachedCtors[SuperId] = Sub;
  5713. return Sub;
  5714. };
  5715. }
  5716. function initProps(Comp) {
  5717. const props = Comp.options.props;
  5718. for (const key in props) {
  5719. proxy(Comp.prototype, `_props`, key);
  5720. }
  5721. }
  5722. function initComputed(Comp) {
  5723. const computed = Comp.options.computed;
  5724. for (const key in computed) {
  5725. defineComputed(Comp.prototype, key, computed[key]);
  5726. }
  5727. }
  5728. function initAssetRegisters(Vue) {
  5729. /**
  5730. * Create asset registration methods.
  5731. */
  5732. ASSET_TYPES.forEach(type => {
  5733. // @ts-expect-error function is not exact same type
  5734. Vue[type] = function (id, definition) {
  5735. if (!definition) {
  5736. return this.options[type + 's'][id];
  5737. }
  5738. else {
  5739. /* istanbul ignore if */
  5740. if (type === 'component') {
  5741. validateComponentName(id);
  5742. }
  5743. if (type === 'component' && isPlainObject(definition)) {
  5744. // @ts-expect-error
  5745. definition.name = definition.name || id;
  5746. definition = this.options._base.extend(definition);
  5747. }
  5748. if (type === 'directive' && isFunction(definition)) {
  5749. definition = { bind: definition, update: definition };
  5750. }
  5751. this.options[type + 's'][id] = definition;
  5752. return definition;
  5753. }
  5754. };
  5755. });
  5756. }
  5757. function _getComponentName(opts) {
  5758. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5759. }
  5760. function matches(pattern, name) {
  5761. if (isArray(pattern)) {
  5762. return pattern.indexOf(name) > -1;
  5763. }
  5764. else if (typeof pattern === 'string') {
  5765. return pattern.split(',').indexOf(name) > -1;
  5766. }
  5767. else if (isRegExp(pattern)) {
  5768. return pattern.test(name);
  5769. }
  5770. /* istanbul ignore next */
  5771. return false;
  5772. }
  5773. function pruneCache(keepAliveInstance, filter) {
  5774. const { cache, keys, _vnode } = keepAliveInstance;
  5775. for (const key in cache) {
  5776. const entry = cache[key];
  5777. if (entry) {
  5778. const name = entry.name;
  5779. if (name && !filter(name)) {
  5780. pruneCacheEntry(cache, key, keys, _vnode);
  5781. }
  5782. }
  5783. }
  5784. }
  5785. function pruneCacheEntry(cache, key, keys, current) {
  5786. const entry = cache[key];
  5787. if (entry && (!current || entry.tag !== current.tag)) {
  5788. // @ts-expect-error can be undefined
  5789. entry.componentInstance.$destroy();
  5790. }
  5791. cache[key] = null;
  5792. remove$2(keys, key);
  5793. }
  5794. const patternTypes = [String, RegExp, Array];
  5795. // TODO defineComponent
  5796. var KeepAlive = {
  5797. name: 'keep-alive',
  5798. abstract: true,
  5799. props: {
  5800. include: patternTypes,
  5801. exclude: patternTypes,
  5802. max: [String, Number]
  5803. },
  5804. methods: {
  5805. cacheVNode() {
  5806. const { cache, keys, vnodeToCache, keyToCache } = this;
  5807. if (vnodeToCache) {
  5808. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5809. cache[keyToCache] = {
  5810. name: _getComponentName(componentOptions),
  5811. tag,
  5812. componentInstance
  5813. };
  5814. keys.push(keyToCache);
  5815. // prune oldest entry
  5816. if (this.max && keys.length > parseInt(this.max)) {
  5817. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5818. }
  5819. this.vnodeToCache = null;
  5820. }
  5821. }
  5822. },
  5823. created() {
  5824. this.cache = Object.create(null);
  5825. this.keys = [];
  5826. },
  5827. destroyed() {
  5828. for (const key in this.cache) {
  5829. pruneCacheEntry(this.cache, key, this.keys);
  5830. }
  5831. },
  5832. mounted() {
  5833. this.cacheVNode();
  5834. this.$watch('include', val => {
  5835. pruneCache(this, name => matches(val, name));
  5836. });
  5837. this.$watch('exclude', val => {
  5838. pruneCache(this, name => !matches(val, name));
  5839. });
  5840. },
  5841. updated() {
  5842. this.cacheVNode();
  5843. },
  5844. render() {
  5845. const slot = this.$slots.default;
  5846. const vnode = getFirstComponentChild(slot);
  5847. const componentOptions = vnode && vnode.componentOptions;
  5848. if (componentOptions) {
  5849. // check pattern
  5850. const name = _getComponentName(componentOptions);
  5851. const { include, exclude } = this;
  5852. if (
  5853. // not included
  5854. (include && (!name || !matches(include, name))) ||
  5855. // excluded
  5856. (exclude && name && matches(exclude, name))) {
  5857. return vnode;
  5858. }
  5859. const { cache, keys } = this;
  5860. const key = vnode.key == null
  5861. ? // same constructor may get registered as different local components
  5862. // so cid alone is not enough (#3269)
  5863. componentOptions.Ctor.cid +
  5864. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5865. : vnode.key;
  5866. if (cache[key]) {
  5867. vnode.componentInstance = cache[key].componentInstance;
  5868. // make current key freshest
  5869. remove$2(keys, key);
  5870. keys.push(key);
  5871. }
  5872. else {
  5873. // delay setting the cache until update
  5874. this.vnodeToCache = vnode;
  5875. this.keyToCache = key;
  5876. }
  5877. // @ts-expect-error can vnode.data can be undefined
  5878. vnode.data.keepAlive = true;
  5879. }
  5880. return vnode || (slot && slot[0]);
  5881. }
  5882. };
  5883. var builtInComponents = {
  5884. KeepAlive
  5885. };
  5886. function initGlobalAPI(Vue) {
  5887. // config
  5888. const configDef = {};
  5889. configDef.get = () => config;
  5890. {
  5891. configDef.set = () => {
  5892. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5893. };
  5894. }
  5895. Object.defineProperty(Vue, 'config', configDef);
  5896. // exposed util methods.
  5897. // NOTE: these are not considered part of the public API - avoid relying on
  5898. // them unless you are aware of the risk.
  5899. Vue.util = {
  5900. warn: warn$2,
  5901. extend,
  5902. mergeOptions,
  5903. defineReactive
  5904. };
  5905. Vue.set = set;
  5906. Vue.delete = del;
  5907. Vue.nextTick = nextTick;
  5908. // 2.6 explicit observable API
  5909. Vue.observable = (obj) => {
  5910. observe(obj);
  5911. return obj;
  5912. };
  5913. Vue.options = Object.create(null);
  5914. ASSET_TYPES.forEach(type => {
  5915. Vue.options[type + 's'] = Object.create(null);
  5916. });
  5917. // this is used to identify the "base" constructor to extend all plain-object
  5918. // components with in Weex's multi-instance scenarios.
  5919. Vue.options._base = Vue;
  5920. extend(Vue.options.components, builtInComponents);
  5921. initUse(Vue);
  5922. initMixin(Vue);
  5923. initExtend(Vue);
  5924. initAssetRegisters(Vue);
  5925. }
  5926. initGlobalAPI(Vue);
  5927. Object.defineProperty(Vue.prototype, '$isServer', {
  5928. get: isServerRendering
  5929. });
  5930. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5931. get() {
  5932. /* istanbul ignore next */
  5933. return this.$vnode && this.$vnode.ssrContext;
  5934. }
  5935. });
  5936. // expose FunctionalRenderContext for ssr runtime helper installation
  5937. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5938. value: FunctionalRenderContext
  5939. });
  5940. Vue.version = version;
  5941. // these are reserved for web because they are directly compiled away
  5942. // during template compilation
  5943. const isReservedAttr = makeMap('style,class');
  5944. // attributes that should be using props for binding
  5945. const acceptValue = makeMap('input,textarea,option,select,progress');
  5946. const mustUseProp = (tag, type, attr) => {
  5947. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5948. (attr === 'selected' && tag === 'option') ||
  5949. (attr === 'checked' && tag === 'input') ||
  5950. (attr === 'muted' && tag === 'video'));
  5951. };
  5952. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5953. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5954. const convertEnumeratedValue = (key, value) => {
  5955. return isFalsyAttrValue(value) || value === 'false'
  5956. ? 'false'
  5957. : // allow arbitrary string value for contenteditable
  5958. key === 'contenteditable' && isValidContentEditableValue(value)
  5959. ? value
  5960. : 'true';
  5961. };
  5962. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5963. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5964. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5965. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5966. 'required,reversed,scoped,seamless,selected,sortable,' +
  5967. 'truespeed,typemustmatch,visible');
  5968. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5969. const isXlink = (name) => {
  5970. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5971. };
  5972. const getXlinkProp = (name) => {
  5973. return isXlink(name) ? name.slice(6, name.length) : '';
  5974. };
  5975. const isFalsyAttrValue = (val) => {
  5976. return val == null || val === false;
  5977. };
  5978. function genClassForVnode(vnode) {
  5979. let data = vnode.data;
  5980. let parentNode = vnode;
  5981. let childNode = vnode;
  5982. while (isDef(childNode.componentInstance)) {
  5983. childNode = childNode.componentInstance._vnode;
  5984. if (childNode && childNode.data) {
  5985. data = mergeClassData(childNode.data, data);
  5986. }
  5987. }
  5988. // @ts-expect-error parentNode.parent not VNodeWithData
  5989. while (isDef((parentNode = parentNode.parent))) {
  5990. if (parentNode && parentNode.data) {
  5991. data = mergeClassData(data, parentNode.data);
  5992. }
  5993. }
  5994. return renderClass(data.staticClass, data.class);
  5995. }
  5996. function mergeClassData(child, parent) {
  5997. return {
  5998. staticClass: concat(child.staticClass, parent.staticClass),
  5999. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6000. };
  6001. }
  6002. function renderClass(staticClass, dynamicClass) {
  6003. if (isDef(staticClass) || isDef(dynamicClass)) {
  6004. return concat(staticClass, stringifyClass(dynamicClass));
  6005. }
  6006. /* istanbul ignore next */
  6007. return '';
  6008. }
  6009. function concat(a, b) {
  6010. return a ? (b ? a + ' ' + b : a) : b || '';
  6011. }
  6012. function stringifyClass(value) {
  6013. if (Array.isArray(value)) {
  6014. return stringifyArray(value);
  6015. }
  6016. if (isObject(value)) {
  6017. return stringifyObject(value);
  6018. }
  6019. if (typeof value === 'string') {
  6020. return value;
  6021. }
  6022. /* istanbul ignore next */
  6023. return '';
  6024. }
  6025. function stringifyArray(value) {
  6026. let res = '';
  6027. let stringified;
  6028. for (let i = 0, l = value.length; i < l; i++) {
  6029. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6030. if (res)
  6031. res += ' ';
  6032. res += stringified;
  6033. }
  6034. }
  6035. return res;
  6036. }
  6037. function stringifyObject(value) {
  6038. let res = '';
  6039. for (const key in value) {
  6040. if (value[key]) {
  6041. if (res)
  6042. res += ' ';
  6043. res += key;
  6044. }
  6045. }
  6046. return res;
  6047. }
  6048. const namespaceMap = {
  6049. svg: 'http://www.w3.org/2000/svg',
  6050. math: 'http://www.w3.org/1998/Math/MathML'
  6051. };
  6052. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6053. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6054. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6055. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6056. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6057. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6058. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6059. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6060. 'output,progress,select,textarea,' +
  6061. 'details,dialog,menu,menuitem,summary,' +
  6062. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6063. // this map is intentionally selective, only covering SVG elements that may
  6064. // contain child elements.
  6065. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6066. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6067. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6068. const isPreTag = (tag) => tag === 'pre';
  6069. const isReservedTag = (tag) => {
  6070. return isHTMLTag(tag) || isSVG(tag);
  6071. };
  6072. function getTagNamespace(tag) {
  6073. if (isSVG(tag)) {
  6074. return 'svg';
  6075. }
  6076. // basic support for MathML
  6077. // note it doesn't support other MathML elements being component roots
  6078. if (tag === 'math') {
  6079. return 'math';
  6080. }
  6081. }
  6082. const unknownElementCache = Object.create(null);
  6083. function isUnknownElement(tag) {
  6084. /* istanbul ignore if */
  6085. if (!inBrowser) {
  6086. return true;
  6087. }
  6088. if (isReservedTag(tag)) {
  6089. return false;
  6090. }
  6091. tag = tag.toLowerCase();
  6092. /* istanbul ignore if */
  6093. if (unknownElementCache[tag] != null) {
  6094. return unknownElementCache[tag];
  6095. }
  6096. const el = document.createElement(tag);
  6097. if (tag.indexOf('-') > -1) {
  6098. // http://stackoverflow.com/a/28210364/1070244
  6099. return (unknownElementCache[tag] =
  6100. el.constructor === window.HTMLUnknownElement ||
  6101. el.constructor === window.HTMLElement);
  6102. }
  6103. else {
  6104. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6105. }
  6106. }
  6107. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6108. /**
  6109. * Query an element selector if it's not an element already.
  6110. */
  6111. function query(el) {
  6112. if (typeof el === 'string') {
  6113. const selected = document.querySelector(el);
  6114. if (!selected) {
  6115. warn$2('Cannot find element: ' + el);
  6116. return document.createElement('div');
  6117. }
  6118. return selected;
  6119. }
  6120. else {
  6121. return el;
  6122. }
  6123. }
  6124. function createElement(tagName, vnode) {
  6125. const elm = document.createElement(tagName);
  6126. if (tagName !== 'select') {
  6127. return elm;
  6128. }
  6129. // false or null will remove the attribute but undefined will not
  6130. if (vnode.data &&
  6131. vnode.data.attrs &&
  6132. vnode.data.attrs.multiple !== undefined) {
  6133. elm.setAttribute('multiple', 'multiple');
  6134. }
  6135. return elm;
  6136. }
  6137. function createElementNS(namespace, tagName) {
  6138. return document.createElementNS(namespaceMap[namespace], tagName);
  6139. }
  6140. function createTextNode(text) {
  6141. return document.createTextNode(text);
  6142. }
  6143. function createComment(text) {
  6144. return document.createComment(text);
  6145. }
  6146. function insertBefore(parentNode, newNode, referenceNode) {
  6147. parentNode.insertBefore(newNode, referenceNode);
  6148. }
  6149. function removeChild(node, child) {
  6150. node.removeChild(child);
  6151. }
  6152. function appendChild(node, child) {
  6153. node.appendChild(child);
  6154. }
  6155. function parentNode(node) {
  6156. return node.parentNode;
  6157. }
  6158. function nextSibling(node) {
  6159. return node.nextSibling;
  6160. }
  6161. function tagName(node) {
  6162. return node.tagName;
  6163. }
  6164. function setTextContent(node, text) {
  6165. node.textContent = text;
  6166. }
  6167. function setStyleScope(node, scopeId) {
  6168. node.setAttribute(scopeId, '');
  6169. }
  6170. var nodeOps = /*#__PURE__*/Object.freeze({
  6171. __proto__: null,
  6172. createElement: createElement,
  6173. createElementNS: createElementNS,
  6174. createTextNode: createTextNode,
  6175. createComment: createComment,
  6176. insertBefore: insertBefore,
  6177. removeChild: removeChild,
  6178. appendChild: appendChild,
  6179. parentNode: parentNode,
  6180. nextSibling: nextSibling,
  6181. tagName: tagName,
  6182. setTextContent: setTextContent,
  6183. setStyleScope: setStyleScope
  6184. });
  6185. var ref = {
  6186. create(_, vnode) {
  6187. registerRef(vnode);
  6188. },
  6189. update(oldVnode, vnode) {
  6190. if (oldVnode.data.ref !== vnode.data.ref) {
  6191. registerRef(oldVnode, true);
  6192. registerRef(vnode);
  6193. }
  6194. },
  6195. destroy(vnode) {
  6196. registerRef(vnode, true);
  6197. }
  6198. };
  6199. function registerRef(vnode, isRemoval) {
  6200. const ref = vnode.data.ref;
  6201. if (!isDef(ref))
  6202. return;
  6203. const vm = vnode.context;
  6204. const refValue = vnode.componentInstance || vnode.elm;
  6205. const value = isRemoval ? null : refValue;
  6206. const $refsValue = isRemoval ? undefined : refValue;
  6207. if (isFunction(ref)) {
  6208. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6209. return;
  6210. }
  6211. const isFor = vnode.data.refInFor;
  6212. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6213. const _isRef = isRef(ref);
  6214. const refs = vm.$refs;
  6215. if (_isString || _isRef) {
  6216. if (isFor) {
  6217. const existing = _isString ? refs[ref] : ref.value;
  6218. if (isRemoval) {
  6219. isArray(existing) && remove$2(existing, refValue);
  6220. }
  6221. else {
  6222. if (!isArray(existing)) {
  6223. if (_isString) {
  6224. refs[ref] = [refValue];
  6225. setSetupRef(vm, ref, refs[ref]);
  6226. }
  6227. else {
  6228. ref.value = [refValue];
  6229. }
  6230. }
  6231. else if (!existing.includes(refValue)) {
  6232. existing.push(refValue);
  6233. }
  6234. }
  6235. }
  6236. else if (_isString) {
  6237. if (isRemoval && refs[ref] !== refValue) {
  6238. return;
  6239. }
  6240. refs[ref] = $refsValue;
  6241. setSetupRef(vm, ref, value);
  6242. }
  6243. else if (_isRef) {
  6244. if (isRemoval && ref.value !== refValue) {
  6245. return;
  6246. }
  6247. ref.value = value;
  6248. }
  6249. else {
  6250. warn$2(`Invalid template ref type: ${typeof ref}`);
  6251. }
  6252. }
  6253. }
  6254. function setSetupRef({ _setupState }, key, val) {
  6255. if (_setupState && hasOwn(_setupState, key)) {
  6256. if (isRef(_setupState[key])) {
  6257. _setupState[key].value = val;
  6258. }
  6259. else {
  6260. _setupState[key] = val;
  6261. }
  6262. }
  6263. }
  6264. /**
  6265. * Virtual DOM patching algorithm based on Snabbdom by
  6266. * Simon Friis Vindum (@paldepind)
  6267. * Licensed under the MIT License
  6268. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6269. *
  6270. * modified by Evan You (@yyx990803)
  6271. *
  6272. * Not type-checking this because this file is perf-critical and the cost
  6273. * of making flow understand it is not worth it.
  6274. */
  6275. const emptyNode = new VNode('', {}, []);
  6276. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6277. function sameVnode(a, b) {
  6278. return (a.key === b.key &&
  6279. a.asyncFactory === b.asyncFactory &&
  6280. ((a.tag === b.tag &&
  6281. a.isComment === b.isComment &&
  6282. isDef(a.data) === isDef(b.data) &&
  6283. sameInputType(a, b)) ||
  6284. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6285. }
  6286. function sameInputType(a, b) {
  6287. if (a.tag !== 'input')
  6288. return true;
  6289. let i;
  6290. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6291. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6292. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6293. }
  6294. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6295. let i, key;
  6296. const map = {};
  6297. for (i = beginIdx; i <= endIdx; ++i) {
  6298. key = children[i].key;
  6299. if (isDef(key))
  6300. map[key] = i;
  6301. }
  6302. return map;
  6303. }
  6304. function createPatchFunction(backend) {
  6305. let i, j;
  6306. const cbs = {};
  6307. const { modules, nodeOps } = backend;
  6308. for (i = 0; i < hooks.length; ++i) {
  6309. cbs[hooks[i]] = [];
  6310. for (j = 0; j < modules.length; ++j) {
  6311. if (isDef(modules[j][hooks[i]])) {
  6312. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6313. }
  6314. }
  6315. }
  6316. function emptyNodeAt(elm) {
  6317. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6318. }
  6319. function createRmCb(childElm, listeners) {
  6320. function remove() {
  6321. if (--remove.listeners === 0) {
  6322. removeNode(childElm);
  6323. }
  6324. }
  6325. remove.listeners = listeners;
  6326. return remove;
  6327. }
  6328. function removeNode(el) {
  6329. const parent = nodeOps.parentNode(el);
  6330. // element may have already been removed due to v-html / v-text
  6331. if (isDef(parent)) {
  6332. nodeOps.removeChild(parent, el);
  6333. }
  6334. }
  6335. function isUnknownElement(vnode, inVPre) {
  6336. return (!inVPre &&
  6337. !vnode.ns &&
  6338. !(config.ignoredElements.length &&
  6339. config.ignoredElements.some(ignore => {
  6340. return isRegExp(ignore)
  6341. ? ignore.test(vnode.tag)
  6342. : ignore === vnode.tag;
  6343. })) &&
  6344. config.isUnknownElement(vnode.tag));
  6345. }
  6346. let creatingElmInVPre = 0;
  6347. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6348. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6349. // This vnode was used in a previous render!
  6350. // now it's used as a new node, overwriting its elm would cause
  6351. // potential patch errors down the road when it's used as an insertion
  6352. // reference node. Instead, we clone the node on-demand before creating
  6353. // associated DOM element for it.
  6354. vnode = ownerArray[index] = cloneVNode(vnode);
  6355. }
  6356. vnode.isRootInsert = !nested; // for transition enter check
  6357. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6358. return;
  6359. }
  6360. const data = vnode.data;
  6361. const children = vnode.children;
  6362. const tag = vnode.tag;
  6363. if (isDef(tag)) {
  6364. {
  6365. if (data && data.pre) {
  6366. creatingElmInVPre++;
  6367. }
  6368. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6369. warn$2('Unknown custom element: <' +
  6370. tag +
  6371. '> - did you ' +
  6372. 'register the component correctly? For recursive components, ' +
  6373. 'make sure to provide the "name" option.', vnode.context);
  6374. }
  6375. }
  6376. vnode.elm = vnode.ns
  6377. ? nodeOps.createElementNS(vnode.ns, tag)
  6378. : nodeOps.createElement(tag, vnode);
  6379. setScope(vnode);
  6380. createChildren(vnode, children, insertedVnodeQueue);
  6381. if (isDef(data)) {
  6382. invokeCreateHooks(vnode, insertedVnodeQueue);
  6383. }
  6384. insert(parentElm, vnode.elm, refElm);
  6385. if (data && data.pre) {
  6386. creatingElmInVPre--;
  6387. }
  6388. }
  6389. else if (isTrue(vnode.isComment)) {
  6390. vnode.elm = nodeOps.createComment(vnode.text);
  6391. insert(parentElm, vnode.elm, refElm);
  6392. }
  6393. else {
  6394. vnode.elm = nodeOps.createTextNode(vnode.text);
  6395. insert(parentElm, vnode.elm, refElm);
  6396. }
  6397. }
  6398. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6399. let i = vnode.data;
  6400. if (isDef(i)) {
  6401. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6402. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6403. i(vnode, false /* hydrating */);
  6404. }
  6405. // after calling the init hook, if the vnode is a child component
  6406. // it should've created a child instance and mounted it. the child
  6407. // component also has set the placeholder vnode's elm.
  6408. // in that case we can just return the element and be done.
  6409. if (isDef(vnode.componentInstance)) {
  6410. initComponent(vnode, insertedVnodeQueue);
  6411. insert(parentElm, vnode.elm, refElm);
  6412. if (isTrue(isReactivated)) {
  6413. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6414. }
  6415. return true;
  6416. }
  6417. }
  6418. }
  6419. function initComponent(vnode, insertedVnodeQueue) {
  6420. if (isDef(vnode.data.pendingInsert)) {
  6421. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6422. vnode.data.pendingInsert = null;
  6423. }
  6424. vnode.elm = vnode.componentInstance.$el;
  6425. if (isPatchable(vnode)) {
  6426. invokeCreateHooks(vnode, insertedVnodeQueue);
  6427. setScope(vnode);
  6428. }
  6429. else {
  6430. // empty component root.
  6431. // skip all element-related modules except for ref (#3455)
  6432. registerRef(vnode);
  6433. // make sure to invoke the insert hook
  6434. insertedVnodeQueue.push(vnode);
  6435. }
  6436. }
  6437. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6438. let i;
  6439. // hack for #4339: a reactivated component with inner transition
  6440. // does not trigger because the inner node's created hooks are not called
  6441. // again. It's not ideal to involve module-specific logic in here but
  6442. // there doesn't seem to be a better way to do it.
  6443. let innerNode = vnode;
  6444. while (innerNode.componentInstance) {
  6445. innerNode = innerNode.componentInstance._vnode;
  6446. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6447. for (i = 0; i < cbs.activate.length; ++i) {
  6448. cbs.activate[i](emptyNode, innerNode);
  6449. }
  6450. insertedVnodeQueue.push(innerNode);
  6451. break;
  6452. }
  6453. }
  6454. // unlike a newly created component,
  6455. // a reactivated keep-alive component doesn't insert itself
  6456. insert(parentElm, vnode.elm, refElm);
  6457. }
  6458. function insert(parent, elm, ref) {
  6459. if (isDef(parent)) {
  6460. if (isDef(ref)) {
  6461. if (nodeOps.parentNode(ref) === parent) {
  6462. nodeOps.insertBefore(parent, elm, ref);
  6463. }
  6464. }
  6465. else {
  6466. nodeOps.appendChild(parent, elm);
  6467. }
  6468. }
  6469. }
  6470. function createChildren(vnode, children, insertedVnodeQueue) {
  6471. if (isArray(children)) {
  6472. {
  6473. checkDuplicateKeys(children);
  6474. }
  6475. for (let i = 0; i < children.length; ++i) {
  6476. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6477. }
  6478. }
  6479. else if (isPrimitive(vnode.text)) {
  6480. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6481. }
  6482. }
  6483. function isPatchable(vnode) {
  6484. while (vnode.componentInstance) {
  6485. vnode = vnode.componentInstance._vnode;
  6486. }
  6487. return isDef(vnode.tag);
  6488. }
  6489. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6490. for (let i = 0; i < cbs.create.length; ++i) {
  6491. cbs.create[i](emptyNode, vnode);
  6492. }
  6493. i = vnode.data.hook; // Reuse variable
  6494. if (isDef(i)) {
  6495. if (isDef(i.create))
  6496. i.create(emptyNode, vnode);
  6497. if (isDef(i.insert))
  6498. insertedVnodeQueue.push(vnode);
  6499. }
  6500. }
  6501. // set scope id attribute for scoped CSS.
  6502. // this is implemented as a special case to avoid the overhead
  6503. // of going through the normal attribute patching process.
  6504. function setScope(vnode) {
  6505. let i;
  6506. if (isDef((i = vnode.fnScopeId))) {
  6507. nodeOps.setStyleScope(vnode.elm, i);
  6508. }
  6509. else {
  6510. let ancestor = vnode;
  6511. while (ancestor) {
  6512. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6513. nodeOps.setStyleScope(vnode.elm, i);
  6514. }
  6515. ancestor = ancestor.parent;
  6516. }
  6517. }
  6518. // for slot content they should also get the scopeId from the host instance.
  6519. if (isDef((i = activeInstance)) &&
  6520. i !== vnode.context &&
  6521. i !== vnode.fnContext &&
  6522. isDef((i = i.$options._scopeId))) {
  6523. nodeOps.setStyleScope(vnode.elm, i);
  6524. }
  6525. }
  6526. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6527. for (; startIdx <= endIdx; ++startIdx) {
  6528. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6529. }
  6530. }
  6531. function invokeDestroyHook(vnode) {
  6532. let i, j;
  6533. const data = vnode.data;
  6534. if (isDef(data)) {
  6535. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6536. i(vnode);
  6537. for (i = 0; i < cbs.destroy.length; ++i)
  6538. cbs.destroy[i](vnode);
  6539. }
  6540. if (isDef((i = vnode.children))) {
  6541. for (j = 0; j < vnode.children.length; ++j) {
  6542. invokeDestroyHook(vnode.children[j]);
  6543. }
  6544. }
  6545. }
  6546. function removeVnodes(vnodes, startIdx, endIdx) {
  6547. for (; startIdx <= endIdx; ++startIdx) {
  6548. const ch = vnodes[startIdx];
  6549. if (isDef(ch)) {
  6550. if (isDef(ch.tag)) {
  6551. removeAndInvokeRemoveHook(ch);
  6552. invokeDestroyHook(ch);
  6553. }
  6554. else {
  6555. // Text node
  6556. removeNode(ch.elm);
  6557. }
  6558. }
  6559. }
  6560. }
  6561. function removeAndInvokeRemoveHook(vnode, rm) {
  6562. if (isDef(rm) || isDef(vnode.data)) {
  6563. let i;
  6564. const listeners = cbs.remove.length + 1;
  6565. if (isDef(rm)) {
  6566. // we have a recursively passed down rm callback
  6567. // increase the listeners count
  6568. rm.listeners += listeners;
  6569. }
  6570. else {
  6571. // directly removing
  6572. rm = createRmCb(vnode.elm, listeners);
  6573. }
  6574. // recursively invoke hooks on child component root node
  6575. if (isDef((i = vnode.componentInstance)) &&
  6576. isDef((i = i._vnode)) &&
  6577. isDef(i.data)) {
  6578. removeAndInvokeRemoveHook(i, rm);
  6579. }
  6580. for (i = 0; i < cbs.remove.length; ++i) {
  6581. cbs.remove[i](vnode, rm);
  6582. }
  6583. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6584. i(vnode, rm);
  6585. }
  6586. else {
  6587. rm();
  6588. }
  6589. }
  6590. else {
  6591. removeNode(vnode.elm);
  6592. }
  6593. }
  6594. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6595. let oldStartIdx = 0;
  6596. let newStartIdx = 0;
  6597. let oldEndIdx = oldCh.length - 1;
  6598. let oldStartVnode = oldCh[0];
  6599. let oldEndVnode = oldCh[oldEndIdx];
  6600. let newEndIdx = newCh.length - 1;
  6601. let newStartVnode = newCh[0];
  6602. let newEndVnode = newCh[newEndIdx];
  6603. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6604. // removeOnly is a special flag used only by <transition-group>
  6605. // to ensure removed elements stay in correct relative positions
  6606. // during leaving transitions
  6607. const canMove = !removeOnly;
  6608. {
  6609. checkDuplicateKeys(newCh);
  6610. }
  6611. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6612. if (isUndef(oldStartVnode)) {
  6613. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6614. }
  6615. else if (isUndef(oldEndVnode)) {
  6616. oldEndVnode = oldCh[--oldEndIdx];
  6617. }
  6618. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6619. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6620. oldStartVnode = oldCh[++oldStartIdx];
  6621. newStartVnode = newCh[++newStartIdx];
  6622. }
  6623. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6624. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6625. oldEndVnode = oldCh[--oldEndIdx];
  6626. newEndVnode = newCh[--newEndIdx];
  6627. }
  6628. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6629. // Vnode moved right
  6630. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6631. canMove &&
  6632. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6633. oldStartVnode = oldCh[++oldStartIdx];
  6634. newEndVnode = newCh[--newEndIdx];
  6635. }
  6636. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6637. // Vnode moved left
  6638. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6639. canMove &&
  6640. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6641. oldEndVnode = oldCh[--oldEndIdx];
  6642. newStartVnode = newCh[++newStartIdx];
  6643. }
  6644. else {
  6645. if (isUndef(oldKeyToIdx))
  6646. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6647. idxInOld = isDef(newStartVnode.key)
  6648. ? oldKeyToIdx[newStartVnode.key]
  6649. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6650. if (isUndef(idxInOld)) {
  6651. // New element
  6652. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6653. }
  6654. else {
  6655. vnodeToMove = oldCh[idxInOld];
  6656. if (sameVnode(vnodeToMove, newStartVnode)) {
  6657. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6658. oldCh[idxInOld] = undefined;
  6659. canMove &&
  6660. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6661. }
  6662. else {
  6663. // same key but different element. treat as new element
  6664. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6665. }
  6666. }
  6667. newStartVnode = newCh[++newStartIdx];
  6668. }
  6669. }
  6670. if (oldStartIdx > oldEndIdx) {
  6671. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6672. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6673. }
  6674. else if (newStartIdx > newEndIdx) {
  6675. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6676. }
  6677. }
  6678. function checkDuplicateKeys(children) {
  6679. const seenKeys = {};
  6680. for (let i = 0; i < children.length; i++) {
  6681. const vnode = children[i];
  6682. const key = vnode.key;
  6683. if (isDef(key)) {
  6684. if (seenKeys[key]) {
  6685. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6686. }
  6687. else {
  6688. seenKeys[key] = true;
  6689. }
  6690. }
  6691. }
  6692. }
  6693. function findIdxInOld(node, oldCh, start, end) {
  6694. for (let i = start; i < end; i++) {
  6695. const c = oldCh[i];
  6696. if (isDef(c) && sameVnode(node, c))
  6697. return i;
  6698. }
  6699. }
  6700. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6701. if (oldVnode === vnode) {
  6702. return;
  6703. }
  6704. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6705. // clone reused vnode
  6706. vnode = ownerArray[index] = cloneVNode(vnode);
  6707. }
  6708. const elm = (vnode.elm = oldVnode.elm);
  6709. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6710. if (isDef(vnode.asyncFactory.resolved)) {
  6711. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6712. }
  6713. else {
  6714. vnode.isAsyncPlaceholder = true;
  6715. }
  6716. return;
  6717. }
  6718. // reuse element for static trees.
  6719. // note we only do this if the vnode is cloned -
  6720. // if the new node is not cloned it means the render functions have been
  6721. // reset by the hot-reload-api and we need to do a proper re-render.
  6722. if (isTrue(vnode.isStatic) &&
  6723. isTrue(oldVnode.isStatic) &&
  6724. vnode.key === oldVnode.key &&
  6725. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6726. vnode.componentInstance = oldVnode.componentInstance;
  6727. return;
  6728. }
  6729. let i;
  6730. const data = vnode.data;
  6731. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6732. i(oldVnode, vnode);
  6733. }
  6734. const oldCh = oldVnode.children;
  6735. const ch = vnode.children;
  6736. if (isDef(data) && isPatchable(vnode)) {
  6737. for (i = 0; i < cbs.update.length; ++i)
  6738. cbs.update[i](oldVnode, vnode);
  6739. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6740. i(oldVnode, vnode);
  6741. }
  6742. if (isUndef(vnode.text)) {
  6743. if (isDef(oldCh) && isDef(ch)) {
  6744. if (oldCh !== ch)
  6745. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6746. }
  6747. else if (isDef(ch)) {
  6748. {
  6749. checkDuplicateKeys(ch);
  6750. }
  6751. if (isDef(oldVnode.text))
  6752. nodeOps.setTextContent(elm, '');
  6753. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6754. }
  6755. else if (isDef(oldCh)) {
  6756. removeVnodes(oldCh, 0, oldCh.length - 1);
  6757. }
  6758. else if (isDef(oldVnode.text)) {
  6759. nodeOps.setTextContent(elm, '');
  6760. }
  6761. }
  6762. else if (oldVnode.text !== vnode.text) {
  6763. nodeOps.setTextContent(elm, vnode.text);
  6764. }
  6765. if (isDef(data)) {
  6766. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6767. i(oldVnode, vnode);
  6768. }
  6769. }
  6770. function invokeInsertHook(vnode, queue, initial) {
  6771. // delay insert hooks for component root nodes, invoke them after the
  6772. // element is really inserted
  6773. if (isTrue(initial) && isDef(vnode.parent)) {
  6774. vnode.parent.data.pendingInsert = queue;
  6775. }
  6776. else {
  6777. for (let i = 0; i < queue.length; ++i) {
  6778. queue[i].data.hook.insert(queue[i]);
  6779. }
  6780. }
  6781. }
  6782. let hydrationBailed = false;
  6783. // list of modules that can skip create hook during hydration because they
  6784. // are already rendered on the client or has no need for initialization
  6785. // Note: style is excluded because it relies on initial clone for future
  6786. // deep updates (#7063).
  6787. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6788. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6789. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6790. let i;
  6791. const { tag, data, children } = vnode;
  6792. inVPre = inVPre || (data && data.pre);
  6793. vnode.elm = elm;
  6794. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6795. vnode.isAsyncPlaceholder = true;
  6796. return true;
  6797. }
  6798. // assert node match
  6799. {
  6800. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6801. return false;
  6802. }
  6803. }
  6804. if (isDef(data)) {
  6805. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6806. i(vnode, true /* hydrating */);
  6807. if (isDef((i = vnode.componentInstance))) {
  6808. // child component. it should have hydrated its own tree.
  6809. initComponent(vnode, insertedVnodeQueue);
  6810. return true;
  6811. }
  6812. }
  6813. if (isDef(tag)) {
  6814. if (isDef(children)) {
  6815. // empty element, allow client to pick up and populate children
  6816. if (!elm.hasChildNodes()) {
  6817. createChildren(vnode, children, insertedVnodeQueue);
  6818. }
  6819. else {
  6820. // v-html and domProps: innerHTML
  6821. if (isDef((i = data)) &&
  6822. isDef((i = i.domProps)) &&
  6823. isDef((i = i.innerHTML))) {
  6824. if (i !== elm.innerHTML) {
  6825. /* istanbul ignore if */
  6826. if (typeof console !== 'undefined' &&
  6827. !hydrationBailed) {
  6828. hydrationBailed = true;
  6829. console.warn('Parent: ', elm);
  6830. console.warn('server innerHTML: ', i);
  6831. console.warn('client innerHTML: ', elm.innerHTML);
  6832. }
  6833. return false;
  6834. }
  6835. }
  6836. else {
  6837. // iterate and compare children lists
  6838. let childrenMatch = true;
  6839. let childNode = elm.firstChild;
  6840. for (let i = 0; i < children.length; i++) {
  6841. if (!childNode ||
  6842. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6843. childrenMatch = false;
  6844. break;
  6845. }
  6846. childNode = childNode.nextSibling;
  6847. }
  6848. // if childNode is not null, it means the actual childNodes list is
  6849. // longer than the virtual children list.
  6850. if (!childrenMatch || childNode) {
  6851. /* istanbul ignore if */
  6852. if (typeof console !== 'undefined' &&
  6853. !hydrationBailed) {
  6854. hydrationBailed = true;
  6855. console.warn('Parent: ', elm);
  6856. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6857. }
  6858. return false;
  6859. }
  6860. }
  6861. }
  6862. }
  6863. if (isDef(data)) {
  6864. let fullInvoke = false;
  6865. for (const key in data) {
  6866. if (!isRenderedModule(key)) {
  6867. fullInvoke = true;
  6868. invokeCreateHooks(vnode, insertedVnodeQueue);
  6869. break;
  6870. }
  6871. }
  6872. if (!fullInvoke && data['class']) {
  6873. // ensure collecting deps for deep class bindings for future updates
  6874. traverse(data['class']);
  6875. }
  6876. }
  6877. }
  6878. else if (elm.data !== vnode.text) {
  6879. elm.data = vnode.text;
  6880. }
  6881. return true;
  6882. }
  6883. function assertNodeMatch(node, vnode, inVPre) {
  6884. if (isDef(vnode.tag)) {
  6885. return (vnode.tag.indexOf('vue-component') === 0 ||
  6886. (!isUnknownElement(vnode, inVPre) &&
  6887. vnode.tag.toLowerCase() ===
  6888. (node.tagName && node.tagName.toLowerCase())));
  6889. }
  6890. else {
  6891. return node.nodeType === (vnode.isComment ? 8 : 3);
  6892. }
  6893. }
  6894. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6895. if (isUndef(vnode)) {
  6896. if (isDef(oldVnode))
  6897. invokeDestroyHook(oldVnode);
  6898. return;
  6899. }
  6900. let isInitialPatch = false;
  6901. const insertedVnodeQueue = [];
  6902. if (isUndef(oldVnode)) {
  6903. // empty mount (likely as component), create new root element
  6904. isInitialPatch = true;
  6905. createElm(vnode, insertedVnodeQueue);
  6906. }
  6907. else {
  6908. const isRealElement = isDef(oldVnode.nodeType);
  6909. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6910. // patch existing root node
  6911. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6912. }
  6913. else {
  6914. if (isRealElement) {
  6915. // mounting to a real element
  6916. // check if this is server-rendered content and if we can perform
  6917. // a successful hydration.
  6918. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6919. oldVnode.removeAttribute(SSR_ATTR);
  6920. hydrating = true;
  6921. }
  6922. if (isTrue(hydrating)) {
  6923. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6924. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6925. return oldVnode;
  6926. }
  6927. else {
  6928. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6929. 'server-rendered content. This is likely caused by incorrect ' +
  6930. 'HTML markup, for example nesting block-level elements inside ' +
  6931. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6932. 'full client-side render.');
  6933. }
  6934. }
  6935. // either not server-rendered, or hydration failed.
  6936. // create an empty node and replace it
  6937. oldVnode = emptyNodeAt(oldVnode);
  6938. }
  6939. // replacing existing element
  6940. const oldElm = oldVnode.elm;
  6941. const parentElm = nodeOps.parentNode(oldElm);
  6942. // create new node
  6943. createElm(vnode, insertedVnodeQueue,
  6944. // extremely rare edge case: do not insert if old element is in a
  6945. // leaving transition. Only happens when combining transition +
  6946. // keep-alive + HOCs. (#4590)
  6947. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6948. // update parent placeholder node element, recursively
  6949. if (isDef(vnode.parent)) {
  6950. let ancestor = vnode.parent;
  6951. const patchable = isPatchable(vnode);
  6952. while (ancestor) {
  6953. for (let i = 0; i < cbs.destroy.length; ++i) {
  6954. cbs.destroy[i](ancestor);
  6955. }
  6956. ancestor.elm = vnode.elm;
  6957. if (patchable) {
  6958. for (let i = 0; i < cbs.create.length; ++i) {
  6959. cbs.create[i](emptyNode, ancestor);
  6960. }
  6961. // #6513
  6962. // invoke insert hooks that may have been merged by create hooks.
  6963. // e.g. for directives that uses the "inserted" hook.
  6964. const insert = ancestor.data.hook.insert;
  6965. if (insert.merged) {
  6966. // start at index 1 to avoid re-invoking component mounted hook
  6967. for (let i = 1; i < insert.fns.length; i++) {
  6968. insert.fns[i]();
  6969. }
  6970. }
  6971. }
  6972. else {
  6973. registerRef(ancestor);
  6974. }
  6975. ancestor = ancestor.parent;
  6976. }
  6977. }
  6978. // destroy old node
  6979. if (isDef(parentElm)) {
  6980. removeVnodes([oldVnode], 0, 0);
  6981. }
  6982. else if (isDef(oldVnode.tag)) {
  6983. invokeDestroyHook(oldVnode);
  6984. }
  6985. }
  6986. }
  6987. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6988. return vnode.elm;
  6989. };
  6990. }
  6991. var directives$1 = {
  6992. create: updateDirectives,
  6993. update: updateDirectives,
  6994. destroy: function unbindDirectives(vnode) {
  6995. // @ts-expect-error emptyNode is not VNodeWithData
  6996. updateDirectives(vnode, emptyNode);
  6997. }
  6998. };
  6999. function updateDirectives(oldVnode, vnode) {
  7000. if (oldVnode.data.directives || vnode.data.directives) {
  7001. _update(oldVnode, vnode);
  7002. }
  7003. }
  7004. function _update(oldVnode, vnode) {
  7005. const isCreate = oldVnode === emptyNode;
  7006. const isDestroy = vnode === emptyNode;
  7007. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7008. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7009. const dirsWithInsert = [];
  7010. const dirsWithPostpatch = [];
  7011. let key, oldDir, dir;
  7012. for (key in newDirs) {
  7013. oldDir = oldDirs[key];
  7014. dir = newDirs[key];
  7015. if (!oldDir) {
  7016. // new directive, bind
  7017. callHook(dir, 'bind', vnode, oldVnode);
  7018. if (dir.def && dir.def.inserted) {
  7019. dirsWithInsert.push(dir);
  7020. }
  7021. }
  7022. else {
  7023. // existing directive, update
  7024. dir.oldValue = oldDir.value;
  7025. dir.oldArg = oldDir.arg;
  7026. callHook(dir, 'update', vnode, oldVnode);
  7027. if (dir.def && dir.def.componentUpdated) {
  7028. dirsWithPostpatch.push(dir);
  7029. }
  7030. }
  7031. }
  7032. if (dirsWithInsert.length) {
  7033. const callInsert = () => {
  7034. for (let i = 0; i < dirsWithInsert.length; i++) {
  7035. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7036. }
  7037. };
  7038. if (isCreate) {
  7039. mergeVNodeHook(vnode, 'insert', callInsert);
  7040. }
  7041. else {
  7042. callInsert();
  7043. }
  7044. }
  7045. if (dirsWithPostpatch.length) {
  7046. mergeVNodeHook(vnode, 'postpatch', () => {
  7047. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7048. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7049. }
  7050. });
  7051. }
  7052. if (!isCreate) {
  7053. for (key in oldDirs) {
  7054. if (!newDirs[key]) {
  7055. // no longer present, unbind
  7056. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7057. }
  7058. }
  7059. }
  7060. }
  7061. const emptyModifiers = Object.create(null);
  7062. function normalizeDirectives(dirs, vm) {
  7063. const res = Object.create(null);
  7064. if (!dirs) {
  7065. // $flow-disable-line
  7066. return res;
  7067. }
  7068. let i, dir;
  7069. for (i = 0; i < dirs.length; i++) {
  7070. dir = dirs[i];
  7071. if (!dir.modifiers) {
  7072. // $flow-disable-line
  7073. dir.modifiers = emptyModifiers;
  7074. }
  7075. res[getRawDirName(dir)] = dir;
  7076. if (vm._setupState && vm._setupState.__sfc) {
  7077. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7078. if (typeof setupDef === 'function') {
  7079. dir.def = {
  7080. bind: setupDef,
  7081. update: setupDef,
  7082. };
  7083. }
  7084. else {
  7085. dir.def = setupDef;
  7086. }
  7087. }
  7088. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7089. }
  7090. // $flow-disable-line
  7091. return res;
  7092. }
  7093. function getRawDirName(dir) {
  7094. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7095. }
  7096. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7097. const fn = dir.def && dir.def[hook];
  7098. if (fn) {
  7099. try {
  7100. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7101. }
  7102. catch (e) {
  7103. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7104. }
  7105. }
  7106. }
  7107. var baseModules = [ref, directives$1];
  7108. function updateAttrs(oldVnode, vnode) {
  7109. const opts = vnode.componentOptions;
  7110. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7111. return;
  7112. }
  7113. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7114. return;
  7115. }
  7116. let key, cur, old;
  7117. const elm = vnode.elm;
  7118. const oldAttrs = oldVnode.data.attrs || {};
  7119. let attrs = vnode.data.attrs || {};
  7120. // clone observed objects, as the user probably wants to mutate it
  7121. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7122. attrs = vnode.data.attrs = extend({}, attrs);
  7123. }
  7124. for (key in attrs) {
  7125. cur = attrs[key];
  7126. old = oldAttrs[key];
  7127. if (old !== cur) {
  7128. setAttr(elm, key, cur, vnode.data.pre);
  7129. }
  7130. }
  7131. // #4391: in IE9, setting type can reset value for input[type=radio]
  7132. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7133. /* istanbul ignore if */
  7134. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7135. setAttr(elm, 'value', attrs.value);
  7136. }
  7137. for (key in oldAttrs) {
  7138. if (isUndef(attrs[key])) {
  7139. if (isXlink(key)) {
  7140. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7141. }
  7142. else if (!isEnumeratedAttr(key)) {
  7143. elm.removeAttribute(key);
  7144. }
  7145. }
  7146. }
  7147. }
  7148. function setAttr(el, key, value, isInPre) {
  7149. if (isInPre || el.tagName.indexOf('-') > -1) {
  7150. baseSetAttr(el, key, value);
  7151. }
  7152. else if (isBooleanAttr(key)) {
  7153. // set attribute for blank value
  7154. // e.g. <option disabled>Select one</option>
  7155. if (isFalsyAttrValue(value)) {
  7156. el.removeAttribute(key);
  7157. }
  7158. else {
  7159. // technically allowfullscreen is a boolean attribute for <iframe>,
  7160. // but Flash expects a value of "true" when used on <embed> tag
  7161. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7162. el.setAttribute(key, value);
  7163. }
  7164. }
  7165. else if (isEnumeratedAttr(key)) {
  7166. el.setAttribute(key, convertEnumeratedValue(key, value));
  7167. }
  7168. else if (isXlink(key)) {
  7169. if (isFalsyAttrValue(value)) {
  7170. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7171. }
  7172. else {
  7173. el.setAttributeNS(xlinkNS, key, value);
  7174. }
  7175. }
  7176. else {
  7177. baseSetAttr(el, key, value);
  7178. }
  7179. }
  7180. function baseSetAttr(el, key, value) {
  7181. if (isFalsyAttrValue(value)) {
  7182. el.removeAttribute(key);
  7183. }
  7184. else {
  7185. // #7138: IE10 & 11 fires input event when setting placeholder on
  7186. // <textarea>... block the first input event and remove the blocker
  7187. // immediately.
  7188. /* istanbul ignore if */
  7189. if (isIE &&
  7190. !isIE9 &&
  7191. el.tagName === 'TEXTAREA' &&
  7192. key === 'placeholder' &&
  7193. value !== '' &&
  7194. !el.__ieph) {
  7195. const blocker = e => {
  7196. e.stopImmediatePropagation();
  7197. el.removeEventListener('input', blocker);
  7198. };
  7199. el.addEventListener('input', blocker);
  7200. // $flow-disable-line
  7201. el.__ieph = true; /* IE placeholder patched */
  7202. }
  7203. el.setAttribute(key, value);
  7204. }
  7205. }
  7206. var attrs = {
  7207. create: updateAttrs,
  7208. update: updateAttrs
  7209. };
  7210. function updateClass(oldVnode, vnode) {
  7211. const el = vnode.elm;
  7212. const data = vnode.data;
  7213. const oldData = oldVnode.data;
  7214. if (isUndef(data.staticClass) &&
  7215. isUndef(data.class) &&
  7216. (isUndef(oldData) ||
  7217. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7218. return;
  7219. }
  7220. let cls = genClassForVnode(vnode);
  7221. // handle transition classes
  7222. const transitionClass = el._transitionClasses;
  7223. if (isDef(transitionClass)) {
  7224. cls = concat(cls, stringifyClass(transitionClass));
  7225. }
  7226. // set the class
  7227. if (cls !== el._prevClass) {
  7228. el.setAttribute('class', cls);
  7229. el._prevClass = cls;
  7230. }
  7231. }
  7232. var klass$1 = {
  7233. create: updateClass,
  7234. update: updateClass
  7235. };
  7236. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7237. function parseFilters(exp) {
  7238. let inSingle = false;
  7239. let inDouble = false;
  7240. let inTemplateString = false;
  7241. let inRegex = false;
  7242. let curly = 0;
  7243. let square = 0;
  7244. let paren = 0;
  7245. let lastFilterIndex = 0;
  7246. let c, prev, i, expression, filters;
  7247. for (i = 0; i < exp.length; i++) {
  7248. prev = c;
  7249. c = exp.charCodeAt(i);
  7250. if (inSingle) {
  7251. if (c === 0x27 && prev !== 0x5c)
  7252. inSingle = false;
  7253. }
  7254. else if (inDouble) {
  7255. if (c === 0x22 && prev !== 0x5c)
  7256. inDouble = false;
  7257. }
  7258. else if (inTemplateString) {
  7259. if (c === 0x60 && prev !== 0x5c)
  7260. inTemplateString = false;
  7261. }
  7262. else if (inRegex) {
  7263. if (c === 0x2f && prev !== 0x5c)
  7264. inRegex = false;
  7265. }
  7266. else if (c === 0x7c && // pipe
  7267. exp.charCodeAt(i + 1) !== 0x7c &&
  7268. exp.charCodeAt(i - 1) !== 0x7c &&
  7269. !curly &&
  7270. !square &&
  7271. !paren) {
  7272. if (expression === undefined) {
  7273. // first filter, end of expression
  7274. lastFilterIndex = i + 1;
  7275. expression = exp.slice(0, i).trim();
  7276. }
  7277. else {
  7278. pushFilter();
  7279. }
  7280. }
  7281. else {
  7282. switch (c) {
  7283. case 0x22:
  7284. inDouble = true;
  7285. break; // "
  7286. case 0x27:
  7287. inSingle = true;
  7288. break; // '
  7289. case 0x60:
  7290. inTemplateString = true;
  7291. break; // `
  7292. case 0x28:
  7293. paren++;
  7294. break; // (
  7295. case 0x29:
  7296. paren--;
  7297. break; // )
  7298. case 0x5b:
  7299. square++;
  7300. break; // [
  7301. case 0x5d:
  7302. square--;
  7303. break; // ]
  7304. case 0x7b:
  7305. curly++;
  7306. break; // {
  7307. case 0x7d:
  7308. curly--;
  7309. break; // }
  7310. }
  7311. if (c === 0x2f) {
  7312. // /
  7313. let j = i - 1;
  7314. let p;
  7315. // find first non-whitespace prev char
  7316. for (; j >= 0; j--) {
  7317. p = exp.charAt(j);
  7318. if (p !== ' ')
  7319. break;
  7320. }
  7321. if (!p || !validDivisionCharRE.test(p)) {
  7322. inRegex = true;
  7323. }
  7324. }
  7325. }
  7326. }
  7327. if (expression === undefined) {
  7328. expression = exp.slice(0, i).trim();
  7329. }
  7330. else if (lastFilterIndex !== 0) {
  7331. pushFilter();
  7332. }
  7333. function pushFilter() {
  7334. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7335. lastFilterIndex = i + 1;
  7336. }
  7337. if (filters) {
  7338. for (i = 0; i < filters.length; i++) {
  7339. expression = wrapFilter(expression, filters[i]);
  7340. }
  7341. }
  7342. return expression;
  7343. }
  7344. function wrapFilter(exp, filter) {
  7345. const i = filter.indexOf('(');
  7346. if (i < 0) {
  7347. // _f: resolveFilter
  7348. return `_f("${filter}")(${exp})`;
  7349. }
  7350. else {
  7351. const name = filter.slice(0, i);
  7352. const args = filter.slice(i + 1);
  7353. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7354. }
  7355. }
  7356. /* eslint-disable no-unused-vars */
  7357. function baseWarn(msg, range) {
  7358. console.error(`[Vue compiler]: ${msg}`);
  7359. }
  7360. /* eslint-enable no-unused-vars */
  7361. function pluckModuleFunction(modules, key) {
  7362. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7363. }
  7364. function addProp(el, name, value, range, dynamic) {
  7365. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7366. el.plain = false;
  7367. }
  7368. function addAttr(el, name, value, range, dynamic) {
  7369. const attrs = dynamic
  7370. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7371. : el.attrs || (el.attrs = []);
  7372. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7373. el.plain = false;
  7374. }
  7375. // add a raw attr (use this in preTransforms)
  7376. function addRawAttr(el, name, value, range) {
  7377. el.attrsMap[name] = value;
  7378. el.attrsList.push(rangeSetItem({ name, value }, range));
  7379. }
  7380. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7381. (el.directives || (el.directives = [])).push(rangeSetItem({
  7382. name,
  7383. rawName,
  7384. value,
  7385. arg,
  7386. isDynamicArg,
  7387. modifiers
  7388. }, range));
  7389. el.plain = false;
  7390. }
  7391. function prependModifierMarker(symbol, name, dynamic) {
  7392. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7393. }
  7394. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7395. modifiers = modifiers || emptyObject;
  7396. // warn prevent and passive modifier
  7397. /* istanbul ignore if */
  7398. if (warn && modifiers.prevent && modifiers.passive) {
  7399. warn("passive and prevent can't be used together. " +
  7400. "Passive handler can't prevent default event.", range);
  7401. }
  7402. // normalize click.right and click.middle since they don't actually fire
  7403. // this is technically browser-specific, but at least for now browsers are
  7404. // the only target envs that have right/middle clicks.
  7405. if (modifiers.right) {
  7406. if (dynamic) {
  7407. name = `(${name})==='click'?'contextmenu':(${name})`;
  7408. }
  7409. else if (name === 'click') {
  7410. name = 'contextmenu';
  7411. delete modifiers.right;
  7412. }
  7413. }
  7414. else if (modifiers.middle) {
  7415. if (dynamic) {
  7416. name = `(${name})==='click'?'mouseup':(${name})`;
  7417. }
  7418. else if (name === 'click') {
  7419. name = 'mouseup';
  7420. }
  7421. }
  7422. // check capture modifier
  7423. if (modifiers.capture) {
  7424. delete modifiers.capture;
  7425. name = prependModifierMarker('!', name, dynamic);
  7426. }
  7427. if (modifiers.once) {
  7428. delete modifiers.once;
  7429. name = prependModifierMarker('~', name, dynamic);
  7430. }
  7431. /* istanbul ignore if */
  7432. if (modifiers.passive) {
  7433. delete modifiers.passive;
  7434. name = prependModifierMarker('&', name, dynamic);
  7435. }
  7436. let events;
  7437. if (modifiers.native) {
  7438. delete modifiers.native;
  7439. events = el.nativeEvents || (el.nativeEvents = {});
  7440. }
  7441. else {
  7442. events = el.events || (el.events = {});
  7443. }
  7444. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7445. if (modifiers !== emptyObject) {
  7446. newHandler.modifiers = modifiers;
  7447. }
  7448. const handlers = events[name];
  7449. /* istanbul ignore if */
  7450. if (Array.isArray(handlers)) {
  7451. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7452. }
  7453. else if (handlers) {
  7454. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7455. }
  7456. else {
  7457. events[name] = newHandler;
  7458. }
  7459. el.plain = false;
  7460. }
  7461. function getRawBindingAttr(el, name) {
  7462. return (el.rawAttrsMap[':' + name] ||
  7463. el.rawAttrsMap['v-bind:' + name] ||
  7464. el.rawAttrsMap[name]);
  7465. }
  7466. function getBindingAttr(el, name, getStatic) {
  7467. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7468. if (dynamicValue != null) {
  7469. return parseFilters(dynamicValue);
  7470. }
  7471. else if (getStatic !== false) {
  7472. const staticValue = getAndRemoveAttr(el, name);
  7473. if (staticValue != null) {
  7474. return JSON.stringify(staticValue);
  7475. }
  7476. }
  7477. }
  7478. // note: this only removes the attr from the Array (attrsList) so that it
  7479. // doesn't get processed by processAttrs.
  7480. // By default it does NOT remove it from the map (attrsMap) because the map is
  7481. // needed during codegen.
  7482. function getAndRemoveAttr(el, name, removeFromMap) {
  7483. let val;
  7484. if ((val = el.attrsMap[name]) != null) {
  7485. const list = el.attrsList;
  7486. for (let i = 0, l = list.length; i < l; i++) {
  7487. if (list[i].name === name) {
  7488. list.splice(i, 1);
  7489. break;
  7490. }
  7491. }
  7492. }
  7493. if (removeFromMap) {
  7494. delete el.attrsMap[name];
  7495. }
  7496. return val;
  7497. }
  7498. function getAndRemoveAttrByRegex(el, name) {
  7499. const list = el.attrsList;
  7500. for (let i = 0, l = list.length; i < l; i++) {
  7501. const attr = list[i];
  7502. if (name.test(attr.name)) {
  7503. list.splice(i, 1);
  7504. return attr;
  7505. }
  7506. }
  7507. }
  7508. function rangeSetItem(item, range) {
  7509. if (range) {
  7510. if (range.start != null) {
  7511. item.start = range.start;
  7512. }
  7513. if (range.end != null) {
  7514. item.end = range.end;
  7515. }
  7516. }
  7517. return item;
  7518. }
  7519. /**
  7520. * Cross-platform code generation for component v-model
  7521. */
  7522. function genComponentModel(el, value, modifiers) {
  7523. const { number, trim } = modifiers || {};
  7524. const baseValueExpression = '$$v';
  7525. let valueExpression = baseValueExpression;
  7526. if (trim) {
  7527. valueExpression =
  7528. `(typeof ${baseValueExpression} === 'string'` +
  7529. `? ${baseValueExpression}.trim()` +
  7530. `: ${baseValueExpression})`;
  7531. }
  7532. if (number) {
  7533. valueExpression = `_n(${valueExpression})`;
  7534. }
  7535. const assignment = genAssignmentCode(value, valueExpression);
  7536. el.model = {
  7537. value: `(${value})`,
  7538. expression: JSON.stringify(value),
  7539. callback: `function (${baseValueExpression}) {${assignment}}`
  7540. };
  7541. }
  7542. /**
  7543. * Cross-platform codegen helper for generating v-model value assignment code.
  7544. */
  7545. function genAssignmentCode(value, assignment) {
  7546. const res = parseModel(value);
  7547. if (res.key === null) {
  7548. return `${value}=${assignment}`;
  7549. }
  7550. else {
  7551. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7552. }
  7553. }
  7554. /**
  7555. * Parse a v-model expression into a base path and a final key segment.
  7556. * Handles both dot-path and possible square brackets.
  7557. *
  7558. * Possible cases:
  7559. *
  7560. * - test
  7561. * - test[key]
  7562. * - test[test1[key]]
  7563. * - test["a"][key]
  7564. * - xxx.test[a[a].test1[key]]
  7565. * - test.xxx.a["asa"][test1[key]]
  7566. *
  7567. */
  7568. let len, str, chr, index, expressionPos, expressionEndPos;
  7569. function parseModel(val) {
  7570. // Fix https://github.com/vuejs/vue/pull/7730
  7571. // allow v-model="obj.val " (trailing whitespace)
  7572. val = val.trim();
  7573. len = val.length;
  7574. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7575. index = val.lastIndexOf('.');
  7576. if (index > -1) {
  7577. return {
  7578. exp: val.slice(0, index),
  7579. key: '"' + val.slice(index + 1) + '"'
  7580. };
  7581. }
  7582. else {
  7583. return {
  7584. exp: val,
  7585. key: null
  7586. };
  7587. }
  7588. }
  7589. str = val;
  7590. index = expressionPos = expressionEndPos = 0;
  7591. while (!eof()) {
  7592. chr = next();
  7593. /* istanbul ignore if */
  7594. if (isStringStart(chr)) {
  7595. parseString(chr);
  7596. }
  7597. else if (chr === 0x5b) {
  7598. parseBracket(chr);
  7599. }
  7600. }
  7601. return {
  7602. exp: val.slice(0, expressionPos),
  7603. key: val.slice(expressionPos + 1, expressionEndPos)
  7604. };
  7605. }
  7606. function next() {
  7607. return str.charCodeAt(++index);
  7608. }
  7609. function eof() {
  7610. return index >= len;
  7611. }
  7612. function isStringStart(chr) {
  7613. return chr === 0x22 || chr === 0x27;
  7614. }
  7615. function parseBracket(chr) {
  7616. let inBracket = 1;
  7617. expressionPos = index;
  7618. while (!eof()) {
  7619. chr = next();
  7620. if (isStringStart(chr)) {
  7621. parseString(chr);
  7622. continue;
  7623. }
  7624. if (chr === 0x5b)
  7625. inBracket++;
  7626. if (chr === 0x5d)
  7627. inBracket--;
  7628. if (inBracket === 0) {
  7629. expressionEndPos = index;
  7630. break;
  7631. }
  7632. }
  7633. }
  7634. function parseString(chr) {
  7635. const stringQuote = chr;
  7636. while (!eof()) {
  7637. chr = next();
  7638. if (chr === stringQuote) {
  7639. break;
  7640. }
  7641. }
  7642. }
  7643. let warn$1;
  7644. // in some cases, the event used has to be determined at runtime
  7645. // so we used some reserved tokens during compile.
  7646. const RANGE_TOKEN = '__r';
  7647. const CHECKBOX_RADIO_TOKEN = '__c';
  7648. function model$1(el, dir, _warn) {
  7649. warn$1 = _warn;
  7650. const value = dir.value;
  7651. const modifiers = dir.modifiers;
  7652. const tag = el.tag;
  7653. const type = el.attrsMap.type;
  7654. {
  7655. // inputs with type="file" are read only and setting the input's
  7656. // value will throw an error.
  7657. if (tag === 'input' && type === 'file') {
  7658. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7659. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7660. }
  7661. }
  7662. if (el.component) {
  7663. genComponentModel(el, value, modifiers);
  7664. // component v-model doesn't need extra runtime
  7665. return false;
  7666. }
  7667. else if (tag === 'select') {
  7668. genSelect(el, value, modifiers);
  7669. }
  7670. else if (tag === 'input' && type === 'checkbox') {
  7671. genCheckboxModel(el, value, modifiers);
  7672. }
  7673. else if (tag === 'input' && type === 'radio') {
  7674. genRadioModel(el, value, modifiers);
  7675. }
  7676. else if (tag === 'input' || tag === 'textarea') {
  7677. genDefaultModel(el, value, modifiers);
  7678. }
  7679. else if (!config.isReservedTag(tag)) {
  7680. genComponentModel(el, value, modifiers);
  7681. // component v-model doesn't need extra runtime
  7682. return false;
  7683. }
  7684. else {
  7685. warn$1(`<${el.tag} v-model="${value}">: ` +
  7686. `v-model is not supported on this element type. ` +
  7687. "If you are working with contenteditable, it's recommended to " +
  7688. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7689. }
  7690. // ensure runtime directive metadata
  7691. return true;
  7692. }
  7693. function genCheckboxModel(el, value, modifiers) {
  7694. const number = modifiers && modifiers.number;
  7695. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7696. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7697. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7698. addProp(el, 'checked', `Array.isArray(${value})` +
  7699. `?_i(${value},${valueBinding})>-1` +
  7700. (trueValueBinding === 'true'
  7701. ? `:(${value})`
  7702. : `:_q(${value},${trueValueBinding})`));
  7703. addHandler(el, 'change', `var $$a=${value},` +
  7704. '$$el=$event.target,' +
  7705. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7706. 'if(Array.isArray($$a)){' +
  7707. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7708. '$$i=_i($$a,$$v);' +
  7709. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7710. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7711. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7712. }
  7713. function genRadioModel(el, value, modifiers) {
  7714. const number = modifiers && modifiers.number;
  7715. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7716. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7717. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7718. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7719. }
  7720. function genSelect(el, value, modifiers) {
  7721. const number = modifiers && modifiers.number;
  7722. const selectedVal = `Array.prototype.filter` +
  7723. `.call($event.target.options,function(o){return o.selected})` +
  7724. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7725. `return ${number ? '_n(val)' : 'val'}})`;
  7726. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7727. let code = `var $$selectedVal = ${selectedVal};`;
  7728. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7729. addHandler(el, 'change', code, null, true);
  7730. }
  7731. function genDefaultModel(el, value, modifiers) {
  7732. const type = el.attrsMap.type;
  7733. // warn if v-bind:value conflicts with v-model
  7734. // except for inputs with v-bind:type
  7735. {
  7736. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7737. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7738. if (value && !typeBinding) {
  7739. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7740. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7741. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7742. }
  7743. }
  7744. const { lazy, number, trim } = modifiers || {};
  7745. const needCompositionGuard = !lazy && type !== 'range';
  7746. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7747. let valueExpression = '$event.target.value';
  7748. if (trim) {
  7749. valueExpression = `$event.target.value.trim()`;
  7750. }
  7751. if (number) {
  7752. valueExpression = `_n(${valueExpression})`;
  7753. }
  7754. let code = genAssignmentCode(value, valueExpression);
  7755. if (needCompositionGuard) {
  7756. code = `if($event.target.composing)return;${code}`;
  7757. }
  7758. addProp(el, 'value', `(${value})`);
  7759. addHandler(el, event, code, null, true);
  7760. if (trim || number) {
  7761. addHandler(el, 'blur', '$forceUpdate()');
  7762. }
  7763. }
  7764. // normalize v-model event tokens that can only be determined at runtime.
  7765. // it's important to place the event as the first in the array because
  7766. // the whole point is ensuring the v-model callback gets called before
  7767. // user-attached handlers.
  7768. function normalizeEvents(on) {
  7769. /* istanbul ignore if */
  7770. if (isDef(on[RANGE_TOKEN])) {
  7771. // IE input[type=range] only supports `change` event
  7772. const event = isIE ? 'change' : 'input';
  7773. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7774. delete on[RANGE_TOKEN];
  7775. }
  7776. // This was originally intended to fix #4521 but no longer necessary
  7777. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7778. /* istanbul ignore if */
  7779. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7780. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7781. delete on[CHECKBOX_RADIO_TOKEN];
  7782. }
  7783. }
  7784. let target;
  7785. function createOnceHandler(event, handler, capture) {
  7786. const _target = target; // save current target element in closure
  7787. return function onceHandler() {
  7788. const res = handler.apply(null, arguments);
  7789. if (res !== null) {
  7790. remove(event, onceHandler, capture, _target);
  7791. }
  7792. };
  7793. }
  7794. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7795. // implementation and does not fire microtasks in between event propagation, so
  7796. // safe to exclude.
  7797. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7798. function add(name, handler, capture, passive) {
  7799. // async edge case #6566: inner click event triggers patch, event handler
  7800. // attached to outer element during patch, and triggered again. This
  7801. // happens because browsers fire microtask ticks between event propagation.
  7802. // the solution is simple: we save the timestamp when a handler is attached,
  7803. // and the handler would only fire if the event passed to it was fired
  7804. // AFTER it was attached.
  7805. if (useMicrotaskFix) {
  7806. const attachedTimestamp = currentFlushTimestamp;
  7807. const original = handler;
  7808. //@ts-expect-error
  7809. handler = original._wrapper = function (e) {
  7810. if (
  7811. // no bubbling, should always fire.
  7812. // this is just a safety net in case event.timeStamp is unreliable in
  7813. // certain weird environments...
  7814. e.target === e.currentTarget ||
  7815. // event is fired after handler attachment
  7816. e.timeStamp >= attachedTimestamp ||
  7817. // bail for environments that have buggy event.timeStamp implementations
  7818. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7819. // #9681 QtWebEngine event.timeStamp is negative value
  7820. e.timeStamp <= 0 ||
  7821. // #9448 bail if event is fired in another document in a multi-page
  7822. // electron/nw.js app, since event.timeStamp will be using a different
  7823. // starting reference
  7824. e.target.ownerDocument !== document) {
  7825. return original.apply(this, arguments);
  7826. }
  7827. };
  7828. }
  7829. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7830. }
  7831. function remove(name, handler, capture, _target) {
  7832. (_target || target).removeEventListener(name,
  7833. //@ts-expect-error
  7834. handler._wrapper || handler, capture);
  7835. }
  7836. function updateDOMListeners(oldVnode, vnode) {
  7837. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7838. return;
  7839. }
  7840. const on = vnode.data.on || {};
  7841. const oldOn = oldVnode.data.on || {};
  7842. // vnode is empty when removing all listeners,
  7843. // and use old vnode dom element
  7844. target = vnode.elm || oldVnode.elm;
  7845. normalizeEvents(on);
  7846. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7847. target = undefined;
  7848. }
  7849. var events = {
  7850. create: updateDOMListeners,
  7851. update: updateDOMListeners,
  7852. // @ts-expect-error emptyNode has actually data
  7853. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7854. };
  7855. let svgContainer;
  7856. function updateDOMProps(oldVnode, vnode) {
  7857. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7858. return;
  7859. }
  7860. let key, cur;
  7861. const elm = vnode.elm;
  7862. const oldProps = oldVnode.data.domProps || {};
  7863. let props = vnode.data.domProps || {};
  7864. // clone observed objects, as the user probably wants to mutate it
  7865. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7866. props = vnode.data.domProps = extend({}, props);
  7867. }
  7868. for (key in oldProps) {
  7869. if (!(key in props)) {
  7870. elm[key] = '';
  7871. }
  7872. }
  7873. for (key in props) {
  7874. cur = props[key];
  7875. // ignore children if the node has textContent or innerHTML,
  7876. // as these will throw away existing DOM nodes and cause removal errors
  7877. // on subsequent patches (#3360)
  7878. if (key === 'textContent' || key === 'innerHTML') {
  7879. if (vnode.children)
  7880. vnode.children.length = 0;
  7881. if (cur === oldProps[key])
  7882. continue;
  7883. // #6601 work around Chrome version <= 55 bug where single textNode
  7884. // replaced by innerHTML/textContent retains its parentNode property
  7885. if (elm.childNodes.length === 1) {
  7886. elm.removeChild(elm.childNodes[0]);
  7887. }
  7888. }
  7889. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7890. // store value as _value as well since
  7891. // non-string values will be stringified
  7892. elm._value = cur;
  7893. // avoid resetting cursor position when value is the same
  7894. const strCur = isUndef(cur) ? '' : String(cur);
  7895. if (shouldUpdateValue(elm, strCur)) {
  7896. elm.value = strCur;
  7897. }
  7898. }
  7899. else if (key === 'innerHTML' &&
  7900. isSVG(elm.tagName) &&
  7901. isUndef(elm.innerHTML)) {
  7902. // IE doesn't support innerHTML for SVG elements
  7903. svgContainer = svgContainer || document.createElement('div');
  7904. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7905. const svg = svgContainer.firstChild;
  7906. while (elm.firstChild) {
  7907. elm.removeChild(elm.firstChild);
  7908. }
  7909. while (svg.firstChild) {
  7910. elm.appendChild(svg.firstChild);
  7911. }
  7912. }
  7913. else if (
  7914. // skip the update if old and new VDOM state is the same.
  7915. // `value` is handled separately because the DOM value may be temporarily
  7916. // out of sync with VDOM state due to focus, composition and modifiers.
  7917. // This #4521 by skipping the unnecessary `checked` update.
  7918. cur !== oldProps[key]) {
  7919. // some property updates can throw
  7920. // e.g. `value` on <progress> w/ non-finite value
  7921. try {
  7922. elm[key] = cur;
  7923. }
  7924. catch (e) { }
  7925. }
  7926. }
  7927. }
  7928. function shouldUpdateValue(elm, checkVal) {
  7929. return (
  7930. //@ts-expect-error
  7931. !elm.composing &&
  7932. (elm.tagName === 'OPTION' ||
  7933. isNotInFocusAndDirty(elm, checkVal) ||
  7934. isDirtyWithModifiers(elm, checkVal)));
  7935. }
  7936. function isNotInFocusAndDirty(elm, checkVal) {
  7937. // return true when textbox (.number and .trim) loses focus and its value is
  7938. // not equal to the updated value
  7939. let notInFocus = true;
  7940. // #6157
  7941. // work around IE bug when accessing document.activeElement in an iframe
  7942. try {
  7943. notInFocus = document.activeElement !== elm;
  7944. }
  7945. catch (e) { }
  7946. return notInFocus && elm.value !== checkVal;
  7947. }
  7948. function isDirtyWithModifiers(elm, newVal) {
  7949. const value = elm.value;
  7950. const modifiers = elm._vModifiers; // injected by v-model runtime
  7951. if (isDef(modifiers)) {
  7952. if (modifiers.number) {
  7953. return toNumber(value) !== toNumber(newVal);
  7954. }
  7955. if (modifiers.trim) {
  7956. return value.trim() !== newVal.trim();
  7957. }
  7958. }
  7959. return value !== newVal;
  7960. }
  7961. var domProps = {
  7962. create: updateDOMProps,
  7963. update: updateDOMProps
  7964. };
  7965. const parseStyleText = cached(function (cssText) {
  7966. const res = {};
  7967. const listDelimiter = /;(?![^(]*\))/g;
  7968. const propertyDelimiter = /:(.+)/;
  7969. cssText.split(listDelimiter).forEach(function (item) {
  7970. if (item) {
  7971. const tmp = item.split(propertyDelimiter);
  7972. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7973. }
  7974. });
  7975. return res;
  7976. });
  7977. // merge static and dynamic style data on the same vnode
  7978. function normalizeStyleData(data) {
  7979. const style = normalizeStyleBinding(data.style);
  7980. // static style is pre-processed into an object during compilation
  7981. // and is always a fresh object, so it's safe to merge into it
  7982. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7983. }
  7984. // normalize possible array / string values into Object
  7985. function normalizeStyleBinding(bindingStyle) {
  7986. if (Array.isArray(bindingStyle)) {
  7987. return toObject(bindingStyle);
  7988. }
  7989. if (typeof bindingStyle === 'string') {
  7990. return parseStyleText(bindingStyle);
  7991. }
  7992. return bindingStyle;
  7993. }
  7994. /**
  7995. * parent component style should be after child's
  7996. * so that parent component's style could override it
  7997. */
  7998. function getStyle(vnode, checkChild) {
  7999. const res = {};
  8000. let styleData;
  8001. if (checkChild) {
  8002. let childNode = vnode;
  8003. while (childNode.componentInstance) {
  8004. childNode = childNode.componentInstance._vnode;
  8005. if (childNode &&
  8006. childNode.data &&
  8007. (styleData = normalizeStyleData(childNode.data))) {
  8008. extend(res, styleData);
  8009. }
  8010. }
  8011. }
  8012. if ((styleData = normalizeStyleData(vnode.data))) {
  8013. extend(res, styleData);
  8014. }
  8015. let parentNode = vnode;
  8016. // @ts-expect-error parentNode.parent not VNodeWithData
  8017. while ((parentNode = parentNode.parent)) {
  8018. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  8019. extend(res, styleData);
  8020. }
  8021. }
  8022. return res;
  8023. }
  8024. const cssVarRE = /^--/;
  8025. const importantRE = /\s*!important$/;
  8026. const setProp = (el, name, val) => {
  8027. /* istanbul ignore if */
  8028. if (cssVarRE.test(name)) {
  8029. el.style.setProperty(name, val);
  8030. }
  8031. else if (importantRE.test(val)) {
  8032. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8033. }
  8034. else {
  8035. const normalizedName = normalize(name);
  8036. if (Array.isArray(val)) {
  8037. // Support values array created by autoprefixer, e.g.
  8038. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8039. // Set them one by one, and the browser will only set those it can recognize
  8040. for (let i = 0, len = val.length; i < len; i++) {
  8041. el.style[normalizedName] = val[i];
  8042. }
  8043. }
  8044. else {
  8045. el.style[normalizedName] = val;
  8046. }
  8047. }
  8048. };
  8049. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8050. let emptyStyle;
  8051. const normalize = cached(function (prop) {
  8052. emptyStyle = emptyStyle || document.createElement('div').style;
  8053. prop = camelize(prop);
  8054. if (prop !== 'filter' && prop in emptyStyle) {
  8055. return prop;
  8056. }
  8057. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8058. for (let i = 0; i < vendorNames.length; i++) {
  8059. const name = vendorNames[i] + capName;
  8060. if (name in emptyStyle) {
  8061. return name;
  8062. }
  8063. }
  8064. });
  8065. function updateStyle(oldVnode, vnode) {
  8066. const data = vnode.data;
  8067. const oldData = oldVnode.data;
  8068. if (isUndef(data.staticStyle) &&
  8069. isUndef(data.style) &&
  8070. isUndef(oldData.staticStyle) &&
  8071. isUndef(oldData.style)) {
  8072. return;
  8073. }
  8074. let cur, name;
  8075. const el = vnode.elm;
  8076. const oldStaticStyle = oldData.staticStyle;
  8077. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8078. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8079. const oldStyle = oldStaticStyle || oldStyleBinding;
  8080. const style = normalizeStyleBinding(vnode.data.style) || {};
  8081. // store normalized style under a different key for next diff
  8082. // make sure to clone it if it's reactive, since the user likely wants
  8083. // to mutate it.
  8084. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8085. const newStyle = getStyle(vnode, true);
  8086. for (name in oldStyle) {
  8087. if (isUndef(newStyle[name])) {
  8088. setProp(el, name, '');
  8089. }
  8090. }
  8091. for (name in newStyle) {
  8092. cur = newStyle[name];
  8093. if (cur !== oldStyle[name]) {
  8094. // ie9 setting to null has no effect, must use empty string
  8095. setProp(el, name, cur == null ? '' : cur);
  8096. }
  8097. }
  8098. }
  8099. var style$1 = {
  8100. create: updateStyle,
  8101. update: updateStyle
  8102. };
  8103. const whitespaceRE$1 = /\s+/;
  8104. /**
  8105. * Add class with compatibility for SVG since classList is not supported on
  8106. * SVG elements in IE
  8107. */
  8108. function addClass(el, cls) {
  8109. /* istanbul ignore if */
  8110. if (!cls || !(cls = cls.trim())) {
  8111. return;
  8112. }
  8113. /* istanbul ignore else */
  8114. if (el.classList) {
  8115. if (cls.indexOf(' ') > -1) {
  8116. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8117. }
  8118. else {
  8119. el.classList.add(cls);
  8120. }
  8121. }
  8122. else {
  8123. const cur = ` ${el.getAttribute('class') || ''} `;
  8124. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8125. el.setAttribute('class', (cur + cls).trim());
  8126. }
  8127. }
  8128. }
  8129. /**
  8130. * Remove class with compatibility for SVG since classList is not supported on
  8131. * SVG elements in IE
  8132. */
  8133. function removeClass(el, cls) {
  8134. /* istanbul ignore if */
  8135. if (!cls || !(cls = cls.trim())) {
  8136. return;
  8137. }
  8138. /* istanbul ignore else */
  8139. if (el.classList) {
  8140. if (cls.indexOf(' ') > -1) {
  8141. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8142. }
  8143. else {
  8144. el.classList.remove(cls);
  8145. }
  8146. if (!el.classList.length) {
  8147. el.removeAttribute('class');
  8148. }
  8149. }
  8150. else {
  8151. let cur = ` ${el.getAttribute('class') || ''} `;
  8152. const tar = ' ' + cls + ' ';
  8153. while (cur.indexOf(tar) >= 0) {
  8154. cur = cur.replace(tar, ' ');
  8155. }
  8156. cur = cur.trim();
  8157. if (cur) {
  8158. el.setAttribute('class', cur);
  8159. }
  8160. else {
  8161. el.removeAttribute('class');
  8162. }
  8163. }
  8164. }
  8165. function resolveTransition(def) {
  8166. if (!def) {
  8167. return;
  8168. }
  8169. /* istanbul ignore else */
  8170. if (typeof def === 'object') {
  8171. const res = {};
  8172. if (def.css !== false) {
  8173. extend(res, autoCssTransition(def.name || 'v'));
  8174. }
  8175. extend(res, def);
  8176. return res;
  8177. }
  8178. else if (typeof def === 'string') {
  8179. return autoCssTransition(def);
  8180. }
  8181. }
  8182. const autoCssTransition = cached(name => {
  8183. return {
  8184. enterClass: `${name}-enter`,
  8185. enterToClass: `${name}-enter-to`,
  8186. enterActiveClass: `${name}-enter-active`,
  8187. leaveClass: `${name}-leave`,
  8188. leaveToClass: `${name}-leave-to`,
  8189. leaveActiveClass: `${name}-leave-active`
  8190. };
  8191. });
  8192. const hasTransition = inBrowser && !isIE9;
  8193. const TRANSITION = 'transition';
  8194. const ANIMATION = 'animation';
  8195. // Transition property/event sniffing
  8196. let transitionProp = 'transition';
  8197. let transitionEndEvent = 'transitionend';
  8198. let animationProp = 'animation';
  8199. let animationEndEvent = 'animationend';
  8200. if (hasTransition) {
  8201. /* istanbul ignore if */
  8202. if (window.ontransitionend === undefined &&
  8203. window.onwebkittransitionend !== undefined) {
  8204. transitionProp = 'WebkitTransition';
  8205. transitionEndEvent = 'webkitTransitionEnd';
  8206. }
  8207. if (window.onanimationend === undefined &&
  8208. window.onwebkitanimationend !== undefined) {
  8209. animationProp = 'WebkitAnimation';
  8210. animationEndEvent = 'webkitAnimationEnd';
  8211. }
  8212. }
  8213. // binding to window is necessary to make hot reload work in IE in strict mode
  8214. const raf = inBrowser
  8215. ? window.requestAnimationFrame
  8216. ? window.requestAnimationFrame.bind(window)
  8217. : setTimeout
  8218. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8219. function nextFrame(fn) {
  8220. raf(() => {
  8221. // @ts-expect-error
  8222. raf(fn);
  8223. });
  8224. }
  8225. function addTransitionClass(el, cls) {
  8226. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8227. if (transitionClasses.indexOf(cls) < 0) {
  8228. transitionClasses.push(cls);
  8229. addClass(el, cls);
  8230. }
  8231. }
  8232. function removeTransitionClass(el, cls) {
  8233. if (el._transitionClasses) {
  8234. remove$2(el._transitionClasses, cls);
  8235. }
  8236. removeClass(el, cls);
  8237. }
  8238. function whenTransitionEnds(el, expectedType, cb) {
  8239. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8240. if (!type)
  8241. return cb();
  8242. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8243. let ended = 0;
  8244. const end = () => {
  8245. el.removeEventListener(event, onEnd);
  8246. cb();
  8247. };
  8248. const onEnd = e => {
  8249. if (e.target === el) {
  8250. if (++ended >= propCount) {
  8251. end();
  8252. }
  8253. }
  8254. };
  8255. setTimeout(() => {
  8256. if (ended < propCount) {
  8257. end();
  8258. }
  8259. }, timeout + 1);
  8260. el.addEventListener(event, onEnd);
  8261. }
  8262. const transformRE = /\b(transform|all)(,|$)/;
  8263. function getTransitionInfo(el, expectedType) {
  8264. const styles = window.getComputedStyle(el);
  8265. // JSDOM may return undefined for transition properties
  8266. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8267. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8268. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8269. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8270. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8271. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8272. let type;
  8273. let timeout = 0;
  8274. let propCount = 0;
  8275. /* istanbul ignore if */
  8276. if (expectedType === TRANSITION) {
  8277. if (transitionTimeout > 0) {
  8278. type = TRANSITION;
  8279. timeout = transitionTimeout;
  8280. propCount = transitionDurations.length;
  8281. }
  8282. }
  8283. else if (expectedType === ANIMATION) {
  8284. if (animationTimeout > 0) {
  8285. type = ANIMATION;
  8286. timeout = animationTimeout;
  8287. propCount = animationDurations.length;
  8288. }
  8289. }
  8290. else {
  8291. timeout = Math.max(transitionTimeout, animationTimeout);
  8292. type =
  8293. timeout > 0
  8294. ? transitionTimeout > animationTimeout
  8295. ? TRANSITION
  8296. : ANIMATION
  8297. : null;
  8298. propCount = type
  8299. ? type === TRANSITION
  8300. ? transitionDurations.length
  8301. : animationDurations.length
  8302. : 0;
  8303. }
  8304. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8305. return {
  8306. type,
  8307. timeout,
  8308. propCount,
  8309. hasTransform
  8310. };
  8311. }
  8312. function getTimeout(delays, durations) {
  8313. /* istanbul ignore next */
  8314. while (delays.length < durations.length) {
  8315. delays = delays.concat(delays);
  8316. }
  8317. return Math.max.apply(null, durations.map((d, i) => {
  8318. return toMs(d) + toMs(delays[i]);
  8319. }));
  8320. }
  8321. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8322. // in a locale-dependent way, using a comma instead of a dot.
  8323. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8324. // as a floor function) causing unexpected behaviors
  8325. function toMs(s) {
  8326. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8327. }
  8328. function enter(vnode, toggleDisplay) {
  8329. const el = vnode.elm;
  8330. // call leave callback now
  8331. if (isDef(el._leaveCb)) {
  8332. el._leaveCb.cancelled = true;
  8333. el._leaveCb();
  8334. }
  8335. const data = resolveTransition(vnode.data.transition);
  8336. if (isUndef(data)) {
  8337. return;
  8338. }
  8339. /* istanbul ignore if */
  8340. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8341. return;
  8342. }
  8343. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8344. // activeInstance will always be the <transition> component managing this
  8345. // transition. One edge case to check is when the <transition> is placed
  8346. // as the root node of a child component. In that case we need to check
  8347. // <transition>'s parent for appear check.
  8348. let context = activeInstance;
  8349. let transitionNode = activeInstance.$vnode;
  8350. while (transitionNode && transitionNode.parent) {
  8351. context = transitionNode.context;
  8352. transitionNode = transitionNode.parent;
  8353. }
  8354. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8355. if (isAppear && !appear && appear !== '') {
  8356. return;
  8357. }
  8358. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8359. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8360. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8361. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8362. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8363. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8364. const enterCancelledHook = isAppear
  8365. ? appearCancelled || enterCancelled
  8366. : enterCancelled;
  8367. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8368. if (explicitEnterDuration != null) {
  8369. checkDuration(explicitEnterDuration, 'enter', vnode);
  8370. }
  8371. const expectsCSS = css !== false && !isIE9;
  8372. const userWantsControl = getHookArgumentsLength(enterHook);
  8373. const cb = (el._enterCb = once(() => {
  8374. if (expectsCSS) {
  8375. removeTransitionClass(el, toClass);
  8376. removeTransitionClass(el, activeClass);
  8377. }
  8378. // @ts-expect-error
  8379. if (cb.cancelled) {
  8380. if (expectsCSS) {
  8381. removeTransitionClass(el, startClass);
  8382. }
  8383. enterCancelledHook && enterCancelledHook(el);
  8384. }
  8385. else {
  8386. afterEnterHook && afterEnterHook(el);
  8387. }
  8388. el._enterCb = null;
  8389. }));
  8390. if (!vnode.data.show) {
  8391. // remove pending leave element on enter by injecting an insert hook
  8392. mergeVNodeHook(vnode, 'insert', () => {
  8393. const parent = el.parentNode;
  8394. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8395. if (pendingNode &&
  8396. pendingNode.tag === vnode.tag &&
  8397. pendingNode.elm._leaveCb) {
  8398. pendingNode.elm._leaveCb();
  8399. }
  8400. enterHook && enterHook(el, cb);
  8401. });
  8402. }
  8403. // start enter transition
  8404. beforeEnterHook && beforeEnterHook(el);
  8405. if (expectsCSS) {
  8406. addTransitionClass(el, startClass);
  8407. addTransitionClass(el, activeClass);
  8408. nextFrame(() => {
  8409. removeTransitionClass(el, startClass);
  8410. // @ts-expect-error
  8411. if (!cb.cancelled) {
  8412. addTransitionClass(el, toClass);
  8413. if (!userWantsControl) {
  8414. if (isValidDuration(explicitEnterDuration)) {
  8415. setTimeout(cb, explicitEnterDuration);
  8416. }
  8417. else {
  8418. whenTransitionEnds(el, type, cb);
  8419. }
  8420. }
  8421. }
  8422. });
  8423. }
  8424. if (vnode.data.show) {
  8425. toggleDisplay && toggleDisplay();
  8426. enterHook && enterHook(el, cb);
  8427. }
  8428. if (!expectsCSS && !userWantsControl) {
  8429. cb();
  8430. }
  8431. }
  8432. function leave(vnode, rm) {
  8433. const el = vnode.elm;
  8434. // call enter callback now
  8435. if (isDef(el._enterCb)) {
  8436. el._enterCb.cancelled = true;
  8437. el._enterCb();
  8438. }
  8439. const data = resolveTransition(vnode.data.transition);
  8440. if (isUndef(data) || el.nodeType !== 1) {
  8441. return rm();
  8442. }
  8443. /* istanbul ignore if */
  8444. if (isDef(el._leaveCb)) {
  8445. return;
  8446. }
  8447. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8448. const expectsCSS = css !== false && !isIE9;
  8449. const userWantsControl = getHookArgumentsLength(leave);
  8450. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8451. if (isDef(explicitLeaveDuration)) {
  8452. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8453. }
  8454. const cb = (el._leaveCb = once(() => {
  8455. if (el.parentNode && el.parentNode._pending) {
  8456. el.parentNode._pending[vnode.key] = null;
  8457. }
  8458. if (expectsCSS) {
  8459. removeTransitionClass(el, leaveToClass);
  8460. removeTransitionClass(el, leaveActiveClass);
  8461. }
  8462. // @ts-expect-error
  8463. if (cb.cancelled) {
  8464. if (expectsCSS) {
  8465. removeTransitionClass(el, leaveClass);
  8466. }
  8467. leaveCancelled && leaveCancelled(el);
  8468. }
  8469. else {
  8470. rm();
  8471. afterLeave && afterLeave(el);
  8472. }
  8473. el._leaveCb = null;
  8474. }));
  8475. if (delayLeave) {
  8476. delayLeave(performLeave);
  8477. }
  8478. else {
  8479. performLeave();
  8480. }
  8481. function performLeave() {
  8482. // the delayed leave may have already been cancelled
  8483. // @ts-expect-error
  8484. if (cb.cancelled) {
  8485. return;
  8486. }
  8487. // record leaving element
  8488. if (!vnode.data.show && el.parentNode) {
  8489. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8490. vnode;
  8491. }
  8492. beforeLeave && beforeLeave(el);
  8493. if (expectsCSS) {
  8494. addTransitionClass(el, leaveClass);
  8495. addTransitionClass(el, leaveActiveClass);
  8496. nextFrame(() => {
  8497. removeTransitionClass(el, leaveClass);
  8498. // @ts-expect-error
  8499. if (!cb.cancelled) {
  8500. addTransitionClass(el, leaveToClass);
  8501. if (!userWantsControl) {
  8502. if (isValidDuration(explicitLeaveDuration)) {
  8503. setTimeout(cb, explicitLeaveDuration);
  8504. }
  8505. else {
  8506. whenTransitionEnds(el, type, cb);
  8507. }
  8508. }
  8509. }
  8510. });
  8511. }
  8512. leave && leave(el, cb);
  8513. if (!expectsCSS && !userWantsControl) {
  8514. cb();
  8515. }
  8516. }
  8517. }
  8518. // only used in dev mode
  8519. function checkDuration(val, name, vnode) {
  8520. if (typeof val !== 'number') {
  8521. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8522. `got ${JSON.stringify(val)}.`, vnode.context);
  8523. }
  8524. else if (isNaN(val)) {
  8525. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8526. 'the duration expression might be incorrect.', vnode.context);
  8527. }
  8528. }
  8529. function isValidDuration(val) {
  8530. return typeof val === 'number' && !isNaN(val);
  8531. }
  8532. /**
  8533. * Normalize a transition hook's argument length. The hook may be:
  8534. * - a merged hook (invoker) with the original in .fns
  8535. * - a wrapped component method (check ._length)
  8536. * - a plain function (.length)
  8537. */
  8538. function getHookArgumentsLength(fn) {
  8539. if (isUndef(fn)) {
  8540. return false;
  8541. }
  8542. // @ts-expect-error
  8543. const invokerFns = fn.fns;
  8544. if (isDef(invokerFns)) {
  8545. // invoker
  8546. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8547. }
  8548. else {
  8549. // @ts-expect-error
  8550. return (fn._length || fn.length) > 1;
  8551. }
  8552. }
  8553. function _enter(_, vnode) {
  8554. if (vnode.data.show !== true) {
  8555. enter(vnode);
  8556. }
  8557. }
  8558. var transition = inBrowser
  8559. ? {
  8560. create: _enter,
  8561. activate: _enter,
  8562. remove(vnode, rm) {
  8563. /* istanbul ignore else */
  8564. if (vnode.data.show !== true) {
  8565. // @ts-expect-error
  8566. leave(vnode, rm);
  8567. }
  8568. else {
  8569. rm();
  8570. }
  8571. }
  8572. }
  8573. : {};
  8574. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8575. // the directive module should be applied last, after all
  8576. // built-in modules have been applied.
  8577. const modules$1 = platformModules.concat(baseModules);
  8578. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8579. /**
  8580. * Not type checking this file because flow doesn't like attaching
  8581. * properties to Elements.
  8582. */
  8583. /* istanbul ignore if */
  8584. if (isIE9) {
  8585. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8586. document.addEventListener('selectionchange', () => {
  8587. const el = document.activeElement;
  8588. // @ts-expect-error
  8589. if (el && el.vmodel) {
  8590. trigger(el, 'input');
  8591. }
  8592. });
  8593. }
  8594. const directive = {
  8595. inserted(el, binding, vnode, oldVnode) {
  8596. if (vnode.tag === 'select') {
  8597. // #6903
  8598. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8599. mergeVNodeHook(vnode, 'postpatch', () => {
  8600. directive.componentUpdated(el, binding, vnode);
  8601. });
  8602. }
  8603. else {
  8604. setSelected(el, binding, vnode.context);
  8605. }
  8606. el._vOptions = [].map.call(el.options, getValue);
  8607. }
  8608. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8609. el._vModifiers = binding.modifiers;
  8610. if (!binding.modifiers.lazy) {
  8611. el.addEventListener('compositionstart', onCompositionStart);
  8612. el.addEventListener('compositionend', onCompositionEnd);
  8613. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8614. // switching focus before confirming composition choice
  8615. // this also fixes the issue where some browsers e.g. iOS Chrome
  8616. // fires "change" instead of "input" on autocomplete.
  8617. el.addEventListener('change', onCompositionEnd);
  8618. /* istanbul ignore if */
  8619. if (isIE9) {
  8620. el.vmodel = true;
  8621. }
  8622. }
  8623. }
  8624. },
  8625. componentUpdated(el, binding, vnode) {
  8626. if (vnode.tag === 'select') {
  8627. setSelected(el, binding, vnode.context);
  8628. // in case the options rendered by v-for have changed,
  8629. // it's possible that the value is out-of-sync with the rendered options.
  8630. // detect such cases and filter out values that no longer has a matching
  8631. // option in the DOM.
  8632. const prevOptions = el._vOptions;
  8633. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8634. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8635. // trigger change event if
  8636. // no matching option found for at least one value
  8637. const needReset = el.multiple
  8638. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8639. : binding.value !== binding.oldValue &&
  8640. hasNoMatchingOption(binding.value, curOptions);
  8641. if (needReset) {
  8642. trigger(el, 'change');
  8643. }
  8644. }
  8645. }
  8646. }
  8647. };
  8648. function setSelected(el, binding, vm) {
  8649. actuallySetSelected(el, binding, vm);
  8650. /* istanbul ignore if */
  8651. if (isIE || isEdge) {
  8652. setTimeout(() => {
  8653. actuallySetSelected(el, binding, vm);
  8654. }, 0);
  8655. }
  8656. }
  8657. function actuallySetSelected(el, binding, vm) {
  8658. const value = binding.value;
  8659. const isMultiple = el.multiple;
  8660. if (isMultiple && !Array.isArray(value)) {
  8661. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8662. `expects an Array value for its binding, but got ${Object.prototype.toString
  8663. .call(value)
  8664. .slice(8, -1)}`, vm);
  8665. return;
  8666. }
  8667. let selected, option;
  8668. for (let i = 0, l = el.options.length; i < l; i++) {
  8669. option = el.options[i];
  8670. if (isMultiple) {
  8671. selected = looseIndexOf(value, getValue(option)) > -1;
  8672. if (option.selected !== selected) {
  8673. option.selected = selected;
  8674. }
  8675. }
  8676. else {
  8677. if (looseEqual(getValue(option), value)) {
  8678. if (el.selectedIndex !== i) {
  8679. el.selectedIndex = i;
  8680. }
  8681. return;
  8682. }
  8683. }
  8684. }
  8685. if (!isMultiple) {
  8686. el.selectedIndex = -1;
  8687. }
  8688. }
  8689. function hasNoMatchingOption(value, options) {
  8690. return options.every(o => !looseEqual(o, value));
  8691. }
  8692. function getValue(option) {
  8693. return '_value' in option ? option._value : option.value;
  8694. }
  8695. function onCompositionStart(e) {
  8696. e.target.composing = true;
  8697. }
  8698. function onCompositionEnd(e) {
  8699. // prevent triggering an input event for no reason
  8700. if (!e.target.composing)
  8701. return;
  8702. e.target.composing = false;
  8703. trigger(e.target, 'input');
  8704. }
  8705. function trigger(el, type) {
  8706. const e = document.createEvent('HTMLEvents');
  8707. e.initEvent(type, true, true);
  8708. el.dispatchEvent(e);
  8709. }
  8710. // recursively search for possible transition defined inside the component root
  8711. function locateNode(vnode) {
  8712. // @ts-expect-error
  8713. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8714. ? locateNode(vnode.componentInstance._vnode)
  8715. : vnode;
  8716. }
  8717. var show = {
  8718. bind(el, { value }, vnode) {
  8719. vnode = locateNode(vnode);
  8720. const transition = vnode.data && vnode.data.transition;
  8721. const originalDisplay = (el.__vOriginalDisplay =
  8722. el.style.display === 'none' ? '' : el.style.display);
  8723. if (value && transition) {
  8724. vnode.data.show = true;
  8725. enter(vnode, () => {
  8726. el.style.display = originalDisplay;
  8727. });
  8728. }
  8729. else {
  8730. el.style.display = value ? originalDisplay : 'none';
  8731. }
  8732. },
  8733. update(el, { value, oldValue }, vnode) {
  8734. /* istanbul ignore if */
  8735. if (!value === !oldValue)
  8736. return;
  8737. vnode = locateNode(vnode);
  8738. const transition = vnode.data && vnode.data.transition;
  8739. if (transition) {
  8740. vnode.data.show = true;
  8741. if (value) {
  8742. enter(vnode, () => {
  8743. el.style.display = el.__vOriginalDisplay;
  8744. });
  8745. }
  8746. else {
  8747. leave(vnode, () => {
  8748. el.style.display = 'none';
  8749. });
  8750. }
  8751. }
  8752. else {
  8753. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8754. }
  8755. },
  8756. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8757. if (!isDestroy) {
  8758. el.style.display = el.__vOriginalDisplay;
  8759. }
  8760. }
  8761. };
  8762. var platformDirectives = {
  8763. model: directive,
  8764. show
  8765. };
  8766. // Provides transition support for a single element/component.
  8767. const transitionProps = {
  8768. name: String,
  8769. appear: Boolean,
  8770. css: Boolean,
  8771. mode: String,
  8772. type: String,
  8773. enterClass: String,
  8774. leaveClass: String,
  8775. enterToClass: String,
  8776. leaveToClass: String,
  8777. enterActiveClass: String,
  8778. leaveActiveClass: String,
  8779. appearClass: String,
  8780. appearActiveClass: String,
  8781. appearToClass: String,
  8782. duration: [Number, String, Object]
  8783. };
  8784. // in case the child is also an abstract component, e.g. <keep-alive>
  8785. // we want to recursively retrieve the real component to be rendered
  8786. function getRealChild(vnode) {
  8787. const compOptions = vnode && vnode.componentOptions;
  8788. if (compOptions && compOptions.Ctor.options.abstract) {
  8789. return getRealChild(getFirstComponentChild(compOptions.children));
  8790. }
  8791. else {
  8792. return vnode;
  8793. }
  8794. }
  8795. function extractTransitionData(comp) {
  8796. const data = {};
  8797. const options = comp.$options;
  8798. // props
  8799. for (const key in options.propsData) {
  8800. data[key] = comp[key];
  8801. }
  8802. // events.
  8803. // extract listeners and pass them directly to the transition methods
  8804. const listeners = options._parentListeners;
  8805. for (const key in listeners) {
  8806. data[camelize(key)] = listeners[key];
  8807. }
  8808. return data;
  8809. }
  8810. function placeholder(h, rawChild) {
  8811. // @ts-expect-error
  8812. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8813. return h('keep-alive', {
  8814. props: rawChild.componentOptions.propsData
  8815. });
  8816. }
  8817. }
  8818. function hasParentTransition(vnode) {
  8819. while ((vnode = vnode.parent)) {
  8820. if (vnode.data.transition) {
  8821. return true;
  8822. }
  8823. }
  8824. }
  8825. function isSameChild(child, oldChild) {
  8826. return oldChild.key === child.key && oldChild.tag === child.tag;
  8827. }
  8828. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8829. const isVShowDirective = d => d.name === 'show';
  8830. var Transition = {
  8831. name: 'transition',
  8832. props: transitionProps,
  8833. abstract: true,
  8834. render(h) {
  8835. let children = this.$slots.default;
  8836. if (!children) {
  8837. return;
  8838. }
  8839. // filter out text nodes (possible whitespaces)
  8840. children = children.filter(isNotTextNode);
  8841. /* istanbul ignore if */
  8842. if (!children.length) {
  8843. return;
  8844. }
  8845. // warn multiple elements
  8846. if (children.length > 1) {
  8847. warn$2('<transition> can only be used on a single element. Use ' +
  8848. '<transition-group> for lists.', this.$parent);
  8849. }
  8850. const mode = this.mode;
  8851. // warn invalid mode
  8852. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8853. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8854. }
  8855. const rawChild = children[0];
  8856. // if this is a component root node and the component's
  8857. // parent container node also has transition, skip.
  8858. if (hasParentTransition(this.$vnode)) {
  8859. return rawChild;
  8860. }
  8861. // apply transition data to child
  8862. // use getRealChild() to ignore abstract components e.g. keep-alive
  8863. const child = getRealChild(rawChild);
  8864. /* istanbul ignore if */
  8865. if (!child) {
  8866. return rawChild;
  8867. }
  8868. if (this._leaving) {
  8869. return placeholder(h, rawChild);
  8870. }
  8871. // ensure a key that is unique to the vnode type and to this transition
  8872. // component instance. This key will be used to remove pending leaving nodes
  8873. // during entering.
  8874. const id = `__transition-${this._uid}-`;
  8875. child.key =
  8876. child.key == null
  8877. ? child.isComment
  8878. ? id + 'comment'
  8879. : id + child.tag
  8880. : isPrimitive(child.key)
  8881. ? String(child.key).indexOf(id) === 0
  8882. ? child.key
  8883. : id + child.key
  8884. : child.key;
  8885. const data = ((child.data || (child.data = {})).transition =
  8886. extractTransitionData(this));
  8887. const oldRawChild = this._vnode;
  8888. const oldChild = getRealChild(oldRawChild);
  8889. // mark v-show
  8890. // so that the transition module can hand over the control to the directive
  8891. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8892. child.data.show = true;
  8893. }
  8894. if (oldChild &&
  8895. oldChild.data &&
  8896. !isSameChild(child, oldChild) &&
  8897. !isAsyncPlaceholder(oldChild) &&
  8898. // #6687 component root is a comment node
  8899. !(oldChild.componentInstance &&
  8900. oldChild.componentInstance._vnode.isComment)) {
  8901. // replace old child transition data with fresh one
  8902. // important for dynamic transitions!
  8903. const oldData = (oldChild.data.transition = extend({}, data));
  8904. // handle transition mode
  8905. if (mode === 'out-in') {
  8906. // return placeholder node and queue update when leave finishes
  8907. this._leaving = true;
  8908. mergeVNodeHook(oldData, 'afterLeave', () => {
  8909. this._leaving = false;
  8910. this.$forceUpdate();
  8911. });
  8912. return placeholder(h, rawChild);
  8913. }
  8914. else if (mode === 'in-out') {
  8915. if (isAsyncPlaceholder(child)) {
  8916. return oldRawChild;
  8917. }
  8918. let delayedLeave;
  8919. const performLeave = () => {
  8920. delayedLeave();
  8921. };
  8922. mergeVNodeHook(data, 'afterEnter', performLeave);
  8923. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8924. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8925. delayedLeave = leave;
  8926. });
  8927. }
  8928. }
  8929. return rawChild;
  8930. }
  8931. };
  8932. // Provides transition support for list items.
  8933. const props = extend({
  8934. tag: String,
  8935. moveClass: String
  8936. }, transitionProps);
  8937. delete props.mode;
  8938. var TransitionGroup = {
  8939. props,
  8940. beforeMount() {
  8941. const update = this._update;
  8942. this._update = (vnode, hydrating) => {
  8943. const restoreActiveInstance = setActiveInstance(this);
  8944. // force removing pass
  8945. this.__patch__(this._vnode, this.kept, false, // hydrating
  8946. true // removeOnly (!important, avoids unnecessary moves)
  8947. );
  8948. this._vnode = this.kept;
  8949. restoreActiveInstance();
  8950. update.call(this, vnode, hydrating);
  8951. };
  8952. },
  8953. render(h) {
  8954. const tag = this.tag || this.$vnode.data.tag || 'span';
  8955. const map = Object.create(null);
  8956. const prevChildren = (this.prevChildren = this.children);
  8957. const rawChildren = this.$slots.default || [];
  8958. const children = (this.children = []);
  8959. const transitionData = extractTransitionData(this);
  8960. for (let i = 0; i < rawChildren.length; i++) {
  8961. const c = rawChildren[i];
  8962. if (c.tag) {
  8963. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8964. children.push(c);
  8965. map[c.key] = c;
  8966. (c.data || (c.data = {})).transition = transitionData;
  8967. }
  8968. else {
  8969. const opts = c.componentOptions;
  8970. const name = opts
  8971. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8972. : c.tag;
  8973. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8974. }
  8975. }
  8976. }
  8977. if (prevChildren) {
  8978. const kept = [];
  8979. const removed = [];
  8980. for (let i = 0; i < prevChildren.length; i++) {
  8981. const c = prevChildren[i];
  8982. c.data.transition = transitionData;
  8983. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8984. c.data.pos = c.elm.getBoundingClientRect();
  8985. if (map[c.key]) {
  8986. kept.push(c);
  8987. }
  8988. else {
  8989. removed.push(c);
  8990. }
  8991. }
  8992. this.kept = h(tag, null, kept);
  8993. this.removed = removed;
  8994. }
  8995. return h(tag, null, children);
  8996. },
  8997. updated() {
  8998. const children = this.prevChildren;
  8999. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  9000. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  9001. return;
  9002. }
  9003. // we divide the work into three loops to avoid mixing DOM reads and writes
  9004. // in each iteration - which helps prevent layout thrashing.
  9005. children.forEach(callPendingCbs);
  9006. children.forEach(recordPosition);
  9007. children.forEach(applyTranslation);
  9008. // force reflow to put everything in position
  9009. // assign to this to avoid being removed in tree-shaking
  9010. // $flow-disable-line
  9011. this._reflow = document.body.offsetHeight;
  9012. children.forEach((c) => {
  9013. if (c.data.moved) {
  9014. const el = c.elm;
  9015. const s = el.style;
  9016. addTransitionClass(el, moveClass);
  9017. s.transform = s.WebkitTransform = s.transitionDuration = '';
  9018. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  9019. if (e && e.target !== el) {
  9020. return;
  9021. }
  9022. if (!e || /transform$/.test(e.propertyName)) {
  9023. el.removeEventListener(transitionEndEvent, cb);
  9024. el._moveCb = null;
  9025. removeTransitionClass(el, moveClass);
  9026. }
  9027. }));
  9028. }
  9029. });
  9030. },
  9031. methods: {
  9032. hasMove(el, moveClass) {
  9033. /* istanbul ignore if */
  9034. if (!hasTransition) {
  9035. return false;
  9036. }
  9037. /* istanbul ignore if */
  9038. if (this._hasMove) {
  9039. return this._hasMove;
  9040. }
  9041. // Detect whether an element with the move class applied has
  9042. // CSS transitions. Since the element may be inside an entering
  9043. // transition at this very moment, we make a clone of it and remove
  9044. // all other transition classes applied to ensure only the move class
  9045. // is applied.
  9046. const clone = el.cloneNode();
  9047. if (el._transitionClasses) {
  9048. el._transitionClasses.forEach((cls) => {
  9049. removeClass(clone, cls);
  9050. });
  9051. }
  9052. addClass(clone, moveClass);
  9053. clone.style.display = 'none';
  9054. this.$el.appendChild(clone);
  9055. const info = getTransitionInfo(clone);
  9056. this.$el.removeChild(clone);
  9057. return (this._hasMove = info.hasTransform);
  9058. }
  9059. }
  9060. };
  9061. function callPendingCbs(c) {
  9062. /* istanbul ignore if */
  9063. if (c.elm._moveCb) {
  9064. c.elm._moveCb();
  9065. }
  9066. /* istanbul ignore if */
  9067. if (c.elm._enterCb) {
  9068. c.elm._enterCb();
  9069. }
  9070. }
  9071. function recordPosition(c) {
  9072. c.data.newPos = c.elm.getBoundingClientRect();
  9073. }
  9074. function applyTranslation(c) {
  9075. const oldPos = c.data.pos;
  9076. const newPos = c.data.newPos;
  9077. const dx = oldPos.left - newPos.left;
  9078. const dy = oldPos.top - newPos.top;
  9079. if (dx || dy) {
  9080. c.data.moved = true;
  9081. const s = c.elm.style;
  9082. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9083. s.transitionDuration = '0s';
  9084. }
  9085. }
  9086. var platformComponents = {
  9087. Transition,
  9088. TransitionGroup
  9089. };
  9090. // install platform specific utils
  9091. Vue.config.mustUseProp = mustUseProp;
  9092. Vue.config.isReservedTag = isReservedTag;
  9093. Vue.config.isReservedAttr = isReservedAttr;
  9094. Vue.config.getTagNamespace = getTagNamespace;
  9095. Vue.config.isUnknownElement = isUnknownElement;
  9096. // install platform runtime directives & components
  9097. extend(Vue.options.directives, platformDirectives);
  9098. extend(Vue.options.components, platformComponents);
  9099. // install platform patch function
  9100. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9101. // public mount method
  9102. Vue.prototype.$mount = function (el, hydrating) {
  9103. el = el && inBrowser ? query(el) : undefined;
  9104. return mountComponent(this, el, hydrating);
  9105. };
  9106. // devtools global hook
  9107. /* istanbul ignore next */
  9108. if (inBrowser) {
  9109. setTimeout(() => {
  9110. if (config.devtools) {
  9111. if (devtools) {
  9112. devtools.emit('init', Vue);
  9113. }
  9114. else {
  9115. // @ts-expect-error
  9116. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9117. 'https://github.com/vuejs/vue-devtools');
  9118. }
  9119. }
  9120. if (config.productionTip !== false &&
  9121. typeof console !== 'undefined') {
  9122. // @ts-expect-error
  9123. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9124. `Make sure to turn on production mode when deploying for production.\n` +
  9125. `See more tips at https://vuejs.org/guide/deployment.html`);
  9126. }
  9127. }, 0);
  9128. }
  9129. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9130. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9131. const buildRegex = cached(delimiters => {
  9132. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9133. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9134. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9135. });
  9136. function parseText(text, delimiters) {
  9137. //@ts-expect-error
  9138. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9139. if (!tagRE.test(text)) {
  9140. return;
  9141. }
  9142. const tokens = [];
  9143. const rawTokens = [];
  9144. let lastIndex = (tagRE.lastIndex = 0);
  9145. let match, index, tokenValue;
  9146. while ((match = tagRE.exec(text))) {
  9147. index = match.index;
  9148. // push text token
  9149. if (index > lastIndex) {
  9150. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9151. tokens.push(JSON.stringify(tokenValue));
  9152. }
  9153. // tag token
  9154. const exp = parseFilters(match[1].trim());
  9155. tokens.push(`_s(${exp})`);
  9156. rawTokens.push({ '@binding': exp });
  9157. lastIndex = index + match[0].length;
  9158. }
  9159. if (lastIndex < text.length) {
  9160. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9161. tokens.push(JSON.stringify(tokenValue));
  9162. }
  9163. return {
  9164. expression: tokens.join('+'),
  9165. tokens: rawTokens
  9166. };
  9167. }
  9168. function transformNode$1(el, options) {
  9169. const warn = options.warn || baseWarn;
  9170. const staticClass = getAndRemoveAttr(el, 'class');
  9171. if (staticClass) {
  9172. const res = parseText(staticClass, options.delimiters);
  9173. if (res) {
  9174. warn(`class="${staticClass}": ` +
  9175. 'Interpolation inside attributes has been removed. ' +
  9176. 'Use v-bind or the colon shorthand instead. For example, ' +
  9177. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9178. }
  9179. }
  9180. if (staticClass) {
  9181. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9182. }
  9183. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9184. if (classBinding) {
  9185. el.classBinding = classBinding;
  9186. }
  9187. }
  9188. function genData$2(el) {
  9189. let data = '';
  9190. if (el.staticClass) {
  9191. data += `staticClass:${el.staticClass},`;
  9192. }
  9193. if (el.classBinding) {
  9194. data += `class:${el.classBinding},`;
  9195. }
  9196. return data;
  9197. }
  9198. var klass = {
  9199. staticKeys: ['staticClass'],
  9200. transformNode: transformNode$1,
  9201. genData: genData$2
  9202. };
  9203. function transformNode(el, options) {
  9204. const warn = options.warn || baseWarn;
  9205. const staticStyle = getAndRemoveAttr(el, 'style');
  9206. if (staticStyle) {
  9207. /* istanbul ignore if */
  9208. {
  9209. const res = parseText(staticStyle, options.delimiters);
  9210. if (res) {
  9211. warn(`style="${staticStyle}": ` +
  9212. 'Interpolation inside attributes has been removed. ' +
  9213. 'Use v-bind or the colon shorthand instead. For example, ' +
  9214. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9215. }
  9216. }
  9217. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9218. }
  9219. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9220. if (styleBinding) {
  9221. el.styleBinding = styleBinding;
  9222. }
  9223. }
  9224. function genData$1(el) {
  9225. let data = '';
  9226. if (el.staticStyle) {
  9227. data += `staticStyle:${el.staticStyle},`;
  9228. }
  9229. if (el.styleBinding) {
  9230. data += `style:(${el.styleBinding}),`;
  9231. }
  9232. return data;
  9233. }
  9234. var style = {
  9235. staticKeys: ['staticStyle'],
  9236. transformNode,
  9237. genData: genData$1
  9238. };
  9239. let decoder;
  9240. var he = {
  9241. decode(html) {
  9242. decoder = decoder || document.createElement('div');
  9243. decoder.innerHTML = html;
  9244. return decoder.textContent;
  9245. }
  9246. };
  9247. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9248. 'link,meta,param,source,track,wbr');
  9249. // Elements that you can, intentionally, leave open
  9250. // (and which close themselves)
  9251. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9252. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9253. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9254. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9255. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9256. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9257. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9258. 'title,tr,track');
  9259. /**
  9260. * Not type-checking this file because it's mostly vendor code.
  9261. */
  9262. // Regular Expressions for parsing tags and attributes
  9263. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9264. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9265. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9266. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9267. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9268. const startTagClose = /^\s*(\/?)>/;
  9269. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9270. const doctype = /^<!DOCTYPE [^>]+>/i;
  9271. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9272. const comment = /^<!\--/;
  9273. const conditionalComment = /^<!\[/;
  9274. // Special Elements (can contain anything)
  9275. const isPlainTextElement = makeMap('script,style,textarea', true);
  9276. const reCache = {};
  9277. const decodingMap = {
  9278. '&lt;': '<',
  9279. '&gt;': '>',
  9280. '&quot;': '"',
  9281. '&amp;': '&',
  9282. '&#10;': '\n',
  9283. '&#9;': '\t',
  9284. '&#39;': "'"
  9285. };
  9286. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9287. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9288. // #5992
  9289. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9290. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9291. function decodeAttr(value, shouldDecodeNewlines) {
  9292. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9293. return value.replace(re, match => decodingMap[match]);
  9294. }
  9295. function parseHTML(html, options) {
  9296. const stack = [];
  9297. const expectHTML = options.expectHTML;
  9298. const isUnaryTag = options.isUnaryTag || no;
  9299. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9300. let index = 0;
  9301. let last, lastTag;
  9302. while (html) {
  9303. last = html;
  9304. // Make sure we're not in a plaintext content element like script/style
  9305. if (!lastTag || !isPlainTextElement(lastTag)) {
  9306. let textEnd = html.indexOf('<');
  9307. if (textEnd === 0) {
  9308. // Comment:
  9309. if (comment.test(html)) {
  9310. const commentEnd = html.indexOf('-->');
  9311. if (commentEnd >= 0) {
  9312. if (options.shouldKeepComment && options.comment) {
  9313. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9314. }
  9315. advance(commentEnd + 3);
  9316. continue;
  9317. }
  9318. }
  9319. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9320. if (conditionalComment.test(html)) {
  9321. const conditionalEnd = html.indexOf(']>');
  9322. if (conditionalEnd >= 0) {
  9323. advance(conditionalEnd + 2);
  9324. continue;
  9325. }
  9326. }
  9327. // Doctype:
  9328. const doctypeMatch = html.match(doctype);
  9329. if (doctypeMatch) {
  9330. advance(doctypeMatch[0].length);
  9331. continue;
  9332. }
  9333. // End tag:
  9334. const endTagMatch = html.match(endTag);
  9335. if (endTagMatch) {
  9336. const curIndex = index;
  9337. advance(endTagMatch[0].length);
  9338. parseEndTag(endTagMatch[1], curIndex, index);
  9339. continue;
  9340. }
  9341. // Start tag:
  9342. const startTagMatch = parseStartTag();
  9343. if (startTagMatch) {
  9344. handleStartTag(startTagMatch);
  9345. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9346. advance(1);
  9347. }
  9348. continue;
  9349. }
  9350. }
  9351. let text, rest, next;
  9352. if (textEnd >= 0) {
  9353. rest = html.slice(textEnd);
  9354. while (!endTag.test(rest) &&
  9355. !startTagOpen.test(rest) &&
  9356. !comment.test(rest) &&
  9357. !conditionalComment.test(rest)) {
  9358. // < in plain text, be forgiving and treat it as text
  9359. next = rest.indexOf('<', 1);
  9360. if (next < 0)
  9361. break;
  9362. textEnd += next;
  9363. rest = html.slice(textEnd);
  9364. }
  9365. text = html.substring(0, textEnd);
  9366. }
  9367. if (textEnd < 0) {
  9368. text = html;
  9369. }
  9370. if (text) {
  9371. advance(text.length);
  9372. }
  9373. if (options.chars && text) {
  9374. options.chars(text, index - text.length, index);
  9375. }
  9376. }
  9377. else {
  9378. let endTagLength = 0;
  9379. const stackedTag = lastTag.toLowerCase();
  9380. const reStackedTag = reCache[stackedTag] ||
  9381. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9382. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9383. endTagLength = endTag.length;
  9384. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9385. text = text
  9386. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9387. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9388. }
  9389. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9390. text = text.slice(1);
  9391. }
  9392. if (options.chars) {
  9393. options.chars(text);
  9394. }
  9395. return '';
  9396. });
  9397. index += html.length - rest.length;
  9398. html = rest;
  9399. parseEndTag(stackedTag, index - endTagLength, index);
  9400. }
  9401. if (html === last) {
  9402. options.chars && options.chars(html);
  9403. if (!stack.length && options.warn) {
  9404. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9405. start: index + html.length
  9406. });
  9407. }
  9408. break;
  9409. }
  9410. }
  9411. // Clean up any remaining tags
  9412. parseEndTag();
  9413. function advance(n) {
  9414. index += n;
  9415. html = html.substring(n);
  9416. }
  9417. function parseStartTag() {
  9418. const start = html.match(startTagOpen);
  9419. if (start) {
  9420. const match = {
  9421. tagName: start[1],
  9422. attrs: [],
  9423. start: index
  9424. };
  9425. advance(start[0].length);
  9426. let end, attr;
  9427. while (!(end = html.match(startTagClose)) &&
  9428. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9429. attr.start = index;
  9430. advance(attr[0].length);
  9431. attr.end = index;
  9432. match.attrs.push(attr);
  9433. }
  9434. if (end) {
  9435. match.unarySlash = end[1];
  9436. advance(end[0].length);
  9437. match.end = index;
  9438. return match;
  9439. }
  9440. }
  9441. }
  9442. function handleStartTag(match) {
  9443. const tagName = match.tagName;
  9444. const unarySlash = match.unarySlash;
  9445. if (expectHTML) {
  9446. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9447. parseEndTag(lastTag);
  9448. }
  9449. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9450. parseEndTag(tagName);
  9451. }
  9452. }
  9453. const unary = isUnaryTag(tagName) || !!unarySlash;
  9454. const l = match.attrs.length;
  9455. const attrs = new Array(l);
  9456. for (let i = 0; i < l; i++) {
  9457. const args = match.attrs[i];
  9458. const value = args[3] || args[4] || args[5] || '';
  9459. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9460. ? options.shouldDecodeNewlinesForHref
  9461. : options.shouldDecodeNewlines;
  9462. attrs[i] = {
  9463. name: args[1],
  9464. value: decodeAttr(value, shouldDecodeNewlines)
  9465. };
  9466. if (options.outputSourceRange) {
  9467. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9468. attrs[i].end = args.end;
  9469. }
  9470. }
  9471. if (!unary) {
  9472. stack.push({
  9473. tag: tagName,
  9474. lowerCasedTag: tagName.toLowerCase(),
  9475. attrs: attrs,
  9476. start: match.start,
  9477. end: match.end
  9478. });
  9479. lastTag = tagName;
  9480. }
  9481. if (options.start) {
  9482. options.start(tagName, attrs, unary, match.start, match.end);
  9483. }
  9484. }
  9485. function parseEndTag(tagName, start, end) {
  9486. let pos, lowerCasedTagName;
  9487. if (start == null)
  9488. start = index;
  9489. if (end == null)
  9490. end = index;
  9491. // Find the closest opened tag of the same type
  9492. if (tagName) {
  9493. lowerCasedTagName = tagName.toLowerCase();
  9494. for (pos = stack.length - 1; pos >= 0; pos--) {
  9495. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9496. break;
  9497. }
  9498. }
  9499. }
  9500. else {
  9501. // If no tag name is provided, clean shop
  9502. pos = 0;
  9503. }
  9504. if (pos >= 0) {
  9505. // Close all the open elements, up the stack
  9506. for (let i = stack.length - 1; i >= pos; i--) {
  9507. if ((i > pos || !tagName) && options.warn) {
  9508. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9509. start: stack[i].start,
  9510. end: stack[i].end
  9511. });
  9512. }
  9513. if (options.end) {
  9514. options.end(stack[i].tag, start, end);
  9515. }
  9516. }
  9517. // Remove the open elements from the stack
  9518. stack.length = pos;
  9519. lastTag = pos && stack[pos - 1].tag;
  9520. }
  9521. else if (lowerCasedTagName === 'br') {
  9522. if (options.start) {
  9523. options.start(tagName, [], true, start, end);
  9524. }
  9525. }
  9526. else if (lowerCasedTagName === 'p') {
  9527. if (options.start) {
  9528. options.start(tagName, [], false, start, end);
  9529. }
  9530. if (options.end) {
  9531. options.end(tagName, start, end);
  9532. }
  9533. }
  9534. }
  9535. }
  9536. const onRE = /^@|^v-on:/;
  9537. const dirRE = /^v-|^@|^:|^#/;
  9538. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9539. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9540. const stripParensRE = /^\(|\)$/g;
  9541. const dynamicArgRE = /^\[.*\]$/;
  9542. const argRE = /:(.*)$/;
  9543. const bindRE = /^:|^\.|^v-bind:/;
  9544. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9545. const slotRE = /^v-slot(:|$)|^#/;
  9546. const lineBreakRE = /[\r\n]/;
  9547. const whitespaceRE = /[ \f\t\r\n]+/g;
  9548. const invalidAttributeRE = /[\s"'<>\/=]/;
  9549. const decodeHTMLCached = cached(he.decode);
  9550. const emptySlotScopeToken = `_empty_`;
  9551. // configurable state
  9552. let warn;
  9553. let delimiters;
  9554. let transforms;
  9555. let preTransforms;
  9556. let postTransforms;
  9557. let platformIsPreTag;
  9558. let platformMustUseProp;
  9559. let platformGetTagNamespace;
  9560. let maybeComponent;
  9561. function createASTElement(tag, attrs, parent) {
  9562. return {
  9563. type: 1,
  9564. tag,
  9565. attrsList: attrs,
  9566. attrsMap: makeAttrsMap(attrs),
  9567. rawAttrsMap: {},
  9568. parent,
  9569. children: []
  9570. };
  9571. }
  9572. /**
  9573. * Convert HTML string to AST.
  9574. */
  9575. function parse(template, options) {
  9576. warn = options.warn || baseWarn;
  9577. platformIsPreTag = options.isPreTag || no;
  9578. platformMustUseProp = options.mustUseProp || no;
  9579. platformGetTagNamespace = options.getTagNamespace || no;
  9580. const isReservedTag = options.isReservedTag || no;
  9581. maybeComponent = (el) => !!(el.component ||
  9582. el.attrsMap[':is'] ||
  9583. el.attrsMap['v-bind:is'] ||
  9584. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9585. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9586. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9587. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9588. delimiters = options.delimiters;
  9589. const stack = [];
  9590. const preserveWhitespace = options.preserveWhitespace !== false;
  9591. const whitespaceOption = options.whitespace;
  9592. let root;
  9593. let currentParent;
  9594. let inVPre = false;
  9595. let inPre = false;
  9596. let warned = false;
  9597. function warnOnce(msg, range) {
  9598. if (!warned) {
  9599. warned = true;
  9600. warn(msg, range);
  9601. }
  9602. }
  9603. function closeElement(element) {
  9604. trimEndingWhitespace(element);
  9605. if (!inVPre && !element.processed) {
  9606. element = processElement(element, options);
  9607. }
  9608. // tree management
  9609. if (!stack.length && element !== root) {
  9610. // allow root elements with v-if, v-else-if and v-else
  9611. if (root.if && (element.elseif || element.else)) {
  9612. {
  9613. checkRootConstraints(element);
  9614. }
  9615. addIfCondition(root, {
  9616. exp: element.elseif,
  9617. block: element
  9618. });
  9619. }
  9620. else {
  9621. warnOnce(`Component template should contain exactly one root element. ` +
  9622. `If you are using v-if on multiple elements, ` +
  9623. `use v-else-if to chain them instead.`, { start: element.start });
  9624. }
  9625. }
  9626. if (currentParent && !element.forbidden) {
  9627. if (element.elseif || element.else) {
  9628. processIfConditions(element, currentParent);
  9629. }
  9630. else {
  9631. if (element.slotScope) {
  9632. // scoped slot
  9633. // keep it in the children list so that v-else(-if) conditions can
  9634. // find it as the prev node.
  9635. const name = element.slotTarget || '"default"';
  9636. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9637. }
  9638. currentParent.children.push(element);
  9639. element.parent = currentParent;
  9640. }
  9641. }
  9642. // final children cleanup
  9643. // filter out scoped slots
  9644. element.children = element.children.filter(c => !c.slotScope);
  9645. // remove trailing whitespace node again
  9646. trimEndingWhitespace(element);
  9647. // check pre state
  9648. if (element.pre) {
  9649. inVPre = false;
  9650. }
  9651. if (platformIsPreTag(element.tag)) {
  9652. inPre = false;
  9653. }
  9654. // apply post-transforms
  9655. for (let i = 0; i < postTransforms.length; i++) {
  9656. postTransforms[i](element, options);
  9657. }
  9658. }
  9659. function trimEndingWhitespace(el) {
  9660. // remove trailing whitespace node
  9661. if (!inPre) {
  9662. let lastNode;
  9663. while ((lastNode = el.children[el.children.length - 1]) &&
  9664. lastNode.type === 3 &&
  9665. lastNode.text === ' ') {
  9666. el.children.pop();
  9667. }
  9668. }
  9669. }
  9670. function checkRootConstraints(el) {
  9671. if (el.tag === 'slot' || el.tag === 'template') {
  9672. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9673. 'contain multiple nodes.', { start: el.start });
  9674. }
  9675. if (el.attrsMap.hasOwnProperty('v-for')) {
  9676. warnOnce('Cannot use v-for on stateful component root element because ' +
  9677. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9678. }
  9679. }
  9680. parseHTML(template, {
  9681. warn,
  9682. expectHTML: options.expectHTML,
  9683. isUnaryTag: options.isUnaryTag,
  9684. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9685. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9686. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9687. shouldKeepComment: options.comments,
  9688. outputSourceRange: options.outputSourceRange,
  9689. start(tag, attrs, unary, start, end) {
  9690. // check namespace.
  9691. // inherit parent ns if there is one
  9692. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9693. // handle IE svg bug
  9694. /* istanbul ignore if */
  9695. if (isIE && ns === 'svg') {
  9696. attrs = guardIESVGBug(attrs);
  9697. }
  9698. let element = createASTElement(tag, attrs, currentParent);
  9699. if (ns) {
  9700. element.ns = ns;
  9701. }
  9702. {
  9703. if (options.outputSourceRange) {
  9704. element.start = start;
  9705. element.end = end;
  9706. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9707. cumulated[attr.name] = attr;
  9708. return cumulated;
  9709. }, {});
  9710. }
  9711. attrs.forEach(attr => {
  9712. if (invalidAttributeRE.test(attr.name)) {
  9713. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9714. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9715. ? {
  9716. start: attr.start + attr.name.indexOf(`[`),
  9717. end: attr.start + attr.name.length
  9718. }
  9719. : undefined);
  9720. }
  9721. });
  9722. }
  9723. if (isForbiddenTag(element) && !isServerRendering()) {
  9724. element.forbidden = true;
  9725. warn('Templates should only be responsible for mapping the state to the ' +
  9726. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9727. `<${tag}>` +
  9728. ', as they will not be parsed.', { start: element.start });
  9729. }
  9730. // apply pre-transforms
  9731. for (let i = 0; i < preTransforms.length; i++) {
  9732. element = preTransforms[i](element, options) || element;
  9733. }
  9734. if (!inVPre) {
  9735. processPre(element);
  9736. if (element.pre) {
  9737. inVPre = true;
  9738. }
  9739. }
  9740. if (platformIsPreTag(element.tag)) {
  9741. inPre = true;
  9742. }
  9743. if (inVPre) {
  9744. processRawAttrs(element);
  9745. }
  9746. else if (!element.processed) {
  9747. // structural directives
  9748. processFor(element);
  9749. processIf(element);
  9750. processOnce(element);
  9751. }
  9752. if (!root) {
  9753. root = element;
  9754. {
  9755. checkRootConstraints(root);
  9756. }
  9757. }
  9758. if (!unary) {
  9759. currentParent = element;
  9760. stack.push(element);
  9761. }
  9762. else {
  9763. closeElement(element);
  9764. }
  9765. },
  9766. end(tag, start, end) {
  9767. const element = stack[stack.length - 1];
  9768. // pop stack
  9769. stack.length -= 1;
  9770. currentParent = stack[stack.length - 1];
  9771. if (options.outputSourceRange) {
  9772. element.end = end;
  9773. }
  9774. closeElement(element);
  9775. },
  9776. chars(text, start, end) {
  9777. if (!currentParent) {
  9778. {
  9779. if (text === template) {
  9780. warnOnce('Component template requires a root element, rather than just text.', { start });
  9781. }
  9782. else if ((text = text.trim())) {
  9783. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9784. start
  9785. });
  9786. }
  9787. }
  9788. return;
  9789. }
  9790. // IE textarea placeholder bug
  9791. /* istanbul ignore if */
  9792. if (isIE &&
  9793. currentParent.tag === 'textarea' &&
  9794. currentParent.attrsMap.placeholder === text) {
  9795. return;
  9796. }
  9797. const children = currentParent.children;
  9798. if (inPre || text.trim()) {
  9799. text = isTextTag(currentParent)
  9800. ? text
  9801. : decodeHTMLCached(text);
  9802. }
  9803. else if (!children.length) {
  9804. // remove the whitespace-only node right after an opening tag
  9805. text = '';
  9806. }
  9807. else if (whitespaceOption) {
  9808. if (whitespaceOption === 'condense') {
  9809. // in condense mode, remove the whitespace node if it contains
  9810. // line break, otherwise condense to a single space
  9811. text = lineBreakRE.test(text) ? '' : ' ';
  9812. }
  9813. else {
  9814. text = ' ';
  9815. }
  9816. }
  9817. else {
  9818. text = preserveWhitespace ? ' ' : '';
  9819. }
  9820. if (text) {
  9821. if (!inPre && whitespaceOption === 'condense') {
  9822. // condense consecutive whitespaces into single space
  9823. text = text.replace(whitespaceRE, ' ');
  9824. }
  9825. let res;
  9826. let child;
  9827. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9828. child = {
  9829. type: 2,
  9830. expression: res.expression,
  9831. tokens: res.tokens,
  9832. text
  9833. };
  9834. }
  9835. else if (text !== ' ' ||
  9836. !children.length ||
  9837. children[children.length - 1].text !== ' ') {
  9838. child = {
  9839. type: 3,
  9840. text
  9841. };
  9842. }
  9843. if (child) {
  9844. if (options.outputSourceRange) {
  9845. child.start = start;
  9846. child.end = end;
  9847. }
  9848. children.push(child);
  9849. }
  9850. }
  9851. },
  9852. comment(text, start, end) {
  9853. // adding anything as a sibling to the root node is forbidden
  9854. // comments should still be allowed, but ignored
  9855. if (currentParent) {
  9856. const child = {
  9857. type: 3,
  9858. text,
  9859. isComment: true
  9860. };
  9861. if (options.outputSourceRange) {
  9862. child.start = start;
  9863. child.end = end;
  9864. }
  9865. currentParent.children.push(child);
  9866. }
  9867. }
  9868. });
  9869. return root;
  9870. }
  9871. function processPre(el) {
  9872. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9873. el.pre = true;
  9874. }
  9875. }
  9876. function processRawAttrs(el) {
  9877. const list = el.attrsList;
  9878. const len = list.length;
  9879. if (len) {
  9880. const attrs = (el.attrs = new Array(len));
  9881. for (let i = 0; i < len; i++) {
  9882. attrs[i] = {
  9883. name: list[i].name,
  9884. value: JSON.stringify(list[i].value)
  9885. };
  9886. if (list[i].start != null) {
  9887. attrs[i].start = list[i].start;
  9888. attrs[i].end = list[i].end;
  9889. }
  9890. }
  9891. }
  9892. else if (!el.pre) {
  9893. // non root node in pre blocks with no attributes
  9894. el.plain = true;
  9895. }
  9896. }
  9897. function processElement(element, options) {
  9898. processKey(element);
  9899. // determine whether this is a plain element after
  9900. // removing structural attributes
  9901. element.plain =
  9902. !element.key && !element.scopedSlots && !element.attrsList.length;
  9903. processRef(element);
  9904. processSlotContent(element);
  9905. processSlotOutlet(element);
  9906. processComponent(element);
  9907. for (let i = 0; i < transforms.length; i++) {
  9908. element = transforms[i](element, options) || element;
  9909. }
  9910. processAttrs(element);
  9911. return element;
  9912. }
  9913. function processKey(el) {
  9914. const exp = getBindingAttr(el, 'key');
  9915. if (exp) {
  9916. {
  9917. if (el.tag === 'template') {
  9918. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9919. }
  9920. if (el.for) {
  9921. const iterator = el.iterator2 || el.iterator1;
  9922. const parent = el.parent;
  9923. if (iterator &&
  9924. iterator === exp &&
  9925. parent &&
  9926. parent.tag === 'transition-group') {
  9927. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9928. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9929. }
  9930. }
  9931. }
  9932. el.key = exp;
  9933. }
  9934. }
  9935. function processRef(el) {
  9936. const ref = getBindingAttr(el, 'ref');
  9937. if (ref) {
  9938. el.ref = ref;
  9939. el.refInFor = checkInFor(el);
  9940. }
  9941. }
  9942. function processFor(el) {
  9943. let exp;
  9944. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9945. const res = parseFor(exp);
  9946. if (res) {
  9947. extend(el, res);
  9948. }
  9949. else {
  9950. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9951. }
  9952. }
  9953. }
  9954. function parseFor(exp) {
  9955. const inMatch = exp.match(forAliasRE);
  9956. if (!inMatch)
  9957. return;
  9958. const res = {};
  9959. res.for = inMatch[2].trim();
  9960. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9961. const iteratorMatch = alias.match(forIteratorRE);
  9962. if (iteratorMatch) {
  9963. res.alias = alias.replace(forIteratorRE, '').trim();
  9964. res.iterator1 = iteratorMatch[1].trim();
  9965. if (iteratorMatch[2]) {
  9966. res.iterator2 = iteratorMatch[2].trim();
  9967. }
  9968. }
  9969. else {
  9970. res.alias = alias;
  9971. }
  9972. return res;
  9973. }
  9974. function processIf(el) {
  9975. const exp = getAndRemoveAttr(el, 'v-if');
  9976. if (exp) {
  9977. el.if = exp;
  9978. addIfCondition(el, {
  9979. exp: exp,
  9980. block: el
  9981. });
  9982. }
  9983. else {
  9984. if (getAndRemoveAttr(el, 'v-else') != null) {
  9985. el.else = true;
  9986. }
  9987. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9988. if (elseif) {
  9989. el.elseif = elseif;
  9990. }
  9991. }
  9992. }
  9993. function processIfConditions(el, parent) {
  9994. const prev = findPrevElement(parent.children);
  9995. if (prev && prev.if) {
  9996. addIfCondition(prev, {
  9997. exp: el.elseif,
  9998. block: el
  9999. });
  10000. }
  10001. else {
  10002. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  10003. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  10004. }
  10005. }
  10006. function findPrevElement(children) {
  10007. let i = children.length;
  10008. while (i--) {
  10009. if (children[i].type === 1) {
  10010. return children[i];
  10011. }
  10012. else {
  10013. if (children[i].text !== ' ') {
  10014. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  10015. `will be ignored.`, children[i]);
  10016. }
  10017. children.pop();
  10018. }
  10019. }
  10020. }
  10021. function addIfCondition(el, condition) {
  10022. if (!el.ifConditions) {
  10023. el.ifConditions = [];
  10024. }
  10025. el.ifConditions.push(condition);
  10026. }
  10027. function processOnce(el) {
  10028. const once = getAndRemoveAttr(el, 'v-once');
  10029. if (once != null) {
  10030. el.once = true;
  10031. }
  10032. }
  10033. // handle content being passed to a component as slot,
  10034. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10035. function processSlotContent(el) {
  10036. let slotScope;
  10037. if (el.tag === 'template') {
  10038. slotScope = getAndRemoveAttr(el, 'scope');
  10039. /* istanbul ignore if */
  10040. if (slotScope) {
  10041. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10042. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10043. `can also be used on plain elements in addition to <template> to ` +
  10044. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10045. }
  10046. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10047. }
  10048. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10049. /* istanbul ignore if */
  10050. if (el.attrsMap['v-for']) {
  10051. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10052. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10053. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10054. }
  10055. el.slotScope = slotScope;
  10056. }
  10057. // slot="xxx"
  10058. const slotTarget = getBindingAttr(el, 'slot');
  10059. if (slotTarget) {
  10060. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10061. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10062. // preserve slot as an attribute for native shadow DOM compat
  10063. // only for non-scoped slots.
  10064. if (el.tag !== 'template' && !el.slotScope) {
  10065. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10066. }
  10067. }
  10068. // 2.6 v-slot syntax
  10069. {
  10070. if (el.tag === 'template') {
  10071. // v-slot on <template>
  10072. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10073. if (slotBinding) {
  10074. {
  10075. if (el.slotTarget || el.slotScope) {
  10076. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10077. }
  10078. if (el.parent && !maybeComponent(el.parent)) {
  10079. warn(`<template v-slot> can only appear at the root level inside ` +
  10080. `the receiving component`, el);
  10081. }
  10082. }
  10083. const { name, dynamic } = getSlotName(slotBinding);
  10084. el.slotTarget = name;
  10085. el.slotTargetDynamic = dynamic;
  10086. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10087. }
  10088. }
  10089. else {
  10090. // v-slot on component, denotes default slot
  10091. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10092. if (slotBinding) {
  10093. {
  10094. if (!maybeComponent(el)) {
  10095. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10096. }
  10097. if (el.slotScope || el.slotTarget) {
  10098. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10099. }
  10100. if (el.scopedSlots) {
  10101. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10102. `<template> syntax when there are other named slots.`, slotBinding);
  10103. }
  10104. }
  10105. // add the component's children to its default slot
  10106. const slots = el.scopedSlots || (el.scopedSlots = {});
  10107. const { name, dynamic } = getSlotName(slotBinding);
  10108. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10109. slotContainer.slotTarget = name;
  10110. slotContainer.slotTargetDynamic = dynamic;
  10111. slotContainer.children = el.children.filter((c) => {
  10112. if (!c.slotScope) {
  10113. c.parent = slotContainer;
  10114. return true;
  10115. }
  10116. });
  10117. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10118. // remove children as they are returned from scopedSlots now
  10119. el.children = [];
  10120. // mark el non-plain so data gets generated
  10121. el.plain = false;
  10122. }
  10123. }
  10124. }
  10125. }
  10126. function getSlotName(binding) {
  10127. let name = binding.name.replace(slotRE, '');
  10128. if (!name) {
  10129. if (binding.name[0] !== '#') {
  10130. name = 'default';
  10131. }
  10132. else {
  10133. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10134. }
  10135. }
  10136. return dynamicArgRE.test(name)
  10137. ? // dynamic [name]
  10138. { name: name.slice(1, -1), dynamic: true }
  10139. : // static name
  10140. { name: `"${name}"`, dynamic: false };
  10141. }
  10142. // handle <slot/> outlets
  10143. function processSlotOutlet(el) {
  10144. if (el.tag === 'slot') {
  10145. el.slotName = getBindingAttr(el, 'name');
  10146. if (el.key) {
  10147. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10148. `and can possibly expand into multiple elements. ` +
  10149. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10150. }
  10151. }
  10152. }
  10153. function processComponent(el) {
  10154. let binding;
  10155. if ((binding = getBindingAttr(el, 'is'))) {
  10156. el.component = binding;
  10157. }
  10158. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10159. el.inlineTemplate = true;
  10160. }
  10161. }
  10162. function processAttrs(el) {
  10163. const list = el.attrsList;
  10164. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10165. for (i = 0, l = list.length; i < l; i++) {
  10166. name = rawName = list[i].name;
  10167. value = list[i].value;
  10168. if (dirRE.test(name)) {
  10169. // mark element as dynamic
  10170. el.hasBindings = true;
  10171. // modifiers
  10172. modifiers = parseModifiers(name.replace(dirRE, ''));
  10173. // support .foo shorthand syntax for the .prop modifier
  10174. if (modifiers) {
  10175. name = name.replace(modifierRE, '');
  10176. }
  10177. if (bindRE.test(name)) {
  10178. // v-bind
  10179. name = name.replace(bindRE, '');
  10180. value = parseFilters(value);
  10181. isDynamic = dynamicArgRE.test(name);
  10182. if (isDynamic) {
  10183. name = name.slice(1, -1);
  10184. }
  10185. if (value.trim().length === 0) {
  10186. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10187. }
  10188. if (modifiers) {
  10189. if (modifiers.prop && !isDynamic) {
  10190. name = camelize(name);
  10191. if (name === 'innerHtml')
  10192. name = 'innerHTML';
  10193. }
  10194. if (modifiers.camel && !isDynamic) {
  10195. name = camelize(name);
  10196. }
  10197. if (modifiers.sync) {
  10198. syncGen = genAssignmentCode(value, `$event`);
  10199. if (!isDynamic) {
  10200. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10201. if (hyphenate(name) !== camelize(name)) {
  10202. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10203. }
  10204. }
  10205. else {
  10206. // handler w/ dynamic event name
  10207. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10208. );
  10209. }
  10210. }
  10211. }
  10212. if ((modifiers && modifiers.prop) ||
  10213. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10214. addProp(el, name, value, list[i], isDynamic);
  10215. }
  10216. else {
  10217. addAttr(el, name, value, list[i], isDynamic);
  10218. }
  10219. }
  10220. else if (onRE.test(name)) {
  10221. // v-on
  10222. name = name.replace(onRE, '');
  10223. isDynamic = dynamicArgRE.test(name);
  10224. if (isDynamic) {
  10225. name = name.slice(1, -1);
  10226. }
  10227. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10228. }
  10229. else {
  10230. // normal directives
  10231. name = name.replace(dirRE, '');
  10232. // parse arg
  10233. const argMatch = name.match(argRE);
  10234. let arg = argMatch && argMatch[1];
  10235. isDynamic = false;
  10236. if (arg) {
  10237. name = name.slice(0, -(arg.length + 1));
  10238. if (dynamicArgRE.test(arg)) {
  10239. arg = arg.slice(1, -1);
  10240. isDynamic = true;
  10241. }
  10242. }
  10243. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10244. if (name === 'model') {
  10245. checkForAliasModel(el, value);
  10246. }
  10247. }
  10248. }
  10249. else {
  10250. // literal attribute
  10251. {
  10252. const res = parseText(value, delimiters);
  10253. if (res) {
  10254. warn(`${name}="${value}": ` +
  10255. 'Interpolation inside attributes has been removed. ' +
  10256. 'Use v-bind or the colon shorthand instead. For example, ' +
  10257. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10258. }
  10259. }
  10260. addAttr(el, name, JSON.stringify(value), list[i]);
  10261. // #6887 firefox doesn't update muted state if set via attribute
  10262. // even immediately after element creation
  10263. if (!el.component &&
  10264. name === 'muted' &&
  10265. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10266. addProp(el, name, 'true', list[i]);
  10267. }
  10268. }
  10269. }
  10270. }
  10271. function checkInFor(el) {
  10272. let parent = el;
  10273. while (parent) {
  10274. if (parent.for !== undefined) {
  10275. return true;
  10276. }
  10277. parent = parent.parent;
  10278. }
  10279. return false;
  10280. }
  10281. function parseModifiers(name) {
  10282. const match = name.match(modifierRE);
  10283. if (match) {
  10284. const ret = {};
  10285. match.forEach(m => {
  10286. ret[m.slice(1)] = true;
  10287. });
  10288. return ret;
  10289. }
  10290. }
  10291. function makeAttrsMap(attrs) {
  10292. const map = {};
  10293. for (let i = 0, l = attrs.length; i < l; i++) {
  10294. if (map[attrs[i].name] && !isIE && !isEdge) {
  10295. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10296. }
  10297. map[attrs[i].name] = attrs[i].value;
  10298. }
  10299. return map;
  10300. }
  10301. // for script (e.g. type="x/template") or style, do not decode content
  10302. function isTextTag(el) {
  10303. return el.tag === 'script' || el.tag === 'style';
  10304. }
  10305. function isForbiddenTag(el) {
  10306. return (el.tag === 'style' ||
  10307. (el.tag === 'script' &&
  10308. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10309. }
  10310. const ieNSBug = /^xmlns:NS\d+/;
  10311. const ieNSPrefix = /^NS\d+:/;
  10312. /* istanbul ignore next */
  10313. function guardIESVGBug(attrs) {
  10314. const res = [];
  10315. for (let i = 0; i < attrs.length; i++) {
  10316. const attr = attrs[i];
  10317. if (!ieNSBug.test(attr.name)) {
  10318. attr.name = attr.name.replace(ieNSPrefix, '');
  10319. res.push(attr);
  10320. }
  10321. }
  10322. return res;
  10323. }
  10324. function checkForAliasModel(el, value) {
  10325. let _el = el;
  10326. while (_el) {
  10327. if (_el.for && _el.alias === value) {
  10328. warn(`<${el.tag} v-model="${value}">: ` +
  10329. `You are binding v-model directly to a v-for iteration alias. ` +
  10330. `This will not be able to modify the v-for source array because ` +
  10331. `writing to the alias is like modifying a function local variable. ` +
  10332. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10333. }
  10334. _el = _el.parent;
  10335. }
  10336. }
  10337. /**
  10338. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10339. * Turn this:
  10340. * <input v-model="data[type]" :type="type">
  10341. * into this:
  10342. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10343. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10344. * <input v-else :type="type" v-model="data[type]">
  10345. */
  10346. function preTransformNode(el, options) {
  10347. if (el.tag === 'input') {
  10348. const map = el.attrsMap;
  10349. if (!map['v-model']) {
  10350. return;
  10351. }
  10352. let typeBinding;
  10353. if (map[':type'] || map['v-bind:type']) {
  10354. typeBinding = getBindingAttr(el, 'type');
  10355. }
  10356. if (!map.type && !typeBinding && map['v-bind']) {
  10357. typeBinding = `(${map['v-bind']}).type`;
  10358. }
  10359. if (typeBinding) {
  10360. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10361. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10362. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10363. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10364. // 1. checkbox
  10365. const branch0 = cloneASTElement(el);
  10366. // process for on the main node
  10367. processFor(branch0);
  10368. addRawAttr(branch0, 'type', 'checkbox');
  10369. processElement(branch0, options);
  10370. branch0.processed = true; // prevent it from double-processed
  10371. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10372. addIfCondition(branch0, {
  10373. exp: branch0.if,
  10374. block: branch0
  10375. });
  10376. // 2. add radio else-if condition
  10377. const branch1 = cloneASTElement(el);
  10378. getAndRemoveAttr(branch1, 'v-for', true);
  10379. addRawAttr(branch1, 'type', 'radio');
  10380. processElement(branch1, options);
  10381. addIfCondition(branch0, {
  10382. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10383. block: branch1
  10384. });
  10385. // 3. other
  10386. const branch2 = cloneASTElement(el);
  10387. getAndRemoveAttr(branch2, 'v-for', true);
  10388. addRawAttr(branch2, ':type', typeBinding);
  10389. processElement(branch2, options);
  10390. addIfCondition(branch0, {
  10391. exp: ifCondition,
  10392. block: branch2
  10393. });
  10394. if (hasElse) {
  10395. branch0.else = true;
  10396. }
  10397. else if (elseIfCondition) {
  10398. branch0.elseif = elseIfCondition;
  10399. }
  10400. return branch0;
  10401. }
  10402. }
  10403. }
  10404. function cloneASTElement(el) {
  10405. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10406. }
  10407. var model = {
  10408. preTransformNode
  10409. };
  10410. var modules = [klass, style, model];
  10411. function text(el, dir) {
  10412. if (dir.value) {
  10413. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10414. }
  10415. }
  10416. function html(el, dir) {
  10417. if (dir.value) {
  10418. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10419. }
  10420. }
  10421. var directives = {
  10422. model: model$1,
  10423. text,
  10424. html
  10425. };
  10426. const baseOptions = {
  10427. expectHTML: true,
  10428. modules,
  10429. directives,
  10430. isPreTag,
  10431. isUnaryTag,
  10432. mustUseProp,
  10433. canBeLeftOpenTag,
  10434. isReservedTag,
  10435. getTagNamespace,
  10436. staticKeys: genStaticKeys$1(modules)
  10437. };
  10438. let isStaticKey;
  10439. let isPlatformReservedTag;
  10440. const genStaticKeysCached = cached(genStaticKeys);
  10441. /**
  10442. * Goal of the optimizer: walk the generated template AST tree
  10443. * and detect sub-trees that are purely static, i.e. parts of
  10444. * the DOM that never needs to change.
  10445. *
  10446. * Once we detect these sub-trees, we can:
  10447. *
  10448. * 1. Hoist them into constants, so that we no longer need to
  10449. * create fresh nodes for them on each re-render;
  10450. * 2. Completely skip them in the patching process.
  10451. */
  10452. function optimize(root, options) {
  10453. if (!root)
  10454. return;
  10455. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10456. isPlatformReservedTag = options.isReservedTag || no;
  10457. // first pass: mark all non-static nodes.
  10458. markStatic(root);
  10459. // second pass: mark static roots.
  10460. markStaticRoots(root, false);
  10461. }
  10462. function genStaticKeys(keys) {
  10463. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10464. (keys ? ',' + keys : ''));
  10465. }
  10466. function markStatic(node) {
  10467. node.static = isStatic(node);
  10468. if (node.type === 1) {
  10469. // do not make component slot content static. this avoids
  10470. // 1. components not able to mutate slot nodes
  10471. // 2. static slot content fails for hot-reloading
  10472. if (!isPlatformReservedTag(node.tag) &&
  10473. node.tag !== 'slot' &&
  10474. node.attrsMap['inline-template'] == null) {
  10475. return;
  10476. }
  10477. for (let i = 0, l = node.children.length; i < l; i++) {
  10478. const child = node.children[i];
  10479. markStatic(child);
  10480. if (!child.static) {
  10481. node.static = false;
  10482. }
  10483. }
  10484. if (node.ifConditions) {
  10485. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10486. const block = node.ifConditions[i].block;
  10487. markStatic(block);
  10488. if (!block.static) {
  10489. node.static = false;
  10490. }
  10491. }
  10492. }
  10493. }
  10494. }
  10495. function markStaticRoots(node, isInFor) {
  10496. if (node.type === 1) {
  10497. if (node.static || node.once) {
  10498. node.staticInFor = isInFor;
  10499. }
  10500. // For a node to qualify as a static root, it should have children that
  10501. // are not just static text. Otherwise the cost of hoisting out will
  10502. // outweigh the benefits and it's better off to just always render it fresh.
  10503. if (node.static &&
  10504. node.children.length &&
  10505. !(node.children.length === 1 && node.children[0].type === 3)) {
  10506. node.staticRoot = true;
  10507. return;
  10508. }
  10509. else {
  10510. node.staticRoot = false;
  10511. }
  10512. if (node.children) {
  10513. for (let i = 0, l = node.children.length; i < l; i++) {
  10514. markStaticRoots(node.children[i], isInFor || !!node.for);
  10515. }
  10516. }
  10517. if (node.ifConditions) {
  10518. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10519. markStaticRoots(node.ifConditions[i].block, isInFor);
  10520. }
  10521. }
  10522. }
  10523. }
  10524. function isStatic(node) {
  10525. if (node.type === 2) {
  10526. // expression
  10527. return false;
  10528. }
  10529. if (node.type === 3) {
  10530. // text
  10531. return true;
  10532. }
  10533. return !!(node.pre ||
  10534. (!node.hasBindings && // no dynamic bindings
  10535. !node.if &&
  10536. !node.for && // not v-if or v-for or v-else
  10537. !isBuiltInTag(node.tag) && // not a built-in
  10538. isPlatformReservedTag(node.tag) && // not a component
  10539. !isDirectChildOfTemplateFor(node) &&
  10540. Object.keys(node).every(isStaticKey)));
  10541. }
  10542. function isDirectChildOfTemplateFor(node) {
  10543. while (node.parent) {
  10544. node = node.parent;
  10545. if (node.tag !== 'template') {
  10546. return false;
  10547. }
  10548. if (node.for) {
  10549. return true;
  10550. }
  10551. }
  10552. return false;
  10553. }
  10554. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10555. const fnInvokeRE = /\([^)]*?\);*$/;
  10556. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10557. // KeyboardEvent.keyCode aliases
  10558. const keyCodes = {
  10559. esc: 27,
  10560. tab: 9,
  10561. enter: 13,
  10562. space: 32,
  10563. up: 38,
  10564. left: 37,
  10565. right: 39,
  10566. down: 40,
  10567. delete: [8, 46]
  10568. };
  10569. // KeyboardEvent.key aliases
  10570. const keyNames = {
  10571. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10572. esc: ['Esc', 'Escape'],
  10573. tab: 'Tab',
  10574. enter: 'Enter',
  10575. // #9112: IE11 uses `Spacebar` for Space key name.
  10576. space: [' ', 'Spacebar'],
  10577. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10578. up: ['Up', 'ArrowUp'],
  10579. left: ['Left', 'ArrowLeft'],
  10580. right: ['Right', 'ArrowRight'],
  10581. down: ['Down', 'ArrowDown'],
  10582. // #9112: IE11 uses `Del` for Delete key name.
  10583. delete: ['Backspace', 'Delete', 'Del']
  10584. };
  10585. // #4868: modifiers that prevent the execution of the listener
  10586. // need to explicitly return null so that we can determine whether to remove
  10587. // the listener for .once
  10588. const genGuard = condition => `if(${condition})return null;`;
  10589. const modifierCode = {
  10590. stop: '$event.stopPropagation();',
  10591. prevent: '$event.preventDefault();',
  10592. self: genGuard(`$event.target !== $event.currentTarget`),
  10593. ctrl: genGuard(`!$event.ctrlKey`),
  10594. shift: genGuard(`!$event.shiftKey`),
  10595. alt: genGuard(`!$event.altKey`),
  10596. meta: genGuard(`!$event.metaKey`),
  10597. left: genGuard(`'button' in $event && $event.button !== 0`),
  10598. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10599. right: genGuard(`'button' in $event && $event.button !== 2`)
  10600. };
  10601. function genHandlers(events, isNative) {
  10602. const prefix = isNative ? 'nativeOn:' : 'on:';
  10603. let staticHandlers = ``;
  10604. let dynamicHandlers = ``;
  10605. for (const name in events) {
  10606. const handlerCode = genHandler(events[name]);
  10607. //@ts-expect-error
  10608. if (events[name] && events[name].dynamic) {
  10609. dynamicHandlers += `${name},${handlerCode},`;
  10610. }
  10611. else {
  10612. staticHandlers += `"${name}":${handlerCode},`;
  10613. }
  10614. }
  10615. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10616. if (dynamicHandlers) {
  10617. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10618. }
  10619. else {
  10620. return prefix + staticHandlers;
  10621. }
  10622. }
  10623. function genHandler(handler) {
  10624. if (!handler) {
  10625. return 'function(){}';
  10626. }
  10627. if (Array.isArray(handler)) {
  10628. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10629. }
  10630. const isMethodPath = simplePathRE.test(handler.value);
  10631. const isFunctionExpression = fnExpRE.test(handler.value);
  10632. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10633. if (!handler.modifiers) {
  10634. if (isMethodPath || isFunctionExpression) {
  10635. return handler.value;
  10636. }
  10637. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10638. }
  10639. else {
  10640. let code = '';
  10641. let genModifierCode = '';
  10642. const keys = [];
  10643. for (const key in handler.modifiers) {
  10644. if (modifierCode[key]) {
  10645. genModifierCode += modifierCode[key];
  10646. // left/right
  10647. if (keyCodes[key]) {
  10648. keys.push(key);
  10649. }
  10650. }
  10651. else if (key === 'exact') {
  10652. const modifiers = handler.modifiers;
  10653. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10654. .filter(keyModifier => !modifiers[keyModifier])
  10655. .map(keyModifier => `$event.${keyModifier}Key`)
  10656. .join('||'));
  10657. }
  10658. else {
  10659. keys.push(key);
  10660. }
  10661. }
  10662. if (keys.length) {
  10663. code += genKeyFilter(keys);
  10664. }
  10665. // Make sure modifiers like prevent and stop get executed after key filtering
  10666. if (genModifierCode) {
  10667. code += genModifierCode;
  10668. }
  10669. const handlerCode = isMethodPath
  10670. ? `return ${handler.value}.apply(null, arguments)`
  10671. : isFunctionExpression
  10672. ? `return (${handler.value}).apply(null, arguments)`
  10673. : isFunctionInvocation
  10674. ? `return ${handler.value}`
  10675. : handler.value;
  10676. return `function($event){${code}${handlerCode}}`;
  10677. }
  10678. }
  10679. function genKeyFilter(keys) {
  10680. return (
  10681. // make sure the key filters only apply to KeyboardEvents
  10682. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10683. // key events that do not have keyCode property...
  10684. `if(!$event.type.indexOf('key')&&` +
  10685. `${keys.map(genFilterCode).join('&&')})return null;`);
  10686. }
  10687. function genFilterCode(key) {
  10688. const keyVal = parseInt(key, 10);
  10689. if (keyVal) {
  10690. return `$event.keyCode!==${keyVal}`;
  10691. }
  10692. const keyCode = keyCodes[key];
  10693. const keyName = keyNames[key];
  10694. return (`_k($event.keyCode,` +
  10695. `${JSON.stringify(key)},` +
  10696. `${JSON.stringify(keyCode)},` +
  10697. `$event.key,` +
  10698. `${JSON.stringify(keyName)}` +
  10699. `)`);
  10700. }
  10701. function on(el, dir) {
  10702. if (dir.modifiers) {
  10703. warn$2(`v-on without argument does not support modifiers.`);
  10704. }
  10705. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10706. }
  10707. function bind(el, dir) {
  10708. el.wrapData = (code) => {
  10709. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10710. };
  10711. }
  10712. var baseDirectives = {
  10713. on,
  10714. bind,
  10715. cloak: noop
  10716. };
  10717. class CodegenState {
  10718. constructor(options) {
  10719. this.options = options;
  10720. this.warn = options.warn || baseWarn;
  10721. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10722. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10723. this.directives = extend(extend({}, baseDirectives), options.directives);
  10724. const isReservedTag = options.isReservedTag || no;
  10725. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10726. this.onceId = 0;
  10727. this.staticRenderFns = [];
  10728. this.pre = false;
  10729. }
  10730. }
  10731. function generate(ast, options) {
  10732. const state = new CodegenState(options);
  10733. // fix #11483, Root level <script> tags should not be rendered.
  10734. const code = ast
  10735. ? ast.tag === 'script'
  10736. ? 'null'
  10737. : genElement(ast, state)
  10738. : '_c("div")';
  10739. return {
  10740. render: `with(this){return ${code}}`,
  10741. staticRenderFns: state.staticRenderFns
  10742. };
  10743. }
  10744. function genElement(el, state) {
  10745. if (el.parent) {
  10746. el.pre = el.pre || el.parent.pre;
  10747. }
  10748. if (el.staticRoot && !el.staticProcessed) {
  10749. return genStatic(el, state);
  10750. }
  10751. else if (el.once && !el.onceProcessed) {
  10752. return genOnce(el, state);
  10753. }
  10754. else if (el.for && !el.forProcessed) {
  10755. return genFor(el, state);
  10756. }
  10757. else if (el.if && !el.ifProcessed) {
  10758. return genIf(el, state);
  10759. }
  10760. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10761. return genChildren(el, state) || 'void 0';
  10762. }
  10763. else if (el.tag === 'slot') {
  10764. return genSlot(el, state);
  10765. }
  10766. else {
  10767. // component or element
  10768. let code;
  10769. if (el.component) {
  10770. code = genComponent(el.component, el, state);
  10771. }
  10772. else {
  10773. let data;
  10774. const maybeComponent = state.maybeComponent(el);
  10775. if (!el.plain || (el.pre && maybeComponent)) {
  10776. data = genData(el, state);
  10777. }
  10778. let tag;
  10779. // check if this is a component in <script setup>
  10780. const bindings = state.options.bindings;
  10781. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10782. tag = checkBindingType(bindings, el.tag);
  10783. }
  10784. if (!tag)
  10785. tag = `'${el.tag}'`;
  10786. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10787. code = `_c(${tag}${data ? `,${data}` : '' // data
  10788. }${children ? `,${children}` : '' // children
  10789. })`;
  10790. }
  10791. // module transforms
  10792. for (let i = 0; i < state.transforms.length; i++) {
  10793. code = state.transforms[i](el, code);
  10794. }
  10795. return code;
  10796. }
  10797. }
  10798. function checkBindingType(bindings, key) {
  10799. const camelName = camelize(key);
  10800. const PascalName = capitalize(camelName);
  10801. const checkType = (type) => {
  10802. if (bindings[key] === type) {
  10803. return key;
  10804. }
  10805. if (bindings[camelName] === type) {
  10806. return camelName;
  10807. }
  10808. if (bindings[PascalName] === type) {
  10809. return PascalName;
  10810. }
  10811. };
  10812. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10813. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10814. if (fromConst) {
  10815. return fromConst;
  10816. }
  10817. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10818. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10819. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10820. if (fromMaybeRef) {
  10821. return fromMaybeRef;
  10822. }
  10823. }
  10824. // hoist static sub-trees out
  10825. function genStatic(el, state) {
  10826. el.staticProcessed = true;
  10827. // Some elements (templates) need to behave differently inside of a v-pre
  10828. // node. All pre nodes are static roots, so we can use this as a location to
  10829. // wrap a state change and reset it upon exiting the pre node.
  10830. const originalPreState = state.pre;
  10831. if (el.pre) {
  10832. state.pre = el.pre;
  10833. }
  10834. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10835. state.pre = originalPreState;
  10836. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10837. }
  10838. // v-once
  10839. function genOnce(el, state) {
  10840. el.onceProcessed = true;
  10841. if (el.if && !el.ifProcessed) {
  10842. return genIf(el, state);
  10843. }
  10844. else if (el.staticInFor) {
  10845. let key = '';
  10846. let parent = el.parent;
  10847. while (parent) {
  10848. if (parent.for) {
  10849. key = parent.key;
  10850. break;
  10851. }
  10852. parent = parent.parent;
  10853. }
  10854. if (!key) {
  10855. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10856. return genElement(el, state);
  10857. }
  10858. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10859. }
  10860. else {
  10861. return genStatic(el, state);
  10862. }
  10863. }
  10864. function genIf(el, state, altGen, altEmpty) {
  10865. el.ifProcessed = true; // avoid recursion
  10866. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10867. }
  10868. function genIfConditions(conditions, state, altGen, altEmpty) {
  10869. if (!conditions.length) {
  10870. return altEmpty || '_e()';
  10871. }
  10872. const condition = conditions.shift();
  10873. if (condition.exp) {
  10874. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10875. }
  10876. else {
  10877. return `${genTernaryExp(condition.block)}`;
  10878. }
  10879. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10880. function genTernaryExp(el) {
  10881. return altGen
  10882. ? altGen(el, state)
  10883. : el.once
  10884. ? genOnce(el, state)
  10885. : genElement(el, state);
  10886. }
  10887. }
  10888. function genFor(el, state, altGen, altHelper) {
  10889. const exp = el.for;
  10890. const alias = el.alias;
  10891. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10892. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10893. if (state.maybeComponent(el) &&
  10894. el.tag !== 'slot' &&
  10895. el.tag !== 'template' &&
  10896. !el.key) {
  10897. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10898. `v-for should have explicit keys. ` +
  10899. `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10900. }
  10901. el.forProcessed = true; // avoid recursion
  10902. return (`${altHelper || '_l'}((${exp}),` +
  10903. `function(${alias}${iterator1}${iterator2}){` +
  10904. `return ${(altGen || genElement)(el, state)}` +
  10905. '})');
  10906. }
  10907. function genData(el, state) {
  10908. let data = '{';
  10909. // directives first.
  10910. // directives may mutate the el's other properties before they are generated.
  10911. const dirs = genDirectives(el, state);
  10912. if (dirs)
  10913. data += dirs + ',';
  10914. // key
  10915. if (el.key) {
  10916. data += `key:${el.key},`;
  10917. }
  10918. // ref
  10919. if (el.ref) {
  10920. data += `ref:${el.ref},`;
  10921. }
  10922. if (el.refInFor) {
  10923. data += `refInFor:true,`;
  10924. }
  10925. // pre
  10926. if (el.pre) {
  10927. data += `pre:true,`;
  10928. }
  10929. // record original tag name for components using "is" attribute
  10930. if (el.component) {
  10931. data += `tag:"${el.tag}",`;
  10932. }
  10933. // module data generation functions
  10934. for (let i = 0; i < state.dataGenFns.length; i++) {
  10935. data += state.dataGenFns[i](el);
  10936. }
  10937. // attributes
  10938. if (el.attrs) {
  10939. data += `attrs:${genProps(el.attrs)},`;
  10940. }
  10941. // DOM props
  10942. if (el.props) {
  10943. data += `domProps:${genProps(el.props)},`;
  10944. }
  10945. // event handlers
  10946. if (el.events) {
  10947. data += `${genHandlers(el.events, false)},`;
  10948. }
  10949. if (el.nativeEvents) {
  10950. data += `${genHandlers(el.nativeEvents, true)},`;
  10951. }
  10952. // slot target
  10953. // only for non-scoped slots
  10954. if (el.slotTarget && !el.slotScope) {
  10955. data += `slot:${el.slotTarget},`;
  10956. }
  10957. // scoped slots
  10958. if (el.scopedSlots) {
  10959. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10960. }
  10961. // component v-model
  10962. if (el.model) {
  10963. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10964. }
  10965. // inline-template
  10966. if (el.inlineTemplate) {
  10967. const inlineTemplate = genInlineTemplate(el, state);
  10968. if (inlineTemplate) {
  10969. data += `${inlineTemplate},`;
  10970. }
  10971. }
  10972. data = data.replace(/,$/, '') + '}';
  10973. // v-bind dynamic argument wrap
  10974. // v-bind with dynamic arguments must be applied using the same v-bind object
  10975. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10976. if (el.dynamicAttrs) {
  10977. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10978. }
  10979. // v-bind data wrap
  10980. if (el.wrapData) {
  10981. data = el.wrapData(data);
  10982. }
  10983. // v-on data wrap
  10984. if (el.wrapListeners) {
  10985. data = el.wrapListeners(data);
  10986. }
  10987. return data;
  10988. }
  10989. function genDirectives(el, state) {
  10990. const dirs = el.directives;
  10991. if (!dirs)
  10992. return;
  10993. let res = 'directives:[';
  10994. let hasRuntime = false;
  10995. let i, l, dir, needRuntime;
  10996. for (i = 0, l = dirs.length; i < l; i++) {
  10997. dir = dirs[i];
  10998. needRuntime = true;
  10999. const gen = state.directives[dir.name];
  11000. if (gen) {
  11001. // compile-time directive that manipulates AST.
  11002. // returns true if it also needs a runtime counterpart.
  11003. needRuntime = !!gen(el, dir, state.warn);
  11004. }
  11005. if (needRuntime) {
  11006. hasRuntime = true;
  11007. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11008. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11009. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11010. }
  11011. }
  11012. if (hasRuntime) {
  11013. return res.slice(0, -1) + ']';
  11014. }
  11015. }
  11016. function genInlineTemplate(el, state) {
  11017. const ast = el.children[0];
  11018. if ((el.children.length !== 1 || ast.type !== 1)) {
  11019. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11020. }
  11021. if (ast && ast.type === 1) {
  11022. const inlineRenderFns = generate(ast, state.options);
  11023. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11024. .map(code => `function(){${code}}`)
  11025. .join(',')}]}`;
  11026. }
  11027. }
  11028. function genScopedSlots(el, slots, state) {
  11029. // by default scoped slots are considered "stable", this allows child
  11030. // components with only scoped slots to skip forced updates from parent.
  11031. // but in some cases we have to bail-out of this optimization
  11032. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11033. let needsForceUpdate = el.for ||
  11034. Object.keys(slots).some(key => {
  11035. const slot = slots[key];
  11036. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11037. );
  11038. });
  11039. // #9534: if a component with scoped slots is inside a conditional branch,
  11040. // it's possible for the same component to be reused but with different
  11041. // compiled slot content. To avoid that, we generate a unique key based on
  11042. // the generated code of all the slot contents.
  11043. let needsKey = !!el.if;
  11044. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11045. // disconnected due to the intermediate scope variable)
  11046. // #9438, #9506
  11047. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11048. // and skip force updating ones that do not actually use scope variables.
  11049. if (!needsForceUpdate) {
  11050. let parent = el.parent;
  11051. while (parent) {
  11052. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11053. parent.for) {
  11054. needsForceUpdate = true;
  11055. break;
  11056. }
  11057. if (parent.if) {
  11058. needsKey = true;
  11059. }
  11060. parent = parent.parent;
  11061. }
  11062. }
  11063. const generatedSlots = Object.keys(slots)
  11064. .map(key => genScopedSlot(slots[key], state))
  11065. .join(',');
  11066. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11067. }
  11068. function hash(str) {
  11069. let hash = 5381;
  11070. let i = str.length;
  11071. while (i) {
  11072. hash = (hash * 33) ^ str.charCodeAt(--i);
  11073. }
  11074. return hash >>> 0;
  11075. }
  11076. function containsSlotChild(el) {
  11077. if (el.type === 1) {
  11078. if (el.tag === 'slot') {
  11079. return true;
  11080. }
  11081. return el.children.some(containsSlotChild);
  11082. }
  11083. return false;
  11084. }
  11085. function genScopedSlot(el, state) {
  11086. const isLegacySyntax = el.attrsMap['slot-scope'];
  11087. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11088. return genIf(el, state, genScopedSlot, `null`);
  11089. }
  11090. if (el.for && !el.forProcessed) {
  11091. return genFor(el, state, genScopedSlot);
  11092. }
  11093. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11094. const fn = `function(${slotScope}){` +
  11095. `return ${el.tag === 'template'
  11096. ? el.if && isLegacySyntax
  11097. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11098. : genChildren(el, state) || 'undefined'
  11099. : genElement(el, state)}}`;
  11100. // reverse proxy v-slot without scope on this.$slots
  11101. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11102. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11103. }
  11104. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11105. const children = el.children;
  11106. if (children.length) {
  11107. const el = children[0];
  11108. // optimize single v-for
  11109. if (children.length === 1 &&
  11110. el.for &&
  11111. el.tag !== 'template' &&
  11112. el.tag !== 'slot') {
  11113. const normalizationType = checkSkip
  11114. ? state.maybeComponent(el)
  11115. ? `,1`
  11116. : `,0`
  11117. : ``;
  11118. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11119. }
  11120. const normalizationType = checkSkip
  11121. ? getNormalizationType(children, state.maybeComponent)
  11122. : 0;
  11123. const gen = altGenNode || genNode;
  11124. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11125. }
  11126. }
  11127. // determine the normalization needed for the children array.
  11128. // 0: no normalization needed
  11129. // 1: simple normalization needed (possible 1-level deep nested array)
  11130. // 2: full normalization needed
  11131. function getNormalizationType(children, maybeComponent) {
  11132. let res = 0;
  11133. for (let i = 0; i < children.length; i++) {
  11134. const el = children[i];
  11135. if (el.type !== 1) {
  11136. continue;
  11137. }
  11138. if (needsNormalization(el) ||
  11139. (el.ifConditions &&
  11140. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11141. res = 2;
  11142. break;
  11143. }
  11144. if (maybeComponent(el) ||
  11145. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11146. res = 1;
  11147. }
  11148. }
  11149. return res;
  11150. }
  11151. function needsNormalization(el) {
  11152. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11153. }
  11154. function genNode(node, state) {
  11155. if (node.type === 1) {
  11156. return genElement(node, state);
  11157. }
  11158. else if (node.type === 3 && node.isComment) {
  11159. return genComment(node);
  11160. }
  11161. else {
  11162. return genText(node);
  11163. }
  11164. }
  11165. function genText(text) {
  11166. return `_v(${text.type === 2
  11167. ? text.expression // no need for () because already wrapped in _s()
  11168. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11169. }
  11170. function genComment(comment) {
  11171. return `_e(${JSON.stringify(comment.text)})`;
  11172. }
  11173. function genSlot(el, state) {
  11174. const slotName = el.slotName || '"default"';
  11175. const children = genChildren(el, state);
  11176. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11177. const attrs = el.attrs || el.dynamicAttrs
  11178. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11179. // slot props are camelized
  11180. name: camelize(attr.name),
  11181. value: attr.value,
  11182. dynamic: attr.dynamic
  11183. })))
  11184. : null;
  11185. const bind = el.attrsMap['v-bind'];
  11186. if ((attrs || bind) && !children) {
  11187. res += `,null`;
  11188. }
  11189. if (attrs) {
  11190. res += `,${attrs}`;
  11191. }
  11192. if (bind) {
  11193. res += `${attrs ? '' : ',null'},${bind}`;
  11194. }
  11195. return res + ')';
  11196. }
  11197. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11198. function genComponent(componentName, el, state) {
  11199. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11200. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11201. }
  11202. function genProps(props) {
  11203. let staticProps = ``;
  11204. let dynamicProps = ``;
  11205. for (let i = 0; i < props.length; i++) {
  11206. const prop = props[i];
  11207. const value = transformSpecialNewlines(prop.value);
  11208. if (prop.dynamic) {
  11209. dynamicProps += `${prop.name},${value},`;
  11210. }
  11211. else {
  11212. staticProps += `"${prop.name}":${value},`;
  11213. }
  11214. }
  11215. staticProps = `{${staticProps.slice(0, -1)}}`;
  11216. if (dynamicProps) {
  11217. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11218. }
  11219. else {
  11220. return staticProps;
  11221. }
  11222. }
  11223. // #3895, #4268
  11224. function transformSpecialNewlines(text) {
  11225. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11226. }
  11227. // these keywords should not appear inside expressions, but operators like
  11228. // typeof, instanceof and in are allowed
  11229. const prohibitedKeywordRE = new RegExp('\\b' +
  11230. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11231. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11232. 'extends,finally,continue,debugger,function,arguments')
  11233. .split(',')
  11234. .join('\\b|\\b') +
  11235. '\\b');
  11236. // these unary operators should not be used as property/method names
  11237. const unaryOperatorsRE = new RegExp('\\b' +
  11238. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11239. '\\s*\\([^\\)]*\\)');
  11240. // strip strings in expressions
  11241. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11242. // detect problematic expressions in a template
  11243. function detectErrors(ast, warn) {
  11244. if (ast) {
  11245. checkNode(ast, warn);
  11246. }
  11247. }
  11248. function checkNode(node, warn) {
  11249. if (node.type === 1) {
  11250. for (const name in node.attrsMap) {
  11251. if (dirRE.test(name)) {
  11252. const value = node.attrsMap[name];
  11253. if (value) {
  11254. const range = node.rawAttrsMap[name];
  11255. if (name === 'v-for') {
  11256. checkFor(node, `v-for="${value}"`, warn, range);
  11257. }
  11258. else if (name === 'v-slot' || name[0] === '#') {
  11259. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11260. }
  11261. else if (onRE.test(name)) {
  11262. checkEvent(value, `${name}="${value}"`, warn, range);
  11263. }
  11264. else {
  11265. checkExpression(value, `${name}="${value}"`, warn, range);
  11266. }
  11267. }
  11268. }
  11269. }
  11270. if (node.children) {
  11271. for (let i = 0; i < node.children.length; i++) {
  11272. checkNode(node.children[i], warn);
  11273. }
  11274. }
  11275. }
  11276. else if (node.type === 2) {
  11277. checkExpression(node.expression, node.text, warn, node);
  11278. }
  11279. }
  11280. function checkEvent(exp, text, warn, range) {
  11281. const stripped = exp.replace(stripStringRE, '');
  11282. const keywordMatch = stripped.match(unaryOperatorsRE);
  11283. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11284. warn(`avoid using JavaScript unary operator as property name: ` +
  11285. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11286. }
  11287. checkExpression(exp, text, warn, range);
  11288. }
  11289. function checkFor(node, text, warn, range) {
  11290. checkExpression(node.for || '', text, warn, range);
  11291. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11292. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11293. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11294. }
  11295. function checkIdentifier(ident, type, text, warn, range) {
  11296. if (typeof ident === 'string') {
  11297. try {
  11298. new Function(`var ${ident}=_`);
  11299. }
  11300. catch (e) {
  11301. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11302. }
  11303. }
  11304. }
  11305. function checkExpression(exp, text, warn, range) {
  11306. try {
  11307. new Function(`return ${exp}`);
  11308. }
  11309. catch (e) {
  11310. const keywordMatch = exp
  11311. .replace(stripStringRE, '')
  11312. .match(prohibitedKeywordRE);
  11313. if (keywordMatch) {
  11314. warn(`avoid using JavaScript keyword as property name: ` +
  11315. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11316. }
  11317. else {
  11318. warn(`invalid expression: ${e.message} in\n\n` +
  11319. ` ${exp}\n\n` +
  11320. ` Raw expression: ${text.trim()}\n`, range);
  11321. }
  11322. }
  11323. }
  11324. function checkFunctionParameterExpression(exp, text, warn, range) {
  11325. try {
  11326. new Function(exp, '');
  11327. }
  11328. catch (e) {
  11329. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11330. ` ${exp}\n\n` +
  11331. ` Raw expression: ${text.trim()}\n`, range);
  11332. }
  11333. }
  11334. const range = 2;
  11335. function generateCodeFrame(source, start = 0, end = source.length) {
  11336. const lines = source.split(/\r?\n/);
  11337. let count = 0;
  11338. const res = [];
  11339. for (let i = 0; i < lines.length; i++) {
  11340. count += lines[i].length + 1;
  11341. if (count >= start) {
  11342. for (let j = i - range; j <= i + range || end > count; j++) {
  11343. if (j < 0 || j >= lines.length)
  11344. continue;
  11345. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11346. const lineLength = lines[j].length;
  11347. if (j === i) {
  11348. // push underline
  11349. const pad = start - (count - lineLength) + 1;
  11350. const length = end > count ? lineLength - pad : end - start;
  11351. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11352. }
  11353. else if (j > i) {
  11354. if (end > count) {
  11355. const length = Math.min(end - count, lineLength);
  11356. res.push(` | ` + repeat(`^`, length));
  11357. }
  11358. count += lineLength + 1;
  11359. }
  11360. }
  11361. break;
  11362. }
  11363. }
  11364. return res.join('\n');
  11365. }
  11366. function repeat(str, n) {
  11367. let result = '';
  11368. if (n > 0) {
  11369. // eslint-disable-next-line no-constant-condition
  11370. while (true) {
  11371. // eslint-disable-line
  11372. if (n & 1)
  11373. result += str;
  11374. n >>>= 1;
  11375. if (n <= 0)
  11376. break;
  11377. str += str;
  11378. }
  11379. }
  11380. return result;
  11381. }
  11382. function createFunction(code, errors) {
  11383. try {
  11384. return new Function(code);
  11385. }
  11386. catch (err) {
  11387. errors.push({ err, code });
  11388. return noop;
  11389. }
  11390. }
  11391. function createCompileToFunctionFn(compile) {
  11392. const cache = Object.create(null);
  11393. return function compileToFunctions(template, options, vm) {
  11394. options = extend({}, options);
  11395. const warn = options.warn || warn$2;
  11396. delete options.warn;
  11397. /* istanbul ignore if */
  11398. {
  11399. // detect possible CSP restriction
  11400. try {
  11401. new Function('return 1');
  11402. }
  11403. catch (e) {
  11404. if (e.toString().match(/unsafe-eval|CSP/)) {
  11405. warn('It seems you are using the standalone build of Vue.js in an ' +
  11406. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11407. 'The template compiler cannot work in this environment. Consider ' +
  11408. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11409. 'templates into render functions.');
  11410. }
  11411. }
  11412. }
  11413. // check cache
  11414. const key = options.delimiters
  11415. ? String(options.delimiters) + template
  11416. : template;
  11417. if (cache[key]) {
  11418. return cache[key];
  11419. }
  11420. // compile
  11421. const compiled = compile(template, options);
  11422. // check compilation errors/tips
  11423. {
  11424. if (compiled.errors && compiled.errors.length) {
  11425. if (options.outputSourceRange) {
  11426. compiled.errors.forEach(e => {
  11427. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11428. generateCodeFrame(template, e.start, e.end), vm);
  11429. });
  11430. }
  11431. else {
  11432. warn(`Error compiling template:\n\n${template}\n\n` +
  11433. compiled.errors.map(e => `- ${e}`).join('\n') +
  11434. '\n', vm);
  11435. }
  11436. }
  11437. if (compiled.tips && compiled.tips.length) {
  11438. if (options.outputSourceRange) {
  11439. compiled.tips.forEach(e => tip(e.msg, vm));
  11440. }
  11441. else {
  11442. compiled.tips.forEach(msg => tip(msg, vm));
  11443. }
  11444. }
  11445. }
  11446. // turn code into functions
  11447. const res = {};
  11448. const fnGenErrors = [];
  11449. res.render = createFunction(compiled.render, fnGenErrors);
  11450. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11451. return createFunction(code, fnGenErrors);
  11452. });
  11453. // check function generation errors.
  11454. // this should only happen if there is a bug in the compiler itself.
  11455. // mostly for codegen development use
  11456. /* istanbul ignore if */
  11457. {
  11458. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11459. warn(`Failed to generate render function:\n\n` +
  11460. fnGenErrors
  11461. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11462. .join('\n'), vm);
  11463. }
  11464. }
  11465. return (cache[key] = res);
  11466. };
  11467. }
  11468. function createCompilerCreator(baseCompile) {
  11469. return function createCompiler(baseOptions) {
  11470. function compile(template, options) {
  11471. const finalOptions = Object.create(baseOptions);
  11472. const errors = [];
  11473. const tips = [];
  11474. let warn = (msg, range, tip) => {
  11475. (tip ? tips : errors).push(msg);
  11476. };
  11477. if (options) {
  11478. if (options.outputSourceRange) {
  11479. // $flow-disable-line
  11480. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11481. warn = (msg, range, tip) => {
  11482. const data = typeof msg === 'string' ? { msg } : msg;
  11483. if (range) {
  11484. if (range.start != null) {
  11485. data.start = range.start + leadingSpaceLength;
  11486. }
  11487. if (range.end != null) {
  11488. data.end = range.end + leadingSpaceLength;
  11489. }
  11490. }
  11491. (tip ? tips : errors).push(data);
  11492. };
  11493. }
  11494. // merge custom modules
  11495. if (options.modules) {
  11496. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11497. }
  11498. // merge custom directives
  11499. if (options.directives) {
  11500. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11501. }
  11502. // copy other options
  11503. for (const key in options) {
  11504. if (key !== 'modules' && key !== 'directives') {
  11505. finalOptions[key] = options[key];
  11506. }
  11507. }
  11508. }
  11509. finalOptions.warn = warn;
  11510. const compiled = baseCompile(template.trim(), finalOptions);
  11511. {
  11512. detectErrors(compiled.ast, warn);
  11513. }
  11514. compiled.errors = errors;
  11515. compiled.tips = tips;
  11516. return compiled;
  11517. }
  11518. return {
  11519. compile,
  11520. compileToFunctions: createCompileToFunctionFn(compile)
  11521. };
  11522. };
  11523. }
  11524. // `createCompilerCreator` allows creating compilers that use alternative
  11525. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11526. // Here we just export a default compiler using the default parts.
  11527. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11528. const ast = parse(template.trim(), options);
  11529. if (options.optimize !== false) {
  11530. optimize(ast, options);
  11531. }
  11532. const code = generate(ast, options);
  11533. return {
  11534. ast,
  11535. render: code.render,
  11536. staticRenderFns: code.staticRenderFns
  11537. };
  11538. });
  11539. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11540. // check whether current browser encodes a char inside attribute values
  11541. let div;
  11542. function getShouldDecode(href) {
  11543. div = div || document.createElement('div');
  11544. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11545. return div.innerHTML.indexOf('&#10;') > 0;
  11546. }
  11547. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11548. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11549. // #6828: chrome encodes content in a[href]
  11550. const shouldDecodeNewlinesForHref = inBrowser
  11551. ? getShouldDecode(true)
  11552. : false;
  11553. const idToTemplate = cached(id => {
  11554. const el = query(id);
  11555. return el && el.innerHTML;
  11556. });
  11557. const mount = Vue.prototype.$mount;
  11558. Vue.prototype.$mount = function (el, hydrating) {
  11559. el = el && query(el);
  11560. /* istanbul ignore if */
  11561. if (el === document.body || el === document.documentElement) {
  11562. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11563. return this;
  11564. }
  11565. const options = this.$options;
  11566. // resolve template/el and convert to render function
  11567. if (!options.render) {
  11568. let template = options.template;
  11569. if (template) {
  11570. if (typeof template === 'string') {
  11571. if (template.charAt(0) === '#') {
  11572. template = idToTemplate(template);
  11573. /* istanbul ignore if */
  11574. if (!template) {
  11575. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11576. }
  11577. }
  11578. }
  11579. else if (template.nodeType) {
  11580. template = template.innerHTML;
  11581. }
  11582. else {
  11583. {
  11584. warn$2('invalid template option:' + template, this);
  11585. }
  11586. return this;
  11587. }
  11588. }
  11589. else if (el) {
  11590. // @ts-expect-error
  11591. template = getOuterHTML(el);
  11592. }
  11593. if (template) {
  11594. /* istanbul ignore if */
  11595. if (config.performance && mark) {
  11596. mark('compile');
  11597. }
  11598. const { render, staticRenderFns } = compileToFunctions(template, {
  11599. outputSourceRange: true,
  11600. shouldDecodeNewlines,
  11601. shouldDecodeNewlinesForHref,
  11602. delimiters: options.delimiters,
  11603. comments: options.comments
  11604. }, this);
  11605. options.render = render;
  11606. options.staticRenderFns = staticRenderFns;
  11607. /* istanbul ignore if */
  11608. if (config.performance && mark) {
  11609. mark('compile end');
  11610. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11611. }
  11612. }
  11613. }
  11614. return mount.call(this, el, hydrating);
  11615. };
  11616. /**
  11617. * Get outerHTML of elements, taking care
  11618. * of SVG elements in IE as well.
  11619. */
  11620. function getOuterHTML(el) {
  11621. if (el.outerHTML) {
  11622. return el.outerHTML;
  11623. }
  11624. else {
  11625. const container = document.createElement('div');
  11626. container.appendChild(el.cloneNode(true));
  11627. return container.innerHTML;
  11628. }
  11629. }
  11630. Vue.compile = compileToFunctions;
  11631. // export type EffectScheduler = (...args: any[]) => any
  11632. /**
  11633. * @internal since we are not exposing this in Vue 2, it's used only for
  11634. * internal testing.
  11635. */
  11636. function effect(fn, scheduler) {
  11637. const watcher = new Watcher(currentInstance, fn, noop, {
  11638. sync: true
  11639. });
  11640. if (scheduler) {
  11641. watcher.update = () => {
  11642. scheduler(() => watcher.run());
  11643. };
  11644. }
  11645. }
  11646. extend(Vue, vca);
  11647. Vue.effect = effect;
  11648. module.exports = Vue;