vue.esm.browser.js 387 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698
  1. /*!
  2. * Vue.js v2.7.13
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. const emptyObject = Object.freeze({});
  7. const isArray = Array.isArray;
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef(v) {
  11. return v === undefined || v === null;
  12. }
  13. function isDef(v) {
  14. return v !== undefined && v !== null;
  15. }
  16. function isTrue(v) {
  17. return v === true;
  18. }
  19. function isFalse(v) {
  20. return v === false;
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive(value) {
  26. return (typeof value === 'string' ||
  27. typeof value === 'number' ||
  28. // $flow-disable-line
  29. typeof value === 'symbol' ||
  30. typeof value === 'boolean');
  31. }
  32. function isFunction(value) {
  33. return typeof value === 'function';
  34. }
  35. /**
  36. * Quick object check - this is primarily used to tell
  37. * objects from primitive values when we know the value
  38. * is a JSON-compliant type.
  39. */
  40. function isObject(obj) {
  41. return obj !== null && typeof obj === 'object';
  42. }
  43. /**
  44. * Get the raw type string of a value, e.g., [object Object].
  45. */
  46. const _toString = Object.prototype.toString;
  47. function toRawType(value) {
  48. return _toString.call(value).slice(8, -1);
  49. }
  50. /**
  51. * Strict object type check. Only returns true
  52. * for plain JavaScript objects.
  53. */
  54. function isPlainObject(obj) {
  55. return _toString.call(obj) === '[object Object]';
  56. }
  57. function isRegExp(v) {
  58. return _toString.call(v) === '[object RegExp]';
  59. }
  60. /**
  61. * Check if val is a valid array index.
  62. */
  63. function isValidArrayIndex(val) {
  64. const n = parseFloat(String(val));
  65. return n >= 0 && Math.floor(n) === n && isFinite(val);
  66. }
  67. function isPromise(val) {
  68. return (isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function');
  71. }
  72. /**
  73. * Convert a value to a string that is actually rendered.
  74. */
  75. function toString(val) {
  76. return val == null
  77. ? ''
  78. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  79. ? JSON.stringify(val, null, 2)
  80. : String(val);
  81. }
  82. /**
  83. * Convert an input value to a number for persistence.
  84. * If the conversion fails, return original string.
  85. */
  86. function toNumber(val) {
  87. const n = parseFloat(val);
  88. return isNaN(n) ? val : n;
  89. }
  90. /**
  91. * Make a map and return a function for checking if a key
  92. * is in that map.
  93. */
  94. function makeMap(str, expectsLowerCase) {
  95. const map = Object.create(null);
  96. const list = str.split(',');
  97. for (let i = 0; i < list.length; i++) {
  98. map[list[i]] = true;
  99. }
  100. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  101. }
  102. /**
  103. * Check if a tag is a built-in tag.
  104. */
  105. const isBuiltInTag = makeMap('slot,component', true);
  106. /**
  107. * Check if an attribute is a reserved attribute.
  108. */
  109. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  110. /**
  111. * Remove an item from an array.
  112. */
  113. function remove$2(arr, item) {
  114. const len = arr.length;
  115. if (len) {
  116. // fast path for the only / last item
  117. if (item === arr[len - 1]) {
  118. arr.length = len - 1;
  119. return;
  120. }
  121. const index = arr.indexOf(item);
  122. if (index > -1) {
  123. return arr.splice(index, 1);
  124. }
  125. }
  126. }
  127. /**
  128. * Check whether an object has the property.
  129. */
  130. const hasOwnProperty = Object.prototype.hasOwnProperty;
  131. function hasOwn(obj, key) {
  132. return hasOwnProperty.call(obj, key);
  133. }
  134. /**
  135. * Create a cached version of a pure function.
  136. */
  137. function cached(fn) {
  138. const cache = Object.create(null);
  139. return function cachedFn(str) {
  140. const hit = cache[str];
  141. return hit || (cache[str] = fn(str));
  142. };
  143. }
  144. /**
  145. * Camelize a hyphen-delimited string.
  146. */
  147. const camelizeRE = /-(\w)/g;
  148. const camelize = cached((str) => {
  149. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  150. });
  151. /**
  152. * Capitalize a string.
  153. */
  154. const capitalize = cached((str) => {
  155. return str.charAt(0).toUpperCase() + str.slice(1);
  156. });
  157. /**
  158. * Hyphenate a camelCase string.
  159. */
  160. const hyphenateRE = /\B([A-Z])/g;
  161. const hyphenate = cached((str) => {
  162. return str.replace(hyphenateRE, '-$1').toLowerCase();
  163. });
  164. /**
  165. * Simple bind polyfill for environments that do not support it,
  166. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  167. * since native bind is now performant enough in most browsers.
  168. * But removing it would mean breaking code that was able to run in
  169. * PhantomJS 1.x, so this must be kept for backward compatibility.
  170. */
  171. /* istanbul ignore next */
  172. function polyfillBind(fn, ctx) {
  173. function boundFn(a) {
  174. const l = arguments.length;
  175. return l
  176. ? l > 1
  177. ? fn.apply(ctx, arguments)
  178. : fn.call(ctx, a)
  179. : fn.call(ctx);
  180. }
  181. boundFn._length = fn.length;
  182. return boundFn;
  183. }
  184. function nativeBind(fn, ctx) {
  185. return fn.bind(ctx);
  186. }
  187. // @ts-expect-error bind cannot be `undefined`
  188. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  189. /**
  190. * Convert an Array-like object to a real Array.
  191. */
  192. function toArray(list, start) {
  193. start = start || 0;
  194. let i = list.length - start;
  195. const ret = new Array(i);
  196. while (i--) {
  197. ret[i] = list[i + start];
  198. }
  199. return ret;
  200. }
  201. /**
  202. * Mix properties into target object.
  203. */
  204. function extend(to, _from) {
  205. for (const key in _from) {
  206. to[key] = _from[key];
  207. }
  208. return to;
  209. }
  210. /**
  211. * Merge an Array of Objects into a single Object.
  212. */
  213. function toObject(arr) {
  214. const res = {};
  215. for (let i = 0; i < arr.length; i++) {
  216. if (arr[i]) {
  217. extend(res, arr[i]);
  218. }
  219. }
  220. return res;
  221. }
  222. /* eslint-disable no-unused-vars */
  223. /**
  224. * Perform no operation.
  225. * Stubbing args to make Flow happy without leaving useless transpiled code
  226. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  227. */
  228. function noop(a, b, c) { }
  229. /**
  230. * Always return false.
  231. */
  232. const no = (a, b, c) => false;
  233. /* eslint-enable no-unused-vars */
  234. /**
  235. * Return the same value.
  236. */
  237. const identity = (_) => _;
  238. /**
  239. * Generate a string containing static keys from compiler modules.
  240. */
  241. function genStaticKeys$1(modules) {
  242. return modules
  243. .reduce((keys, m) => {
  244. return keys.concat(m.staticKeys || []);
  245. }, [])
  246. .join(',');
  247. }
  248. /**
  249. * Check if two values are loosely equal - that is,
  250. * if they are plain objects, do they have the same shape?
  251. */
  252. function looseEqual(a, b) {
  253. if (a === b)
  254. return true;
  255. const isObjectA = isObject(a);
  256. const isObjectB = isObject(b);
  257. if (isObjectA && isObjectB) {
  258. try {
  259. const isArrayA = Array.isArray(a);
  260. const isArrayB = Array.isArray(b);
  261. if (isArrayA && isArrayB) {
  262. return (a.length === b.length &&
  263. a.every((e, i) => {
  264. return looseEqual(e, b[i]);
  265. }));
  266. }
  267. else if (a instanceof Date && b instanceof Date) {
  268. return a.getTime() === b.getTime();
  269. }
  270. else if (!isArrayA && !isArrayB) {
  271. const keysA = Object.keys(a);
  272. const keysB = Object.keys(b);
  273. return (keysA.length === keysB.length &&
  274. keysA.every(key => {
  275. return looseEqual(a[key], b[key]);
  276. }));
  277. }
  278. else {
  279. /* istanbul ignore next */
  280. return false;
  281. }
  282. }
  283. catch (e) {
  284. /* istanbul ignore next */
  285. return false;
  286. }
  287. }
  288. else if (!isObjectA && !isObjectB) {
  289. return String(a) === String(b);
  290. }
  291. else {
  292. return false;
  293. }
  294. }
  295. /**
  296. * Return the first index at which a loosely equal value can be
  297. * found in the array (if value is a plain object, the array must
  298. * contain an object of the same shape), or -1 if it is not present.
  299. */
  300. function looseIndexOf(arr, val) {
  301. for (let i = 0; i < arr.length; i++) {
  302. if (looseEqual(arr[i], val))
  303. return i;
  304. }
  305. return -1;
  306. }
  307. /**
  308. * Ensure a function is called only once.
  309. */
  310. function once(fn) {
  311. let called = false;
  312. return function () {
  313. if (!called) {
  314. called = true;
  315. fn.apply(this, arguments);
  316. }
  317. };
  318. }
  319. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  320. function hasChanged(x, y) {
  321. if (x === y) {
  322. return x === 0 && 1 / x !== 1 / y;
  323. }
  324. else {
  325. return x === x || y === y;
  326. }
  327. }
  328. const SSR_ATTR = 'data-server-rendered';
  329. const ASSET_TYPES = ['component', 'directive', 'filter'];
  330. const LIFECYCLE_HOOKS = [
  331. 'beforeCreate',
  332. 'created',
  333. 'beforeMount',
  334. 'mounted',
  335. 'beforeUpdate',
  336. 'updated',
  337. 'beforeDestroy',
  338. 'destroyed',
  339. 'activated',
  340. 'deactivated',
  341. 'errorCaptured',
  342. 'serverPrefetch',
  343. 'renderTracked',
  344. 'renderTriggered'
  345. ];
  346. var config = {
  347. /**
  348. * Option merge strategies (used in core/util/options)
  349. */
  350. // $flow-disable-line
  351. optionMergeStrategies: Object.create(null),
  352. /**
  353. * Whether to suppress warnings.
  354. */
  355. silent: false,
  356. /**
  357. * Show production mode tip message on boot?
  358. */
  359. productionTip: true,
  360. /**
  361. * Whether to enable devtools
  362. */
  363. devtools: true,
  364. /**
  365. * Whether to record perf
  366. */
  367. performance: false,
  368. /**
  369. * Error handler for watcher errors
  370. */
  371. errorHandler: null,
  372. /**
  373. * Warn handler for watcher warns
  374. */
  375. warnHandler: null,
  376. /**
  377. * Ignore certain custom elements
  378. */
  379. ignoredElements: [],
  380. /**
  381. * Custom user key aliases for v-on
  382. */
  383. // $flow-disable-line
  384. keyCodes: Object.create(null),
  385. /**
  386. * Check if a tag is reserved so that it cannot be registered as a
  387. * component. This is platform-dependent and may be overwritten.
  388. */
  389. isReservedTag: no,
  390. /**
  391. * Check if an attribute is reserved so that it cannot be used as a component
  392. * prop. This is platform-dependent and may be overwritten.
  393. */
  394. isReservedAttr: no,
  395. /**
  396. * Check if a tag is an unknown element.
  397. * Platform-dependent.
  398. */
  399. isUnknownElement: no,
  400. /**
  401. * Get the namespace of an element
  402. */
  403. getTagNamespace: noop,
  404. /**
  405. * Parse the real tag name for the specific platform.
  406. */
  407. parsePlatformTagName: identity,
  408. /**
  409. * Check if an attribute must be bound using property, e.g. value
  410. * Platform-dependent.
  411. */
  412. mustUseProp: no,
  413. /**
  414. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  415. * This will significantly reduce performance if set to false.
  416. */
  417. async: true,
  418. /**
  419. * Exposed for legacy reasons
  420. */
  421. _lifecycleHooks: LIFECYCLE_HOOKS
  422. };
  423. /**
  424. * unicode letters used for parsing html tags, component names and property paths.
  425. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  426. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  427. */
  428. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  429. /**
  430. * Check if a string starts with $ or _
  431. */
  432. function isReserved(str) {
  433. const c = (str + '').charCodeAt(0);
  434. return c === 0x24 || c === 0x5f;
  435. }
  436. /**
  437. * Define a property.
  438. */
  439. function def(obj, key, val, enumerable) {
  440. Object.defineProperty(obj, key, {
  441. value: val,
  442. enumerable: !!enumerable,
  443. writable: true,
  444. configurable: true
  445. });
  446. }
  447. /**
  448. * Parse simple path.
  449. */
  450. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  451. function parsePath(path) {
  452. if (bailRE.test(path)) {
  453. return;
  454. }
  455. const segments = path.split('.');
  456. return function (obj) {
  457. for (let i = 0; i < segments.length; i++) {
  458. if (!obj)
  459. return;
  460. obj = obj[segments[i]];
  461. }
  462. return obj;
  463. };
  464. }
  465. // can we use __proto__?
  466. const hasProto = '__proto__' in {};
  467. // Browser environment sniffing
  468. const inBrowser = typeof window !== 'undefined';
  469. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  470. const isIE = UA && /msie|trident/.test(UA);
  471. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  472. const isEdge = UA && UA.indexOf('edge/') > 0;
  473. UA && UA.indexOf('android') > 0;
  474. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  475. UA && /chrome\/\d+/.test(UA) && !isEdge;
  476. UA && /phantomjs/.test(UA);
  477. const isFF = UA && UA.match(/firefox\/(\d+)/);
  478. // Firefox has a "watch" function on Object.prototype...
  479. // @ts-expect-error firebox support
  480. const nativeWatch = {}.watch;
  481. let supportsPassive = false;
  482. if (inBrowser) {
  483. try {
  484. const opts = {};
  485. Object.defineProperty(opts, 'passive', {
  486. get() {
  487. /* istanbul ignore next */
  488. supportsPassive = true;
  489. }
  490. }); // https://github.com/facebook/flow/issues/285
  491. window.addEventListener('test-passive', null, opts);
  492. }
  493. catch (e) { }
  494. }
  495. // this needs to be lazy-evaled because vue may be required before
  496. // vue-server-renderer can set VUE_ENV
  497. let _isServer;
  498. const isServerRendering = () => {
  499. if (_isServer === undefined) {
  500. /* istanbul ignore if */
  501. if (!inBrowser && typeof global !== 'undefined') {
  502. // detect presence of vue-server-renderer and avoid
  503. // Webpack shimming the process
  504. _isServer =
  505. global['process'] && global['process'].env.VUE_ENV === 'server';
  506. }
  507. else {
  508. _isServer = false;
  509. }
  510. }
  511. return _isServer;
  512. };
  513. // detect devtools
  514. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  515. /* istanbul ignore next */
  516. function isNative(Ctor) {
  517. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  518. }
  519. const hasSymbol = typeof Symbol !== 'undefined' &&
  520. isNative(Symbol) &&
  521. typeof Reflect !== 'undefined' &&
  522. isNative(Reflect.ownKeys);
  523. let _Set; // $flow-disable-line
  524. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  525. // use native Set when available.
  526. _Set = Set;
  527. }
  528. else {
  529. // a non-standard Set polyfill that only works with primitive keys.
  530. _Set = class Set {
  531. constructor() {
  532. this.set = Object.create(null);
  533. }
  534. has(key) {
  535. return this.set[key] === true;
  536. }
  537. add(key) {
  538. this.set[key] = true;
  539. }
  540. clear() {
  541. this.set = Object.create(null);
  542. }
  543. };
  544. }
  545. let currentInstance = null;
  546. /**
  547. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  548. * relies on it). Do not use this internally, just use `currentInstance`.
  549. *
  550. * @internal this function needs manual type declaration because it relies
  551. * on previously manually authored types from Vue 2
  552. */
  553. function getCurrentInstance() {
  554. return currentInstance && { proxy: currentInstance };
  555. }
  556. /**
  557. * @internal
  558. */
  559. function setCurrentInstance(vm = null) {
  560. if (!vm)
  561. currentInstance && currentInstance._scope.off();
  562. currentInstance = vm;
  563. vm && vm._scope.on();
  564. }
  565. /**
  566. * @internal
  567. */
  568. class VNode {
  569. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  570. this.tag = tag;
  571. this.data = data;
  572. this.children = children;
  573. this.text = text;
  574. this.elm = elm;
  575. this.ns = undefined;
  576. this.context = context;
  577. this.fnContext = undefined;
  578. this.fnOptions = undefined;
  579. this.fnScopeId = undefined;
  580. this.key = data && data.key;
  581. this.componentOptions = componentOptions;
  582. this.componentInstance = undefined;
  583. this.parent = undefined;
  584. this.raw = false;
  585. this.isStatic = false;
  586. this.isRootInsert = true;
  587. this.isComment = false;
  588. this.isCloned = false;
  589. this.isOnce = false;
  590. this.asyncFactory = asyncFactory;
  591. this.asyncMeta = undefined;
  592. this.isAsyncPlaceholder = false;
  593. }
  594. // DEPRECATED: alias for componentInstance for backwards compat.
  595. /* istanbul ignore next */
  596. get child() {
  597. return this.componentInstance;
  598. }
  599. }
  600. const createEmptyVNode = (text = '') => {
  601. const node = new VNode();
  602. node.text = text;
  603. node.isComment = true;
  604. return node;
  605. };
  606. function createTextVNode(val) {
  607. return new VNode(undefined, undefined, undefined, String(val));
  608. }
  609. // optimized shallow clone
  610. // used for static nodes and slot nodes because they may be reused across
  611. // multiple renders, cloning them avoids errors when DOM manipulations rely
  612. // on their elm reference.
  613. function cloneVNode(vnode) {
  614. const cloned = new VNode(vnode.tag, vnode.data,
  615. // #7975
  616. // clone children array to avoid mutating original in case of cloning
  617. // a child.
  618. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  619. cloned.ns = vnode.ns;
  620. cloned.isStatic = vnode.isStatic;
  621. cloned.key = vnode.key;
  622. cloned.isComment = vnode.isComment;
  623. cloned.fnContext = vnode.fnContext;
  624. cloned.fnOptions = vnode.fnOptions;
  625. cloned.fnScopeId = vnode.fnScopeId;
  626. cloned.asyncMeta = vnode.asyncMeta;
  627. cloned.isCloned = true;
  628. return cloned;
  629. }
  630. /* not type checking this file because flow doesn't play well with Proxy */
  631. let initProxy;
  632. {
  633. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  634. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  635. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  636. 'require' // for Webpack/Browserify
  637. );
  638. const warnNonPresent = (target, key) => {
  639. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  640. 'referenced during render. Make sure that this property is reactive, ' +
  641. 'either in the data option, or for class-based components, by ' +
  642. 'initializing the property. ' +
  643. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  644. };
  645. const warnReservedPrefix = (target, key) => {
  646. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  647. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  648. 'prevent conflicts with Vue internals. ' +
  649. 'See: https://v2.vuejs.org/v2/api/#data', target);
  650. };
  651. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  652. if (hasProxy) {
  653. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  654. config.keyCodes = new Proxy(config.keyCodes, {
  655. set(target, key, value) {
  656. if (isBuiltInModifier(key)) {
  657. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  658. return false;
  659. }
  660. else {
  661. target[key] = value;
  662. return true;
  663. }
  664. }
  665. });
  666. }
  667. const hasHandler = {
  668. has(target, key) {
  669. const has = key in target;
  670. const isAllowed = allowedGlobals(key) ||
  671. (typeof key === 'string' &&
  672. key.charAt(0) === '_' &&
  673. !(key in target.$data));
  674. if (!has && !isAllowed) {
  675. if (key in target.$data)
  676. warnReservedPrefix(target, key);
  677. else
  678. warnNonPresent(target, key);
  679. }
  680. return has || !isAllowed;
  681. }
  682. };
  683. const getHandler = {
  684. get(target, key) {
  685. if (typeof key === 'string' && !(key in target)) {
  686. if (key in target.$data)
  687. warnReservedPrefix(target, key);
  688. else
  689. warnNonPresent(target, key);
  690. }
  691. return target[key];
  692. }
  693. };
  694. initProxy = function initProxy(vm) {
  695. if (hasProxy) {
  696. // determine which proxy handler to use
  697. const options = vm.$options;
  698. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  699. vm._renderProxy = new Proxy(vm, handlers);
  700. }
  701. else {
  702. vm._renderProxy = vm;
  703. }
  704. };
  705. }
  706. let uid$2 = 0;
  707. const pendingCleanupDeps = [];
  708. const cleanupDeps = () => {
  709. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  710. const dep = pendingCleanupDeps[i];
  711. dep.subs = dep.subs.filter(s => s);
  712. dep._pending = false;
  713. }
  714. pendingCleanupDeps.length = 0;
  715. };
  716. /**
  717. * A dep is an observable that can have multiple
  718. * directives subscribing to it.
  719. * @internal
  720. */
  721. class Dep {
  722. constructor() {
  723. // pending subs cleanup
  724. this._pending = false;
  725. this.id = uid$2++;
  726. this.subs = [];
  727. }
  728. addSub(sub) {
  729. this.subs.push(sub);
  730. }
  731. removeSub(sub) {
  732. // #12696 deps with massive amount of subscribers are extremely slow to
  733. // clean up in Chromium
  734. // to workaround this, we unset the sub for now, and clear them on
  735. // next scheduler flush.
  736. this.subs[this.subs.indexOf(sub)] = null;
  737. if (!this._pending) {
  738. this._pending = true;
  739. pendingCleanupDeps.push(this);
  740. }
  741. }
  742. depend(info) {
  743. if (Dep.target) {
  744. Dep.target.addDep(this);
  745. if (info && Dep.target.onTrack) {
  746. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  747. }
  748. }
  749. }
  750. notify(info) {
  751. // stabilize the subscriber list first
  752. const subs = this.subs.filter(s => s);
  753. if (!config.async) {
  754. // subs aren't sorted in scheduler if not running async
  755. // we need to sort them now to make sure they fire in correct
  756. // order
  757. subs.sort((a, b) => a.id - b.id);
  758. }
  759. for (let i = 0, l = subs.length; i < l; i++) {
  760. const sub = subs[i];
  761. if (info) {
  762. sub.onTrigger &&
  763. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  764. }
  765. sub.update();
  766. }
  767. }
  768. }
  769. // The current target watcher being evaluated.
  770. // This is globally unique because only one watcher
  771. // can be evaluated at a time.
  772. Dep.target = null;
  773. const targetStack = [];
  774. function pushTarget(target) {
  775. targetStack.push(target);
  776. Dep.target = target;
  777. }
  778. function popTarget() {
  779. targetStack.pop();
  780. Dep.target = targetStack[targetStack.length - 1];
  781. }
  782. /*
  783. * not type checking this file because flow doesn't play well with
  784. * dynamically accessing methods on Array prototype
  785. */
  786. const arrayProto = Array.prototype;
  787. const arrayMethods = Object.create(arrayProto);
  788. const methodsToPatch = [
  789. 'push',
  790. 'pop',
  791. 'shift',
  792. 'unshift',
  793. 'splice',
  794. 'sort',
  795. 'reverse'
  796. ];
  797. /**
  798. * Intercept mutating methods and emit events
  799. */
  800. methodsToPatch.forEach(function (method) {
  801. // cache original method
  802. const original = arrayProto[method];
  803. def(arrayMethods, method, function mutator(...args) {
  804. const result = original.apply(this, args);
  805. const ob = this.__ob__;
  806. let inserted;
  807. switch (method) {
  808. case 'push':
  809. case 'unshift':
  810. inserted = args;
  811. break;
  812. case 'splice':
  813. inserted = args.slice(2);
  814. break;
  815. }
  816. if (inserted)
  817. ob.observeArray(inserted);
  818. // notify change
  819. {
  820. ob.dep.notify({
  821. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  822. target: this,
  823. key: method
  824. });
  825. }
  826. return result;
  827. });
  828. });
  829. const rawMap = new WeakMap();
  830. function reactive(target) {
  831. makeReactive(target, false);
  832. return target;
  833. }
  834. /**
  835. * Return a shallowly-reactive copy of the original object, where only the root
  836. * level properties are reactive. It also does not auto-unwrap refs (even at the
  837. * root level).
  838. */
  839. function shallowReactive(target) {
  840. makeReactive(target, true);
  841. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  842. return target;
  843. }
  844. function makeReactive(target, shallow) {
  845. // if trying to observe a readonly proxy, return the readonly version.
  846. if (!isReadonly(target)) {
  847. {
  848. if (isArray(target)) {
  849. 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.`);
  850. }
  851. const existingOb = target && target.__ob__;
  852. if (existingOb && existingOb.shallow !== shallow) {
  853. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  854. }
  855. }
  856. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  857. if (!ob) {
  858. if (target == null || isPrimitive(target)) {
  859. warn$2(`value cannot be made reactive: ${String(target)}`);
  860. }
  861. if (isCollectionType(target)) {
  862. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  863. }
  864. }
  865. }
  866. }
  867. function isReactive(value) {
  868. if (isReadonly(value)) {
  869. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  870. }
  871. return !!(value && value.__ob__);
  872. }
  873. function isShallow(value) {
  874. return !!(value && value.__v_isShallow);
  875. }
  876. function isReadonly(value) {
  877. return !!(value && value.__v_isReadonly);
  878. }
  879. function isProxy(value) {
  880. return isReactive(value) || isReadonly(value);
  881. }
  882. function toRaw(observed) {
  883. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  884. return raw ? toRaw(raw) : observed;
  885. }
  886. function markRaw(value) {
  887. if (isObject(value)) {
  888. rawMap.set(value, true);
  889. }
  890. return value;
  891. }
  892. /**
  893. * @internal
  894. */
  895. function isCollectionType(value) {
  896. const type = toRawType(value);
  897. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  898. }
  899. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  900. const NO_INIITIAL_VALUE = {};
  901. /**
  902. * In some cases we may want to disable observation inside a component's
  903. * update computation.
  904. */
  905. let shouldObserve = true;
  906. function toggleObserving(value) {
  907. shouldObserve = value;
  908. }
  909. // ssr mock dep
  910. const mockDep = {
  911. notify: noop,
  912. depend: noop,
  913. addSub: noop,
  914. removeSub: noop
  915. };
  916. /**
  917. * Observer class that is attached to each observed
  918. * object. Once attached, the observer converts the target
  919. * object's property keys into getter/setters that
  920. * collect dependencies and dispatch updates.
  921. */
  922. class Observer {
  923. constructor(value, shallow = false, mock = false) {
  924. this.value = value;
  925. this.shallow = shallow;
  926. this.mock = mock;
  927. // this.value = value
  928. this.dep = mock ? mockDep : new Dep();
  929. this.vmCount = 0;
  930. def(value, '__ob__', this);
  931. if (isArray(value)) {
  932. if (!mock) {
  933. if (hasProto) {
  934. value.__proto__ = arrayMethods;
  935. /* eslint-enable no-proto */
  936. }
  937. else {
  938. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  939. const key = arrayKeys[i];
  940. def(value, key, arrayMethods[key]);
  941. }
  942. }
  943. }
  944. if (!shallow) {
  945. this.observeArray(value);
  946. }
  947. }
  948. else {
  949. /**
  950. * Walk through all properties and convert them into
  951. * getter/setters. This method should only be called when
  952. * value type is Object.
  953. */
  954. const keys = Object.keys(value);
  955. for (let i = 0; i < keys.length; i++) {
  956. const key = keys[i];
  957. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  958. }
  959. }
  960. }
  961. /**
  962. * Observe a list of Array items.
  963. */
  964. observeArray(value) {
  965. for (let i = 0, l = value.length; i < l; i++) {
  966. observe(value[i], false, this.mock);
  967. }
  968. }
  969. }
  970. // helpers
  971. /**
  972. * Attempt to create an observer instance for a value,
  973. * returns the new observer if successfully observed,
  974. * or the existing observer if the value already has one.
  975. */
  976. function observe(value, shallow, ssrMockReactivity) {
  977. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  978. return value.__ob__;
  979. }
  980. if (shouldObserve &&
  981. (ssrMockReactivity || !isServerRendering()) &&
  982. (isArray(value) || isPlainObject(value)) &&
  983. Object.isExtensible(value) &&
  984. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  985. !rawMap.has(value) &&
  986. !isRef(value) &&
  987. !(value instanceof VNode)) {
  988. return new Observer(value, shallow, ssrMockReactivity);
  989. }
  990. }
  991. /**
  992. * Define a reactive property on an Object.
  993. */
  994. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  995. const dep = new Dep();
  996. const property = Object.getOwnPropertyDescriptor(obj, key);
  997. if (property && property.configurable === false) {
  998. return;
  999. }
  1000. // cater for pre-defined getter/setters
  1001. const getter = property && property.get;
  1002. const setter = property && property.set;
  1003. if ((!getter || setter) &&
  1004. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  1005. val = obj[key];
  1006. }
  1007. let childOb = !shallow && observe(val, false, mock);
  1008. Object.defineProperty(obj, key, {
  1009. enumerable: true,
  1010. configurable: true,
  1011. get: function reactiveGetter() {
  1012. const value = getter ? getter.call(obj) : val;
  1013. if (Dep.target) {
  1014. {
  1015. dep.depend({
  1016. target: obj,
  1017. type: "get" /* TrackOpTypes.GET */,
  1018. key
  1019. });
  1020. }
  1021. if (childOb) {
  1022. childOb.dep.depend();
  1023. if (isArray(value)) {
  1024. dependArray(value);
  1025. }
  1026. }
  1027. }
  1028. return isRef(value) && !shallow ? value.value : value;
  1029. },
  1030. set: function reactiveSetter(newVal) {
  1031. const value = getter ? getter.call(obj) : val;
  1032. if (!hasChanged(value, newVal)) {
  1033. return;
  1034. }
  1035. if (customSetter) {
  1036. customSetter();
  1037. }
  1038. if (setter) {
  1039. setter.call(obj, newVal);
  1040. }
  1041. else if (getter) {
  1042. // #7981: for accessor properties without setter
  1043. return;
  1044. }
  1045. else if (!shallow && isRef(value) && !isRef(newVal)) {
  1046. value.value = newVal;
  1047. return;
  1048. }
  1049. else {
  1050. val = newVal;
  1051. }
  1052. childOb = !shallow && observe(newVal, false, mock);
  1053. {
  1054. dep.notify({
  1055. type: "set" /* TriggerOpTypes.SET */,
  1056. target: obj,
  1057. key,
  1058. newValue: newVal,
  1059. oldValue: value
  1060. });
  1061. }
  1062. }
  1063. });
  1064. return dep;
  1065. }
  1066. function set(target, key, val) {
  1067. if ((isUndef(target) || isPrimitive(target))) {
  1068. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  1069. }
  1070. if (isReadonly(target)) {
  1071. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1072. return;
  1073. }
  1074. const ob = target.__ob__;
  1075. if (isArray(target) && isValidArrayIndex(key)) {
  1076. target.length = Math.max(target.length, key);
  1077. target.splice(key, 1, val);
  1078. // when mocking for SSR, array methods are not hijacked
  1079. if (ob && !ob.shallow && ob.mock) {
  1080. observe(val, false, true);
  1081. }
  1082. return val;
  1083. }
  1084. if (key in target && !(key in Object.prototype)) {
  1085. target[key] = val;
  1086. return val;
  1087. }
  1088. if (target._isVue || (ob && ob.vmCount)) {
  1089. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1090. 'at runtime - declare it upfront in the data option.');
  1091. return val;
  1092. }
  1093. if (!ob) {
  1094. target[key] = val;
  1095. return val;
  1096. }
  1097. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1098. {
  1099. ob.dep.notify({
  1100. type: "add" /* TriggerOpTypes.ADD */,
  1101. target: target,
  1102. key,
  1103. newValue: val,
  1104. oldValue: undefined
  1105. });
  1106. }
  1107. return val;
  1108. }
  1109. function del(target, key) {
  1110. if ((isUndef(target) || isPrimitive(target))) {
  1111. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1112. }
  1113. if (isArray(target) && isValidArrayIndex(key)) {
  1114. target.splice(key, 1);
  1115. return;
  1116. }
  1117. const ob = target.__ob__;
  1118. if (target._isVue || (ob && ob.vmCount)) {
  1119. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1120. '- just set it to null.');
  1121. return;
  1122. }
  1123. if (isReadonly(target)) {
  1124. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1125. return;
  1126. }
  1127. if (!hasOwn(target, key)) {
  1128. return;
  1129. }
  1130. delete target[key];
  1131. if (!ob) {
  1132. return;
  1133. }
  1134. {
  1135. ob.dep.notify({
  1136. type: "delete" /* TriggerOpTypes.DELETE */,
  1137. target: target,
  1138. key
  1139. });
  1140. }
  1141. }
  1142. /**
  1143. * Collect dependencies on array elements when the array is touched, since
  1144. * we cannot intercept array element access like property getters.
  1145. */
  1146. function dependArray(value) {
  1147. for (let e, i = 0, l = value.length; i < l; i++) {
  1148. e = value[i];
  1149. if (e && e.__ob__) {
  1150. e.__ob__.dep.depend();
  1151. }
  1152. if (isArray(e)) {
  1153. dependArray(e);
  1154. }
  1155. }
  1156. }
  1157. /**
  1158. * @internal
  1159. */
  1160. const RefFlag = `__v_isRef`;
  1161. function isRef(r) {
  1162. return !!(r && r.__v_isRef === true);
  1163. }
  1164. function ref$1(value) {
  1165. return createRef(value, false);
  1166. }
  1167. function shallowRef(value) {
  1168. return createRef(value, true);
  1169. }
  1170. function createRef(rawValue, shallow) {
  1171. if (isRef(rawValue)) {
  1172. return rawValue;
  1173. }
  1174. const ref = {};
  1175. def(ref, RefFlag, true);
  1176. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1177. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1178. return ref;
  1179. }
  1180. function triggerRef(ref) {
  1181. if (!ref.dep) {
  1182. warn$2(`received object is not a triggerable ref.`);
  1183. }
  1184. {
  1185. ref.dep &&
  1186. ref.dep.notify({
  1187. type: "set" /* TriggerOpTypes.SET */,
  1188. target: ref,
  1189. key: 'value'
  1190. });
  1191. }
  1192. }
  1193. function unref(ref) {
  1194. return isRef(ref) ? ref.value : ref;
  1195. }
  1196. function proxyRefs(objectWithRefs) {
  1197. if (isReactive(objectWithRefs)) {
  1198. return objectWithRefs;
  1199. }
  1200. const proxy = {};
  1201. const keys = Object.keys(objectWithRefs);
  1202. for (let i = 0; i < keys.length; i++) {
  1203. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1204. }
  1205. return proxy;
  1206. }
  1207. function proxyWithRefUnwrap(target, source, key) {
  1208. Object.defineProperty(target, key, {
  1209. enumerable: true,
  1210. configurable: true,
  1211. get: () => {
  1212. const val = source[key];
  1213. if (isRef(val)) {
  1214. return val.value;
  1215. }
  1216. else {
  1217. const ob = val && val.__ob__;
  1218. if (ob)
  1219. ob.dep.depend();
  1220. return val;
  1221. }
  1222. },
  1223. set: value => {
  1224. const oldValue = source[key];
  1225. if (isRef(oldValue) && !isRef(value)) {
  1226. oldValue.value = value;
  1227. }
  1228. else {
  1229. source[key] = value;
  1230. }
  1231. }
  1232. });
  1233. }
  1234. function customRef(factory) {
  1235. const dep = new Dep();
  1236. const { get, set } = factory(() => {
  1237. {
  1238. dep.depend({
  1239. target: ref,
  1240. type: "get" /* TrackOpTypes.GET */,
  1241. key: 'value'
  1242. });
  1243. }
  1244. }, () => {
  1245. {
  1246. dep.notify({
  1247. target: ref,
  1248. type: "set" /* TriggerOpTypes.SET */,
  1249. key: 'value'
  1250. });
  1251. }
  1252. });
  1253. const ref = {
  1254. get value() {
  1255. return get();
  1256. },
  1257. set value(newVal) {
  1258. set(newVal);
  1259. }
  1260. };
  1261. def(ref, RefFlag, true);
  1262. return ref;
  1263. }
  1264. function toRefs(object) {
  1265. if (!isReactive(object)) {
  1266. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1267. }
  1268. const ret = isArray(object) ? new Array(object.length) : {};
  1269. for (const key in object) {
  1270. ret[key] = toRef(object, key);
  1271. }
  1272. return ret;
  1273. }
  1274. function toRef(object, key, defaultValue) {
  1275. const val = object[key];
  1276. if (isRef(val)) {
  1277. return val;
  1278. }
  1279. const ref = {
  1280. get value() {
  1281. const val = object[key];
  1282. return val === undefined ? defaultValue : val;
  1283. },
  1284. set value(newVal) {
  1285. object[key] = newVal;
  1286. }
  1287. };
  1288. def(ref, RefFlag, true);
  1289. return ref;
  1290. }
  1291. const rawToReadonlyMap = new WeakMap();
  1292. const rawToShallowReadonlyMap = new WeakMap();
  1293. function readonly(target) {
  1294. return createReadonly(target, false);
  1295. }
  1296. function createReadonly(target, shallow) {
  1297. if (!isPlainObject(target)) {
  1298. {
  1299. if (isArray(target)) {
  1300. warn$2(`Vue 2 does not support readonly arrays.`);
  1301. }
  1302. else if (isCollectionType(target)) {
  1303. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1304. }
  1305. else {
  1306. warn$2(`value cannot be made readonly: ${typeof target}`);
  1307. }
  1308. }
  1309. return target;
  1310. }
  1311. // already a readonly object
  1312. if (isReadonly(target)) {
  1313. return target;
  1314. }
  1315. // already has a readonly proxy
  1316. const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap;
  1317. const existingProxy = map.get(target);
  1318. if (existingProxy) {
  1319. return existingProxy;
  1320. }
  1321. const proxy = Object.create(Object.getPrototypeOf(target));
  1322. map.set(target, proxy);
  1323. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1324. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1325. if (isRef(target)) {
  1326. def(proxy, RefFlag, true);
  1327. }
  1328. if (shallow || isShallow(target)) {
  1329. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1330. }
  1331. const keys = Object.keys(target);
  1332. for (let i = 0; i < keys.length; i++) {
  1333. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1334. }
  1335. return proxy;
  1336. }
  1337. function defineReadonlyProperty(proxy, target, key, shallow) {
  1338. Object.defineProperty(proxy, key, {
  1339. enumerable: true,
  1340. configurable: true,
  1341. get() {
  1342. const val = target[key];
  1343. return shallow || !isPlainObject(val) ? val : readonly(val);
  1344. },
  1345. set() {
  1346. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1347. }
  1348. });
  1349. }
  1350. /**
  1351. * Returns a reactive-copy of the original object, where only the root level
  1352. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1353. * returned properties.
  1354. * This is used for creating the props proxy object for stateful components.
  1355. */
  1356. function shallowReadonly(target) {
  1357. return createReadonly(target, true);
  1358. }
  1359. function computed(getterOrOptions, debugOptions) {
  1360. let getter;
  1361. let setter;
  1362. const onlyGetter = isFunction(getterOrOptions);
  1363. if (onlyGetter) {
  1364. getter = getterOrOptions;
  1365. setter = () => {
  1366. warn$2('Write operation failed: computed value is readonly');
  1367. }
  1368. ;
  1369. }
  1370. else {
  1371. getter = getterOrOptions.get;
  1372. setter = getterOrOptions.set;
  1373. }
  1374. const watcher = isServerRendering()
  1375. ? null
  1376. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1377. if (watcher && debugOptions) {
  1378. watcher.onTrack = debugOptions.onTrack;
  1379. watcher.onTrigger = debugOptions.onTrigger;
  1380. }
  1381. const ref = {
  1382. // some libs rely on the presence effect for checking computed refs
  1383. // from normal refs, but the implementation doesn't matter
  1384. effect: watcher,
  1385. get value() {
  1386. if (watcher) {
  1387. if (watcher.dirty) {
  1388. watcher.evaluate();
  1389. }
  1390. if (Dep.target) {
  1391. if (Dep.target.onTrack) {
  1392. Dep.target.onTrack({
  1393. effect: Dep.target,
  1394. target: ref,
  1395. type: "get" /* TrackOpTypes.GET */,
  1396. key: 'value'
  1397. });
  1398. }
  1399. watcher.depend();
  1400. }
  1401. return watcher.value;
  1402. }
  1403. else {
  1404. return getter();
  1405. }
  1406. },
  1407. set value(newVal) {
  1408. setter(newVal);
  1409. }
  1410. };
  1411. def(ref, RefFlag, true);
  1412. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1413. return ref;
  1414. }
  1415. let mark;
  1416. let measure;
  1417. {
  1418. const perf = inBrowser && window.performance;
  1419. /* istanbul ignore if */
  1420. if (perf &&
  1421. // @ts-ignore
  1422. perf.mark &&
  1423. // @ts-ignore
  1424. perf.measure &&
  1425. // @ts-ignore
  1426. perf.clearMarks &&
  1427. // @ts-ignore
  1428. perf.clearMeasures) {
  1429. mark = tag => perf.mark(tag);
  1430. measure = (name, startTag, endTag) => {
  1431. perf.measure(name, startTag, endTag);
  1432. perf.clearMarks(startTag);
  1433. perf.clearMarks(endTag);
  1434. // perf.clearMeasures(name)
  1435. };
  1436. }
  1437. }
  1438. const normalizeEvent = cached((name) => {
  1439. const passive = name.charAt(0) === '&';
  1440. name = passive ? name.slice(1) : name;
  1441. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1442. name = once ? name.slice(1) : name;
  1443. const capture = name.charAt(0) === '!';
  1444. name = capture ? name.slice(1) : name;
  1445. return {
  1446. name,
  1447. once,
  1448. capture,
  1449. passive
  1450. };
  1451. });
  1452. function createFnInvoker(fns, vm) {
  1453. function invoker() {
  1454. const fns = invoker.fns;
  1455. if (isArray(fns)) {
  1456. const cloned = fns.slice();
  1457. for (let i = 0; i < cloned.length; i++) {
  1458. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1459. }
  1460. }
  1461. else {
  1462. // return handler return value for single handlers
  1463. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1464. }
  1465. }
  1466. invoker.fns = fns;
  1467. return invoker;
  1468. }
  1469. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1470. let name, cur, old, event;
  1471. for (name in on) {
  1472. cur = on[name];
  1473. old = oldOn[name];
  1474. event = normalizeEvent(name);
  1475. if (isUndef(cur)) {
  1476. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1477. }
  1478. else if (isUndef(old)) {
  1479. if (isUndef(cur.fns)) {
  1480. cur = on[name] = createFnInvoker(cur, vm);
  1481. }
  1482. if (isTrue(event.once)) {
  1483. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1484. }
  1485. add(event.name, cur, event.capture, event.passive, event.params);
  1486. }
  1487. else if (cur !== old) {
  1488. old.fns = cur;
  1489. on[name] = old;
  1490. }
  1491. }
  1492. for (name in oldOn) {
  1493. if (isUndef(on[name])) {
  1494. event = normalizeEvent(name);
  1495. remove(event.name, oldOn[name], event.capture);
  1496. }
  1497. }
  1498. }
  1499. function mergeVNodeHook(def, hookKey, hook) {
  1500. if (def instanceof VNode) {
  1501. def = def.data.hook || (def.data.hook = {});
  1502. }
  1503. let invoker;
  1504. const oldHook = def[hookKey];
  1505. function wrappedHook() {
  1506. hook.apply(this, arguments);
  1507. // important: remove merged hook to ensure it's called only once
  1508. // and prevent memory leak
  1509. remove$2(invoker.fns, wrappedHook);
  1510. }
  1511. if (isUndef(oldHook)) {
  1512. // no existing hook
  1513. invoker = createFnInvoker([wrappedHook]);
  1514. }
  1515. else {
  1516. /* istanbul ignore if */
  1517. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1518. // already a merged invoker
  1519. invoker = oldHook;
  1520. invoker.fns.push(wrappedHook);
  1521. }
  1522. else {
  1523. // existing plain hook
  1524. invoker = createFnInvoker([oldHook, wrappedHook]);
  1525. }
  1526. }
  1527. invoker.merged = true;
  1528. def[hookKey] = invoker;
  1529. }
  1530. function extractPropsFromVNodeData(data, Ctor, tag) {
  1531. // we are only extracting raw values here.
  1532. // validation and default values are handled in the child
  1533. // component itself.
  1534. const propOptions = Ctor.options.props;
  1535. if (isUndef(propOptions)) {
  1536. return;
  1537. }
  1538. const res = {};
  1539. const { attrs, props } = data;
  1540. if (isDef(attrs) || isDef(props)) {
  1541. for (const key in propOptions) {
  1542. const altKey = hyphenate(key);
  1543. {
  1544. const keyInLowerCase = key.toLowerCase();
  1545. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1546. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1547. `${formatComponentName(
  1548. // @ts-expect-error tag is string
  1549. tag || Ctor)}, but the declared prop name is` +
  1550. ` "${key}". ` +
  1551. `Note that HTML attributes are case-insensitive and camelCased ` +
  1552. `props need to use their kebab-case equivalents when using in-DOM ` +
  1553. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1554. }
  1555. }
  1556. checkProp(res, props, key, altKey, true) ||
  1557. checkProp(res, attrs, key, altKey, false);
  1558. }
  1559. }
  1560. return res;
  1561. }
  1562. function checkProp(res, hash, key, altKey, preserve) {
  1563. if (isDef(hash)) {
  1564. if (hasOwn(hash, key)) {
  1565. res[key] = hash[key];
  1566. if (!preserve) {
  1567. delete hash[key];
  1568. }
  1569. return true;
  1570. }
  1571. else if (hasOwn(hash, altKey)) {
  1572. res[key] = hash[altKey];
  1573. if (!preserve) {
  1574. delete hash[altKey];
  1575. }
  1576. return true;
  1577. }
  1578. }
  1579. return false;
  1580. }
  1581. // The template compiler attempts to minimize the need for normalization by
  1582. // statically analyzing the template at compile time.
  1583. //
  1584. // For plain HTML markup, normalization can be completely skipped because the
  1585. // generated render function is guaranteed to return Array<VNode>. There are
  1586. // two cases where extra normalization is needed:
  1587. // 1. When the children contains components - because a functional component
  1588. // may return an Array instead of a single root. In this case, just a simple
  1589. // normalization is needed - if any child is an Array, we flatten the whole
  1590. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1591. // because functional components already normalize their own children.
  1592. function simpleNormalizeChildren(children) {
  1593. for (let i = 0; i < children.length; i++) {
  1594. if (isArray(children[i])) {
  1595. return Array.prototype.concat.apply([], children);
  1596. }
  1597. }
  1598. return children;
  1599. }
  1600. // 2. When the children contains constructs that always generated nested Arrays,
  1601. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1602. // with hand-written render functions / JSX. In such cases a full normalization
  1603. // is needed to cater to all possible types of children values.
  1604. function normalizeChildren(children) {
  1605. return isPrimitive(children)
  1606. ? [createTextVNode(children)]
  1607. : isArray(children)
  1608. ? normalizeArrayChildren(children)
  1609. : undefined;
  1610. }
  1611. function isTextNode(node) {
  1612. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1613. }
  1614. function normalizeArrayChildren(children, nestedIndex) {
  1615. const res = [];
  1616. let i, c, lastIndex, last;
  1617. for (i = 0; i < children.length; i++) {
  1618. c = children[i];
  1619. if (isUndef(c) || typeof c === 'boolean')
  1620. continue;
  1621. lastIndex = res.length - 1;
  1622. last = res[lastIndex];
  1623. // nested
  1624. if (isArray(c)) {
  1625. if (c.length > 0) {
  1626. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1627. // merge adjacent text nodes
  1628. if (isTextNode(c[0]) && isTextNode(last)) {
  1629. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1630. c.shift();
  1631. }
  1632. res.push.apply(res, c);
  1633. }
  1634. }
  1635. else if (isPrimitive(c)) {
  1636. if (isTextNode(last)) {
  1637. // merge adjacent text nodes
  1638. // this is necessary for SSR hydration because text nodes are
  1639. // essentially merged when rendered to HTML strings
  1640. res[lastIndex] = createTextVNode(last.text + c);
  1641. }
  1642. else if (c !== '') {
  1643. // convert primitive to vnode
  1644. res.push(createTextVNode(c));
  1645. }
  1646. }
  1647. else {
  1648. if (isTextNode(c) && isTextNode(last)) {
  1649. // merge adjacent text nodes
  1650. res[lastIndex] = createTextVNode(last.text + c.text);
  1651. }
  1652. else {
  1653. // default key for nested array children (likely generated by v-for)
  1654. if (isTrue(children._isVList) &&
  1655. isDef(c.tag) &&
  1656. isUndef(c.key) &&
  1657. isDef(nestedIndex)) {
  1658. c.key = `__vlist${nestedIndex}_${i}__`;
  1659. }
  1660. res.push(c);
  1661. }
  1662. }
  1663. }
  1664. return res;
  1665. }
  1666. const SIMPLE_NORMALIZE = 1;
  1667. const ALWAYS_NORMALIZE = 2;
  1668. // wrapper function for providing a more flexible interface
  1669. // without getting yelled at by flow
  1670. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1671. if (isArray(data) || isPrimitive(data)) {
  1672. normalizationType = children;
  1673. children = data;
  1674. data = undefined;
  1675. }
  1676. if (isTrue(alwaysNormalize)) {
  1677. normalizationType = ALWAYS_NORMALIZE;
  1678. }
  1679. return _createElement(context, tag, data, children, normalizationType);
  1680. }
  1681. function _createElement(context, tag, data, children, normalizationType) {
  1682. if (isDef(data) && isDef(data.__ob__)) {
  1683. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1684. return createEmptyVNode();
  1685. }
  1686. // object syntax in v-bind
  1687. if (isDef(data) && isDef(data.is)) {
  1688. tag = data.is;
  1689. }
  1690. if (!tag) {
  1691. // in case of component :is set to falsy value
  1692. return createEmptyVNode();
  1693. }
  1694. // warn against non-primitive key
  1695. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1696. warn$2('Avoid using non-primitive value as key, ' +
  1697. 'use string/number value instead.', context);
  1698. }
  1699. // support single function children as default scoped slot
  1700. if (isArray(children) && isFunction(children[0])) {
  1701. data = data || {};
  1702. data.scopedSlots = { default: children[0] };
  1703. children.length = 0;
  1704. }
  1705. if (normalizationType === ALWAYS_NORMALIZE) {
  1706. children = normalizeChildren(children);
  1707. }
  1708. else if (normalizationType === SIMPLE_NORMALIZE) {
  1709. children = simpleNormalizeChildren(children);
  1710. }
  1711. let vnode, ns;
  1712. if (typeof tag === 'string') {
  1713. let Ctor;
  1714. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1715. if (config.isReservedTag(tag)) {
  1716. // platform built-in elements
  1717. if (isDef(data) &&
  1718. isDef(data.nativeOn) &&
  1719. data.tag !== 'component') {
  1720. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1721. }
  1722. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1723. }
  1724. else if ((!data || !data.pre) &&
  1725. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1726. // component
  1727. vnode = createComponent(Ctor, data, context, children, tag);
  1728. }
  1729. else {
  1730. // unknown or unlisted namespaced elements
  1731. // check at runtime because it may get assigned a namespace when its
  1732. // parent normalizes children
  1733. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1734. }
  1735. }
  1736. else {
  1737. // direct component options / constructor
  1738. vnode = createComponent(tag, data, context, children);
  1739. }
  1740. if (isArray(vnode)) {
  1741. return vnode;
  1742. }
  1743. else if (isDef(vnode)) {
  1744. if (isDef(ns))
  1745. applyNS(vnode, ns);
  1746. if (isDef(data))
  1747. registerDeepBindings(data);
  1748. return vnode;
  1749. }
  1750. else {
  1751. return createEmptyVNode();
  1752. }
  1753. }
  1754. function applyNS(vnode, ns, force) {
  1755. vnode.ns = ns;
  1756. if (vnode.tag === 'foreignObject') {
  1757. // use default namespace inside foreignObject
  1758. ns = undefined;
  1759. force = true;
  1760. }
  1761. if (isDef(vnode.children)) {
  1762. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1763. const child = vnode.children[i];
  1764. if (isDef(child.tag) &&
  1765. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1766. applyNS(child, ns, force);
  1767. }
  1768. }
  1769. }
  1770. }
  1771. // ref #5318
  1772. // necessary to ensure parent re-render when deep bindings like :style and
  1773. // :class are used on slot nodes
  1774. function registerDeepBindings(data) {
  1775. if (isObject(data.style)) {
  1776. traverse(data.style);
  1777. }
  1778. if (isObject(data.class)) {
  1779. traverse(data.class);
  1780. }
  1781. }
  1782. /**
  1783. * Runtime helper for rendering v-for lists.
  1784. */
  1785. function renderList(val, render) {
  1786. let ret = null, i, l, keys, key;
  1787. if (isArray(val) || typeof val === 'string') {
  1788. ret = new Array(val.length);
  1789. for (i = 0, l = val.length; i < l; i++) {
  1790. ret[i] = render(val[i], i);
  1791. }
  1792. }
  1793. else if (typeof val === 'number') {
  1794. ret = new Array(val);
  1795. for (i = 0; i < val; i++) {
  1796. ret[i] = render(i + 1, i);
  1797. }
  1798. }
  1799. else if (isObject(val)) {
  1800. if (hasSymbol && val[Symbol.iterator]) {
  1801. ret = [];
  1802. const iterator = val[Symbol.iterator]();
  1803. let result = iterator.next();
  1804. while (!result.done) {
  1805. ret.push(render(result.value, ret.length));
  1806. result = iterator.next();
  1807. }
  1808. }
  1809. else {
  1810. keys = Object.keys(val);
  1811. ret = new Array(keys.length);
  1812. for (i = 0, l = keys.length; i < l; i++) {
  1813. key = keys[i];
  1814. ret[i] = render(val[key], key, i);
  1815. }
  1816. }
  1817. }
  1818. if (!isDef(ret)) {
  1819. ret = [];
  1820. }
  1821. ret._isVList = true;
  1822. return ret;
  1823. }
  1824. /**
  1825. * Runtime helper for rendering <slot>
  1826. */
  1827. function renderSlot(name, fallbackRender, props, bindObject) {
  1828. const scopedSlotFn = this.$scopedSlots[name];
  1829. let nodes;
  1830. if (scopedSlotFn) {
  1831. // scoped slot
  1832. props = props || {};
  1833. if (bindObject) {
  1834. if (!isObject(bindObject)) {
  1835. warn$2('slot v-bind without argument expects an Object', this);
  1836. }
  1837. props = extend(extend({}, bindObject), props);
  1838. }
  1839. nodes =
  1840. scopedSlotFn(props) ||
  1841. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1842. }
  1843. else {
  1844. nodes =
  1845. this.$slots[name] ||
  1846. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1847. }
  1848. const target = props && props.slot;
  1849. if (target) {
  1850. return this.$createElement('template', { slot: target }, nodes);
  1851. }
  1852. else {
  1853. return nodes;
  1854. }
  1855. }
  1856. /**
  1857. * Runtime helper for resolving filters
  1858. */
  1859. function resolveFilter(id) {
  1860. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1861. }
  1862. function isKeyNotMatch(expect, actual) {
  1863. if (isArray(expect)) {
  1864. return expect.indexOf(actual) === -1;
  1865. }
  1866. else {
  1867. return expect !== actual;
  1868. }
  1869. }
  1870. /**
  1871. * Runtime helper for checking keyCodes from config.
  1872. * exposed as Vue.prototype._k
  1873. * passing in eventKeyName as last argument separately for backwards compat
  1874. */
  1875. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1876. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1877. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1878. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1879. }
  1880. else if (mappedKeyCode) {
  1881. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1882. }
  1883. else if (eventKeyName) {
  1884. return hyphenate(eventKeyName) !== key;
  1885. }
  1886. return eventKeyCode === undefined;
  1887. }
  1888. /**
  1889. * Runtime helper for merging v-bind="object" into a VNode's data.
  1890. */
  1891. function bindObjectProps(data, tag, value, asProp, isSync) {
  1892. if (value) {
  1893. if (!isObject(value)) {
  1894. warn$2('v-bind without argument expects an Object or Array value', this);
  1895. }
  1896. else {
  1897. if (isArray(value)) {
  1898. value = toObject(value);
  1899. }
  1900. let hash;
  1901. for (const key in value) {
  1902. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1903. hash = data;
  1904. }
  1905. else {
  1906. const type = data.attrs && data.attrs.type;
  1907. hash =
  1908. asProp || config.mustUseProp(tag, type, key)
  1909. ? data.domProps || (data.domProps = {})
  1910. : data.attrs || (data.attrs = {});
  1911. }
  1912. const camelizedKey = camelize(key);
  1913. const hyphenatedKey = hyphenate(key);
  1914. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1915. hash[key] = value[key];
  1916. if (isSync) {
  1917. const on = data.on || (data.on = {});
  1918. on[`update:${key}`] = function ($event) {
  1919. value[key] = $event;
  1920. };
  1921. }
  1922. }
  1923. }
  1924. }
  1925. }
  1926. return data;
  1927. }
  1928. /**
  1929. * Runtime helper for rendering static trees.
  1930. */
  1931. function renderStatic(index, isInFor) {
  1932. const cached = this._staticTrees || (this._staticTrees = []);
  1933. let tree = cached[index];
  1934. // if has already-rendered static tree and not inside v-for,
  1935. // we can reuse the same tree.
  1936. if (tree && !isInFor) {
  1937. return tree;
  1938. }
  1939. // otherwise, render a fresh tree.
  1940. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1941. );
  1942. markStatic$1(tree, `__static__${index}`, false);
  1943. return tree;
  1944. }
  1945. /**
  1946. * Runtime helper for v-once.
  1947. * Effectively it means marking the node as static with a unique key.
  1948. */
  1949. function markOnce(tree, index, key) {
  1950. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1951. return tree;
  1952. }
  1953. function markStatic$1(tree, key, isOnce) {
  1954. if (isArray(tree)) {
  1955. for (let i = 0; i < tree.length; i++) {
  1956. if (tree[i] && typeof tree[i] !== 'string') {
  1957. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1958. }
  1959. }
  1960. }
  1961. else {
  1962. markStaticNode(tree, key, isOnce);
  1963. }
  1964. }
  1965. function markStaticNode(node, key, isOnce) {
  1966. node.isStatic = true;
  1967. node.key = key;
  1968. node.isOnce = isOnce;
  1969. }
  1970. function bindObjectListeners(data, value) {
  1971. if (value) {
  1972. if (!isPlainObject(value)) {
  1973. warn$2('v-on without argument expects an Object value', this);
  1974. }
  1975. else {
  1976. const on = (data.on = data.on ? extend({}, data.on) : {});
  1977. for (const key in value) {
  1978. const existing = on[key];
  1979. const ours = value[key];
  1980. on[key] = existing ? [].concat(existing, ours) : ours;
  1981. }
  1982. }
  1983. }
  1984. return data;
  1985. }
  1986. function resolveScopedSlots(fns, res,
  1987. // the following are added in 2.6
  1988. hasDynamicKeys, contentHashKey) {
  1989. res = res || { $stable: !hasDynamicKeys };
  1990. for (let i = 0; i < fns.length; i++) {
  1991. const slot = fns[i];
  1992. if (isArray(slot)) {
  1993. resolveScopedSlots(slot, res, hasDynamicKeys);
  1994. }
  1995. else if (slot) {
  1996. // marker for reverse proxying v-slot without scope on this.$slots
  1997. // @ts-expect-error
  1998. if (slot.proxy) {
  1999. // @ts-expect-error
  2000. slot.fn.proxy = true;
  2001. }
  2002. res[slot.key] = slot.fn;
  2003. }
  2004. }
  2005. if (contentHashKey) {
  2006. res.$key = contentHashKey;
  2007. }
  2008. return res;
  2009. }
  2010. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2011. function bindDynamicKeys(baseObj, values) {
  2012. for (let i = 0; i < values.length; i += 2) {
  2013. const key = values[i];
  2014. if (typeof key === 'string' && key) {
  2015. baseObj[values[i]] = values[i + 1];
  2016. }
  2017. else if (key !== '' && key !== null) {
  2018. // null is a special value for explicitly removing a binding
  2019. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2020. }
  2021. }
  2022. return baseObj;
  2023. }
  2024. // helper to dynamically append modifier runtime markers to event names.
  2025. // ensure only append when value is already string, otherwise it will be cast
  2026. // to string and cause the type check to miss.
  2027. function prependModifier(value, symbol) {
  2028. return typeof value === 'string' ? symbol + value : value;
  2029. }
  2030. function installRenderHelpers(target) {
  2031. target._o = markOnce;
  2032. target._n = toNumber;
  2033. target._s = toString;
  2034. target._l = renderList;
  2035. target._t = renderSlot;
  2036. target._q = looseEqual;
  2037. target._i = looseIndexOf;
  2038. target._m = renderStatic;
  2039. target._f = resolveFilter;
  2040. target._k = checkKeyCodes;
  2041. target._b = bindObjectProps;
  2042. target._v = createTextVNode;
  2043. target._e = createEmptyVNode;
  2044. target._u = resolveScopedSlots;
  2045. target._g = bindObjectListeners;
  2046. target._d = bindDynamicKeys;
  2047. target._p = prependModifier;
  2048. }
  2049. /**
  2050. * Runtime helper for resolving raw children VNodes into a slot object.
  2051. */
  2052. function resolveSlots(children, context) {
  2053. if (!children || !children.length) {
  2054. return {};
  2055. }
  2056. const slots = {};
  2057. for (let i = 0, l = children.length; i < l; i++) {
  2058. const child = children[i];
  2059. const data = child.data;
  2060. // remove slot attribute if the node is resolved as a Vue slot node
  2061. if (data && data.attrs && data.attrs.slot) {
  2062. delete data.attrs.slot;
  2063. }
  2064. // named slots should only be respected if the vnode was rendered in the
  2065. // same context.
  2066. if ((child.context === context || child.fnContext === context) &&
  2067. data &&
  2068. data.slot != null) {
  2069. const name = data.slot;
  2070. const slot = slots[name] || (slots[name] = []);
  2071. if (child.tag === 'template') {
  2072. slot.push.apply(slot, child.children || []);
  2073. }
  2074. else {
  2075. slot.push(child);
  2076. }
  2077. }
  2078. else {
  2079. (slots.default || (slots.default = [])).push(child);
  2080. }
  2081. }
  2082. // ignore slots that contains only whitespace
  2083. for (const name in slots) {
  2084. if (slots[name].every(isWhitespace)) {
  2085. delete slots[name];
  2086. }
  2087. }
  2088. return slots;
  2089. }
  2090. function isWhitespace(node) {
  2091. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2092. }
  2093. function isAsyncPlaceholder(node) {
  2094. // @ts-expect-error not really boolean type
  2095. return node.isComment && node.asyncFactory;
  2096. }
  2097. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2098. let res;
  2099. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2100. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2101. const key = scopedSlots && scopedSlots.$key;
  2102. if (!scopedSlots) {
  2103. res = {};
  2104. }
  2105. else if (scopedSlots._normalized) {
  2106. // fast path 1: child component re-render only, parent did not change
  2107. return scopedSlots._normalized;
  2108. }
  2109. else if (isStable &&
  2110. prevScopedSlots &&
  2111. prevScopedSlots !== emptyObject &&
  2112. key === prevScopedSlots.$key &&
  2113. !hasNormalSlots &&
  2114. !prevScopedSlots.$hasNormal) {
  2115. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2116. // only need to normalize once
  2117. return prevScopedSlots;
  2118. }
  2119. else {
  2120. res = {};
  2121. for (const key in scopedSlots) {
  2122. if (scopedSlots[key] && key[0] !== '$') {
  2123. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2124. }
  2125. }
  2126. }
  2127. // expose normal slots on scopedSlots
  2128. for (const key in normalSlots) {
  2129. if (!(key in res)) {
  2130. res[key] = proxyNormalSlot(normalSlots, key);
  2131. }
  2132. }
  2133. // avoriaz seems to mock a non-extensible $scopedSlots object
  2134. // and when that is passed down this would cause an error
  2135. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2136. scopedSlots._normalized = res;
  2137. }
  2138. def(res, '$stable', isStable);
  2139. def(res, '$key', key);
  2140. def(res, '$hasNormal', hasNormalSlots);
  2141. return res;
  2142. }
  2143. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2144. const normalized = function () {
  2145. const cur = currentInstance;
  2146. setCurrentInstance(vm);
  2147. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2148. res =
  2149. res && typeof res === 'object' && !isArray(res)
  2150. ? [res] // single vnode
  2151. : normalizeChildren(res);
  2152. const vnode = res && res[0];
  2153. setCurrentInstance(cur);
  2154. return res &&
  2155. (!vnode ||
  2156. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2157. ? undefined
  2158. : res;
  2159. };
  2160. // this is a slot using the new v-slot syntax without scope. although it is
  2161. // compiled as a scoped slot, render fn users would expect it to be present
  2162. // on this.$slots because the usage is semantically a normal slot.
  2163. if (fn.proxy) {
  2164. Object.defineProperty(normalSlots, key, {
  2165. get: normalized,
  2166. enumerable: true,
  2167. configurable: true
  2168. });
  2169. }
  2170. return normalized;
  2171. }
  2172. function proxyNormalSlot(slots, key) {
  2173. return () => slots[key];
  2174. }
  2175. function initSetup(vm) {
  2176. const options = vm.$options;
  2177. const setup = options.setup;
  2178. if (setup) {
  2179. const ctx = (vm._setupContext = createSetupContext(vm));
  2180. setCurrentInstance(vm);
  2181. pushTarget();
  2182. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2183. popTarget();
  2184. setCurrentInstance();
  2185. if (isFunction(setupResult)) {
  2186. // render function
  2187. // @ts-ignore
  2188. options.render = setupResult;
  2189. }
  2190. else if (isObject(setupResult)) {
  2191. // bindings
  2192. if (setupResult instanceof VNode) {
  2193. warn$2(`setup() should not return VNodes directly - ` +
  2194. `return a render function instead.`);
  2195. }
  2196. vm._setupState = setupResult;
  2197. // __sfc indicates compiled bindings from <script setup>
  2198. if (!setupResult.__sfc) {
  2199. for (const key in setupResult) {
  2200. if (!isReserved(key)) {
  2201. proxyWithRefUnwrap(vm, setupResult, key);
  2202. }
  2203. else {
  2204. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2205. }
  2206. }
  2207. }
  2208. else {
  2209. // exposed for compiled render fn
  2210. const proxy = (vm._setupProxy = {});
  2211. for (const key in setupResult) {
  2212. if (key !== '__sfc') {
  2213. proxyWithRefUnwrap(proxy, setupResult, key);
  2214. }
  2215. }
  2216. }
  2217. }
  2218. else if (setupResult !== undefined) {
  2219. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2220. }
  2221. }
  2222. }
  2223. function createSetupContext(vm) {
  2224. let exposeCalled = false;
  2225. return {
  2226. get attrs() {
  2227. if (!vm._attrsProxy) {
  2228. const proxy = (vm._attrsProxy = {});
  2229. def(proxy, '_v_attr_proxy', true);
  2230. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2231. }
  2232. return vm._attrsProxy;
  2233. },
  2234. get listeners() {
  2235. if (!vm._listenersProxy) {
  2236. const proxy = (vm._listenersProxy = {});
  2237. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2238. }
  2239. return vm._listenersProxy;
  2240. },
  2241. get slots() {
  2242. return initSlotsProxy(vm);
  2243. },
  2244. emit: bind$1(vm.$emit, vm),
  2245. expose(exposed) {
  2246. {
  2247. if (exposeCalled) {
  2248. warn$2(`expose() should be called only once per setup().`, vm);
  2249. }
  2250. exposeCalled = true;
  2251. }
  2252. if (exposed) {
  2253. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2254. }
  2255. }
  2256. };
  2257. }
  2258. function syncSetupProxy(to, from, prev, instance, type) {
  2259. let changed = false;
  2260. for (const key in from) {
  2261. if (!(key in to)) {
  2262. changed = true;
  2263. defineProxyAttr(to, key, instance, type);
  2264. }
  2265. else if (from[key] !== prev[key]) {
  2266. changed = true;
  2267. }
  2268. }
  2269. for (const key in to) {
  2270. if (!(key in from)) {
  2271. changed = true;
  2272. delete to[key];
  2273. }
  2274. }
  2275. return changed;
  2276. }
  2277. function defineProxyAttr(proxy, key, instance, type) {
  2278. Object.defineProperty(proxy, key, {
  2279. enumerable: true,
  2280. configurable: true,
  2281. get() {
  2282. return instance[type][key];
  2283. }
  2284. });
  2285. }
  2286. function initSlotsProxy(vm) {
  2287. if (!vm._slotsProxy) {
  2288. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2289. }
  2290. return vm._slotsProxy;
  2291. }
  2292. function syncSetupSlots(to, from) {
  2293. for (const key in from) {
  2294. to[key] = from[key];
  2295. }
  2296. for (const key in to) {
  2297. if (!(key in from)) {
  2298. delete to[key];
  2299. }
  2300. }
  2301. }
  2302. /**
  2303. * @internal use manual type def because public setup context type relies on
  2304. * legacy VNode types
  2305. */
  2306. function useSlots() {
  2307. return getContext().slots;
  2308. }
  2309. /**
  2310. * @internal use manual type def because public setup context type relies on
  2311. * legacy VNode types
  2312. */
  2313. function useAttrs() {
  2314. return getContext().attrs;
  2315. }
  2316. /**
  2317. * Vue 2 only
  2318. * @internal use manual type def because public setup context type relies on
  2319. * legacy VNode types
  2320. */
  2321. function useListeners() {
  2322. return getContext().listeners;
  2323. }
  2324. function getContext() {
  2325. if (!currentInstance) {
  2326. warn$2(`useContext() called without active instance.`);
  2327. }
  2328. const vm = currentInstance;
  2329. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2330. }
  2331. /**
  2332. * Runtime helper for merging default declarations. Imported by compiled code
  2333. * only.
  2334. * @internal
  2335. */
  2336. function mergeDefaults(raw, defaults) {
  2337. const props = isArray(raw)
  2338. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2339. : raw;
  2340. for (const key in defaults) {
  2341. const opt = props[key];
  2342. if (opt) {
  2343. if (isArray(opt) || isFunction(opt)) {
  2344. props[key] = { type: opt, default: defaults[key] };
  2345. }
  2346. else {
  2347. opt.default = defaults[key];
  2348. }
  2349. }
  2350. else if (opt === null) {
  2351. props[key] = { default: defaults[key] };
  2352. }
  2353. else {
  2354. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2355. }
  2356. }
  2357. return props;
  2358. }
  2359. function initRender(vm) {
  2360. vm._vnode = null; // the root of the child tree
  2361. vm._staticTrees = null; // v-once cached trees
  2362. const options = vm.$options;
  2363. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2364. const renderContext = parentVnode && parentVnode.context;
  2365. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2366. vm.$scopedSlots = parentVnode
  2367. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2368. : emptyObject;
  2369. // bind the createElement fn to this instance
  2370. // so that we get proper render context inside it.
  2371. // args order: tag, data, children, normalizationType, alwaysNormalize
  2372. // internal version is used by render functions compiled from templates
  2373. // @ts-expect-error
  2374. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2375. // normalization is always applied for the public version, used in
  2376. // user-written render functions.
  2377. // @ts-expect-error
  2378. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2379. // $attrs & $listeners are exposed for easier HOC creation.
  2380. // they need to be reactive so that HOCs using them are always updated
  2381. const parentData = parentVnode && parentVnode.data;
  2382. /* istanbul ignore else */
  2383. {
  2384. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2385. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2386. }, true);
  2387. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2388. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2389. }, true);
  2390. }
  2391. }
  2392. let currentRenderingInstance = null;
  2393. function renderMixin(Vue) {
  2394. // install runtime convenience helpers
  2395. installRenderHelpers(Vue.prototype);
  2396. Vue.prototype.$nextTick = function (fn) {
  2397. return nextTick(fn, this);
  2398. };
  2399. Vue.prototype._render = function () {
  2400. const vm = this;
  2401. const { render, _parentVnode } = vm.$options;
  2402. if (_parentVnode && vm._isMounted) {
  2403. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2404. if (vm._slotsProxy) {
  2405. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2406. }
  2407. }
  2408. // set parent vnode. this allows render functions to have access
  2409. // to the data on the placeholder node.
  2410. vm.$vnode = _parentVnode;
  2411. // render self
  2412. let vnode;
  2413. try {
  2414. // There's no need to maintain a stack because all render fns are called
  2415. // separately from one another. Nested component's render fns are called
  2416. // when parent component is patched.
  2417. setCurrentInstance(vm);
  2418. currentRenderingInstance = vm;
  2419. vnode = render.call(vm._renderProxy, vm.$createElement);
  2420. }
  2421. catch (e) {
  2422. handleError(e, vm, `render`);
  2423. // return error render result,
  2424. // or previous vnode to prevent render error causing blank component
  2425. /* istanbul ignore else */
  2426. if (vm.$options.renderError) {
  2427. try {
  2428. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2429. }
  2430. catch (e) {
  2431. handleError(e, vm, `renderError`);
  2432. vnode = vm._vnode;
  2433. }
  2434. }
  2435. else {
  2436. vnode = vm._vnode;
  2437. }
  2438. }
  2439. finally {
  2440. currentRenderingInstance = null;
  2441. setCurrentInstance();
  2442. }
  2443. // if the returned array contains only a single node, allow it
  2444. if (isArray(vnode) && vnode.length === 1) {
  2445. vnode = vnode[0];
  2446. }
  2447. // return empty vnode in case the render function errored out
  2448. if (!(vnode instanceof VNode)) {
  2449. if (isArray(vnode)) {
  2450. warn$2('Multiple root nodes returned from render function. Render function ' +
  2451. 'should return a single root node.', vm);
  2452. }
  2453. vnode = createEmptyVNode();
  2454. }
  2455. // set parent
  2456. vnode.parent = _parentVnode;
  2457. return vnode;
  2458. };
  2459. }
  2460. function ensureCtor(comp, base) {
  2461. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2462. comp = comp.default;
  2463. }
  2464. return isObject(comp) ? base.extend(comp) : comp;
  2465. }
  2466. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2467. const node = createEmptyVNode();
  2468. node.asyncFactory = factory;
  2469. node.asyncMeta = { data, context, children, tag };
  2470. return node;
  2471. }
  2472. function resolveAsyncComponent(factory, baseCtor) {
  2473. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2474. return factory.errorComp;
  2475. }
  2476. if (isDef(factory.resolved)) {
  2477. return factory.resolved;
  2478. }
  2479. const owner = currentRenderingInstance;
  2480. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2481. // already pending
  2482. factory.owners.push(owner);
  2483. }
  2484. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2485. return factory.loadingComp;
  2486. }
  2487. if (owner && !isDef(factory.owners)) {
  2488. const owners = (factory.owners = [owner]);
  2489. let sync = true;
  2490. let timerLoading = null;
  2491. let timerTimeout = null;
  2492. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2493. const forceRender = (renderCompleted) => {
  2494. for (let i = 0, l = owners.length; i < l; i++) {
  2495. owners[i].$forceUpdate();
  2496. }
  2497. if (renderCompleted) {
  2498. owners.length = 0;
  2499. if (timerLoading !== null) {
  2500. clearTimeout(timerLoading);
  2501. timerLoading = null;
  2502. }
  2503. if (timerTimeout !== null) {
  2504. clearTimeout(timerTimeout);
  2505. timerTimeout = null;
  2506. }
  2507. }
  2508. };
  2509. const resolve = once((res) => {
  2510. // cache resolved
  2511. factory.resolved = ensureCtor(res, baseCtor);
  2512. // invoke callbacks only if this is not a synchronous resolve
  2513. // (async resolves are shimmed as synchronous during SSR)
  2514. if (!sync) {
  2515. forceRender(true);
  2516. }
  2517. else {
  2518. owners.length = 0;
  2519. }
  2520. });
  2521. const reject = once(reason => {
  2522. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2523. (reason ? `\nReason: ${reason}` : ''));
  2524. if (isDef(factory.errorComp)) {
  2525. factory.error = true;
  2526. forceRender(true);
  2527. }
  2528. });
  2529. const res = factory(resolve, reject);
  2530. if (isObject(res)) {
  2531. if (isPromise(res)) {
  2532. // () => Promise
  2533. if (isUndef(factory.resolved)) {
  2534. res.then(resolve, reject);
  2535. }
  2536. }
  2537. else if (isPromise(res.component)) {
  2538. res.component.then(resolve, reject);
  2539. if (isDef(res.error)) {
  2540. factory.errorComp = ensureCtor(res.error, baseCtor);
  2541. }
  2542. if (isDef(res.loading)) {
  2543. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2544. if (res.delay === 0) {
  2545. factory.loading = true;
  2546. }
  2547. else {
  2548. // @ts-expect-error NodeJS timeout type
  2549. timerLoading = setTimeout(() => {
  2550. timerLoading = null;
  2551. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2552. factory.loading = true;
  2553. forceRender(false);
  2554. }
  2555. }, res.delay || 200);
  2556. }
  2557. }
  2558. if (isDef(res.timeout)) {
  2559. // @ts-expect-error NodeJS timeout type
  2560. timerTimeout = setTimeout(() => {
  2561. timerTimeout = null;
  2562. if (isUndef(factory.resolved)) {
  2563. reject(`timeout (${res.timeout}ms)` );
  2564. }
  2565. }, res.timeout);
  2566. }
  2567. }
  2568. }
  2569. sync = false;
  2570. // return in case resolved synchronously
  2571. return factory.loading ? factory.loadingComp : factory.resolved;
  2572. }
  2573. }
  2574. function getFirstComponentChild(children) {
  2575. if (isArray(children)) {
  2576. for (let i = 0; i < children.length; i++) {
  2577. const c = children[i];
  2578. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2579. return c;
  2580. }
  2581. }
  2582. }
  2583. }
  2584. function initEvents(vm) {
  2585. vm._events = Object.create(null);
  2586. vm._hasHookEvent = false;
  2587. // init parent attached events
  2588. const listeners = vm.$options._parentListeners;
  2589. if (listeners) {
  2590. updateComponentListeners(vm, listeners);
  2591. }
  2592. }
  2593. let target$1;
  2594. function add$1(event, fn) {
  2595. target$1.$on(event, fn);
  2596. }
  2597. function remove$1(event, fn) {
  2598. target$1.$off(event, fn);
  2599. }
  2600. function createOnceHandler$1(event, fn) {
  2601. const _target = target$1;
  2602. return function onceHandler() {
  2603. const res = fn.apply(null, arguments);
  2604. if (res !== null) {
  2605. _target.$off(event, onceHandler);
  2606. }
  2607. };
  2608. }
  2609. function updateComponentListeners(vm, listeners, oldListeners) {
  2610. target$1 = vm;
  2611. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2612. target$1 = undefined;
  2613. }
  2614. function eventsMixin(Vue) {
  2615. const hookRE = /^hook:/;
  2616. Vue.prototype.$on = function (event, fn) {
  2617. const vm = this;
  2618. if (isArray(event)) {
  2619. for (let i = 0, l = event.length; i < l; i++) {
  2620. vm.$on(event[i], fn);
  2621. }
  2622. }
  2623. else {
  2624. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2625. // optimize hook:event cost by using a boolean flag marked at registration
  2626. // instead of a hash lookup
  2627. if (hookRE.test(event)) {
  2628. vm._hasHookEvent = true;
  2629. }
  2630. }
  2631. return vm;
  2632. };
  2633. Vue.prototype.$once = function (event, fn) {
  2634. const vm = this;
  2635. function on() {
  2636. vm.$off(event, on);
  2637. fn.apply(vm, arguments);
  2638. }
  2639. on.fn = fn;
  2640. vm.$on(event, on);
  2641. return vm;
  2642. };
  2643. Vue.prototype.$off = function (event, fn) {
  2644. const vm = this;
  2645. // all
  2646. if (!arguments.length) {
  2647. vm._events = Object.create(null);
  2648. return vm;
  2649. }
  2650. // array of events
  2651. if (isArray(event)) {
  2652. for (let i = 0, l = event.length; i < l; i++) {
  2653. vm.$off(event[i], fn);
  2654. }
  2655. return vm;
  2656. }
  2657. // specific event
  2658. const cbs = vm._events[event];
  2659. if (!cbs) {
  2660. return vm;
  2661. }
  2662. if (!fn) {
  2663. vm._events[event] = null;
  2664. return vm;
  2665. }
  2666. // specific handler
  2667. let cb;
  2668. let i = cbs.length;
  2669. while (i--) {
  2670. cb = cbs[i];
  2671. if (cb === fn || cb.fn === fn) {
  2672. cbs.splice(i, 1);
  2673. break;
  2674. }
  2675. }
  2676. return vm;
  2677. };
  2678. Vue.prototype.$emit = function (event) {
  2679. const vm = this;
  2680. {
  2681. const lowerCaseEvent = event.toLowerCase();
  2682. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2683. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2684. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2685. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2686. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2687. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2688. }
  2689. }
  2690. let cbs = vm._events[event];
  2691. if (cbs) {
  2692. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2693. const args = toArray(arguments, 1);
  2694. const info = `event handler for "${event}"`;
  2695. for (let i = 0, l = cbs.length; i < l; i++) {
  2696. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2697. }
  2698. }
  2699. return vm;
  2700. };
  2701. }
  2702. let activeInstance = null;
  2703. let isUpdatingChildComponent = false;
  2704. function setActiveInstance(vm) {
  2705. const prevActiveInstance = activeInstance;
  2706. activeInstance = vm;
  2707. return () => {
  2708. activeInstance = prevActiveInstance;
  2709. };
  2710. }
  2711. function initLifecycle(vm) {
  2712. const options = vm.$options;
  2713. // locate first non-abstract parent
  2714. let parent = options.parent;
  2715. if (parent && !options.abstract) {
  2716. while (parent.$options.abstract && parent.$parent) {
  2717. parent = parent.$parent;
  2718. }
  2719. parent.$children.push(vm);
  2720. }
  2721. vm.$parent = parent;
  2722. vm.$root = parent ? parent.$root : vm;
  2723. vm.$children = [];
  2724. vm.$refs = {};
  2725. vm._provided = parent ? parent._provided : Object.create(null);
  2726. vm._watcher = null;
  2727. vm._inactive = null;
  2728. vm._directInactive = false;
  2729. vm._isMounted = false;
  2730. vm._isDestroyed = false;
  2731. vm._isBeingDestroyed = false;
  2732. }
  2733. function lifecycleMixin(Vue) {
  2734. Vue.prototype._update = function (vnode, hydrating) {
  2735. const vm = this;
  2736. const prevEl = vm.$el;
  2737. const prevVnode = vm._vnode;
  2738. const restoreActiveInstance = setActiveInstance(vm);
  2739. vm._vnode = vnode;
  2740. // Vue.prototype.__patch__ is injected in entry points
  2741. // based on the rendering backend used.
  2742. if (!prevVnode) {
  2743. // initial render
  2744. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2745. }
  2746. else {
  2747. // updates
  2748. vm.$el = vm.__patch__(prevVnode, vnode);
  2749. }
  2750. restoreActiveInstance();
  2751. // update __vue__ reference
  2752. if (prevEl) {
  2753. prevEl.__vue__ = null;
  2754. }
  2755. if (vm.$el) {
  2756. vm.$el.__vue__ = vm;
  2757. }
  2758. // if parent is an HOC, update its $el as well
  2759. let wrapper = vm;
  2760. while (wrapper &&
  2761. wrapper.$vnode &&
  2762. wrapper.$parent &&
  2763. wrapper.$vnode === wrapper.$parent._vnode) {
  2764. wrapper.$parent.$el = wrapper.$el;
  2765. wrapper = wrapper.$parent;
  2766. }
  2767. // updated hook is called by the scheduler to ensure that children are
  2768. // updated in a parent's updated hook.
  2769. };
  2770. Vue.prototype.$forceUpdate = function () {
  2771. const vm = this;
  2772. if (vm._watcher) {
  2773. vm._watcher.update();
  2774. }
  2775. };
  2776. Vue.prototype.$destroy = function () {
  2777. const vm = this;
  2778. if (vm._isBeingDestroyed) {
  2779. return;
  2780. }
  2781. callHook$1(vm, 'beforeDestroy');
  2782. vm._isBeingDestroyed = true;
  2783. // remove self from parent
  2784. const parent = vm.$parent;
  2785. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2786. remove$2(parent.$children, vm);
  2787. }
  2788. // teardown scope. this includes both the render watcher and other
  2789. // watchers created
  2790. vm._scope.stop();
  2791. // remove reference from data ob
  2792. // frozen object may not have observer.
  2793. if (vm._data.__ob__) {
  2794. vm._data.__ob__.vmCount--;
  2795. }
  2796. // call the last hook...
  2797. vm._isDestroyed = true;
  2798. // invoke destroy hooks on current rendered tree
  2799. vm.__patch__(vm._vnode, null);
  2800. // fire destroyed hook
  2801. callHook$1(vm, 'destroyed');
  2802. // turn off all instance listeners.
  2803. vm.$off();
  2804. // remove __vue__ reference
  2805. if (vm.$el) {
  2806. vm.$el.__vue__ = null;
  2807. }
  2808. // release circular reference (#6759)
  2809. if (vm.$vnode) {
  2810. vm.$vnode.parent = null;
  2811. }
  2812. };
  2813. }
  2814. function mountComponent(vm, el, hydrating) {
  2815. vm.$el = el;
  2816. if (!vm.$options.render) {
  2817. // @ts-expect-error invalid type
  2818. vm.$options.render = createEmptyVNode;
  2819. {
  2820. /* istanbul ignore if */
  2821. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2822. vm.$options.el ||
  2823. el) {
  2824. warn$2('You are using the runtime-only build of Vue where the template ' +
  2825. 'compiler is not available. Either pre-compile the templates into ' +
  2826. 'render functions, or use the compiler-included build.', vm);
  2827. }
  2828. else {
  2829. warn$2('Failed to mount component: template or render function not defined.', vm);
  2830. }
  2831. }
  2832. }
  2833. callHook$1(vm, 'beforeMount');
  2834. let updateComponent;
  2835. /* istanbul ignore if */
  2836. if (config.performance && mark) {
  2837. updateComponent = () => {
  2838. const name = vm._name;
  2839. const id = vm._uid;
  2840. const startTag = `vue-perf-start:${id}`;
  2841. const endTag = `vue-perf-end:${id}`;
  2842. mark(startTag);
  2843. const vnode = vm._render();
  2844. mark(endTag);
  2845. measure(`vue ${name} render`, startTag, endTag);
  2846. mark(startTag);
  2847. vm._update(vnode, hydrating);
  2848. mark(endTag);
  2849. measure(`vue ${name} patch`, startTag, endTag);
  2850. };
  2851. }
  2852. else {
  2853. updateComponent = () => {
  2854. vm._update(vm._render(), hydrating);
  2855. };
  2856. }
  2857. const watcherOptions = {
  2858. before() {
  2859. if (vm._isMounted && !vm._isDestroyed) {
  2860. callHook$1(vm, 'beforeUpdate');
  2861. }
  2862. }
  2863. };
  2864. {
  2865. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2866. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2867. }
  2868. // we set this to vm._watcher inside the watcher's constructor
  2869. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2870. // component's mounted hook), which relies on vm._watcher being already defined
  2871. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2872. hydrating = false;
  2873. // flush buffer for flush: "pre" watchers queued in setup()
  2874. const preWatchers = vm._preWatchers;
  2875. if (preWatchers) {
  2876. for (let i = 0; i < preWatchers.length; i++) {
  2877. preWatchers[i].run();
  2878. }
  2879. }
  2880. // manually mounted instance, call mounted on self
  2881. // mounted is called for render-created child components in its inserted hook
  2882. if (vm.$vnode == null) {
  2883. vm._isMounted = true;
  2884. callHook$1(vm, 'mounted');
  2885. }
  2886. return vm;
  2887. }
  2888. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2889. {
  2890. isUpdatingChildComponent = true;
  2891. }
  2892. // determine whether component has slot children
  2893. // we need to do this before overwriting $options._renderChildren.
  2894. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2895. // dynamic slot names). Static scoped slots compiled from template has the
  2896. // "$stable" marker.
  2897. const newScopedSlots = parentVnode.data.scopedSlots;
  2898. const oldScopedSlots = vm.$scopedSlots;
  2899. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  2900. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  2901. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  2902. (!newScopedSlots && vm.$scopedSlots.$key));
  2903. // Any static slot children from the parent may have changed during parent's
  2904. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  2905. // update is necessary to ensure correctness.
  2906. let needsForceUpdate = !!(renderChildren || // has new static slots
  2907. vm.$options._renderChildren || // has old static slots
  2908. hasDynamicScopedSlot);
  2909. const prevVNode = vm.$vnode;
  2910. vm.$options._parentVnode = parentVnode;
  2911. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2912. if (vm._vnode) {
  2913. // update child tree's parent
  2914. vm._vnode.parent = parentVnode;
  2915. }
  2916. vm.$options._renderChildren = renderChildren;
  2917. // update $attrs and $listeners hash
  2918. // these are also reactive so they may trigger child update if the child
  2919. // used them during render
  2920. const attrs = parentVnode.data.attrs || emptyObject;
  2921. if (vm._attrsProxy) {
  2922. // force update if attrs are accessed and has changed since it may be
  2923. // passed to a child component.
  2924. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  2925. needsForceUpdate = true;
  2926. }
  2927. }
  2928. vm.$attrs = attrs;
  2929. // update listeners
  2930. listeners = listeners || emptyObject;
  2931. const prevListeners = vm.$options._parentListeners;
  2932. if (vm._listenersProxy) {
  2933. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  2934. }
  2935. vm.$listeners = vm.$options._parentListeners = listeners;
  2936. updateComponentListeners(vm, listeners, prevListeners);
  2937. // update props
  2938. if (propsData && vm.$options.props) {
  2939. toggleObserving(false);
  2940. const props = vm._props;
  2941. const propKeys = vm.$options._propKeys || [];
  2942. for (let i = 0; i < propKeys.length; i++) {
  2943. const key = propKeys[i];
  2944. const propOptions = vm.$options.props; // wtf flow?
  2945. props[key] = validateProp(key, propOptions, propsData, vm);
  2946. }
  2947. toggleObserving(true);
  2948. // keep a copy of raw propsData
  2949. vm.$options.propsData = propsData;
  2950. }
  2951. // resolve slots + force update if has children
  2952. if (needsForceUpdate) {
  2953. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2954. vm.$forceUpdate();
  2955. }
  2956. {
  2957. isUpdatingChildComponent = false;
  2958. }
  2959. }
  2960. function isInInactiveTree(vm) {
  2961. while (vm && (vm = vm.$parent)) {
  2962. if (vm._inactive)
  2963. return true;
  2964. }
  2965. return false;
  2966. }
  2967. function activateChildComponent(vm, direct) {
  2968. if (direct) {
  2969. vm._directInactive = false;
  2970. if (isInInactiveTree(vm)) {
  2971. return;
  2972. }
  2973. }
  2974. else if (vm._directInactive) {
  2975. return;
  2976. }
  2977. if (vm._inactive || vm._inactive === null) {
  2978. vm._inactive = false;
  2979. for (let i = 0; i < vm.$children.length; i++) {
  2980. activateChildComponent(vm.$children[i]);
  2981. }
  2982. callHook$1(vm, 'activated');
  2983. }
  2984. }
  2985. function deactivateChildComponent(vm, direct) {
  2986. if (direct) {
  2987. vm._directInactive = true;
  2988. if (isInInactiveTree(vm)) {
  2989. return;
  2990. }
  2991. }
  2992. if (!vm._inactive) {
  2993. vm._inactive = true;
  2994. for (let i = 0; i < vm.$children.length; i++) {
  2995. deactivateChildComponent(vm.$children[i]);
  2996. }
  2997. callHook$1(vm, 'deactivated');
  2998. }
  2999. }
  3000. function callHook$1(vm, hook, args, setContext = true) {
  3001. // #7573 disable dep collection when invoking lifecycle hooks
  3002. pushTarget();
  3003. const prev = currentInstance;
  3004. setContext && setCurrentInstance(vm);
  3005. const handlers = vm.$options[hook];
  3006. const info = `${hook} hook`;
  3007. if (handlers) {
  3008. for (let i = 0, j = handlers.length; i < j; i++) {
  3009. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3010. }
  3011. }
  3012. if (vm._hasHookEvent) {
  3013. vm.$emit('hook:' + hook);
  3014. }
  3015. setContext && setCurrentInstance(prev);
  3016. popTarget();
  3017. }
  3018. const MAX_UPDATE_COUNT = 100;
  3019. const queue = [];
  3020. const activatedChildren = [];
  3021. let has = {};
  3022. let circular = {};
  3023. let waiting = false;
  3024. let flushing = false;
  3025. let index$1 = 0;
  3026. /**
  3027. * Reset the scheduler's state.
  3028. */
  3029. function resetSchedulerState() {
  3030. index$1 = queue.length = activatedChildren.length = 0;
  3031. has = {};
  3032. {
  3033. circular = {};
  3034. }
  3035. waiting = flushing = false;
  3036. }
  3037. // Async edge case #6566 requires saving the timestamp when event listeners are
  3038. // attached. However, calling performance.now() has a perf overhead especially
  3039. // if the page has thousands of event listeners. Instead, we take a timestamp
  3040. // every time the scheduler flushes and use that for all event listeners
  3041. // attached during that flush.
  3042. let currentFlushTimestamp = 0;
  3043. // Async edge case fix requires storing an event listener's attach timestamp.
  3044. let getNow = Date.now;
  3045. // Determine what event timestamp the browser is using. Annoyingly, the
  3046. // timestamp can either be hi-res (relative to page load) or low-res
  3047. // (relative to UNIX epoch), so in order to compare time we have to use the
  3048. // same timestamp type when saving the flush timestamp.
  3049. // All IE versions use low-res event timestamps, and have problematic clock
  3050. // implementations (#9632)
  3051. if (inBrowser && !isIE) {
  3052. const performance = window.performance;
  3053. if (performance &&
  3054. typeof performance.now === 'function' &&
  3055. getNow() > document.createEvent('Event').timeStamp) {
  3056. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3057. // smaller than it, it means the event is using a hi-res timestamp,
  3058. // and we need to use the hi-res version for event listener timestamps as
  3059. // well.
  3060. getNow = () => performance.now();
  3061. }
  3062. }
  3063. const sortCompareFn = (a, b) => {
  3064. if (a.post) {
  3065. if (!b.post)
  3066. return 1;
  3067. }
  3068. else if (b.post) {
  3069. return -1;
  3070. }
  3071. return a.id - b.id;
  3072. };
  3073. /**
  3074. * Flush both queues and run the watchers.
  3075. */
  3076. function flushSchedulerQueue() {
  3077. currentFlushTimestamp = getNow();
  3078. flushing = true;
  3079. let watcher, id;
  3080. // Sort queue before flush.
  3081. // This ensures that:
  3082. // 1. Components are updated from parent to child. (because parent is always
  3083. // created before the child)
  3084. // 2. A component's user watchers are run before its render watcher (because
  3085. // user watchers are created before the render watcher)
  3086. // 3. If a component is destroyed during a parent component's watcher run,
  3087. // its watchers can be skipped.
  3088. queue.sort(sortCompareFn);
  3089. // do not cache length because more watchers might be pushed
  3090. // as we run existing watchers
  3091. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3092. watcher = queue[index$1];
  3093. if (watcher.before) {
  3094. watcher.before();
  3095. }
  3096. id = watcher.id;
  3097. has[id] = null;
  3098. watcher.run();
  3099. // in dev build, check and stop circular updates.
  3100. if (has[id] != null) {
  3101. circular[id] = (circular[id] || 0) + 1;
  3102. if (circular[id] > MAX_UPDATE_COUNT) {
  3103. warn$2('You may have an infinite update loop ' +
  3104. (watcher.user
  3105. ? `in watcher with expression "${watcher.expression}"`
  3106. : `in a component render function.`), watcher.vm);
  3107. break;
  3108. }
  3109. }
  3110. }
  3111. // keep copies of post queues before resetting state
  3112. const activatedQueue = activatedChildren.slice();
  3113. const updatedQueue = queue.slice();
  3114. resetSchedulerState();
  3115. // call component updated and activated hooks
  3116. callActivatedHooks(activatedQueue);
  3117. callUpdatedHooks(updatedQueue);
  3118. cleanupDeps();
  3119. // devtool hook
  3120. /* istanbul ignore if */
  3121. if (devtools && config.devtools) {
  3122. devtools.emit('flush');
  3123. }
  3124. }
  3125. function callUpdatedHooks(queue) {
  3126. let i = queue.length;
  3127. while (i--) {
  3128. const watcher = queue[i];
  3129. const vm = watcher.vm;
  3130. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3131. callHook$1(vm, 'updated');
  3132. }
  3133. }
  3134. }
  3135. /**
  3136. * Queue a kept-alive component that was activated during patch.
  3137. * The queue will be processed after the entire tree has been patched.
  3138. */
  3139. function queueActivatedComponent(vm) {
  3140. // setting _inactive to false here so that a render function can
  3141. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3142. vm._inactive = false;
  3143. activatedChildren.push(vm);
  3144. }
  3145. function callActivatedHooks(queue) {
  3146. for (let i = 0; i < queue.length; i++) {
  3147. queue[i]._inactive = true;
  3148. activateChildComponent(queue[i], true /* true */);
  3149. }
  3150. }
  3151. /**
  3152. * Push a watcher into the watcher queue.
  3153. * Jobs with duplicate IDs will be skipped unless it's
  3154. * pushed when the queue is being flushed.
  3155. */
  3156. function queueWatcher(watcher) {
  3157. const id = watcher.id;
  3158. if (has[id] != null) {
  3159. return;
  3160. }
  3161. if (watcher === Dep.target && watcher.noRecurse) {
  3162. return;
  3163. }
  3164. has[id] = true;
  3165. if (!flushing) {
  3166. queue.push(watcher);
  3167. }
  3168. else {
  3169. // if already flushing, splice the watcher based on its id
  3170. // if already past its id, it will be run next immediately.
  3171. let i = queue.length - 1;
  3172. while (i > index$1 && queue[i].id > watcher.id) {
  3173. i--;
  3174. }
  3175. queue.splice(i + 1, 0, watcher);
  3176. }
  3177. // queue the flush
  3178. if (!waiting) {
  3179. waiting = true;
  3180. if (!config.async) {
  3181. flushSchedulerQueue();
  3182. return;
  3183. }
  3184. nextTick(flushSchedulerQueue);
  3185. }
  3186. }
  3187. const WATCHER = `watcher`;
  3188. const WATCHER_CB = `${WATCHER} callback`;
  3189. const WATCHER_GETTER = `${WATCHER} getter`;
  3190. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3191. // Simple effect.
  3192. function watchEffect(effect, options) {
  3193. return doWatch(effect, null, options);
  3194. }
  3195. function watchPostEffect(effect, options) {
  3196. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3197. }
  3198. function watchSyncEffect(effect, options) {
  3199. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3200. }
  3201. // initial value for watchers to trigger on undefined initial values
  3202. const INITIAL_WATCHER_VALUE = {};
  3203. // implementation
  3204. function watch(source, cb, options) {
  3205. if (typeof cb !== 'function') {
  3206. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3207. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3208. `supports \`watch(source, cb, options?) signature.`);
  3209. }
  3210. return doWatch(source, cb, options);
  3211. }
  3212. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3213. if (!cb) {
  3214. if (immediate !== undefined) {
  3215. warn$2(`watch() "immediate" option is only respected when using the ` +
  3216. `watch(source, callback, options?) signature.`);
  3217. }
  3218. if (deep !== undefined) {
  3219. warn$2(`watch() "deep" option is only respected when using the ` +
  3220. `watch(source, callback, options?) signature.`);
  3221. }
  3222. }
  3223. const warnInvalidSource = (s) => {
  3224. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3225. `function, a ref, a reactive object, or an array of these types.`);
  3226. };
  3227. const instance = currentInstance;
  3228. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3229. let getter;
  3230. let forceTrigger = false;
  3231. let isMultiSource = false;
  3232. if (isRef(source)) {
  3233. getter = () => source.value;
  3234. forceTrigger = isShallow(source);
  3235. }
  3236. else if (isReactive(source)) {
  3237. getter = () => {
  3238. source.__ob__.dep.depend();
  3239. return source;
  3240. };
  3241. deep = true;
  3242. }
  3243. else if (isArray(source)) {
  3244. isMultiSource = true;
  3245. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3246. getter = () => source.map(s => {
  3247. if (isRef(s)) {
  3248. return s.value;
  3249. }
  3250. else if (isReactive(s)) {
  3251. return traverse(s);
  3252. }
  3253. else if (isFunction(s)) {
  3254. return call(s, WATCHER_GETTER);
  3255. }
  3256. else {
  3257. warnInvalidSource(s);
  3258. }
  3259. });
  3260. }
  3261. else if (isFunction(source)) {
  3262. if (cb) {
  3263. // getter with cb
  3264. getter = () => call(source, WATCHER_GETTER);
  3265. }
  3266. else {
  3267. // no cb -> simple effect
  3268. getter = () => {
  3269. if (instance && instance._isDestroyed) {
  3270. return;
  3271. }
  3272. if (cleanup) {
  3273. cleanup();
  3274. }
  3275. return call(source, WATCHER, [onCleanup]);
  3276. };
  3277. }
  3278. }
  3279. else {
  3280. getter = noop;
  3281. warnInvalidSource(source);
  3282. }
  3283. if (cb && deep) {
  3284. const baseGetter = getter;
  3285. getter = () => traverse(baseGetter());
  3286. }
  3287. let cleanup;
  3288. let onCleanup = (fn) => {
  3289. cleanup = watcher.onStop = () => {
  3290. call(fn, WATCHER_CLEANUP);
  3291. };
  3292. };
  3293. // in SSR there is no need to setup an actual effect, and it should be noop
  3294. // unless it's eager
  3295. if (isServerRendering()) {
  3296. // we will also not call the invalidate callback (+ runner is not set up)
  3297. onCleanup = noop;
  3298. if (!cb) {
  3299. getter();
  3300. }
  3301. else if (immediate) {
  3302. call(cb, WATCHER_CB, [
  3303. getter(),
  3304. isMultiSource ? [] : undefined,
  3305. onCleanup
  3306. ]);
  3307. }
  3308. return noop;
  3309. }
  3310. const watcher = new Watcher(currentInstance, getter, noop, {
  3311. lazy: true
  3312. });
  3313. watcher.noRecurse = !cb;
  3314. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3315. // overwrite default run
  3316. watcher.run = () => {
  3317. if (!watcher.active) {
  3318. return;
  3319. }
  3320. if (cb) {
  3321. // watch(source, cb)
  3322. const newValue = watcher.get();
  3323. if (deep ||
  3324. forceTrigger ||
  3325. (isMultiSource
  3326. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3327. : hasChanged(newValue, oldValue))) {
  3328. // cleanup before running cb again
  3329. if (cleanup) {
  3330. cleanup();
  3331. }
  3332. call(cb, WATCHER_CB, [
  3333. newValue,
  3334. // pass undefined as the old value when it's changed for the first time
  3335. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3336. onCleanup
  3337. ]);
  3338. oldValue = newValue;
  3339. }
  3340. }
  3341. else {
  3342. // watchEffect
  3343. watcher.get();
  3344. }
  3345. };
  3346. if (flush === 'sync') {
  3347. watcher.update = watcher.run;
  3348. }
  3349. else if (flush === 'post') {
  3350. watcher.post = true;
  3351. watcher.update = () => queueWatcher(watcher);
  3352. }
  3353. else {
  3354. // pre
  3355. watcher.update = () => {
  3356. if (instance && instance === currentInstance && !instance._isMounted) {
  3357. // pre-watcher triggered before
  3358. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3359. if (buffer.indexOf(watcher) < 0)
  3360. buffer.push(watcher);
  3361. }
  3362. else {
  3363. queueWatcher(watcher);
  3364. }
  3365. };
  3366. }
  3367. {
  3368. watcher.onTrack = onTrack;
  3369. watcher.onTrigger = onTrigger;
  3370. }
  3371. // initial run
  3372. if (cb) {
  3373. if (immediate) {
  3374. watcher.run();
  3375. }
  3376. else {
  3377. oldValue = watcher.get();
  3378. }
  3379. }
  3380. else if (flush === 'post' && instance) {
  3381. instance.$once('hook:mounted', () => watcher.get());
  3382. }
  3383. else {
  3384. watcher.get();
  3385. }
  3386. return () => {
  3387. watcher.teardown();
  3388. };
  3389. }
  3390. let activeEffectScope;
  3391. class EffectScope {
  3392. constructor(detached = false) {
  3393. this.detached = detached;
  3394. /**
  3395. * @internal
  3396. */
  3397. this.active = true;
  3398. /**
  3399. * @internal
  3400. */
  3401. this.effects = [];
  3402. /**
  3403. * @internal
  3404. */
  3405. this.cleanups = [];
  3406. this.parent = activeEffectScope;
  3407. if (!detached && 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.detached && 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.parent = undefined;
  3465. this.active = false;
  3466. }
  3467. }
  3468. }
  3469. function effectScope(detached) {
  3470. return new EffectScope(detached);
  3471. }
  3472. /**
  3473. * @internal
  3474. */
  3475. function recordEffectScope(effect, scope = activeEffectScope) {
  3476. if (scope && scope.active) {
  3477. scope.effects.push(effect);
  3478. }
  3479. }
  3480. function getCurrentScope() {
  3481. return activeEffectScope;
  3482. }
  3483. function onScopeDispose(fn) {
  3484. if (activeEffectScope) {
  3485. activeEffectScope.cleanups.push(fn);
  3486. }
  3487. else {
  3488. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  3489. ` to be associated with.`);
  3490. }
  3491. }
  3492. function provide(key, value) {
  3493. if (!currentInstance) {
  3494. {
  3495. warn$2(`provide() can only be used inside setup().`);
  3496. }
  3497. }
  3498. else {
  3499. // TS doesn't allow symbol as index type
  3500. resolveProvided(currentInstance)[key] = value;
  3501. }
  3502. }
  3503. function resolveProvided(vm) {
  3504. // by default an instance inherits its parent's provides object
  3505. // but when it needs to provide values of its own, it creates its
  3506. // own provides object using parent provides object as prototype.
  3507. // this way in `inject` we can simply look up injections from direct
  3508. // parent and let the prototype chain do the work.
  3509. const existing = vm._provided;
  3510. const parentProvides = vm.$parent && vm.$parent._provided;
  3511. if (parentProvides === existing) {
  3512. return (vm._provided = Object.create(parentProvides));
  3513. }
  3514. else {
  3515. return existing;
  3516. }
  3517. }
  3518. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3519. // fallback to `currentRenderingInstance` so that this can be called in
  3520. // a functional component
  3521. const instance = currentInstance;
  3522. if (instance) {
  3523. // #2400
  3524. // to support `app.use` plugins,
  3525. // fallback to appContext's `provides` if the instance is at root
  3526. const provides = instance.$parent && instance.$parent._provided;
  3527. if (provides && key in provides) {
  3528. // TS doesn't allow symbol as index type
  3529. return provides[key];
  3530. }
  3531. else if (arguments.length > 1) {
  3532. return treatDefaultAsFactory && isFunction(defaultValue)
  3533. ? defaultValue.call(instance)
  3534. : defaultValue;
  3535. }
  3536. else {
  3537. warn$2(`injection "${String(key)}" not found.`);
  3538. }
  3539. }
  3540. else {
  3541. warn$2(`inject() can only be used inside setup() or functional components.`);
  3542. }
  3543. }
  3544. /**
  3545. * @internal this function needs manual public type declaration because it relies
  3546. * on previously manually authored types from Vue 2
  3547. */
  3548. function h(type, props, children) {
  3549. if (!currentInstance) {
  3550. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3551. `component instance, e.g. synchronously in a component's render or setup function.`);
  3552. }
  3553. return createElement$1(currentInstance, type, props, children, 2, true);
  3554. }
  3555. function handleError(err, vm, info) {
  3556. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3557. // See: https://github.com/vuejs/vuex/issues/1505
  3558. pushTarget();
  3559. try {
  3560. if (vm) {
  3561. let cur = vm;
  3562. while ((cur = cur.$parent)) {
  3563. const hooks = cur.$options.errorCaptured;
  3564. if (hooks) {
  3565. for (let i = 0; i < hooks.length; i++) {
  3566. try {
  3567. const capture = hooks[i].call(cur, err, vm, info) === false;
  3568. if (capture)
  3569. return;
  3570. }
  3571. catch (e) {
  3572. globalHandleError(e, cur, 'errorCaptured hook');
  3573. }
  3574. }
  3575. }
  3576. }
  3577. }
  3578. globalHandleError(err, vm, info);
  3579. }
  3580. finally {
  3581. popTarget();
  3582. }
  3583. }
  3584. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3585. let res;
  3586. try {
  3587. res = args ? handler.apply(context, args) : handler.call(context);
  3588. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3589. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3590. res._handled = true;
  3591. }
  3592. }
  3593. catch (e) {
  3594. handleError(e, vm, info);
  3595. }
  3596. return res;
  3597. }
  3598. function globalHandleError(err, vm, info) {
  3599. if (config.errorHandler) {
  3600. try {
  3601. return config.errorHandler.call(null, err, vm, info);
  3602. }
  3603. catch (e) {
  3604. // if the user intentionally throws the original error in the handler,
  3605. // do not log it twice
  3606. if (e !== err) {
  3607. logError(e, null, 'config.errorHandler');
  3608. }
  3609. }
  3610. }
  3611. logError(err, vm, info);
  3612. }
  3613. function logError(err, vm, info) {
  3614. {
  3615. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3616. }
  3617. /* istanbul ignore else */
  3618. if (inBrowser && typeof console !== 'undefined') {
  3619. console.error(err);
  3620. }
  3621. else {
  3622. throw err;
  3623. }
  3624. }
  3625. /* globals MutationObserver */
  3626. let isUsingMicroTask = false;
  3627. const callbacks = [];
  3628. let pending = false;
  3629. function flushCallbacks() {
  3630. pending = false;
  3631. const copies = callbacks.slice(0);
  3632. callbacks.length = 0;
  3633. for (let i = 0; i < copies.length; i++) {
  3634. copies[i]();
  3635. }
  3636. }
  3637. // Here we have async deferring wrappers using microtasks.
  3638. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3639. // However, it has subtle problems when state is changed right before repaint
  3640. // (e.g. #6813, out-in transitions).
  3641. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3642. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3643. // So we now use microtasks everywhere, again.
  3644. // A major drawback of this tradeoff is that there are some scenarios
  3645. // where microtasks have too high a priority and fire in between supposedly
  3646. // sequential events (e.g. #4521, #6690, which have workarounds)
  3647. // or even between bubbling of the same event (#6566).
  3648. let timerFunc;
  3649. // The nextTick behavior leverages the microtask queue, which can be accessed
  3650. // via either native Promise.then or MutationObserver.
  3651. // MutationObserver has wider support, however it is seriously bugged in
  3652. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3653. // completely stops working after triggering a few times... so, if native
  3654. // Promise is available, we will use it:
  3655. /* istanbul ignore next, $flow-disable-line */
  3656. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3657. const p = Promise.resolve();
  3658. timerFunc = () => {
  3659. p.then(flushCallbacks);
  3660. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3661. // it can get stuck in a weird state where callbacks are pushed into the
  3662. // microtask queue but the queue isn't being flushed, until the browser
  3663. // needs to do some other work, e.g. handle a timer. Therefore we can
  3664. // "force" the microtask queue to be flushed by adding an empty timer.
  3665. if (isIOS)
  3666. setTimeout(noop);
  3667. };
  3668. isUsingMicroTask = true;
  3669. }
  3670. else if (!isIE &&
  3671. typeof MutationObserver !== 'undefined' &&
  3672. (isNative(MutationObserver) ||
  3673. // PhantomJS and iOS 7.x
  3674. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3675. // Use MutationObserver where native Promise is not available,
  3676. // e.g. PhantomJS, iOS7, Android 4.4
  3677. // (#6466 MutationObserver is unreliable in IE11)
  3678. let counter = 1;
  3679. const observer = new MutationObserver(flushCallbacks);
  3680. const textNode = document.createTextNode(String(counter));
  3681. observer.observe(textNode, {
  3682. characterData: true
  3683. });
  3684. timerFunc = () => {
  3685. counter = (counter + 1) % 2;
  3686. textNode.data = String(counter);
  3687. };
  3688. isUsingMicroTask = true;
  3689. }
  3690. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3691. // Fallback to setImmediate.
  3692. // Technically it leverages the (macro) task queue,
  3693. // but it is still a better choice than setTimeout.
  3694. timerFunc = () => {
  3695. setImmediate(flushCallbacks);
  3696. };
  3697. }
  3698. else {
  3699. // Fallback to setTimeout.
  3700. timerFunc = () => {
  3701. setTimeout(flushCallbacks, 0);
  3702. };
  3703. }
  3704. /**
  3705. * @internal
  3706. */
  3707. function nextTick(cb, ctx) {
  3708. let _resolve;
  3709. callbacks.push(() => {
  3710. if (cb) {
  3711. try {
  3712. cb.call(ctx);
  3713. }
  3714. catch (e) {
  3715. handleError(e, ctx, 'nextTick');
  3716. }
  3717. }
  3718. else if (_resolve) {
  3719. _resolve(ctx);
  3720. }
  3721. });
  3722. if (!pending) {
  3723. pending = true;
  3724. timerFunc();
  3725. }
  3726. // $flow-disable-line
  3727. if (!cb && typeof Promise !== 'undefined') {
  3728. return new Promise(resolve => {
  3729. _resolve = resolve;
  3730. });
  3731. }
  3732. }
  3733. function useCssModule(name = '$style') {
  3734. /* istanbul ignore else */
  3735. {
  3736. {
  3737. warn$2(`useCssModule() is not supported in the global build.`);
  3738. }
  3739. return emptyObject;
  3740. }
  3741. }
  3742. /**
  3743. * Runtime helper for SFC's CSS variable injection feature.
  3744. * @private
  3745. */
  3746. function useCssVars(getter) {
  3747. if (!inBrowser && !false)
  3748. return;
  3749. const instance = currentInstance;
  3750. if (!instance) {
  3751. warn$2(`useCssVars is called without current active component instance.`);
  3752. return;
  3753. }
  3754. watchPostEffect(() => {
  3755. const el = instance.$el;
  3756. const vars = getter(instance, instance._setupProxy);
  3757. if (el && el.nodeType === 1) {
  3758. const style = el.style;
  3759. for (const key in vars) {
  3760. style.setProperty(`--${key}`, vars[key]);
  3761. }
  3762. }
  3763. });
  3764. }
  3765. /**
  3766. * v3-compatible async component API.
  3767. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3768. * because it relies on existing manual types
  3769. */
  3770. function defineAsyncComponent(source) {
  3771. if (isFunction(source)) {
  3772. source = { loader: source };
  3773. }
  3774. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3775. suspensible = false, // in Vue 3 default is true
  3776. onError: userOnError } = source;
  3777. if (suspensible) {
  3778. warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3779. }
  3780. let pendingRequest = null;
  3781. let retries = 0;
  3782. const retry = () => {
  3783. retries++;
  3784. pendingRequest = null;
  3785. return load();
  3786. };
  3787. const load = () => {
  3788. let thisRequest;
  3789. return (pendingRequest ||
  3790. (thisRequest = pendingRequest =
  3791. loader()
  3792. .catch(err => {
  3793. err = err instanceof Error ? err : new Error(String(err));
  3794. if (userOnError) {
  3795. return new Promise((resolve, reject) => {
  3796. const userRetry = () => resolve(retry());
  3797. const userFail = () => reject(err);
  3798. userOnError(err, userRetry, userFail, retries + 1);
  3799. });
  3800. }
  3801. else {
  3802. throw err;
  3803. }
  3804. })
  3805. .then((comp) => {
  3806. if (thisRequest !== pendingRequest && pendingRequest) {
  3807. return pendingRequest;
  3808. }
  3809. if (!comp) {
  3810. warn$2(`Async component loader resolved to undefined. ` +
  3811. `If you are using retry(), make sure to return its return value.`);
  3812. }
  3813. // interop module default
  3814. if (comp &&
  3815. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3816. comp = comp.default;
  3817. }
  3818. if (comp && !isObject(comp) && !isFunction(comp)) {
  3819. throw new Error(`Invalid async component load result: ${comp}`);
  3820. }
  3821. return comp;
  3822. })));
  3823. };
  3824. return () => {
  3825. const component = load();
  3826. return {
  3827. component,
  3828. delay,
  3829. timeout,
  3830. error: errorComponent,
  3831. loading: loadingComponent
  3832. };
  3833. };
  3834. }
  3835. function createLifeCycle(hookName) {
  3836. return (fn, target = currentInstance) => {
  3837. if (!target) {
  3838. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3839. `associated with. ` +
  3840. `Lifecycle injection APIs can only be used during execution of setup().`);
  3841. return;
  3842. }
  3843. return injectHook(target, hookName, fn);
  3844. };
  3845. }
  3846. function formatName(name) {
  3847. if (name === 'beforeDestroy') {
  3848. name = 'beforeUnmount';
  3849. }
  3850. else if (name === 'destroyed') {
  3851. name = 'unmounted';
  3852. }
  3853. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3854. }
  3855. function injectHook(instance, hookName, fn) {
  3856. const options = instance.$options;
  3857. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3858. }
  3859. const onBeforeMount = createLifeCycle('beforeMount');
  3860. const onMounted = createLifeCycle('mounted');
  3861. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3862. const onUpdated = createLifeCycle('updated');
  3863. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3864. const onUnmounted = createLifeCycle('destroyed');
  3865. const onActivated = createLifeCycle('activated');
  3866. const onDeactivated = createLifeCycle('deactivated');
  3867. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3868. const onRenderTracked = createLifeCycle('renderTracked');
  3869. const onRenderTriggered = createLifeCycle('renderTriggered');
  3870. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3871. function onErrorCaptured(hook, target = currentInstance) {
  3872. injectErrorCapturedHook(hook, target);
  3873. }
  3874. /**
  3875. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3876. */
  3877. const version = '2.7.13';
  3878. /**
  3879. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3880. */
  3881. function defineComponent(options) {
  3882. return options;
  3883. }
  3884. const seenObjects = new _Set();
  3885. /**
  3886. * Recursively traverse an object to evoke all converted
  3887. * getters, so that every nested property inside the object
  3888. * is collected as a "deep" dependency.
  3889. */
  3890. function traverse(val) {
  3891. _traverse(val, seenObjects);
  3892. seenObjects.clear();
  3893. return val;
  3894. }
  3895. function _traverse(val, seen) {
  3896. let i, keys;
  3897. const isA = isArray(val);
  3898. if ((!isA && !isObject(val)) ||
  3899. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3900. Object.isFrozen(val) ||
  3901. val instanceof VNode) {
  3902. return;
  3903. }
  3904. if (val.__ob__) {
  3905. const depId = val.__ob__.dep.id;
  3906. if (seen.has(depId)) {
  3907. return;
  3908. }
  3909. seen.add(depId);
  3910. }
  3911. if (isA) {
  3912. i = val.length;
  3913. while (i--)
  3914. _traverse(val[i], seen);
  3915. }
  3916. else if (isRef(val)) {
  3917. _traverse(val.value, seen);
  3918. }
  3919. else {
  3920. keys = Object.keys(val);
  3921. i = keys.length;
  3922. while (i--)
  3923. _traverse(val[keys[i]], seen);
  3924. }
  3925. }
  3926. let uid$1 = 0;
  3927. /**
  3928. * A watcher parses an expression, collects dependencies,
  3929. * and fires callback when the expression value changes.
  3930. * This is used for both the $watch() api and directives.
  3931. * @internal
  3932. */
  3933. class Watcher {
  3934. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3935. recordEffectScope(this,
  3936. // if the active effect scope is manually created (not a component scope),
  3937. // prioritize it
  3938. activeEffectScope && !activeEffectScope._vm
  3939. ? activeEffectScope
  3940. : vm
  3941. ? vm._scope
  3942. : undefined);
  3943. if ((this.vm = vm) && isRenderWatcher) {
  3944. vm._watcher = this;
  3945. }
  3946. // options
  3947. if (options) {
  3948. this.deep = !!options.deep;
  3949. this.user = !!options.user;
  3950. this.lazy = !!options.lazy;
  3951. this.sync = !!options.sync;
  3952. this.before = options.before;
  3953. {
  3954. this.onTrack = options.onTrack;
  3955. this.onTrigger = options.onTrigger;
  3956. }
  3957. }
  3958. else {
  3959. this.deep = this.user = this.lazy = this.sync = false;
  3960. }
  3961. this.cb = cb;
  3962. this.id = ++uid$1; // uid for batching
  3963. this.active = true;
  3964. this.post = false;
  3965. this.dirty = this.lazy; // for lazy watchers
  3966. this.deps = [];
  3967. this.newDeps = [];
  3968. this.depIds = new _Set();
  3969. this.newDepIds = new _Set();
  3970. this.expression = expOrFn.toString() ;
  3971. // parse expression for getter
  3972. if (isFunction(expOrFn)) {
  3973. this.getter = expOrFn;
  3974. }
  3975. else {
  3976. this.getter = parsePath(expOrFn);
  3977. if (!this.getter) {
  3978. this.getter = noop;
  3979. warn$2(`Failed watching path: "${expOrFn}" ` +
  3980. 'Watcher only accepts simple dot-delimited paths. ' +
  3981. 'For full control, use a function instead.', vm);
  3982. }
  3983. }
  3984. this.value = this.lazy ? undefined : this.get();
  3985. }
  3986. /**
  3987. * Evaluate the getter, and re-collect dependencies.
  3988. */
  3989. get() {
  3990. pushTarget(this);
  3991. let value;
  3992. const vm = this.vm;
  3993. try {
  3994. value = this.getter.call(vm, vm);
  3995. }
  3996. catch (e) {
  3997. if (this.user) {
  3998. handleError(e, vm, `getter for watcher "${this.expression}"`);
  3999. }
  4000. else {
  4001. throw e;
  4002. }
  4003. }
  4004. finally {
  4005. // "touch" every property so they are all tracked as
  4006. // dependencies for deep watching
  4007. if (this.deep) {
  4008. traverse(value);
  4009. }
  4010. popTarget();
  4011. this.cleanupDeps();
  4012. }
  4013. return value;
  4014. }
  4015. /**
  4016. * Add a dependency to this directive.
  4017. */
  4018. addDep(dep) {
  4019. const id = dep.id;
  4020. if (!this.newDepIds.has(id)) {
  4021. this.newDepIds.add(id);
  4022. this.newDeps.push(dep);
  4023. if (!this.depIds.has(id)) {
  4024. dep.addSub(this);
  4025. }
  4026. }
  4027. }
  4028. /**
  4029. * Clean up for dependency collection.
  4030. */
  4031. cleanupDeps() {
  4032. let i = this.deps.length;
  4033. while (i--) {
  4034. const dep = this.deps[i];
  4035. if (!this.newDepIds.has(dep.id)) {
  4036. dep.removeSub(this);
  4037. }
  4038. }
  4039. let tmp = this.depIds;
  4040. this.depIds = this.newDepIds;
  4041. this.newDepIds = tmp;
  4042. this.newDepIds.clear();
  4043. tmp = this.deps;
  4044. this.deps = this.newDeps;
  4045. this.newDeps = tmp;
  4046. this.newDeps.length = 0;
  4047. }
  4048. /**
  4049. * Subscriber interface.
  4050. * Will be called when a dependency changes.
  4051. */
  4052. update() {
  4053. /* istanbul ignore else */
  4054. if (this.lazy) {
  4055. this.dirty = true;
  4056. }
  4057. else if (this.sync) {
  4058. this.run();
  4059. }
  4060. else {
  4061. queueWatcher(this);
  4062. }
  4063. }
  4064. /**
  4065. * Scheduler job interface.
  4066. * Will be called by the scheduler.
  4067. */
  4068. run() {
  4069. if (this.active) {
  4070. const value = this.get();
  4071. if (value !== this.value ||
  4072. // Deep watchers and watchers on Object/Arrays should fire even
  4073. // when the value is the same, because the value may
  4074. // have mutated.
  4075. isObject(value) ||
  4076. this.deep) {
  4077. // set new value
  4078. const oldValue = this.value;
  4079. this.value = value;
  4080. if (this.user) {
  4081. const info = `callback for watcher "${this.expression}"`;
  4082. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4083. }
  4084. else {
  4085. this.cb.call(this.vm, value, oldValue);
  4086. }
  4087. }
  4088. }
  4089. }
  4090. /**
  4091. * Evaluate the value of the watcher.
  4092. * This only gets called for lazy watchers.
  4093. */
  4094. evaluate() {
  4095. this.value = this.get();
  4096. this.dirty = false;
  4097. }
  4098. /**
  4099. * Depend on all deps collected by this watcher.
  4100. */
  4101. depend() {
  4102. let i = this.deps.length;
  4103. while (i--) {
  4104. this.deps[i].depend();
  4105. }
  4106. }
  4107. /**
  4108. * Remove self from all dependencies' subscriber list.
  4109. */
  4110. teardown() {
  4111. if (this.vm && !this.vm._isBeingDestroyed) {
  4112. remove$2(this.vm._scope.effects, this);
  4113. }
  4114. if (this.active) {
  4115. let i = this.deps.length;
  4116. while (i--) {
  4117. this.deps[i].removeSub(this);
  4118. }
  4119. this.active = false;
  4120. if (this.onStop) {
  4121. this.onStop();
  4122. }
  4123. }
  4124. }
  4125. }
  4126. const sharedPropertyDefinition = {
  4127. enumerable: true,
  4128. configurable: true,
  4129. get: noop,
  4130. set: noop
  4131. };
  4132. function proxy(target, sourceKey, key) {
  4133. sharedPropertyDefinition.get = function proxyGetter() {
  4134. return this[sourceKey][key];
  4135. };
  4136. sharedPropertyDefinition.set = function proxySetter(val) {
  4137. this[sourceKey][key] = val;
  4138. };
  4139. Object.defineProperty(target, key, sharedPropertyDefinition);
  4140. }
  4141. function initState(vm) {
  4142. const opts = vm.$options;
  4143. if (opts.props)
  4144. initProps$1(vm, opts.props);
  4145. // Composition API
  4146. initSetup(vm);
  4147. if (opts.methods)
  4148. initMethods(vm, opts.methods);
  4149. if (opts.data) {
  4150. initData(vm);
  4151. }
  4152. else {
  4153. const ob = observe((vm._data = {}));
  4154. ob && ob.vmCount++;
  4155. }
  4156. if (opts.computed)
  4157. initComputed$1(vm, opts.computed);
  4158. if (opts.watch && opts.watch !== nativeWatch) {
  4159. initWatch(vm, opts.watch);
  4160. }
  4161. }
  4162. function initProps$1(vm, propsOptions) {
  4163. const propsData = vm.$options.propsData || {};
  4164. const props = (vm._props = shallowReactive({}));
  4165. // cache prop keys so that future props updates can iterate using Array
  4166. // instead of dynamic object key enumeration.
  4167. const keys = (vm.$options._propKeys = []);
  4168. const isRoot = !vm.$parent;
  4169. // root instance props should be converted
  4170. if (!isRoot) {
  4171. toggleObserving(false);
  4172. }
  4173. for (const key in propsOptions) {
  4174. keys.push(key);
  4175. const value = validateProp(key, propsOptions, propsData, vm);
  4176. /* istanbul ignore else */
  4177. {
  4178. const hyphenatedKey = hyphenate(key);
  4179. if (isReservedAttribute(hyphenatedKey) ||
  4180. config.isReservedAttr(hyphenatedKey)) {
  4181. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4182. }
  4183. defineReactive(props, key, value, () => {
  4184. if (!isRoot && !isUpdatingChildComponent) {
  4185. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4186. `overwritten whenever the parent component re-renders. ` +
  4187. `Instead, use a data or computed property based on the prop's ` +
  4188. `value. Prop being mutated: "${key}"`, vm);
  4189. }
  4190. });
  4191. }
  4192. // static props are already proxied on the component's prototype
  4193. // during Vue.extend(). We only need to proxy props defined at
  4194. // instantiation here.
  4195. if (!(key in vm)) {
  4196. proxy(vm, `_props`, key);
  4197. }
  4198. }
  4199. toggleObserving(true);
  4200. }
  4201. function initData(vm) {
  4202. let data = vm.$options.data;
  4203. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4204. if (!isPlainObject(data)) {
  4205. data = {};
  4206. warn$2('data functions should return an object:\n' +
  4207. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4208. }
  4209. // proxy data on instance
  4210. const keys = Object.keys(data);
  4211. const props = vm.$options.props;
  4212. const methods = vm.$options.methods;
  4213. let i = keys.length;
  4214. while (i--) {
  4215. const key = keys[i];
  4216. {
  4217. if (methods && hasOwn(methods, key)) {
  4218. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4219. }
  4220. }
  4221. if (props && hasOwn(props, key)) {
  4222. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4223. `Use prop default value instead.`, vm);
  4224. }
  4225. else if (!isReserved(key)) {
  4226. proxy(vm, `_data`, key);
  4227. }
  4228. }
  4229. // observe data
  4230. const ob = observe(data);
  4231. ob && ob.vmCount++;
  4232. }
  4233. function getData(data, vm) {
  4234. // #7573 disable dep collection when invoking data getters
  4235. pushTarget();
  4236. try {
  4237. return data.call(vm, vm);
  4238. }
  4239. catch (e) {
  4240. handleError(e, vm, `data()`);
  4241. return {};
  4242. }
  4243. finally {
  4244. popTarget();
  4245. }
  4246. }
  4247. const computedWatcherOptions = { lazy: true };
  4248. function initComputed$1(vm, computed) {
  4249. // $flow-disable-line
  4250. const watchers = (vm._computedWatchers = Object.create(null));
  4251. // computed properties are just getters during SSR
  4252. const isSSR = isServerRendering();
  4253. for (const key in computed) {
  4254. const userDef = computed[key];
  4255. const getter = isFunction(userDef) ? userDef : userDef.get;
  4256. if (getter == null) {
  4257. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4258. }
  4259. if (!isSSR) {
  4260. // create internal watcher for the computed property.
  4261. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4262. }
  4263. // component-defined computed properties are already defined on the
  4264. // component prototype. We only need to define computed properties defined
  4265. // at instantiation here.
  4266. if (!(key in vm)) {
  4267. defineComputed(vm, key, userDef);
  4268. }
  4269. else {
  4270. if (key in vm.$data) {
  4271. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4272. }
  4273. else if (vm.$options.props && key in vm.$options.props) {
  4274. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4275. }
  4276. else if (vm.$options.methods && key in vm.$options.methods) {
  4277. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4278. }
  4279. }
  4280. }
  4281. }
  4282. function defineComputed(target, key, userDef) {
  4283. const shouldCache = !isServerRendering();
  4284. if (isFunction(userDef)) {
  4285. sharedPropertyDefinition.get = shouldCache
  4286. ? createComputedGetter(key)
  4287. : createGetterInvoker(userDef);
  4288. sharedPropertyDefinition.set = noop;
  4289. }
  4290. else {
  4291. sharedPropertyDefinition.get = userDef.get
  4292. ? shouldCache && userDef.cache !== false
  4293. ? createComputedGetter(key)
  4294. : createGetterInvoker(userDef.get)
  4295. : noop;
  4296. sharedPropertyDefinition.set = userDef.set || noop;
  4297. }
  4298. if (sharedPropertyDefinition.set === noop) {
  4299. sharedPropertyDefinition.set = function () {
  4300. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4301. };
  4302. }
  4303. Object.defineProperty(target, key, sharedPropertyDefinition);
  4304. }
  4305. function createComputedGetter(key) {
  4306. return function computedGetter() {
  4307. const watcher = this._computedWatchers && this._computedWatchers[key];
  4308. if (watcher) {
  4309. if (watcher.dirty) {
  4310. watcher.evaluate();
  4311. }
  4312. if (Dep.target) {
  4313. if (Dep.target.onTrack) {
  4314. Dep.target.onTrack({
  4315. effect: Dep.target,
  4316. target: this,
  4317. type: "get" /* TrackOpTypes.GET */,
  4318. key
  4319. });
  4320. }
  4321. watcher.depend();
  4322. }
  4323. return watcher.value;
  4324. }
  4325. };
  4326. }
  4327. function createGetterInvoker(fn) {
  4328. return function computedGetter() {
  4329. return fn.call(this, this);
  4330. };
  4331. }
  4332. function initMethods(vm, methods) {
  4333. const props = vm.$options.props;
  4334. for (const key in methods) {
  4335. {
  4336. if (typeof methods[key] !== 'function') {
  4337. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4338. `Did you reference the function correctly?`, vm);
  4339. }
  4340. if (props && hasOwn(props, key)) {
  4341. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4342. }
  4343. if (key in vm && isReserved(key)) {
  4344. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4345. `Avoid defining component methods that start with _ or $.`);
  4346. }
  4347. }
  4348. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4349. }
  4350. }
  4351. function initWatch(vm, watch) {
  4352. for (const key in watch) {
  4353. const handler = watch[key];
  4354. if (isArray(handler)) {
  4355. for (let i = 0; i < handler.length; i++) {
  4356. createWatcher(vm, key, handler[i]);
  4357. }
  4358. }
  4359. else {
  4360. createWatcher(vm, key, handler);
  4361. }
  4362. }
  4363. }
  4364. function createWatcher(vm, expOrFn, handler, options) {
  4365. if (isPlainObject(handler)) {
  4366. options = handler;
  4367. handler = handler.handler;
  4368. }
  4369. if (typeof handler === 'string') {
  4370. handler = vm[handler];
  4371. }
  4372. return vm.$watch(expOrFn, handler, options);
  4373. }
  4374. function stateMixin(Vue) {
  4375. // flow somehow has problems with directly declared definition object
  4376. // when using Object.defineProperty, so we have to procedurally build up
  4377. // the object here.
  4378. const dataDef = {};
  4379. dataDef.get = function () {
  4380. return this._data;
  4381. };
  4382. const propsDef = {};
  4383. propsDef.get = function () {
  4384. return this._props;
  4385. };
  4386. {
  4387. dataDef.set = function () {
  4388. warn$2('Avoid replacing instance root $data. ' +
  4389. 'Use nested data properties instead.', this);
  4390. };
  4391. propsDef.set = function () {
  4392. warn$2(`$props is readonly.`, this);
  4393. };
  4394. }
  4395. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4396. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4397. Vue.prototype.$set = set;
  4398. Vue.prototype.$delete = del;
  4399. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4400. const vm = this;
  4401. if (isPlainObject(cb)) {
  4402. return createWatcher(vm, expOrFn, cb, options);
  4403. }
  4404. options = options || {};
  4405. options.user = true;
  4406. const watcher = new Watcher(vm, expOrFn, cb, options);
  4407. if (options.immediate) {
  4408. const info = `callback for immediate watcher "${watcher.expression}"`;
  4409. pushTarget();
  4410. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4411. popTarget();
  4412. }
  4413. return function unwatchFn() {
  4414. watcher.teardown();
  4415. };
  4416. };
  4417. }
  4418. function initProvide(vm) {
  4419. const provideOption = vm.$options.provide;
  4420. if (provideOption) {
  4421. const provided = isFunction(provideOption)
  4422. ? provideOption.call(vm)
  4423. : provideOption;
  4424. if (!isObject(provided)) {
  4425. return;
  4426. }
  4427. const source = resolveProvided(vm);
  4428. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4429. // iterate the keys ourselves.
  4430. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4431. for (let i = 0; i < keys.length; i++) {
  4432. const key = keys[i];
  4433. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4434. }
  4435. }
  4436. }
  4437. function initInjections(vm) {
  4438. const result = resolveInject(vm.$options.inject, vm);
  4439. if (result) {
  4440. toggleObserving(false);
  4441. Object.keys(result).forEach(key => {
  4442. /* istanbul ignore else */
  4443. {
  4444. defineReactive(vm, key, result[key], () => {
  4445. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4446. `overwritten whenever the provided component re-renders. ` +
  4447. `injection being mutated: "${key}"`, vm);
  4448. });
  4449. }
  4450. });
  4451. toggleObserving(true);
  4452. }
  4453. }
  4454. function resolveInject(inject, vm) {
  4455. if (inject) {
  4456. // inject is :any because flow is not smart enough to figure out cached
  4457. const result = Object.create(null);
  4458. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4459. for (let i = 0; i < keys.length; i++) {
  4460. const key = keys[i];
  4461. // #6574 in case the inject object is observed...
  4462. if (key === '__ob__')
  4463. continue;
  4464. const provideKey = inject[key].from;
  4465. if (provideKey in vm._provided) {
  4466. result[key] = vm._provided[provideKey];
  4467. }
  4468. else if ('default' in inject[key]) {
  4469. const provideDefault = inject[key].default;
  4470. result[key] = isFunction(provideDefault)
  4471. ? provideDefault.call(vm)
  4472. : provideDefault;
  4473. }
  4474. else {
  4475. warn$2(`Injection "${key}" not found`, vm);
  4476. }
  4477. }
  4478. return result;
  4479. }
  4480. }
  4481. let uid = 0;
  4482. function initMixin$1(Vue) {
  4483. Vue.prototype._init = function (options) {
  4484. const vm = this;
  4485. // a uid
  4486. vm._uid = uid++;
  4487. let startTag, endTag;
  4488. /* istanbul ignore if */
  4489. if (config.performance && mark) {
  4490. startTag = `vue-perf-start:${vm._uid}`;
  4491. endTag = `vue-perf-end:${vm._uid}`;
  4492. mark(startTag);
  4493. }
  4494. // a flag to mark this as a Vue instance without having to do instanceof
  4495. // check
  4496. vm._isVue = true;
  4497. // avoid instances from being observed
  4498. vm.__v_skip = true;
  4499. // effect scope
  4500. vm._scope = new EffectScope(true /* detached */);
  4501. vm._scope._vm = true;
  4502. // merge options
  4503. if (options && options._isComponent) {
  4504. // optimize internal component instantiation
  4505. // since dynamic options merging is pretty slow, and none of the
  4506. // internal component options needs special treatment.
  4507. initInternalComponent(vm, options);
  4508. }
  4509. else {
  4510. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4511. }
  4512. /* istanbul ignore else */
  4513. {
  4514. initProxy(vm);
  4515. }
  4516. // expose real self
  4517. vm._self = vm;
  4518. initLifecycle(vm);
  4519. initEvents(vm);
  4520. initRender(vm);
  4521. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4522. initInjections(vm); // resolve injections before data/props
  4523. initState(vm);
  4524. initProvide(vm); // resolve provide after data/props
  4525. callHook$1(vm, 'created');
  4526. /* istanbul ignore if */
  4527. if (config.performance && mark) {
  4528. vm._name = formatComponentName(vm, false);
  4529. mark(endTag);
  4530. measure(`vue ${vm._name} init`, startTag, endTag);
  4531. }
  4532. if (vm.$options.el) {
  4533. vm.$mount(vm.$options.el);
  4534. }
  4535. };
  4536. }
  4537. function initInternalComponent(vm, options) {
  4538. const opts = (vm.$options = Object.create(vm.constructor.options));
  4539. // doing this because it's faster than dynamic enumeration.
  4540. const parentVnode = options._parentVnode;
  4541. opts.parent = options.parent;
  4542. opts._parentVnode = parentVnode;
  4543. const vnodeComponentOptions = parentVnode.componentOptions;
  4544. opts.propsData = vnodeComponentOptions.propsData;
  4545. opts._parentListeners = vnodeComponentOptions.listeners;
  4546. opts._renderChildren = vnodeComponentOptions.children;
  4547. opts._componentTag = vnodeComponentOptions.tag;
  4548. if (options.render) {
  4549. opts.render = options.render;
  4550. opts.staticRenderFns = options.staticRenderFns;
  4551. }
  4552. }
  4553. function resolveConstructorOptions(Ctor) {
  4554. let options = Ctor.options;
  4555. if (Ctor.super) {
  4556. const superOptions = resolveConstructorOptions(Ctor.super);
  4557. const cachedSuperOptions = Ctor.superOptions;
  4558. if (superOptions !== cachedSuperOptions) {
  4559. // super option changed,
  4560. // need to resolve new options.
  4561. Ctor.superOptions = superOptions;
  4562. // check if there are any late-modified/attached options (#4976)
  4563. const modifiedOptions = resolveModifiedOptions(Ctor);
  4564. // update base extend options
  4565. if (modifiedOptions) {
  4566. extend(Ctor.extendOptions, modifiedOptions);
  4567. }
  4568. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4569. if (options.name) {
  4570. options.components[options.name] = Ctor;
  4571. }
  4572. }
  4573. }
  4574. return options;
  4575. }
  4576. function resolveModifiedOptions(Ctor) {
  4577. let modified;
  4578. const latest = Ctor.options;
  4579. const sealed = Ctor.sealedOptions;
  4580. for (const key in latest) {
  4581. if (latest[key] !== sealed[key]) {
  4582. if (!modified)
  4583. modified = {};
  4584. modified[key] = latest[key];
  4585. }
  4586. }
  4587. return modified;
  4588. }
  4589. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4590. const options = Ctor.options;
  4591. // ensure the createElement function in functional components
  4592. // gets a unique context - this is necessary for correct named slot check
  4593. let contextVm;
  4594. if (hasOwn(parent, '_uid')) {
  4595. contextVm = Object.create(parent);
  4596. contextVm._original = parent;
  4597. }
  4598. else {
  4599. // the context vm passed in is a functional context as well.
  4600. // in this case we want to make sure we are able to get a hold to the
  4601. // real context instance.
  4602. contextVm = parent;
  4603. // @ts-ignore
  4604. parent = parent._original;
  4605. }
  4606. const isCompiled = isTrue(options._compiled);
  4607. const needNormalization = !isCompiled;
  4608. this.data = data;
  4609. this.props = props;
  4610. this.children = children;
  4611. this.parent = parent;
  4612. this.listeners = data.on || emptyObject;
  4613. this.injections = resolveInject(options.inject, parent);
  4614. this.slots = () => {
  4615. if (!this.$slots) {
  4616. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4617. }
  4618. return this.$slots;
  4619. };
  4620. Object.defineProperty(this, 'scopedSlots', {
  4621. enumerable: true,
  4622. get() {
  4623. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4624. }
  4625. });
  4626. // support for compiled functional template
  4627. if (isCompiled) {
  4628. // exposing $options for renderStatic()
  4629. this.$options = options;
  4630. // pre-resolve slots for renderSlot()
  4631. this.$slots = this.slots();
  4632. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4633. }
  4634. if (options._scopeId) {
  4635. this._c = (a, b, c, d) => {
  4636. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4637. if (vnode && !isArray(vnode)) {
  4638. vnode.fnScopeId = options._scopeId;
  4639. vnode.fnContext = parent;
  4640. }
  4641. return vnode;
  4642. };
  4643. }
  4644. else {
  4645. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4646. }
  4647. }
  4648. installRenderHelpers(FunctionalRenderContext.prototype);
  4649. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4650. const options = Ctor.options;
  4651. const props = {};
  4652. const propOptions = options.props;
  4653. if (isDef(propOptions)) {
  4654. for (const key in propOptions) {
  4655. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4656. }
  4657. }
  4658. else {
  4659. if (isDef(data.attrs))
  4660. mergeProps(props, data.attrs);
  4661. if (isDef(data.props))
  4662. mergeProps(props, data.props);
  4663. }
  4664. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4665. const vnode = options.render.call(null, renderContext._c, renderContext);
  4666. if (vnode instanceof VNode) {
  4667. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4668. }
  4669. else if (isArray(vnode)) {
  4670. const vnodes = normalizeChildren(vnode) || [];
  4671. const res = new Array(vnodes.length);
  4672. for (let i = 0; i < vnodes.length; i++) {
  4673. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4674. }
  4675. return res;
  4676. }
  4677. }
  4678. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4679. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4680. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4681. // that should not be matched to match.
  4682. const clone = cloneVNode(vnode);
  4683. clone.fnContext = contextVm;
  4684. clone.fnOptions = options;
  4685. {
  4686. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4687. renderContext;
  4688. }
  4689. if (data.slot) {
  4690. (clone.data || (clone.data = {})).slot = data.slot;
  4691. }
  4692. return clone;
  4693. }
  4694. function mergeProps(to, from) {
  4695. for (const key in from) {
  4696. to[camelize(key)] = from[key];
  4697. }
  4698. }
  4699. function getComponentName(options) {
  4700. return options.name || options.__name || options._componentTag;
  4701. }
  4702. // inline hooks to be invoked on component VNodes during patch
  4703. const componentVNodeHooks = {
  4704. init(vnode, hydrating) {
  4705. if (vnode.componentInstance &&
  4706. !vnode.componentInstance._isDestroyed &&
  4707. vnode.data.keepAlive) {
  4708. // kept-alive components, treat as a patch
  4709. const mountedNode = vnode; // work around flow
  4710. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4711. }
  4712. else {
  4713. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4714. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4715. }
  4716. },
  4717. prepatch(oldVnode, vnode) {
  4718. const options = vnode.componentOptions;
  4719. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4720. updateChildComponent(child, options.propsData, // updated props
  4721. options.listeners, // updated listeners
  4722. vnode, // new parent vnode
  4723. options.children // new children
  4724. );
  4725. },
  4726. insert(vnode) {
  4727. const { context, componentInstance } = vnode;
  4728. if (!componentInstance._isMounted) {
  4729. componentInstance._isMounted = true;
  4730. callHook$1(componentInstance, 'mounted');
  4731. }
  4732. if (vnode.data.keepAlive) {
  4733. if (context._isMounted) {
  4734. // vue-router#1212
  4735. // During updates, a kept-alive component's child components may
  4736. // change, so directly walking the tree here may call activated hooks
  4737. // on incorrect children. Instead we push them into a queue which will
  4738. // be processed after the whole patch process ended.
  4739. queueActivatedComponent(componentInstance);
  4740. }
  4741. else {
  4742. activateChildComponent(componentInstance, true /* direct */);
  4743. }
  4744. }
  4745. },
  4746. destroy(vnode) {
  4747. const { componentInstance } = vnode;
  4748. if (!componentInstance._isDestroyed) {
  4749. if (!vnode.data.keepAlive) {
  4750. componentInstance.$destroy();
  4751. }
  4752. else {
  4753. deactivateChildComponent(componentInstance, true /* direct */);
  4754. }
  4755. }
  4756. }
  4757. };
  4758. const hooksToMerge = Object.keys(componentVNodeHooks);
  4759. function createComponent(Ctor, data, context, children, tag) {
  4760. if (isUndef(Ctor)) {
  4761. return;
  4762. }
  4763. const baseCtor = context.$options._base;
  4764. // plain options object: turn it into a constructor
  4765. if (isObject(Ctor)) {
  4766. Ctor = baseCtor.extend(Ctor);
  4767. }
  4768. // if at this stage it's not a constructor or an async component factory,
  4769. // reject.
  4770. if (typeof Ctor !== 'function') {
  4771. {
  4772. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4773. }
  4774. return;
  4775. }
  4776. // async component
  4777. let asyncFactory;
  4778. // @ts-expect-error
  4779. if (isUndef(Ctor.cid)) {
  4780. asyncFactory = Ctor;
  4781. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4782. if (Ctor === undefined) {
  4783. // return a placeholder node for async component, which is rendered
  4784. // as a comment node but preserves all the raw information for the node.
  4785. // the information will be used for async server-rendering and hydration.
  4786. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4787. }
  4788. }
  4789. data = data || {};
  4790. // resolve constructor options in case global mixins are applied after
  4791. // component constructor creation
  4792. resolveConstructorOptions(Ctor);
  4793. // transform component v-model data into props & events
  4794. if (isDef(data.model)) {
  4795. // @ts-expect-error
  4796. transformModel(Ctor.options, data);
  4797. }
  4798. // extract props
  4799. // @ts-expect-error
  4800. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4801. // functional component
  4802. // @ts-expect-error
  4803. if (isTrue(Ctor.options.functional)) {
  4804. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4805. }
  4806. // extract listeners, since these needs to be treated as
  4807. // child component listeners instead of DOM listeners
  4808. const listeners = data.on;
  4809. // replace with listeners with .native modifier
  4810. // so it gets processed during parent component patch.
  4811. data.on = data.nativeOn;
  4812. // @ts-expect-error
  4813. if (isTrue(Ctor.options.abstract)) {
  4814. // abstract components do not keep anything
  4815. // other than props & listeners & slot
  4816. // work around flow
  4817. const slot = data.slot;
  4818. data = {};
  4819. if (slot) {
  4820. data.slot = slot;
  4821. }
  4822. }
  4823. // install component management hooks onto the placeholder node
  4824. installComponentHooks(data);
  4825. // return a placeholder vnode
  4826. // @ts-expect-error
  4827. const name = getComponentName(Ctor.options) || tag;
  4828. const vnode = new VNode(
  4829. // @ts-expect-error
  4830. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4831. // @ts-expect-error
  4832. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4833. return vnode;
  4834. }
  4835. function createComponentInstanceForVnode(
  4836. // we know it's MountedComponentVNode but flow doesn't
  4837. vnode,
  4838. // activeInstance in lifecycle state
  4839. parent) {
  4840. const options = {
  4841. _isComponent: true,
  4842. _parentVnode: vnode,
  4843. parent
  4844. };
  4845. // check inline-template render functions
  4846. const inlineTemplate = vnode.data.inlineTemplate;
  4847. if (isDef(inlineTemplate)) {
  4848. options.render = inlineTemplate.render;
  4849. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4850. }
  4851. return new vnode.componentOptions.Ctor(options);
  4852. }
  4853. function installComponentHooks(data) {
  4854. const hooks = data.hook || (data.hook = {});
  4855. for (let i = 0; i < hooksToMerge.length; i++) {
  4856. const key = hooksToMerge[i];
  4857. const existing = hooks[key];
  4858. const toMerge = componentVNodeHooks[key];
  4859. // @ts-expect-error
  4860. if (existing !== toMerge && !(existing && existing._merged)) {
  4861. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4862. }
  4863. }
  4864. }
  4865. function mergeHook(f1, f2) {
  4866. const merged = (a, b) => {
  4867. // flow complains about extra args which is why we use any
  4868. f1(a, b);
  4869. f2(a, b);
  4870. };
  4871. merged._merged = true;
  4872. return merged;
  4873. }
  4874. // transform component v-model info (value and callback) into
  4875. // prop and event handler respectively.
  4876. function transformModel(options, data) {
  4877. const prop = (options.model && options.model.prop) || 'value';
  4878. const event = (options.model && options.model.event) || 'input';
  4879. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4880. const on = data.on || (data.on = {});
  4881. const existing = on[event];
  4882. const callback = data.model.callback;
  4883. if (isDef(existing)) {
  4884. if (isArray(existing)
  4885. ? existing.indexOf(callback) === -1
  4886. : existing !== callback) {
  4887. on[event] = [callback].concat(existing);
  4888. }
  4889. }
  4890. else {
  4891. on[event] = callback;
  4892. }
  4893. }
  4894. let warn$2 = noop;
  4895. let tip = noop;
  4896. let generateComponentTrace; // work around flow check
  4897. let formatComponentName;
  4898. {
  4899. const hasConsole = typeof console !== 'undefined';
  4900. const classifyRE = /(?:^|[-_])(\w)/g;
  4901. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4902. warn$2 = (msg, vm = currentInstance) => {
  4903. const trace = vm ? generateComponentTrace(vm) : '';
  4904. if (config.warnHandler) {
  4905. config.warnHandler.call(null, msg, vm, trace);
  4906. }
  4907. else if (hasConsole && !config.silent) {
  4908. console.error(`[Vue warn]: ${msg}${trace}`);
  4909. }
  4910. };
  4911. tip = (msg, vm) => {
  4912. if (hasConsole && !config.silent) {
  4913. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4914. }
  4915. };
  4916. formatComponentName = (vm, includeFile) => {
  4917. if (vm.$root === vm) {
  4918. return '<Root>';
  4919. }
  4920. const options = isFunction(vm) && vm.cid != null
  4921. ? vm.options
  4922. : vm._isVue
  4923. ? vm.$options || vm.constructor.options
  4924. : vm;
  4925. let name = getComponentName(options);
  4926. const file = options.__file;
  4927. if (!name && file) {
  4928. const match = file.match(/([^/\\]+)\.vue$/);
  4929. name = match && match[1];
  4930. }
  4931. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4932. (file && includeFile !== false ? ` at ${file}` : ''));
  4933. };
  4934. const repeat = (str, n) => {
  4935. let res = '';
  4936. while (n) {
  4937. if (n % 2 === 1)
  4938. res += str;
  4939. if (n > 1)
  4940. str += str;
  4941. n >>= 1;
  4942. }
  4943. return res;
  4944. };
  4945. generateComponentTrace = (vm) => {
  4946. if (vm._isVue && vm.$parent) {
  4947. const tree = [];
  4948. let currentRecursiveSequence = 0;
  4949. while (vm) {
  4950. if (tree.length > 0) {
  4951. const last = tree[tree.length - 1];
  4952. if (last.constructor === vm.constructor) {
  4953. currentRecursiveSequence++;
  4954. vm = vm.$parent;
  4955. continue;
  4956. }
  4957. else if (currentRecursiveSequence > 0) {
  4958. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4959. currentRecursiveSequence = 0;
  4960. }
  4961. }
  4962. tree.push(vm);
  4963. vm = vm.$parent;
  4964. }
  4965. return ('\n\nfound in\n\n' +
  4966. tree
  4967. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4968. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4969. : formatComponentName(vm)}`)
  4970. .join('\n'));
  4971. }
  4972. else {
  4973. return `\n\n(found in ${formatComponentName(vm)})`;
  4974. }
  4975. };
  4976. }
  4977. /**
  4978. * Option overwriting strategies are functions that handle
  4979. * how to merge a parent option value and a child option
  4980. * value into the final value.
  4981. */
  4982. const strats = config.optionMergeStrategies;
  4983. /**
  4984. * Options with restrictions
  4985. */
  4986. {
  4987. strats.el = strats.propsData = function (parent, child, vm, key) {
  4988. if (!vm) {
  4989. warn$2(`option "${key}" can only be used during instance ` +
  4990. 'creation with the `new` keyword.');
  4991. }
  4992. return defaultStrat(parent, child);
  4993. };
  4994. }
  4995. /**
  4996. * Helper that recursively merges two data objects together.
  4997. */
  4998. function mergeData(to, from) {
  4999. if (!from)
  5000. return to;
  5001. let key, toVal, fromVal;
  5002. const keys = hasSymbol
  5003. ? Reflect.ownKeys(from)
  5004. : Object.keys(from);
  5005. for (let i = 0; i < keys.length; i++) {
  5006. key = keys[i];
  5007. // in case the object is already observed...
  5008. if (key === '__ob__')
  5009. continue;
  5010. toVal = to[key];
  5011. fromVal = from[key];
  5012. if (!hasOwn(to, key)) {
  5013. set(to, key, fromVal);
  5014. }
  5015. else if (toVal !== fromVal &&
  5016. isPlainObject(toVal) &&
  5017. isPlainObject(fromVal)) {
  5018. mergeData(toVal, fromVal);
  5019. }
  5020. }
  5021. return to;
  5022. }
  5023. /**
  5024. * Data
  5025. */
  5026. function mergeDataOrFn(parentVal, childVal, vm) {
  5027. if (!vm) {
  5028. // in a Vue.extend merge, both should be functions
  5029. if (!childVal) {
  5030. return parentVal;
  5031. }
  5032. if (!parentVal) {
  5033. return childVal;
  5034. }
  5035. // when parentVal & childVal are both present,
  5036. // we need to return a function that returns the
  5037. // merged result of both functions... no need to
  5038. // check if parentVal is a function here because
  5039. // it has to be a function to pass previous merges.
  5040. return function mergedDataFn() {
  5041. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5042. };
  5043. }
  5044. else {
  5045. return function mergedInstanceDataFn() {
  5046. // instance merge
  5047. const instanceData = isFunction(childVal)
  5048. ? childVal.call(vm, vm)
  5049. : childVal;
  5050. const defaultData = isFunction(parentVal)
  5051. ? parentVal.call(vm, vm)
  5052. : parentVal;
  5053. if (instanceData) {
  5054. return mergeData(instanceData, defaultData);
  5055. }
  5056. else {
  5057. return defaultData;
  5058. }
  5059. };
  5060. }
  5061. }
  5062. strats.data = function (parentVal, childVal, vm) {
  5063. if (!vm) {
  5064. if (childVal && typeof childVal !== 'function') {
  5065. warn$2('The "data" option should be a function ' +
  5066. 'that returns a per-instance value in component ' +
  5067. 'definitions.', vm);
  5068. return parentVal;
  5069. }
  5070. return mergeDataOrFn(parentVal, childVal);
  5071. }
  5072. return mergeDataOrFn(parentVal, childVal, vm);
  5073. };
  5074. /**
  5075. * Hooks and props are merged as arrays.
  5076. */
  5077. function mergeLifecycleHook(parentVal, childVal) {
  5078. const res = childVal
  5079. ? parentVal
  5080. ? parentVal.concat(childVal)
  5081. : isArray(childVal)
  5082. ? childVal
  5083. : [childVal]
  5084. : parentVal;
  5085. return res ? dedupeHooks(res) : res;
  5086. }
  5087. function dedupeHooks(hooks) {
  5088. const res = [];
  5089. for (let i = 0; i < hooks.length; i++) {
  5090. if (res.indexOf(hooks[i]) === -1) {
  5091. res.push(hooks[i]);
  5092. }
  5093. }
  5094. return res;
  5095. }
  5096. LIFECYCLE_HOOKS.forEach(hook => {
  5097. strats[hook] = mergeLifecycleHook;
  5098. });
  5099. /**
  5100. * Assets
  5101. *
  5102. * When a vm is present (instance creation), we need to do
  5103. * a three-way merge between constructor options, instance
  5104. * options and parent options.
  5105. */
  5106. function mergeAssets(parentVal, childVal, vm, key) {
  5107. const res = Object.create(parentVal || null);
  5108. if (childVal) {
  5109. assertObjectType(key, childVal, vm);
  5110. return extend(res, childVal);
  5111. }
  5112. else {
  5113. return res;
  5114. }
  5115. }
  5116. ASSET_TYPES.forEach(function (type) {
  5117. strats[type + 's'] = mergeAssets;
  5118. });
  5119. /**
  5120. * Watchers.
  5121. *
  5122. * Watchers hashes should not overwrite one
  5123. * another, so we merge them as arrays.
  5124. */
  5125. strats.watch = function (parentVal, childVal, vm, key) {
  5126. // work around Firefox's Object.prototype.watch...
  5127. //@ts-expect-error work around
  5128. if (parentVal === nativeWatch)
  5129. parentVal = undefined;
  5130. //@ts-expect-error work around
  5131. if (childVal === nativeWatch)
  5132. childVal = undefined;
  5133. /* istanbul ignore if */
  5134. if (!childVal)
  5135. return Object.create(parentVal || null);
  5136. {
  5137. assertObjectType(key, childVal, vm);
  5138. }
  5139. if (!parentVal)
  5140. return childVal;
  5141. const ret = {};
  5142. extend(ret, parentVal);
  5143. for (const key in childVal) {
  5144. let parent = ret[key];
  5145. const child = childVal[key];
  5146. if (parent && !isArray(parent)) {
  5147. parent = [parent];
  5148. }
  5149. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5150. }
  5151. return ret;
  5152. };
  5153. /**
  5154. * Other object hashes.
  5155. */
  5156. strats.props =
  5157. strats.methods =
  5158. strats.inject =
  5159. strats.computed =
  5160. function (parentVal, childVal, vm, key) {
  5161. if (childVal && true) {
  5162. assertObjectType(key, childVal, vm);
  5163. }
  5164. if (!parentVal)
  5165. return childVal;
  5166. const ret = Object.create(null);
  5167. extend(ret, parentVal);
  5168. if (childVal)
  5169. extend(ret, childVal);
  5170. return ret;
  5171. };
  5172. strats.provide = mergeDataOrFn;
  5173. /**
  5174. * Default strategy.
  5175. */
  5176. const defaultStrat = function (parentVal, childVal) {
  5177. return childVal === undefined ? parentVal : childVal;
  5178. };
  5179. /**
  5180. * Validate component names
  5181. */
  5182. function checkComponents(options) {
  5183. for (const key in options.components) {
  5184. validateComponentName(key);
  5185. }
  5186. }
  5187. function validateComponentName(name) {
  5188. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5189. warn$2('Invalid component name: "' +
  5190. name +
  5191. '". Component names ' +
  5192. 'should conform to valid custom element name in html5 specification.');
  5193. }
  5194. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5195. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5196. 'id: ' +
  5197. name);
  5198. }
  5199. }
  5200. /**
  5201. * Ensure all props option syntax are normalized into the
  5202. * Object-based format.
  5203. */
  5204. function normalizeProps(options, vm) {
  5205. const props = options.props;
  5206. if (!props)
  5207. return;
  5208. const res = {};
  5209. let i, val, name;
  5210. if (isArray(props)) {
  5211. i = props.length;
  5212. while (i--) {
  5213. val = props[i];
  5214. if (typeof val === 'string') {
  5215. name = camelize(val);
  5216. res[name] = { type: null };
  5217. }
  5218. else {
  5219. warn$2('props must be strings when using array syntax.');
  5220. }
  5221. }
  5222. }
  5223. else if (isPlainObject(props)) {
  5224. for (const key in props) {
  5225. val = props[key];
  5226. name = camelize(key);
  5227. res[name] = isPlainObject(val) ? val : { type: val };
  5228. }
  5229. }
  5230. else {
  5231. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5232. `but got ${toRawType(props)}.`, vm);
  5233. }
  5234. options.props = res;
  5235. }
  5236. /**
  5237. * Normalize all injections into Object-based format
  5238. */
  5239. function normalizeInject(options, vm) {
  5240. const inject = options.inject;
  5241. if (!inject)
  5242. return;
  5243. const normalized = (options.inject = {});
  5244. if (isArray(inject)) {
  5245. for (let i = 0; i < inject.length; i++) {
  5246. normalized[inject[i]] = { from: inject[i] };
  5247. }
  5248. }
  5249. else if (isPlainObject(inject)) {
  5250. for (const key in inject) {
  5251. const val = inject[key];
  5252. normalized[key] = isPlainObject(val)
  5253. ? extend({ from: key }, val)
  5254. : { from: val };
  5255. }
  5256. }
  5257. else {
  5258. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5259. `but got ${toRawType(inject)}.`, vm);
  5260. }
  5261. }
  5262. /**
  5263. * Normalize raw function directives into object format.
  5264. */
  5265. function normalizeDirectives$1(options) {
  5266. const dirs = options.directives;
  5267. if (dirs) {
  5268. for (const key in dirs) {
  5269. const def = dirs[key];
  5270. if (isFunction(def)) {
  5271. dirs[key] = { bind: def, update: def };
  5272. }
  5273. }
  5274. }
  5275. }
  5276. function assertObjectType(name, value, vm) {
  5277. if (!isPlainObject(value)) {
  5278. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5279. `but got ${toRawType(value)}.`, vm);
  5280. }
  5281. }
  5282. /**
  5283. * Merge two option objects into a new one.
  5284. * Core utility used in both instantiation and inheritance.
  5285. */
  5286. function mergeOptions(parent, child, vm) {
  5287. {
  5288. checkComponents(child);
  5289. }
  5290. if (isFunction(child)) {
  5291. // @ts-expect-error
  5292. child = child.options;
  5293. }
  5294. normalizeProps(child, vm);
  5295. normalizeInject(child, vm);
  5296. normalizeDirectives$1(child);
  5297. // Apply extends and mixins on the child options,
  5298. // but only if it is a raw options object that isn't
  5299. // the result of another mergeOptions call.
  5300. // Only merged options has the _base property.
  5301. if (!child._base) {
  5302. if (child.extends) {
  5303. parent = mergeOptions(parent, child.extends, vm);
  5304. }
  5305. if (child.mixins) {
  5306. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5307. parent = mergeOptions(parent, child.mixins[i], vm);
  5308. }
  5309. }
  5310. }
  5311. const options = {};
  5312. let key;
  5313. for (key in parent) {
  5314. mergeField(key);
  5315. }
  5316. for (key in child) {
  5317. if (!hasOwn(parent, key)) {
  5318. mergeField(key);
  5319. }
  5320. }
  5321. function mergeField(key) {
  5322. const strat = strats[key] || defaultStrat;
  5323. options[key] = strat(parent[key], child[key], vm, key);
  5324. }
  5325. return options;
  5326. }
  5327. /**
  5328. * Resolve an asset.
  5329. * This function is used because child instances need access
  5330. * to assets defined in its ancestor chain.
  5331. */
  5332. function resolveAsset(options, type, id, warnMissing) {
  5333. /* istanbul ignore if */
  5334. if (typeof id !== 'string') {
  5335. return;
  5336. }
  5337. const assets = options[type];
  5338. // check local registration variations first
  5339. if (hasOwn(assets, id))
  5340. return assets[id];
  5341. const camelizedId = camelize(id);
  5342. if (hasOwn(assets, camelizedId))
  5343. return assets[camelizedId];
  5344. const PascalCaseId = capitalize(camelizedId);
  5345. if (hasOwn(assets, PascalCaseId))
  5346. return assets[PascalCaseId];
  5347. // fallback to prototype chain
  5348. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5349. if (warnMissing && !res) {
  5350. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5351. }
  5352. return res;
  5353. }
  5354. function validateProp(key, propOptions, propsData, vm) {
  5355. const prop = propOptions[key];
  5356. const absent = !hasOwn(propsData, key);
  5357. let value = propsData[key];
  5358. // boolean casting
  5359. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5360. if (booleanIndex > -1) {
  5361. if (absent && !hasOwn(prop, 'default')) {
  5362. value = false;
  5363. }
  5364. else if (value === '' || value === hyphenate(key)) {
  5365. // only cast empty string / same name to boolean if
  5366. // boolean has higher priority
  5367. const stringIndex = getTypeIndex(String, prop.type);
  5368. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5369. value = true;
  5370. }
  5371. }
  5372. }
  5373. // check default value
  5374. if (value === undefined) {
  5375. value = getPropDefaultValue(vm, prop, key);
  5376. // since the default value is a fresh copy,
  5377. // make sure to observe it.
  5378. const prevShouldObserve = shouldObserve;
  5379. toggleObserving(true);
  5380. observe(value);
  5381. toggleObserving(prevShouldObserve);
  5382. }
  5383. {
  5384. assertProp(prop, key, value, vm, absent);
  5385. }
  5386. return value;
  5387. }
  5388. /**
  5389. * Get the default value of a prop.
  5390. */
  5391. function getPropDefaultValue(vm, prop, key) {
  5392. // no default, return undefined
  5393. if (!hasOwn(prop, 'default')) {
  5394. return undefined;
  5395. }
  5396. const def = prop.default;
  5397. // warn against non-factory defaults for Object & Array
  5398. if (isObject(def)) {
  5399. warn$2('Invalid default value for prop "' +
  5400. key +
  5401. '": ' +
  5402. 'Props with type Object/Array must use a factory function ' +
  5403. 'to return the default value.', vm);
  5404. }
  5405. // the raw prop value was also undefined from previous render,
  5406. // return previous default value to avoid unnecessary watcher trigger
  5407. if (vm &&
  5408. vm.$options.propsData &&
  5409. vm.$options.propsData[key] === undefined &&
  5410. vm._props[key] !== undefined) {
  5411. return vm._props[key];
  5412. }
  5413. // call factory function for non-Function types
  5414. // a value is Function if its prototype is function even across different execution context
  5415. return isFunction(def) && getType(prop.type) !== 'Function'
  5416. ? def.call(vm)
  5417. : def;
  5418. }
  5419. /**
  5420. * Assert whether a prop is valid.
  5421. */
  5422. function assertProp(prop, name, value, vm, absent) {
  5423. if (prop.required && absent) {
  5424. warn$2('Missing required prop: "' + name + '"', vm);
  5425. return;
  5426. }
  5427. if (value == null && !prop.required) {
  5428. return;
  5429. }
  5430. let type = prop.type;
  5431. let valid = !type || type === true;
  5432. const expectedTypes = [];
  5433. if (type) {
  5434. if (!isArray(type)) {
  5435. type = [type];
  5436. }
  5437. for (let i = 0; i < type.length && !valid; i++) {
  5438. const assertedType = assertType(value, type[i], vm);
  5439. expectedTypes.push(assertedType.expectedType || '');
  5440. valid = assertedType.valid;
  5441. }
  5442. }
  5443. const haveExpectedTypes = expectedTypes.some(t => t);
  5444. if (!valid && haveExpectedTypes) {
  5445. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5446. return;
  5447. }
  5448. const validator = prop.validator;
  5449. if (validator) {
  5450. if (!validator(value)) {
  5451. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5452. }
  5453. }
  5454. }
  5455. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5456. function assertType(value, type, vm) {
  5457. let valid;
  5458. const expectedType = getType(type);
  5459. if (simpleCheckRE.test(expectedType)) {
  5460. const t = typeof value;
  5461. valid = t === expectedType.toLowerCase();
  5462. // for primitive wrapper objects
  5463. if (!valid && t === 'object') {
  5464. valid = value instanceof type;
  5465. }
  5466. }
  5467. else if (expectedType === 'Object') {
  5468. valid = isPlainObject(value);
  5469. }
  5470. else if (expectedType === 'Array') {
  5471. valid = isArray(value);
  5472. }
  5473. else {
  5474. try {
  5475. valid = value instanceof type;
  5476. }
  5477. catch (e) {
  5478. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5479. valid = false;
  5480. }
  5481. }
  5482. return {
  5483. valid,
  5484. expectedType
  5485. };
  5486. }
  5487. const functionTypeCheckRE = /^\s*function (\w+)/;
  5488. /**
  5489. * Use function string name to check built-in types,
  5490. * because a simple equality check will fail when running
  5491. * across different vms / iframes.
  5492. */
  5493. function getType(fn) {
  5494. const match = fn && fn.toString().match(functionTypeCheckRE);
  5495. return match ? match[1] : '';
  5496. }
  5497. function isSameType(a, b) {
  5498. return getType(a) === getType(b);
  5499. }
  5500. function getTypeIndex(type, expectedTypes) {
  5501. if (!isArray(expectedTypes)) {
  5502. return isSameType(expectedTypes, type) ? 0 : -1;
  5503. }
  5504. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5505. if (isSameType(expectedTypes[i], type)) {
  5506. return i;
  5507. }
  5508. }
  5509. return -1;
  5510. }
  5511. function getInvalidTypeMessage(name, value, expectedTypes) {
  5512. let message = `Invalid prop: type check failed for prop "${name}".` +
  5513. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5514. const expectedType = expectedTypes[0];
  5515. const receivedType = toRawType(value);
  5516. // check if we need to specify expected value
  5517. if (expectedTypes.length === 1 &&
  5518. isExplicable(expectedType) &&
  5519. isExplicable(typeof value) &&
  5520. !isBoolean(expectedType, receivedType)) {
  5521. message += ` with value ${styleValue(value, expectedType)}`;
  5522. }
  5523. message += `, got ${receivedType} `;
  5524. // check if we need to specify received value
  5525. if (isExplicable(receivedType)) {
  5526. message += `with value ${styleValue(value, receivedType)}.`;
  5527. }
  5528. return message;
  5529. }
  5530. function styleValue(value, type) {
  5531. if (type === 'String') {
  5532. return `"${value}"`;
  5533. }
  5534. else if (type === 'Number') {
  5535. return `${Number(value)}`;
  5536. }
  5537. else {
  5538. return `${value}`;
  5539. }
  5540. }
  5541. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5542. function isExplicable(value) {
  5543. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5544. }
  5545. function isBoolean(...args) {
  5546. return args.some(elem => elem.toLowerCase() === 'boolean');
  5547. }
  5548. function Vue(options) {
  5549. if (!(this instanceof Vue)) {
  5550. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5551. }
  5552. this._init(options);
  5553. }
  5554. //@ts-expect-error Vue has function type
  5555. initMixin$1(Vue);
  5556. //@ts-expect-error Vue has function type
  5557. stateMixin(Vue);
  5558. //@ts-expect-error Vue has function type
  5559. eventsMixin(Vue);
  5560. //@ts-expect-error Vue has function type
  5561. lifecycleMixin(Vue);
  5562. //@ts-expect-error Vue has function type
  5563. renderMixin(Vue);
  5564. function initUse(Vue) {
  5565. Vue.use = function (plugin) {
  5566. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5567. if (installedPlugins.indexOf(plugin) > -1) {
  5568. return this;
  5569. }
  5570. // additional parameters
  5571. const args = toArray(arguments, 1);
  5572. args.unshift(this);
  5573. if (isFunction(plugin.install)) {
  5574. plugin.install.apply(plugin, args);
  5575. }
  5576. else if (isFunction(plugin)) {
  5577. plugin.apply(null, args);
  5578. }
  5579. installedPlugins.push(plugin);
  5580. return this;
  5581. };
  5582. }
  5583. function initMixin(Vue) {
  5584. Vue.mixin = function (mixin) {
  5585. this.options = mergeOptions(this.options, mixin);
  5586. return this;
  5587. };
  5588. }
  5589. function initExtend(Vue) {
  5590. /**
  5591. * Each instance constructor, including Vue, has a unique
  5592. * cid. This enables us to create wrapped "child
  5593. * constructors" for prototypal inheritance and cache them.
  5594. */
  5595. Vue.cid = 0;
  5596. let cid = 1;
  5597. /**
  5598. * Class inheritance
  5599. */
  5600. Vue.extend = function (extendOptions) {
  5601. extendOptions = extendOptions || {};
  5602. const Super = this;
  5603. const SuperId = Super.cid;
  5604. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5605. if (cachedCtors[SuperId]) {
  5606. return cachedCtors[SuperId];
  5607. }
  5608. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5609. if (name) {
  5610. validateComponentName(name);
  5611. }
  5612. const Sub = function VueComponent(options) {
  5613. this._init(options);
  5614. };
  5615. Sub.prototype = Object.create(Super.prototype);
  5616. Sub.prototype.constructor = Sub;
  5617. Sub.cid = cid++;
  5618. Sub.options = mergeOptions(Super.options, extendOptions);
  5619. Sub['super'] = Super;
  5620. // For props and computed properties, we define the proxy getters on
  5621. // the Vue instances at extension time, on the extended prototype. This
  5622. // avoids Object.defineProperty calls for each instance created.
  5623. if (Sub.options.props) {
  5624. initProps(Sub);
  5625. }
  5626. if (Sub.options.computed) {
  5627. initComputed(Sub);
  5628. }
  5629. // allow further extension/mixin/plugin usage
  5630. Sub.extend = Super.extend;
  5631. Sub.mixin = Super.mixin;
  5632. Sub.use = Super.use;
  5633. // create asset registers, so extended classes
  5634. // can have their private assets too.
  5635. ASSET_TYPES.forEach(function (type) {
  5636. Sub[type] = Super[type];
  5637. });
  5638. // enable recursive self-lookup
  5639. if (name) {
  5640. Sub.options.components[name] = Sub;
  5641. }
  5642. // keep a reference to the super options at extension time.
  5643. // later at instantiation we can check if Super's options have
  5644. // been updated.
  5645. Sub.superOptions = Super.options;
  5646. Sub.extendOptions = extendOptions;
  5647. Sub.sealedOptions = extend({}, Sub.options);
  5648. // cache constructor
  5649. cachedCtors[SuperId] = Sub;
  5650. return Sub;
  5651. };
  5652. }
  5653. function initProps(Comp) {
  5654. const props = Comp.options.props;
  5655. for (const key in props) {
  5656. proxy(Comp.prototype, `_props`, key);
  5657. }
  5658. }
  5659. function initComputed(Comp) {
  5660. const computed = Comp.options.computed;
  5661. for (const key in computed) {
  5662. defineComputed(Comp.prototype, key, computed[key]);
  5663. }
  5664. }
  5665. function initAssetRegisters(Vue) {
  5666. /**
  5667. * Create asset registration methods.
  5668. */
  5669. ASSET_TYPES.forEach(type => {
  5670. // @ts-expect-error function is not exact same type
  5671. Vue[type] = function (id, definition) {
  5672. if (!definition) {
  5673. return this.options[type + 's'][id];
  5674. }
  5675. else {
  5676. /* istanbul ignore if */
  5677. if (type === 'component') {
  5678. validateComponentName(id);
  5679. }
  5680. if (type === 'component' && isPlainObject(definition)) {
  5681. // @ts-expect-error
  5682. definition.name = definition.name || id;
  5683. definition = this.options._base.extend(definition);
  5684. }
  5685. if (type === 'directive' && isFunction(definition)) {
  5686. definition = { bind: definition, update: definition };
  5687. }
  5688. this.options[type + 's'][id] = definition;
  5689. return definition;
  5690. }
  5691. };
  5692. });
  5693. }
  5694. function _getComponentName(opts) {
  5695. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5696. }
  5697. function matches(pattern, name) {
  5698. if (isArray(pattern)) {
  5699. return pattern.indexOf(name) > -1;
  5700. }
  5701. else if (typeof pattern === 'string') {
  5702. return pattern.split(',').indexOf(name) > -1;
  5703. }
  5704. else if (isRegExp(pattern)) {
  5705. return pattern.test(name);
  5706. }
  5707. /* istanbul ignore next */
  5708. return false;
  5709. }
  5710. function pruneCache(keepAliveInstance, filter) {
  5711. const { cache, keys, _vnode } = keepAliveInstance;
  5712. for (const key in cache) {
  5713. const entry = cache[key];
  5714. if (entry) {
  5715. const name = entry.name;
  5716. if (name && !filter(name)) {
  5717. pruneCacheEntry(cache, key, keys, _vnode);
  5718. }
  5719. }
  5720. }
  5721. }
  5722. function pruneCacheEntry(cache, key, keys, current) {
  5723. const entry = cache[key];
  5724. if (entry && (!current || entry.tag !== current.tag)) {
  5725. // @ts-expect-error can be undefined
  5726. entry.componentInstance.$destroy();
  5727. }
  5728. cache[key] = null;
  5729. remove$2(keys, key);
  5730. }
  5731. const patternTypes = [String, RegExp, Array];
  5732. // TODO defineComponent
  5733. var KeepAlive = {
  5734. name: 'keep-alive',
  5735. abstract: true,
  5736. props: {
  5737. include: patternTypes,
  5738. exclude: patternTypes,
  5739. max: [String, Number]
  5740. },
  5741. methods: {
  5742. cacheVNode() {
  5743. const { cache, keys, vnodeToCache, keyToCache } = this;
  5744. if (vnodeToCache) {
  5745. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5746. cache[keyToCache] = {
  5747. name: _getComponentName(componentOptions),
  5748. tag,
  5749. componentInstance
  5750. };
  5751. keys.push(keyToCache);
  5752. // prune oldest entry
  5753. if (this.max && keys.length > parseInt(this.max)) {
  5754. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5755. }
  5756. this.vnodeToCache = null;
  5757. }
  5758. }
  5759. },
  5760. created() {
  5761. this.cache = Object.create(null);
  5762. this.keys = [];
  5763. },
  5764. destroyed() {
  5765. for (const key in this.cache) {
  5766. pruneCacheEntry(this.cache, key, this.keys);
  5767. }
  5768. },
  5769. mounted() {
  5770. this.cacheVNode();
  5771. this.$watch('include', val => {
  5772. pruneCache(this, name => matches(val, name));
  5773. });
  5774. this.$watch('exclude', val => {
  5775. pruneCache(this, name => !matches(val, name));
  5776. });
  5777. },
  5778. updated() {
  5779. this.cacheVNode();
  5780. },
  5781. render() {
  5782. const slot = this.$slots.default;
  5783. const vnode = getFirstComponentChild(slot);
  5784. const componentOptions = vnode && vnode.componentOptions;
  5785. if (componentOptions) {
  5786. // check pattern
  5787. const name = _getComponentName(componentOptions);
  5788. const { include, exclude } = this;
  5789. if (
  5790. // not included
  5791. (include && (!name || !matches(include, name))) ||
  5792. // excluded
  5793. (exclude && name && matches(exclude, name))) {
  5794. return vnode;
  5795. }
  5796. const { cache, keys } = this;
  5797. const key = vnode.key == null
  5798. ? // same constructor may get registered as different local components
  5799. // so cid alone is not enough (#3269)
  5800. componentOptions.Ctor.cid +
  5801. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5802. : vnode.key;
  5803. if (cache[key]) {
  5804. vnode.componentInstance = cache[key].componentInstance;
  5805. // make current key freshest
  5806. remove$2(keys, key);
  5807. keys.push(key);
  5808. }
  5809. else {
  5810. // delay setting the cache until update
  5811. this.vnodeToCache = vnode;
  5812. this.keyToCache = key;
  5813. }
  5814. // @ts-expect-error can vnode.data can be undefined
  5815. vnode.data.keepAlive = true;
  5816. }
  5817. return vnode || (slot && slot[0]);
  5818. }
  5819. };
  5820. var builtInComponents = {
  5821. KeepAlive
  5822. };
  5823. function initGlobalAPI(Vue) {
  5824. // config
  5825. const configDef = {};
  5826. configDef.get = () => config;
  5827. {
  5828. configDef.set = () => {
  5829. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5830. };
  5831. }
  5832. Object.defineProperty(Vue, 'config', configDef);
  5833. // exposed util methods.
  5834. // NOTE: these are not considered part of the public API - avoid relying on
  5835. // them unless you are aware of the risk.
  5836. Vue.util = {
  5837. warn: warn$2,
  5838. extend,
  5839. mergeOptions,
  5840. defineReactive
  5841. };
  5842. Vue.set = set;
  5843. Vue.delete = del;
  5844. Vue.nextTick = nextTick;
  5845. // 2.6 explicit observable API
  5846. Vue.observable = (obj) => {
  5847. observe(obj);
  5848. return obj;
  5849. };
  5850. Vue.options = Object.create(null);
  5851. ASSET_TYPES.forEach(type => {
  5852. Vue.options[type + 's'] = Object.create(null);
  5853. });
  5854. // this is used to identify the "base" constructor to extend all plain-object
  5855. // components with in Weex's multi-instance scenarios.
  5856. Vue.options._base = Vue;
  5857. extend(Vue.options.components, builtInComponents);
  5858. initUse(Vue);
  5859. initMixin(Vue);
  5860. initExtend(Vue);
  5861. initAssetRegisters(Vue);
  5862. }
  5863. initGlobalAPI(Vue);
  5864. Object.defineProperty(Vue.prototype, '$isServer', {
  5865. get: isServerRendering
  5866. });
  5867. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5868. get() {
  5869. /* istanbul ignore next */
  5870. return this.$vnode && this.$vnode.ssrContext;
  5871. }
  5872. });
  5873. // expose FunctionalRenderContext for ssr runtime helper installation
  5874. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5875. value: FunctionalRenderContext
  5876. });
  5877. Vue.version = version;
  5878. // these are reserved for web because they are directly compiled away
  5879. // during template compilation
  5880. const isReservedAttr = makeMap('style,class');
  5881. // attributes that should be using props for binding
  5882. const acceptValue = makeMap('input,textarea,option,select,progress');
  5883. const mustUseProp = (tag, type, attr) => {
  5884. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5885. (attr === 'selected' && tag === 'option') ||
  5886. (attr === 'checked' && tag === 'input') ||
  5887. (attr === 'muted' && tag === 'video'));
  5888. };
  5889. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5890. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5891. const convertEnumeratedValue = (key, value) => {
  5892. return isFalsyAttrValue(value) || value === 'false'
  5893. ? 'false'
  5894. : // allow arbitrary string value for contenteditable
  5895. key === 'contenteditable' && isValidContentEditableValue(value)
  5896. ? value
  5897. : 'true';
  5898. };
  5899. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5900. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5901. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5902. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5903. 'required,reversed,scoped,seamless,selected,sortable,' +
  5904. 'truespeed,typemustmatch,visible');
  5905. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5906. const isXlink = (name) => {
  5907. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5908. };
  5909. const getXlinkProp = (name) => {
  5910. return isXlink(name) ? name.slice(6, name.length) : '';
  5911. };
  5912. const isFalsyAttrValue = (val) => {
  5913. return val == null || val === false;
  5914. };
  5915. function genClassForVnode(vnode) {
  5916. let data = vnode.data;
  5917. let parentNode = vnode;
  5918. let childNode = vnode;
  5919. while (isDef(childNode.componentInstance)) {
  5920. childNode = childNode.componentInstance._vnode;
  5921. if (childNode && childNode.data) {
  5922. data = mergeClassData(childNode.data, data);
  5923. }
  5924. }
  5925. // @ts-expect-error parentNode.parent not VNodeWithData
  5926. while (isDef((parentNode = parentNode.parent))) {
  5927. if (parentNode && parentNode.data) {
  5928. data = mergeClassData(data, parentNode.data);
  5929. }
  5930. }
  5931. return renderClass(data.staticClass, data.class);
  5932. }
  5933. function mergeClassData(child, parent) {
  5934. return {
  5935. staticClass: concat(child.staticClass, parent.staticClass),
  5936. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  5937. };
  5938. }
  5939. function renderClass(staticClass, dynamicClass) {
  5940. if (isDef(staticClass) || isDef(dynamicClass)) {
  5941. return concat(staticClass, stringifyClass(dynamicClass));
  5942. }
  5943. /* istanbul ignore next */
  5944. return '';
  5945. }
  5946. function concat(a, b) {
  5947. return a ? (b ? a + ' ' + b : a) : b || '';
  5948. }
  5949. function stringifyClass(value) {
  5950. if (Array.isArray(value)) {
  5951. return stringifyArray(value);
  5952. }
  5953. if (isObject(value)) {
  5954. return stringifyObject(value);
  5955. }
  5956. if (typeof value === 'string') {
  5957. return value;
  5958. }
  5959. /* istanbul ignore next */
  5960. return '';
  5961. }
  5962. function stringifyArray(value) {
  5963. let res = '';
  5964. let stringified;
  5965. for (let i = 0, l = value.length; i < l; i++) {
  5966. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  5967. if (res)
  5968. res += ' ';
  5969. res += stringified;
  5970. }
  5971. }
  5972. return res;
  5973. }
  5974. function stringifyObject(value) {
  5975. let res = '';
  5976. for (const key in value) {
  5977. if (value[key]) {
  5978. if (res)
  5979. res += ' ';
  5980. res += key;
  5981. }
  5982. }
  5983. return res;
  5984. }
  5985. const namespaceMap = {
  5986. svg: 'http://www.w3.org/2000/svg',
  5987. math: 'http://www.w3.org/1998/Math/MathML'
  5988. };
  5989. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  5990. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5991. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5992. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5993. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5994. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5995. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5996. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5997. 'output,progress,select,textarea,' +
  5998. 'details,dialog,menu,menuitem,summary,' +
  5999. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6000. // this map is intentionally selective, only covering SVG elements that may
  6001. // contain child elements.
  6002. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6003. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6004. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6005. const isPreTag = (tag) => tag === 'pre';
  6006. const isReservedTag = (tag) => {
  6007. return isHTMLTag(tag) || isSVG(tag);
  6008. };
  6009. function getTagNamespace(tag) {
  6010. if (isSVG(tag)) {
  6011. return 'svg';
  6012. }
  6013. // basic support for MathML
  6014. // note it doesn't support other MathML elements being component roots
  6015. if (tag === 'math') {
  6016. return 'math';
  6017. }
  6018. }
  6019. const unknownElementCache = Object.create(null);
  6020. function isUnknownElement(tag) {
  6021. /* istanbul ignore if */
  6022. if (!inBrowser) {
  6023. return true;
  6024. }
  6025. if (isReservedTag(tag)) {
  6026. return false;
  6027. }
  6028. tag = tag.toLowerCase();
  6029. /* istanbul ignore if */
  6030. if (unknownElementCache[tag] != null) {
  6031. return unknownElementCache[tag];
  6032. }
  6033. const el = document.createElement(tag);
  6034. if (tag.indexOf('-') > -1) {
  6035. // http://stackoverflow.com/a/28210364/1070244
  6036. return (unknownElementCache[tag] =
  6037. el.constructor === window.HTMLUnknownElement ||
  6038. el.constructor === window.HTMLElement);
  6039. }
  6040. else {
  6041. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6042. }
  6043. }
  6044. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6045. /**
  6046. * Query an element selector if it's not an element already.
  6047. */
  6048. function query(el) {
  6049. if (typeof el === 'string') {
  6050. const selected = document.querySelector(el);
  6051. if (!selected) {
  6052. warn$2('Cannot find element: ' + el);
  6053. return document.createElement('div');
  6054. }
  6055. return selected;
  6056. }
  6057. else {
  6058. return el;
  6059. }
  6060. }
  6061. function createElement(tagName, vnode) {
  6062. const elm = document.createElement(tagName);
  6063. if (tagName !== 'select') {
  6064. return elm;
  6065. }
  6066. // false or null will remove the attribute but undefined will not
  6067. if (vnode.data &&
  6068. vnode.data.attrs &&
  6069. vnode.data.attrs.multiple !== undefined) {
  6070. elm.setAttribute('multiple', 'multiple');
  6071. }
  6072. return elm;
  6073. }
  6074. function createElementNS(namespace, tagName) {
  6075. return document.createElementNS(namespaceMap[namespace], tagName);
  6076. }
  6077. function createTextNode(text) {
  6078. return document.createTextNode(text);
  6079. }
  6080. function createComment(text) {
  6081. return document.createComment(text);
  6082. }
  6083. function insertBefore(parentNode, newNode, referenceNode) {
  6084. parentNode.insertBefore(newNode, referenceNode);
  6085. }
  6086. function removeChild(node, child) {
  6087. node.removeChild(child);
  6088. }
  6089. function appendChild(node, child) {
  6090. node.appendChild(child);
  6091. }
  6092. function parentNode(node) {
  6093. return node.parentNode;
  6094. }
  6095. function nextSibling(node) {
  6096. return node.nextSibling;
  6097. }
  6098. function tagName(node) {
  6099. return node.tagName;
  6100. }
  6101. function setTextContent(node, text) {
  6102. node.textContent = text;
  6103. }
  6104. function setStyleScope(node, scopeId) {
  6105. node.setAttribute(scopeId, '');
  6106. }
  6107. var nodeOps = /*#__PURE__*/Object.freeze({
  6108. __proto__: null,
  6109. createElement: createElement,
  6110. createElementNS: createElementNS,
  6111. createTextNode: createTextNode,
  6112. createComment: createComment,
  6113. insertBefore: insertBefore,
  6114. removeChild: removeChild,
  6115. appendChild: appendChild,
  6116. parentNode: parentNode,
  6117. nextSibling: nextSibling,
  6118. tagName: tagName,
  6119. setTextContent: setTextContent,
  6120. setStyleScope: setStyleScope
  6121. });
  6122. var ref = {
  6123. create(_, vnode) {
  6124. registerRef(vnode);
  6125. },
  6126. update(oldVnode, vnode) {
  6127. if (oldVnode.data.ref !== vnode.data.ref) {
  6128. registerRef(oldVnode, true);
  6129. registerRef(vnode);
  6130. }
  6131. },
  6132. destroy(vnode) {
  6133. registerRef(vnode, true);
  6134. }
  6135. };
  6136. function registerRef(vnode, isRemoval) {
  6137. const ref = vnode.data.ref;
  6138. if (!isDef(ref))
  6139. return;
  6140. const vm = vnode.context;
  6141. const refValue = vnode.componentInstance || vnode.elm;
  6142. const value = isRemoval ? null : refValue;
  6143. const $refsValue = isRemoval ? undefined : refValue;
  6144. if (isFunction(ref)) {
  6145. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6146. return;
  6147. }
  6148. const isFor = vnode.data.refInFor;
  6149. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6150. const _isRef = isRef(ref);
  6151. const refs = vm.$refs;
  6152. if (_isString || _isRef) {
  6153. if (isFor) {
  6154. const existing = _isString ? refs[ref] : ref.value;
  6155. if (isRemoval) {
  6156. isArray(existing) && remove$2(existing, refValue);
  6157. }
  6158. else {
  6159. if (!isArray(existing)) {
  6160. if (_isString) {
  6161. refs[ref] = [refValue];
  6162. setSetupRef(vm, ref, refs[ref]);
  6163. }
  6164. else {
  6165. ref.value = [refValue];
  6166. }
  6167. }
  6168. else if (!existing.includes(refValue)) {
  6169. existing.push(refValue);
  6170. }
  6171. }
  6172. }
  6173. else if (_isString) {
  6174. if (isRemoval && refs[ref] !== refValue) {
  6175. return;
  6176. }
  6177. refs[ref] = $refsValue;
  6178. setSetupRef(vm, ref, value);
  6179. }
  6180. else if (_isRef) {
  6181. if (isRemoval && ref.value !== refValue) {
  6182. return;
  6183. }
  6184. ref.value = value;
  6185. }
  6186. else {
  6187. warn$2(`Invalid template ref type: ${typeof ref}`);
  6188. }
  6189. }
  6190. }
  6191. function setSetupRef({ _setupState }, key, val) {
  6192. if (_setupState && hasOwn(_setupState, key)) {
  6193. if (isRef(_setupState[key])) {
  6194. _setupState[key].value = val;
  6195. }
  6196. else {
  6197. _setupState[key] = val;
  6198. }
  6199. }
  6200. }
  6201. /**
  6202. * Virtual DOM patching algorithm based on Snabbdom by
  6203. * Simon Friis Vindum (@paldepind)
  6204. * Licensed under the MIT License
  6205. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6206. *
  6207. * modified by Evan You (@yyx990803)
  6208. *
  6209. * Not type-checking this because this file is perf-critical and the cost
  6210. * of making flow understand it is not worth it.
  6211. */
  6212. const emptyNode = new VNode('', {}, []);
  6213. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6214. function sameVnode(a, b) {
  6215. return (a.key === b.key &&
  6216. a.asyncFactory === b.asyncFactory &&
  6217. ((a.tag === b.tag &&
  6218. a.isComment === b.isComment &&
  6219. isDef(a.data) === isDef(b.data) &&
  6220. sameInputType(a, b)) ||
  6221. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6222. }
  6223. function sameInputType(a, b) {
  6224. if (a.tag !== 'input')
  6225. return true;
  6226. let i;
  6227. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6228. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6229. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6230. }
  6231. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6232. let i, key;
  6233. const map = {};
  6234. for (i = beginIdx; i <= endIdx; ++i) {
  6235. key = children[i].key;
  6236. if (isDef(key))
  6237. map[key] = i;
  6238. }
  6239. return map;
  6240. }
  6241. function createPatchFunction(backend) {
  6242. let i, j;
  6243. const cbs = {};
  6244. const { modules, nodeOps } = backend;
  6245. for (i = 0; i < hooks.length; ++i) {
  6246. cbs[hooks[i]] = [];
  6247. for (j = 0; j < modules.length; ++j) {
  6248. if (isDef(modules[j][hooks[i]])) {
  6249. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6250. }
  6251. }
  6252. }
  6253. function emptyNodeAt(elm) {
  6254. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6255. }
  6256. function createRmCb(childElm, listeners) {
  6257. function remove() {
  6258. if (--remove.listeners === 0) {
  6259. removeNode(childElm);
  6260. }
  6261. }
  6262. remove.listeners = listeners;
  6263. return remove;
  6264. }
  6265. function removeNode(el) {
  6266. const parent = nodeOps.parentNode(el);
  6267. // element may have already been removed due to v-html / v-text
  6268. if (isDef(parent)) {
  6269. nodeOps.removeChild(parent, el);
  6270. }
  6271. }
  6272. function isUnknownElement(vnode, inVPre) {
  6273. return (!inVPre &&
  6274. !vnode.ns &&
  6275. !(config.ignoredElements.length &&
  6276. config.ignoredElements.some(ignore => {
  6277. return isRegExp(ignore)
  6278. ? ignore.test(vnode.tag)
  6279. : ignore === vnode.tag;
  6280. })) &&
  6281. config.isUnknownElement(vnode.tag));
  6282. }
  6283. let creatingElmInVPre = 0;
  6284. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6285. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6286. // This vnode was used in a previous render!
  6287. // now it's used as a new node, overwriting its elm would cause
  6288. // potential patch errors down the road when it's used as an insertion
  6289. // reference node. Instead, we clone the node on-demand before creating
  6290. // associated DOM element for it.
  6291. vnode = ownerArray[index] = cloneVNode(vnode);
  6292. }
  6293. vnode.isRootInsert = !nested; // for transition enter check
  6294. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6295. return;
  6296. }
  6297. const data = vnode.data;
  6298. const children = vnode.children;
  6299. const tag = vnode.tag;
  6300. if (isDef(tag)) {
  6301. {
  6302. if (data && data.pre) {
  6303. creatingElmInVPre++;
  6304. }
  6305. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6306. warn$2('Unknown custom element: <' +
  6307. tag +
  6308. '> - did you ' +
  6309. 'register the component correctly? For recursive components, ' +
  6310. 'make sure to provide the "name" option.', vnode.context);
  6311. }
  6312. }
  6313. vnode.elm = vnode.ns
  6314. ? nodeOps.createElementNS(vnode.ns, tag)
  6315. : nodeOps.createElement(tag, vnode);
  6316. setScope(vnode);
  6317. createChildren(vnode, children, insertedVnodeQueue);
  6318. if (isDef(data)) {
  6319. invokeCreateHooks(vnode, insertedVnodeQueue);
  6320. }
  6321. insert(parentElm, vnode.elm, refElm);
  6322. if (data && data.pre) {
  6323. creatingElmInVPre--;
  6324. }
  6325. }
  6326. else if (isTrue(vnode.isComment)) {
  6327. vnode.elm = nodeOps.createComment(vnode.text);
  6328. insert(parentElm, vnode.elm, refElm);
  6329. }
  6330. else {
  6331. vnode.elm = nodeOps.createTextNode(vnode.text);
  6332. insert(parentElm, vnode.elm, refElm);
  6333. }
  6334. }
  6335. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6336. let i = vnode.data;
  6337. if (isDef(i)) {
  6338. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6339. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6340. i(vnode, false /* hydrating */);
  6341. }
  6342. // after calling the init hook, if the vnode is a child component
  6343. // it should've created a child instance and mounted it. the child
  6344. // component also has set the placeholder vnode's elm.
  6345. // in that case we can just return the element and be done.
  6346. if (isDef(vnode.componentInstance)) {
  6347. initComponent(vnode, insertedVnodeQueue);
  6348. insert(parentElm, vnode.elm, refElm);
  6349. if (isTrue(isReactivated)) {
  6350. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6351. }
  6352. return true;
  6353. }
  6354. }
  6355. }
  6356. function initComponent(vnode, insertedVnodeQueue) {
  6357. if (isDef(vnode.data.pendingInsert)) {
  6358. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6359. vnode.data.pendingInsert = null;
  6360. }
  6361. vnode.elm = vnode.componentInstance.$el;
  6362. if (isPatchable(vnode)) {
  6363. invokeCreateHooks(vnode, insertedVnodeQueue);
  6364. setScope(vnode);
  6365. }
  6366. else {
  6367. // empty component root.
  6368. // skip all element-related modules except for ref (#3455)
  6369. registerRef(vnode);
  6370. // make sure to invoke the insert hook
  6371. insertedVnodeQueue.push(vnode);
  6372. }
  6373. }
  6374. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6375. let i;
  6376. // hack for #4339: a reactivated component with inner transition
  6377. // does not trigger because the inner node's created hooks are not called
  6378. // again. It's not ideal to involve module-specific logic in here but
  6379. // there doesn't seem to be a better way to do it.
  6380. let innerNode = vnode;
  6381. while (innerNode.componentInstance) {
  6382. innerNode = innerNode.componentInstance._vnode;
  6383. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6384. for (i = 0; i < cbs.activate.length; ++i) {
  6385. cbs.activate[i](emptyNode, innerNode);
  6386. }
  6387. insertedVnodeQueue.push(innerNode);
  6388. break;
  6389. }
  6390. }
  6391. // unlike a newly created component,
  6392. // a reactivated keep-alive component doesn't insert itself
  6393. insert(parentElm, vnode.elm, refElm);
  6394. }
  6395. function insert(parent, elm, ref) {
  6396. if (isDef(parent)) {
  6397. if (isDef(ref)) {
  6398. if (nodeOps.parentNode(ref) === parent) {
  6399. nodeOps.insertBefore(parent, elm, ref);
  6400. }
  6401. }
  6402. else {
  6403. nodeOps.appendChild(parent, elm);
  6404. }
  6405. }
  6406. }
  6407. function createChildren(vnode, children, insertedVnodeQueue) {
  6408. if (isArray(children)) {
  6409. {
  6410. checkDuplicateKeys(children);
  6411. }
  6412. for (let i = 0; i < children.length; ++i) {
  6413. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6414. }
  6415. }
  6416. else if (isPrimitive(vnode.text)) {
  6417. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6418. }
  6419. }
  6420. function isPatchable(vnode) {
  6421. while (vnode.componentInstance) {
  6422. vnode = vnode.componentInstance._vnode;
  6423. }
  6424. return isDef(vnode.tag);
  6425. }
  6426. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6427. for (let i = 0; i < cbs.create.length; ++i) {
  6428. cbs.create[i](emptyNode, vnode);
  6429. }
  6430. i = vnode.data.hook; // Reuse variable
  6431. if (isDef(i)) {
  6432. if (isDef(i.create))
  6433. i.create(emptyNode, vnode);
  6434. if (isDef(i.insert))
  6435. insertedVnodeQueue.push(vnode);
  6436. }
  6437. }
  6438. // set scope id attribute for scoped CSS.
  6439. // this is implemented as a special case to avoid the overhead
  6440. // of going through the normal attribute patching process.
  6441. function setScope(vnode) {
  6442. let i;
  6443. if (isDef((i = vnode.fnScopeId))) {
  6444. nodeOps.setStyleScope(vnode.elm, i);
  6445. }
  6446. else {
  6447. let ancestor = vnode;
  6448. while (ancestor) {
  6449. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6450. nodeOps.setStyleScope(vnode.elm, i);
  6451. }
  6452. ancestor = ancestor.parent;
  6453. }
  6454. }
  6455. // for slot content they should also get the scopeId from the host instance.
  6456. if (isDef((i = activeInstance)) &&
  6457. i !== vnode.context &&
  6458. i !== vnode.fnContext &&
  6459. isDef((i = i.$options._scopeId))) {
  6460. nodeOps.setStyleScope(vnode.elm, i);
  6461. }
  6462. }
  6463. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6464. for (; startIdx <= endIdx; ++startIdx) {
  6465. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6466. }
  6467. }
  6468. function invokeDestroyHook(vnode) {
  6469. let i, j;
  6470. const data = vnode.data;
  6471. if (isDef(data)) {
  6472. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6473. i(vnode);
  6474. for (i = 0; i < cbs.destroy.length; ++i)
  6475. cbs.destroy[i](vnode);
  6476. }
  6477. if (isDef((i = vnode.children))) {
  6478. for (j = 0; j < vnode.children.length; ++j) {
  6479. invokeDestroyHook(vnode.children[j]);
  6480. }
  6481. }
  6482. }
  6483. function removeVnodes(vnodes, startIdx, endIdx) {
  6484. for (; startIdx <= endIdx; ++startIdx) {
  6485. const ch = vnodes[startIdx];
  6486. if (isDef(ch)) {
  6487. if (isDef(ch.tag)) {
  6488. removeAndInvokeRemoveHook(ch);
  6489. invokeDestroyHook(ch);
  6490. }
  6491. else {
  6492. // Text node
  6493. removeNode(ch.elm);
  6494. }
  6495. }
  6496. }
  6497. }
  6498. function removeAndInvokeRemoveHook(vnode, rm) {
  6499. if (isDef(rm) || isDef(vnode.data)) {
  6500. let i;
  6501. const listeners = cbs.remove.length + 1;
  6502. if (isDef(rm)) {
  6503. // we have a recursively passed down rm callback
  6504. // increase the listeners count
  6505. rm.listeners += listeners;
  6506. }
  6507. else {
  6508. // directly removing
  6509. rm = createRmCb(vnode.elm, listeners);
  6510. }
  6511. // recursively invoke hooks on child component root node
  6512. if (isDef((i = vnode.componentInstance)) &&
  6513. isDef((i = i._vnode)) &&
  6514. isDef(i.data)) {
  6515. removeAndInvokeRemoveHook(i, rm);
  6516. }
  6517. for (i = 0; i < cbs.remove.length; ++i) {
  6518. cbs.remove[i](vnode, rm);
  6519. }
  6520. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6521. i(vnode, rm);
  6522. }
  6523. else {
  6524. rm();
  6525. }
  6526. }
  6527. else {
  6528. removeNode(vnode.elm);
  6529. }
  6530. }
  6531. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6532. let oldStartIdx = 0;
  6533. let newStartIdx = 0;
  6534. let oldEndIdx = oldCh.length - 1;
  6535. let oldStartVnode = oldCh[0];
  6536. let oldEndVnode = oldCh[oldEndIdx];
  6537. let newEndIdx = newCh.length - 1;
  6538. let newStartVnode = newCh[0];
  6539. let newEndVnode = newCh[newEndIdx];
  6540. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6541. // removeOnly is a special flag used only by <transition-group>
  6542. // to ensure removed elements stay in correct relative positions
  6543. // during leaving transitions
  6544. const canMove = !removeOnly;
  6545. {
  6546. checkDuplicateKeys(newCh);
  6547. }
  6548. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6549. if (isUndef(oldStartVnode)) {
  6550. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6551. }
  6552. else if (isUndef(oldEndVnode)) {
  6553. oldEndVnode = oldCh[--oldEndIdx];
  6554. }
  6555. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6556. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6557. oldStartVnode = oldCh[++oldStartIdx];
  6558. newStartVnode = newCh[++newStartIdx];
  6559. }
  6560. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6561. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6562. oldEndVnode = oldCh[--oldEndIdx];
  6563. newEndVnode = newCh[--newEndIdx];
  6564. }
  6565. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6566. // Vnode moved right
  6567. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6568. canMove &&
  6569. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6570. oldStartVnode = oldCh[++oldStartIdx];
  6571. newEndVnode = newCh[--newEndIdx];
  6572. }
  6573. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6574. // Vnode moved left
  6575. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6576. canMove &&
  6577. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6578. oldEndVnode = oldCh[--oldEndIdx];
  6579. newStartVnode = newCh[++newStartIdx];
  6580. }
  6581. else {
  6582. if (isUndef(oldKeyToIdx))
  6583. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6584. idxInOld = isDef(newStartVnode.key)
  6585. ? oldKeyToIdx[newStartVnode.key]
  6586. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6587. if (isUndef(idxInOld)) {
  6588. // New element
  6589. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6590. }
  6591. else {
  6592. vnodeToMove = oldCh[idxInOld];
  6593. if (sameVnode(vnodeToMove, newStartVnode)) {
  6594. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6595. oldCh[idxInOld] = undefined;
  6596. canMove &&
  6597. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6598. }
  6599. else {
  6600. // same key but different element. treat as new element
  6601. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6602. }
  6603. }
  6604. newStartVnode = newCh[++newStartIdx];
  6605. }
  6606. }
  6607. if (oldStartIdx > oldEndIdx) {
  6608. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6609. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6610. }
  6611. else if (newStartIdx > newEndIdx) {
  6612. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6613. }
  6614. }
  6615. function checkDuplicateKeys(children) {
  6616. const seenKeys = {};
  6617. for (let i = 0; i < children.length; i++) {
  6618. const vnode = children[i];
  6619. const key = vnode.key;
  6620. if (isDef(key)) {
  6621. if (seenKeys[key]) {
  6622. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6623. }
  6624. else {
  6625. seenKeys[key] = true;
  6626. }
  6627. }
  6628. }
  6629. }
  6630. function findIdxInOld(node, oldCh, start, end) {
  6631. for (let i = start; i < end; i++) {
  6632. const c = oldCh[i];
  6633. if (isDef(c) && sameVnode(node, c))
  6634. return i;
  6635. }
  6636. }
  6637. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6638. if (oldVnode === vnode) {
  6639. return;
  6640. }
  6641. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6642. // clone reused vnode
  6643. vnode = ownerArray[index] = cloneVNode(vnode);
  6644. }
  6645. const elm = (vnode.elm = oldVnode.elm);
  6646. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6647. if (isDef(vnode.asyncFactory.resolved)) {
  6648. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6649. }
  6650. else {
  6651. vnode.isAsyncPlaceholder = true;
  6652. }
  6653. return;
  6654. }
  6655. // reuse element for static trees.
  6656. // note we only do this if the vnode is cloned -
  6657. // if the new node is not cloned it means the render functions have been
  6658. // reset by the hot-reload-api and we need to do a proper re-render.
  6659. if (isTrue(vnode.isStatic) &&
  6660. isTrue(oldVnode.isStatic) &&
  6661. vnode.key === oldVnode.key &&
  6662. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6663. vnode.componentInstance = oldVnode.componentInstance;
  6664. return;
  6665. }
  6666. let i;
  6667. const data = vnode.data;
  6668. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6669. i(oldVnode, vnode);
  6670. }
  6671. const oldCh = oldVnode.children;
  6672. const ch = vnode.children;
  6673. if (isDef(data) && isPatchable(vnode)) {
  6674. for (i = 0; i < cbs.update.length; ++i)
  6675. cbs.update[i](oldVnode, vnode);
  6676. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6677. i(oldVnode, vnode);
  6678. }
  6679. if (isUndef(vnode.text)) {
  6680. if (isDef(oldCh) && isDef(ch)) {
  6681. if (oldCh !== ch)
  6682. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6683. }
  6684. else if (isDef(ch)) {
  6685. {
  6686. checkDuplicateKeys(ch);
  6687. }
  6688. if (isDef(oldVnode.text))
  6689. nodeOps.setTextContent(elm, '');
  6690. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6691. }
  6692. else if (isDef(oldCh)) {
  6693. removeVnodes(oldCh, 0, oldCh.length - 1);
  6694. }
  6695. else if (isDef(oldVnode.text)) {
  6696. nodeOps.setTextContent(elm, '');
  6697. }
  6698. }
  6699. else if (oldVnode.text !== vnode.text) {
  6700. nodeOps.setTextContent(elm, vnode.text);
  6701. }
  6702. if (isDef(data)) {
  6703. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6704. i(oldVnode, vnode);
  6705. }
  6706. }
  6707. function invokeInsertHook(vnode, queue, initial) {
  6708. // delay insert hooks for component root nodes, invoke them after the
  6709. // element is really inserted
  6710. if (isTrue(initial) && isDef(vnode.parent)) {
  6711. vnode.parent.data.pendingInsert = queue;
  6712. }
  6713. else {
  6714. for (let i = 0; i < queue.length; ++i) {
  6715. queue[i].data.hook.insert(queue[i]);
  6716. }
  6717. }
  6718. }
  6719. let hydrationBailed = false;
  6720. // list of modules that can skip create hook during hydration because they
  6721. // are already rendered on the client or has no need for initialization
  6722. // Note: style is excluded because it relies on initial clone for future
  6723. // deep updates (#7063).
  6724. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6725. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6726. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6727. let i;
  6728. const { tag, data, children } = vnode;
  6729. inVPre = inVPre || (data && data.pre);
  6730. vnode.elm = elm;
  6731. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6732. vnode.isAsyncPlaceholder = true;
  6733. return true;
  6734. }
  6735. // assert node match
  6736. {
  6737. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6738. return false;
  6739. }
  6740. }
  6741. if (isDef(data)) {
  6742. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6743. i(vnode, true /* hydrating */);
  6744. if (isDef((i = vnode.componentInstance))) {
  6745. // child component. it should have hydrated its own tree.
  6746. initComponent(vnode, insertedVnodeQueue);
  6747. return true;
  6748. }
  6749. }
  6750. if (isDef(tag)) {
  6751. if (isDef(children)) {
  6752. // empty element, allow client to pick up and populate children
  6753. if (!elm.hasChildNodes()) {
  6754. createChildren(vnode, children, insertedVnodeQueue);
  6755. }
  6756. else {
  6757. // v-html and domProps: innerHTML
  6758. if (isDef((i = data)) &&
  6759. isDef((i = i.domProps)) &&
  6760. isDef((i = i.innerHTML))) {
  6761. if (i !== elm.innerHTML) {
  6762. /* istanbul ignore if */
  6763. if (typeof console !== 'undefined' &&
  6764. !hydrationBailed) {
  6765. hydrationBailed = true;
  6766. console.warn('Parent: ', elm);
  6767. console.warn('server innerHTML: ', i);
  6768. console.warn('client innerHTML: ', elm.innerHTML);
  6769. }
  6770. return false;
  6771. }
  6772. }
  6773. else {
  6774. // iterate and compare children lists
  6775. let childrenMatch = true;
  6776. let childNode = elm.firstChild;
  6777. for (let i = 0; i < children.length; i++) {
  6778. if (!childNode ||
  6779. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6780. childrenMatch = false;
  6781. break;
  6782. }
  6783. childNode = childNode.nextSibling;
  6784. }
  6785. // if childNode is not null, it means the actual childNodes list is
  6786. // longer than the virtual children list.
  6787. if (!childrenMatch || childNode) {
  6788. /* istanbul ignore if */
  6789. if (typeof console !== 'undefined' &&
  6790. !hydrationBailed) {
  6791. hydrationBailed = true;
  6792. console.warn('Parent: ', elm);
  6793. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6794. }
  6795. return false;
  6796. }
  6797. }
  6798. }
  6799. }
  6800. if (isDef(data)) {
  6801. let fullInvoke = false;
  6802. for (const key in data) {
  6803. if (!isRenderedModule(key)) {
  6804. fullInvoke = true;
  6805. invokeCreateHooks(vnode, insertedVnodeQueue);
  6806. break;
  6807. }
  6808. }
  6809. if (!fullInvoke && data['class']) {
  6810. // ensure collecting deps for deep class bindings for future updates
  6811. traverse(data['class']);
  6812. }
  6813. }
  6814. }
  6815. else if (elm.data !== vnode.text) {
  6816. elm.data = vnode.text;
  6817. }
  6818. return true;
  6819. }
  6820. function assertNodeMatch(node, vnode, inVPre) {
  6821. if (isDef(vnode.tag)) {
  6822. return (vnode.tag.indexOf('vue-component') === 0 ||
  6823. (!isUnknownElement(vnode, inVPre) &&
  6824. vnode.tag.toLowerCase() ===
  6825. (node.tagName && node.tagName.toLowerCase())));
  6826. }
  6827. else {
  6828. return node.nodeType === (vnode.isComment ? 8 : 3);
  6829. }
  6830. }
  6831. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6832. if (isUndef(vnode)) {
  6833. if (isDef(oldVnode))
  6834. invokeDestroyHook(oldVnode);
  6835. return;
  6836. }
  6837. let isInitialPatch = false;
  6838. const insertedVnodeQueue = [];
  6839. if (isUndef(oldVnode)) {
  6840. // empty mount (likely as component), create new root element
  6841. isInitialPatch = true;
  6842. createElm(vnode, insertedVnodeQueue);
  6843. }
  6844. else {
  6845. const isRealElement = isDef(oldVnode.nodeType);
  6846. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6847. // patch existing root node
  6848. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6849. }
  6850. else {
  6851. if (isRealElement) {
  6852. // mounting to a real element
  6853. // check if this is server-rendered content and if we can perform
  6854. // a successful hydration.
  6855. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6856. oldVnode.removeAttribute(SSR_ATTR);
  6857. hydrating = true;
  6858. }
  6859. if (isTrue(hydrating)) {
  6860. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6861. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6862. return oldVnode;
  6863. }
  6864. else {
  6865. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6866. 'server-rendered content. This is likely caused by incorrect ' +
  6867. 'HTML markup, for example nesting block-level elements inside ' +
  6868. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6869. 'full client-side render.');
  6870. }
  6871. }
  6872. // either not server-rendered, or hydration failed.
  6873. // create an empty node and replace it
  6874. oldVnode = emptyNodeAt(oldVnode);
  6875. }
  6876. // replacing existing element
  6877. const oldElm = oldVnode.elm;
  6878. const parentElm = nodeOps.parentNode(oldElm);
  6879. // create new node
  6880. createElm(vnode, insertedVnodeQueue,
  6881. // extremely rare edge case: do not insert if old element is in a
  6882. // leaving transition. Only happens when combining transition +
  6883. // keep-alive + HOCs. (#4590)
  6884. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6885. // update parent placeholder node element, recursively
  6886. if (isDef(vnode.parent)) {
  6887. let ancestor = vnode.parent;
  6888. const patchable = isPatchable(vnode);
  6889. while (ancestor) {
  6890. for (let i = 0; i < cbs.destroy.length; ++i) {
  6891. cbs.destroy[i](ancestor);
  6892. }
  6893. ancestor.elm = vnode.elm;
  6894. if (patchable) {
  6895. for (let i = 0; i < cbs.create.length; ++i) {
  6896. cbs.create[i](emptyNode, ancestor);
  6897. }
  6898. // #6513
  6899. // invoke insert hooks that may have been merged by create hooks.
  6900. // e.g. for directives that uses the "inserted" hook.
  6901. const insert = ancestor.data.hook.insert;
  6902. if (insert.merged) {
  6903. // start at index 1 to avoid re-invoking component mounted hook
  6904. for (let i = 1; i < insert.fns.length; i++) {
  6905. insert.fns[i]();
  6906. }
  6907. }
  6908. }
  6909. else {
  6910. registerRef(ancestor);
  6911. }
  6912. ancestor = ancestor.parent;
  6913. }
  6914. }
  6915. // destroy old node
  6916. if (isDef(parentElm)) {
  6917. removeVnodes([oldVnode], 0, 0);
  6918. }
  6919. else if (isDef(oldVnode.tag)) {
  6920. invokeDestroyHook(oldVnode);
  6921. }
  6922. }
  6923. }
  6924. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6925. return vnode.elm;
  6926. };
  6927. }
  6928. var directives$1 = {
  6929. create: updateDirectives,
  6930. update: updateDirectives,
  6931. destroy: function unbindDirectives(vnode) {
  6932. // @ts-expect-error emptyNode is not VNodeWithData
  6933. updateDirectives(vnode, emptyNode);
  6934. }
  6935. };
  6936. function updateDirectives(oldVnode, vnode) {
  6937. if (oldVnode.data.directives || vnode.data.directives) {
  6938. _update(oldVnode, vnode);
  6939. }
  6940. }
  6941. function _update(oldVnode, vnode) {
  6942. const isCreate = oldVnode === emptyNode;
  6943. const isDestroy = vnode === emptyNode;
  6944. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  6945. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  6946. const dirsWithInsert = [];
  6947. const dirsWithPostpatch = [];
  6948. let key, oldDir, dir;
  6949. for (key in newDirs) {
  6950. oldDir = oldDirs[key];
  6951. dir = newDirs[key];
  6952. if (!oldDir) {
  6953. // new directive, bind
  6954. callHook(dir, 'bind', vnode, oldVnode);
  6955. if (dir.def && dir.def.inserted) {
  6956. dirsWithInsert.push(dir);
  6957. }
  6958. }
  6959. else {
  6960. // existing directive, update
  6961. dir.oldValue = oldDir.value;
  6962. dir.oldArg = oldDir.arg;
  6963. callHook(dir, 'update', vnode, oldVnode);
  6964. if (dir.def && dir.def.componentUpdated) {
  6965. dirsWithPostpatch.push(dir);
  6966. }
  6967. }
  6968. }
  6969. if (dirsWithInsert.length) {
  6970. const callInsert = () => {
  6971. for (let i = 0; i < dirsWithInsert.length; i++) {
  6972. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  6973. }
  6974. };
  6975. if (isCreate) {
  6976. mergeVNodeHook(vnode, 'insert', callInsert);
  6977. }
  6978. else {
  6979. callInsert();
  6980. }
  6981. }
  6982. if (dirsWithPostpatch.length) {
  6983. mergeVNodeHook(vnode, 'postpatch', () => {
  6984. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  6985. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  6986. }
  6987. });
  6988. }
  6989. if (!isCreate) {
  6990. for (key in oldDirs) {
  6991. if (!newDirs[key]) {
  6992. // no longer present, unbind
  6993. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  6994. }
  6995. }
  6996. }
  6997. }
  6998. const emptyModifiers = Object.create(null);
  6999. function normalizeDirectives(dirs, vm) {
  7000. const res = Object.create(null);
  7001. if (!dirs) {
  7002. // $flow-disable-line
  7003. return res;
  7004. }
  7005. let i, dir;
  7006. for (i = 0; i < dirs.length; i++) {
  7007. dir = dirs[i];
  7008. if (!dir.modifiers) {
  7009. // $flow-disable-line
  7010. dir.modifiers = emptyModifiers;
  7011. }
  7012. res[getRawDirName(dir)] = dir;
  7013. if (vm._setupState && vm._setupState.__sfc) {
  7014. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7015. if (typeof setupDef === 'function') {
  7016. dir.def = {
  7017. bind: setupDef,
  7018. update: setupDef,
  7019. };
  7020. }
  7021. else {
  7022. dir.def = setupDef;
  7023. }
  7024. }
  7025. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7026. }
  7027. // $flow-disable-line
  7028. return res;
  7029. }
  7030. function getRawDirName(dir) {
  7031. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7032. }
  7033. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7034. const fn = dir.def && dir.def[hook];
  7035. if (fn) {
  7036. try {
  7037. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7038. }
  7039. catch (e) {
  7040. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7041. }
  7042. }
  7043. }
  7044. var baseModules = [ref, directives$1];
  7045. function updateAttrs(oldVnode, vnode) {
  7046. const opts = vnode.componentOptions;
  7047. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7048. return;
  7049. }
  7050. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7051. return;
  7052. }
  7053. let key, cur, old;
  7054. const elm = vnode.elm;
  7055. const oldAttrs = oldVnode.data.attrs || {};
  7056. let attrs = vnode.data.attrs || {};
  7057. // clone observed objects, as the user probably wants to mutate it
  7058. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7059. attrs = vnode.data.attrs = extend({}, attrs);
  7060. }
  7061. for (key in attrs) {
  7062. cur = attrs[key];
  7063. old = oldAttrs[key];
  7064. if (old !== cur) {
  7065. setAttr(elm, key, cur, vnode.data.pre);
  7066. }
  7067. }
  7068. // #4391: in IE9, setting type can reset value for input[type=radio]
  7069. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7070. /* istanbul ignore if */
  7071. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7072. setAttr(elm, 'value', attrs.value);
  7073. }
  7074. for (key in oldAttrs) {
  7075. if (isUndef(attrs[key])) {
  7076. if (isXlink(key)) {
  7077. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7078. }
  7079. else if (!isEnumeratedAttr(key)) {
  7080. elm.removeAttribute(key);
  7081. }
  7082. }
  7083. }
  7084. }
  7085. function setAttr(el, key, value, isInPre) {
  7086. if (isInPre || el.tagName.indexOf('-') > -1) {
  7087. baseSetAttr(el, key, value);
  7088. }
  7089. else if (isBooleanAttr(key)) {
  7090. // set attribute for blank value
  7091. // e.g. <option disabled>Select one</option>
  7092. if (isFalsyAttrValue(value)) {
  7093. el.removeAttribute(key);
  7094. }
  7095. else {
  7096. // technically allowfullscreen is a boolean attribute for <iframe>,
  7097. // but Flash expects a value of "true" when used on <embed> tag
  7098. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7099. el.setAttribute(key, value);
  7100. }
  7101. }
  7102. else if (isEnumeratedAttr(key)) {
  7103. el.setAttribute(key, convertEnumeratedValue(key, value));
  7104. }
  7105. else if (isXlink(key)) {
  7106. if (isFalsyAttrValue(value)) {
  7107. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7108. }
  7109. else {
  7110. el.setAttributeNS(xlinkNS, key, value);
  7111. }
  7112. }
  7113. else {
  7114. baseSetAttr(el, key, value);
  7115. }
  7116. }
  7117. function baseSetAttr(el, key, value) {
  7118. if (isFalsyAttrValue(value)) {
  7119. el.removeAttribute(key);
  7120. }
  7121. else {
  7122. // #7138: IE10 & 11 fires input event when setting placeholder on
  7123. // <textarea>... block the first input event and remove the blocker
  7124. // immediately.
  7125. /* istanbul ignore if */
  7126. if (isIE &&
  7127. !isIE9 &&
  7128. el.tagName === 'TEXTAREA' &&
  7129. key === 'placeholder' &&
  7130. value !== '' &&
  7131. !el.__ieph) {
  7132. const blocker = e => {
  7133. e.stopImmediatePropagation();
  7134. el.removeEventListener('input', blocker);
  7135. };
  7136. el.addEventListener('input', blocker);
  7137. // $flow-disable-line
  7138. el.__ieph = true; /* IE placeholder patched */
  7139. }
  7140. el.setAttribute(key, value);
  7141. }
  7142. }
  7143. var attrs = {
  7144. create: updateAttrs,
  7145. update: updateAttrs
  7146. };
  7147. function updateClass(oldVnode, vnode) {
  7148. const el = vnode.elm;
  7149. const data = vnode.data;
  7150. const oldData = oldVnode.data;
  7151. if (isUndef(data.staticClass) &&
  7152. isUndef(data.class) &&
  7153. (isUndef(oldData) ||
  7154. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7155. return;
  7156. }
  7157. let cls = genClassForVnode(vnode);
  7158. // handle transition classes
  7159. const transitionClass = el._transitionClasses;
  7160. if (isDef(transitionClass)) {
  7161. cls = concat(cls, stringifyClass(transitionClass));
  7162. }
  7163. // set the class
  7164. if (cls !== el._prevClass) {
  7165. el.setAttribute('class', cls);
  7166. el._prevClass = cls;
  7167. }
  7168. }
  7169. var klass$1 = {
  7170. create: updateClass,
  7171. update: updateClass
  7172. };
  7173. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7174. function parseFilters(exp) {
  7175. let inSingle = false;
  7176. let inDouble = false;
  7177. let inTemplateString = false;
  7178. let inRegex = false;
  7179. let curly = 0;
  7180. let square = 0;
  7181. let paren = 0;
  7182. let lastFilterIndex = 0;
  7183. let c, prev, i, expression, filters;
  7184. for (i = 0; i < exp.length; i++) {
  7185. prev = c;
  7186. c = exp.charCodeAt(i);
  7187. if (inSingle) {
  7188. if (c === 0x27 && prev !== 0x5c)
  7189. inSingle = false;
  7190. }
  7191. else if (inDouble) {
  7192. if (c === 0x22 && prev !== 0x5c)
  7193. inDouble = false;
  7194. }
  7195. else if (inTemplateString) {
  7196. if (c === 0x60 && prev !== 0x5c)
  7197. inTemplateString = false;
  7198. }
  7199. else if (inRegex) {
  7200. if (c === 0x2f && prev !== 0x5c)
  7201. inRegex = false;
  7202. }
  7203. else if (c === 0x7c && // pipe
  7204. exp.charCodeAt(i + 1) !== 0x7c &&
  7205. exp.charCodeAt(i - 1) !== 0x7c &&
  7206. !curly &&
  7207. !square &&
  7208. !paren) {
  7209. if (expression === undefined) {
  7210. // first filter, end of expression
  7211. lastFilterIndex = i + 1;
  7212. expression = exp.slice(0, i).trim();
  7213. }
  7214. else {
  7215. pushFilter();
  7216. }
  7217. }
  7218. else {
  7219. switch (c) {
  7220. case 0x22:
  7221. inDouble = true;
  7222. break; // "
  7223. case 0x27:
  7224. inSingle = true;
  7225. break; // '
  7226. case 0x60:
  7227. inTemplateString = true;
  7228. break; // `
  7229. case 0x28:
  7230. paren++;
  7231. break; // (
  7232. case 0x29:
  7233. paren--;
  7234. break; // )
  7235. case 0x5b:
  7236. square++;
  7237. break; // [
  7238. case 0x5d:
  7239. square--;
  7240. break; // ]
  7241. case 0x7b:
  7242. curly++;
  7243. break; // {
  7244. case 0x7d:
  7245. curly--;
  7246. break; // }
  7247. }
  7248. if (c === 0x2f) {
  7249. // /
  7250. let j = i - 1;
  7251. let p;
  7252. // find first non-whitespace prev char
  7253. for (; j >= 0; j--) {
  7254. p = exp.charAt(j);
  7255. if (p !== ' ')
  7256. break;
  7257. }
  7258. if (!p || !validDivisionCharRE.test(p)) {
  7259. inRegex = true;
  7260. }
  7261. }
  7262. }
  7263. }
  7264. if (expression === undefined) {
  7265. expression = exp.slice(0, i).trim();
  7266. }
  7267. else if (lastFilterIndex !== 0) {
  7268. pushFilter();
  7269. }
  7270. function pushFilter() {
  7271. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7272. lastFilterIndex = i + 1;
  7273. }
  7274. if (filters) {
  7275. for (i = 0; i < filters.length; i++) {
  7276. expression = wrapFilter(expression, filters[i]);
  7277. }
  7278. }
  7279. return expression;
  7280. }
  7281. function wrapFilter(exp, filter) {
  7282. const i = filter.indexOf('(');
  7283. if (i < 0) {
  7284. // _f: resolveFilter
  7285. return `_f("${filter}")(${exp})`;
  7286. }
  7287. else {
  7288. const name = filter.slice(0, i);
  7289. const args = filter.slice(i + 1);
  7290. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7291. }
  7292. }
  7293. /* eslint-disable no-unused-vars */
  7294. function baseWarn(msg, range) {
  7295. console.error(`[Vue compiler]: ${msg}`);
  7296. }
  7297. /* eslint-enable no-unused-vars */
  7298. function pluckModuleFunction(modules, key) {
  7299. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7300. }
  7301. function addProp(el, name, value, range, dynamic) {
  7302. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7303. el.plain = false;
  7304. }
  7305. function addAttr(el, name, value, range, dynamic) {
  7306. const attrs = dynamic
  7307. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7308. : el.attrs || (el.attrs = []);
  7309. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7310. el.plain = false;
  7311. }
  7312. // add a raw attr (use this in preTransforms)
  7313. function addRawAttr(el, name, value, range) {
  7314. el.attrsMap[name] = value;
  7315. el.attrsList.push(rangeSetItem({ name, value }, range));
  7316. }
  7317. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7318. (el.directives || (el.directives = [])).push(rangeSetItem({
  7319. name,
  7320. rawName,
  7321. value,
  7322. arg,
  7323. isDynamicArg,
  7324. modifiers
  7325. }, range));
  7326. el.plain = false;
  7327. }
  7328. function prependModifierMarker(symbol, name, dynamic) {
  7329. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7330. }
  7331. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7332. modifiers = modifiers || emptyObject;
  7333. // warn prevent and passive modifier
  7334. /* istanbul ignore if */
  7335. if (warn && modifiers.prevent && modifiers.passive) {
  7336. warn("passive and prevent can't be used together. " +
  7337. "Passive handler can't prevent default event.", range);
  7338. }
  7339. // normalize click.right and click.middle since they don't actually fire
  7340. // this is technically browser-specific, but at least for now browsers are
  7341. // the only target envs that have right/middle clicks.
  7342. if (modifiers.right) {
  7343. if (dynamic) {
  7344. name = `(${name})==='click'?'contextmenu':(${name})`;
  7345. }
  7346. else if (name === 'click') {
  7347. name = 'contextmenu';
  7348. delete modifiers.right;
  7349. }
  7350. }
  7351. else if (modifiers.middle) {
  7352. if (dynamic) {
  7353. name = `(${name})==='click'?'mouseup':(${name})`;
  7354. }
  7355. else if (name === 'click') {
  7356. name = 'mouseup';
  7357. }
  7358. }
  7359. // check capture modifier
  7360. if (modifiers.capture) {
  7361. delete modifiers.capture;
  7362. name = prependModifierMarker('!', name, dynamic);
  7363. }
  7364. if (modifiers.once) {
  7365. delete modifiers.once;
  7366. name = prependModifierMarker('~', name, dynamic);
  7367. }
  7368. /* istanbul ignore if */
  7369. if (modifiers.passive) {
  7370. delete modifiers.passive;
  7371. name = prependModifierMarker('&', name, dynamic);
  7372. }
  7373. let events;
  7374. if (modifiers.native) {
  7375. delete modifiers.native;
  7376. events = el.nativeEvents || (el.nativeEvents = {});
  7377. }
  7378. else {
  7379. events = el.events || (el.events = {});
  7380. }
  7381. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7382. if (modifiers !== emptyObject) {
  7383. newHandler.modifiers = modifiers;
  7384. }
  7385. const handlers = events[name];
  7386. /* istanbul ignore if */
  7387. if (Array.isArray(handlers)) {
  7388. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7389. }
  7390. else if (handlers) {
  7391. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7392. }
  7393. else {
  7394. events[name] = newHandler;
  7395. }
  7396. el.plain = false;
  7397. }
  7398. function getRawBindingAttr(el, name) {
  7399. return (el.rawAttrsMap[':' + name] ||
  7400. el.rawAttrsMap['v-bind:' + name] ||
  7401. el.rawAttrsMap[name]);
  7402. }
  7403. function getBindingAttr(el, name, getStatic) {
  7404. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7405. if (dynamicValue != null) {
  7406. return parseFilters(dynamicValue);
  7407. }
  7408. else if (getStatic !== false) {
  7409. const staticValue = getAndRemoveAttr(el, name);
  7410. if (staticValue != null) {
  7411. return JSON.stringify(staticValue);
  7412. }
  7413. }
  7414. }
  7415. // note: this only removes the attr from the Array (attrsList) so that it
  7416. // doesn't get processed by processAttrs.
  7417. // By default it does NOT remove it from the map (attrsMap) because the map is
  7418. // needed during codegen.
  7419. function getAndRemoveAttr(el, name, removeFromMap) {
  7420. let val;
  7421. if ((val = el.attrsMap[name]) != null) {
  7422. const list = el.attrsList;
  7423. for (let i = 0, l = list.length; i < l; i++) {
  7424. if (list[i].name === name) {
  7425. list.splice(i, 1);
  7426. break;
  7427. }
  7428. }
  7429. }
  7430. if (removeFromMap) {
  7431. delete el.attrsMap[name];
  7432. }
  7433. return val;
  7434. }
  7435. function getAndRemoveAttrByRegex(el, name) {
  7436. const list = el.attrsList;
  7437. for (let i = 0, l = list.length; i < l; i++) {
  7438. const attr = list[i];
  7439. if (name.test(attr.name)) {
  7440. list.splice(i, 1);
  7441. return attr;
  7442. }
  7443. }
  7444. }
  7445. function rangeSetItem(item, range) {
  7446. if (range) {
  7447. if (range.start != null) {
  7448. item.start = range.start;
  7449. }
  7450. if (range.end != null) {
  7451. item.end = range.end;
  7452. }
  7453. }
  7454. return item;
  7455. }
  7456. /**
  7457. * Cross-platform code generation for component v-model
  7458. */
  7459. function genComponentModel(el, value, modifiers) {
  7460. const { number, trim } = modifiers || {};
  7461. const baseValueExpression = '$$v';
  7462. let valueExpression = baseValueExpression;
  7463. if (trim) {
  7464. valueExpression =
  7465. `(typeof ${baseValueExpression} === 'string'` +
  7466. `? ${baseValueExpression}.trim()` +
  7467. `: ${baseValueExpression})`;
  7468. }
  7469. if (number) {
  7470. valueExpression = `_n(${valueExpression})`;
  7471. }
  7472. const assignment = genAssignmentCode(value, valueExpression);
  7473. el.model = {
  7474. value: `(${value})`,
  7475. expression: JSON.stringify(value),
  7476. callback: `function (${baseValueExpression}) {${assignment}}`
  7477. };
  7478. }
  7479. /**
  7480. * Cross-platform codegen helper for generating v-model value assignment code.
  7481. */
  7482. function genAssignmentCode(value, assignment) {
  7483. const res = parseModel(value);
  7484. if (res.key === null) {
  7485. return `${value}=${assignment}`;
  7486. }
  7487. else {
  7488. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7489. }
  7490. }
  7491. /**
  7492. * Parse a v-model expression into a base path and a final key segment.
  7493. * Handles both dot-path and possible square brackets.
  7494. *
  7495. * Possible cases:
  7496. *
  7497. * - test
  7498. * - test[key]
  7499. * - test[test1[key]]
  7500. * - test["a"][key]
  7501. * - xxx.test[a[a].test1[key]]
  7502. * - test.xxx.a["asa"][test1[key]]
  7503. *
  7504. */
  7505. let len, str, chr, index, expressionPos, expressionEndPos;
  7506. function parseModel(val) {
  7507. // Fix https://github.com/vuejs/vue/pull/7730
  7508. // allow v-model="obj.val " (trailing whitespace)
  7509. val = val.trim();
  7510. len = val.length;
  7511. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7512. index = val.lastIndexOf('.');
  7513. if (index > -1) {
  7514. return {
  7515. exp: val.slice(0, index),
  7516. key: '"' + val.slice(index + 1) + '"'
  7517. };
  7518. }
  7519. else {
  7520. return {
  7521. exp: val,
  7522. key: null
  7523. };
  7524. }
  7525. }
  7526. str = val;
  7527. index = expressionPos = expressionEndPos = 0;
  7528. while (!eof()) {
  7529. chr = next();
  7530. /* istanbul ignore if */
  7531. if (isStringStart(chr)) {
  7532. parseString(chr);
  7533. }
  7534. else if (chr === 0x5b) {
  7535. parseBracket(chr);
  7536. }
  7537. }
  7538. return {
  7539. exp: val.slice(0, expressionPos),
  7540. key: val.slice(expressionPos + 1, expressionEndPos)
  7541. };
  7542. }
  7543. function next() {
  7544. return str.charCodeAt(++index);
  7545. }
  7546. function eof() {
  7547. return index >= len;
  7548. }
  7549. function isStringStart(chr) {
  7550. return chr === 0x22 || chr === 0x27;
  7551. }
  7552. function parseBracket(chr) {
  7553. let inBracket = 1;
  7554. expressionPos = index;
  7555. while (!eof()) {
  7556. chr = next();
  7557. if (isStringStart(chr)) {
  7558. parseString(chr);
  7559. continue;
  7560. }
  7561. if (chr === 0x5b)
  7562. inBracket++;
  7563. if (chr === 0x5d)
  7564. inBracket--;
  7565. if (inBracket === 0) {
  7566. expressionEndPos = index;
  7567. break;
  7568. }
  7569. }
  7570. }
  7571. function parseString(chr) {
  7572. const stringQuote = chr;
  7573. while (!eof()) {
  7574. chr = next();
  7575. if (chr === stringQuote) {
  7576. break;
  7577. }
  7578. }
  7579. }
  7580. let warn$1;
  7581. // in some cases, the event used has to be determined at runtime
  7582. // so we used some reserved tokens during compile.
  7583. const RANGE_TOKEN = '__r';
  7584. const CHECKBOX_RADIO_TOKEN = '__c';
  7585. function model$1(el, dir, _warn) {
  7586. warn$1 = _warn;
  7587. const value = dir.value;
  7588. const modifiers = dir.modifiers;
  7589. const tag = el.tag;
  7590. const type = el.attrsMap.type;
  7591. {
  7592. // inputs with type="file" are read only and setting the input's
  7593. // value will throw an error.
  7594. if (tag === 'input' && type === 'file') {
  7595. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7596. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7597. }
  7598. }
  7599. if (el.component) {
  7600. genComponentModel(el, value, modifiers);
  7601. // component v-model doesn't need extra runtime
  7602. return false;
  7603. }
  7604. else if (tag === 'select') {
  7605. genSelect(el, value, modifiers);
  7606. }
  7607. else if (tag === 'input' && type === 'checkbox') {
  7608. genCheckboxModel(el, value, modifiers);
  7609. }
  7610. else if (tag === 'input' && type === 'radio') {
  7611. genRadioModel(el, value, modifiers);
  7612. }
  7613. else if (tag === 'input' || tag === 'textarea') {
  7614. genDefaultModel(el, value, modifiers);
  7615. }
  7616. else if (!config.isReservedTag(tag)) {
  7617. genComponentModel(el, value, modifiers);
  7618. // component v-model doesn't need extra runtime
  7619. return false;
  7620. }
  7621. else {
  7622. warn$1(`<${el.tag} v-model="${value}">: ` +
  7623. `v-model is not supported on this element type. ` +
  7624. "If you are working with contenteditable, it's recommended to " +
  7625. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7626. }
  7627. // ensure runtime directive metadata
  7628. return true;
  7629. }
  7630. function genCheckboxModel(el, value, modifiers) {
  7631. const number = modifiers && modifiers.number;
  7632. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7633. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7634. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7635. addProp(el, 'checked', `Array.isArray(${value})` +
  7636. `?_i(${value},${valueBinding})>-1` +
  7637. (trueValueBinding === 'true'
  7638. ? `:(${value})`
  7639. : `:_q(${value},${trueValueBinding})`));
  7640. addHandler(el, 'change', `var $$a=${value},` +
  7641. '$$el=$event.target,' +
  7642. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7643. 'if(Array.isArray($$a)){' +
  7644. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7645. '$$i=_i($$a,$$v);' +
  7646. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7647. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7648. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7649. }
  7650. function genRadioModel(el, value, modifiers) {
  7651. const number = modifiers && modifiers.number;
  7652. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7653. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7654. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7655. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7656. }
  7657. function genSelect(el, value, modifiers) {
  7658. const number = modifiers && modifiers.number;
  7659. const selectedVal = `Array.prototype.filter` +
  7660. `.call($event.target.options,function(o){return o.selected})` +
  7661. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7662. `return ${number ? '_n(val)' : 'val'}})`;
  7663. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7664. let code = `var $$selectedVal = ${selectedVal};`;
  7665. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7666. addHandler(el, 'change', code, null, true);
  7667. }
  7668. function genDefaultModel(el, value, modifiers) {
  7669. const type = el.attrsMap.type;
  7670. // warn if v-bind:value conflicts with v-model
  7671. // except for inputs with v-bind:type
  7672. {
  7673. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7674. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7675. if (value && !typeBinding) {
  7676. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7677. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7678. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7679. }
  7680. }
  7681. const { lazy, number, trim } = modifiers || {};
  7682. const needCompositionGuard = !lazy && type !== 'range';
  7683. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7684. let valueExpression = '$event.target.value';
  7685. if (trim) {
  7686. valueExpression = `$event.target.value.trim()`;
  7687. }
  7688. if (number) {
  7689. valueExpression = `_n(${valueExpression})`;
  7690. }
  7691. let code = genAssignmentCode(value, valueExpression);
  7692. if (needCompositionGuard) {
  7693. code = `if($event.target.composing)return;${code}`;
  7694. }
  7695. addProp(el, 'value', `(${value})`);
  7696. addHandler(el, event, code, null, true);
  7697. if (trim || number) {
  7698. addHandler(el, 'blur', '$forceUpdate()');
  7699. }
  7700. }
  7701. // normalize v-model event tokens that can only be determined at runtime.
  7702. // it's important to place the event as the first in the array because
  7703. // the whole point is ensuring the v-model callback gets called before
  7704. // user-attached handlers.
  7705. function normalizeEvents(on) {
  7706. /* istanbul ignore if */
  7707. if (isDef(on[RANGE_TOKEN])) {
  7708. // IE input[type=range] only supports `change` event
  7709. const event = isIE ? 'change' : 'input';
  7710. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7711. delete on[RANGE_TOKEN];
  7712. }
  7713. // This was originally intended to fix #4521 but no longer necessary
  7714. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7715. /* istanbul ignore if */
  7716. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7717. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7718. delete on[CHECKBOX_RADIO_TOKEN];
  7719. }
  7720. }
  7721. let target;
  7722. function createOnceHandler(event, handler, capture) {
  7723. const _target = target; // save current target element in closure
  7724. return function onceHandler() {
  7725. const res = handler.apply(null, arguments);
  7726. if (res !== null) {
  7727. remove(event, onceHandler, capture, _target);
  7728. }
  7729. };
  7730. }
  7731. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7732. // implementation and does not fire microtasks in between event propagation, so
  7733. // safe to exclude.
  7734. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7735. function add(name, handler, capture, passive) {
  7736. // async edge case #6566: inner click event triggers patch, event handler
  7737. // attached to outer element during patch, and triggered again. This
  7738. // happens because browsers fire microtask ticks between event propagation.
  7739. // the solution is simple: we save the timestamp when a handler is attached,
  7740. // and the handler would only fire if the event passed to it was fired
  7741. // AFTER it was attached.
  7742. if (useMicrotaskFix) {
  7743. const attachedTimestamp = currentFlushTimestamp;
  7744. const original = handler;
  7745. //@ts-expect-error
  7746. handler = original._wrapper = function (e) {
  7747. if (
  7748. // no bubbling, should always fire.
  7749. // this is just a safety net in case event.timeStamp is unreliable in
  7750. // certain weird environments...
  7751. e.target === e.currentTarget ||
  7752. // event is fired after handler attachment
  7753. e.timeStamp >= attachedTimestamp ||
  7754. // bail for environments that have buggy event.timeStamp implementations
  7755. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7756. // #9681 QtWebEngine event.timeStamp is negative value
  7757. e.timeStamp <= 0 ||
  7758. // #9448 bail if event is fired in another document in a multi-page
  7759. // electron/nw.js app, since event.timeStamp will be using a different
  7760. // starting reference
  7761. e.target.ownerDocument !== document) {
  7762. return original.apply(this, arguments);
  7763. }
  7764. };
  7765. }
  7766. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7767. }
  7768. function remove(name, handler, capture, _target) {
  7769. (_target || target).removeEventListener(name,
  7770. //@ts-expect-error
  7771. handler._wrapper || handler, capture);
  7772. }
  7773. function updateDOMListeners(oldVnode, vnode) {
  7774. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7775. return;
  7776. }
  7777. const on = vnode.data.on || {};
  7778. const oldOn = oldVnode.data.on || {};
  7779. // vnode is empty when removing all listeners,
  7780. // and use old vnode dom element
  7781. target = vnode.elm || oldVnode.elm;
  7782. normalizeEvents(on);
  7783. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7784. target = undefined;
  7785. }
  7786. var events = {
  7787. create: updateDOMListeners,
  7788. update: updateDOMListeners,
  7789. // @ts-expect-error emptyNode has actually data
  7790. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7791. };
  7792. let svgContainer;
  7793. function updateDOMProps(oldVnode, vnode) {
  7794. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7795. return;
  7796. }
  7797. let key, cur;
  7798. const elm = vnode.elm;
  7799. const oldProps = oldVnode.data.domProps || {};
  7800. let props = vnode.data.domProps || {};
  7801. // clone observed objects, as the user probably wants to mutate it
  7802. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7803. props = vnode.data.domProps = extend({}, props);
  7804. }
  7805. for (key in oldProps) {
  7806. if (!(key in props)) {
  7807. elm[key] = '';
  7808. }
  7809. }
  7810. for (key in props) {
  7811. cur = props[key];
  7812. // ignore children if the node has textContent or innerHTML,
  7813. // as these will throw away existing DOM nodes and cause removal errors
  7814. // on subsequent patches (#3360)
  7815. if (key === 'textContent' || key === 'innerHTML') {
  7816. if (vnode.children)
  7817. vnode.children.length = 0;
  7818. if (cur === oldProps[key])
  7819. continue;
  7820. // #6601 work around Chrome version <= 55 bug where single textNode
  7821. // replaced by innerHTML/textContent retains its parentNode property
  7822. if (elm.childNodes.length === 1) {
  7823. elm.removeChild(elm.childNodes[0]);
  7824. }
  7825. }
  7826. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7827. // store value as _value as well since
  7828. // non-string values will be stringified
  7829. elm._value = cur;
  7830. // avoid resetting cursor position when value is the same
  7831. const strCur = isUndef(cur) ? '' : String(cur);
  7832. if (shouldUpdateValue(elm, strCur)) {
  7833. elm.value = strCur;
  7834. }
  7835. }
  7836. else if (key === 'innerHTML' &&
  7837. isSVG(elm.tagName) &&
  7838. isUndef(elm.innerHTML)) {
  7839. // IE doesn't support innerHTML for SVG elements
  7840. svgContainer = svgContainer || document.createElement('div');
  7841. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7842. const svg = svgContainer.firstChild;
  7843. while (elm.firstChild) {
  7844. elm.removeChild(elm.firstChild);
  7845. }
  7846. while (svg.firstChild) {
  7847. elm.appendChild(svg.firstChild);
  7848. }
  7849. }
  7850. else if (
  7851. // skip the update if old and new VDOM state is the same.
  7852. // `value` is handled separately because the DOM value may be temporarily
  7853. // out of sync with VDOM state due to focus, composition and modifiers.
  7854. // This #4521 by skipping the unnecessary `checked` update.
  7855. cur !== oldProps[key]) {
  7856. // some property updates can throw
  7857. // e.g. `value` on <progress> w/ non-finite value
  7858. try {
  7859. elm[key] = cur;
  7860. }
  7861. catch (e) { }
  7862. }
  7863. }
  7864. }
  7865. function shouldUpdateValue(elm, checkVal) {
  7866. return (
  7867. //@ts-expect-error
  7868. !elm.composing &&
  7869. (elm.tagName === 'OPTION' ||
  7870. isNotInFocusAndDirty(elm, checkVal) ||
  7871. isDirtyWithModifiers(elm, checkVal)));
  7872. }
  7873. function isNotInFocusAndDirty(elm, checkVal) {
  7874. // return true when textbox (.number and .trim) loses focus and its value is
  7875. // not equal to the updated value
  7876. let notInFocus = true;
  7877. // #6157
  7878. // work around IE bug when accessing document.activeElement in an iframe
  7879. try {
  7880. notInFocus = document.activeElement !== elm;
  7881. }
  7882. catch (e) { }
  7883. return notInFocus && elm.value !== checkVal;
  7884. }
  7885. function isDirtyWithModifiers(elm, newVal) {
  7886. const value = elm.value;
  7887. const modifiers = elm._vModifiers; // injected by v-model runtime
  7888. if (isDef(modifiers)) {
  7889. if (modifiers.number) {
  7890. return toNumber(value) !== toNumber(newVal);
  7891. }
  7892. if (modifiers.trim) {
  7893. return value.trim() !== newVal.trim();
  7894. }
  7895. }
  7896. return value !== newVal;
  7897. }
  7898. var domProps = {
  7899. create: updateDOMProps,
  7900. update: updateDOMProps
  7901. };
  7902. const parseStyleText = cached(function (cssText) {
  7903. const res = {};
  7904. const listDelimiter = /;(?![^(]*\))/g;
  7905. const propertyDelimiter = /:(.+)/;
  7906. cssText.split(listDelimiter).forEach(function (item) {
  7907. if (item) {
  7908. const tmp = item.split(propertyDelimiter);
  7909. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7910. }
  7911. });
  7912. return res;
  7913. });
  7914. // merge static and dynamic style data on the same vnode
  7915. function normalizeStyleData(data) {
  7916. const style = normalizeStyleBinding(data.style);
  7917. // static style is pre-processed into an object during compilation
  7918. // and is always a fresh object, so it's safe to merge into it
  7919. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7920. }
  7921. // normalize possible array / string values into Object
  7922. function normalizeStyleBinding(bindingStyle) {
  7923. if (Array.isArray(bindingStyle)) {
  7924. return toObject(bindingStyle);
  7925. }
  7926. if (typeof bindingStyle === 'string') {
  7927. return parseStyleText(bindingStyle);
  7928. }
  7929. return bindingStyle;
  7930. }
  7931. /**
  7932. * parent component style should be after child's
  7933. * so that parent component's style could override it
  7934. */
  7935. function getStyle(vnode, checkChild) {
  7936. const res = {};
  7937. let styleData;
  7938. if (checkChild) {
  7939. let childNode = vnode;
  7940. while (childNode.componentInstance) {
  7941. childNode = childNode.componentInstance._vnode;
  7942. if (childNode &&
  7943. childNode.data &&
  7944. (styleData = normalizeStyleData(childNode.data))) {
  7945. extend(res, styleData);
  7946. }
  7947. }
  7948. }
  7949. if ((styleData = normalizeStyleData(vnode.data))) {
  7950. extend(res, styleData);
  7951. }
  7952. let parentNode = vnode;
  7953. // @ts-expect-error parentNode.parent not VNodeWithData
  7954. while ((parentNode = parentNode.parent)) {
  7955. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7956. extend(res, styleData);
  7957. }
  7958. }
  7959. return res;
  7960. }
  7961. const cssVarRE = /^--/;
  7962. const importantRE = /\s*!important$/;
  7963. const setProp = (el, name, val) => {
  7964. /* istanbul ignore if */
  7965. if (cssVarRE.test(name)) {
  7966. el.style.setProperty(name, val);
  7967. }
  7968. else if (importantRE.test(val)) {
  7969. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7970. }
  7971. else {
  7972. const normalizedName = normalize(name);
  7973. if (Array.isArray(val)) {
  7974. // Support values array created by autoprefixer, e.g.
  7975. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7976. // Set them one by one, and the browser will only set those it can recognize
  7977. for (let i = 0, len = val.length; i < len; i++) {
  7978. el.style[normalizedName] = val[i];
  7979. }
  7980. }
  7981. else {
  7982. el.style[normalizedName] = val;
  7983. }
  7984. }
  7985. };
  7986. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7987. let emptyStyle;
  7988. const normalize = cached(function (prop) {
  7989. emptyStyle = emptyStyle || document.createElement('div').style;
  7990. prop = camelize(prop);
  7991. if (prop !== 'filter' && prop in emptyStyle) {
  7992. return prop;
  7993. }
  7994. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7995. for (let i = 0; i < vendorNames.length; i++) {
  7996. const name = vendorNames[i] + capName;
  7997. if (name in emptyStyle) {
  7998. return name;
  7999. }
  8000. }
  8001. });
  8002. function updateStyle(oldVnode, vnode) {
  8003. const data = vnode.data;
  8004. const oldData = oldVnode.data;
  8005. if (isUndef(data.staticStyle) &&
  8006. isUndef(data.style) &&
  8007. isUndef(oldData.staticStyle) &&
  8008. isUndef(oldData.style)) {
  8009. return;
  8010. }
  8011. let cur, name;
  8012. const el = vnode.elm;
  8013. const oldStaticStyle = oldData.staticStyle;
  8014. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8015. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8016. const oldStyle = oldStaticStyle || oldStyleBinding;
  8017. const style = normalizeStyleBinding(vnode.data.style) || {};
  8018. // store normalized style under a different key for next diff
  8019. // make sure to clone it if it's reactive, since the user likely wants
  8020. // to mutate it.
  8021. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8022. const newStyle = getStyle(vnode, true);
  8023. for (name in oldStyle) {
  8024. if (isUndef(newStyle[name])) {
  8025. setProp(el, name, '');
  8026. }
  8027. }
  8028. for (name in newStyle) {
  8029. cur = newStyle[name];
  8030. if (cur !== oldStyle[name]) {
  8031. // ie9 setting to null has no effect, must use empty string
  8032. setProp(el, name, cur == null ? '' : cur);
  8033. }
  8034. }
  8035. }
  8036. var style$1 = {
  8037. create: updateStyle,
  8038. update: updateStyle
  8039. };
  8040. const whitespaceRE$1 = /\s+/;
  8041. /**
  8042. * Add class with compatibility for SVG since classList is not supported on
  8043. * SVG elements in IE
  8044. */
  8045. function addClass(el, cls) {
  8046. /* istanbul ignore if */
  8047. if (!cls || !(cls = cls.trim())) {
  8048. return;
  8049. }
  8050. /* istanbul ignore else */
  8051. if (el.classList) {
  8052. if (cls.indexOf(' ') > -1) {
  8053. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8054. }
  8055. else {
  8056. el.classList.add(cls);
  8057. }
  8058. }
  8059. else {
  8060. const cur = ` ${el.getAttribute('class') || ''} `;
  8061. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8062. el.setAttribute('class', (cur + cls).trim());
  8063. }
  8064. }
  8065. }
  8066. /**
  8067. * Remove class with compatibility for SVG since classList is not supported on
  8068. * SVG elements in IE
  8069. */
  8070. function removeClass(el, cls) {
  8071. /* istanbul ignore if */
  8072. if (!cls || !(cls = cls.trim())) {
  8073. return;
  8074. }
  8075. /* istanbul ignore else */
  8076. if (el.classList) {
  8077. if (cls.indexOf(' ') > -1) {
  8078. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8079. }
  8080. else {
  8081. el.classList.remove(cls);
  8082. }
  8083. if (!el.classList.length) {
  8084. el.removeAttribute('class');
  8085. }
  8086. }
  8087. else {
  8088. let cur = ` ${el.getAttribute('class') || ''} `;
  8089. const tar = ' ' + cls + ' ';
  8090. while (cur.indexOf(tar) >= 0) {
  8091. cur = cur.replace(tar, ' ');
  8092. }
  8093. cur = cur.trim();
  8094. if (cur) {
  8095. el.setAttribute('class', cur);
  8096. }
  8097. else {
  8098. el.removeAttribute('class');
  8099. }
  8100. }
  8101. }
  8102. function resolveTransition(def) {
  8103. if (!def) {
  8104. return;
  8105. }
  8106. /* istanbul ignore else */
  8107. if (typeof def === 'object') {
  8108. const res = {};
  8109. if (def.css !== false) {
  8110. extend(res, autoCssTransition(def.name || 'v'));
  8111. }
  8112. extend(res, def);
  8113. return res;
  8114. }
  8115. else if (typeof def === 'string') {
  8116. return autoCssTransition(def);
  8117. }
  8118. }
  8119. const autoCssTransition = cached(name => {
  8120. return {
  8121. enterClass: `${name}-enter`,
  8122. enterToClass: `${name}-enter-to`,
  8123. enterActiveClass: `${name}-enter-active`,
  8124. leaveClass: `${name}-leave`,
  8125. leaveToClass: `${name}-leave-to`,
  8126. leaveActiveClass: `${name}-leave-active`
  8127. };
  8128. });
  8129. const hasTransition = inBrowser && !isIE9;
  8130. const TRANSITION = 'transition';
  8131. const ANIMATION = 'animation';
  8132. // Transition property/event sniffing
  8133. let transitionProp = 'transition';
  8134. let transitionEndEvent = 'transitionend';
  8135. let animationProp = 'animation';
  8136. let animationEndEvent = 'animationend';
  8137. if (hasTransition) {
  8138. /* istanbul ignore if */
  8139. if (window.ontransitionend === undefined &&
  8140. window.onwebkittransitionend !== undefined) {
  8141. transitionProp = 'WebkitTransition';
  8142. transitionEndEvent = 'webkitTransitionEnd';
  8143. }
  8144. if (window.onanimationend === undefined &&
  8145. window.onwebkitanimationend !== undefined) {
  8146. animationProp = 'WebkitAnimation';
  8147. animationEndEvent = 'webkitAnimationEnd';
  8148. }
  8149. }
  8150. // binding to window is necessary to make hot reload work in IE in strict mode
  8151. const raf = inBrowser
  8152. ? window.requestAnimationFrame
  8153. ? window.requestAnimationFrame.bind(window)
  8154. : setTimeout
  8155. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8156. function nextFrame(fn) {
  8157. raf(() => {
  8158. // @ts-expect-error
  8159. raf(fn);
  8160. });
  8161. }
  8162. function addTransitionClass(el, cls) {
  8163. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8164. if (transitionClasses.indexOf(cls) < 0) {
  8165. transitionClasses.push(cls);
  8166. addClass(el, cls);
  8167. }
  8168. }
  8169. function removeTransitionClass(el, cls) {
  8170. if (el._transitionClasses) {
  8171. remove$2(el._transitionClasses, cls);
  8172. }
  8173. removeClass(el, cls);
  8174. }
  8175. function whenTransitionEnds(el, expectedType, cb) {
  8176. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8177. if (!type)
  8178. return cb();
  8179. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8180. let ended = 0;
  8181. const end = () => {
  8182. el.removeEventListener(event, onEnd);
  8183. cb();
  8184. };
  8185. const onEnd = e => {
  8186. if (e.target === el) {
  8187. if (++ended >= propCount) {
  8188. end();
  8189. }
  8190. }
  8191. };
  8192. setTimeout(() => {
  8193. if (ended < propCount) {
  8194. end();
  8195. }
  8196. }, timeout + 1);
  8197. el.addEventListener(event, onEnd);
  8198. }
  8199. const transformRE = /\b(transform|all)(,|$)/;
  8200. function getTransitionInfo(el, expectedType) {
  8201. const styles = window.getComputedStyle(el);
  8202. // JSDOM may return undefined for transition properties
  8203. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8204. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8205. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8206. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8207. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8208. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8209. let type;
  8210. let timeout = 0;
  8211. let propCount = 0;
  8212. /* istanbul ignore if */
  8213. if (expectedType === TRANSITION) {
  8214. if (transitionTimeout > 0) {
  8215. type = TRANSITION;
  8216. timeout = transitionTimeout;
  8217. propCount = transitionDurations.length;
  8218. }
  8219. }
  8220. else if (expectedType === ANIMATION) {
  8221. if (animationTimeout > 0) {
  8222. type = ANIMATION;
  8223. timeout = animationTimeout;
  8224. propCount = animationDurations.length;
  8225. }
  8226. }
  8227. else {
  8228. timeout = Math.max(transitionTimeout, animationTimeout);
  8229. type =
  8230. timeout > 0
  8231. ? transitionTimeout > animationTimeout
  8232. ? TRANSITION
  8233. : ANIMATION
  8234. : null;
  8235. propCount = type
  8236. ? type === TRANSITION
  8237. ? transitionDurations.length
  8238. : animationDurations.length
  8239. : 0;
  8240. }
  8241. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8242. return {
  8243. type,
  8244. timeout,
  8245. propCount,
  8246. hasTransform
  8247. };
  8248. }
  8249. function getTimeout(delays, durations) {
  8250. /* istanbul ignore next */
  8251. while (delays.length < durations.length) {
  8252. delays = delays.concat(delays);
  8253. }
  8254. return Math.max.apply(null, durations.map((d, i) => {
  8255. return toMs(d) + toMs(delays[i]);
  8256. }));
  8257. }
  8258. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8259. // in a locale-dependent way, using a comma instead of a dot.
  8260. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8261. // as a floor function) causing unexpected behaviors
  8262. function toMs(s) {
  8263. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8264. }
  8265. function enter(vnode, toggleDisplay) {
  8266. const el = vnode.elm;
  8267. // call leave callback now
  8268. if (isDef(el._leaveCb)) {
  8269. el._leaveCb.cancelled = true;
  8270. el._leaveCb();
  8271. }
  8272. const data = resolveTransition(vnode.data.transition);
  8273. if (isUndef(data)) {
  8274. return;
  8275. }
  8276. /* istanbul ignore if */
  8277. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8278. return;
  8279. }
  8280. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8281. // activeInstance will always be the <transition> component managing this
  8282. // transition. One edge case to check is when the <transition> is placed
  8283. // as the root node of a child component. In that case we need to check
  8284. // <transition>'s parent for appear check.
  8285. let context = activeInstance;
  8286. let transitionNode = activeInstance.$vnode;
  8287. while (transitionNode && transitionNode.parent) {
  8288. context = transitionNode.context;
  8289. transitionNode = transitionNode.parent;
  8290. }
  8291. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8292. if (isAppear && !appear && appear !== '') {
  8293. return;
  8294. }
  8295. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8296. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8297. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8298. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8299. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8300. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8301. const enterCancelledHook = isAppear
  8302. ? appearCancelled || enterCancelled
  8303. : enterCancelled;
  8304. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8305. if (explicitEnterDuration != null) {
  8306. checkDuration(explicitEnterDuration, 'enter', vnode);
  8307. }
  8308. const expectsCSS = css !== false && !isIE9;
  8309. const userWantsControl = getHookArgumentsLength(enterHook);
  8310. const cb = (el._enterCb = once(() => {
  8311. if (expectsCSS) {
  8312. removeTransitionClass(el, toClass);
  8313. removeTransitionClass(el, activeClass);
  8314. }
  8315. // @ts-expect-error
  8316. if (cb.cancelled) {
  8317. if (expectsCSS) {
  8318. removeTransitionClass(el, startClass);
  8319. }
  8320. enterCancelledHook && enterCancelledHook(el);
  8321. }
  8322. else {
  8323. afterEnterHook && afterEnterHook(el);
  8324. }
  8325. el._enterCb = null;
  8326. }));
  8327. if (!vnode.data.show) {
  8328. // remove pending leave element on enter by injecting an insert hook
  8329. mergeVNodeHook(vnode, 'insert', () => {
  8330. const parent = el.parentNode;
  8331. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8332. if (pendingNode &&
  8333. pendingNode.tag === vnode.tag &&
  8334. pendingNode.elm._leaveCb) {
  8335. pendingNode.elm._leaveCb();
  8336. }
  8337. enterHook && enterHook(el, cb);
  8338. });
  8339. }
  8340. // start enter transition
  8341. beforeEnterHook && beforeEnterHook(el);
  8342. if (expectsCSS) {
  8343. addTransitionClass(el, startClass);
  8344. addTransitionClass(el, activeClass);
  8345. nextFrame(() => {
  8346. removeTransitionClass(el, startClass);
  8347. // @ts-expect-error
  8348. if (!cb.cancelled) {
  8349. addTransitionClass(el, toClass);
  8350. if (!userWantsControl) {
  8351. if (isValidDuration(explicitEnterDuration)) {
  8352. setTimeout(cb, explicitEnterDuration);
  8353. }
  8354. else {
  8355. whenTransitionEnds(el, type, cb);
  8356. }
  8357. }
  8358. }
  8359. });
  8360. }
  8361. if (vnode.data.show) {
  8362. toggleDisplay && toggleDisplay();
  8363. enterHook && enterHook(el, cb);
  8364. }
  8365. if (!expectsCSS && !userWantsControl) {
  8366. cb();
  8367. }
  8368. }
  8369. function leave(vnode, rm) {
  8370. const el = vnode.elm;
  8371. // call enter callback now
  8372. if (isDef(el._enterCb)) {
  8373. el._enterCb.cancelled = true;
  8374. el._enterCb();
  8375. }
  8376. const data = resolveTransition(vnode.data.transition);
  8377. if (isUndef(data) || el.nodeType !== 1) {
  8378. return rm();
  8379. }
  8380. /* istanbul ignore if */
  8381. if (isDef(el._leaveCb)) {
  8382. return;
  8383. }
  8384. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8385. const expectsCSS = css !== false && !isIE9;
  8386. const userWantsControl = getHookArgumentsLength(leave);
  8387. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8388. if (isDef(explicitLeaveDuration)) {
  8389. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8390. }
  8391. const cb = (el._leaveCb = once(() => {
  8392. if (el.parentNode && el.parentNode._pending) {
  8393. el.parentNode._pending[vnode.key] = null;
  8394. }
  8395. if (expectsCSS) {
  8396. removeTransitionClass(el, leaveToClass);
  8397. removeTransitionClass(el, leaveActiveClass);
  8398. }
  8399. // @ts-expect-error
  8400. if (cb.cancelled) {
  8401. if (expectsCSS) {
  8402. removeTransitionClass(el, leaveClass);
  8403. }
  8404. leaveCancelled && leaveCancelled(el);
  8405. }
  8406. else {
  8407. rm();
  8408. afterLeave && afterLeave(el);
  8409. }
  8410. el._leaveCb = null;
  8411. }));
  8412. if (delayLeave) {
  8413. delayLeave(performLeave);
  8414. }
  8415. else {
  8416. performLeave();
  8417. }
  8418. function performLeave() {
  8419. // the delayed leave may have already been cancelled
  8420. // @ts-expect-error
  8421. if (cb.cancelled) {
  8422. return;
  8423. }
  8424. // record leaving element
  8425. if (!vnode.data.show && el.parentNode) {
  8426. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8427. vnode;
  8428. }
  8429. beforeLeave && beforeLeave(el);
  8430. if (expectsCSS) {
  8431. addTransitionClass(el, leaveClass);
  8432. addTransitionClass(el, leaveActiveClass);
  8433. nextFrame(() => {
  8434. removeTransitionClass(el, leaveClass);
  8435. // @ts-expect-error
  8436. if (!cb.cancelled) {
  8437. addTransitionClass(el, leaveToClass);
  8438. if (!userWantsControl) {
  8439. if (isValidDuration(explicitLeaveDuration)) {
  8440. setTimeout(cb, explicitLeaveDuration);
  8441. }
  8442. else {
  8443. whenTransitionEnds(el, type, cb);
  8444. }
  8445. }
  8446. }
  8447. });
  8448. }
  8449. leave && leave(el, cb);
  8450. if (!expectsCSS && !userWantsControl) {
  8451. cb();
  8452. }
  8453. }
  8454. }
  8455. // only used in dev mode
  8456. function checkDuration(val, name, vnode) {
  8457. if (typeof val !== 'number') {
  8458. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8459. `got ${JSON.stringify(val)}.`, vnode.context);
  8460. }
  8461. else if (isNaN(val)) {
  8462. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8463. 'the duration expression might be incorrect.', vnode.context);
  8464. }
  8465. }
  8466. function isValidDuration(val) {
  8467. return typeof val === 'number' && !isNaN(val);
  8468. }
  8469. /**
  8470. * Normalize a transition hook's argument length. The hook may be:
  8471. * - a merged hook (invoker) with the original in .fns
  8472. * - a wrapped component method (check ._length)
  8473. * - a plain function (.length)
  8474. */
  8475. function getHookArgumentsLength(fn) {
  8476. if (isUndef(fn)) {
  8477. return false;
  8478. }
  8479. // @ts-expect-error
  8480. const invokerFns = fn.fns;
  8481. if (isDef(invokerFns)) {
  8482. // invoker
  8483. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8484. }
  8485. else {
  8486. // @ts-expect-error
  8487. return (fn._length || fn.length) > 1;
  8488. }
  8489. }
  8490. function _enter(_, vnode) {
  8491. if (vnode.data.show !== true) {
  8492. enter(vnode);
  8493. }
  8494. }
  8495. var transition = inBrowser
  8496. ? {
  8497. create: _enter,
  8498. activate: _enter,
  8499. remove(vnode, rm) {
  8500. /* istanbul ignore else */
  8501. if (vnode.data.show !== true) {
  8502. // @ts-expect-error
  8503. leave(vnode, rm);
  8504. }
  8505. else {
  8506. rm();
  8507. }
  8508. }
  8509. }
  8510. : {};
  8511. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8512. // the directive module should be applied last, after all
  8513. // built-in modules have been applied.
  8514. const modules$1 = platformModules.concat(baseModules);
  8515. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8516. /**
  8517. * Not type checking this file because flow doesn't like attaching
  8518. * properties to Elements.
  8519. */
  8520. /* istanbul ignore if */
  8521. if (isIE9) {
  8522. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8523. document.addEventListener('selectionchange', () => {
  8524. const el = document.activeElement;
  8525. // @ts-expect-error
  8526. if (el && el.vmodel) {
  8527. trigger(el, 'input');
  8528. }
  8529. });
  8530. }
  8531. const directive = {
  8532. inserted(el, binding, vnode, oldVnode) {
  8533. if (vnode.tag === 'select') {
  8534. // #6903
  8535. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8536. mergeVNodeHook(vnode, 'postpatch', () => {
  8537. directive.componentUpdated(el, binding, vnode);
  8538. });
  8539. }
  8540. else {
  8541. setSelected(el, binding, vnode.context);
  8542. }
  8543. el._vOptions = [].map.call(el.options, getValue);
  8544. }
  8545. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8546. el._vModifiers = binding.modifiers;
  8547. if (!binding.modifiers.lazy) {
  8548. el.addEventListener('compositionstart', onCompositionStart);
  8549. el.addEventListener('compositionend', onCompositionEnd);
  8550. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8551. // switching focus before confirming composition choice
  8552. // this also fixes the issue where some browsers e.g. iOS Chrome
  8553. // fires "change" instead of "input" on autocomplete.
  8554. el.addEventListener('change', onCompositionEnd);
  8555. /* istanbul ignore if */
  8556. if (isIE9) {
  8557. el.vmodel = true;
  8558. }
  8559. }
  8560. }
  8561. },
  8562. componentUpdated(el, binding, vnode) {
  8563. if (vnode.tag === 'select') {
  8564. setSelected(el, binding, vnode.context);
  8565. // in case the options rendered by v-for have changed,
  8566. // it's possible that the value is out-of-sync with the rendered options.
  8567. // detect such cases and filter out values that no longer has a matching
  8568. // option in the DOM.
  8569. const prevOptions = el._vOptions;
  8570. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8571. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8572. // trigger change event if
  8573. // no matching option found for at least one value
  8574. const needReset = el.multiple
  8575. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8576. : binding.value !== binding.oldValue &&
  8577. hasNoMatchingOption(binding.value, curOptions);
  8578. if (needReset) {
  8579. trigger(el, 'change');
  8580. }
  8581. }
  8582. }
  8583. }
  8584. };
  8585. function setSelected(el, binding, vm) {
  8586. actuallySetSelected(el, binding, vm);
  8587. /* istanbul ignore if */
  8588. if (isIE || isEdge) {
  8589. setTimeout(() => {
  8590. actuallySetSelected(el, binding, vm);
  8591. }, 0);
  8592. }
  8593. }
  8594. function actuallySetSelected(el, binding, vm) {
  8595. const value = binding.value;
  8596. const isMultiple = el.multiple;
  8597. if (isMultiple && !Array.isArray(value)) {
  8598. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8599. `expects an Array value for its binding, but got ${Object.prototype.toString
  8600. .call(value)
  8601. .slice(8, -1)}`, vm);
  8602. return;
  8603. }
  8604. let selected, option;
  8605. for (let i = 0, l = el.options.length; i < l; i++) {
  8606. option = el.options[i];
  8607. if (isMultiple) {
  8608. selected = looseIndexOf(value, getValue(option)) > -1;
  8609. if (option.selected !== selected) {
  8610. option.selected = selected;
  8611. }
  8612. }
  8613. else {
  8614. if (looseEqual(getValue(option), value)) {
  8615. if (el.selectedIndex !== i) {
  8616. el.selectedIndex = i;
  8617. }
  8618. return;
  8619. }
  8620. }
  8621. }
  8622. if (!isMultiple) {
  8623. el.selectedIndex = -1;
  8624. }
  8625. }
  8626. function hasNoMatchingOption(value, options) {
  8627. return options.every(o => !looseEqual(o, value));
  8628. }
  8629. function getValue(option) {
  8630. return '_value' in option ? option._value : option.value;
  8631. }
  8632. function onCompositionStart(e) {
  8633. e.target.composing = true;
  8634. }
  8635. function onCompositionEnd(e) {
  8636. // prevent triggering an input event for no reason
  8637. if (!e.target.composing)
  8638. return;
  8639. e.target.composing = false;
  8640. trigger(e.target, 'input');
  8641. }
  8642. function trigger(el, type) {
  8643. const e = document.createEvent('HTMLEvents');
  8644. e.initEvent(type, true, true);
  8645. el.dispatchEvent(e);
  8646. }
  8647. // recursively search for possible transition defined inside the component root
  8648. function locateNode(vnode) {
  8649. // @ts-expect-error
  8650. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8651. ? locateNode(vnode.componentInstance._vnode)
  8652. : vnode;
  8653. }
  8654. var show = {
  8655. bind(el, { value }, vnode) {
  8656. vnode = locateNode(vnode);
  8657. const transition = vnode.data && vnode.data.transition;
  8658. const originalDisplay = (el.__vOriginalDisplay =
  8659. el.style.display === 'none' ? '' : el.style.display);
  8660. if (value && transition) {
  8661. vnode.data.show = true;
  8662. enter(vnode, () => {
  8663. el.style.display = originalDisplay;
  8664. });
  8665. }
  8666. else {
  8667. el.style.display = value ? originalDisplay : 'none';
  8668. }
  8669. },
  8670. update(el, { value, oldValue }, vnode) {
  8671. /* istanbul ignore if */
  8672. if (!value === !oldValue)
  8673. return;
  8674. vnode = locateNode(vnode);
  8675. const transition = vnode.data && vnode.data.transition;
  8676. if (transition) {
  8677. vnode.data.show = true;
  8678. if (value) {
  8679. enter(vnode, () => {
  8680. el.style.display = el.__vOriginalDisplay;
  8681. });
  8682. }
  8683. else {
  8684. leave(vnode, () => {
  8685. el.style.display = 'none';
  8686. });
  8687. }
  8688. }
  8689. else {
  8690. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8691. }
  8692. },
  8693. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8694. if (!isDestroy) {
  8695. el.style.display = el.__vOriginalDisplay;
  8696. }
  8697. }
  8698. };
  8699. var platformDirectives = {
  8700. model: directive,
  8701. show
  8702. };
  8703. // Provides transition support for a single element/component.
  8704. const transitionProps = {
  8705. name: String,
  8706. appear: Boolean,
  8707. css: Boolean,
  8708. mode: String,
  8709. type: String,
  8710. enterClass: String,
  8711. leaveClass: String,
  8712. enterToClass: String,
  8713. leaveToClass: String,
  8714. enterActiveClass: String,
  8715. leaveActiveClass: String,
  8716. appearClass: String,
  8717. appearActiveClass: String,
  8718. appearToClass: String,
  8719. duration: [Number, String, Object]
  8720. };
  8721. // in case the child is also an abstract component, e.g. <keep-alive>
  8722. // we want to recursively retrieve the real component to be rendered
  8723. function getRealChild(vnode) {
  8724. const compOptions = vnode && vnode.componentOptions;
  8725. if (compOptions && compOptions.Ctor.options.abstract) {
  8726. return getRealChild(getFirstComponentChild(compOptions.children));
  8727. }
  8728. else {
  8729. return vnode;
  8730. }
  8731. }
  8732. function extractTransitionData(comp) {
  8733. const data = {};
  8734. const options = comp.$options;
  8735. // props
  8736. for (const key in options.propsData) {
  8737. data[key] = comp[key];
  8738. }
  8739. // events.
  8740. // extract listeners and pass them directly to the transition methods
  8741. const listeners = options._parentListeners;
  8742. for (const key in listeners) {
  8743. data[camelize(key)] = listeners[key];
  8744. }
  8745. return data;
  8746. }
  8747. function placeholder(h, rawChild) {
  8748. // @ts-expect-error
  8749. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8750. return h('keep-alive', {
  8751. props: rawChild.componentOptions.propsData
  8752. });
  8753. }
  8754. }
  8755. function hasParentTransition(vnode) {
  8756. while ((vnode = vnode.parent)) {
  8757. if (vnode.data.transition) {
  8758. return true;
  8759. }
  8760. }
  8761. }
  8762. function isSameChild(child, oldChild) {
  8763. return oldChild.key === child.key && oldChild.tag === child.tag;
  8764. }
  8765. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8766. const isVShowDirective = d => d.name === 'show';
  8767. var Transition = {
  8768. name: 'transition',
  8769. props: transitionProps,
  8770. abstract: true,
  8771. render(h) {
  8772. let children = this.$slots.default;
  8773. if (!children) {
  8774. return;
  8775. }
  8776. // filter out text nodes (possible whitespaces)
  8777. children = children.filter(isNotTextNode);
  8778. /* istanbul ignore if */
  8779. if (!children.length) {
  8780. return;
  8781. }
  8782. // warn multiple elements
  8783. if (children.length > 1) {
  8784. warn$2('<transition> can only be used on a single element. Use ' +
  8785. '<transition-group> for lists.', this.$parent);
  8786. }
  8787. const mode = this.mode;
  8788. // warn invalid mode
  8789. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8790. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8791. }
  8792. const rawChild = children[0];
  8793. // if this is a component root node and the component's
  8794. // parent container node also has transition, skip.
  8795. if (hasParentTransition(this.$vnode)) {
  8796. return rawChild;
  8797. }
  8798. // apply transition data to child
  8799. // use getRealChild() to ignore abstract components e.g. keep-alive
  8800. const child = getRealChild(rawChild);
  8801. /* istanbul ignore if */
  8802. if (!child) {
  8803. return rawChild;
  8804. }
  8805. if (this._leaving) {
  8806. return placeholder(h, rawChild);
  8807. }
  8808. // ensure a key that is unique to the vnode type and to this transition
  8809. // component instance. This key will be used to remove pending leaving nodes
  8810. // during entering.
  8811. const id = `__transition-${this._uid}-`;
  8812. child.key =
  8813. child.key == null
  8814. ? child.isComment
  8815. ? id + 'comment'
  8816. : id + child.tag
  8817. : isPrimitive(child.key)
  8818. ? String(child.key).indexOf(id) === 0
  8819. ? child.key
  8820. : id + child.key
  8821. : child.key;
  8822. const data = ((child.data || (child.data = {})).transition =
  8823. extractTransitionData(this));
  8824. const oldRawChild = this._vnode;
  8825. const oldChild = getRealChild(oldRawChild);
  8826. // mark v-show
  8827. // so that the transition module can hand over the control to the directive
  8828. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8829. child.data.show = true;
  8830. }
  8831. if (oldChild &&
  8832. oldChild.data &&
  8833. !isSameChild(child, oldChild) &&
  8834. !isAsyncPlaceholder(oldChild) &&
  8835. // #6687 component root is a comment node
  8836. !(oldChild.componentInstance &&
  8837. oldChild.componentInstance._vnode.isComment)) {
  8838. // replace old child transition data with fresh one
  8839. // important for dynamic transitions!
  8840. const oldData = (oldChild.data.transition = extend({}, data));
  8841. // handle transition mode
  8842. if (mode === 'out-in') {
  8843. // return placeholder node and queue update when leave finishes
  8844. this._leaving = true;
  8845. mergeVNodeHook(oldData, 'afterLeave', () => {
  8846. this._leaving = false;
  8847. this.$forceUpdate();
  8848. });
  8849. return placeholder(h, rawChild);
  8850. }
  8851. else if (mode === 'in-out') {
  8852. if (isAsyncPlaceholder(child)) {
  8853. return oldRawChild;
  8854. }
  8855. let delayedLeave;
  8856. const performLeave = () => {
  8857. delayedLeave();
  8858. };
  8859. mergeVNodeHook(data, 'afterEnter', performLeave);
  8860. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8861. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8862. delayedLeave = leave;
  8863. });
  8864. }
  8865. }
  8866. return rawChild;
  8867. }
  8868. };
  8869. // Provides transition support for list items.
  8870. const props = extend({
  8871. tag: String,
  8872. moveClass: String
  8873. }, transitionProps);
  8874. delete props.mode;
  8875. var TransitionGroup = {
  8876. props,
  8877. beforeMount() {
  8878. const update = this._update;
  8879. this._update = (vnode, hydrating) => {
  8880. const restoreActiveInstance = setActiveInstance(this);
  8881. // force removing pass
  8882. this.__patch__(this._vnode, this.kept, false, // hydrating
  8883. true // removeOnly (!important, avoids unnecessary moves)
  8884. );
  8885. this._vnode = this.kept;
  8886. restoreActiveInstance();
  8887. update.call(this, vnode, hydrating);
  8888. };
  8889. },
  8890. render(h) {
  8891. const tag = this.tag || this.$vnode.data.tag || 'span';
  8892. const map = Object.create(null);
  8893. const prevChildren = (this.prevChildren = this.children);
  8894. const rawChildren = this.$slots.default || [];
  8895. const children = (this.children = []);
  8896. const transitionData = extractTransitionData(this);
  8897. for (let i = 0; i < rawChildren.length; i++) {
  8898. const c = rawChildren[i];
  8899. if (c.tag) {
  8900. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8901. children.push(c);
  8902. map[c.key] = c;
  8903. (c.data || (c.data = {})).transition = transitionData;
  8904. }
  8905. else {
  8906. const opts = c.componentOptions;
  8907. const name = opts
  8908. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8909. : c.tag;
  8910. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8911. }
  8912. }
  8913. }
  8914. if (prevChildren) {
  8915. const kept = [];
  8916. const removed = [];
  8917. for (let i = 0; i < prevChildren.length; i++) {
  8918. const c = prevChildren[i];
  8919. c.data.transition = transitionData;
  8920. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8921. c.data.pos = c.elm.getBoundingClientRect();
  8922. if (map[c.key]) {
  8923. kept.push(c);
  8924. }
  8925. else {
  8926. removed.push(c);
  8927. }
  8928. }
  8929. this.kept = h(tag, null, kept);
  8930. this.removed = removed;
  8931. }
  8932. return h(tag, null, children);
  8933. },
  8934. updated() {
  8935. const children = this.prevChildren;
  8936. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8937. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8938. return;
  8939. }
  8940. // we divide the work into three loops to avoid mixing DOM reads and writes
  8941. // in each iteration - which helps prevent layout thrashing.
  8942. children.forEach(callPendingCbs);
  8943. children.forEach(recordPosition);
  8944. children.forEach(applyTranslation);
  8945. // force reflow to put everything in position
  8946. // assign to this to avoid being removed in tree-shaking
  8947. // $flow-disable-line
  8948. this._reflow = document.body.offsetHeight;
  8949. children.forEach((c) => {
  8950. if (c.data.moved) {
  8951. const el = c.elm;
  8952. const s = el.style;
  8953. addTransitionClass(el, moveClass);
  8954. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8955. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8956. if (e && e.target !== el) {
  8957. return;
  8958. }
  8959. if (!e || /transform$/.test(e.propertyName)) {
  8960. el.removeEventListener(transitionEndEvent, cb);
  8961. el._moveCb = null;
  8962. removeTransitionClass(el, moveClass);
  8963. }
  8964. }));
  8965. }
  8966. });
  8967. },
  8968. methods: {
  8969. hasMove(el, moveClass) {
  8970. /* istanbul ignore if */
  8971. if (!hasTransition) {
  8972. return false;
  8973. }
  8974. /* istanbul ignore if */
  8975. if (this._hasMove) {
  8976. return this._hasMove;
  8977. }
  8978. // Detect whether an element with the move class applied has
  8979. // CSS transitions. Since the element may be inside an entering
  8980. // transition at this very moment, we make a clone of it and remove
  8981. // all other transition classes applied to ensure only the move class
  8982. // is applied.
  8983. const clone = el.cloneNode();
  8984. if (el._transitionClasses) {
  8985. el._transitionClasses.forEach((cls) => {
  8986. removeClass(clone, cls);
  8987. });
  8988. }
  8989. addClass(clone, moveClass);
  8990. clone.style.display = 'none';
  8991. this.$el.appendChild(clone);
  8992. const info = getTransitionInfo(clone);
  8993. this.$el.removeChild(clone);
  8994. return (this._hasMove = info.hasTransform);
  8995. }
  8996. }
  8997. };
  8998. function callPendingCbs(c) {
  8999. /* istanbul ignore if */
  9000. if (c.elm._moveCb) {
  9001. c.elm._moveCb();
  9002. }
  9003. /* istanbul ignore if */
  9004. if (c.elm._enterCb) {
  9005. c.elm._enterCb();
  9006. }
  9007. }
  9008. function recordPosition(c) {
  9009. c.data.newPos = c.elm.getBoundingClientRect();
  9010. }
  9011. function applyTranslation(c) {
  9012. const oldPos = c.data.pos;
  9013. const newPos = c.data.newPos;
  9014. const dx = oldPos.left - newPos.left;
  9015. const dy = oldPos.top - newPos.top;
  9016. if (dx || dy) {
  9017. c.data.moved = true;
  9018. const s = c.elm.style;
  9019. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9020. s.transitionDuration = '0s';
  9021. }
  9022. }
  9023. var platformComponents = {
  9024. Transition,
  9025. TransitionGroup
  9026. };
  9027. // install platform specific utils
  9028. Vue.config.mustUseProp = mustUseProp;
  9029. Vue.config.isReservedTag = isReservedTag;
  9030. Vue.config.isReservedAttr = isReservedAttr;
  9031. Vue.config.getTagNamespace = getTagNamespace;
  9032. Vue.config.isUnknownElement = isUnknownElement;
  9033. // install platform runtime directives & components
  9034. extend(Vue.options.directives, platformDirectives);
  9035. extend(Vue.options.components, platformComponents);
  9036. // install platform patch function
  9037. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9038. // public mount method
  9039. Vue.prototype.$mount = function (el, hydrating) {
  9040. el = el && inBrowser ? query(el) : undefined;
  9041. return mountComponent(this, el, hydrating);
  9042. };
  9043. // devtools global hook
  9044. /* istanbul ignore next */
  9045. if (inBrowser) {
  9046. setTimeout(() => {
  9047. if (config.devtools) {
  9048. if (devtools) {
  9049. devtools.emit('init', Vue);
  9050. }
  9051. else {
  9052. // @ts-expect-error
  9053. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9054. 'https://github.com/vuejs/vue-devtools');
  9055. }
  9056. }
  9057. if (config.productionTip !== false &&
  9058. typeof console !== 'undefined') {
  9059. // @ts-expect-error
  9060. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9061. `Make sure to turn on production mode when deploying for production.\n` +
  9062. `See more tips at https://vuejs.org/guide/deployment.html`);
  9063. }
  9064. }, 0);
  9065. }
  9066. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9067. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9068. const buildRegex = cached(delimiters => {
  9069. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9070. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9071. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9072. });
  9073. function parseText(text, delimiters) {
  9074. //@ts-expect-error
  9075. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9076. if (!tagRE.test(text)) {
  9077. return;
  9078. }
  9079. const tokens = [];
  9080. const rawTokens = [];
  9081. let lastIndex = (tagRE.lastIndex = 0);
  9082. let match, index, tokenValue;
  9083. while ((match = tagRE.exec(text))) {
  9084. index = match.index;
  9085. // push text token
  9086. if (index > lastIndex) {
  9087. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9088. tokens.push(JSON.stringify(tokenValue));
  9089. }
  9090. // tag token
  9091. const exp = parseFilters(match[1].trim());
  9092. tokens.push(`_s(${exp})`);
  9093. rawTokens.push({ '@binding': exp });
  9094. lastIndex = index + match[0].length;
  9095. }
  9096. if (lastIndex < text.length) {
  9097. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9098. tokens.push(JSON.stringify(tokenValue));
  9099. }
  9100. return {
  9101. expression: tokens.join('+'),
  9102. tokens: rawTokens
  9103. };
  9104. }
  9105. function transformNode$1(el, options) {
  9106. const warn = options.warn || baseWarn;
  9107. const staticClass = getAndRemoveAttr(el, 'class');
  9108. if (staticClass) {
  9109. const res = parseText(staticClass, options.delimiters);
  9110. if (res) {
  9111. warn(`class="${staticClass}": ` +
  9112. 'Interpolation inside attributes has been removed. ' +
  9113. 'Use v-bind or the colon shorthand instead. For example, ' +
  9114. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9115. }
  9116. }
  9117. if (staticClass) {
  9118. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9119. }
  9120. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9121. if (classBinding) {
  9122. el.classBinding = classBinding;
  9123. }
  9124. }
  9125. function genData$2(el) {
  9126. let data = '';
  9127. if (el.staticClass) {
  9128. data += `staticClass:${el.staticClass},`;
  9129. }
  9130. if (el.classBinding) {
  9131. data += `class:${el.classBinding},`;
  9132. }
  9133. return data;
  9134. }
  9135. var klass = {
  9136. staticKeys: ['staticClass'],
  9137. transformNode: transformNode$1,
  9138. genData: genData$2
  9139. };
  9140. function transformNode(el, options) {
  9141. const warn = options.warn || baseWarn;
  9142. const staticStyle = getAndRemoveAttr(el, 'style');
  9143. if (staticStyle) {
  9144. /* istanbul ignore if */
  9145. {
  9146. const res = parseText(staticStyle, options.delimiters);
  9147. if (res) {
  9148. warn(`style="${staticStyle}": ` +
  9149. 'Interpolation inside attributes has been removed. ' +
  9150. 'Use v-bind or the colon shorthand instead. For example, ' +
  9151. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9152. }
  9153. }
  9154. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9155. }
  9156. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9157. if (styleBinding) {
  9158. el.styleBinding = styleBinding;
  9159. }
  9160. }
  9161. function genData$1(el) {
  9162. let data = '';
  9163. if (el.staticStyle) {
  9164. data += `staticStyle:${el.staticStyle},`;
  9165. }
  9166. if (el.styleBinding) {
  9167. data += `style:(${el.styleBinding}),`;
  9168. }
  9169. return data;
  9170. }
  9171. var style = {
  9172. staticKeys: ['staticStyle'],
  9173. transformNode,
  9174. genData: genData$1
  9175. };
  9176. let decoder;
  9177. var he = {
  9178. decode(html) {
  9179. decoder = decoder || document.createElement('div');
  9180. decoder.innerHTML = html;
  9181. return decoder.textContent;
  9182. }
  9183. };
  9184. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9185. 'link,meta,param,source,track,wbr');
  9186. // Elements that you can, intentionally, leave open
  9187. // (and which close themselves)
  9188. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9189. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9190. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9191. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9192. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9193. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9194. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9195. 'title,tr,track');
  9196. /**
  9197. * Not type-checking this file because it's mostly vendor code.
  9198. */
  9199. // Regular Expressions for parsing tags and attributes
  9200. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9201. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9202. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9203. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9204. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9205. const startTagClose = /^\s*(\/?)>/;
  9206. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9207. const doctype = /^<!DOCTYPE [^>]+>/i;
  9208. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9209. const comment = /^<!\--/;
  9210. const conditionalComment = /^<!\[/;
  9211. // Special Elements (can contain anything)
  9212. const isPlainTextElement = makeMap('script,style,textarea', true);
  9213. const reCache = {};
  9214. const decodingMap = {
  9215. '&lt;': '<',
  9216. '&gt;': '>',
  9217. '&quot;': '"',
  9218. '&amp;': '&',
  9219. '&#10;': '\n',
  9220. '&#9;': '\t',
  9221. '&#39;': "'"
  9222. };
  9223. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9224. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9225. // #5992
  9226. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9227. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9228. function decodeAttr(value, shouldDecodeNewlines) {
  9229. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9230. return value.replace(re, match => decodingMap[match]);
  9231. }
  9232. function parseHTML(html, options) {
  9233. const stack = [];
  9234. const expectHTML = options.expectHTML;
  9235. const isUnaryTag = options.isUnaryTag || no;
  9236. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9237. let index = 0;
  9238. let last, lastTag;
  9239. while (html) {
  9240. last = html;
  9241. // Make sure we're not in a plaintext content element like script/style
  9242. if (!lastTag || !isPlainTextElement(lastTag)) {
  9243. let textEnd = html.indexOf('<');
  9244. if (textEnd === 0) {
  9245. // Comment:
  9246. if (comment.test(html)) {
  9247. const commentEnd = html.indexOf('-->');
  9248. if (commentEnd >= 0) {
  9249. if (options.shouldKeepComment && options.comment) {
  9250. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9251. }
  9252. advance(commentEnd + 3);
  9253. continue;
  9254. }
  9255. }
  9256. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9257. if (conditionalComment.test(html)) {
  9258. const conditionalEnd = html.indexOf(']>');
  9259. if (conditionalEnd >= 0) {
  9260. advance(conditionalEnd + 2);
  9261. continue;
  9262. }
  9263. }
  9264. // Doctype:
  9265. const doctypeMatch = html.match(doctype);
  9266. if (doctypeMatch) {
  9267. advance(doctypeMatch[0].length);
  9268. continue;
  9269. }
  9270. // End tag:
  9271. const endTagMatch = html.match(endTag);
  9272. if (endTagMatch) {
  9273. const curIndex = index;
  9274. advance(endTagMatch[0].length);
  9275. parseEndTag(endTagMatch[1], curIndex, index);
  9276. continue;
  9277. }
  9278. // Start tag:
  9279. const startTagMatch = parseStartTag();
  9280. if (startTagMatch) {
  9281. handleStartTag(startTagMatch);
  9282. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9283. advance(1);
  9284. }
  9285. continue;
  9286. }
  9287. }
  9288. let text, rest, next;
  9289. if (textEnd >= 0) {
  9290. rest = html.slice(textEnd);
  9291. while (!endTag.test(rest) &&
  9292. !startTagOpen.test(rest) &&
  9293. !comment.test(rest) &&
  9294. !conditionalComment.test(rest)) {
  9295. // < in plain text, be forgiving and treat it as text
  9296. next = rest.indexOf('<', 1);
  9297. if (next < 0)
  9298. break;
  9299. textEnd += next;
  9300. rest = html.slice(textEnd);
  9301. }
  9302. text = html.substring(0, textEnd);
  9303. }
  9304. if (textEnd < 0) {
  9305. text = html;
  9306. }
  9307. if (text) {
  9308. advance(text.length);
  9309. }
  9310. if (options.chars && text) {
  9311. options.chars(text, index - text.length, index);
  9312. }
  9313. }
  9314. else {
  9315. let endTagLength = 0;
  9316. const stackedTag = lastTag.toLowerCase();
  9317. const reStackedTag = reCache[stackedTag] ||
  9318. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9319. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9320. endTagLength = endTag.length;
  9321. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9322. text = text
  9323. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9324. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9325. }
  9326. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9327. text = text.slice(1);
  9328. }
  9329. if (options.chars) {
  9330. options.chars(text);
  9331. }
  9332. return '';
  9333. });
  9334. index += html.length - rest.length;
  9335. html = rest;
  9336. parseEndTag(stackedTag, index - endTagLength, index);
  9337. }
  9338. if (html === last) {
  9339. options.chars && options.chars(html);
  9340. if (!stack.length && options.warn) {
  9341. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9342. start: index + html.length
  9343. });
  9344. }
  9345. break;
  9346. }
  9347. }
  9348. // Clean up any remaining tags
  9349. parseEndTag();
  9350. function advance(n) {
  9351. index += n;
  9352. html = html.substring(n);
  9353. }
  9354. function parseStartTag() {
  9355. const start = html.match(startTagOpen);
  9356. if (start) {
  9357. const match = {
  9358. tagName: start[1],
  9359. attrs: [],
  9360. start: index
  9361. };
  9362. advance(start[0].length);
  9363. let end, attr;
  9364. while (!(end = html.match(startTagClose)) &&
  9365. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9366. attr.start = index;
  9367. advance(attr[0].length);
  9368. attr.end = index;
  9369. match.attrs.push(attr);
  9370. }
  9371. if (end) {
  9372. match.unarySlash = end[1];
  9373. advance(end[0].length);
  9374. match.end = index;
  9375. return match;
  9376. }
  9377. }
  9378. }
  9379. function handleStartTag(match) {
  9380. const tagName = match.tagName;
  9381. const unarySlash = match.unarySlash;
  9382. if (expectHTML) {
  9383. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9384. parseEndTag(lastTag);
  9385. }
  9386. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9387. parseEndTag(tagName);
  9388. }
  9389. }
  9390. const unary = isUnaryTag(tagName) || !!unarySlash;
  9391. const l = match.attrs.length;
  9392. const attrs = new Array(l);
  9393. for (let i = 0; i < l; i++) {
  9394. const args = match.attrs[i];
  9395. const value = args[3] || args[4] || args[5] || '';
  9396. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9397. ? options.shouldDecodeNewlinesForHref
  9398. : options.shouldDecodeNewlines;
  9399. attrs[i] = {
  9400. name: args[1],
  9401. value: decodeAttr(value, shouldDecodeNewlines)
  9402. };
  9403. if (options.outputSourceRange) {
  9404. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9405. attrs[i].end = args.end;
  9406. }
  9407. }
  9408. if (!unary) {
  9409. stack.push({
  9410. tag: tagName,
  9411. lowerCasedTag: tagName.toLowerCase(),
  9412. attrs: attrs,
  9413. start: match.start,
  9414. end: match.end
  9415. });
  9416. lastTag = tagName;
  9417. }
  9418. if (options.start) {
  9419. options.start(tagName, attrs, unary, match.start, match.end);
  9420. }
  9421. }
  9422. function parseEndTag(tagName, start, end) {
  9423. let pos, lowerCasedTagName;
  9424. if (start == null)
  9425. start = index;
  9426. if (end == null)
  9427. end = index;
  9428. // Find the closest opened tag of the same type
  9429. if (tagName) {
  9430. lowerCasedTagName = tagName.toLowerCase();
  9431. for (pos = stack.length - 1; pos >= 0; pos--) {
  9432. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9433. break;
  9434. }
  9435. }
  9436. }
  9437. else {
  9438. // If no tag name is provided, clean shop
  9439. pos = 0;
  9440. }
  9441. if (pos >= 0) {
  9442. // Close all the open elements, up the stack
  9443. for (let i = stack.length - 1; i >= pos; i--) {
  9444. if ((i > pos || !tagName) && options.warn) {
  9445. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9446. start: stack[i].start,
  9447. end: stack[i].end
  9448. });
  9449. }
  9450. if (options.end) {
  9451. options.end(stack[i].tag, start, end);
  9452. }
  9453. }
  9454. // Remove the open elements from the stack
  9455. stack.length = pos;
  9456. lastTag = pos && stack[pos - 1].tag;
  9457. }
  9458. else if (lowerCasedTagName === 'br') {
  9459. if (options.start) {
  9460. options.start(tagName, [], true, start, end);
  9461. }
  9462. }
  9463. else if (lowerCasedTagName === 'p') {
  9464. if (options.start) {
  9465. options.start(tagName, [], false, start, end);
  9466. }
  9467. if (options.end) {
  9468. options.end(tagName, start, end);
  9469. }
  9470. }
  9471. }
  9472. }
  9473. const onRE = /^@|^v-on:/;
  9474. const dirRE = /^v-|^@|^:|^#/;
  9475. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9476. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9477. const stripParensRE = /^\(|\)$/g;
  9478. const dynamicArgRE = /^\[.*\]$/;
  9479. const argRE = /:(.*)$/;
  9480. const bindRE = /^:|^\.|^v-bind:/;
  9481. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9482. const slotRE = /^v-slot(:|$)|^#/;
  9483. const lineBreakRE = /[\r\n]/;
  9484. const whitespaceRE = /[ \f\t\r\n]+/g;
  9485. const invalidAttributeRE = /[\s"'<>\/=]/;
  9486. const decodeHTMLCached = cached(he.decode);
  9487. const emptySlotScopeToken = `_empty_`;
  9488. // configurable state
  9489. let warn;
  9490. let delimiters;
  9491. let transforms;
  9492. let preTransforms;
  9493. let postTransforms;
  9494. let platformIsPreTag;
  9495. let platformMustUseProp;
  9496. let platformGetTagNamespace;
  9497. let maybeComponent;
  9498. function createASTElement(tag, attrs, parent) {
  9499. return {
  9500. type: 1,
  9501. tag,
  9502. attrsList: attrs,
  9503. attrsMap: makeAttrsMap(attrs),
  9504. rawAttrsMap: {},
  9505. parent,
  9506. children: []
  9507. };
  9508. }
  9509. /**
  9510. * Convert HTML string to AST.
  9511. */
  9512. function parse(template, options) {
  9513. warn = options.warn || baseWarn;
  9514. platformIsPreTag = options.isPreTag || no;
  9515. platformMustUseProp = options.mustUseProp || no;
  9516. platformGetTagNamespace = options.getTagNamespace || no;
  9517. const isReservedTag = options.isReservedTag || no;
  9518. maybeComponent = (el) => !!(el.component ||
  9519. el.attrsMap[':is'] ||
  9520. el.attrsMap['v-bind:is'] ||
  9521. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9522. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9523. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9524. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9525. delimiters = options.delimiters;
  9526. const stack = [];
  9527. const preserveWhitespace = options.preserveWhitespace !== false;
  9528. const whitespaceOption = options.whitespace;
  9529. let root;
  9530. let currentParent;
  9531. let inVPre = false;
  9532. let inPre = false;
  9533. let warned = false;
  9534. function warnOnce(msg, range) {
  9535. if (!warned) {
  9536. warned = true;
  9537. warn(msg, range);
  9538. }
  9539. }
  9540. function closeElement(element) {
  9541. trimEndingWhitespace(element);
  9542. if (!inVPre && !element.processed) {
  9543. element = processElement(element, options);
  9544. }
  9545. // tree management
  9546. if (!stack.length && element !== root) {
  9547. // allow root elements with v-if, v-else-if and v-else
  9548. if (root.if && (element.elseif || element.else)) {
  9549. {
  9550. checkRootConstraints(element);
  9551. }
  9552. addIfCondition(root, {
  9553. exp: element.elseif,
  9554. block: element
  9555. });
  9556. }
  9557. else {
  9558. warnOnce(`Component template should contain exactly one root element. ` +
  9559. `If you are using v-if on multiple elements, ` +
  9560. `use v-else-if to chain them instead.`, { start: element.start });
  9561. }
  9562. }
  9563. if (currentParent && !element.forbidden) {
  9564. if (element.elseif || element.else) {
  9565. processIfConditions(element, currentParent);
  9566. }
  9567. else {
  9568. if (element.slotScope) {
  9569. // scoped slot
  9570. // keep it in the children list so that v-else(-if) conditions can
  9571. // find it as the prev node.
  9572. const name = element.slotTarget || '"default"';
  9573. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9574. }
  9575. currentParent.children.push(element);
  9576. element.parent = currentParent;
  9577. }
  9578. }
  9579. // final children cleanup
  9580. // filter out scoped slots
  9581. element.children = element.children.filter(c => !c.slotScope);
  9582. // remove trailing whitespace node again
  9583. trimEndingWhitespace(element);
  9584. // check pre state
  9585. if (element.pre) {
  9586. inVPre = false;
  9587. }
  9588. if (platformIsPreTag(element.tag)) {
  9589. inPre = false;
  9590. }
  9591. // apply post-transforms
  9592. for (let i = 0; i < postTransforms.length; i++) {
  9593. postTransforms[i](element, options);
  9594. }
  9595. }
  9596. function trimEndingWhitespace(el) {
  9597. // remove trailing whitespace node
  9598. if (!inPre) {
  9599. let lastNode;
  9600. while ((lastNode = el.children[el.children.length - 1]) &&
  9601. lastNode.type === 3 &&
  9602. lastNode.text === ' ') {
  9603. el.children.pop();
  9604. }
  9605. }
  9606. }
  9607. function checkRootConstraints(el) {
  9608. if (el.tag === 'slot' || el.tag === 'template') {
  9609. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9610. 'contain multiple nodes.', { start: el.start });
  9611. }
  9612. if (el.attrsMap.hasOwnProperty('v-for')) {
  9613. warnOnce('Cannot use v-for on stateful component root element because ' +
  9614. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9615. }
  9616. }
  9617. parseHTML(template, {
  9618. warn,
  9619. expectHTML: options.expectHTML,
  9620. isUnaryTag: options.isUnaryTag,
  9621. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9622. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9623. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9624. shouldKeepComment: options.comments,
  9625. outputSourceRange: options.outputSourceRange,
  9626. start(tag, attrs, unary, start, end) {
  9627. // check namespace.
  9628. // inherit parent ns if there is one
  9629. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9630. // handle IE svg bug
  9631. /* istanbul ignore if */
  9632. if (isIE && ns === 'svg') {
  9633. attrs = guardIESVGBug(attrs);
  9634. }
  9635. let element = createASTElement(tag, attrs, currentParent);
  9636. if (ns) {
  9637. element.ns = ns;
  9638. }
  9639. {
  9640. if (options.outputSourceRange) {
  9641. element.start = start;
  9642. element.end = end;
  9643. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9644. cumulated[attr.name] = attr;
  9645. return cumulated;
  9646. }, {});
  9647. }
  9648. attrs.forEach(attr => {
  9649. if (invalidAttributeRE.test(attr.name)) {
  9650. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9651. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9652. ? {
  9653. start: attr.start + attr.name.indexOf(`[`),
  9654. end: attr.start + attr.name.length
  9655. }
  9656. : undefined);
  9657. }
  9658. });
  9659. }
  9660. if (isForbiddenTag(element) && !isServerRendering()) {
  9661. element.forbidden = true;
  9662. warn('Templates should only be responsible for mapping the state to the ' +
  9663. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9664. `<${tag}>` +
  9665. ', as they will not be parsed.', { start: element.start });
  9666. }
  9667. // apply pre-transforms
  9668. for (let i = 0; i < preTransforms.length; i++) {
  9669. element = preTransforms[i](element, options) || element;
  9670. }
  9671. if (!inVPre) {
  9672. processPre(element);
  9673. if (element.pre) {
  9674. inVPre = true;
  9675. }
  9676. }
  9677. if (platformIsPreTag(element.tag)) {
  9678. inPre = true;
  9679. }
  9680. if (inVPre) {
  9681. processRawAttrs(element);
  9682. }
  9683. else if (!element.processed) {
  9684. // structural directives
  9685. processFor(element);
  9686. processIf(element);
  9687. processOnce(element);
  9688. }
  9689. if (!root) {
  9690. root = element;
  9691. {
  9692. checkRootConstraints(root);
  9693. }
  9694. }
  9695. if (!unary) {
  9696. currentParent = element;
  9697. stack.push(element);
  9698. }
  9699. else {
  9700. closeElement(element);
  9701. }
  9702. },
  9703. end(tag, start, end) {
  9704. const element = stack[stack.length - 1];
  9705. // pop stack
  9706. stack.length -= 1;
  9707. currentParent = stack[stack.length - 1];
  9708. if (options.outputSourceRange) {
  9709. element.end = end;
  9710. }
  9711. closeElement(element);
  9712. },
  9713. chars(text, start, end) {
  9714. if (!currentParent) {
  9715. {
  9716. if (text === template) {
  9717. warnOnce('Component template requires a root element, rather than just text.', { start });
  9718. }
  9719. else if ((text = text.trim())) {
  9720. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9721. start
  9722. });
  9723. }
  9724. }
  9725. return;
  9726. }
  9727. // IE textarea placeholder bug
  9728. /* istanbul ignore if */
  9729. if (isIE &&
  9730. currentParent.tag === 'textarea' &&
  9731. currentParent.attrsMap.placeholder === text) {
  9732. return;
  9733. }
  9734. const children = currentParent.children;
  9735. if (inPre || text.trim()) {
  9736. text = isTextTag(currentParent)
  9737. ? text
  9738. : decodeHTMLCached(text);
  9739. }
  9740. else if (!children.length) {
  9741. // remove the whitespace-only node right after an opening tag
  9742. text = '';
  9743. }
  9744. else if (whitespaceOption) {
  9745. if (whitespaceOption === 'condense') {
  9746. // in condense mode, remove the whitespace node if it contains
  9747. // line break, otherwise condense to a single space
  9748. text = lineBreakRE.test(text) ? '' : ' ';
  9749. }
  9750. else {
  9751. text = ' ';
  9752. }
  9753. }
  9754. else {
  9755. text = preserveWhitespace ? ' ' : '';
  9756. }
  9757. if (text) {
  9758. if (!inPre && whitespaceOption === 'condense') {
  9759. // condense consecutive whitespaces into single space
  9760. text = text.replace(whitespaceRE, ' ');
  9761. }
  9762. let res;
  9763. let child;
  9764. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9765. child = {
  9766. type: 2,
  9767. expression: res.expression,
  9768. tokens: res.tokens,
  9769. text
  9770. };
  9771. }
  9772. else if (text !== ' ' ||
  9773. !children.length ||
  9774. children[children.length - 1].text !== ' ') {
  9775. child = {
  9776. type: 3,
  9777. text
  9778. };
  9779. }
  9780. if (child) {
  9781. if (options.outputSourceRange) {
  9782. child.start = start;
  9783. child.end = end;
  9784. }
  9785. children.push(child);
  9786. }
  9787. }
  9788. },
  9789. comment(text, start, end) {
  9790. // adding anything as a sibling to the root node is forbidden
  9791. // comments should still be allowed, but ignored
  9792. if (currentParent) {
  9793. const child = {
  9794. type: 3,
  9795. text,
  9796. isComment: true
  9797. };
  9798. if (options.outputSourceRange) {
  9799. child.start = start;
  9800. child.end = end;
  9801. }
  9802. currentParent.children.push(child);
  9803. }
  9804. }
  9805. });
  9806. return root;
  9807. }
  9808. function processPre(el) {
  9809. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9810. el.pre = true;
  9811. }
  9812. }
  9813. function processRawAttrs(el) {
  9814. const list = el.attrsList;
  9815. const len = list.length;
  9816. if (len) {
  9817. const attrs = (el.attrs = new Array(len));
  9818. for (let i = 0; i < len; i++) {
  9819. attrs[i] = {
  9820. name: list[i].name,
  9821. value: JSON.stringify(list[i].value)
  9822. };
  9823. if (list[i].start != null) {
  9824. attrs[i].start = list[i].start;
  9825. attrs[i].end = list[i].end;
  9826. }
  9827. }
  9828. }
  9829. else if (!el.pre) {
  9830. // non root node in pre blocks with no attributes
  9831. el.plain = true;
  9832. }
  9833. }
  9834. function processElement(element, options) {
  9835. processKey(element);
  9836. // determine whether this is a plain element after
  9837. // removing structural attributes
  9838. element.plain =
  9839. !element.key && !element.scopedSlots && !element.attrsList.length;
  9840. processRef(element);
  9841. processSlotContent(element);
  9842. processSlotOutlet(element);
  9843. processComponent(element);
  9844. for (let i = 0; i < transforms.length; i++) {
  9845. element = transforms[i](element, options) || element;
  9846. }
  9847. processAttrs(element);
  9848. return element;
  9849. }
  9850. function processKey(el) {
  9851. const exp = getBindingAttr(el, 'key');
  9852. if (exp) {
  9853. {
  9854. if (el.tag === 'template') {
  9855. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9856. }
  9857. if (el.for) {
  9858. const iterator = el.iterator2 || el.iterator1;
  9859. const parent = el.parent;
  9860. if (iterator &&
  9861. iterator === exp &&
  9862. parent &&
  9863. parent.tag === 'transition-group') {
  9864. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9865. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9866. }
  9867. }
  9868. }
  9869. el.key = exp;
  9870. }
  9871. }
  9872. function processRef(el) {
  9873. const ref = getBindingAttr(el, 'ref');
  9874. if (ref) {
  9875. el.ref = ref;
  9876. el.refInFor = checkInFor(el);
  9877. }
  9878. }
  9879. function processFor(el) {
  9880. let exp;
  9881. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9882. const res = parseFor(exp);
  9883. if (res) {
  9884. extend(el, res);
  9885. }
  9886. else {
  9887. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9888. }
  9889. }
  9890. }
  9891. function parseFor(exp) {
  9892. const inMatch = exp.match(forAliasRE);
  9893. if (!inMatch)
  9894. return;
  9895. const res = {};
  9896. res.for = inMatch[2].trim();
  9897. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9898. const iteratorMatch = alias.match(forIteratorRE);
  9899. if (iteratorMatch) {
  9900. res.alias = alias.replace(forIteratorRE, '').trim();
  9901. res.iterator1 = iteratorMatch[1].trim();
  9902. if (iteratorMatch[2]) {
  9903. res.iterator2 = iteratorMatch[2].trim();
  9904. }
  9905. }
  9906. else {
  9907. res.alias = alias;
  9908. }
  9909. return res;
  9910. }
  9911. function processIf(el) {
  9912. const exp = getAndRemoveAttr(el, 'v-if');
  9913. if (exp) {
  9914. el.if = exp;
  9915. addIfCondition(el, {
  9916. exp: exp,
  9917. block: el
  9918. });
  9919. }
  9920. else {
  9921. if (getAndRemoveAttr(el, 'v-else') != null) {
  9922. el.else = true;
  9923. }
  9924. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9925. if (elseif) {
  9926. el.elseif = elseif;
  9927. }
  9928. }
  9929. }
  9930. function processIfConditions(el, parent) {
  9931. const prev = findPrevElement(parent.children);
  9932. if (prev && prev.if) {
  9933. addIfCondition(prev, {
  9934. exp: el.elseif,
  9935. block: el
  9936. });
  9937. }
  9938. else {
  9939. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  9940. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  9941. }
  9942. }
  9943. function findPrevElement(children) {
  9944. let i = children.length;
  9945. while (i--) {
  9946. if (children[i].type === 1) {
  9947. return children[i];
  9948. }
  9949. else {
  9950. if (children[i].text !== ' ') {
  9951. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9952. `will be ignored.`, children[i]);
  9953. }
  9954. children.pop();
  9955. }
  9956. }
  9957. }
  9958. function addIfCondition(el, condition) {
  9959. if (!el.ifConditions) {
  9960. el.ifConditions = [];
  9961. }
  9962. el.ifConditions.push(condition);
  9963. }
  9964. function processOnce(el) {
  9965. const once = getAndRemoveAttr(el, 'v-once');
  9966. if (once != null) {
  9967. el.once = true;
  9968. }
  9969. }
  9970. // handle content being passed to a component as slot,
  9971. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9972. function processSlotContent(el) {
  9973. let slotScope;
  9974. if (el.tag === 'template') {
  9975. slotScope = getAndRemoveAttr(el, 'scope');
  9976. /* istanbul ignore if */
  9977. if (slotScope) {
  9978. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  9979. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  9980. `can also be used on plain elements in addition to <template> to ` +
  9981. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  9982. }
  9983. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9984. }
  9985. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  9986. /* istanbul ignore if */
  9987. if (el.attrsMap['v-for']) {
  9988. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  9989. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  9990. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  9991. }
  9992. el.slotScope = slotScope;
  9993. }
  9994. // slot="xxx"
  9995. const slotTarget = getBindingAttr(el, 'slot');
  9996. if (slotTarget) {
  9997. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  9998. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  9999. // preserve slot as an attribute for native shadow DOM compat
  10000. // only for non-scoped slots.
  10001. if (el.tag !== 'template' && !el.slotScope) {
  10002. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10003. }
  10004. }
  10005. // 2.6 v-slot syntax
  10006. {
  10007. if (el.tag === 'template') {
  10008. // v-slot on <template>
  10009. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10010. if (slotBinding) {
  10011. {
  10012. if (el.slotTarget || el.slotScope) {
  10013. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10014. }
  10015. if (el.parent && !maybeComponent(el.parent)) {
  10016. warn(`<template v-slot> can only appear at the root level inside ` +
  10017. `the receiving component`, el);
  10018. }
  10019. }
  10020. const { name, dynamic } = getSlotName(slotBinding);
  10021. el.slotTarget = name;
  10022. el.slotTargetDynamic = dynamic;
  10023. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10024. }
  10025. }
  10026. else {
  10027. // v-slot on component, denotes default slot
  10028. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10029. if (slotBinding) {
  10030. {
  10031. if (!maybeComponent(el)) {
  10032. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10033. }
  10034. if (el.slotScope || el.slotTarget) {
  10035. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10036. }
  10037. if (el.scopedSlots) {
  10038. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10039. `<template> syntax when there are other named slots.`, slotBinding);
  10040. }
  10041. }
  10042. // add the component's children to its default slot
  10043. const slots = el.scopedSlots || (el.scopedSlots = {});
  10044. const { name, dynamic } = getSlotName(slotBinding);
  10045. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10046. slotContainer.slotTarget = name;
  10047. slotContainer.slotTargetDynamic = dynamic;
  10048. slotContainer.children = el.children.filter((c) => {
  10049. if (!c.slotScope) {
  10050. c.parent = slotContainer;
  10051. return true;
  10052. }
  10053. });
  10054. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10055. // remove children as they are returned from scopedSlots now
  10056. el.children = [];
  10057. // mark el non-plain so data gets generated
  10058. el.plain = false;
  10059. }
  10060. }
  10061. }
  10062. }
  10063. function getSlotName(binding) {
  10064. let name = binding.name.replace(slotRE, '');
  10065. if (!name) {
  10066. if (binding.name[0] !== '#') {
  10067. name = 'default';
  10068. }
  10069. else {
  10070. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10071. }
  10072. }
  10073. return dynamicArgRE.test(name)
  10074. ? // dynamic [name]
  10075. { name: name.slice(1, -1), dynamic: true }
  10076. : // static name
  10077. { name: `"${name}"`, dynamic: false };
  10078. }
  10079. // handle <slot/> outlets
  10080. function processSlotOutlet(el) {
  10081. if (el.tag === 'slot') {
  10082. el.slotName = getBindingAttr(el, 'name');
  10083. if (el.key) {
  10084. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10085. `and can possibly expand into multiple elements. ` +
  10086. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10087. }
  10088. }
  10089. }
  10090. function processComponent(el) {
  10091. let binding;
  10092. if ((binding = getBindingAttr(el, 'is'))) {
  10093. el.component = binding;
  10094. }
  10095. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10096. el.inlineTemplate = true;
  10097. }
  10098. }
  10099. function processAttrs(el) {
  10100. const list = el.attrsList;
  10101. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10102. for (i = 0, l = list.length; i < l; i++) {
  10103. name = rawName = list[i].name;
  10104. value = list[i].value;
  10105. if (dirRE.test(name)) {
  10106. // mark element as dynamic
  10107. el.hasBindings = true;
  10108. // modifiers
  10109. modifiers = parseModifiers(name.replace(dirRE, ''));
  10110. // support .foo shorthand syntax for the .prop modifier
  10111. if (modifiers) {
  10112. name = name.replace(modifierRE, '');
  10113. }
  10114. if (bindRE.test(name)) {
  10115. // v-bind
  10116. name = name.replace(bindRE, '');
  10117. value = parseFilters(value);
  10118. isDynamic = dynamicArgRE.test(name);
  10119. if (isDynamic) {
  10120. name = name.slice(1, -1);
  10121. }
  10122. if (value.trim().length === 0) {
  10123. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10124. }
  10125. if (modifiers) {
  10126. if (modifiers.prop && !isDynamic) {
  10127. name = camelize(name);
  10128. if (name === 'innerHtml')
  10129. name = 'innerHTML';
  10130. }
  10131. if (modifiers.camel && !isDynamic) {
  10132. name = camelize(name);
  10133. }
  10134. if (modifiers.sync) {
  10135. syncGen = genAssignmentCode(value, `$event`);
  10136. if (!isDynamic) {
  10137. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10138. if (hyphenate(name) !== camelize(name)) {
  10139. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10140. }
  10141. }
  10142. else {
  10143. // handler w/ dynamic event name
  10144. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10145. );
  10146. }
  10147. }
  10148. }
  10149. if ((modifiers && modifiers.prop) ||
  10150. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10151. addProp(el, name, value, list[i], isDynamic);
  10152. }
  10153. else {
  10154. addAttr(el, name, value, list[i], isDynamic);
  10155. }
  10156. }
  10157. else if (onRE.test(name)) {
  10158. // v-on
  10159. name = name.replace(onRE, '');
  10160. isDynamic = dynamicArgRE.test(name);
  10161. if (isDynamic) {
  10162. name = name.slice(1, -1);
  10163. }
  10164. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10165. }
  10166. else {
  10167. // normal directives
  10168. name = name.replace(dirRE, '');
  10169. // parse arg
  10170. const argMatch = name.match(argRE);
  10171. let arg = argMatch && argMatch[1];
  10172. isDynamic = false;
  10173. if (arg) {
  10174. name = name.slice(0, -(arg.length + 1));
  10175. if (dynamicArgRE.test(arg)) {
  10176. arg = arg.slice(1, -1);
  10177. isDynamic = true;
  10178. }
  10179. }
  10180. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10181. if (name === 'model') {
  10182. checkForAliasModel(el, value);
  10183. }
  10184. }
  10185. }
  10186. else {
  10187. // literal attribute
  10188. {
  10189. const res = parseText(value, delimiters);
  10190. if (res) {
  10191. warn(`${name}="${value}": ` +
  10192. 'Interpolation inside attributes has been removed. ' +
  10193. 'Use v-bind or the colon shorthand instead. For example, ' +
  10194. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10195. }
  10196. }
  10197. addAttr(el, name, JSON.stringify(value), list[i]);
  10198. // #6887 firefox doesn't update muted state if set via attribute
  10199. // even immediately after element creation
  10200. if (!el.component &&
  10201. name === 'muted' &&
  10202. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10203. addProp(el, name, 'true', list[i]);
  10204. }
  10205. }
  10206. }
  10207. }
  10208. function checkInFor(el) {
  10209. let parent = el;
  10210. while (parent) {
  10211. if (parent.for !== undefined) {
  10212. return true;
  10213. }
  10214. parent = parent.parent;
  10215. }
  10216. return false;
  10217. }
  10218. function parseModifiers(name) {
  10219. const match = name.match(modifierRE);
  10220. if (match) {
  10221. const ret = {};
  10222. match.forEach(m => {
  10223. ret[m.slice(1)] = true;
  10224. });
  10225. return ret;
  10226. }
  10227. }
  10228. function makeAttrsMap(attrs) {
  10229. const map = {};
  10230. for (let i = 0, l = attrs.length; i < l; i++) {
  10231. if (map[attrs[i].name] && !isIE && !isEdge) {
  10232. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10233. }
  10234. map[attrs[i].name] = attrs[i].value;
  10235. }
  10236. return map;
  10237. }
  10238. // for script (e.g. type="x/template") or style, do not decode content
  10239. function isTextTag(el) {
  10240. return el.tag === 'script' || el.tag === 'style';
  10241. }
  10242. function isForbiddenTag(el) {
  10243. return (el.tag === 'style' ||
  10244. (el.tag === 'script' &&
  10245. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10246. }
  10247. const ieNSBug = /^xmlns:NS\d+/;
  10248. const ieNSPrefix = /^NS\d+:/;
  10249. /* istanbul ignore next */
  10250. function guardIESVGBug(attrs) {
  10251. const res = [];
  10252. for (let i = 0; i < attrs.length; i++) {
  10253. const attr = attrs[i];
  10254. if (!ieNSBug.test(attr.name)) {
  10255. attr.name = attr.name.replace(ieNSPrefix, '');
  10256. res.push(attr);
  10257. }
  10258. }
  10259. return res;
  10260. }
  10261. function checkForAliasModel(el, value) {
  10262. let _el = el;
  10263. while (_el) {
  10264. if (_el.for && _el.alias === value) {
  10265. warn(`<${el.tag} v-model="${value}">: ` +
  10266. `You are binding v-model directly to a v-for iteration alias. ` +
  10267. `This will not be able to modify the v-for source array because ` +
  10268. `writing to the alias is like modifying a function local variable. ` +
  10269. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10270. }
  10271. _el = _el.parent;
  10272. }
  10273. }
  10274. /**
  10275. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10276. * Turn this:
  10277. * <input v-model="data[type]" :type="type">
  10278. * into this:
  10279. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10280. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10281. * <input v-else :type="type" v-model="data[type]">
  10282. */
  10283. function preTransformNode(el, options) {
  10284. if (el.tag === 'input') {
  10285. const map = el.attrsMap;
  10286. if (!map['v-model']) {
  10287. return;
  10288. }
  10289. let typeBinding;
  10290. if (map[':type'] || map['v-bind:type']) {
  10291. typeBinding = getBindingAttr(el, 'type');
  10292. }
  10293. if (!map.type && !typeBinding && map['v-bind']) {
  10294. typeBinding = `(${map['v-bind']}).type`;
  10295. }
  10296. if (typeBinding) {
  10297. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10298. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10299. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10300. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10301. // 1. checkbox
  10302. const branch0 = cloneASTElement(el);
  10303. // process for on the main node
  10304. processFor(branch0);
  10305. addRawAttr(branch0, 'type', 'checkbox');
  10306. processElement(branch0, options);
  10307. branch0.processed = true; // prevent it from double-processed
  10308. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10309. addIfCondition(branch0, {
  10310. exp: branch0.if,
  10311. block: branch0
  10312. });
  10313. // 2. add radio else-if condition
  10314. const branch1 = cloneASTElement(el);
  10315. getAndRemoveAttr(branch1, 'v-for', true);
  10316. addRawAttr(branch1, 'type', 'radio');
  10317. processElement(branch1, options);
  10318. addIfCondition(branch0, {
  10319. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10320. block: branch1
  10321. });
  10322. // 3. other
  10323. const branch2 = cloneASTElement(el);
  10324. getAndRemoveAttr(branch2, 'v-for', true);
  10325. addRawAttr(branch2, ':type', typeBinding);
  10326. processElement(branch2, options);
  10327. addIfCondition(branch0, {
  10328. exp: ifCondition,
  10329. block: branch2
  10330. });
  10331. if (hasElse) {
  10332. branch0.else = true;
  10333. }
  10334. else if (elseIfCondition) {
  10335. branch0.elseif = elseIfCondition;
  10336. }
  10337. return branch0;
  10338. }
  10339. }
  10340. }
  10341. function cloneASTElement(el) {
  10342. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10343. }
  10344. var model = {
  10345. preTransformNode
  10346. };
  10347. var modules = [klass, style, model];
  10348. function text(el, dir) {
  10349. if (dir.value) {
  10350. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10351. }
  10352. }
  10353. function html(el, dir) {
  10354. if (dir.value) {
  10355. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10356. }
  10357. }
  10358. var directives = {
  10359. model: model$1,
  10360. text,
  10361. html
  10362. };
  10363. const baseOptions = {
  10364. expectHTML: true,
  10365. modules,
  10366. directives,
  10367. isPreTag,
  10368. isUnaryTag,
  10369. mustUseProp,
  10370. canBeLeftOpenTag,
  10371. isReservedTag,
  10372. getTagNamespace,
  10373. staticKeys: genStaticKeys$1(modules)
  10374. };
  10375. let isStaticKey;
  10376. let isPlatformReservedTag;
  10377. const genStaticKeysCached = cached(genStaticKeys);
  10378. /**
  10379. * Goal of the optimizer: walk the generated template AST tree
  10380. * and detect sub-trees that are purely static, i.e. parts of
  10381. * the DOM that never needs to change.
  10382. *
  10383. * Once we detect these sub-trees, we can:
  10384. *
  10385. * 1. Hoist them into constants, so that we no longer need to
  10386. * create fresh nodes for them on each re-render;
  10387. * 2. Completely skip them in the patching process.
  10388. */
  10389. function optimize(root, options) {
  10390. if (!root)
  10391. return;
  10392. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10393. isPlatformReservedTag = options.isReservedTag || no;
  10394. // first pass: mark all non-static nodes.
  10395. markStatic(root);
  10396. // second pass: mark static roots.
  10397. markStaticRoots(root, false);
  10398. }
  10399. function genStaticKeys(keys) {
  10400. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10401. (keys ? ',' + keys : ''));
  10402. }
  10403. function markStatic(node) {
  10404. node.static = isStatic(node);
  10405. if (node.type === 1) {
  10406. // do not make component slot content static. this avoids
  10407. // 1. components not able to mutate slot nodes
  10408. // 2. static slot content fails for hot-reloading
  10409. if (!isPlatformReservedTag(node.tag) &&
  10410. node.tag !== 'slot' &&
  10411. node.attrsMap['inline-template'] == null) {
  10412. return;
  10413. }
  10414. for (let i = 0, l = node.children.length; i < l; i++) {
  10415. const child = node.children[i];
  10416. markStatic(child);
  10417. if (!child.static) {
  10418. node.static = false;
  10419. }
  10420. }
  10421. if (node.ifConditions) {
  10422. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10423. const block = node.ifConditions[i].block;
  10424. markStatic(block);
  10425. if (!block.static) {
  10426. node.static = false;
  10427. }
  10428. }
  10429. }
  10430. }
  10431. }
  10432. function markStaticRoots(node, isInFor) {
  10433. if (node.type === 1) {
  10434. if (node.static || node.once) {
  10435. node.staticInFor = isInFor;
  10436. }
  10437. // For a node to qualify as a static root, it should have children that
  10438. // are not just static text. Otherwise the cost of hoisting out will
  10439. // outweigh the benefits and it's better off to just always render it fresh.
  10440. if (node.static &&
  10441. node.children.length &&
  10442. !(node.children.length === 1 && node.children[0].type === 3)) {
  10443. node.staticRoot = true;
  10444. return;
  10445. }
  10446. else {
  10447. node.staticRoot = false;
  10448. }
  10449. if (node.children) {
  10450. for (let i = 0, l = node.children.length; i < l; i++) {
  10451. markStaticRoots(node.children[i], isInFor || !!node.for);
  10452. }
  10453. }
  10454. if (node.ifConditions) {
  10455. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10456. markStaticRoots(node.ifConditions[i].block, isInFor);
  10457. }
  10458. }
  10459. }
  10460. }
  10461. function isStatic(node) {
  10462. if (node.type === 2) {
  10463. // expression
  10464. return false;
  10465. }
  10466. if (node.type === 3) {
  10467. // text
  10468. return true;
  10469. }
  10470. return !!(node.pre ||
  10471. (!node.hasBindings && // no dynamic bindings
  10472. !node.if &&
  10473. !node.for && // not v-if or v-for or v-else
  10474. !isBuiltInTag(node.tag) && // not a built-in
  10475. isPlatformReservedTag(node.tag) && // not a component
  10476. !isDirectChildOfTemplateFor(node) &&
  10477. Object.keys(node).every(isStaticKey)));
  10478. }
  10479. function isDirectChildOfTemplateFor(node) {
  10480. while (node.parent) {
  10481. node = node.parent;
  10482. if (node.tag !== 'template') {
  10483. return false;
  10484. }
  10485. if (node.for) {
  10486. return true;
  10487. }
  10488. }
  10489. return false;
  10490. }
  10491. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10492. const fnInvokeRE = /\([^)]*?\);*$/;
  10493. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10494. // KeyboardEvent.keyCode aliases
  10495. const keyCodes = {
  10496. esc: 27,
  10497. tab: 9,
  10498. enter: 13,
  10499. space: 32,
  10500. up: 38,
  10501. left: 37,
  10502. right: 39,
  10503. down: 40,
  10504. delete: [8, 46]
  10505. };
  10506. // KeyboardEvent.key aliases
  10507. const keyNames = {
  10508. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10509. esc: ['Esc', 'Escape'],
  10510. tab: 'Tab',
  10511. enter: 'Enter',
  10512. // #9112: IE11 uses `Spacebar` for Space key name.
  10513. space: [' ', 'Spacebar'],
  10514. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10515. up: ['Up', 'ArrowUp'],
  10516. left: ['Left', 'ArrowLeft'],
  10517. right: ['Right', 'ArrowRight'],
  10518. down: ['Down', 'ArrowDown'],
  10519. // #9112: IE11 uses `Del` for Delete key name.
  10520. delete: ['Backspace', 'Delete', 'Del']
  10521. };
  10522. // #4868: modifiers that prevent the execution of the listener
  10523. // need to explicitly return null so that we can determine whether to remove
  10524. // the listener for .once
  10525. const genGuard = condition => `if(${condition})return null;`;
  10526. const modifierCode = {
  10527. stop: '$event.stopPropagation();',
  10528. prevent: '$event.preventDefault();',
  10529. self: genGuard(`$event.target !== $event.currentTarget`),
  10530. ctrl: genGuard(`!$event.ctrlKey`),
  10531. shift: genGuard(`!$event.shiftKey`),
  10532. alt: genGuard(`!$event.altKey`),
  10533. meta: genGuard(`!$event.metaKey`),
  10534. left: genGuard(`'button' in $event && $event.button !== 0`),
  10535. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10536. right: genGuard(`'button' in $event && $event.button !== 2`)
  10537. };
  10538. function genHandlers(events, isNative) {
  10539. const prefix = isNative ? 'nativeOn:' : 'on:';
  10540. let staticHandlers = ``;
  10541. let dynamicHandlers = ``;
  10542. for (const name in events) {
  10543. const handlerCode = genHandler(events[name]);
  10544. //@ts-expect-error
  10545. if (events[name] && events[name].dynamic) {
  10546. dynamicHandlers += `${name},${handlerCode},`;
  10547. }
  10548. else {
  10549. staticHandlers += `"${name}":${handlerCode},`;
  10550. }
  10551. }
  10552. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10553. if (dynamicHandlers) {
  10554. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10555. }
  10556. else {
  10557. return prefix + staticHandlers;
  10558. }
  10559. }
  10560. function genHandler(handler) {
  10561. if (!handler) {
  10562. return 'function(){}';
  10563. }
  10564. if (Array.isArray(handler)) {
  10565. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10566. }
  10567. const isMethodPath = simplePathRE.test(handler.value);
  10568. const isFunctionExpression = fnExpRE.test(handler.value);
  10569. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10570. if (!handler.modifiers) {
  10571. if (isMethodPath || isFunctionExpression) {
  10572. return handler.value;
  10573. }
  10574. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10575. }
  10576. else {
  10577. let code = '';
  10578. let genModifierCode = '';
  10579. const keys = [];
  10580. for (const key in handler.modifiers) {
  10581. if (modifierCode[key]) {
  10582. genModifierCode += modifierCode[key];
  10583. // left/right
  10584. if (keyCodes[key]) {
  10585. keys.push(key);
  10586. }
  10587. }
  10588. else if (key === 'exact') {
  10589. const modifiers = handler.modifiers;
  10590. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10591. .filter(keyModifier => !modifiers[keyModifier])
  10592. .map(keyModifier => `$event.${keyModifier}Key`)
  10593. .join('||'));
  10594. }
  10595. else {
  10596. keys.push(key);
  10597. }
  10598. }
  10599. if (keys.length) {
  10600. code += genKeyFilter(keys);
  10601. }
  10602. // Make sure modifiers like prevent and stop get executed after key filtering
  10603. if (genModifierCode) {
  10604. code += genModifierCode;
  10605. }
  10606. const handlerCode = isMethodPath
  10607. ? `return ${handler.value}.apply(null, arguments)`
  10608. : isFunctionExpression
  10609. ? `return (${handler.value}).apply(null, arguments)`
  10610. : isFunctionInvocation
  10611. ? `return ${handler.value}`
  10612. : handler.value;
  10613. return `function($event){${code}${handlerCode}}`;
  10614. }
  10615. }
  10616. function genKeyFilter(keys) {
  10617. return (
  10618. // make sure the key filters only apply to KeyboardEvents
  10619. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10620. // key events that do not have keyCode property...
  10621. `if(!$event.type.indexOf('key')&&` +
  10622. `${keys.map(genFilterCode).join('&&')})return null;`);
  10623. }
  10624. function genFilterCode(key) {
  10625. const keyVal = parseInt(key, 10);
  10626. if (keyVal) {
  10627. return `$event.keyCode!==${keyVal}`;
  10628. }
  10629. const keyCode = keyCodes[key];
  10630. const keyName = keyNames[key];
  10631. return (`_k($event.keyCode,` +
  10632. `${JSON.stringify(key)},` +
  10633. `${JSON.stringify(keyCode)},` +
  10634. `$event.key,` +
  10635. `${JSON.stringify(keyName)}` +
  10636. `)`);
  10637. }
  10638. function on(el, dir) {
  10639. if (dir.modifiers) {
  10640. warn$2(`v-on without argument does not support modifiers.`);
  10641. }
  10642. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10643. }
  10644. function bind(el, dir) {
  10645. el.wrapData = (code) => {
  10646. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10647. };
  10648. }
  10649. var baseDirectives = {
  10650. on,
  10651. bind,
  10652. cloak: noop
  10653. };
  10654. class CodegenState {
  10655. constructor(options) {
  10656. this.options = options;
  10657. this.warn = options.warn || baseWarn;
  10658. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10659. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10660. this.directives = extend(extend({}, baseDirectives), options.directives);
  10661. const isReservedTag = options.isReservedTag || no;
  10662. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10663. this.onceId = 0;
  10664. this.staticRenderFns = [];
  10665. this.pre = false;
  10666. }
  10667. }
  10668. function generate(ast, options) {
  10669. const state = new CodegenState(options);
  10670. // fix #11483, Root level <script> tags should not be rendered.
  10671. const code = ast
  10672. ? ast.tag === 'script'
  10673. ? 'null'
  10674. : genElement(ast, state)
  10675. : '_c("div")';
  10676. return {
  10677. render: `with(this){return ${code}}`,
  10678. staticRenderFns: state.staticRenderFns
  10679. };
  10680. }
  10681. function genElement(el, state) {
  10682. if (el.parent) {
  10683. el.pre = el.pre || el.parent.pre;
  10684. }
  10685. if (el.staticRoot && !el.staticProcessed) {
  10686. return genStatic(el, state);
  10687. }
  10688. else if (el.once && !el.onceProcessed) {
  10689. return genOnce(el, state);
  10690. }
  10691. else if (el.for && !el.forProcessed) {
  10692. return genFor(el, state);
  10693. }
  10694. else if (el.if && !el.ifProcessed) {
  10695. return genIf(el, state);
  10696. }
  10697. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10698. return genChildren(el, state) || 'void 0';
  10699. }
  10700. else if (el.tag === 'slot') {
  10701. return genSlot(el, state);
  10702. }
  10703. else {
  10704. // component or element
  10705. let code;
  10706. if (el.component) {
  10707. code = genComponent(el.component, el, state);
  10708. }
  10709. else {
  10710. let data;
  10711. const maybeComponent = state.maybeComponent(el);
  10712. if (!el.plain || (el.pre && maybeComponent)) {
  10713. data = genData(el, state);
  10714. }
  10715. let tag;
  10716. // check if this is a component in <script setup>
  10717. const bindings = state.options.bindings;
  10718. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10719. tag = checkBindingType(bindings, el.tag);
  10720. }
  10721. if (!tag)
  10722. tag = `'${el.tag}'`;
  10723. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10724. code = `_c(${tag}${data ? `,${data}` : '' // data
  10725. }${children ? `,${children}` : '' // children
  10726. })`;
  10727. }
  10728. // module transforms
  10729. for (let i = 0; i < state.transforms.length; i++) {
  10730. code = state.transforms[i](el, code);
  10731. }
  10732. return code;
  10733. }
  10734. }
  10735. function checkBindingType(bindings, key) {
  10736. const camelName = camelize(key);
  10737. const PascalName = capitalize(camelName);
  10738. const checkType = (type) => {
  10739. if (bindings[key] === type) {
  10740. return key;
  10741. }
  10742. if (bindings[camelName] === type) {
  10743. return camelName;
  10744. }
  10745. if (bindings[PascalName] === type) {
  10746. return PascalName;
  10747. }
  10748. };
  10749. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10750. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10751. if (fromConst) {
  10752. return fromConst;
  10753. }
  10754. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10755. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10756. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10757. if (fromMaybeRef) {
  10758. return fromMaybeRef;
  10759. }
  10760. }
  10761. // hoist static sub-trees out
  10762. function genStatic(el, state) {
  10763. el.staticProcessed = true;
  10764. // Some elements (templates) need to behave differently inside of a v-pre
  10765. // node. All pre nodes are static roots, so we can use this as a location to
  10766. // wrap a state change and reset it upon exiting the pre node.
  10767. const originalPreState = state.pre;
  10768. if (el.pre) {
  10769. state.pre = el.pre;
  10770. }
  10771. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10772. state.pre = originalPreState;
  10773. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10774. }
  10775. // v-once
  10776. function genOnce(el, state) {
  10777. el.onceProcessed = true;
  10778. if (el.if && !el.ifProcessed) {
  10779. return genIf(el, state);
  10780. }
  10781. else if (el.staticInFor) {
  10782. let key = '';
  10783. let parent = el.parent;
  10784. while (parent) {
  10785. if (parent.for) {
  10786. key = parent.key;
  10787. break;
  10788. }
  10789. parent = parent.parent;
  10790. }
  10791. if (!key) {
  10792. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10793. return genElement(el, state);
  10794. }
  10795. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10796. }
  10797. else {
  10798. return genStatic(el, state);
  10799. }
  10800. }
  10801. function genIf(el, state, altGen, altEmpty) {
  10802. el.ifProcessed = true; // avoid recursion
  10803. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10804. }
  10805. function genIfConditions(conditions, state, altGen, altEmpty) {
  10806. if (!conditions.length) {
  10807. return altEmpty || '_e()';
  10808. }
  10809. const condition = conditions.shift();
  10810. if (condition.exp) {
  10811. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10812. }
  10813. else {
  10814. return `${genTernaryExp(condition.block)}`;
  10815. }
  10816. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10817. function genTernaryExp(el) {
  10818. return altGen
  10819. ? altGen(el, state)
  10820. : el.once
  10821. ? genOnce(el, state)
  10822. : genElement(el, state);
  10823. }
  10824. }
  10825. function genFor(el, state, altGen, altHelper) {
  10826. const exp = el.for;
  10827. const alias = el.alias;
  10828. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10829. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10830. if (state.maybeComponent(el) &&
  10831. el.tag !== 'slot' &&
  10832. el.tag !== 'template' &&
  10833. !el.key) {
  10834. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10835. `v-for should have explicit keys. ` +
  10836. `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10837. }
  10838. el.forProcessed = true; // avoid recursion
  10839. return (`${altHelper || '_l'}((${exp}),` +
  10840. `function(${alias}${iterator1}${iterator2}){` +
  10841. `return ${(altGen || genElement)(el, state)}` +
  10842. '})');
  10843. }
  10844. function genData(el, state) {
  10845. let data = '{';
  10846. // directives first.
  10847. // directives may mutate the el's other properties before they are generated.
  10848. const dirs = genDirectives(el, state);
  10849. if (dirs)
  10850. data += dirs + ',';
  10851. // key
  10852. if (el.key) {
  10853. data += `key:${el.key},`;
  10854. }
  10855. // ref
  10856. if (el.ref) {
  10857. data += `ref:${el.ref},`;
  10858. }
  10859. if (el.refInFor) {
  10860. data += `refInFor:true,`;
  10861. }
  10862. // pre
  10863. if (el.pre) {
  10864. data += `pre:true,`;
  10865. }
  10866. // record original tag name for components using "is" attribute
  10867. if (el.component) {
  10868. data += `tag:"${el.tag}",`;
  10869. }
  10870. // module data generation functions
  10871. for (let i = 0; i < state.dataGenFns.length; i++) {
  10872. data += state.dataGenFns[i](el);
  10873. }
  10874. // attributes
  10875. if (el.attrs) {
  10876. data += `attrs:${genProps(el.attrs)},`;
  10877. }
  10878. // DOM props
  10879. if (el.props) {
  10880. data += `domProps:${genProps(el.props)},`;
  10881. }
  10882. // event handlers
  10883. if (el.events) {
  10884. data += `${genHandlers(el.events, false)},`;
  10885. }
  10886. if (el.nativeEvents) {
  10887. data += `${genHandlers(el.nativeEvents, true)},`;
  10888. }
  10889. // slot target
  10890. // only for non-scoped slots
  10891. if (el.slotTarget && !el.slotScope) {
  10892. data += `slot:${el.slotTarget},`;
  10893. }
  10894. // scoped slots
  10895. if (el.scopedSlots) {
  10896. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10897. }
  10898. // component v-model
  10899. if (el.model) {
  10900. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10901. }
  10902. // inline-template
  10903. if (el.inlineTemplate) {
  10904. const inlineTemplate = genInlineTemplate(el, state);
  10905. if (inlineTemplate) {
  10906. data += `${inlineTemplate},`;
  10907. }
  10908. }
  10909. data = data.replace(/,$/, '') + '}';
  10910. // v-bind dynamic argument wrap
  10911. // v-bind with dynamic arguments must be applied using the same v-bind object
  10912. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10913. if (el.dynamicAttrs) {
  10914. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10915. }
  10916. // v-bind data wrap
  10917. if (el.wrapData) {
  10918. data = el.wrapData(data);
  10919. }
  10920. // v-on data wrap
  10921. if (el.wrapListeners) {
  10922. data = el.wrapListeners(data);
  10923. }
  10924. return data;
  10925. }
  10926. function genDirectives(el, state) {
  10927. const dirs = el.directives;
  10928. if (!dirs)
  10929. return;
  10930. let res = 'directives:[';
  10931. let hasRuntime = false;
  10932. let i, l, dir, needRuntime;
  10933. for (i = 0, l = dirs.length; i < l; i++) {
  10934. dir = dirs[i];
  10935. needRuntime = true;
  10936. const gen = state.directives[dir.name];
  10937. if (gen) {
  10938. // compile-time directive that manipulates AST.
  10939. // returns true if it also needs a runtime counterpart.
  10940. needRuntime = !!gen(el, dir, state.warn);
  10941. }
  10942. if (needRuntime) {
  10943. hasRuntime = true;
  10944. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  10945. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  10946. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  10947. }
  10948. }
  10949. if (hasRuntime) {
  10950. return res.slice(0, -1) + ']';
  10951. }
  10952. }
  10953. function genInlineTemplate(el, state) {
  10954. const ast = el.children[0];
  10955. if ((el.children.length !== 1 || ast.type !== 1)) {
  10956. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  10957. }
  10958. if (ast && ast.type === 1) {
  10959. const inlineRenderFns = generate(ast, state.options);
  10960. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  10961. .map(code => `function(){${code}}`)
  10962. .join(',')}]}`;
  10963. }
  10964. }
  10965. function genScopedSlots(el, slots, state) {
  10966. // by default scoped slots are considered "stable", this allows child
  10967. // components with only scoped slots to skip forced updates from parent.
  10968. // but in some cases we have to bail-out of this optimization
  10969. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10970. let needsForceUpdate = el.for ||
  10971. Object.keys(slots).some(key => {
  10972. const slot = slots[key];
  10973. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10974. );
  10975. });
  10976. // #9534: if a component with scoped slots is inside a conditional branch,
  10977. // it's possible for the same component to be reused but with different
  10978. // compiled slot content. To avoid that, we generate a unique key based on
  10979. // the generated code of all the slot contents.
  10980. let needsKey = !!el.if;
  10981. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10982. // disconnected due to the intermediate scope variable)
  10983. // #9438, #9506
  10984. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10985. // and skip force updating ones that do not actually use scope variables.
  10986. if (!needsForceUpdate) {
  10987. let parent = el.parent;
  10988. while (parent) {
  10989. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  10990. parent.for) {
  10991. needsForceUpdate = true;
  10992. break;
  10993. }
  10994. if (parent.if) {
  10995. needsKey = true;
  10996. }
  10997. parent = parent.parent;
  10998. }
  10999. }
  11000. const generatedSlots = Object.keys(slots)
  11001. .map(key => genScopedSlot(slots[key], state))
  11002. .join(',');
  11003. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11004. }
  11005. function hash(str) {
  11006. let hash = 5381;
  11007. let i = str.length;
  11008. while (i) {
  11009. hash = (hash * 33) ^ str.charCodeAt(--i);
  11010. }
  11011. return hash >>> 0;
  11012. }
  11013. function containsSlotChild(el) {
  11014. if (el.type === 1) {
  11015. if (el.tag === 'slot') {
  11016. return true;
  11017. }
  11018. return el.children.some(containsSlotChild);
  11019. }
  11020. return false;
  11021. }
  11022. function genScopedSlot(el, state) {
  11023. const isLegacySyntax = el.attrsMap['slot-scope'];
  11024. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11025. return genIf(el, state, genScopedSlot, `null`);
  11026. }
  11027. if (el.for && !el.forProcessed) {
  11028. return genFor(el, state, genScopedSlot);
  11029. }
  11030. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11031. const fn = `function(${slotScope}){` +
  11032. `return ${el.tag === 'template'
  11033. ? el.if && isLegacySyntax
  11034. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11035. : genChildren(el, state) || 'undefined'
  11036. : genElement(el, state)}}`;
  11037. // reverse proxy v-slot without scope on this.$slots
  11038. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11039. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11040. }
  11041. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11042. const children = el.children;
  11043. if (children.length) {
  11044. const el = children[0];
  11045. // optimize single v-for
  11046. if (children.length === 1 &&
  11047. el.for &&
  11048. el.tag !== 'template' &&
  11049. el.tag !== 'slot') {
  11050. const normalizationType = checkSkip
  11051. ? state.maybeComponent(el)
  11052. ? `,1`
  11053. : `,0`
  11054. : ``;
  11055. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11056. }
  11057. const normalizationType = checkSkip
  11058. ? getNormalizationType(children, state.maybeComponent)
  11059. : 0;
  11060. const gen = altGenNode || genNode;
  11061. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11062. }
  11063. }
  11064. // determine the normalization needed for the children array.
  11065. // 0: no normalization needed
  11066. // 1: simple normalization needed (possible 1-level deep nested array)
  11067. // 2: full normalization needed
  11068. function getNormalizationType(children, maybeComponent) {
  11069. let res = 0;
  11070. for (let i = 0; i < children.length; i++) {
  11071. const el = children[i];
  11072. if (el.type !== 1) {
  11073. continue;
  11074. }
  11075. if (needsNormalization(el) ||
  11076. (el.ifConditions &&
  11077. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11078. res = 2;
  11079. break;
  11080. }
  11081. if (maybeComponent(el) ||
  11082. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11083. res = 1;
  11084. }
  11085. }
  11086. return res;
  11087. }
  11088. function needsNormalization(el) {
  11089. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11090. }
  11091. function genNode(node, state) {
  11092. if (node.type === 1) {
  11093. return genElement(node, state);
  11094. }
  11095. else if (node.type === 3 && node.isComment) {
  11096. return genComment(node);
  11097. }
  11098. else {
  11099. return genText(node);
  11100. }
  11101. }
  11102. function genText(text) {
  11103. return `_v(${text.type === 2
  11104. ? text.expression // no need for () because already wrapped in _s()
  11105. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11106. }
  11107. function genComment(comment) {
  11108. return `_e(${JSON.stringify(comment.text)})`;
  11109. }
  11110. function genSlot(el, state) {
  11111. const slotName = el.slotName || '"default"';
  11112. const children = genChildren(el, state);
  11113. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11114. const attrs = el.attrs || el.dynamicAttrs
  11115. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11116. // slot props are camelized
  11117. name: camelize(attr.name),
  11118. value: attr.value,
  11119. dynamic: attr.dynamic
  11120. })))
  11121. : null;
  11122. const bind = el.attrsMap['v-bind'];
  11123. if ((attrs || bind) && !children) {
  11124. res += `,null`;
  11125. }
  11126. if (attrs) {
  11127. res += `,${attrs}`;
  11128. }
  11129. if (bind) {
  11130. res += `${attrs ? '' : ',null'},${bind}`;
  11131. }
  11132. return res + ')';
  11133. }
  11134. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11135. function genComponent(componentName, el, state) {
  11136. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11137. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11138. }
  11139. function genProps(props) {
  11140. let staticProps = ``;
  11141. let dynamicProps = ``;
  11142. for (let i = 0; i < props.length; i++) {
  11143. const prop = props[i];
  11144. const value = transformSpecialNewlines(prop.value);
  11145. if (prop.dynamic) {
  11146. dynamicProps += `${prop.name},${value},`;
  11147. }
  11148. else {
  11149. staticProps += `"${prop.name}":${value},`;
  11150. }
  11151. }
  11152. staticProps = `{${staticProps.slice(0, -1)}}`;
  11153. if (dynamicProps) {
  11154. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11155. }
  11156. else {
  11157. return staticProps;
  11158. }
  11159. }
  11160. // #3895, #4268
  11161. function transformSpecialNewlines(text) {
  11162. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11163. }
  11164. // these keywords should not appear inside expressions, but operators like
  11165. // typeof, instanceof and in are allowed
  11166. const prohibitedKeywordRE = new RegExp('\\b' +
  11167. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11168. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11169. 'extends,finally,continue,debugger,function,arguments')
  11170. .split(',')
  11171. .join('\\b|\\b') +
  11172. '\\b');
  11173. // these unary operators should not be used as property/method names
  11174. const unaryOperatorsRE = new RegExp('\\b' +
  11175. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11176. '\\s*\\([^\\)]*\\)');
  11177. // strip strings in expressions
  11178. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11179. // detect problematic expressions in a template
  11180. function detectErrors(ast, warn) {
  11181. if (ast) {
  11182. checkNode(ast, warn);
  11183. }
  11184. }
  11185. function checkNode(node, warn) {
  11186. if (node.type === 1) {
  11187. for (const name in node.attrsMap) {
  11188. if (dirRE.test(name)) {
  11189. const value = node.attrsMap[name];
  11190. if (value) {
  11191. const range = node.rawAttrsMap[name];
  11192. if (name === 'v-for') {
  11193. checkFor(node, `v-for="${value}"`, warn, range);
  11194. }
  11195. else if (name === 'v-slot' || name[0] === '#') {
  11196. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11197. }
  11198. else if (onRE.test(name)) {
  11199. checkEvent(value, `${name}="${value}"`, warn, range);
  11200. }
  11201. else {
  11202. checkExpression(value, `${name}="${value}"`, warn, range);
  11203. }
  11204. }
  11205. }
  11206. }
  11207. if (node.children) {
  11208. for (let i = 0; i < node.children.length; i++) {
  11209. checkNode(node.children[i], warn);
  11210. }
  11211. }
  11212. }
  11213. else if (node.type === 2) {
  11214. checkExpression(node.expression, node.text, warn, node);
  11215. }
  11216. }
  11217. function checkEvent(exp, text, warn, range) {
  11218. const stripped = exp.replace(stripStringRE, '');
  11219. const keywordMatch = stripped.match(unaryOperatorsRE);
  11220. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11221. warn(`avoid using JavaScript unary operator as property name: ` +
  11222. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11223. }
  11224. checkExpression(exp, text, warn, range);
  11225. }
  11226. function checkFor(node, text, warn, range) {
  11227. checkExpression(node.for || '', text, warn, range);
  11228. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11229. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11230. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11231. }
  11232. function checkIdentifier(ident, type, text, warn, range) {
  11233. if (typeof ident === 'string') {
  11234. try {
  11235. new Function(`var ${ident}=_`);
  11236. }
  11237. catch (e) {
  11238. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11239. }
  11240. }
  11241. }
  11242. function checkExpression(exp, text, warn, range) {
  11243. try {
  11244. new Function(`return ${exp}`);
  11245. }
  11246. catch (e) {
  11247. const keywordMatch = exp
  11248. .replace(stripStringRE, '')
  11249. .match(prohibitedKeywordRE);
  11250. if (keywordMatch) {
  11251. warn(`avoid using JavaScript keyword as property name: ` +
  11252. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11253. }
  11254. else {
  11255. warn(`invalid expression: ${e.message} in\n\n` +
  11256. ` ${exp}\n\n` +
  11257. ` Raw expression: ${text.trim()}\n`, range);
  11258. }
  11259. }
  11260. }
  11261. function checkFunctionParameterExpression(exp, text, warn, range) {
  11262. try {
  11263. new Function(exp, '');
  11264. }
  11265. catch (e) {
  11266. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11267. ` ${exp}\n\n` +
  11268. ` Raw expression: ${text.trim()}\n`, range);
  11269. }
  11270. }
  11271. const range = 2;
  11272. function generateCodeFrame(source, start = 0, end = source.length) {
  11273. const lines = source.split(/\r?\n/);
  11274. let count = 0;
  11275. const res = [];
  11276. for (let i = 0; i < lines.length; i++) {
  11277. count += lines[i].length + 1;
  11278. if (count >= start) {
  11279. for (let j = i - range; j <= i + range || end > count; j++) {
  11280. if (j < 0 || j >= lines.length)
  11281. continue;
  11282. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11283. const lineLength = lines[j].length;
  11284. if (j === i) {
  11285. // push underline
  11286. const pad = start - (count - lineLength) + 1;
  11287. const length = end > count ? lineLength - pad : end - start;
  11288. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11289. }
  11290. else if (j > i) {
  11291. if (end > count) {
  11292. const length = Math.min(end - count, lineLength);
  11293. res.push(` | ` + repeat(`^`, length));
  11294. }
  11295. count += lineLength + 1;
  11296. }
  11297. }
  11298. break;
  11299. }
  11300. }
  11301. return res.join('\n');
  11302. }
  11303. function repeat(str, n) {
  11304. let result = '';
  11305. if (n > 0) {
  11306. // eslint-disable-next-line no-constant-condition
  11307. while (true) {
  11308. // eslint-disable-line
  11309. if (n & 1)
  11310. result += str;
  11311. n >>>= 1;
  11312. if (n <= 0)
  11313. break;
  11314. str += str;
  11315. }
  11316. }
  11317. return result;
  11318. }
  11319. function createFunction(code, errors) {
  11320. try {
  11321. return new Function(code);
  11322. }
  11323. catch (err) {
  11324. errors.push({ err, code });
  11325. return noop;
  11326. }
  11327. }
  11328. function createCompileToFunctionFn(compile) {
  11329. const cache = Object.create(null);
  11330. return function compileToFunctions(template, options, vm) {
  11331. options = extend({}, options);
  11332. const warn = options.warn || warn$2;
  11333. delete options.warn;
  11334. /* istanbul ignore if */
  11335. {
  11336. // detect possible CSP restriction
  11337. try {
  11338. new Function('return 1');
  11339. }
  11340. catch (e) {
  11341. if (e.toString().match(/unsafe-eval|CSP/)) {
  11342. warn('It seems you are using the standalone build of Vue.js in an ' +
  11343. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11344. 'The template compiler cannot work in this environment. Consider ' +
  11345. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11346. 'templates into render functions.');
  11347. }
  11348. }
  11349. }
  11350. // check cache
  11351. const key = options.delimiters
  11352. ? String(options.delimiters) + template
  11353. : template;
  11354. if (cache[key]) {
  11355. return cache[key];
  11356. }
  11357. // compile
  11358. const compiled = compile(template, options);
  11359. // check compilation errors/tips
  11360. {
  11361. if (compiled.errors && compiled.errors.length) {
  11362. if (options.outputSourceRange) {
  11363. compiled.errors.forEach(e => {
  11364. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11365. generateCodeFrame(template, e.start, e.end), vm);
  11366. });
  11367. }
  11368. else {
  11369. warn(`Error compiling template:\n\n${template}\n\n` +
  11370. compiled.errors.map(e => `- ${e}`).join('\n') +
  11371. '\n', vm);
  11372. }
  11373. }
  11374. if (compiled.tips && compiled.tips.length) {
  11375. if (options.outputSourceRange) {
  11376. compiled.tips.forEach(e => tip(e.msg, vm));
  11377. }
  11378. else {
  11379. compiled.tips.forEach(msg => tip(msg, vm));
  11380. }
  11381. }
  11382. }
  11383. // turn code into functions
  11384. const res = {};
  11385. const fnGenErrors = [];
  11386. res.render = createFunction(compiled.render, fnGenErrors);
  11387. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11388. return createFunction(code, fnGenErrors);
  11389. });
  11390. // check function generation errors.
  11391. // this should only happen if there is a bug in the compiler itself.
  11392. // mostly for codegen development use
  11393. /* istanbul ignore if */
  11394. {
  11395. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11396. warn(`Failed to generate render function:\n\n` +
  11397. fnGenErrors
  11398. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11399. .join('\n'), vm);
  11400. }
  11401. }
  11402. return (cache[key] = res);
  11403. };
  11404. }
  11405. function createCompilerCreator(baseCompile) {
  11406. return function createCompiler(baseOptions) {
  11407. function compile(template, options) {
  11408. const finalOptions = Object.create(baseOptions);
  11409. const errors = [];
  11410. const tips = [];
  11411. let warn = (msg, range, tip) => {
  11412. (tip ? tips : errors).push(msg);
  11413. };
  11414. if (options) {
  11415. if (options.outputSourceRange) {
  11416. // $flow-disable-line
  11417. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11418. warn = (msg, range, tip) => {
  11419. const data = typeof msg === 'string' ? { msg } : msg;
  11420. if (range) {
  11421. if (range.start != null) {
  11422. data.start = range.start + leadingSpaceLength;
  11423. }
  11424. if (range.end != null) {
  11425. data.end = range.end + leadingSpaceLength;
  11426. }
  11427. }
  11428. (tip ? tips : errors).push(data);
  11429. };
  11430. }
  11431. // merge custom modules
  11432. if (options.modules) {
  11433. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11434. }
  11435. // merge custom directives
  11436. if (options.directives) {
  11437. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11438. }
  11439. // copy other options
  11440. for (const key in options) {
  11441. if (key !== 'modules' && key !== 'directives') {
  11442. finalOptions[key] = options[key];
  11443. }
  11444. }
  11445. }
  11446. finalOptions.warn = warn;
  11447. const compiled = baseCompile(template.trim(), finalOptions);
  11448. {
  11449. detectErrors(compiled.ast, warn);
  11450. }
  11451. compiled.errors = errors;
  11452. compiled.tips = tips;
  11453. return compiled;
  11454. }
  11455. return {
  11456. compile,
  11457. compileToFunctions: createCompileToFunctionFn(compile)
  11458. };
  11459. };
  11460. }
  11461. // `createCompilerCreator` allows creating compilers that use alternative
  11462. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11463. // Here we just export a default compiler using the default parts.
  11464. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11465. const ast = parse(template.trim(), options);
  11466. if (options.optimize !== false) {
  11467. optimize(ast, options);
  11468. }
  11469. const code = generate(ast, options);
  11470. return {
  11471. ast,
  11472. render: code.render,
  11473. staticRenderFns: code.staticRenderFns
  11474. };
  11475. });
  11476. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11477. // check whether current browser encodes a char inside attribute values
  11478. let div;
  11479. function getShouldDecode(href) {
  11480. div = div || document.createElement('div');
  11481. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11482. return div.innerHTML.indexOf('&#10;') > 0;
  11483. }
  11484. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11485. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11486. // #6828: chrome encodes content in a[href]
  11487. const shouldDecodeNewlinesForHref = inBrowser
  11488. ? getShouldDecode(true)
  11489. : false;
  11490. const idToTemplate = cached(id => {
  11491. const el = query(id);
  11492. return el && el.innerHTML;
  11493. });
  11494. const mount = Vue.prototype.$mount;
  11495. Vue.prototype.$mount = function (el, hydrating) {
  11496. el = el && query(el);
  11497. /* istanbul ignore if */
  11498. if (el === document.body || el === document.documentElement) {
  11499. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11500. return this;
  11501. }
  11502. const options = this.$options;
  11503. // resolve template/el and convert to render function
  11504. if (!options.render) {
  11505. let template = options.template;
  11506. if (template) {
  11507. if (typeof template === 'string') {
  11508. if (template.charAt(0) === '#') {
  11509. template = idToTemplate(template);
  11510. /* istanbul ignore if */
  11511. if (!template) {
  11512. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11513. }
  11514. }
  11515. }
  11516. else if (template.nodeType) {
  11517. template = template.innerHTML;
  11518. }
  11519. else {
  11520. {
  11521. warn$2('invalid template option:' + template, this);
  11522. }
  11523. return this;
  11524. }
  11525. }
  11526. else if (el) {
  11527. // @ts-expect-error
  11528. template = getOuterHTML(el);
  11529. }
  11530. if (template) {
  11531. /* istanbul ignore if */
  11532. if (config.performance && mark) {
  11533. mark('compile');
  11534. }
  11535. const { render, staticRenderFns } = compileToFunctions(template, {
  11536. outputSourceRange: true,
  11537. shouldDecodeNewlines,
  11538. shouldDecodeNewlinesForHref,
  11539. delimiters: options.delimiters,
  11540. comments: options.comments
  11541. }, this);
  11542. options.render = render;
  11543. options.staticRenderFns = staticRenderFns;
  11544. /* istanbul ignore if */
  11545. if (config.performance && mark) {
  11546. mark('compile end');
  11547. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11548. }
  11549. }
  11550. }
  11551. return mount.call(this, el, hydrating);
  11552. };
  11553. /**
  11554. * Get outerHTML of elements, taking care
  11555. * of SVG elements in IE as well.
  11556. */
  11557. function getOuterHTML(el) {
  11558. if (el.outerHTML) {
  11559. return el.outerHTML;
  11560. }
  11561. else {
  11562. const container = document.createElement('div');
  11563. container.appendChild(el.cloneNode(true));
  11564. return container.innerHTML;
  11565. }
  11566. }
  11567. Vue.compile = compileToFunctions;
  11568. export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };