vue.common.dev.js 389 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785
  1. /*!
  2. * Vue.js v2.7.13
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray(list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret;
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend(to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to;
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject(arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res;
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop(a, b, c) { }
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys$1(modules) {
  243. return modules
  244. .reduce((keys, m) => {
  245. return keys.concat(m.staticKeys || []);
  246. }, [])
  247. .join(',');
  248. }
  249. /**
  250. * Check if two values are loosely equal - that is,
  251. * if they are plain objects, do they have the same shape?
  252. */
  253. function looseEqual(a, b) {
  254. if (a === b)
  255. return true;
  256. const isObjectA = isObject(a);
  257. const isObjectB = isObject(b);
  258. if (isObjectA && isObjectB) {
  259. try {
  260. const isArrayA = Array.isArray(a);
  261. const isArrayB = Array.isArray(b);
  262. if (isArrayA && isArrayB) {
  263. return (a.length === b.length &&
  264. a.every((e, i) => {
  265. return looseEqual(e, b[i]);
  266. }));
  267. }
  268. else if (a instanceof Date && b instanceof Date) {
  269. return a.getTime() === b.getTime();
  270. }
  271. else if (!isArrayA && !isArrayB) {
  272. const keysA = Object.keys(a);
  273. const keysB = Object.keys(b);
  274. return (keysA.length === keysB.length &&
  275. keysA.every(key => {
  276. return looseEqual(a[key], b[key]);
  277. }));
  278. }
  279. else {
  280. /* istanbul ignore next */
  281. return false;
  282. }
  283. }
  284. catch (e) {
  285. /* istanbul ignore next */
  286. return false;
  287. }
  288. }
  289. else if (!isObjectA && !isObjectB) {
  290. return String(a) === String(b);
  291. }
  292. else {
  293. return false;
  294. }
  295. }
  296. /**
  297. * Return the first index at which a loosely equal value can be
  298. * found in the array (if value is a plain object, the array must
  299. * contain an object of the same shape), or -1 if it is not present.
  300. */
  301. function looseIndexOf(arr, val) {
  302. for (let i = 0; i < arr.length; i++) {
  303. if (looseEqual(arr[i], val))
  304. return i;
  305. }
  306. return -1;
  307. }
  308. /**
  309. * Ensure a function is called only once.
  310. */
  311. function once(fn) {
  312. let called = false;
  313. return function () {
  314. if (!called) {
  315. called = true;
  316. fn.apply(this, arguments);
  317. }
  318. };
  319. }
  320. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  321. function hasChanged(x, y) {
  322. if (x === y) {
  323. return x === 0 && 1 / x !== 1 / y;
  324. }
  325. else {
  326. return x === x || y === y;
  327. }
  328. }
  329. const SSR_ATTR = 'data-server-rendered';
  330. const ASSET_TYPES = ['component', 'directive', 'filter'];
  331. const LIFECYCLE_HOOKS = [
  332. 'beforeCreate',
  333. 'created',
  334. 'beforeMount',
  335. 'mounted',
  336. 'beforeUpdate',
  337. 'updated',
  338. 'beforeDestroy',
  339. 'destroyed',
  340. 'activated',
  341. 'deactivated',
  342. 'errorCaptured',
  343. 'serverPrefetch',
  344. 'renderTracked',
  345. 'renderTriggered'
  346. ];
  347. var config = {
  348. /**
  349. * Option merge strategies (used in core/util/options)
  350. */
  351. // $flow-disable-line
  352. optionMergeStrategies: Object.create(null),
  353. /**
  354. * Whether to suppress warnings.
  355. */
  356. silent: false,
  357. /**
  358. * Show production mode tip message on boot?
  359. */
  360. productionTip: true,
  361. /**
  362. * Whether to enable devtools
  363. */
  364. devtools: true,
  365. /**
  366. * Whether to record perf
  367. */
  368. performance: false,
  369. /**
  370. * Error handler for watcher errors
  371. */
  372. errorHandler: null,
  373. /**
  374. * Warn handler for watcher warns
  375. */
  376. warnHandler: null,
  377. /**
  378. * Ignore certain custom elements
  379. */
  380. ignoredElements: [],
  381. /**
  382. * Custom user key aliases for v-on
  383. */
  384. // $flow-disable-line
  385. keyCodes: Object.create(null),
  386. /**
  387. * Check if a tag is reserved so that it cannot be registered as a
  388. * component. This is platform-dependent and may be overwritten.
  389. */
  390. isReservedTag: no,
  391. /**
  392. * Check if an attribute is reserved so that it cannot be used as a component
  393. * prop. This is platform-dependent and may be overwritten.
  394. */
  395. isReservedAttr: no,
  396. /**
  397. * Check if a tag is an unknown element.
  398. * Platform-dependent.
  399. */
  400. isUnknownElement: no,
  401. /**
  402. * Get the namespace of an element
  403. */
  404. getTagNamespace: noop,
  405. /**
  406. * Parse the real tag name for the specific platform.
  407. */
  408. parsePlatformTagName: identity,
  409. /**
  410. * Check if an attribute must be bound using property, e.g. value
  411. * Platform-dependent.
  412. */
  413. mustUseProp: no,
  414. /**
  415. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  416. * This will significantly reduce performance if set to false.
  417. */
  418. async: true,
  419. /**
  420. * Exposed for legacy reasons
  421. */
  422. _lifecycleHooks: LIFECYCLE_HOOKS
  423. };
  424. /**
  425. * unicode letters used for parsing html tags, component names and property paths.
  426. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  427. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  428. */
  429. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  430. /**
  431. * Check if a string starts with $ or _
  432. */
  433. function isReserved(str) {
  434. const c = (str + '').charCodeAt(0);
  435. return c === 0x24 || c === 0x5f;
  436. }
  437. /**
  438. * Define a property.
  439. */
  440. function def(obj, key, val, enumerable) {
  441. Object.defineProperty(obj, key, {
  442. value: val,
  443. enumerable: !!enumerable,
  444. writable: true,
  445. configurable: true
  446. });
  447. }
  448. /**
  449. * Parse simple path.
  450. */
  451. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  452. function parsePath(path) {
  453. if (bailRE.test(path)) {
  454. return;
  455. }
  456. const segments = path.split('.');
  457. return function (obj) {
  458. for (let i = 0; i < segments.length; i++) {
  459. if (!obj)
  460. return;
  461. obj = obj[segments[i]];
  462. }
  463. return obj;
  464. };
  465. }
  466. // can we use __proto__?
  467. const hasProto = '__proto__' in {};
  468. // Browser environment sniffing
  469. const inBrowser = typeof window !== 'undefined';
  470. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  471. const isIE = UA && /msie|trident/.test(UA);
  472. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  473. const isEdge = UA && UA.indexOf('edge/') > 0;
  474. UA && UA.indexOf('android') > 0;
  475. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  476. UA && /chrome\/\d+/.test(UA) && !isEdge;
  477. UA && /phantomjs/.test(UA);
  478. const isFF = UA && UA.match(/firefox\/(\d+)/);
  479. // Firefox has a "watch" function on Object.prototype...
  480. // @ts-expect-error firebox support
  481. const nativeWatch = {}.watch;
  482. let supportsPassive = false;
  483. if (inBrowser) {
  484. try {
  485. const opts = {};
  486. Object.defineProperty(opts, 'passive', {
  487. get() {
  488. /* istanbul ignore next */
  489. supportsPassive = true;
  490. }
  491. }); // https://github.com/facebook/flow/issues/285
  492. window.addEventListener('test-passive', null, opts);
  493. }
  494. catch (e) { }
  495. }
  496. // this needs to be lazy-evaled because vue may be required before
  497. // vue-server-renderer can set VUE_ENV
  498. let _isServer;
  499. const isServerRendering = () => {
  500. if (_isServer === undefined) {
  501. /* istanbul ignore if */
  502. if (!inBrowser && typeof global !== 'undefined') {
  503. // detect presence of vue-server-renderer and avoid
  504. // Webpack shimming the process
  505. _isServer =
  506. global['process'] && global['process'].env.VUE_ENV === 'server';
  507. }
  508. else {
  509. _isServer = false;
  510. }
  511. }
  512. return _isServer;
  513. };
  514. // detect devtools
  515. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  516. /* istanbul ignore next */
  517. function isNative(Ctor) {
  518. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  519. }
  520. const hasSymbol = typeof Symbol !== 'undefined' &&
  521. isNative(Symbol) &&
  522. typeof Reflect !== 'undefined' &&
  523. isNative(Reflect.ownKeys);
  524. let _Set; // $flow-disable-line
  525. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  526. // use native Set when available.
  527. _Set = Set;
  528. }
  529. else {
  530. // a non-standard Set polyfill that only works with primitive keys.
  531. _Set = class Set {
  532. constructor() {
  533. this.set = Object.create(null);
  534. }
  535. has(key) {
  536. return this.set[key] === true;
  537. }
  538. add(key) {
  539. this.set[key] = true;
  540. }
  541. clear() {
  542. this.set = Object.create(null);
  543. }
  544. };
  545. }
  546. let currentInstance = null;
  547. /**
  548. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  549. * relies on it). Do not use this internally, just use `currentInstance`.
  550. *
  551. * @internal this function needs manual type declaration because it relies
  552. * on previously manually authored types from Vue 2
  553. */
  554. function getCurrentInstance() {
  555. return currentInstance && { proxy: currentInstance };
  556. }
  557. /**
  558. * @internal
  559. */
  560. function setCurrentInstance(vm = null) {
  561. if (!vm)
  562. currentInstance && currentInstance._scope.off();
  563. currentInstance = vm;
  564. vm && vm._scope.on();
  565. }
  566. /**
  567. * @internal
  568. */
  569. class VNode {
  570. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  571. this.tag = tag;
  572. this.data = data;
  573. this.children = children;
  574. this.text = text;
  575. this.elm = elm;
  576. this.ns = undefined;
  577. this.context = context;
  578. this.fnContext = undefined;
  579. this.fnOptions = undefined;
  580. this.fnScopeId = undefined;
  581. this.key = data && data.key;
  582. this.componentOptions = componentOptions;
  583. this.componentInstance = undefined;
  584. this.parent = undefined;
  585. this.raw = false;
  586. this.isStatic = false;
  587. this.isRootInsert = true;
  588. this.isComment = false;
  589. this.isCloned = false;
  590. this.isOnce = false;
  591. this.asyncFactory = asyncFactory;
  592. this.asyncMeta = undefined;
  593. this.isAsyncPlaceholder = false;
  594. }
  595. // DEPRECATED: alias for componentInstance for backwards compat.
  596. /* istanbul ignore next */
  597. get child() {
  598. return this.componentInstance;
  599. }
  600. }
  601. const createEmptyVNode = (text = '') => {
  602. const node = new VNode();
  603. node.text = text;
  604. node.isComment = true;
  605. return node;
  606. };
  607. function createTextVNode(val) {
  608. return new VNode(undefined, undefined, undefined, String(val));
  609. }
  610. // optimized shallow clone
  611. // used for static nodes and slot nodes because they may be reused across
  612. // multiple renders, cloning them avoids errors when DOM manipulations rely
  613. // on their elm reference.
  614. function cloneVNode(vnode) {
  615. const cloned = new VNode(vnode.tag, vnode.data,
  616. // #7975
  617. // clone children array to avoid mutating original in case of cloning
  618. // a child.
  619. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  620. cloned.ns = vnode.ns;
  621. cloned.isStatic = vnode.isStatic;
  622. cloned.key = vnode.key;
  623. cloned.isComment = vnode.isComment;
  624. cloned.fnContext = vnode.fnContext;
  625. cloned.fnOptions = vnode.fnOptions;
  626. cloned.fnScopeId = vnode.fnScopeId;
  627. cloned.asyncMeta = vnode.asyncMeta;
  628. cloned.isCloned = true;
  629. return cloned;
  630. }
  631. /* not type checking this file because flow doesn't play well with Proxy */
  632. let initProxy;
  633. {
  634. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  635. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  636. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  637. 'require' // for Webpack/Browserify
  638. );
  639. const warnNonPresent = (target, key) => {
  640. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  641. 'referenced during render. Make sure that this property is reactive, ' +
  642. 'either in the data option, or for class-based components, by ' +
  643. 'initializing the property. ' +
  644. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  645. };
  646. const warnReservedPrefix = (target, key) => {
  647. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  648. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  649. 'prevent conflicts with Vue internals. ' +
  650. 'See: https://v2.vuejs.org/v2/api/#data', target);
  651. };
  652. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  653. if (hasProxy) {
  654. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  655. config.keyCodes = new Proxy(config.keyCodes, {
  656. set(target, key, value) {
  657. if (isBuiltInModifier(key)) {
  658. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  659. return false;
  660. }
  661. else {
  662. target[key] = value;
  663. return true;
  664. }
  665. }
  666. });
  667. }
  668. const hasHandler = {
  669. has(target, key) {
  670. const has = key in target;
  671. const isAllowed = allowedGlobals(key) ||
  672. (typeof key === 'string' &&
  673. key.charAt(0) === '_' &&
  674. !(key in target.$data));
  675. if (!has && !isAllowed) {
  676. if (key in target.$data)
  677. warnReservedPrefix(target, key);
  678. else
  679. warnNonPresent(target, key);
  680. }
  681. return has || !isAllowed;
  682. }
  683. };
  684. const getHandler = {
  685. get(target, key) {
  686. if (typeof key === 'string' && !(key in target)) {
  687. if (key in target.$data)
  688. warnReservedPrefix(target, key);
  689. else
  690. warnNonPresent(target, key);
  691. }
  692. return target[key];
  693. }
  694. };
  695. initProxy = function initProxy(vm) {
  696. if (hasProxy) {
  697. // determine which proxy handler to use
  698. const options = vm.$options;
  699. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  700. vm._renderProxy = new Proxy(vm, handlers);
  701. }
  702. else {
  703. vm._renderProxy = vm;
  704. }
  705. };
  706. }
  707. let uid$2 = 0;
  708. const pendingCleanupDeps = [];
  709. const cleanupDeps = () => {
  710. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  711. const dep = pendingCleanupDeps[i];
  712. dep.subs = dep.subs.filter(s => s);
  713. dep._pending = false;
  714. }
  715. pendingCleanupDeps.length = 0;
  716. };
  717. /**
  718. * A dep is an observable that can have multiple
  719. * directives subscribing to it.
  720. * @internal
  721. */
  722. class Dep {
  723. constructor() {
  724. // pending subs cleanup
  725. this._pending = false;
  726. this.id = uid$2++;
  727. this.subs = [];
  728. }
  729. addSub(sub) {
  730. this.subs.push(sub);
  731. }
  732. removeSub(sub) {
  733. // #12696 deps with massive amount of subscribers are extremely slow to
  734. // clean up in Chromium
  735. // to workaround this, we unset the sub for now, and clear them on
  736. // next scheduler flush.
  737. this.subs[this.subs.indexOf(sub)] = null;
  738. if (!this._pending) {
  739. this._pending = true;
  740. pendingCleanupDeps.push(this);
  741. }
  742. }
  743. depend(info) {
  744. if (Dep.target) {
  745. Dep.target.addDep(this);
  746. if (info && Dep.target.onTrack) {
  747. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  748. }
  749. }
  750. }
  751. notify(info) {
  752. // stabilize the subscriber list first
  753. const subs = this.subs.filter(s => s);
  754. if (!config.async) {
  755. // subs aren't sorted in scheduler if not running async
  756. // we need to sort them now to make sure they fire in correct
  757. // order
  758. subs.sort((a, b) => a.id - b.id);
  759. }
  760. for (let i = 0, l = subs.length; i < l; i++) {
  761. const sub = subs[i];
  762. if (info) {
  763. sub.onTrigger &&
  764. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  765. }
  766. sub.update();
  767. }
  768. }
  769. }
  770. // The current target watcher being evaluated.
  771. // This is globally unique because only one watcher
  772. // can be evaluated at a time.
  773. Dep.target = null;
  774. const targetStack = [];
  775. function pushTarget(target) {
  776. targetStack.push(target);
  777. Dep.target = target;
  778. }
  779. function popTarget() {
  780. targetStack.pop();
  781. Dep.target = targetStack[targetStack.length - 1];
  782. }
  783. /*
  784. * not type checking this file because flow doesn't play well with
  785. * dynamically accessing methods on Array prototype
  786. */
  787. const arrayProto = Array.prototype;
  788. const arrayMethods = Object.create(arrayProto);
  789. const methodsToPatch = [
  790. 'push',
  791. 'pop',
  792. 'shift',
  793. 'unshift',
  794. 'splice',
  795. 'sort',
  796. 'reverse'
  797. ];
  798. /**
  799. * Intercept mutating methods and emit events
  800. */
  801. methodsToPatch.forEach(function (method) {
  802. // cache original method
  803. const original = arrayProto[method];
  804. def(arrayMethods, method, function mutator(...args) {
  805. const result = original.apply(this, args);
  806. const ob = this.__ob__;
  807. let inserted;
  808. switch (method) {
  809. case 'push':
  810. case 'unshift':
  811. inserted = args;
  812. break;
  813. case 'splice':
  814. inserted = args.slice(2);
  815. break;
  816. }
  817. if (inserted)
  818. ob.observeArray(inserted);
  819. // notify change
  820. {
  821. ob.dep.notify({
  822. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  823. target: this,
  824. key: method
  825. });
  826. }
  827. return result;
  828. });
  829. });
  830. const rawMap = new WeakMap();
  831. function reactive(target) {
  832. makeReactive(target, false);
  833. return target;
  834. }
  835. /**
  836. * Return a shallowly-reactive copy of the original object, where only the root
  837. * level properties are reactive. It also does not auto-unwrap refs (even at the
  838. * root level).
  839. */
  840. function shallowReactive(target) {
  841. makeReactive(target, true);
  842. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  843. return target;
  844. }
  845. function makeReactive(target, shallow) {
  846. // if trying to observe a readonly proxy, return the readonly version.
  847. if (!isReadonly(target)) {
  848. {
  849. if (isArray(target)) {
  850. warn$2(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
  851. }
  852. const existingOb = target && target.__ob__;
  853. if (existingOb && existingOb.shallow !== shallow) {
  854. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  855. }
  856. }
  857. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  858. if (!ob) {
  859. if (target == null || isPrimitive(target)) {
  860. warn$2(`value cannot be made reactive: ${String(target)}`);
  861. }
  862. if (isCollectionType(target)) {
  863. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  864. }
  865. }
  866. }
  867. }
  868. function isReactive(value) {
  869. if (isReadonly(value)) {
  870. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  871. }
  872. return !!(value && value.__ob__);
  873. }
  874. function isShallow(value) {
  875. return !!(value && value.__v_isShallow);
  876. }
  877. function isReadonly(value) {
  878. return !!(value && value.__v_isReadonly);
  879. }
  880. function isProxy(value) {
  881. return isReactive(value) || isReadonly(value);
  882. }
  883. function toRaw(observed) {
  884. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  885. return raw ? toRaw(raw) : observed;
  886. }
  887. function markRaw(value) {
  888. if (isObject(value)) {
  889. rawMap.set(value, true);
  890. }
  891. return value;
  892. }
  893. /**
  894. * @internal
  895. */
  896. function isCollectionType(value) {
  897. const type = toRawType(value);
  898. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  899. }
  900. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  901. const NO_INIITIAL_VALUE = {};
  902. /**
  903. * In some cases we may want to disable observation inside a component's
  904. * update computation.
  905. */
  906. let shouldObserve = true;
  907. function toggleObserving(value) {
  908. shouldObserve = value;
  909. }
  910. // ssr mock dep
  911. const mockDep = {
  912. notify: noop,
  913. depend: noop,
  914. addSub: noop,
  915. removeSub: noop
  916. };
  917. /**
  918. * Observer class that is attached to each observed
  919. * object. Once attached, the observer converts the target
  920. * object's property keys into getter/setters that
  921. * collect dependencies and dispatch updates.
  922. */
  923. class Observer {
  924. constructor(value, shallow = false, mock = false) {
  925. this.value = value;
  926. this.shallow = shallow;
  927. this.mock = mock;
  928. // this.value = value
  929. this.dep = mock ? mockDep : new Dep();
  930. this.vmCount = 0;
  931. def(value, '__ob__', this);
  932. if (isArray(value)) {
  933. if (!mock) {
  934. if (hasProto) {
  935. value.__proto__ = arrayMethods;
  936. /* eslint-enable no-proto */
  937. }
  938. else {
  939. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  940. const key = arrayKeys[i];
  941. def(value, key, arrayMethods[key]);
  942. }
  943. }
  944. }
  945. if (!shallow) {
  946. this.observeArray(value);
  947. }
  948. }
  949. else {
  950. /**
  951. * Walk through all properties and convert them into
  952. * getter/setters. This method should only be called when
  953. * value type is Object.
  954. */
  955. const keys = Object.keys(value);
  956. for (let i = 0; i < keys.length; i++) {
  957. const key = keys[i];
  958. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  959. }
  960. }
  961. }
  962. /**
  963. * Observe a list of Array items.
  964. */
  965. observeArray(value) {
  966. for (let i = 0, l = value.length; i < l; i++) {
  967. observe(value[i], false, this.mock);
  968. }
  969. }
  970. }
  971. // helpers
  972. /**
  973. * Attempt to create an observer instance for a value,
  974. * returns the new observer if successfully observed,
  975. * or the existing observer if the value already has one.
  976. */
  977. function observe(value, shallow, ssrMockReactivity) {
  978. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  979. return value.__ob__;
  980. }
  981. if (shouldObserve &&
  982. (ssrMockReactivity || !isServerRendering()) &&
  983. (isArray(value) || isPlainObject(value)) &&
  984. Object.isExtensible(value) &&
  985. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  986. !rawMap.has(value) &&
  987. !isRef(value) &&
  988. !(value instanceof VNode)) {
  989. return new Observer(value, shallow, ssrMockReactivity);
  990. }
  991. }
  992. /**
  993. * Define a reactive property on an Object.
  994. */
  995. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  996. const dep = new Dep();
  997. const property = Object.getOwnPropertyDescriptor(obj, key);
  998. if (property && property.configurable === false) {
  999. return;
  1000. }
  1001. // cater for pre-defined getter/setters
  1002. const getter = property && property.get;
  1003. const setter = property && property.set;
  1004. if ((!getter || setter) &&
  1005. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  1006. val = obj[key];
  1007. }
  1008. let childOb = !shallow && observe(val, false, mock);
  1009. Object.defineProperty(obj, key, {
  1010. enumerable: true,
  1011. configurable: true,
  1012. get: function reactiveGetter() {
  1013. const value = getter ? getter.call(obj) : val;
  1014. if (Dep.target) {
  1015. {
  1016. dep.depend({
  1017. target: obj,
  1018. type: "get" /* TrackOpTypes.GET */,
  1019. key
  1020. });
  1021. }
  1022. if (childOb) {
  1023. childOb.dep.depend();
  1024. if (isArray(value)) {
  1025. dependArray(value);
  1026. }
  1027. }
  1028. }
  1029. return isRef(value) && !shallow ? value.value : value;
  1030. },
  1031. set: function reactiveSetter(newVal) {
  1032. const value = getter ? getter.call(obj) : val;
  1033. if (!hasChanged(value, newVal)) {
  1034. return;
  1035. }
  1036. if (customSetter) {
  1037. customSetter();
  1038. }
  1039. if (setter) {
  1040. setter.call(obj, newVal);
  1041. }
  1042. else if (getter) {
  1043. // #7981: for accessor properties without setter
  1044. return;
  1045. }
  1046. else if (!shallow && isRef(value) && !isRef(newVal)) {
  1047. value.value = newVal;
  1048. return;
  1049. }
  1050. else {
  1051. val = newVal;
  1052. }
  1053. childOb = !shallow && observe(newVal, false, mock);
  1054. {
  1055. dep.notify({
  1056. type: "set" /* TriggerOpTypes.SET */,
  1057. target: obj,
  1058. key,
  1059. newValue: newVal,
  1060. oldValue: value
  1061. });
  1062. }
  1063. }
  1064. });
  1065. return dep;
  1066. }
  1067. function set(target, key, val) {
  1068. if ((isUndef(target) || isPrimitive(target))) {
  1069. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  1070. }
  1071. if (isReadonly(target)) {
  1072. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1073. return;
  1074. }
  1075. const ob = target.__ob__;
  1076. if (isArray(target) && isValidArrayIndex(key)) {
  1077. target.length = Math.max(target.length, key);
  1078. target.splice(key, 1, val);
  1079. // when mocking for SSR, array methods are not hijacked
  1080. if (ob && !ob.shallow && ob.mock) {
  1081. observe(val, false, true);
  1082. }
  1083. return val;
  1084. }
  1085. if (key in target && !(key in Object.prototype)) {
  1086. target[key] = val;
  1087. return val;
  1088. }
  1089. if (target._isVue || (ob && ob.vmCount)) {
  1090. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1091. 'at runtime - declare it upfront in the data option.');
  1092. return val;
  1093. }
  1094. if (!ob) {
  1095. target[key] = val;
  1096. return val;
  1097. }
  1098. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1099. {
  1100. ob.dep.notify({
  1101. type: "add" /* TriggerOpTypes.ADD */,
  1102. target: target,
  1103. key,
  1104. newValue: val,
  1105. oldValue: undefined
  1106. });
  1107. }
  1108. return val;
  1109. }
  1110. function del(target, key) {
  1111. if ((isUndef(target) || isPrimitive(target))) {
  1112. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1113. }
  1114. if (isArray(target) && isValidArrayIndex(key)) {
  1115. target.splice(key, 1);
  1116. return;
  1117. }
  1118. const ob = target.__ob__;
  1119. if (target._isVue || (ob && ob.vmCount)) {
  1120. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1121. '- just set it to null.');
  1122. return;
  1123. }
  1124. if (isReadonly(target)) {
  1125. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1126. return;
  1127. }
  1128. if (!hasOwn(target, key)) {
  1129. return;
  1130. }
  1131. delete target[key];
  1132. if (!ob) {
  1133. return;
  1134. }
  1135. {
  1136. ob.dep.notify({
  1137. type: "delete" /* TriggerOpTypes.DELETE */,
  1138. target: target,
  1139. key
  1140. });
  1141. }
  1142. }
  1143. /**
  1144. * Collect dependencies on array elements when the array is touched, since
  1145. * we cannot intercept array element access like property getters.
  1146. */
  1147. function dependArray(value) {
  1148. for (let e, i = 0, l = value.length; i < l; i++) {
  1149. e = value[i];
  1150. if (e && e.__ob__) {
  1151. e.__ob__.dep.depend();
  1152. }
  1153. if (isArray(e)) {
  1154. dependArray(e);
  1155. }
  1156. }
  1157. }
  1158. /**
  1159. * @internal
  1160. */
  1161. const RefFlag = `__v_isRef`;
  1162. function isRef(r) {
  1163. return !!(r && r.__v_isRef === true);
  1164. }
  1165. function ref$1(value) {
  1166. return createRef(value, false);
  1167. }
  1168. function shallowRef(value) {
  1169. return createRef(value, true);
  1170. }
  1171. function createRef(rawValue, shallow) {
  1172. if (isRef(rawValue)) {
  1173. return rawValue;
  1174. }
  1175. const ref = {};
  1176. def(ref, RefFlag, true);
  1177. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1178. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1179. return ref;
  1180. }
  1181. function triggerRef(ref) {
  1182. if (!ref.dep) {
  1183. warn$2(`received object is not a triggerable ref.`);
  1184. }
  1185. {
  1186. ref.dep &&
  1187. ref.dep.notify({
  1188. type: "set" /* TriggerOpTypes.SET */,
  1189. target: ref,
  1190. key: 'value'
  1191. });
  1192. }
  1193. }
  1194. function unref(ref) {
  1195. return isRef(ref) ? ref.value : ref;
  1196. }
  1197. function proxyRefs(objectWithRefs) {
  1198. if (isReactive(objectWithRefs)) {
  1199. return objectWithRefs;
  1200. }
  1201. const proxy = {};
  1202. const keys = Object.keys(objectWithRefs);
  1203. for (let i = 0; i < keys.length; i++) {
  1204. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1205. }
  1206. return proxy;
  1207. }
  1208. function proxyWithRefUnwrap(target, source, key) {
  1209. Object.defineProperty(target, key, {
  1210. enumerable: true,
  1211. configurable: true,
  1212. get: () => {
  1213. const val = source[key];
  1214. if (isRef(val)) {
  1215. return val.value;
  1216. }
  1217. else {
  1218. const ob = val && val.__ob__;
  1219. if (ob)
  1220. ob.dep.depend();
  1221. return val;
  1222. }
  1223. },
  1224. set: value => {
  1225. const oldValue = source[key];
  1226. if (isRef(oldValue) && !isRef(value)) {
  1227. oldValue.value = value;
  1228. }
  1229. else {
  1230. source[key] = value;
  1231. }
  1232. }
  1233. });
  1234. }
  1235. function customRef(factory) {
  1236. const dep = new Dep();
  1237. const { get, set } = factory(() => {
  1238. {
  1239. dep.depend({
  1240. target: ref,
  1241. type: "get" /* TrackOpTypes.GET */,
  1242. key: 'value'
  1243. });
  1244. }
  1245. }, () => {
  1246. {
  1247. dep.notify({
  1248. target: ref,
  1249. type: "set" /* TriggerOpTypes.SET */,
  1250. key: 'value'
  1251. });
  1252. }
  1253. });
  1254. const ref = {
  1255. get value() {
  1256. return get();
  1257. },
  1258. set value(newVal) {
  1259. set(newVal);
  1260. }
  1261. };
  1262. def(ref, RefFlag, true);
  1263. return ref;
  1264. }
  1265. function toRefs(object) {
  1266. if (!isReactive(object)) {
  1267. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1268. }
  1269. const ret = isArray(object) ? new Array(object.length) : {};
  1270. for (const key in object) {
  1271. ret[key] = toRef(object, key);
  1272. }
  1273. return ret;
  1274. }
  1275. function toRef(object, key, defaultValue) {
  1276. const val = object[key];
  1277. if (isRef(val)) {
  1278. return val;
  1279. }
  1280. const ref = {
  1281. get value() {
  1282. const val = object[key];
  1283. return val === undefined ? defaultValue : val;
  1284. },
  1285. set value(newVal) {
  1286. object[key] = newVal;
  1287. }
  1288. };
  1289. def(ref, RefFlag, true);
  1290. return ref;
  1291. }
  1292. const rawToReadonlyMap = new WeakMap();
  1293. const rawToShallowReadonlyMap = new WeakMap();
  1294. function readonly(target) {
  1295. return createReadonly(target, false);
  1296. }
  1297. function createReadonly(target, shallow) {
  1298. if (!isPlainObject(target)) {
  1299. {
  1300. if (isArray(target)) {
  1301. warn$2(`Vue 2 does not support readonly arrays.`);
  1302. }
  1303. else if (isCollectionType(target)) {
  1304. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1305. }
  1306. else {
  1307. warn$2(`value cannot be made readonly: ${typeof target}`);
  1308. }
  1309. }
  1310. return target;
  1311. }
  1312. // already a readonly object
  1313. if (isReadonly(target)) {
  1314. return target;
  1315. }
  1316. // already has a readonly proxy
  1317. const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap;
  1318. const existingProxy = map.get(target);
  1319. if (existingProxy) {
  1320. return existingProxy;
  1321. }
  1322. const proxy = Object.create(Object.getPrototypeOf(target));
  1323. map.set(target, proxy);
  1324. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1325. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1326. if (isRef(target)) {
  1327. def(proxy, RefFlag, true);
  1328. }
  1329. if (shallow || isShallow(target)) {
  1330. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1331. }
  1332. const keys = Object.keys(target);
  1333. for (let i = 0; i < keys.length; i++) {
  1334. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1335. }
  1336. return proxy;
  1337. }
  1338. function defineReadonlyProperty(proxy, target, key, shallow) {
  1339. Object.defineProperty(proxy, key, {
  1340. enumerable: true,
  1341. configurable: true,
  1342. get() {
  1343. const val = target[key];
  1344. return shallow || !isPlainObject(val) ? val : readonly(val);
  1345. },
  1346. set() {
  1347. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1348. }
  1349. });
  1350. }
  1351. /**
  1352. * Returns a reactive-copy of the original object, where only the root level
  1353. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1354. * returned properties.
  1355. * This is used for creating the props proxy object for stateful components.
  1356. */
  1357. function shallowReadonly(target) {
  1358. return createReadonly(target, true);
  1359. }
  1360. function computed(getterOrOptions, debugOptions) {
  1361. let getter;
  1362. let setter;
  1363. const onlyGetter = isFunction(getterOrOptions);
  1364. if (onlyGetter) {
  1365. getter = getterOrOptions;
  1366. setter = () => {
  1367. warn$2('Write operation failed: computed value is readonly');
  1368. }
  1369. ;
  1370. }
  1371. else {
  1372. getter = getterOrOptions.get;
  1373. setter = getterOrOptions.set;
  1374. }
  1375. const watcher = isServerRendering()
  1376. ? null
  1377. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1378. if (watcher && debugOptions) {
  1379. watcher.onTrack = debugOptions.onTrack;
  1380. watcher.onTrigger = debugOptions.onTrigger;
  1381. }
  1382. const ref = {
  1383. // some libs rely on the presence effect for checking computed refs
  1384. // from normal refs, but the implementation doesn't matter
  1385. effect: watcher,
  1386. get value() {
  1387. if (watcher) {
  1388. if (watcher.dirty) {
  1389. watcher.evaluate();
  1390. }
  1391. if (Dep.target) {
  1392. if (Dep.target.onTrack) {
  1393. Dep.target.onTrack({
  1394. effect: Dep.target,
  1395. target: ref,
  1396. type: "get" /* TrackOpTypes.GET */,
  1397. key: 'value'
  1398. });
  1399. }
  1400. watcher.depend();
  1401. }
  1402. return watcher.value;
  1403. }
  1404. else {
  1405. return getter();
  1406. }
  1407. },
  1408. set value(newVal) {
  1409. setter(newVal);
  1410. }
  1411. };
  1412. def(ref, RefFlag, true);
  1413. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1414. return ref;
  1415. }
  1416. let mark;
  1417. let measure;
  1418. {
  1419. const perf = inBrowser && window.performance;
  1420. /* istanbul ignore if */
  1421. if (perf &&
  1422. // @ts-ignore
  1423. perf.mark &&
  1424. // @ts-ignore
  1425. perf.measure &&
  1426. // @ts-ignore
  1427. perf.clearMarks &&
  1428. // @ts-ignore
  1429. perf.clearMeasures) {
  1430. mark = tag => perf.mark(tag);
  1431. measure = (name, startTag, endTag) => {
  1432. perf.measure(name, startTag, endTag);
  1433. perf.clearMarks(startTag);
  1434. perf.clearMarks(endTag);
  1435. // perf.clearMeasures(name)
  1436. };
  1437. }
  1438. }
  1439. const normalizeEvent = cached((name) => {
  1440. const passive = name.charAt(0) === '&';
  1441. name = passive ? name.slice(1) : name;
  1442. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1443. name = once ? name.slice(1) : name;
  1444. const capture = name.charAt(0) === '!';
  1445. name = capture ? name.slice(1) : name;
  1446. return {
  1447. name,
  1448. once,
  1449. capture,
  1450. passive
  1451. };
  1452. });
  1453. function createFnInvoker(fns, vm) {
  1454. function invoker() {
  1455. const fns = invoker.fns;
  1456. if (isArray(fns)) {
  1457. const cloned = fns.slice();
  1458. for (let i = 0; i < cloned.length; i++) {
  1459. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1460. }
  1461. }
  1462. else {
  1463. // return handler return value for single handlers
  1464. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1465. }
  1466. }
  1467. invoker.fns = fns;
  1468. return invoker;
  1469. }
  1470. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1471. let name, cur, old, event;
  1472. for (name in on) {
  1473. cur = on[name];
  1474. old = oldOn[name];
  1475. event = normalizeEvent(name);
  1476. if (isUndef(cur)) {
  1477. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1478. }
  1479. else if (isUndef(old)) {
  1480. if (isUndef(cur.fns)) {
  1481. cur = on[name] = createFnInvoker(cur, vm);
  1482. }
  1483. if (isTrue(event.once)) {
  1484. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1485. }
  1486. add(event.name, cur, event.capture, event.passive, event.params);
  1487. }
  1488. else if (cur !== old) {
  1489. old.fns = cur;
  1490. on[name] = old;
  1491. }
  1492. }
  1493. for (name in oldOn) {
  1494. if (isUndef(on[name])) {
  1495. event = normalizeEvent(name);
  1496. remove(event.name, oldOn[name], event.capture);
  1497. }
  1498. }
  1499. }
  1500. function mergeVNodeHook(def, hookKey, hook) {
  1501. if (def instanceof VNode) {
  1502. def = def.data.hook || (def.data.hook = {});
  1503. }
  1504. let invoker;
  1505. const oldHook = def[hookKey];
  1506. function wrappedHook() {
  1507. hook.apply(this, arguments);
  1508. // important: remove merged hook to ensure it's called only once
  1509. // and prevent memory leak
  1510. remove$2(invoker.fns, wrappedHook);
  1511. }
  1512. if (isUndef(oldHook)) {
  1513. // no existing hook
  1514. invoker = createFnInvoker([wrappedHook]);
  1515. }
  1516. else {
  1517. /* istanbul ignore if */
  1518. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1519. // already a merged invoker
  1520. invoker = oldHook;
  1521. invoker.fns.push(wrappedHook);
  1522. }
  1523. else {
  1524. // existing plain hook
  1525. invoker = createFnInvoker([oldHook, wrappedHook]);
  1526. }
  1527. }
  1528. invoker.merged = true;
  1529. def[hookKey] = invoker;
  1530. }
  1531. function extractPropsFromVNodeData(data, Ctor, tag) {
  1532. // we are only extracting raw values here.
  1533. // validation and default values are handled in the child
  1534. // component itself.
  1535. const propOptions = Ctor.options.props;
  1536. if (isUndef(propOptions)) {
  1537. return;
  1538. }
  1539. const res = {};
  1540. const { attrs, props } = data;
  1541. if (isDef(attrs) || isDef(props)) {
  1542. for (const key in propOptions) {
  1543. const altKey = hyphenate(key);
  1544. {
  1545. const keyInLowerCase = key.toLowerCase();
  1546. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1547. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1548. `${formatComponentName(
  1549. // @ts-expect-error tag is string
  1550. tag || Ctor)}, but the declared prop name is` +
  1551. ` "${key}". ` +
  1552. `Note that HTML attributes are case-insensitive and camelCased ` +
  1553. `props need to use their kebab-case equivalents when using in-DOM ` +
  1554. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1555. }
  1556. }
  1557. checkProp(res, props, key, altKey, true) ||
  1558. checkProp(res, attrs, key, altKey, false);
  1559. }
  1560. }
  1561. return res;
  1562. }
  1563. function checkProp(res, hash, key, altKey, preserve) {
  1564. if (isDef(hash)) {
  1565. if (hasOwn(hash, key)) {
  1566. res[key] = hash[key];
  1567. if (!preserve) {
  1568. delete hash[key];
  1569. }
  1570. return true;
  1571. }
  1572. else if (hasOwn(hash, altKey)) {
  1573. res[key] = hash[altKey];
  1574. if (!preserve) {
  1575. delete hash[altKey];
  1576. }
  1577. return true;
  1578. }
  1579. }
  1580. return false;
  1581. }
  1582. // The template compiler attempts to minimize the need for normalization by
  1583. // statically analyzing the template at compile time.
  1584. //
  1585. // For plain HTML markup, normalization can be completely skipped because the
  1586. // generated render function is guaranteed to return Array<VNode>. There are
  1587. // two cases where extra normalization is needed:
  1588. // 1. When the children contains components - because a functional component
  1589. // may return an Array instead of a single root. In this case, just a simple
  1590. // normalization is needed - if any child is an Array, we flatten the whole
  1591. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1592. // because functional components already normalize their own children.
  1593. function simpleNormalizeChildren(children) {
  1594. for (let i = 0; i < children.length; i++) {
  1595. if (isArray(children[i])) {
  1596. return Array.prototype.concat.apply([], children);
  1597. }
  1598. }
  1599. return children;
  1600. }
  1601. // 2. When the children contains constructs that always generated nested Arrays,
  1602. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1603. // with hand-written render functions / JSX. In such cases a full normalization
  1604. // is needed to cater to all possible types of children values.
  1605. function normalizeChildren(children) {
  1606. return isPrimitive(children)
  1607. ? [createTextVNode(children)]
  1608. : isArray(children)
  1609. ? normalizeArrayChildren(children)
  1610. : undefined;
  1611. }
  1612. function isTextNode(node) {
  1613. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1614. }
  1615. function normalizeArrayChildren(children, nestedIndex) {
  1616. const res = [];
  1617. let i, c, lastIndex, last;
  1618. for (i = 0; i < children.length; i++) {
  1619. c = children[i];
  1620. if (isUndef(c) || typeof c === 'boolean')
  1621. continue;
  1622. lastIndex = res.length - 1;
  1623. last = res[lastIndex];
  1624. // nested
  1625. if (isArray(c)) {
  1626. if (c.length > 0) {
  1627. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1628. // merge adjacent text nodes
  1629. if (isTextNode(c[0]) && isTextNode(last)) {
  1630. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1631. c.shift();
  1632. }
  1633. res.push.apply(res, c);
  1634. }
  1635. }
  1636. else if (isPrimitive(c)) {
  1637. if (isTextNode(last)) {
  1638. // merge adjacent text nodes
  1639. // this is necessary for SSR hydration because text nodes are
  1640. // essentially merged when rendered to HTML strings
  1641. res[lastIndex] = createTextVNode(last.text + c);
  1642. }
  1643. else if (c !== '') {
  1644. // convert primitive to vnode
  1645. res.push(createTextVNode(c));
  1646. }
  1647. }
  1648. else {
  1649. if (isTextNode(c) && isTextNode(last)) {
  1650. // merge adjacent text nodes
  1651. res[lastIndex] = createTextVNode(last.text + c.text);
  1652. }
  1653. else {
  1654. // default key for nested array children (likely generated by v-for)
  1655. if (isTrue(children._isVList) &&
  1656. isDef(c.tag) &&
  1657. isUndef(c.key) &&
  1658. isDef(nestedIndex)) {
  1659. c.key = `__vlist${nestedIndex}_${i}__`;
  1660. }
  1661. res.push(c);
  1662. }
  1663. }
  1664. }
  1665. return res;
  1666. }
  1667. const SIMPLE_NORMALIZE = 1;
  1668. const ALWAYS_NORMALIZE = 2;
  1669. // wrapper function for providing a more flexible interface
  1670. // without getting yelled at by flow
  1671. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1672. if (isArray(data) || isPrimitive(data)) {
  1673. normalizationType = children;
  1674. children = data;
  1675. data = undefined;
  1676. }
  1677. if (isTrue(alwaysNormalize)) {
  1678. normalizationType = ALWAYS_NORMALIZE;
  1679. }
  1680. return _createElement(context, tag, data, children, normalizationType);
  1681. }
  1682. function _createElement(context, tag, data, children, normalizationType) {
  1683. if (isDef(data) && isDef(data.__ob__)) {
  1684. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1685. return createEmptyVNode();
  1686. }
  1687. // object syntax in v-bind
  1688. if (isDef(data) && isDef(data.is)) {
  1689. tag = data.is;
  1690. }
  1691. if (!tag) {
  1692. // in case of component :is set to falsy value
  1693. return createEmptyVNode();
  1694. }
  1695. // warn against non-primitive key
  1696. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1697. warn$2('Avoid using non-primitive value as key, ' +
  1698. 'use string/number value instead.', context);
  1699. }
  1700. // support single function children as default scoped slot
  1701. if (isArray(children) && isFunction(children[0])) {
  1702. data = data || {};
  1703. data.scopedSlots = { default: children[0] };
  1704. children.length = 0;
  1705. }
  1706. if (normalizationType === ALWAYS_NORMALIZE) {
  1707. children = normalizeChildren(children);
  1708. }
  1709. else if (normalizationType === SIMPLE_NORMALIZE) {
  1710. children = simpleNormalizeChildren(children);
  1711. }
  1712. let vnode, ns;
  1713. if (typeof tag === 'string') {
  1714. let Ctor;
  1715. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1716. if (config.isReservedTag(tag)) {
  1717. // platform built-in elements
  1718. if (isDef(data) &&
  1719. isDef(data.nativeOn) &&
  1720. data.tag !== 'component') {
  1721. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1722. }
  1723. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1724. }
  1725. else if ((!data || !data.pre) &&
  1726. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1727. // component
  1728. vnode = createComponent(Ctor, data, context, children, tag);
  1729. }
  1730. else {
  1731. // unknown or unlisted namespaced elements
  1732. // check at runtime because it may get assigned a namespace when its
  1733. // parent normalizes children
  1734. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1735. }
  1736. }
  1737. else {
  1738. // direct component options / constructor
  1739. vnode = createComponent(tag, data, context, children);
  1740. }
  1741. if (isArray(vnode)) {
  1742. return vnode;
  1743. }
  1744. else if (isDef(vnode)) {
  1745. if (isDef(ns))
  1746. applyNS(vnode, ns);
  1747. if (isDef(data))
  1748. registerDeepBindings(data);
  1749. return vnode;
  1750. }
  1751. else {
  1752. return createEmptyVNode();
  1753. }
  1754. }
  1755. function applyNS(vnode, ns, force) {
  1756. vnode.ns = ns;
  1757. if (vnode.tag === 'foreignObject') {
  1758. // use default namespace inside foreignObject
  1759. ns = undefined;
  1760. force = true;
  1761. }
  1762. if (isDef(vnode.children)) {
  1763. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1764. const child = vnode.children[i];
  1765. if (isDef(child.tag) &&
  1766. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1767. applyNS(child, ns, force);
  1768. }
  1769. }
  1770. }
  1771. }
  1772. // ref #5318
  1773. // necessary to ensure parent re-render when deep bindings like :style and
  1774. // :class are used on slot nodes
  1775. function registerDeepBindings(data) {
  1776. if (isObject(data.style)) {
  1777. traverse(data.style);
  1778. }
  1779. if (isObject(data.class)) {
  1780. traverse(data.class);
  1781. }
  1782. }
  1783. /**
  1784. * Runtime helper for rendering v-for lists.
  1785. */
  1786. function renderList(val, render) {
  1787. let ret = null, i, l, keys, key;
  1788. if (isArray(val) || typeof val === 'string') {
  1789. ret = new Array(val.length);
  1790. for (i = 0, l = val.length; i < l; i++) {
  1791. ret[i] = render(val[i], i);
  1792. }
  1793. }
  1794. else if (typeof val === 'number') {
  1795. ret = new Array(val);
  1796. for (i = 0; i < val; i++) {
  1797. ret[i] = render(i + 1, i);
  1798. }
  1799. }
  1800. else if (isObject(val)) {
  1801. if (hasSymbol && val[Symbol.iterator]) {
  1802. ret = [];
  1803. const iterator = val[Symbol.iterator]();
  1804. let result = iterator.next();
  1805. while (!result.done) {
  1806. ret.push(render(result.value, ret.length));
  1807. result = iterator.next();
  1808. }
  1809. }
  1810. else {
  1811. keys = Object.keys(val);
  1812. ret = new Array(keys.length);
  1813. for (i = 0, l = keys.length; i < l; i++) {
  1814. key = keys[i];
  1815. ret[i] = render(val[key], key, i);
  1816. }
  1817. }
  1818. }
  1819. if (!isDef(ret)) {
  1820. ret = [];
  1821. }
  1822. ret._isVList = true;
  1823. return ret;
  1824. }
  1825. /**
  1826. * Runtime helper for rendering <slot>
  1827. */
  1828. function renderSlot(name, fallbackRender, props, bindObject) {
  1829. const scopedSlotFn = this.$scopedSlots[name];
  1830. let nodes;
  1831. if (scopedSlotFn) {
  1832. // scoped slot
  1833. props = props || {};
  1834. if (bindObject) {
  1835. if (!isObject(bindObject)) {
  1836. warn$2('slot v-bind without argument expects an Object', this);
  1837. }
  1838. props = extend(extend({}, bindObject), props);
  1839. }
  1840. nodes =
  1841. scopedSlotFn(props) ||
  1842. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1843. }
  1844. else {
  1845. nodes =
  1846. this.$slots[name] ||
  1847. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1848. }
  1849. const target = props && props.slot;
  1850. if (target) {
  1851. return this.$createElement('template', { slot: target }, nodes);
  1852. }
  1853. else {
  1854. return nodes;
  1855. }
  1856. }
  1857. /**
  1858. * Runtime helper for resolving filters
  1859. */
  1860. function resolveFilter(id) {
  1861. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1862. }
  1863. function isKeyNotMatch(expect, actual) {
  1864. if (isArray(expect)) {
  1865. return expect.indexOf(actual) === -1;
  1866. }
  1867. else {
  1868. return expect !== actual;
  1869. }
  1870. }
  1871. /**
  1872. * Runtime helper for checking keyCodes from config.
  1873. * exposed as Vue.prototype._k
  1874. * passing in eventKeyName as last argument separately for backwards compat
  1875. */
  1876. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1877. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1878. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1879. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1880. }
  1881. else if (mappedKeyCode) {
  1882. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1883. }
  1884. else if (eventKeyName) {
  1885. return hyphenate(eventKeyName) !== key;
  1886. }
  1887. return eventKeyCode === undefined;
  1888. }
  1889. /**
  1890. * Runtime helper for merging v-bind="object" into a VNode's data.
  1891. */
  1892. function bindObjectProps(data, tag, value, asProp, isSync) {
  1893. if (value) {
  1894. if (!isObject(value)) {
  1895. warn$2('v-bind without argument expects an Object or Array value', this);
  1896. }
  1897. else {
  1898. if (isArray(value)) {
  1899. value = toObject(value);
  1900. }
  1901. let hash;
  1902. for (const key in value) {
  1903. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1904. hash = data;
  1905. }
  1906. else {
  1907. const type = data.attrs && data.attrs.type;
  1908. hash =
  1909. asProp || config.mustUseProp(tag, type, key)
  1910. ? data.domProps || (data.domProps = {})
  1911. : data.attrs || (data.attrs = {});
  1912. }
  1913. const camelizedKey = camelize(key);
  1914. const hyphenatedKey = hyphenate(key);
  1915. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1916. hash[key] = value[key];
  1917. if (isSync) {
  1918. const on = data.on || (data.on = {});
  1919. on[`update:${key}`] = function ($event) {
  1920. value[key] = $event;
  1921. };
  1922. }
  1923. }
  1924. }
  1925. }
  1926. }
  1927. return data;
  1928. }
  1929. /**
  1930. * Runtime helper for rendering static trees.
  1931. */
  1932. function renderStatic(index, isInFor) {
  1933. const cached = this._staticTrees || (this._staticTrees = []);
  1934. let tree = cached[index];
  1935. // if has already-rendered static tree and not inside v-for,
  1936. // we can reuse the same tree.
  1937. if (tree && !isInFor) {
  1938. return tree;
  1939. }
  1940. // otherwise, render a fresh tree.
  1941. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1942. );
  1943. markStatic$1(tree, `__static__${index}`, false);
  1944. return tree;
  1945. }
  1946. /**
  1947. * Runtime helper for v-once.
  1948. * Effectively it means marking the node as static with a unique key.
  1949. */
  1950. function markOnce(tree, index, key) {
  1951. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1952. return tree;
  1953. }
  1954. function markStatic$1(tree, key, isOnce) {
  1955. if (isArray(tree)) {
  1956. for (let i = 0; i < tree.length; i++) {
  1957. if (tree[i] && typeof tree[i] !== 'string') {
  1958. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1959. }
  1960. }
  1961. }
  1962. else {
  1963. markStaticNode(tree, key, isOnce);
  1964. }
  1965. }
  1966. function markStaticNode(node, key, isOnce) {
  1967. node.isStatic = true;
  1968. node.key = key;
  1969. node.isOnce = isOnce;
  1970. }
  1971. function bindObjectListeners(data, value) {
  1972. if (value) {
  1973. if (!isPlainObject(value)) {
  1974. warn$2('v-on without argument expects an Object value', this);
  1975. }
  1976. else {
  1977. const on = (data.on = data.on ? extend({}, data.on) : {});
  1978. for (const key in value) {
  1979. const existing = on[key];
  1980. const ours = value[key];
  1981. on[key] = existing ? [].concat(existing, ours) : ours;
  1982. }
  1983. }
  1984. }
  1985. return data;
  1986. }
  1987. function resolveScopedSlots(fns, res,
  1988. // the following are added in 2.6
  1989. hasDynamicKeys, contentHashKey) {
  1990. res = res || { $stable: !hasDynamicKeys };
  1991. for (let i = 0; i < fns.length; i++) {
  1992. const slot = fns[i];
  1993. if (isArray(slot)) {
  1994. resolveScopedSlots(slot, res, hasDynamicKeys);
  1995. }
  1996. else if (slot) {
  1997. // marker for reverse proxying v-slot without scope on this.$slots
  1998. // @ts-expect-error
  1999. if (slot.proxy) {
  2000. // @ts-expect-error
  2001. slot.fn.proxy = true;
  2002. }
  2003. res[slot.key] = slot.fn;
  2004. }
  2005. }
  2006. if (contentHashKey) {
  2007. res.$key = contentHashKey;
  2008. }
  2009. return res;
  2010. }
  2011. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2012. function bindDynamicKeys(baseObj, values) {
  2013. for (let i = 0; i < values.length; i += 2) {
  2014. const key = values[i];
  2015. if (typeof key === 'string' && key) {
  2016. baseObj[values[i]] = values[i + 1];
  2017. }
  2018. else if (key !== '' && key !== null) {
  2019. // null is a special value for explicitly removing a binding
  2020. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2021. }
  2022. }
  2023. return baseObj;
  2024. }
  2025. // helper to dynamically append modifier runtime markers to event names.
  2026. // ensure only append when value is already string, otherwise it will be cast
  2027. // to string and cause the type check to miss.
  2028. function prependModifier(value, symbol) {
  2029. return typeof value === 'string' ? symbol + value : value;
  2030. }
  2031. function installRenderHelpers(target) {
  2032. target._o = markOnce;
  2033. target._n = toNumber;
  2034. target._s = toString;
  2035. target._l = renderList;
  2036. target._t = renderSlot;
  2037. target._q = looseEqual;
  2038. target._i = looseIndexOf;
  2039. target._m = renderStatic;
  2040. target._f = resolveFilter;
  2041. target._k = checkKeyCodes;
  2042. target._b = bindObjectProps;
  2043. target._v = createTextVNode;
  2044. target._e = createEmptyVNode;
  2045. target._u = resolveScopedSlots;
  2046. target._g = bindObjectListeners;
  2047. target._d = bindDynamicKeys;
  2048. target._p = prependModifier;
  2049. }
  2050. /**
  2051. * Runtime helper for resolving raw children VNodes into a slot object.
  2052. */
  2053. function resolveSlots(children, context) {
  2054. if (!children || !children.length) {
  2055. return {};
  2056. }
  2057. const slots = {};
  2058. for (let i = 0, l = children.length; i < l; i++) {
  2059. const child = children[i];
  2060. const data = child.data;
  2061. // remove slot attribute if the node is resolved as a Vue slot node
  2062. if (data && data.attrs && data.attrs.slot) {
  2063. delete data.attrs.slot;
  2064. }
  2065. // named slots should only be respected if the vnode was rendered in the
  2066. // same context.
  2067. if ((child.context === context || child.fnContext === context) &&
  2068. data &&
  2069. data.slot != null) {
  2070. const name = data.slot;
  2071. const slot = slots[name] || (slots[name] = []);
  2072. if (child.tag === 'template') {
  2073. slot.push.apply(slot, child.children || []);
  2074. }
  2075. else {
  2076. slot.push(child);
  2077. }
  2078. }
  2079. else {
  2080. (slots.default || (slots.default = [])).push(child);
  2081. }
  2082. }
  2083. // ignore slots that contains only whitespace
  2084. for (const name in slots) {
  2085. if (slots[name].every(isWhitespace)) {
  2086. delete slots[name];
  2087. }
  2088. }
  2089. return slots;
  2090. }
  2091. function isWhitespace(node) {
  2092. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2093. }
  2094. function isAsyncPlaceholder(node) {
  2095. // @ts-expect-error not really boolean type
  2096. return node.isComment && node.asyncFactory;
  2097. }
  2098. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2099. let res;
  2100. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2101. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2102. const key = scopedSlots && scopedSlots.$key;
  2103. if (!scopedSlots) {
  2104. res = {};
  2105. }
  2106. else if (scopedSlots._normalized) {
  2107. // fast path 1: child component re-render only, parent did not change
  2108. return scopedSlots._normalized;
  2109. }
  2110. else if (isStable &&
  2111. prevScopedSlots &&
  2112. prevScopedSlots !== emptyObject &&
  2113. key === prevScopedSlots.$key &&
  2114. !hasNormalSlots &&
  2115. !prevScopedSlots.$hasNormal) {
  2116. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2117. // only need to normalize once
  2118. return prevScopedSlots;
  2119. }
  2120. else {
  2121. res = {};
  2122. for (const key in scopedSlots) {
  2123. if (scopedSlots[key] && key[0] !== '$') {
  2124. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2125. }
  2126. }
  2127. }
  2128. // expose normal slots on scopedSlots
  2129. for (const key in normalSlots) {
  2130. if (!(key in res)) {
  2131. res[key] = proxyNormalSlot(normalSlots, key);
  2132. }
  2133. }
  2134. // avoriaz seems to mock a non-extensible $scopedSlots object
  2135. // and when that is passed down this would cause an error
  2136. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2137. scopedSlots._normalized = res;
  2138. }
  2139. def(res, '$stable', isStable);
  2140. def(res, '$key', key);
  2141. def(res, '$hasNormal', hasNormalSlots);
  2142. return res;
  2143. }
  2144. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2145. const normalized = function () {
  2146. const cur = currentInstance;
  2147. setCurrentInstance(vm);
  2148. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2149. res =
  2150. res && typeof res === 'object' && !isArray(res)
  2151. ? [res] // single vnode
  2152. : normalizeChildren(res);
  2153. const vnode = res && res[0];
  2154. setCurrentInstance(cur);
  2155. return res &&
  2156. (!vnode ||
  2157. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2158. ? undefined
  2159. : res;
  2160. };
  2161. // this is a slot using the new v-slot syntax without scope. although it is
  2162. // compiled as a scoped slot, render fn users would expect it to be present
  2163. // on this.$slots because the usage is semantically a normal slot.
  2164. if (fn.proxy) {
  2165. Object.defineProperty(normalSlots, key, {
  2166. get: normalized,
  2167. enumerable: true,
  2168. configurable: true
  2169. });
  2170. }
  2171. return normalized;
  2172. }
  2173. function proxyNormalSlot(slots, key) {
  2174. return () => slots[key];
  2175. }
  2176. function initSetup(vm) {
  2177. const options = vm.$options;
  2178. const setup = options.setup;
  2179. if (setup) {
  2180. const ctx = (vm._setupContext = createSetupContext(vm));
  2181. setCurrentInstance(vm);
  2182. pushTarget();
  2183. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2184. popTarget();
  2185. setCurrentInstance();
  2186. if (isFunction(setupResult)) {
  2187. // render function
  2188. // @ts-ignore
  2189. options.render = setupResult;
  2190. }
  2191. else if (isObject(setupResult)) {
  2192. // bindings
  2193. if (setupResult instanceof VNode) {
  2194. warn$2(`setup() should not return VNodes directly - ` +
  2195. `return a render function instead.`);
  2196. }
  2197. vm._setupState = setupResult;
  2198. // __sfc indicates compiled bindings from <script setup>
  2199. if (!setupResult.__sfc) {
  2200. for (const key in setupResult) {
  2201. if (!isReserved(key)) {
  2202. proxyWithRefUnwrap(vm, setupResult, key);
  2203. }
  2204. else {
  2205. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2206. }
  2207. }
  2208. }
  2209. else {
  2210. // exposed for compiled render fn
  2211. const proxy = (vm._setupProxy = {});
  2212. for (const key in setupResult) {
  2213. if (key !== '__sfc') {
  2214. proxyWithRefUnwrap(proxy, setupResult, key);
  2215. }
  2216. }
  2217. }
  2218. }
  2219. else if (setupResult !== undefined) {
  2220. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2221. }
  2222. }
  2223. }
  2224. function createSetupContext(vm) {
  2225. let exposeCalled = false;
  2226. return {
  2227. get attrs() {
  2228. if (!vm._attrsProxy) {
  2229. const proxy = (vm._attrsProxy = {});
  2230. def(proxy, '_v_attr_proxy', true);
  2231. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2232. }
  2233. return vm._attrsProxy;
  2234. },
  2235. get listeners() {
  2236. if (!vm._listenersProxy) {
  2237. const proxy = (vm._listenersProxy = {});
  2238. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2239. }
  2240. return vm._listenersProxy;
  2241. },
  2242. get slots() {
  2243. return initSlotsProxy(vm);
  2244. },
  2245. emit: bind$1(vm.$emit, vm),
  2246. expose(exposed) {
  2247. {
  2248. if (exposeCalled) {
  2249. warn$2(`expose() should be called only once per setup().`, vm);
  2250. }
  2251. exposeCalled = true;
  2252. }
  2253. if (exposed) {
  2254. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2255. }
  2256. }
  2257. };
  2258. }
  2259. function syncSetupProxy(to, from, prev, instance, type) {
  2260. let changed = false;
  2261. for (const key in from) {
  2262. if (!(key in to)) {
  2263. changed = true;
  2264. defineProxyAttr(to, key, instance, type);
  2265. }
  2266. else if (from[key] !== prev[key]) {
  2267. changed = true;
  2268. }
  2269. }
  2270. for (const key in to) {
  2271. if (!(key in from)) {
  2272. changed = true;
  2273. delete to[key];
  2274. }
  2275. }
  2276. return changed;
  2277. }
  2278. function defineProxyAttr(proxy, key, instance, type) {
  2279. Object.defineProperty(proxy, key, {
  2280. enumerable: true,
  2281. configurable: true,
  2282. get() {
  2283. return instance[type][key];
  2284. }
  2285. });
  2286. }
  2287. function initSlotsProxy(vm) {
  2288. if (!vm._slotsProxy) {
  2289. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2290. }
  2291. return vm._slotsProxy;
  2292. }
  2293. function syncSetupSlots(to, from) {
  2294. for (const key in from) {
  2295. to[key] = from[key];
  2296. }
  2297. for (const key in to) {
  2298. if (!(key in from)) {
  2299. delete to[key];
  2300. }
  2301. }
  2302. }
  2303. /**
  2304. * @internal use manual type def because public setup context type relies on
  2305. * legacy VNode types
  2306. */
  2307. function useSlots() {
  2308. return getContext().slots;
  2309. }
  2310. /**
  2311. * @internal use manual type def because public setup context type relies on
  2312. * legacy VNode types
  2313. */
  2314. function useAttrs() {
  2315. return getContext().attrs;
  2316. }
  2317. /**
  2318. * Vue 2 only
  2319. * @internal use manual type def because public setup context type relies on
  2320. * legacy VNode types
  2321. */
  2322. function useListeners() {
  2323. return getContext().listeners;
  2324. }
  2325. function getContext() {
  2326. if (!currentInstance) {
  2327. warn$2(`useContext() called without active instance.`);
  2328. }
  2329. const vm = currentInstance;
  2330. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2331. }
  2332. /**
  2333. * Runtime helper for merging default declarations. Imported by compiled code
  2334. * only.
  2335. * @internal
  2336. */
  2337. function mergeDefaults(raw, defaults) {
  2338. const props = isArray(raw)
  2339. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2340. : raw;
  2341. for (const key in defaults) {
  2342. const opt = props[key];
  2343. if (opt) {
  2344. if (isArray(opt) || isFunction(opt)) {
  2345. props[key] = { type: opt, default: defaults[key] };
  2346. }
  2347. else {
  2348. opt.default = defaults[key];
  2349. }
  2350. }
  2351. else if (opt === null) {
  2352. props[key] = { default: defaults[key] };
  2353. }
  2354. else {
  2355. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2356. }
  2357. }
  2358. return props;
  2359. }
  2360. function initRender(vm) {
  2361. vm._vnode = null; // the root of the child tree
  2362. vm._staticTrees = null; // v-once cached trees
  2363. const options = vm.$options;
  2364. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2365. const renderContext = parentVnode && parentVnode.context;
  2366. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2367. vm.$scopedSlots = parentVnode
  2368. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2369. : emptyObject;
  2370. // bind the createElement fn to this instance
  2371. // so that we get proper render context inside it.
  2372. // args order: tag, data, children, normalizationType, alwaysNormalize
  2373. // internal version is used by render functions compiled from templates
  2374. // @ts-expect-error
  2375. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2376. // normalization is always applied for the public version, used in
  2377. // user-written render functions.
  2378. // @ts-expect-error
  2379. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2380. // $attrs & $listeners are exposed for easier HOC creation.
  2381. // they need to be reactive so that HOCs using them are always updated
  2382. const parentData = parentVnode && parentVnode.data;
  2383. /* istanbul ignore else */
  2384. {
  2385. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2386. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2387. }, true);
  2388. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2389. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2390. }, true);
  2391. }
  2392. }
  2393. let currentRenderingInstance = null;
  2394. function renderMixin(Vue) {
  2395. // install runtime convenience helpers
  2396. installRenderHelpers(Vue.prototype);
  2397. Vue.prototype.$nextTick = function (fn) {
  2398. return nextTick(fn, this);
  2399. };
  2400. Vue.prototype._render = function () {
  2401. const vm = this;
  2402. const { render, _parentVnode } = vm.$options;
  2403. if (_parentVnode && vm._isMounted) {
  2404. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2405. if (vm._slotsProxy) {
  2406. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2407. }
  2408. }
  2409. // set parent vnode. this allows render functions to have access
  2410. // to the data on the placeholder node.
  2411. vm.$vnode = _parentVnode;
  2412. // render self
  2413. let vnode;
  2414. try {
  2415. // There's no need to maintain a stack because all render fns are called
  2416. // separately from one another. Nested component's render fns are called
  2417. // when parent component is patched.
  2418. setCurrentInstance(vm);
  2419. currentRenderingInstance = vm;
  2420. vnode = render.call(vm._renderProxy, vm.$createElement);
  2421. }
  2422. catch (e) {
  2423. handleError(e, vm, `render`);
  2424. // return error render result,
  2425. // or previous vnode to prevent render error causing blank component
  2426. /* istanbul ignore else */
  2427. if (vm.$options.renderError) {
  2428. try {
  2429. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2430. }
  2431. catch (e) {
  2432. handleError(e, vm, `renderError`);
  2433. vnode = vm._vnode;
  2434. }
  2435. }
  2436. else {
  2437. vnode = vm._vnode;
  2438. }
  2439. }
  2440. finally {
  2441. currentRenderingInstance = null;
  2442. setCurrentInstance();
  2443. }
  2444. // if the returned array contains only a single node, allow it
  2445. if (isArray(vnode) && vnode.length === 1) {
  2446. vnode = vnode[0];
  2447. }
  2448. // return empty vnode in case the render function errored out
  2449. if (!(vnode instanceof VNode)) {
  2450. if (isArray(vnode)) {
  2451. warn$2('Multiple root nodes returned from render function. Render function ' +
  2452. 'should return a single root node.', vm);
  2453. }
  2454. vnode = createEmptyVNode();
  2455. }
  2456. // set parent
  2457. vnode.parent = _parentVnode;
  2458. return vnode;
  2459. };
  2460. }
  2461. function ensureCtor(comp, base) {
  2462. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2463. comp = comp.default;
  2464. }
  2465. return isObject(comp) ? base.extend(comp) : comp;
  2466. }
  2467. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2468. const node = createEmptyVNode();
  2469. node.asyncFactory = factory;
  2470. node.asyncMeta = { data, context, children, tag };
  2471. return node;
  2472. }
  2473. function resolveAsyncComponent(factory, baseCtor) {
  2474. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2475. return factory.errorComp;
  2476. }
  2477. if (isDef(factory.resolved)) {
  2478. return factory.resolved;
  2479. }
  2480. const owner = currentRenderingInstance;
  2481. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2482. // already pending
  2483. factory.owners.push(owner);
  2484. }
  2485. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2486. return factory.loadingComp;
  2487. }
  2488. if (owner && !isDef(factory.owners)) {
  2489. const owners = (factory.owners = [owner]);
  2490. let sync = true;
  2491. let timerLoading = null;
  2492. let timerTimeout = null;
  2493. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2494. const forceRender = (renderCompleted) => {
  2495. for (let i = 0, l = owners.length; i < l; i++) {
  2496. owners[i].$forceUpdate();
  2497. }
  2498. if (renderCompleted) {
  2499. owners.length = 0;
  2500. if (timerLoading !== null) {
  2501. clearTimeout(timerLoading);
  2502. timerLoading = null;
  2503. }
  2504. if (timerTimeout !== null) {
  2505. clearTimeout(timerTimeout);
  2506. timerTimeout = null;
  2507. }
  2508. }
  2509. };
  2510. const resolve = once((res) => {
  2511. // cache resolved
  2512. factory.resolved = ensureCtor(res, baseCtor);
  2513. // invoke callbacks only if this is not a synchronous resolve
  2514. // (async resolves are shimmed as synchronous during SSR)
  2515. if (!sync) {
  2516. forceRender(true);
  2517. }
  2518. else {
  2519. owners.length = 0;
  2520. }
  2521. });
  2522. const reject = once(reason => {
  2523. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2524. (reason ? `\nReason: ${reason}` : ''));
  2525. if (isDef(factory.errorComp)) {
  2526. factory.error = true;
  2527. forceRender(true);
  2528. }
  2529. });
  2530. const res = factory(resolve, reject);
  2531. if (isObject(res)) {
  2532. if (isPromise(res)) {
  2533. // () => Promise
  2534. if (isUndef(factory.resolved)) {
  2535. res.then(resolve, reject);
  2536. }
  2537. }
  2538. else if (isPromise(res.component)) {
  2539. res.component.then(resolve, reject);
  2540. if (isDef(res.error)) {
  2541. factory.errorComp = ensureCtor(res.error, baseCtor);
  2542. }
  2543. if (isDef(res.loading)) {
  2544. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2545. if (res.delay === 0) {
  2546. factory.loading = true;
  2547. }
  2548. else {
  2549. // @ts-expect-error NodeJS timeout type
  2550. timerLoading = setTimeout(() => {
  2551. timerLoading = null;
  2552. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2553. factory.loading = true;
  2554. forceRender(false);
  2555. }
  2556. }, res.delay || 200);
  2557. }
  2558. }
  2559. if (isDef(res.timeout)) {
  2560. // @ts-expect-error NodeJS timeout type
  2561. timerTimeout = setTimeout(() => {
  2562. timerTimeout = null;
  2563. if (isUndef(factory.resolved)) {
  2564. reject(`timeout (${res.timeout}ms)` );
  2565. }
  2566. }, res.timeout);
  2567. }
  2568. }
  2569. }
  2570. sync = false;
  2571. // return in case resolved synchronously
  2572. return factory.loading ? factory.loadingComp : factory.resolved;
  2573. }
  2574. }
  2575. function getFirstComponentChild(children) {
  2576. if (isArray(children)) {
  2577. for (let i = 0; i < children.length; i++) {
  2578. const c = children[i];
  2579. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2580. return c;
  2581. }
  2582. }
  2583. }
  2584. }
  2585. function initEvents(vm) {
  2586. vm._events = Object.create(null);
  2587. vm._hasHookEvent = false;
  2588. // init parent attached events
  2589. const listeners = vm.$options._parentListeners;
  2590. if (listeners) {
  2591. updateComponentListeners(vm, listeners);
  2592. }
  2593. }
  2594. let target$1;
  2595. function add$1(event, fn) {
  2596. target$1.$on(event, fn);
  2597. }
  2598. function remove$1(event, fn) {
  2599. target$1.$off(event, fn);
  2600. }
  2601. function createOnceHandler$1(event, fn) {
  2602. const _target = target$1;
  2603. return function onceHandler() {
  2604. const res = fn.apply(null, arguments);
  2605. if (res !== null) {
  2606. _target.$off(event, onceHandler);
  2607. }
  2608. };
  2609. }
  2610. function updateComponentListeners(vm, listeners, oldListeners) {
  2611. target$1 = vm;
  2612. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2613. target$1 = undefined;
  2614. }
  2615. function eventsMixin(Vue) {
  2616. const hookRE = /^hook:/;
  2617. Vue.prototype.$on = function (event, fn) {
  2618. const vm = this;
  2619. if (isArray(event)) {
  2620. for (let i = 0, l = event.length; i < l; i++) {
  2621. vm.$on(event[i], fn);
  2622. }
  2623. }
  2624. else {
  2625. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2626. // optimize hook:event cost by using a boolean flag marked at registration
  2627. // instead of a hash lookup
  2628. if (hookRE.test(event)) {
  2629. vm._hasHookEvent = true;
  2630. }
  2631. }
  2632. return vm;
  2633. };
  2634. Vue.prototype.$once = function (event, fn) {
  2635. const vm = this;
  2636. function on() {
  2637. vm.$off(event, on);
  2638. fn.apply(vm, arguments);
  2639. }
  2640. on.fn = fn;
  2641. vm.$on(event, on);
  2642. return vm;
  2643. };
  2644. Vue.prototype.$off = function (event, fn) {
  2645. const vm = this;
  2646. // all
  2647. if (!arguments.length) {
  2648. vm._events = Object.create(null);
  2649. return vm;
  2650. }
  2651. // array of events
  2652. if (isArray(event)) {
  2653. for (let i = 0, l = event.length; i < l; i++) {
  2654. vm.$off(event[i], fn);
  2655. }
  2656. return vm;
  2657. }
  2658. // specific event
  2659. const cbs = vm._events[event];
  2660. if (!cbs) {
  2661. return vm;
  2662. }
  2663. if (!fn) {
  2664. vm._events[event] = null;
  2665. return vm;
  2666. }
  2667. // specific handler
  2668. let cb;
  2669. let i = cbs.length;
  2670. while (i--) {
  2671. cb = cbs[i];
  2672. if (cb === fn || cb.fn === fn) {
  2673. cbs.splice(i, 1);
  2674. break;
  2675. }
  2676. }
  2677. return vm;
  2678. };
  2679. Vue.prototype.$emit = function (event) {
  2680. const vm = this;
  2681. {
  2682. const lowerCaseEvent = event.toLowerCase();
  2683. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2684. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2685. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2686. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2687. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2688. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2689. }
  2690. }
  2691. let cbs = vm._events[event];
  2692. if (cbs) {
  2693. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2694. const args = toArray(arguments, 1);
  2695. const info = `event handler for "${event}"`;
  2696. for (let i = 0, l = cbs.length; i < l; i++) {
  2697. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2698. }
  2699. }
  2700. return vm;
  2701. };
  2702. }
  2703. let activeInstance = null;
  2704. let isUpdatingChildComponent = false;
  2705. function setActiveInstance(vm) {
  2706. const prevActiveInstance = activeInstance;
  2707. activeInstance = vm;
  2708. return () => {
  2709. activeInstance = prevActiveInstance;
  2710. };
  2711. }
  2712. function initLifecycle(vm) {
  2713. const options = vm.$options;
  2714. // locate first non-abstract parent
  2715. let parent = options.parent;
  2716. if (parent && !options.abstract) {
  2717. while (parent.$options.abstract && parent.$parent) {
  2718. parent = parent.$parent;
  2719. }
  2720. parent.$children.push(vm);
  2721. }
  2722. vm.$parent = parent;
  2723. vm.$root = parent ? parent.$root : vm;
  2724. vm.$children = [];
  2725. vm.$refs = {};
  2726. vm._provided = parent ? parent._provided : Object.create(null);
  2727. vm._watcher = null;
  2728. vm._inactive = null;
  2729. vm._directInactive = false;
  2730. vm._isMounted = false;
  2731. vm._isDestroyed = false;
  2732. vm._isBeingDestroyed = false;
  2733. }
  2734. function lifecycleMixin(Vue) {
  2735. Vue.prototype._update = function (vnode, hydrating) {
  2736. const vm = this;
  2737. const prevEl = vm.$el;
  2738. const prevVnode = vm._vnode;
  2739. const restoreActiveInstance = setActiveInstance(vm);
  2740. vm._vnode = vnode;
  2741. // Vue.prototype.__patch__ is injected in entry points
  2742. // based on the rendering backend used.
  2743. if (!prevVnode) {
  2744. // initial render
  2745. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2746. }
  2747. else {
  2748. // updates
  2749. vm.$el = vm.__patch__(prevVnode, vnode);
  2750. }
  2751. restoreActiveInstance();
  2752. // update __vue__ reference
  2753. if (prevEl) {
  2754. prevEl.__vue__ = null;
  2755. }
  2756. if (vm.$el) {
  2757. vm.$el.__vue__ = vm;
  2758. }
  2759. // if parent is an HOC, update its $el as well
  2760. let wrapper = vm;
  2761. while (wrapper &&
  2762. wrapper.$vnode &&
  2763. wrapper.$parent &&
  2764. wrapper.$vnode === wrapper.$parent._vnode) {
  2765. wrapper.$parent.$el = wrapper.$el;
  2766. wrapper = wrapper.$parent;
  2767. }
  2768. // updated hook is called by the scheduler to ensure that children are
  2769. // updated in a parent's updated hook.
  2770. };
  2771. Vue.prototype.$forceUpdate = function () {
  2772. const vm = this;
  2773. if (vm._watcher) {
  2774. vm._watcher.update();
  2775. }
  2776. };
  2777. Vue.prototype.$destroy = function () {
  2778. const vm = this;
  2779. if (vm._isBeingDestroyed) {
  2780. return;
  2781. }
  2782. callHook$1(vm, 'beforeDestroy');
  2783. vm._isBeingDestroyed = true;
  2784. // remove self from parent
  2785. const parent = vm.$parent;
  2786. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2787. remove$2(parent.$children, vm);
  2788. }
  2789. // teardown scope. this includes both the render watcher and other
  2790. // watchers created
  2791. vm._scope.stop();
  2792. // remove reference from data ob
  2793. // frozen object may not have observer.
  2794. if (vm._data.__ob__) {
  2795. vm._data.__ob__.vmCount--;
  2796. }
  2797. // call the last hook...
  2798. vm._isDestroyed = true;
  2799. // invoke destroy hooks on current rendered tree
  2800. vm.__patch__(vm._vnode, null);
  2801. // fire destroyed hook
  2802. callHook$1(vm, 'destroyed');
  2803. // turn off all instance listeners.
  2804. vm.$off();
  2805. // remove __vue__ reference
  2806. if (vm.$el) {
  2807. vm.$el.__vue__ = null;
  2808. }
  2809. // release circular reference (#6759)
  2810. if (vm.$vnode) {
  2811. vm.$vnode.parent = null;
  2812. }
  2813. };
  2814. }
  2815. function mountComponent(vm, el, hydrating) {
  2816. vm.$el = el;
  2817. if (!vm.$options.render) {
  2818. // @ts-expect-error invalid type
  2819. vm.$options.render = createEmptyVNode;
  2820. {
  2821. /* istanbul ignore if */
  2822. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2823. vm.$options.el ||
  2824. el) {
  2825. warn$2('You are using the runtime-only build of Vue where the template ' +
  2826. 'compiler is not available. Either pre-compile the templates into ' +
  2827. 'render functions, or use the compiler-included build.', vm);
  2828. }
  2829. else {
  2830. warn$2('Failed to mount component: template or render function not defined.', vm);
  2831. }
  2832. }
  2833. }
  2834. callHook$1(vm, 'beforeMount');
  2835. let updateComponent;
  2836. /* istanbul ignore if */
  2837. if (config.performance && mark) {
  2838. updateComponent = () => {
  2839. const name = vm._name;
  2840. const id = vm._uid;
  2841. const startTag = `vue-perf-start:${id}`;
  2842. const endTag = `vue-perf-end:${id}`;
  2843. mark(startTag);
  2844. const vnode = vm._render();
  2845. mark(endTag);
  2846. measure(`vue ${name} render`, startTag, endTag);
  2847. mark(startTag);
  2848. vm._update(vnode, hydrating);
  2849. mark(endTag);
  2850. measure(`vue ${name} patch`, startTag, endTag);
  2851. };
  2852. }
  2853. else {
  2854. updateComponent = () => {
  2855. vm._update(vm._render(), hydrating);
  2856. };
  2857. }
  2858. const watcherOptions = {
  2859. before() {
  2860. if (vm._isMounted && !vm._isDestroyed) {
  2861. callHook$1(vm, 'beforeUpdate');
  2862. }
  2863. }
  2864. };
  2865. {
  2866. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2867. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2868. }
  2869. // we set this to vm._watcher inside the watcher's constructor
  2870. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2871. // component's mounted hook), which relies on vm._watcher being already defined
  2872. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2873. hydrating = false;
  2874. // flush buffer for flush: "pre" watchers queued in setup()
  2875. const preWatchers = vm._preWatchers;
  2876. if (preWatchers) {
  2877. for (let i = 0; i < preWatchers.length; i++) {
  2878. preWatchers[i].run();
  2879. }
  2880. }
  2881. // manually mounted instance, call mounted on self
  2882. // mounted is called for render-created child components in its inserted hook
  2883. if (vm.$vnode == null) {
  2884. vm._isMounted = true;
  2885. callHook$1(vm, 'mounted');
  2886. }
  2887. return vm;
  2888. }
  2889. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2890. {
  2891. isUpdatingChildComponent = true;
  2892. }
  2893. // determine whether component has slot children
  2894. // we need to do this before overwriting $options._renderChildren.
  2895. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2896. // dynamic slot names). Static scoped slots compiled from template has the
  2897. // "$stable" marker.
  2898. const newScopedSlots = parentVnode.data.scopedSlots;
  2899. const oldScopedSlots = vm.$scopedSlots;
  2900. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  2901. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  2902. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  2903. (!newScopedSlots && vm.$scopedSlots.$key));
  2904. // Any static slot children from the parent may have changed during parent's
  2905. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  2906. // update is necessary to ensure correctness.
  2907. let needsForceUpdate = !!(renderChildren || // has new static slots
  2908. vm.$options._renderChildren || // has old static slots
  2909. hasDynamicScopedSlot);
  2910. const prevVNode = vm.$vnode;
  2911. vm.$options._parentVnode = parentVnode;
  2912. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2913. if (vm._vnode) {
  2914. // update child tree's parent
  2915. vm._vnode.parent = parentVnode;
  2916. }
  2917. vm.$options._renderChildren = renderChildren;
  2918. // update $attrs and $listeners hash
  2919. // these are also reactive so they may trigger child update if the child
  2920. // used them during render
  2921. const attrs = parentVnode.data.attrs || emptyObject;
  2922. if (vm._attrsProxy) {
  2923. // force update if attrs are accessed and has changed since it may be
  2924. // passed to a child component.
  2925. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  2926. needsForceUpdate = true;
  2927. }
  2928. }
  2929. vm.$attrs = attrs;
  2930. // update listeners
  2931. listeners = listeners || emptyObject;
  2932. const prevListeners = vm.$options._parentListeners;
  2933. if (vm._listenersProxy) {
  2934. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  2935. }
  2936. vm.$listeners = vm.$options._parentListeners = listeners;
  2937. updateComponentListeners(vm, listeners, prevListeners);
  2938. // update props
  2939. if (propsData && vm.$options.props) {
  2940. toggleObserving(false);
  2941. const props = vm._props;
  2942. const propKeys = vm.$options._propKeys || [];
  2943. for (let i = 0; i < propKeys.length; i++) {
  2944. const key = propKeys[i];
  2945. const propOptions = vm.$options.props; // wtf flow?
  2946. props[key] = validateProp(key, propOptions, propsData, vm);
  2947. }
  2948. toggleObserving(true);
  2949. // keep a copy of raw propsData
  2950. vm.$options.propsData = propsData;
  2951. }
  2952. // resolve slots + force update if has children
  2953. if (needsForceUpdate) {
  2954. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2955. vm.$forceUpdate();
  2956. }
  2957. {
  2958. isUpdatingChildComponent = false;
  2959. }
  2960. }
  2961. function isInInactiveTree(vm) {
  2962. while (vm && (vm = vm.$parent)) {
  2963. if (vm._inactive)
  2964. return true;
  2965. }
  2966. return false;
  2967. }
  2968. function activateChildComponent(vm, direct) {
  2969. if (direct) {
  2970. vm._directInactive = false;
  2971. if (isInInactiveTree(vm)) {
  2972. return;
  2973. }
  2974. }
  2975. else if (vm._directInactive) {
  2976. return;
  2977. }
  2978. if (vm._inactive || vm._inactive === null) {
  2979. vm._inactive = false;
  2980. for (let i = 0; i < vm.$children.length; i++) {
  2981. activateChildComponent(vm.$children[i]);
  2982. }
  2983. callHook$1(vm, 'activated');
  2984. }
  2985. }
  2986. function deactivateChildComponent(vm, direct) {
  2987. if (direct) {
  2988. vm._directInactive = true;
  2989. if (isInInactiveTree(vm)) {
  2990. return;
  2991. }
  2992. }
  2993. if (!vm._inactive) {
  2994. vm._inactive = true;
  2995. for (let i = 0; i < vm.$children.length; i++) {
  2996. deactivateChildComponent(vm.$children[i]);
  2997. }
  2998. callHook$1(vm, 'deactivated');
  2999. }
  3000. }
  3001. function callHook$1(vm, hook, args, setContext = true) {
  3002. // #7573 disable dep collection when invoking lifecycle hooks
  3003. pushTarget();
  3004. const prev = currentInstance;
  3005. setContext && setCurrentInstance(vm);
  3006. const handlers = vm.$options[hook];
  3007. const info = `${hook} hook`;
  3008. if (handlers) {
  3009. for (let i = 0, j = handlers.length; i < j; i++) {
  3010. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3011. }
  3012. }
  3013. if (vm._hasHookEvent) {
  3014. vm.$emit('hook:' + hook);
  3015. }
  3016. setContext && setCurrentInstance(prev);
  3017. popTarget();
  3018. }
  3019. const MAX_UPDATE_COUNT = 100;
  3020. const queue = [];
  3021. const activatedChildren = [];
  3022. let has = {};
  3023. let circular = {};
  3024. let waiting = false;
  3025. let flushing = false;
  3026. let index$1 = 0;
  3027. /**
  3028. * Reset the scheduler's state.
  3029. */
  3030. function resetSchedulerState() {
  3031. index$1 = queue.length = activatedChildren.length = 0;
  3032. has = {};
  3033. {
  3034. circular = {};
  3035. }
  3036. waiting = flushing = false;
  3037. }
  3038. // Async edge case #6566 requires saving the timestamp when event listeners are
  3039. // attached. However, calling performance.now() has a perf overhead especially
  3040. // if the page has thousands of event listeners. Instead, we take a timestamp
  3041. // every time the scheduler flushes and use that for all event listeners
  3042. // attached during that flush.
  3043. let currentFlushTimestamp = 0;
  3044. // Async edge case fix requires storing an event listener's attach timestamp.
  3045. let getNow = Date.now;
  3046. // Determine what event timestamp the browser is using. Annoyingly, the
  3047. // timestamp can either be hi-res (relative to page load) or low-res
  3048. // (relative to UNIX epoch), so in order to compare time we have to use the
  3049. // same timestamp type when saving the flush timestamp.
  3050. // All IE versions use low-res event timestamps, and have problematic clock
  3051. // implementations (#9632)
  3052. if (inBrowser && !isIE) {
  3053. const performance = window.performance;
  3054. if (performance &&
  3055. typeof performance.now === 'function' &&
  3056. getNow() > document.createEvent('Event').timeStamp) {
  3057. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3058. // smaller than it, it means the event is using a hi-res timestamp,
  3059. // and we need to use the hi-res version for event listener timestamps as
  3060. // well.
  3061. getNow = () => performance.now();
  3062. }
  3063. }
  3064. const sortCompareFn = (a, b) => {
  3065. if (a.post) {
  3066. if (!b.post)
  3067. return 1;
  3068. }
  3069. else if (b.post) {
  3070. return -1;
  3071. }
  3072. return a.id - b.id;
  3073. };
  3074. /**
  3075. * Flush both queues and run the watchers.
  3076. */
  3077. function flushSchedulerQueue() {
  3078. currentFlushTimestamp = getNow();
  3079. flushing = true;
  3080. let watcher, id;
  3081. // Sort queue before flush.
  3082. // This ensures that:
  3083. // 1. Components are updated from parent to child. (because parent is always
  3084. // created before the child)
  3085. // 2. A component's user watchers are run before its render watcher (because
  3086. // user watchers are created before the render watcher)
  3087. // 3. If a component is destroyed during a parent component's watcher run,
  3088. // its watchers can be skipped.
  3089. queue.sort(sortCompareFn);
  3090. // do not cache length because more watchers might be pushed
  3091. // as we run existing watchers
  3092. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3093. watcher = queue[index$1];
  3094. if (watcher.before) {
  3095. watcher.before();
  3096. }
  3097. id = watcher.id;
  3098. has[id] = null;
  3099. watcher.run();
  3100. // in dev build, check and stop circular updates.
  3101. if (has[id] != null) {
  3102. circular[id] = (circular[id] || 0) + 1;
  3103. if (circular[id] > MAX_UPDATE_COUNT) {
  3104. warn$2('You may have an infinite update loop ' +
  3105. (watcher.user
  3106. ? `in watcher with expression "${watcher.expression}"`
  3107. : `in a component render function.`), watcher.vm);
  3108. break;
  3109. }
  3110. }
  3111. }
  3112. // keep copies of post queues before resetting state
  3113. const activatedQueue = activatedChildren.slice();
  3114. const updatedQueue = queue.slice();
  3115. resetSchedulerState();
  3116. // call component updated and activated hooks
  3117. callActivatedHooks(activatedQueue);
  3118. callUpdatedHooks(updatedQueue);
  3119. cleanupDeps();
  3120. // devtool hook
  3121. /* istanbul ignore if */
  3122. if (devtools && config.devtools) {
  3123. devtools.emit('flush');
  3124. }
  3125. }
  3126. function callUpdatedHooks(queue) {
  3127. let i = queue.length;
  3128. while (i--) {
  3129. const watcher = queue[i];
  3130. const vm = watcher.vm;
  3131. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3132. callHook$1(vm, 'updated');
  3133. }
  3134. }
  3135. }
  3136. /**
  3137. * Queue a kept-alive component that was activated during patch.
  3138. * The queue will be processed after the entire tree has been patched.
  3139. */
  3140. function queueActivatedComponent(vm) {
  3141. // setting _inactive to false here so that a render function can
  3142. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3143. vm._inactive = false;
  3144. activatedChildren.push(vm);
  3145. }
  3146. function callActivatedHooks(queue) {
  3147. for (let i = 0; i < queue.length; i++) {
  3148. queue[i]._inactive = true;
  3149. activateChildComponent(queue[i], true /* true */);
  3150. }
  3151. }
  3152. /**
  3153. * Push a watcher into the watcher queue.
  3154. * Jobs with duplicate IDs will be skipped unless it's
  3155. * pushed when the queue is being flushed.
  3156. */
  3157. function queueWatcher(watcher) {
  3158. const id = watcher.id;
  3159. if (has[id] != null) {
  3160. return;
  3161. }
  3162. if (watcher === Dep.target && watcher.noRecurse) {
  3163. return;
  3164. }
  3165. has[id] = true;
  3166. if (!flushing) {
  3167. queue.push(watcher);
  3168. }
  3169. else {
  3170. // if already flushing, splice the watcher based on its id
  3171. // if already past its id, it will be run next immediately.
  3172. let i = queue.length - 1;
  3173. while (i > index$1 && queue[i].id > watcher.id) {
  3174. i--;
  3175. }
  3176. queue.splice(i + 1, 0, watcher);
  3177. }
  3178. // queue the flush
  3179. if (!waiting) {
  3180. waiting = true;
  3181. if (!config.async) {
  3182. flushSchedulerQueue();
  3183. return;
  3184. }
  3185. nextTick(flushSchedulerQueue);
  3186. }
  3187. }
  3188. const WATCHER = `watcher`;
  3189. const WATCHER_CB = `${WATCHER} callback`;
  3190. const WATCHER_GETTER = `${WATCHER} getter`;
  3191. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3192. // Simple effect.
  3193. function watchEffect(effect, options) {
  3194. return doWatch(effect, null, options);
  3195. }
  3196. function watchPostEffect(effect, options) {
  3197. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3198. }
  3199. function watchSyncEffect(effect, options) {
  3200. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3201. }
  3202. // initial value for watchers to trigger on undefined initial values
  3203. const INITIAL_WATCHER_VALUE = {};
  3204. // implementation
  3205. function watch(source, cb, options) {
  3206. if (typeof cb !== 'function') {
  3207. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3208. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3209. `supports \`watch(source, cb, options?) signature.`);
  3210. }
  3211. return doWatch(source, cb, options);
  3212. }
  3213. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3214. if (!cb) {
  3215. if (immediate !== undefined) {
  3216. warn$2(`watch() "immediate" option is only respected when using the ` +
  3217. `watch(source, callback, options?) signature.`);
  3218. }
  3219. if (deep !== undefined) {
  3220. warn$2(`watch() "deep" option is only respected when using the ` +
  3221. `watch(source, callback, options?) signature.`);
  3222. }
  3223. }
  3224. const warnInvalidSource = (s) => {
  3225. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3226. `function, a ref, a reactive object, or an array of these types.`);
  3227. };
  3228. const instance = currentInstance;
  3229. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3230. let getter;
  3231. let forceTrigger = false;
  3232. let isMultiSource = false;
  3233. if (isRef(source)) {
  3234. getter = () => source.value;
  3235. forceTrigger = isShallow(source);
  3236. }
  3237. else if (isReactive(source)) {
  3238. getter = () => {
  3239. source.__ob__.dep.depend();
  3240. return source;
  3241. };
  3242. deep = true;
  3243. }
  3244. else if (isArray(source)) {
  3245. isMultiSource = true;
  3246. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3247. getter = () => source.map(s => {
  3248. if (isRef(s)) {
  3249. return s.value;
  3250. }
  3251. else if (isReactive(s)) {
  3252. return traverse(s);
  3253. }
  3254. else if (isFunction(s)) {
  3255. return call(s, WATCHER_GETTER);
  3256. }
  3257. else {
  3258. warnInvalidSource(s);
  3259. }
  3260. });
  3261. }
  3262. else if (isFunction(source)) {
  3263. if (cb) {
  3264. // getter with cb
  3265. getter = () => call(source, WATCHER_GETTER);
  3266. }
  3267. else {
  3268. // no cb -> simple effect
  3269. getter = () => {
  3270. if (instance && instance._isDestroyed) {
  3271. return;
  3272. }
  3273. if (cleanup) {
  3274. cleanup();
  3275. }
  3276. return call(source, WATCHER, [onCleanup]);
  3277. };
  3278. }
  3279. }
  3280. else {
  3281. getter = noop;
  3282. warnInvalidSource(source);
  3283. }
  3284. if (cb && deep) {
  3285. const baseGetter = getter;
  3286. getter = () => traverse(baseGetter());
  3287. }
  3288. let cleanup;
  3289. let onCleanup = (fn) => {
  3290. cleanup = watcher.onStop = () => {
  3291. call(fn, WATCHER_CLEANUP);
  3292. };
  3293. };
  3294. // in SSR there is no need to setup an actual effect, and it should be noop
  3295. // unless it's eager
  3296. if (isServerRendering()) {
  3297. // we will also not call the invalidate callback (+ runner is not set up)
  3298. onCleanup = noop;
  3299. if (!cb) {
  3300. getter();
  3301. }
  3302. else if (immediate) {
  3303. call(cb, WATCHER_CB, [
  3304. getter(),
  3305. isMultiSource ? [] : undefined,
  3306. onCleanup
  3307. ]);
  3308. }
  3309. return noop;
  3310. }
  3311. const watcher = new Watcher(currentInstance, getter, noop, {
  3312. lazy: true
  3313. });
  3314. watcher.noRecurse = !cb;
  3315. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3316. // overwrite default run
  3317. watcher.run = () => {
  3318. if (!watcher.active) {
  3319. return;
  3320. }
  3321. if (cb) {
  3322. // watch(source, cb)
  3323. const newValue = watcher.get();
  3324. if (deep ||
  3325. forceTrigger ||
  3326. (isMultiSource
  3327. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3328. : hasChanged(newValue, oldValue))) {
  3329. // cleanup before running cb again
  3330. if (cleanup) {
  3331. cleanup();
  3332. }
  3333. call(cb, WATCHER_CB, [
  3334. newValue,
  3335. // pass undefined as the old value when it's changed for the first time
  3336. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3337. onCleanup
  3338. ]);
  3339. oldValue = newValue;
  3340. }
  3341. }
  3342. else {
  3343. // watchEffect
  3344. watcher.get();
  3345. }
  3346. };
  3347. if (flush === 'sync') {
  3348. watcher.update = watcher.run;
  3349. }
  3350. else if (flush === 'post') {
  3351. watcher.post = true;
  3352. watcher.update = () => queueWatcher(watcher);
  3353. }
  3354. else {
  3355. // pre
  3356. watcher.update = () => {
  3357. if (instance && instance === currentInstance && !instance._isMounted) {
  3358. // pre-watcher triggered before
  3359. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3360. if (buffer.indexOf(watcher) < 0)
  3361. buffer.push(watcher);
  3362. }
  3363. else {
  3364. queueWatcher(watcher);
  3365. }
  3366. };
  3367. }
  3368. {
  3369. watcher.onTrack = onTrack;
  3370. watcher.onTrigger = onTrigger;
  3371. }
  3372. // initial run
  3373. if (cb) {
  3374. if (immediate) {
  3375. watcher.run();
  3376. }
  3377. else {
  3378. oldValue = watcher.get();
  3379. }
  3380. }
  3381. else if (flush === 'post' && instance) {
  3382. instance.$once('hook:mounted', () => watcher.get());
  3383. }
  3384. else {
  3385. watcher.get();
  3386. }
  3387. return () => {
  3388. watcher.teardown();
  3389. };
  3390. }
  3391. let activeEffectScope;
  3392. class EffectScope {
  3393. constructor(detached = false) {
  3394. this.detached = detached;
  3395. /**
  3396. * @internal
  3397. */
  3398. this.active = true;
  3399. /**
  3400. * @internal
  3401. */
  3402. this.effects = [];
  3403. /**
  3404. * @internal
  3405. */
  3406. this.cleanups = [];
  3407. this.parent = activeEffectScope;
  3408. if (!detached && activeEffectScope) {
  3409. this.index =
  3410. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  3411. }
  3412. }
  3413. run(fn) {
  3414. if (this.active) {
  3415. const currentEffectScope = activeEffectScope;
  3416. try {
  3417. activeEffectScope = this;
  3418. return fn();
  3419. }
  3420. finally {
  3421. activeEffectScope = currentEffectScope;
  3422. }
  3423. }
  3424. else {
  3425. warn$2(`cannot run an inactive effect scope.`);
  3426. }
  3427. }
  3428. /**
  3429. * This should only be called on non-detached scopes
  3430. * @internal
  3431. */
  3432. on() {
  3433. activeEffectScope = this;
  3434. }
  3435. /**
  3436. * This should only be called on non-detached scopes
  3437. * @internal
  3438. */
  3439. off() {
  3440. activeEffectScope = this.parent;
  3441. }
  3442. stop(fromParent) {
  3443. if (this.active) {
  3444. let i, l;
  3445. for (i = 0, l = this.effects.length; i < l; i++) {
  3446. this.effects[i].teardown();
  3447. }
  3448. for (i = 0, l = this.cleanups.length; i < l; i++) {
  3449. this.cleanups[i]();
  3450. }
  3451. if (this.scopes) {
  3452. for (i = 0, l = this.scopes.length; i < l; i++) {
  3453. this.scopes[i].stop(true);
  3454. }
  3455. }
  3456. // nested scope, dereference from parent to avoid memory leaks
  3457. if (!this.detached && this.parent && !fromParent) {
  3458. // optimized O(1) removal
  3459. const last = this.parent.scopes.pop();
  3460. if (last && last !== this) {
  3461. this.parent.scopes[this.index] = last;
  3462. last.index = this.index;
  3463. }
  3464. }
  3465. this.parent = undefined;
  3466. this.active = false;
  3467. }
  3468. }
  3469. }
  3470. function effectScope(detached) {
  3471. return new EffectScope(detached);
  3472. }
  3473. /**
  3474. * @internal
  3475. */
  3476. function recordEffectScope(effect, scope = activeEffectScope) {
  3477. if (scope && scope.active) {
  3478. scope.effects.push(effect);
  3479. }
  3480. }
  3481. function getCurrentScope() {
  3482. return activeEffectScope;
  3483. }
  3484. function onScopeDispose(fn) {
  3485. if (activeEffectScope) {
  3486. activeEffectScope.cleanups.push(fn);
  3487. }
  3488. else {
  3489. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  3490. ` to be associated with.`);
  3491. }
  3492. }
  3493. function provide(key, value) {
  3494. if (!currentInstance) {
  3495. {
  3496. warn$2(`provide() can only be used inside setup().`);
  3497. }
  3498. }
  3499. else {
  3500. // TS doesn't allow symbol as index type
  3501. resolveProvided(currentInstance)[key] = value;
  3502. }
  3503. }
  3504. function resolveProvided(vm) {
  3505. // by default an instance inherits its parent's provides object
  3506. // but when it needs to provide values of its own, it creates its
  3507. // own provides object using parent provides object as prototype.
  3508. // this way in `inject` we can simply look up injections from direct
  3509. // parent and let the prototype chain do the work.
  3510. const existing = vm._provided;
  3511. const parentProvides = vm.$parent && vm.$parent._provided;
  3512. if (parentProvides === existing) {
  3513. return (vm._provided = Object.create(parentProvides));
  3514. }
  3515. else {
  3516. return existing;
  3517. }
  3518. }
  3519. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3520. // fallback to `currentRenderingInstance` so that this can be called in
  3521. // a functional component
  3522. const instance = currentInstance;
  3523. if (instance) {
  3524. // #2400
  3525. // to support `app.use` plugins,
  3526. // fallback to appContext's `provides` if the instance is at root
  3527. const provides = instance.$parent && instance.$parent._provided;
  3528. if (provides && key in provides) {
  3529. // TS doesn't allow symbol as index type
  3530. return provides[key];
  3531. }
  3532. else if (arguments.length > 1) {
  3533. return treatDefaultAsFactory && isFunction(defaultValue)
  3534. ? defaultValue.call(instance)
  3535. : defaultValue;
  3536. }
  3537. else {
  3538. warn$2(`injection "${String(key)}" not found.`);
  3539. }
  3540. }
  3541. else {
  3542. warn$2(`inject() can only be used inside setup() or functional components.`);
  3543. }
  3544. }
  3545. /**
  3546. * @internal this function needs manual public type declaration because it relies
  3547. * on previously manually authored types from Vue 2
  3548. */
  3549. function h(type, props, children) {
  3550. if (!currentInstance) {
  3551. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3552. `component instance, e.g. synchronously in a component's render or setup function.`);
  3553. }
  3554. return createElement$1(currentInstance, type, props, children, 2, true);
  3555. }
  3556. function handleError(err, vm, info) {
  3557. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3558. // See: https://github.com/vuejs/vuex/issues/1505
  3559. pushTarget();
  3560. try {
  3561. if (vm) {
  3562. let cur = vm;
  3563. while ((cur = cur.$parent)) {
  3564. const hooks = cur.$options.errorCaptured;
  3565. if (hooks) {
  3566. for (let i = 0; i < hooks.length; i++) {
  3567. try {
  3568. const capture = hooks[i].call(cur, err, vm, info) === false;
  3569. if (capture)
  3570. return;
  3571. }
  3572. catch (e) {
  3573. globalHandleError(e, cur, 'errorCaptured hook');
  3574. }
  3575. }
  3576. }
  3577. }
  3578. }
  3579. globalHandleError(err, vm, info);
  3580. }
  3581. finally {
  3582. popTarget();
  3583. }
  3584. }
  3585. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3586. let res;
  3587. try {
  3588. res = args ? handler.apply(context, args) : handler.call(context);
  3589. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3590. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3591. res._handled = true;
  3592. }
  3593. }
  3594. catch (e) {
  3595. handleError(e, vm, info);
  3596. }
  3597. return res;
  3598. }
  3599. function globalHandleError(err, vm, info) {
  3600. if (config.errorHandler) {
  3601. try {
  3602. return config.errorHandler.call(null, err, vm, info);
  3603. }
  3604. catch (e) {
  3605. // if the user intentionally throws the original error in the handler,
  3606. // do not log it twice
  3607. if (e !== err) {
  3608. logError(e, null, 'config.errorHandler');
  3609. }
  3610. }
  3611. }
  3612. logError(err, vm, info);
  3613. }
  3614. function logError(err, vm, info) {
  3615. {
  3616. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3617. }
  3618. /* istanbul ignore else */
  3619. if (inBrowser && typeof console !== 'undefined') {
  3620. console.error(err);
  3621. }
  3622. else {
  3623. throw err;
  3624. }
  3625. }
  3626. /* globals MutationObserver */
  3627. let isUsingMicroTask = false;
  3628. const callbacks = [];
  3629. let pending = false;
  3630. function flushCallbacks() {
  3631. pending = false;
  3632. const copies = callbacks.slice(0);
  3633. callbacks.length = 0;
  3634. for (let i = 0; i < copies.length; i++) {
  3635. copies[i]();
  3636. }
  3637. }
  3638. // Here we have async deferring wrappers using microtasks.
  3639. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3640. // However, it has subtle problems when state is changed right before repaint
  3641. // (e.g. #6813, out-in transitions).
  3642. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3643. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3644. // So we now use microtasks everywhere, again.
  3645. // A major drawback of this tradeoff is that there are some scenarios
  3646. // where microtasks have too high a priority and fire in between supposedly
  3647. // sequential events (e.g. #4521, #6690, which have workarounds)
  3648. // or even between bubbling of the same event (#6566).
  3649. let timerFunc;
  3650. // The nextTick behavior leverages the microtask queue, which can be accessed
  3651. // via either native Promise.then or MutationObserver.
  3652. // MutationObserver has wider support, however it is seriously bugged in
  3653. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3654. // completely stops working after triggering a few times... so, if native
  3655. // Promise is available, we will use it:
  3656. /* istanbul ignore next, $flow-disable-line */
  3657. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3658. const p = Promise.resolve();
  3659. timerFunc = () => {
  3660. p.then(flushCallbacks);
  3661. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3662. // it can get stuck in a weird state where callbacks are pushed into the
  3663. // microtask queue but the queue isn't being flushed, until the browser
  3664. // needs to do some other work, e.g. handle a timer. Therefore we can
  3665. // "force" the microtask queue to be flushed by adding an empty timer.
  3666. if (isIOS)
  3667. setTimeout(noop);
  3668. };
  3669. isUsingMicroTask = true;
  3670. }
  3671. else if (!isIE &&
  3672. typeof MutationObserver !== 'undefined' &&
  3673. (isNative(MutationObserver) ||
  3674. // PhantomJS and iOS 7.x
  3675. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3676. // Use MutationObserver where native Promise is not available,
  3677. // e.g. PhantomJS, iOS7, Android 4.4
  3678. // (#6466 MutationObserver is unreliable in IE11)
  3679. let counter = 1;
  3680. const observer = new MutationObserver(flushCallbacks);
  3681. const textNode = document.createTextNode(String(counter));
  3682. observer.observe(textNode, {
  3683. characterData: true
  3684. });
  3685. timerFunc = () => {
  3686. counter = (counter + 1) % 2;
  3687. textNode.data = String(counter);
  3688. };
  3689. isUsingMicroTask = true;
  3690. }
  3691. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3692. // Fallback to setImmediate.
  3693. // Technically it leverages the (macro) task queue,
  3694. // but it is still a better choice than setTimeout.
  3695. timerFunc = () => {
  3696. setImmediate(flushCallbacks);
  3697. };
  3698. }
  3699. else {
  3700. // Fallback to setTimeout.
  3701. timerFunc = () => {
  3702. setTimeout(flushCallbacks, 0);
  3703. };
  3704. }
  3705. /**
  3706. * @internal
  3707. */
  3708. function nextTick(cb, ctx) {
  3709. let _resolve;
  3710. callbacks.push(() => {
  3711. if (cb) {
  3712. try {
  3713. cb.call(ctx);
  3714. }
  3715. catch (e) {
  3716. handleError(e, ctx, 'nextTick');
  3717. }
  3718. }
  3719. else if (_resolve) {
  3720. _resolve(ctx);
  3721. }
  3722. });
  3723. if (!pending) {
  3724. pending = true;
  3725. timerFunc();
  3726. }
  3727. // $flow-disable-line
  3728. if (!cb && typeof Promise !== 'undefined') {
  3729. return new Promise(resolve => {
  3730. _resolve = resolve;
  3731. });
  3732. }
  3733. }
  3734. function useCssModule(name = '$style') {
  3735. /* istanbul ignore else */
  3736. {
  3737. if (!currentInstance) {
  3738. warn$2(`useCssModule must be called inside setup()`);
  3739. return emptyObject;
  3740. }
  3741. const mod = currentInstance[name];
  3742. if (!mod) {
  3743. warn$2(`Current instance does not have CSS module named "${name}".`);
  3744. return emptyObject;
  3745. }
  3746. return mod;
  3747. }
  3748. }
  3749. /**
  3750. * Runtime helper for SFC's CSS variable injection feature.
  3751. * @private
  3752. */
  3753. function useCssVars(getter) {
  3754. if (!inBrowser && !false)
  3755. return;
  3756. const instance = currentInstance;
  3757. if (!instance) {
  3758. warn$2(`useCssVars is called without current active component instance.`);
  3759. return;
  3760. }
  3761. watchPostEffect(() => {
  3762. const el = instance.$el;
  3763. const vars = getter(instance, instance._setupProxy);
  3764. if (el && el.nodeType === 1) {
  3765. const style = el.style;
  3766. for (const key in vars) {
  3767. style.setProperty(`--${key}`, vars[key]);
  3768. }
  3769. }
  3770. });
  3771. }
  3772. /**
  3773. * v3-compatible async component API.
  3774. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3775. * because it relies on existing manual types
  3776. */
  3777. function defineAsyncComponent(source) {
  3778. if (isFunction(source)) {
  3779. source = { loader: source };
  3780. }
  3781. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3782. suspensible = false, // in Vue 3 default is true
  3783. onError: userOnError } = source;
  3784. if (suspensible) {
  3785. warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3786. }
  3787. let pendingRequest = null;
  3788. let retries = 0;
  3789. const retry = () => {
  3790. retries++;
  3791. pendingRequest = null;
  3792. return load();
  3793. };
  3794. const load = () => {
  3795. let thisRequest;
  3796. return (pendingRequest ||
  3797. (thisRequest = pendingRequest =
  3798. loader()
  3799. .catch(err => {
  3800. err = err instanceof Error ? err : new Error(String(err));
  3801. if (userOnError) {
  3802. return new Promise((resolve, reject) => {
  3803. const userRetry = () => resolve(retry());
  3804. const userFail = () => reject(err);
  3805. userOnError(err, userRetry, userFail, retries + 1);
  3806. });
  3807. }
  3808. else {
  3809. throw err;
  3810. }
  3811. })
  3812. .then((comp) => {
  3813. if (thisRequest !== pendingRequest && pendingRequest) {
  3814. return pendingRequest;
  3815. }
  3816. if (!comp) {
  3817. warn$2(`Async component loader resolved to undefined. ` +
  3818. `If you are using retry(), make sure to return its return value.`);
  3819. }
  3820. // interop module default
  3821. if (comp &&
  3822. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3823. comp = comp.default;
  3824. }
  3825. if (comp && !isObject(comp) && !isFunction(comp)) {
  3826. throw new Error(`Invalid async component load result: ${comp}`);
  3827. }
  3828. return comp;
  3829. })));
  3830. };
  3831. return () => {
  3832. const component = load();
  3833. return {
  3834. component,
  3835. delay,
  3836. timeout,
  3837. error: errorComponent,
  3838. loading: loadingComponent
  3839. };
  3840. };
  3841. }
  3842. function createLifeCycle(hookName) {
  3843. return (fn, target = currentInstance) => {
  3844. if (!target) {
  3845. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3846. `associated with. ` +
  3847. `Lifecycle injection APIs can only be used during execution of setup().`);
  3848. return;
  3849. }
  3850. return injectHook(target, hookName, fn);
  3851. };
  3852. }
  3853. function formatName(name) {
  3854. if (name === 'beforeDestroy') {
  3855. name = 'beforeUnmount';
  3856. }
  3857. else if (name === 'destroyed') {
  3858. name = 'unmounted';
  3859. }
  3860. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3861. }
  3862. function injectHook(instance, hookName, fn) {
  3863. const options = instance.$options;
  3864. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3865. }
  3866. const onBeforeMount = createLifeCycle('beforeMount');
  3867. const onMounted = createLifeCycle('mounted');
  3868. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3869. const onUpdated = createLifeCycle('updated');
  3870. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3871. const onUnmounted = createLifeCycle('destroyed');
  3872. const onActivated = createLifeCycle('activated');
  3873. const onDeactivated = createLifeCycle('deactivated');
  3874. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3875. const onRenderTracked = createLifeCycle('renderTracked');
  3876. const onRenderTriggered = createLifeCycle('renderTriggered');
  3877. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3878. function onErrorCaptured(hook, target = currentInstance) {
  3879. injectErrorCapturedHook(hook, target);
  3880. }
  3881. /**
  3882. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3883. */
  3884. const version = '2.7.13';
  3885. /**
  3886. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3887. */
  3888. function defineComponent(options) {
  3889. return options;
  3890. }
  3891. var vca = /*#__PURE__*/Object.freeze({
  3892. __proto__: null,
  3893. version: version,
  3894. defineComponent: defineComponent,
  3895. ref: ref$1,
  3896. shallowRef: shallowRef,
  3897. isRef: isRef,
  3898. toRef: toRef,
  3899. toRefs: toRefs,
  3900. unref: unref,
  3901. proxyRefs: proxyRefs,
  3902. customRef: customRef,
  3903. triggerRef: triggerRef,
  3904. reactive: reactive,
  3905. isReactive: isReactive,
  3906. isReadonly: isReadonly,
  3907. isShallow: isShallow,
  3908. isProxy: isProxy,
  3909. shallowReactive: shallowReactive,
  3910. markRaw: markRaw,
  3911. toRaw: toRaw,
  3912. readonly: readonly,
  3913. shallowReadonly: shallowReadonly,
  3914. computed: computed,
  3915. watch: watch,
  3916. watchEffect: watchEffect,
  3917. watchPostEffect: watchPostEffect,
  3918. watchSyncEffect: watchSyncEffect,
  3919. EffectScope: EffectScope,
  3920. effectScope: effectScope,
  3921. onScopeDispose: onScopeDispose,
  3922. getCurrentScope: getCurrentScope,
  3923. provide: provide,
  3924. inject: inject,
  3925. h: h,
  3926. getCurrentInstance: getCurrentInstance,
  3927. useSlots: useSlots,
  3928. useAttrs: useAttrs,
  3929. useListeners: useListeners,
  3930. mergeDefaults: mergeDefaults,
  3931. nextTick: nextTick,
  3932. set: set,
  3933. del: del,
  3934. useCssModule: useCssModule,
  3935. useCssVars: useCssVars,
  3936. defineAsyncComponent: defineAsyncComponent,
  3937. onBeforeMount: onBeforeMount,
  3938. onMounted: onMounted,
  3939. onBeforeUpdate: onBeforeUpdate,
  3940. onUpdated: onUpdated,
  3941. onBeforeUnmount: onBeforeUnmount,
  3942. onUnmounted: onUnmounted,
  3943. onActivated: onActivated,
  3944. onDeactivated: onDeactivated,
  3945. onServerPrefetch: onServerPrefetch,
  3946. onRenderTracked: onRenderTracked,
  3947. onRenderTriggered: onRenderTriggered,
  3948. onErrorCaptured: onErrorCaptured
  3949. });
  3950. const seenObjects = new _Set();
  3951. /**
  3952. * Recursively traverse an object to evoke all converted
  3953. * getters, so that every nested property inside the object
  3954. * is collected as a "deep" dependency.
  3955. */
  3956. function traverse(val) {
  3957. _traverse(val, seenObjects);
  3958. seenObjects.clear();
  3959. return val;
  3960. }
  3961. function _traverse(val, seen) {
  3962. let i, keys;
  3963. const isA = isArray(val);
  3964. if ((!isA && !isObject(val)) ||
  3965. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3966. Object.isFrozen(val) ||
  3967. val instanceof VNode) {
  3968. return;
  3969. }
  3970. if (val.__ob__) {
  3971. const depId = val.__ob__.dep.id;
  3972. if (seen.has(depId)) {
  3973. return;
  3974. }
  3975. seen.add(depId);
  3976. }
  3977. if (isA) {
  3978. i = val.length;
  3979. while (i--)
  3980. _traverse(val[i], seen);
  3981. }
  3982. else if (isRef(val)) {
  3983. _traverse(val.value, seen);
  3984. }
  3985. else {
  3986. keys = Object.keys(val);
  3987. i = keys.length;
  3988. while (i--)
  3989. _traverse(val[keys[i]], seen);
  3990. }
  3991. }
  3992. let uid$1 = 0;
  3993. /**
  3994. * A watcher parses an expression, collects dependencies,
  3995. * and fires callback when the expression value changes.
  3996. * This is used for both the $watch() api and directives.
  3997. * @internal
  3998. */
  3999. class Watcher {
  4000. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  4001. recordEffectScope(this,
  4002. // if the active effect scope is manually created (not a component scope),
  4003. // prioritize it
  4004. activeEffectScope && !activeEffectScope._vm
  4005. ? activeEffectScope
  4006. : vm
  4007. ? vm._scope
  4008. : undefined);
  4009. if ((this.vm = vm) && isRenderWatcher) {
  4010. vm._watcher = this;
  4011. }
  4012. // options
  4013. if (options) {
  4014. this.deep = !!options.deep;
  4015. this.user = !!options.user;
  4016. this.lazy = !!options.lazy;
  4017. this.sync = !!options.sync;
  4018. this.before = options.before;
  4019. {
  4020. this.onTrack = options.onTrack;
  4021. this.onTrigger = options.onTrigger;
  4022. }
  4023. }
  4024. else {
  4025. this.deep = this.user = this.lazy = this.sync = false;
  4026. }
  4027. this.cb = cb;
  4028. this.id = ++uid$1; // uid for batching
  4029. this.active = true;
  4030. this.post = false;
  4031. this.dirty = this.lazy; // for lazy watchers
  4032. this.deps = [];
  4033. this.newDeps = [];
  4034. this.depIds = new _Set();
  4035. this.newDepIds = new _Set();
  4036. this.expression = expOrFn.toString() ;
  4037. // parse expression for getter
  4038. if (isFunction(expOrFn)) {
  4039. this.getter = expOrFn;
  4040. }
  4041. else {
  4042. this.getter = parsePath(expOrFn);
  4043. if (!this.getter) {
  4044. this.getter = noop;
  4045. warn$2(`Failed watching path: "${expOrFn}" ` +
  4046. 'Watcher only accepts simple dot-delimited paths. ' +
  4047. 'For full control, use a function instead.', vm);
  4048. }
  4049. }
  4050. this.value = this.lazy ? undefined : this.get();
  4051. }
  4052. /**
  4053. * Evaluate the getter, and re-collect dependencies.
  4054. */
  4055. get() {
  4056. pushTarget(this);
  4057. let value;
  4058. const vm = this.vm;
  4059. try {
  4060. value = this.getter.call(vm, vm);
  4061. }
  4062. catch (e) {
  4063. if (this.user) {
  4064. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4065. }
  4066. else {
  4067. throw e;
  4068. }
  4069. }
  4070. finally {
  4071. // "touch" every property so they are all tracked as
  4072. // dependencies for deep watching
  4073. if (this.deep) {
  4074. traverse(value);
  4075. }
  4076. popTarget();
  4077. this.cleanupDeps();
  4078. }
  4079. return value;
  4080. }
  4081. /**
  4082. * Add a dependency to this directive.
  4083. */
  4084. addDep(dep) {
  4085. const id = dep.id;
  4086. if (!this.newDepIds.has(id)) {
  4087. this.newDepIds.add(id);
  4088. this.newDeps.push(dep);
  4089. if (!this.depIds.has(id)) {
  4090. dep.addSub(this);
  4091. }
  4092. }
  4093. }
  4094. /**
  4095. * Clean up for dependency collection.
  4096. */
  4097. cleanupDeps() {
  4098. let i = this.deps.length;
  4099. while (i--) {
  4100. const dep = this.deps[i];
  4101. if (!this.newDepIds.has(dep.id)) {
  4102. dep.removeSub(this);
  4103. }
  4104. }
  4105. let tmp = this.depIds;
  4106. this.depIds = this.newDepIds;
  4107. this.newDepIds = tmp;
  4108. this.newDepIds.clear();
  4109. tmp = this.deps;
  4110. this.deps = this.newDeps;
  4111. this.newDeps = tmp;
  4112. this.newDeps.length = 0;
  4113. }
  4114. /**
  4115. * Subscriber interface.
  4116. * Will be called when a dependency changes.
  4117. */
  4118. update() {
  4119. /* istanbul ignore else */
  4120. if (this.lazy) {
  4121. this.dirty = true;
  4122. }
  4123. else if (this.sync) {
  4124. this.run();
  4125. }
  4126. else {
  4127. queueWatcher(this);
  4128. }
  4129. }
  4130. /**
  4131. * Scheduler job interface.
  4132. * Will be called by the scheduler.
  4133. */
  4134. run() {
  4135. if (this.active) {
  4136. const value = this.get();
  4137. if (value !== this.value ||
  4138. // Deep watchers and watchers on Object/Arrays should fire even
  4139. // when the value is the same, because the value may
  4140. // have mutated.
  4141. isObject(value) ||
  4142. this.deep) {
  4143. // set new value
  4144. const oldValue = this.value;
  4145. this.value = value;
  4146. if (this.user) {
  4147. const info = `callback for watcher "${this.expression}"`;
  4148. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4149. }
  4150. else {
  4151. this.cb.call(this.vm, value, oldValue);
  4152. }
  4153. }
  4154. }
  4155. }
  4156. /**
  4157. * Evaluate the value of the watcher.
  4158. * This only gets called for lazy watchers.
  4159. */
  4160. evaluate() {
  4161. this.value = this.get();
  4162. this.dirty = false;
  4163. }
  4164. /**
  4165. * Depend on all deps collected by this watcher.
  4166. */
  4167. depend() {
  4168. let i = this.deps.length;
  4169. while (i--) {
  4170. this.deps[i].depend();
  4171. }
  4172. }
  4173. /**
  4174. * Remove self from all dependencies' subscriber list.
  4175. */
  4176. teardown() {
  4177. if (this.vm && !this.vm._isBeingDestroyed) {
  4178. remove$2(this.vm._scope.effects, this);
  4179. }
  4180. if (this.active) {
  4181. let i = this.deps.length;
  4182. while (i--) {
  4183. this.deps[i].removeSub(this);
  4184. }
  4185. this.active = false;
  4186. if (this.onStop) {
  4187. this.onStop();
  4188. }
  4189. }
  4190. }
  4191. }
  4192. const sharedPropertyDefinition = {
  4193. enumerable: true,
  4194. configurable: true,
  4195. get: noop,
  4196. set: noop
  4197. };
  4198. function proxy(target, sourceKey, key) {
  4199. sharedPropertyDefinition.get = function proxyGetter() {
  4200. return this[sourceKey][key];
  4201. };
  4202. sharedPropertyDefinition.set = function proxySetter(val) {
  4203. this[sourceKey][key] = val;
  4204. };
  4205. Object.defineProperty(target, key, sharedPropertyDefinition);
  4206. }
  4207. function initState(vm) {
  4208. const opts = vm.$options;
  4209. if (opts.props)
  4210. initProps$1(vm, opts.props);
  4211. // Composition API
  4212. initSetup(vm);
  4213. if (opts.methods)
  4214. initMethods(vm, opts.methods);
  4215. if (opts.data) {
  4216. initData(vm);
  4217. }
  4218. else {
  4219. const ob = observe((vm._data = {}));
  4220. ob && ob.vmCount++;
  4221. }
  4222. if (opts.computed)
  4223. initComputed$1(vm, opts.computed);
  4224. if (opts.watch && opts.watch !== nativeWatch) {
  4225. initWatch(vm, opts.watch);
  4226. }
  4227. }
  4228. function initProps$1(vm, propsOptions) {
  4229. const propsData = vm.$options.propsData || {};
  4230. const props = (vm._props = shallowReactive({}));
  4231. // cache prop keys so that future props updates can iterate using Array
  4232. // instead of dynamic object key enumeration.
  4233. const keys = (vm.$options._propKeys = []);
  4234. const isRoot = !vm.$parent;
  4235. // root instance props should be converted
  4236. if (!isRoot) {
  4237. toggleObserving(false);
  4238. }
  4239. for (const key in propsOptions) {
  4240. keys.push(key);
  4241. const value = validateProp(key, propsOptions, propsData, vm);
  4242. /* istanbul ignore else */
  4243. {
  4244. const hyphenatedKey = hyphenate(key);
  4245. if (isReservedAttribute(hyphenatedKey) ||
  4246. config.isReservedAttr(hyphenatedKey)) {
  4247. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4248. }
  4249. defineReactive(props, key, value, () => {
  4250. if (!isRoot && !isUpdatingChildComponent) {
  4251. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4252. `overwritten whenever the parent component re-renders. ` +
  4253. `Instead, use a data or computed property based on the prop's ` +
  4254. `value. Prop being mutated: "${key}"`, vm);
  4255. }
  4256. });
  4257. }
  4258. // static props are already proxied on the component's prototype
  4259. // during Vue.extend(). We only need to proxy props defined at
  4260. // instantiation here.
  4261. if (!(key in vm)) {
  4262. proxy(vm, `_props`, key);
  4263. }
  4264. }
  4265. toggleObserving(true);
  4266. }
  4267. function initData(vm) {
  4268. let data = vm.$options.data;
  4269. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4270. if (!isPlainObject(data)) {
  4271. data = {};
  4272. warn$2('data functions should return an object:\n' +
  4273. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4274. }
  4275. // proxy data on instance
  4276. const keys = Object.keys(data);
  4277. const props = vm.$options.props;
  4278. const methods = vm.$options.methods;
  4279. let i = keys.length;
  4280. while (i--) {
  4281. const key = keys[i];
  4282. {
  4283. if (methods && hasOwn(methods, key)) {
  4284. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4285. }
  4286. }
  4287. if (props && hasOwn(props, key)) {
  4288. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4289. `Use prop default value instead.`, vm);
  4290. }
  4291. else if (!isReserved(key)) {
  4292. proxy(vm, `_data`, key);
  4293. }
  4294. }
  4295. // observe data
  4296. const ob = observe(data);
  4297. ob && ob.vmCount++;
  4298. }
  4299. function getData(data, vm) {
  4300. // #7573 disable dep collection when invoking data getters
  4301. pushTarget();
  4302. try {
  4303. return data.call(vm, vm);
  4304. }
  4305. catch (e) {
  4306. handleError(e, vm, `data()`);
  4307. return {};
  4308. }
  4309. finally {
  4310. popTarget();
  4311. }
  4312. }
  4313. const computedWatcherOptions = { lazy: true };
  4314. function initComputed$1(vm, computed) {
  4315. // $flow-disable-line
  4316. const watchers = (vm._computedWatchers = Object.create(null));
  4317. // computed properties are just getters during SSR
  4318. const isSSR = isServerRendering();
  4319. for (const key in computed) {
  4320. const userDef = computed[key];
  4321. const getter = isFunction(userDef) ? userDef : userDef.get;
  4322. if (getter == null) {
  4323. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4324. }
  4325. if (!isSSR) {
  4326. // create internal watcher for the computed property.
  4327. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4328. }
  4329. // component-defined computed properties are already defined on the
  4330. // component prototype. We only need to define computed properties defined
  4331. // at instantiation here.
  4332. if (!(key in vm)) {
  4333. defineComputed(vm, key, userDef);
  4334. }
  4335. else {
  4336. if (key in vm.$data) {
  4337. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4338. }
  4339. else if (vm.$options.props && key in vm.$options.props) {
  4340. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4341. }
  4342. else if (vm.$options.methods && key in vm.$options.methods) {
  4343. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4344. }
  4345. }
  4346. }
  4347. }
  4348. function defineComputed(target, key, userDef) {
  4349. const shouldCache = !isServerRendering();
  4350. if (isFunction(userDef)) {
  4351. sharedPropertyDefinition.get = shouldCache
  4352. ? createComputedGetter(key)
  4353. : createGetterInvoker(userDef);
  4354. sharedPropertyDefinition.set = noop;
  4355. }
  4356. else {
  4357. sharedPropertyDefinition.get = userDef.get
  4358. ? shouldCache && userDef.cache !== false
  4359. ? createComputedGetter(key)
  4360. : createGetterInvoker(userDef.get)
  4361. : noop;
  4362. sharedPropertyDefinition.set = userDef.set || noop;
  4363. }
  4364. if (sharedPropertyDefinition.set === noop) {
  4365. sharedPropertyDefinition.set = function () {
  4366. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4367. };
  4368. }
  4369. Object.defineProperty(target, key, sharedPropertyDefinition);
  4370. }
  4371. function createComputedGetter(key) {
  4372. return function computedGetter() {
  4373. const watcher = this._computedWatchers && this._computedWatchers[key];
  4374. if (watcher) {
  4375. if (watcher.dirty) {
  4376. watcher.evaluate();
  4377. }
  4378. if (Dep.target) {
  4379. if (Dep.target.onTrack) {
  4380. Dep.target.onTrack({
  4381. effect: Dep.target,
  4382. target: this,
  4383. type: "get" /* TrackOpTypes.GET */,
  4384. key
  4385. });
  4386. }
  4387. watcher.depend();
  4388. }
  4389. return watcher.value;
  4390. }
  4391. };
  4392. }
  4393. function createGetterInvoker(fn) {
  4394. return function computedGetter() {
  4395. return fn.call(this, this);
  4396. };
  4397. }
  4398. function initMethods(vm, methods) {
  4399. const props = vm.$options.props;
  4400. for (const key in methods) {
  4401. {
  4402. if (typeof methods[key] !== 'function') {
  4403. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4404. `Did you reference the function correctly?`, vm);
  4405. }
  4406. if (props && hasOwn(props, key)) {
  4407. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4408. }
  4409. if (key in vm && isReserved(key)) {
  4410. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4411. `Avoid defining component methods that start with _ or $.`);
  4412. }
  4413. }
  4414. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4415. }
  4416. }
  4417. function initWatch(vm, watch) {
  4418. for (const key in watch) {
  4419. const handler = watch[key];
  4420. if (isArray(handler)) {
  4421. for (let i = 0; i < handler.length; i++) {
  4422. createWatcher(vm, key, handler[i]);
  4423. }
  4424. }
  4425. else {
  4426. createWatcher(vm, key, handler);
  4427. }
  4428. }
  4429. }
  4430. function createWatcher(vm, expOrFn, handler, options) {
  4431. if (isPlainObject(handler)) {
  4432. options = handler;
  4433. handler = handler.handler;
  4434. }
  4435. if (typeof handler === 'string') {
  4436. handler = vm[handler];
  4437. }
  4438. return vm.$watch(expOrFn, handler, options);
  4439. }
  4440. function stateMixin(Vue) {
  4441. // flow somehow has problems with directly declared definition object
  4442. // when using Object.defineProperty, so we have to procedurally build up
  4443. // the object here.
  4444. const dataDef = {};
  4445. dataDef.get = function () {
  4446. return this._data;
  4447. };
  4448. const propsDef = {};
  4449. propsDef.get = function () {
  4450. return this._props;
  4451. };
  4452. {
  4453. dataDef.set = function () {
  4454. warn$2('Avoid replacing instance root $data. ' +
  4455. 'Use nested data properties instead.', this);
  4456. };
  4457. propsDef.set = function () {
  4458. warn$2(`$props is readonly.`, this);
  4459. };
  4460. }
  4461. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4462. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4463. Vue.prototype.$set = set;
  4464. Vue.prototype.$delete = del;
  4465. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4466. const vm = this;
  4467. if (isPlainObject(cb)) {
  4468. return createWatcher(vm, expOrFn, cb, options);
  4469. }
  4470. options = options || {};
  4471. options.user = true;
  4472. const watcher = new Watcher(vm, expOrFn, cb, options);
  4473. if (options.immediate) {
  4474. const info = `callback for immediate watcher "${watcher.expression}"`;
  4475. pushTarget();
  4476. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4477. popTarget();
  4478. }
  4479. return function unwatchFn() {
  4480. watcher.teardown();
  4481. };
  4482. };
  4483. }
  4484. function initProvide(vm) {
  4485. const provideOption = vm.$options.provide;
  4486. if (provideOption) {
  4487. const provided = isFunction(provideOption)
  4488. ? provideOption.call(vm)
  4489. : provideOption;
  4490. if (!isObject(provided)) {
  4491. return;
  4492. }
  4493. const source = resolveProvided(vm);
  4494. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4495. // iterate the keys ourselves.
  4496. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4497. for (let i = 0; i < keys.length; i++) {
  4498. const key = keys[i];
  4499. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4500. }
  4501. }
  4502. }
  4503. function initInjections(vm) {
  4504. const result = resolveInject(vm.$options.inject, vm);
  4505. if (result) {
  4506. toggleObserving(false);
  4507. Object.keys(result).forEach(key => {
  4508. /* istanbul ignore else */
  4509. {
  4510. defineReactive(vm, key, result[key], () => {
  4511. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4512. `overwritten whenever the provided component re-renders. ` +
  4513. `injection being mutated: "${key}"`, vm);
  4514. });
  4515. }
  4516. });
  4517. toggleObserving(true);
  4518. }
  4519. }
  4520. function resolveInject(inject, vm) {
  4521. if (inject) {
  4522. // inject is :any because flow is not smart enough to figure out cached
  4523. const result = Object.create(null);
  4524. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4525. for (let i = 0; i < keys.length; i++) {
  4526. const key = keys[i];
  4527. // #6574 in case the inject object is observed...
  4528. if (key === '__ob__')
  4529. continue;
  4530. const provideKey = inject[key].from;
  4531. if (provideKey in vm._provided) {
  4532. result[key] = vm._provided[provideKey];
  4533. }
  4534. else if ('default' in inject[key]) {
  4535. const provideDefault = inject[key].default;
  4536. result[key] = isFunction(provideDefault)
  4537. ? provideDefault.call(vm)
  4538. : provideDefault;
  4539. }
  4540. else {
  4541. warn$2(`Injection "${key}" not found`, vm);
  4542. }
  4543. }
  4544. return result;
  4545. }
  4546. }
  4547. let uid = 0;
  4548. function initMixin$1(Vue) {
  4549. Vue.prototype._init = function (options) {
  4550. const vm = this;
  4551. // a uid
  4552. vm._uid = uid++;
  4553. let startTag, endTag;
  4554. /* istanbul ignore if */
  4555. if (config.performance && mark) {
  4556. startTag = `vue-perf-start:${vm._uid}`;
  4557. endTag = `vue-perf-end:${vm._uid}`;
  4558. mark(startTag);
  4559. }
  4560. // a flag to mark this as a Vue instance without having to do instanceof
  4561. // check
  4562. vm._isVue = true;
  4563. // avoid instances from being observed
  4564. vm.__v_skip = true;
  4565. // effect scope
  4566. vm._scope = new EffectScope(true /* detached */);
  4567. vm._scope._vm = true;
  4568. // merge options
  4569. if (options && options._isComponent) {
  4570. // optimize internal component instantiation
  4571. // since dynamic options merging is pretty slow, and none of the
  4572. // internal component options needs special treatment.
  4573. initInternalComponent(vm, options);
  4574. }
  4575. else {
  4576. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4577. }
  4578. /* istanbul ignore else */
  4579. {
  4580. initProxy(vm);
  4581. }
  4582. // expose real self
  4583. vm._self = vm;
  4584. initLifecycle(vm);
  4585. initEvents(vm);
  4586. initRender(vm);
  4587. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4588. initInjections(vm); // resolve injections before data/props
  4589. initState(vm);
  4590. initProvide(vm); // resolve provide after data/props
  4591. callHook$1(vm, 'created');
  4592. /* istanbul ignore if */
  4593. if (config.performance && mark) {
  4594. vm._name = formatComponentName(vm, false);
  4595. mark(endTag);
  4596. measure(`vue ${vm._name} init`, startTag, endTag);
  4597. }
  4598. if (vm.$options.el) {
  4599. vm.$mount(vm.$options.el);
  4600. }
  4601. };
  4602. }
  4603. function initInternalComponent(vm, options) {
  4604. const opts = (vm.$options = Object.create(vm.constructor.options));
  4605. // doing this because it's faster than dynamic enumeration.
  4606. const parentVnode = options._parentVnode;
  4607. opts.parent = options.parent;
  4608. opts._parentVnode = parentVnode;
  4609. const vnodeComponentOptions = parentVnode.componentOptions;
  4610. opts.propsData = vnodeComponentOptions.propsData;
  4611. opts._parentListeners = vnodeComponentOptions.listeners;
  4612. opts._renderChildren = vnodeComponentOptions.children;
  4613. opts._componentTag = vnodeComponentOptions.tag;
  4614. if (options.render) {
  4615. opts.render = options.render;
  4616. opts.staticRenderFns = options.staticRenderFns;
  4617. }
  4618. }
  4619. function resolveConstructorOptions(Ctor) {
  4620. let options = Ctor.options;
  4621. if (Ctor.super) {
  4622. const superOptions = resolveConstructorOptions(Ctor.super);
  4623. const cachedSuperOptions = Ctor.superOptions;
  4624. if (superOptions !== cachedSuperOptions) {
  4625. // super option changed,
  4626. // need to resolve new options.
  4627. Ctor.superOptions = superOptions;
  4628. // check if there are any late-modified/attached options (#4976)
  4629. const modifiedOptions = resolveModifiedOptions(Ctor);
  4630. // update base extend options
  4631. if (modifiedOptions) {
  4632. extend(Ctor.extendOptions, modifiedOptions);
  4633. }
  4634. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4635. if (options.name) {
  4636. options.components[options.name] = Ctor;
  4637. }
  4638. }
  4639. }
  4640. return options;
  4641. }
  4642. function resolveModifiedOptions(Ctor) {
  4643. let modified;
  4644. const latest = Ctor.options;
  4645. const sealed = Ctor.sealedOptions;
  4646. for (const key in latest) {
  4647. if (latest[key] !== sealed[key]) {
  4648. if (!modified)
  4649. modified = {};
  4650. modified[key] = latest[key];
  4651. }
  4652. }
  4653. return modified;
  4654. }
  4655. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4656. const options = Ctor.options;
  4657. // ensure the createElement function in functional components
  4658. // gets a unique context - this is necessary for correct named slot check
  4659. let contextVm;
  4660. if (hasOwn(parent, '_uid')) {
  4661. contextVm = Object.create(parent);
  4662. contextVm._original = parent;
  4663. }
  4664. else {
  4665. // the context vm passed in is a functional context as well.
  4666. // in this case we want to make sure we are able to get a hold to the
  4667. // real context instance.
  4668. contextVm = parent;
  4669. // @ts-ignore
  4670. parent = parent._original;
  4671. }
  4672. const isCompiled = isTrue(options._compiled);
  4673. const needNormalization = !isCompiled;
  4674. this.data = data;
  4675. this.props = props;
  4676. this.children = children;
  4677. this.parent = parent;
  4678. this.listeners = data.on || emptyObject;
  4679. this.injections = resolveInject(options.inject, parent);
  4680. this.slots = () => {
  4681. if (!this.$slots) {
  4682. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4683. }
  4684. return this.$slots;
  4685. };
  4686. Object.defineProperty(this, 'scopedSlots', {
  4687. enumerable: true,
  4688. get() {
  4689. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4690. }
  4691. });
  4692. // support for compiled functional template
  4693. if (isCompiled) {
  4694. // exposing $options for renderStatic()
  4695. this.$options = options;
  4696. // pre-resolve slots for renderSlot()
  4697. this.$slots = this.slots();
  4698. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4699. }
  4700. if (options._scopeId) {
  4701. this._c = (a, b, c, d) => {
  4702. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4703. if (vnode && !isArray(vnode)) {
  4704. vnode.fnScopeId = options._scopeId;
  4705. vnode.fnContext = parent;
  4706. }
  4707. return vnode;
  4708. };
  4709. }
  4710. else {
  4711. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4712. }
  4713. }
  4714. installRenderHelpers(FunctionalRenderContext.prototype);
  4715. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4716. const options = Ctor.options;
  4717. const props = {};
  4718. const propOptions = options.props;
  4719. if (isDef(propOptions)) {
  4720. for (const key in propOptions) {
  4721. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4722. }
  4723. }
  4724. else {
  4725. if (isDef(data.attrs))
  4726. mergeProps(props, data.attrs);
  4727. if (isDef(data.props))
  4728. mergeProps(props, data.props);
  4729. }
  4730. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4731. const vnode = options.render.call(null, renderContext._c, renderContext);
  4732. if (vnode instanceof VNode) {
  4733. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4734. }
  4735. else if (isArray(vnode)) {
  4736. const vnodes = normalizeChildren(vnode) || [];
  4737. const res = new Array(vnodes.length);
  4738. for (let i = 0; i < vnodes.length; i++) {
  4739. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4740. }
  4741. return res;
  4742. }
  4743. }
  4744. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4745. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4746. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4747. // that should not be matched to match.
  4748. const clone = cloneVNode(vnode);
  4749. clone.fnContext = contextVm;
  4750. clone.fnOptions = options;
  4751. {
  4752. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4753. renderContext;
  4754. }
  4755. if (data.slot) {
  4756. (clone.data || (clone.data = {})).slot = data.slot;
  4757. }
  4758. return clone;
  4759. }
  4760. function mergeProps(to, from) {
  4761. for (const key in from) {
  4762. to[camelize(key)] = from[key];
  4763. }
  4764. }
  4765. function getComponentName(options) {
  4766. return options.name || options.__name || options._componentTag;
  4767. }
  4768. // inline hooks to be invoked on component VNodes during patch
  4769. const componentVNodeHooks = {
  4770. init(vnode, hydrating) {
  4771. if (vnode.componentInstance &&
  4772. !vnode.componentInstance._isDestroyed &&
  4773. vnode.data.keepAlive) {
  4774. // kept-alive components, treat as a patch
  4775. const mountedNode = vnode; // work around flow
  4776. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4777. }
  4778. else {
  4779. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4780. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4781. }
  4782. },
  4783. prepatch(oldVnode, vnode) {
  4784. const options = vnode.componentOptions;
  4785. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4786. updateChildComponent(child, options.propsData, // updated props
  4787. options.listeners, // updated listeners
  4788. vnode, // new parent vnode
  4789. options.children // new children
  4790. );
  4791. },
  4792. insert(vnode) {
  4793. const { context, componentInstance } = vnode;
  4794. if (!componentInstance._isMounted) {
  4795. componentInstance._isMounted = true;
  4796. callHook$1(componentInstance, 'mounted');
  4797. }
  4798. if (vnode.data.keepAlive) {
  4799. if (context._isMounted) {
  4800. // vue-router#1212
  4801. // During updates, a kept-alive component's child components may
  4802. // change, so directly walking the tree here may call activated hooks
  4803. // on incorrect children. Instead we push them into a queue which will
  4804. // be processed after the whole patch process ended.
  4805. queueActivatedComponent(componentInstance);
  4806. }
  4807. else {
  4808. activateChildComponent(componentInstance, true /* direct */);
  4809. }
  4810. }
  4811. },
  4812. destroy(vnode) {
  4813. const { componentInstance } = vnode;
  4814. if (!componentInstance._isDestroyed) {
  4815. if (!vnode.data.keepAlive) {
  4816. componentInstance.$destroy();
  4817. }
  4818. else {
  4819. deactivateChildComponent(componentInstance, true /* direct */);
  4820. }
  4821. }
  4822. }
  4823. };
  4824. const hooksToMerge = Object.keys(componentVNodeHooks);
  4825. function createComponent(Ctor, data, context, children, tag) {
  4826. if (isUndef(Ctor)) {
  4827. return;
  4828. }
  4829. const baseCtor = context.$options._base;
  4830. // plain options object: turn it into a constructor
  4831. if (isObject(Ctor)) {
  4832. Ctor = baseCtor.extend(Ctor);
  4833. }
  4834. // if at this stage it's not a constructor or an async component factory,
  4835. // reject.
  4836. if (typeof Ctor !== 'function') {
  4837. {
  4838. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4839. }
  4840. return;
  4841. }
  4842. // async component
  4843. let asyncFactory;
  4844. // @ts-expect-error
  4845. if (isUndef(Ctor.cid)) {
  4846. asyncFactory = Ctor;
  4847. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4848. if (Ctor === undefined) {
  4849. // return a placeholder node for async component, which is rendered
  4850. // as a comment node but preserves all the raw information for the node.
  4851. // the information will be used for async server-rendering and hydration.
  4852. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4853. }
  4854. }
  4855. data = data || {};
  4856. // resolve constructor options in case global mixins are applied after
  4857. // component constructor creation
  4858. resolveConstructorOptions(Ctor);
  4859. // transform component v-model data into props & events
  4860. if (isDef(data.model)) {
  4861. // @ts-expect-error
  4862. transformModel(Ctor.options, data);
  4863. }
  4864. // extract props
  4865. // @ts-expect-error
  4866. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4867. // functional component
  4868. // @ts-expect-error
  4869. if (isTrue(Ctor.options.functional)) {
  4870. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4871. }
  4872. // extract listeners, since these needs to be treated as
  4873. // child component listeners instead of DOM listeners
  4874. const listeners = data.on;
  4875. // replace with listeners with .native modifier
  4876. // so it gets processed during parent component patch.
  4877. data.on = data.nativeOn;
  4878. // @ts-expect-error
  4879. if (isTrue(Ctor.options.abstract)) {
  4880. // abstract components do not keep anything
  4881. // other than props & listeners & slot
  4882. // work around flow
  4883. const slot = data.slot;
  4884. data = {};
  4885. if (slot) {
  4886. data.slot = slot;
  4887. }
  4888. }
  4889. // install component management hooks onto the placeholder node
  4890. installComponentHooks(data);
  4891. // return a placeholder vnode
  4892. // @ts-expect-error
  4893. const name = getComponentName(Ctor.options) || tag;
  4894. const vnode = new VNode(
  4895. // @ts-expect-error
  4896. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4897. // @ts-expect-error
  4898. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4899. return vnode;
  4900. }
  4901. function createComponentInstanceForVnode(
  4902. // we know it's MountedComponentVNode but flow doesn't
  4903. vnode,
  4904. // activeInstance in lifecycle state
  4905. parent) {
  4906. const options = {
  4907. _isComponent: true,
  4908. _parentVnode: vnode,
  4909. parent
  4910. };
  4911. // check inline-template render functions
  4912. const inlineTemplate = vnode.data.inlineTemplate;
  4913. if (isDef(inlineTemplate)) {
  4914. options.render = inlineTemplate.render;
  4915. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4916. }
  4917. return new vnode.componentOptions.Ctor(options);
  4918. }
  4919. function installComponentHooks(data) {
  4920. const hooks = data.hook || (data.hook = {});
  4921. for (let i = 0; i < hooksToMerge.length; i++) {
  4922. const key = hooksToMerge[i];
  4923. const existing = hooks[key];
  4924. const toMerge = componentVNodeHooks[key];
  4925. // @ts-expect-error
  4926. if (existing !== toMerge && !(existing && existing._merged)) {
  4927. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4928. }
  4929. }
  4930. }
  4931. function mergeHook(f1, f2) {
  4932. const merged = (a, b) => {
  4933. // flow complains about extra args which is why we use any
  4934. f1(a, b);
  4935. f2(a, b);
  4936. };
  4937. merged._merged = true;
  4938. return merged;
  4939. }
  4940. // transform component v-model info (value and callback) into
  4941. // prop and event handler respectively.
  4942. function transformModel(options, data) {
  4943. const prop = (options.model && options.model.prop) || 'value';
  4944. const event = (options.model && options.model.event) || 'input';
  4945. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4946. const on = data.on || (data.on = {});
  4947. const existing = on[event];
  4948. const callback = data.model.callback;
  4949. if (isDef(existing)) {
  4950. if (isArray(existing)
  4951. ? existing.indexOf(callback) === -1
  4952. : existing !== callback) {
  4953. on[event] = [callback].concat(existing);
  4954. }
  4955. }
  4956. else {
  4957. on[event] = callback;
  4958. }
  4959. }
  4960. let warn$2 = noop;
  4961. let tip = noop;
  4962. let generateComponentTrace; // work around flow check
  4963. let formatComponentName;
  4964. {
  4965. const hasConsole = typeof console !== 'undefined';
  4966. const classifyRE = /(?:^|[-_])(\w)/g;
  4967. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4968. warn$2 = (msg, vm = currentInstance) => {
  4969. const trace = vm ? generateComponentTrace(vm) : '';
  4970. if (config.warnHandler) {
  4971. config.warnHandler.call(null, msg, vm, trace);
  4972. }
  4973. else if (hasConsole && !config.silent) {
  4974. console.error(`[Vue warn]: ${msg}${trace}`);
  4975. }
  4976. };
  4977. tip = (msg, vm) => {
  4978. if (hasConsole && !config.silent) {
  4979. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4980. }
  4981. };
  4982. formatComponentName = (vm, includeFile) => {
  4983. if (vm.$root === vm) {
  4984. return '<Root>';
  4985. }
  4986. const options = isFunction(vm) && vm.cid != null
  4987. ? vm.options
  4988. : vm._isVue
  4989. ? vm.$options || vm.constructor.options
  4990. : vm;
  4991. let name = getComponentName(options);
  4992. const file = options.__file;
  4993. if (!name && file) {
  4994. const match = file.match(/([^/\\]+)\.vue$/);
  4995. name = match && match[1];
  4996. }
  4997. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4998. (file && includeFile !== false ? ` at ${file}` : ''));
  4999. };
  5000. const repeat = (str, n) => {
  5001. let res = '';
  5002. while (n) {
  5003. if (n % 2 === 1)
  5004. res += str;
  5005. if (n > 1)
  5006. str += str;
  5007. n >>= 1;
  5008. }
  5009. return res;
  5010. };
  5011. generateComponentTrace = (vm) => {
  5012. if (vm._isVue && vm.$parent) {
  5013. const tree = [];
  5014. let currentRecursiveSequence = 0;
  5015. while (vm) {
  5016. if (tree.length > 0) {
  5017. const last = tree[tree.length - 1];
  5018. if (last.constructor === vm.constructor) {
  5019. currentRecursiveSequence++;
  5020. vm = vm.$parent;
  5021. continue;
  5022. }
  5023. else if (currentRecursiveSequence > 0) {
  5024. tree[tree.length - 1] = [last, currentRecursiveSequence];
  5025. currentRecursiveSequence = 0;
  5026. }
  5027. }
  5028. tree.push(vm);
  5029. vm = vm.$parent;
  5030. }
  5031. return ('\n\nfound in\n\n' +
  5032. tree
  5033. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  5034. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  5035. : formatComponentName(vm)}`)
  5036. .join('\n'));
  5037. }
  5038. else {
  5039. return `\n\n(found in ${formatComponentName(vm)})`;
  5040. }
  5041. };
  5042. }
  5043. /**
  5044. * Option overwriting strategies are functions that handle
  5045. * how to merge a parent option value and a child option
  5046. * value into the final value.
  5047. */
  5048. const strats = config.optionMergeStrategies;
  5049. /**
  5050. * Options with restrictions
  5051. */
  5052. {
  5053. strats.el = strats.propsData = function (parent, child, vm, key) {
  5054. if (!vm) {
  5055. warn$2(`option "${key}" can only be used during instance ` +
  5056. 'creation with the `new` keyword.');
  5057. }
  5058. return defaultStrat(parent, child);
  5059. };
  5060. }
  5061. /**
  5062. * Helper that recursively merges two data objects together.
  5063. */
  5064. function mergeData(to, from) {
  5065. if (!from)
  5066. return to;
  5067. let key, toVal, fromVal;
  5068. const keys = hasSymbol
  5069. ? Reflect.ownKeys(from)
  5070. : Object.keys(from);
  5071. for (let i = 0; i < keys.length; i++) {
  5072. key = keys[i];
  5073. // in case the object is already observed...
  5074. if (key === '__ob__')
  5075. continue;
  5076. toVal = to[key];
  5077. fromVal = from[key];
  5078. if (!hasOwn(to, key)) {
  5079. set(to, key, fromVal);
  5080. }
  5081. else if (toVal !== fromVal &&
  5082. isPlainObject(toVal) &&
  5083. isPlainObject(fromVal)) {
  5084. mergeData(toVal, fromVal);
  5085. }
  5086. }
  5087. return to;
  5088. }
  5089. /**
  5090. * Data
  5091. */
  5092. function mergeDataOrFn(parentVal, childVal, vm) {
  5093. if (!vm) {
  5094. // in a Vue.extend merge, both should be functions
  5095. if (!childVal) {
  5096. return parentVal;
  5097. }
  5098. if (!parentVal) {
  5099. return childVal;
  5100. }
  5101. // when parentVal & childVal are both present,
  5102. // we need to return a function that returns the
  5103. // merged result of both functions... no need to
  5104. // check if parentVal is a function here because
  5105. // it has to be a function to pass previous merges.
  5106. return function mergedDataFn() {
  5107. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5108. };
  5109. }
  5110. else {
  5111. return function mergedInstanceDataFn() {
  5112. // instance merge
  5113. const instanceData = isFunction(childVal)
  5114. ? childVal.call(vm, vm)
  5115. : childVal;
  5116. const defaultData = isFunction(parentVal)
  5117. ? parentVal.call(vm, vm)
  5118. : parentVal;
  5119. if (instanceData) {
  5120. return mergeData(instanceData, defaultData);
  5121. }
  5122. else {
  5123. return defaultData;
  5124. }
  5125. };
  5126. }
  5127. }
  5128. strats.data = function (parentVal, childVal, vm) {
  5129. if (!vm) {
  5130. if (childVal && typeof childVal !== 'function') {
  5131. warn$2('The "data" option should be a function ' +
  5132. 'that returns a per-instance value in component ' +
  5133. 'definitions.', vm);
  5134. return parentVal;
  5135. }
  5136. return mergeDataOrFn(parentVal, childVal);
  5137. }
  5138. return mergeDataOrFn(parentVal, childVal, vm);
  5139. };
  5140. /**
  5141. * Hooks and props are merged as arrays.
  5142. */
  5143. function mergeLifecycleHook(parentVal, childVal) {
  5144. const res = childVal
  5145. ? parentVal
  5146. ? parentVal.concat(childVal)
  5147. : isArray(childVal)
  5148. ? childVal
  5149. : [childVal]
  5150. : parentVal;
  5151. return res ? dedupeHooks(res) : res;
  5152. }
  5153. function dedupeHooks(hooks) {
  5154. const res = [];
  5155. for (let i = 0; i < hooks.length; i++) {
  5156. if (res.indexOf(hooks[i]) === -1) {
  5157. res.push(hooks[i]);
  5158. }
  5159. }
  5160. return res;
  5161. }
  5162. LIFECYCLE_HOOKS.forEach(hook => {
  5163. strats[hook] = mergeLifecycleHook;
  5164. });
  5165. /**
  5166. * Assets
  5167. *
  5168. * When a vm is present (instance creation), we need to do
  5169. * a three-way merge between constructor options, instance
  5170. * options and parent options.
  5171. */
  5172. function mergeAssets(parentVal, childVal, vm, key) {
  5173. const res = Object.create(parentVal || null);
  5174. if (childVal) {
  5175. assertObjectType(key, childVal, vm);
  5176. return extend(res, childVal);
  5177. }
  5178. else {
  5179. return res;
  5180. }
  5181. }
  5182. ASSET_TYPES.forEach(function (type) {
  5183. strats[type + 's'] = mergeAssets;
  5184. });
  5185. /**
  5186. * Watchers.
  5187. *
  5188. * Watchers hashes should not overwrite one
  5189. * another, so we merge them as arrays.
  5190. */
  5191. strats.watch = function (parentVal, childVal, vm, key) {
  5192. // work around Firefox's Object.prototype.watch...
  5193. //@ts-expect-error work around
  5194. if (parentVal === nativeWatch)
  5195. parentVal = undefined;
  5196. //@ts-expect-error work around
  5197. if (childVal === nativeWatch)
  5198. childVal = undefined;
  5199. /* istanbul ignore if */
  5200. if (!childVal)
  5201. return Object.create(parentVal || null);
  5202. {
  5203. assertObjectType(key, childVal, vm);
  5204. }
  5205. if (!parentVal)
  5206. return childVal;
  5207. const ret = {};
  5208. extend(ret, parentVal);
  5209. for (const key in childVal) {
  5210. let parent = ret[key];
  5211. const child = childVal[key];
  5212. if (parent && !isArray(parent)) {
  5213. parent = [parent];
  5214. }
  5215. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5216. }
  5217. return ret;
  5218. };
  5219. /**
  5220. * Other object hashes.
  5221. */
  5222. strats.props =
  5223. strats.methods =
  5224. strats.inject =
  5225. strats.computed =
  5226. function (parentVal, childVal, vm, key) {
  5227. if (childVal && true) {
  5228. assertObjectType(key, childVal, vm);
  5229. }
  5230. if (!parentVal)
  5231. return childVal;
  5232. const ret = Object.create(null);
  5233. extend(ret, parentVal);
  5234. if (childVal)
  5235. extend(ret, childVal);
  5236. return ret;
  5237. };
  5238. strats.provide = mergeDataOrFn;
  5239. /**
  5240. * Default strategy.
  5241. */
  5242. const defaultStrat = function (parentVal, childVal) {
  5243. return childVal === undefined ? parentVal : childVal;
  5244. };
  5245. /**
  5246. * Validate component names
  5247. */
  5248. function checkComponents(options) {
  5249. for (const key in options.components) {
  5250. validateComponentName(key);
  5251. }
  5252. }
  5253. function validateComponentName(name) {
  5254. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5255. warn$2('Invalid component name: "' +
  5256. name +
  5257. '". Component names ' +
  5258. 'should conform to valid custom element name in html5 specification.');
  5259. }
  5260. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5261. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5262. 'id: ' +
  5263. name);
  5264. }
  5265. }
  5266. /**
  5267. * Ensure all props option syntax are normalized into the
  5268. * Object-based format.
  5269. */
  5270. function normalizeProps(options, vm) {
  5271. const props = options.props;
  5272. if (!props)
  5273. return;
  5274. const res = {};
  5275. let i, val, name;
  5276. if (isArray(props)) {
  5277. i = props.length;
  5278. while (i--) {
  5279. val = props[i];
  5280. if (typeof val === 'string') {
  5281. name = camelize(val);
  5282. res[name] = { type: null };
  5283. }
  5284. else {
  5285. warn$2('props must be strings when using array syntax.');
  5286. }
  5287. }
  5288. }
  5289. else if (isPlainObject(props)) {
  5290. for (const key in props) {
  5291. val = props[key];
  5292. name = camelize(key);
  5293. res[name] = isPlainObject(val) ? val : { type: val };
  5294. }
  5295. }
  5296. else {
  5297. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5298. `but got ${toRawType(props)}.`, vm);
  5299. }
  5300. options.props = res;
  5301. }
  5302. /**
  5303. * Normalize all injections into Object-based format
  5304. */
  5305. function normalizeInject(options, vm) {
  5306. const inject = options.inject;
  5307. if (!inject)
  5308. return;
  5309. const normalized = (options.inject = {});
  5310. if (isArray(inject)) {
  5311. for (let i = 0; i < inject.length; i++) {
  5312. normalized[inject[i]] = { from: inject[i] };
  5313. }
  5314. }
  5315. else if (isPlainObject(inject)) {
  5316. for (const key in inject) {
  5317. const val = inject[key];
  5318. normalized[key] = isPlainObject(val)
  5319. ? extend({ from: key }, val)
  5320. : { from: val };
  5321. }
  5322. }
  5323. else {
  5324. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5325. `but got ${toRawType(inject)}.`, vm);
  5326. }
  5327. }
  5328. /**
  5329. * Normalize raw function directives into object format.
  5330. */
  5331. function normalizeDirectives$1(options) {
  5332. const dirs = options.directives;
  5333. if (dirs) {
  5334. for (const key in dirs) {
  5335. const def = dirs[key];
  5336. if (isFunction(def)) {
  5337. dirs[key] = { bind: def, update: def };
  5338. }
  5339. }
  5340. }
  5341. }
  5342. function assertObjectType(name, value, vm) {
  5343. if (!isPlainObject(value)) {
  5344. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5345. `but got ${toRawType(value)}.`, vm);
  5346. }
  5347. }
  5348. /**
  5349. * Merge two option objects into a new one.
  5350. * Core utility used in both instantiation and inheritance.
  5351. */
  5352. function mergeOptions(parent, child, vm) {
  5353. {
  5354. checkComponents(child);
  5355. }
  5356. if (isFunction(child)) {
  5357. // @ts-expect-error
  5358. child = child.options;
  5359. }
  5360. normalizeProps(child, vm);
  5361. normalizeInject(child, vm);
  5362. normalizeDirectives$1(child);
  5363. // Apply extends and mixins on the child options,
  5364. // but only if it is a raw options object that isn't
  5365. // the result of another mergeOptions call.
  5366. // Only merged options has the _base property.
  5367. if (!child._base) {
  5368. if (child.extends) {
  5369. parent = mergeOptions(parent, child.extends, vm);
  5370. }
  5371. if (child.mixins) {
  5372. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5373. parent = mergeOptions(parent, child.mixins[i], vm);
  5374. }
  5375. }
  5376. }
  5377. const options = {};
  5378. let key;
  5379. for (key in parent) {
  5380. mergeField(key);
  5381. }
  5382. for (key in child) {
  5383. if (!hasOwn(parent, key)) {
  5384. mergeField(key);
  5385. }
  5386. }
  5387. function mergeField(key) {
  5388. const strat = strats[key] || defaultStrat;
  5389. options[key] = strat(parent[key], child[key], vm, key);
  5390. }
  5391. return options;
  5392. }
  5393. /**
  5394. * Resolve an asset.
  5395. * This function is used because child instances need access
  5396. * to assets defined in its ancestor chain.
  5397. */
  5398. function resolveAsset(options, type, id, warnMissing) {
  5399. /* istanbul ignore if */
  5400. if (typeof id !== 'string') {
  5401. return;
  5402. }
  5403. const assets = options[type];
  5404. // check local registration variations first
  5405. if (hasOwn(assets, id))
  5406. return assets[id];
  5407. const camelizedId = camelize(id);
  5408. if (hasOwn(assets, camelizedId))
  5409. return assets[camelizedId];
  5410. const PascalCaseId = capitalize(camelizedId);
  5411. if (hasOwn(assets, PascalCaseId))
  5412. return assets[PascalCaseId];
  5413. // fallback to prototype chain
  5414. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5415. if (warnMissing && !res) {
  5416. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5417. }
  5418. return res;
  5419. }
  5420. function validateProp(key, propOptions, propsData, vm) {
  5421. const prop = propOptions[key];
  5422. const absent = !hasOwn(propsData, key);
  5423. let value = propsData[key];
  5424. // boolean casting
  5425. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5426. if (booleanIndex > -1) {
  5427. if (absent && !hasOwn(prop, 'default')) {
  5428. value = false;
  5429. }
  5430. else if (value === '' || value === hyphenate(key)) {
  5431. // only cast empty string / same name to boolean if
  5432. // boolean has higher priority
  5433. const stringIndex = getTypeIndex(String, prop.type);
  5434. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5435. value = true;
  5436. }
  5437. }
  5438. }
  5439. // check default value
  5440. if (value === undefined) {
  5441. value = getPropDefaultValue(vm, prop, key);
  5442. // since the default value is a fresh copy,
  5443. // make sure to observe it.
  5444. const prevShouldObserve = shouldObserve;
  5445. toggleObserving(true);
  5446. observe(value);
  5447. toggleObserving(prevShouldObserve);
  5448. }
  5449. {
  5450. assertProp(prop, key, value, vm, absent);
  5451. }
  5452. return value;
  5453. }
  5454. /**
  5455. * Get the default value of a prop.
  5456. */
  5457. function getPropDefaultValue(vm, prop, key) {
  5458. // no default, return undefined
  5459. if (!hasOwn(prop, 'default')) {
  5460. return undefined;
  5461. }
  5462. const def = prop.default;
  5463. // warn against non-factory defaults for Object & Array
  5464. if (isObject(def)) {
  5465. warn$2('Invalid default value for prop "' +
  5466. key +
  5467. '": ' +
  5468. 'Props with type Object/Array must use a factory function ' +
  5469. 'to return the default value.', vm);
  5470. }
  5471. // the raw prop value was also undefined from previous render,
  5472. // return previous default value to avoid unnecessary watcher trigger
  5473. if (vm &&
  5474. vm.$options.propsData &&
  5475. vm.$options.propsData[key] === undefined &&
  5476. vm._props[key] !== undefined) {
  5477. return vm._props[key];
  5478. }
  5479. // call factory function for non-Function types
  5480. // a value is Function if its prototype is function even across different execution context
  5481. return isFunction(def) && getType(prop.type) !== 'Function'
  5482. ? def.call(vm)
  5483. : def;
  5484. }
  5485. /**
  5486. * Assert whether a prop is valid.
  5487. */
  5488. function assertProp(prop, name, value, vm, absent) {
  5489. if (prop.required && absent) {
  5490. warn$2('Missing required prop: "' + name + '"', vm);
  5491. return;
  5492. }
  5493. if (value == null && !prop.required) {
  5494. return;
  5495. }
  5496. let type = prop.type;
  5497. let valid = !type || type === true;
  5498. const expectedTypes = [];
  5499. if (type) {
  5500. if (!isArray(type)) {
  5501. type = [type];
  5502. }
  5503. for (let i = 0; i < type.length && !valid; i++) {
  5504. const assertedType = assertType(value, type[i], vm);
  5505. expectedTypes.push(assertedType.expectedType || '');
  5506. valid = assertedType.valid;
  5507. }
  5508. }
  5509. const haveExpectedTypes = expectedTypes.some(t => t);
  5510. if (!valid && haveExpectedTypes) {
  5511. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5512. return;
  5513. }
  5514. const validator = prop.validator;
  5515. if (validator) {
  5516. if (!validator(value)) {
  5517. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5518. }
  5519. }
  5520. }
  5521. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5522. function assertType(value, type, vm) {
  5523. let valid;
  5524. const expectedType = getType(type);
  5525. if (simpleCheckRE.test(expectedType)) {
  5526. const t = typeof value;
  5527. valid = t === expectedType.toLowerCase();
  5528. // for primitive wrapper objects
  5529. if (!valid && t === 'object') {
  5530. valid = value instanceof type;
  5531. }
  5532. }
  5533. else if (expectedType === 'Object') {
  5534. valid = isPlainObject(value);
  5535. }
  5536. else if (expectedType === 'Array') {
  5537. valid = isArray(value);
  5538. }
  5539. else {
  5540. try {
  5541. valid = value instanceof type;
  5542. }
  5543. catch (e) {
  5544. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5545. valid = false;
  5546. }
  5547. }
  5548. return {
  5549. valid,
  5550. expectedType
  5551. };
  5552. }
  5553. const functionTypeCheckRE = /^\s*function (\w+)/;
  5554. /**
  5555. * Use function string name to check built-in types,
  5556. * because a simple equality check will fail when running
  5557. * across different vms / iframes.
  5558. */
  5559. function getType(fn) {
  5560. const match = fn && fn.toString().match(functionTypeCheckRE);
  5561. return match ? match[1] : '';
  5562. }
  5563. function isSameType(a, b) {
  5564. return getType(a) === getType(b);
  5565. }
  5566. function getTypeIndex(type, expectedTypes) {
  5567. if (!isArray(expectedTypes)) {
  5568. return isSameType(expectedTypes, type) ? 0 : -1;
  5569. }
  5570. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5571. if (isSameType(expectedTypes[i], type)) {
  5572. return i;
  5573. }
  5574. }
  5575. return -1;
  5576. }
  5577. function getInvalidTypeMessage(name, value, expectedTypes) {
  5578. let message = `Invalid prop: type check failed for prop "${name}".` +
  5579. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5580. const expectedType = expectedTypes[0];
  5581. const receivedType = toRawType(value);
  5582. // check if we need to specify expected value
  5583. if (expectedTypes.length === 1 &&
  5584. isExplicable(expectedType) &&
  5585. isExplicable(typeof value) &&
  5586. !isBoolean(expectedType, receivedType)) {
  5587. message += ` with value ${styleValue(value, expectedType)}`;
  5588. }
  5589. message += `, got ${receivedType} `;
  5590. // check if we need to specify received value
  5591. if (isExplicable(receivedType)) {
  5592. message += `with value ${styleValue(value, receivedType)}.`;
  5593. }
  5594. return message;
  5595. }
  5596. function styleValue(value, type) {
  5597. if (type === 'String') {
  5598. return `"${value}"`;
  5599. }
  5600. else if (type === 'Number') {
  5601. return `${Number(value)}`;
  5602. }
  5603. else {
  5604. return `${value}`;
  5605. }
  5606. }
  5607. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5608. function isExplicable(value) {
  5609. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5610. }
  5611. function isBoolean(...args) {
  5612. return args.some(elem => elem.toLowerCase() === 'boolean');
  5613. }
  5614. function Vue(options) {
  5615. if (!(this instanceof Vue)) {
  5616. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5617. }
  5618. this._init(options);
  5619. }
  5620. //@ts-expect-error Vue has function type
  5621. initMixin$1(Vue);
  5622. //@ts-expect-error Vue has function type
  5623. stateMixin(Vue);
  5624. //@ts-expect-error Vue has function type
  5625. eventsMixin(Vue);
  5626. //@ts-expect-error Vue has function type
  5627. lifecycleMixin(Vue);
  5628. //@ts-expect-error Vue has function type
  5629. renderMixin(Vue);
  5630. function initUse(Vue) {
  5631. Vue.use = function (plugin) {
  5632. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5633. if (installedPlugins.indexOf(plugin) > -1) {
  5634. return this;
  5635. }
  5636. // additional parameters
  5637. const args = toArray(arguments, 1);
  5638. args.unshift(this);
  5639. if (isFunction(plugin.install)) {
  5640. plugin.install.apply(plugin, args);
  5641. }
  5642. else if (isFunction(plugin)) {
  5643. plugin.apply(null, args);
  5644. }
  5645. installedPlugins.push(plugin);
  5646. return this;
  5647. };
  5648. }
  5649. function initMixin(Vue) {
  5650. Vue.mixin = function (mixin) {
  5651. this.options = mergeOptions(this.options, mixin);
  5652. return this;
  5653. };
  5654. }
  5655. function initExtend(Vue) {
  5656. /**
  5657. * Each instance constructor, including Vue, has a unique
  5658. * cid. This enables us to create wrapped "child
  5659. * constructors" for prototypal inheritance and cache them.
  5660. */
  5661. Vue.cid = 0;
  5662. let cid = 1;
  5663. /**
  5664. * Class inheritance
  5665. */
  5666. Vue.extend = function (extendOptions) {
  5667. extendOptions = extendOptions || {};
  5668. const Super = this;
  5669. const SuperId = Super.cid;
  5670. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5671. if (cachedCtors[SuperId]) {
  5672. return cachedCtors[SuperId];
  5673. }
  5674. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5675. if (name) {
  5676. validateComponentName(name);
  5677. }
  5678. const Sub = function VueComponent(options) {
  5679. this._init(options);
  5680. };
  5681. Sub.prototype = Object.create(Super.prototype);
  5682. Sub.prototype.constructor = Sub;
  5683. Sub.cid = cid++;
  5684. Sub.options = mergeOptions(Super.options, extendOptions);
  5685. Sub['super'] = Super;
  5686. // For props and computed properties, we define the proxy getters on
  5687. // the Vue instances at extension time, on the extended prototype. This
  5688. // avoids Object.defineProperty calls for each instance created.
  5689. if (Sub.options.props) {
  5690. initProps(Sub);
  5691. }
  5692. if (Sub.options.computed) {
  5693. initComputed(Sub);
  5694. }
  5695. // allow further extension/mixin/plugin usage
  5696. Sub.extend = Super.extend;
  5697. Sub.mixin = Super.mixin;
  5698. Sub.use = Super.use;
  5699. // create asset registers, so extended classes
  5700. // can have their private assets too.
  5701. ASSET_TYPES.forEach(function (type) {
  5702. Sub[type] = Super[type];
  5703. });
  5704. // enable recursive self-lookup
  5705. if (name) {
  5706. Sub.options.components[name] = Sub;
  5707. }
  5708. // keep a reference to the super options at extension time.
  5709. // later at instantiation we can check if Super's options have
  5710. // been updated.
  5711. Sub.superOptions = Super.options;
  5712. Sub.extendOptions = extendOptions;
  5713. Sub.sealedOptions = extend({}, Sub.options);
  5714. // cache constructor
  5715. cachedCtors[SuperId] = Sub;
  5716. return Sub;
  5717. };
  5718. }
  5719. function initProps(Comp) {
  5720. const props = Comp.options.props;
  5721. for (const key in props) {
  5722. proxy(Comp.prototype, `_props`, key);
  5723. }
  5724. }
  5725. function initComputed(Comp) {
  5726. const computed = Comp.options.computed;
  5727. for (const key in computed) {
  5728. defineComputed(Comp.prototype, key, computed[key]);
  5729. }
  5730. }
  5731. function initAssetRegisters(Vue) {
  5732. /**
  5733. * Create asset registration methods.
  5734. */
  5735. ASSET_TYPES.forEach(type => {
  5736. // @ts-expect-error function is not exact same type
  5737. Vue[type] = function (id, definition) {
  5738. if (!definition) {
  5739. return this.options[type + 's'][id];
  5740. }
  5741. else {
  5742. /* istanbul ignore if */
  5743. if (type === 'component') {
  5744. validateComponentName(id);
  5745. }
  5746. if (type === 'component' && isPlainObject(definition)) {
  5747. // @ts-expect-error
  5748. definition.name = definition.name || id;
  5749. definition = this.options._base.extend(definition);
  5750. }
  5751. if (type === 'directive' && isFunction(definition)) {
  5752. definition = { bind: definition, update: definition };
  5753. }
  5754. this.options[type + 's'][id] = definition;
  5755. return definition;
  5756. }
  5757. };
  5758. });
  5759. }
  5760. function _getComponentName(opts) {
  5761. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5762. }
  5763. function matches(pattern, name) {
  5764. if (isArray(pattern)) {
  5765. return pattern.indexOf(name) > -1;
  5766. }
  5767. else if (typeof pattern === 'string') {
  5768. return pattern.split(',').indexOf(name) > -1;
  5769. }
  5770. else if (isRegExp(pattern)) {
  5771. return pattern.test(name);
  5772. }
  5773. /* istanbul ignore next */
  5774. return false;
  5775. }
  5776. function pruneCache(keepAliveInstance, filter) {
  5777. const { cache, keys, _vnode } = keepAliveInstance;
  5778. for (const key in cache) {
  5779. const entry = cache[key];
  5780. if (entry) {
  5781. const name = entry.name;
  5782. if (name && !filter(name)) {
  5783. pruneCacheEntry(cache, key, keys, _vnode);
  5784. }
  5785. }
  5786. }
  5787. }
  5788. function pruneCacheEntry(cache, key, keys, current) {
  5789. const entry = cache[key];
  5790. if (entry && (!current || entry.tag !== current.tag)) {
  5791. // @ts-expect-error can be undefined
  5792. entry.componentInstance.$destroy();
  5793. }
  5794. cache[key] = null;
  5795. remove$2(keys, key);
  5796. }
  5797. const patternTypes = [String, RegExp, Array];
  5798. // TODO defineComponent
  5799. var KeepAlive = {
  5800. name: 'keep-alive',
  5801. abstract: true,
  5802. props: {
  5803. include: patternTypes,
  5804. exclude: patternTypes,
  5805. max: [String, Number]
  5806. },
  5807. methods: {
  5808. cacheVNode() {
  5809. const { cache, keys, vnodeToCache, keyToCache } = this;
  5810. if (vnodeToCache) {
  5811. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5812. cache[keyToCache] = {
  5813. name: _getComponentName(componentOptions),
  5814. tag,
  5815. componentInstance
  5816. };
  5817. keys.push(keyToCache);
  5818. // prune oldest entry
  5819. if (this.max && keys.length > parseInt(this.max)) {
  5820. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5821. }
  5822. this.vnodeToCache = null;
  5823. }
  5824. }
  5825. },
  5826. created() {
  5827. this.cache = Object.create(null);
  5828. this.keys = [];
  5829. },
  5830. destroyed() {
  5831. for (const key in this.cache) {
  5832. pruneCacheEntry(this.cache, key, this.keys);
  5833. }
  5834. },
  5835. mounted() {
  5836. this.cacheVNode();
  5837. this.$watch('include', val => {
  5838. pruneCache(this, name => matches(val, name));
  5839. });
  5840. this.$watch('exclude', val => {
  5841. pruneCache(this, name => !matches(val, name));
  5842. });
  5843. },
  5844. updated() {
  5845. this.cacheVNode();
  5846. },
  5847. render() {
  5848. const slot = this.$slots.default;
  5849. const vnode = getFirstComponentChild(slot);
  5850. const componentOptions = vnode && vnode.componentOptions;
  5851. if (componentOptions) {
  5852. // check pattern
  5853. const name = _getComponentName(componentOptions);
  5854. const { include, exclude } = this;
  5855. if (
  5856. // not included
  5857. (include && (!name || !matches(include, name))) ||
  5858. // excluded
  5859. (exclude && name && matches(exclude, name))) {
  5860. return vnode;
  5861. }
  5862. const { cache, keys } = this;
  5863. const key = vnode.key == null
  5864. ? // same constructor may get registered as different local components
  5865. // so cid alone is not enough (#3269)
  5866. componentOptions.Ctor.cid +
  5867. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5868. : vnode.key;
  5869. if (cache[key]) {
  5870. vnode.componentInstance = cache[key].componentInstance;
  5871. // make current key freshest
  5872. remove$2(keys, key);
  5873. keys.push(key);
  5874. }
  5875. else {
  5876. // delay setting the cache until update
  5877. this.vnodeToCache = vnode;
  5878. this.keyToCache = key;
  5879. }
  5880. // @ts-expect-error can vnode.data can be undefined
  5881. vnode.data.keepAlive = true;
  5882. }
  5883. return vnode || (slot && slot[0]);
  5884. }
  5885. };
  5886. var builtInComponents = {
  5887. KeepAlive
  5888. };
  5889. function initGlobalAPI(Vue) {
  5890. // config
  5891. const configDef = {};
  5892. configDef.get = () => config;
  5893. {
  5894. configDef.set = () => {
  5895. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5896. };
  5897. }
  5898. Object.defineProperty(Vue, 'config', configDef);
  5899. // exposed util methods.
  5900. // NOTE: these are not considered part of the public API - avoid relying on
  5901. // them unless you are aware of the risk.
  5902. Vue.util = {
  5903. warn: warn$2,
  5904. extend,
  5905. mergeOptions,
  5906. defineReactive
  5907. };
  5908. Vue.set = set;
  5909. Vue.delete = del;
  5910. Vue.nextTick = nextTick;
  5911. // 2.6 explicit observable API
  5912. Vue.observable = (obj) => {
  5913. observe(obj);
  5914. return obj;
  5915. };
  5916. Vue.options = Object.create(null);
  5917. ASSET_TYPES.forEach(type => {
  5918. Vue.options[type + 's'] = Object.create(null);
  5919. });
  5920. // this is used to identify the "base" constructor to extend all plain-object
  5921. // components with in Weex's multi-instance scenarios.
  5922. Vue.options._base = Vue;
  5923. extend(Vue.options.components, builtInComponents);
  5924. initUse(Vue);
  5925. initMixin(Vue);
  5926. initExtend(Vue);
  5927. initAssetRegisters(Vue);
  5928. }
  5929. initGlobalAPI(Vue);
  5930. Object.defineProperty(Vue.prototype, '$isServer', {
  5931. get: isServerRendering
  5932. });
  5933. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5934. get() {
  5935. /* istanbul ignore next */
  5936. return this.$vnode && this.$vnode.ssrContext;
  5937. }
  5938. });
  5939. // expose FunctionalRenderContext for ssr runtime helper installation
  5940. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5941. value: FunctionalRenderContext
  5942. });
  5943. Vue.version = version;
  5944. // these are reserved for web because they are directly compiled away
  5945. // during template compilation
  5946. const isReservedAttr = makeMap('style,class');
  5947. // attributes that should be using props for binding
  5948. const acceptValue = makeMap('input,textarea,option,select,progress');
  5949. const mustUseProp = (tag, type, attr) => {
  5950. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5951. (attr === 'selected' && tag === 'option') ||
  5952. (attr === 'checked' && tag === 'input') ||
  5953. (attr === 'muted' && tag === 'video'));
  5954. };
  5955. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5956. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5957. const convertEnumeratedValue = (key, value) => {
  5958. return isFalsyAttrValue(value) || value === 'false'
  5959. ? 'false'
  5960. : // allow arbitrary string value for contenteditable
  5961. key === 'contenteditable' && isValidContentEditableValue(value)
  5962. ? value
  5963. : 'true';
  5964. };
  5965. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5966. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5967. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5968. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5969. 'required,reversed,scoped,seamless,selected,sortable,' +
  5970. 'truespeed,typemustmatch,visible');
  5971. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5972. const isXlink = (name) => {
  5973. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5974. };
  5975. const getXlinkProp = (name) => {
  5976. return isXlink(name) ? name.slice(6, name.length) : '';
  5977. };
  5978. const isFalsyAttrValue = (val) => {
  5979. return val == null || val === false;
  5980. };
  5981. function genClassForVnode(vnode) {
  5982. let data = vnode.data;
  5983. let parentNode = vnode;
  5984. let childNode = vnode;
  5985. while (isDef(childNode.componentInstance)) {
  5986. childNode = childNode.componentInstance._vnode;
  5987. if (childNode && childNode.data) {
  5988. data = mergeClassData(childNode.data, data);
  5989. }
  5990. }
  5991. // @ts-expect-error parentNode.parent not VNodeWithData
  5992. while (isDef((parentNode = parentNode.parent))) {
  5993. if (parentNode && parentNode.data) {
  5994. data = mergeClassData(data, parentNode.data);
  5995. }
  5996. }
  5997. return renderClass(data.staticClass, data.class);
  5998. }
  5999. function mergeClassData(child, parent) {
  6000. return {
  6001. staticClass: concat(child.staticClass, parent.staticClass),
  6002. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6003. };
  6004. }
  6005. function renderClass(staticClass, dynamicClass) {
  6006. if (isDef(staticClass) || isDef(dynamicClass)) {
  6007. return concat(staticClass, stringifyClass(dynamicClass));
  6008. }
  6009. /* istanbul ignore next */
  6010. return '';
  6011. }
  6012. function concat(a, b) {
  6013. return a ? (b ? a + ' ' + b : a) : b || '';
  6014. }
  6015. function stringifyClass(value) {
  6016. if (Array.isArray(value)) {
  6017. return stringifyArray(value);
  6018. }
  6019. if (isObject(value)) {
  6020. return stringifyObject(value);
  6021. }
  6022. if (typeof value === 'string') {
  6023. return value;
  6024. }
  6025. /* istanbul ignore next */
  6026. return '';
  6027. }
  6028. function stringifyArray(value) {
  6029. let res = '';
  6030. let stringified;
  6031. for (let i = 0, l = value.length; i < l; i++) {
  6032. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6033. if (res)
  6034. res += ' ';
  6035. res += stringified;
  6036. }
  6037. }
  6038. return res;
  6039. }
  6040. function stringifyObject(value) {
  6041. let res = '';
  6042. for (const key in value) {
  6043. if (value[key]) {
  6044. if (res)
  6045. res += ' ';
  6046. res += key;
  6047. }
  6048. }
  6049. return res;
  6050. }
  6051. const namespaceMap = {
  6052. svg: 'http://www.w3.org/2000/svg',
  6053. math: 'http://www.w3.org/1998/Math/MathML'
  6054. };
  6055. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6056. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6057. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6058. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6059. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6060. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6061. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6062. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6063. 'output,progress,select,textarea,' +
  6064. 'details,dialog,menu,menuitem,summary,' +
  6065. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6066. // this map is intentionally selective, only covering SVG elements that may
  6067. // contain child elements.
  6068. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6069. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6070. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6071. const isPreTag = (tag) => tag === 'pre';
  6072. const isReservedTag = (tag) => {
  6073. return isHTMLTag(tag) || isSVG(tag);
  6074. };
  6075. function getTagNamespace(tag) {
  6076. if (isSVG(tag)) {
  6077. return 'svg';
  6078. }
  6079. // basic support for MathML
  6080. // note it doesn't support other MathML elements being component roots
  6081. if (tag === 'math') {
  6082. return 'math';
  6083. }
  6084. }
  6085. const unknownElementCache = Object.create(null);
  6086. function isUnknownElement(tag) {
  6087. /* istanbul ignore if */
  6088. if (!inBrowser) {
  6089. return true;
  6090. }
  6091. if (isReservedTag(tag)) {
  6092. return false;
  6093. }
  6094. tag = tag.toLowerCase();
  6095. /* istanbul ignore if */
  6096. if (unknownElementCache[tag] != null) {
  6097. return unknownElementCache[tag];
  6098. }
  6099. const el = document.createElement(tag);
  6100. if (tag.indexOf('-') > -1) {
  6101. // http://stackoverflow.com/a/28210364/1070244
  6102. return (unknownElementCache[tag] =
  6103. el.constructor === window.HTMLUnknownElement ||
  6104. el.constructor === window.HTMLElement);
  6105. }
  6106. else {
  6107. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6108. }
  6109. }
  6110. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6111. /**
  6112. * Query an element selector if it's not an element already.
  6113. */
  6114. function query(el) {
  6115. if (typeof el === 'string') {
  6116. const selected = document.querySelector(el);
  6117. if (!selected) {
  6118. warn$2('Cannot find element: ' + el);
  6119. return document.createElement('div');
  6120. }
  6121. return selected;
  6122. }
  6123. else {
  6124. return el;
  6125. }
  6126. }
  6127. function createElement(tagName, vnode) {
  6128. const elm = document.createElement(tagName);
  6129. if (tagName !== 'select') {
  6130. return elm;
  6131. }
  6132. // false or null will remove the attribute but undefined will not
  6133. if (vnode.data &&
  6134. vnode.data.attrs &&
  6135. vnode.data.attrs.multiple !== undefined) {
  6136. elm.setAttribute('multiple', 'multiple');
  6137. }
  6138. return elm;
  6139. }
  6140. function createElementNS(namespace, tagName) {
  6141. return document.createElementNS(namespaceMap[namespace], tagName);
  6142. }
  6143. function createTextNode(text) {
  6144. return document.createTextNode(text);
  6145. }
  6146. function createComment(text) {
  6147. return document.createComment(text);
  6148. }
  6149. function insertBefore(parentNode, newNode, referenceNode) {
  6150. parentNode.insertBefore(newNode, referenceNode);
  6151. }
  6152. function removeChild(node, child) {
  6153. node.removeChild(child);
  6154. }
  6155. function appendChild(node, child) {
  6156. node.appendChild(child);
  6157. }
  6158. function parentNode(node) {
  6159. return node.parentNode;
  6160. }
  6161. function nextSibling(node) {
  6162. return node.nextSibling;
  6163. }
  6164. function tagName(node) {
  6165. return node.tagName;
  6166. }
  6167. function setTextContent(node, text) {
  6168. node.textContent = text;
  6169. }
  6170. function setStyleScope(node, scopeId) {
  6171. node.setAttribute(scopeId, '');
  6172. }
  6173. var nodeOps = /*#__PURE__*/Object.freeze({
  6174. __proto__: null,
  6175. createElement: createElement,
  6176. createElementNS: createElementNS,
  6177. createTextNode: createTextNode,
  6178. createComment: createComment,
  6179. insertBefore: insertBefore,
  6180. removeChild: removeChild,
  6181. appendChild: appendChild,
  6182. parentNode: parentNode,
  6183. nextSibling: nextSibling,
  6184. tagName: tagName,
  6185. setTextContent: setTextContent,
  6186. setStyleScope: setStyleScope
  6187. });
  6188. var ref = {
  6189. create(_, vnode) {
  6190. registerRef(vnode);
  6191. },
  6192. update(oldVnode, vnode) {
  6193. if (oldVnode.data.ref !== vnode.data.ref) {
  6194. registerRef(oldVnode, true);
  6195. registerRef(vnode);
  6196. }
  6197. },
  6198. destroy(vnode) {
  6199. registerRef(vnode, true);
  6200. }
  6201. };
  6202. function registerRef(vnode, isRemoval) {
  6203. const ref = vnode.data.ref;
  6204. if (!isDef(ref))
  6205. return;
  6206. const vm = vnode.context;
  6207. const refValue = vnode.componentInstance || vnode.elm;
  6208. const value = isRemoval ? null : refValue;
  6209. const $refsValue = isRemoval ? undefined : refValue;
  6210. if (isFunction(ref)) {
  6211. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6212. return;
  6213. }
  6214. const isFor = vnode.data.refInFor;
  6215. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6216. const _isRef = isRef(ref);
  6217. const refs = vm.$refs;
  6218. if (_isString || _isRef) {
  6219. if (isFor) {
  6220. const existing = _isString ? refs[ref] : ref.value;
  6221. if (isRemoval) {
  6222. isArray(existing) && remove$2(existing, refValue);
  6223. }
  6224. else {
  6225. if (!isArray(existing)) {
  6226. if (_isString) {
  6227. refs[ref] = [refValue];
  6228. setSetupRef(vm, ref, refs[ref]);
  6229. }
  6230. else {
  6231. ref.value = [refValue];
  6232. }
  6233. }
  6234. else if (!existing.includes(refValue)) {
  6235. existing.push(refValue);
  6236. }
  6237. }
  6238. }
  6239. else if (_isString) {
  6240. if (isRemoval && refs[ref] !== refValue) {
  6241. return;
  6242. }
  6243. refs[ref] = $refsValue;
  6244. setSetupRef(vm, ref, value);
  6245. }
  6246. else if (_isRef) {
  6247. if (isRemoval && ref.value !== refValue) {
  6248. return;
  6249. }
  6250. ref.value = value;
  6251. }
  6252. else {
  6253. warn$2(`Invalid template ref type: ${typeof ref}`);
  6254. }
  6255. }
  6256. }
  6257. function setSetupRef({ _setupState }, key, val) {
  6258. if (_setupState && hasOwn(_setupState, key)) {
  6259. if (isRef(_setupState[key])) {
  6260. _setupState[key].value = val;
  6261. }
  6262. else {
  6263. _setupState[key] = val;
  6264. }
  6265. }
  6266. }
  6267. /**
  6268. * Virtual DOM patching algorithm based on Snabbdom by
  6269. * Simon Friis Vindum (@paldepind)
  6270. * Licensed under the MIT License
  6271. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6272. *
  6273. * modified by Evan You (@yyx990803)
  6274. *
  6275. * Not type-checking this because this file is perf-critical and the cost
  6276. * of making flow understand it is not worth it.
  6277. */
  6278. const emptyNode = new VNode('', {}, []);
  6279. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6280. function sameVnode(a, b) {
  6281. return (a.key === b.key &&
  6282. a.asyncFactory === b.asyncFactory &&
  6283. ((a.tag === b.tag &&
  6284. a.isComment === b.isComment &&
  6285. isDef(a.data) === isDef(b.data) &&
  6286. sameInputType(a, b)) ||
  6287. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6288. }
  6289. function sameInputType(a, b) {
  6290. if (a.tag !== 'input')
  6291. return true;
  6292. let i;
  6293. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6294. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6295. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6296. }
  6297. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6298. let i, key;
  6299. const map = {};
  6300. for (i = beginIdx; i <= endIdx; ++i) {
  6301. key = children[i].key;
  6302. if (isDef(key))
  6303. map[key] = i;
  6304. }
  6305. return map;
  6306. }
  6307. function createPatchFunction(backend) {
  6308. let i, j;
  6309. const cbs = {};
  6310. const { modules, nodeOps } = backend;
  6311. for (i = 0; i < hooks.length; ++i) {
  6312. cbs[hooks[i]] = [];
  6313. for (j = 0; j < modules.length; ++j) {
  6314. if (isDef(modules[j][hooks[i]])) {
  6315. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6316. }
  6317. }
  6318. }
  6319. function emptyNodeAt(elm) {
  6320. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6321. }
  6322. function createRmCb(childElm, listeners) {
  6323. function remove() {
  6324. if (--remove.listeners === 0) {
  6325. removeNode(childElm);
  6326. }
  6327. }
  6328. remove.listeners = listeners;
  6329. return remove;
  6330. }
  6331. function removeNode(el) {
  6332. const parent = nodeOps.parentNode(el);
  6333. // element may have already been removed due to v-html / v-text
  6334. if (isDef(parent)) {
  6335. nodeOps.removeChild(parent, el);
  6336. }
  6337. }
  6338. function isUnknownElement(vnode, inVPre) {
  6339. return (!inVPre &&
  6340. !vnode.ns &&
  6341. !(config.ignoredElements.length &&
  6342. config.ignoredElements.some(ignore => {
  6343. return isRegExp(ignore)
  6344. ? ignore.test(vnode.tag)
  6345. : ignore === vnode.tag;
  6346. })) &&
  6347. config.isUnknownElement(vnode.tag));
  6348. }
  6349. let creatingElmInVPre = 0;
  6350. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6351. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6352. // This vnode was used in a previous render!
  6353. // now it's used as a new node, overwriting its elm would cause
  6354. // potential patch errors down the road when it's used as an insertion
  6355. // reference node. Instead, we clone the node on-demand before creating
  6356. // associated DOM element for it.
  6357. vnode = ownerArray[index] = cloneVNode(vnode);
  6358. }
  6359. vnode.isRootInsert = !nested; // for transition enter check
  6360. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6361. return;
  6362. }
  6363. const data = vnode.data;
  6364. const children = vnode.children;
  6365. const tag = vnode.tag;
  6366. if (isDef(tag)) {
  6367. {
  6368. if (data && data.pre) {
  6369. creatingElmInVPre++;
  6370. }
  6371. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6372. warn$2('Unknown custom element: <' +
  6373. tag +
  6374. '> - did you ' +
  6375. 'register the component correctly? For recursive components, ' +
  6376. 'make sure to provide the "name" option.', vnode.context);
  6377. }
  6378. }
  6379. vnode.elm = vnode.ns
  6380. ? nodeOps.createElementNS(vnode.ns, tag)
  6381. : nodeOps.createElement(tag, vnode);
  6382. setScope(vnode);
  6383. createChildren(vnode, children, insertedVnodeQueue);
  6384. if (isDef(data)) {
  6385. invokeCreateHooks(vnode, insertedVnodeQueue);
  6386. }
  6387. insert(parentElm, vnode.elm, refElm);
  6388. if (data && data.pre) {
  6389. creatingElmInVPre--;
  6390. }
  6391. }
  6392. else if (isTrue(vnode.isComment)) {
  6393. vnode.elm = nodeOps.createComment(vnode.text);
  6394. insert(parentElm, vnode.elm, refElm);
  6395. }
  6396. else {
  6397. vnode.elm = nodeOps.createTextNode(vnode.text);
  6398. insert(parentElm, vnode.elm, refElm);
  6399. }
  6400. }
  6401. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6402. let i = vnode.data;
  6403. if (isDef(i)) {
  6404. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6405. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6406. i(vnode, false /* hydrating */);
  6407. }
  6408. // after calling the init hook, if the vnode is a child component
  6409. // it should've created a child instance and mounted it. the child
  6410. // component also has set the placeholder vnode's elm.
  6411. // in that case we can just return the element and be done.
  6412. if (isDef(vnode.componentInstance)) {
  6413. initComponent(vnode, insertedVnodeQueue);
  6414. insert(parentElm, vnode.elm, refElm);
  6415. if (isTrue(isReactivated)) {
  6416. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6417. }
  6418. return true;
  6419. }
  6420. }
  6421. }
  6422. function initComponent(vnode, insertedVnodeQueue) {
  6423. if (isDef(vnode.data.pendingInsert)) {
  6424. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6425. vnode.data.pendingInsert = null;
  6426. }
  6427. vnode.elm = vnode.componentInstance.$el;
  6428. if (isPatchable(vnode)) {
  6429. invokeCreateHooks(vnode, insertedVnodeQueue);
  6430. setScope(vnode);
  6431. }
  6432. else {
  6433. // empty component root.
  6434. // skip all element-related modules except for ref (#3455)
  6435. registerRef(vnode);
  6436. // make sure to invoke the insert hook
  6437. insertedVnodeQueue.push(vnode);
  6438. }
  6439. }
  6440. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6441. let i;
  6442. // hack for #4339: a reactivated component with inner transition
  6443. // does not trigger because the inner node's created hooks are not called
  6444. // again. It's not ideal to involve module-specific logic in here but
  6445. // there doesn't seem to be a better way to do it.
  6446. let innerNode = vnode;
  6447. while (innerNode.componentInstance) {
  6448. innerNode = innerNode.componentInstance._vnode;
  6449. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6450. for (i = 0; i < cbs.activate.length; ++i) {
  6451. cbs.activate[i](emptyNode, innerNode);
  6452. }
  6453. insertedVnodeQueue.push(innerNode);
  6454. break;
  6455. }
  6456. }
  6457. // unlike a newly created component,
  6458. // a reactivated keep-alive component doesn't insert itself
  6459. insert(parentElm, vnode.elm, refElm);
  6460. }
  6461. function insert(parent, elm, ref) {
  6462. if (isDef(parent)) {
  6463. if (isDef(ref)) {
  6464. if (nodeOps.parentNode(ref) === parent) {
  6465. nodeOps.insertBefore(parent, elm, ref);
  6466. }
  6467. }
  6468. else {
  6469. nodeOps.appendChild(parent, elm);
  6470. }
  6471. }
  6472. }
  6473. function createChildren(vnode, children, insertedVnodeQueue) {
  6474. if (isArray(children)) {
  6475. {
  6476. checkDuplicateKeys(children);
  6477. }
  6478. for (let i = 0; i < children.length; ++i) {
  6479. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6480. }
  6481. }
  6482. else if (isPrimitive(vnode.text)) {
  6483. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6484. }
  6485. }
  6486. function isPatchable(vnode) {
  6487. while (vnode.componentInstance) {
  6488. vnode = vnode.componentInstance._vnode;
  6489. }
  6490. return isDef(vnode.tag);
  6491. }
  6492. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6493. for (let i = 0; i < cbs.create.length; ++i) {
  6494. cbs.create[i](emptyNode, vnode);
  6495. }
  6496. i = vnode.data.hook; // Reuse variable
  6497. if (isDef(i)) {
  6498. if (isDef(i.create))
  6499. i.create(emptyNode, vnode);
  6500. if (isDef(i.insert))
  6501. insertedVnodeQueue.push(vnode);
  6502. }
  6503. }
  6504. // set scope id attribute for scoped CSS.
  6505. // this is implemented as a special case to avoid the overhead
  6506. // of going through the normal attribute patching process.
  6507. function setScope(vnode) {
  6508. let i;
  6509. if (isDef((i = vnode.fnScopeId))) {
  6510. nodeOps.setStyleScope(vnode.elm, i);
  6511. }
  6512. else {
  6513. let ancestor = vnode;
  6514. while (ancestor) {
  6515. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6516. nodeOps.setStyleScope(vnode.elm, i);
  6517. }
  6518. ancestor = ancestor.parent;
  6519. }
  6520. }
  6521. // for slot content they should also get the scopeId from the host instance.
  6522. if (isDef((i = activeInstance)) &&
  6523. i !== vnode.context &&
  6524. i !== vnode.fnContext &&
  6525. isDef((i = i.$options._scopeId))) {
  6526. nodeOps.setStyleScope(vnode.elm, i);
  6527. }
  6528. }
  6529. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6530. for (; startIdx <= endIdx; ++startIdx) {
  6531. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6532. }
  6533. }
  6534. function invokeDestroyHook(vnode) {
  6535. let i, j;
  6536. const data = vnode.data;
  6537. if (isDef(data)) {
  6538. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6539. i(vnode);
  6540. for (i = 0; i < cbs.destroy.length; ++i)
  6541. cbs.destroy[i](vnode);
  6542. }
  6543. if (isDef((i = vnode.children))) {
  6544. for (j = 0; j < vnode.children.length; ++j) {
  6545. invokeDestroyHook(vnode.children[j]);
  6546. }
  6547. }
  6548. }
  6549. function removeVnodes(vnodes, startIdx, endIdx) {
  6550. for (; startIdx <= endIdx; ++startIdx) {
  6551. const ch = vnodes[startIdx];
  6552. if (isDef(ch)) {
  6553. if (isDef(ch.tag)) {
  6554. removeAndInvokeRemoveHook(ch);
  6555. invokeDestroyHook(ch);
  6556. }
  6557. else {
  6558. // Text node
  6559. removeNode(ch.elm);
  6560. }
  6561. }
  6562. }
  6563. }
  6564. function removeAndInvokeRemoveHook(vnode, rm) {
  6565. if (isDef(rm) || isDef(vnode.data)) {
  6566. let i;
  6567. const listeners = cbs.remove.length + 1;
  6568. if (isDef(rm)) {
  6569. // we have a recursively passed down rm callback
  6570. // increase the listeners count
  6571. rm.listeners += listeners;
  6572. }
  6573. else {
  6574. // directly removing
  6575. rm = createRmCb(vnode.elm, listeners);
  6576. }
  6577. // recursively invoke hooks on child component root node
  6578. if (isDef((i = vnode.componentInstance)) &&
  6579. isDef((i = i._vnode)) &&
  6580. isDef(i.data)) {
  6581. removeAndInvokeRemoveHook(i, rm);
  6582. }
  6583. for (i = 0; i < cbs.remove.length; ++i) {
  6584. cbs.remove[i](vnode, rm);
  6585. }
  6586. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6587. i(vnode, rm);
  6588. }
  6589. else {
  6590. rm();
  6591. }
  6592. }
  6593. else {
  6594. removeNode(vnode.elm);
  6595. }
  6596. }
  6597. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6598. let oldStartIdx = 0;
  6599. let newStartIdx = 0;
  6600. let oldEndIdx = oldCh.length - 1;
  6601. let oldStartVnode = oldCh[0];
  6602. let oldEndVnode = oldCh[oldEndIdx];
  6603. let newEndIdx = newCh.length - 1;
  6604. let newStartVnode = newCh[0];
  6605. let newEndVnode = newCh[newEndIdx];
  6606. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6607. // removeOnly is a special flag used only by <transition-group>
  6608. // to ensure removed elements stay in correct relative positions
  6609. // during leaving transitions
  6610. const canMove = !removeOnly;
  6611. {
  6612. checkDuplicateKeys(newCh);
  6613. }
  6614. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6615. if (isUndef(oldStartVnode)) {
  6616. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6617. }
  6618. else if (isUndef(oldEndVnode)) {
  6619. oldEndVnode = oldCh[--oldEndIdx];
  6620. }
  6621. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6622. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6623. oldStartVnode = oldCh[++oldStartIdx];
  6624. newStartVnode = newCh[++newStartIdx];
  6625. }
  6626. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6627. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6628. oldEndVnode = oldCh[--oldEndIdx];
  6629. newEndVnode = newCh[--newEndIdx];
  6630. }
  6631. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6632. // Vnode moved right
  6633. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6634. canMove &&
  6635. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6636. oldStartVnode = oldCh[++oldStartIdx];
  6637. newEndVnode = newCh[--newEndIdx];
  6638. }
  6639. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6640. // Vnode moved left
  6641. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6642. canMove &&
  6643. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6644. oldEndVnode = oldCh[--oldEndIdx];
  6645. newStartVnode = newCh[++newStartIdx];
  6646. }
  6647. else {
  6648. if (isUndef(oldKeyToIdx))
  6649. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6650. idxInOld = isDef(newStartVnode.key)
  6651. ? oldKeyToIdx[newStartVnode.key]
  6652. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6653. if (isUndef(idxInOld)) {
  6654. // New element
  6655. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6656. }
  6657. else {
  6658. vnodeToMove = oldCh[idxInOld];
  6659. if (sameVnode(vnodeToMove, newStartVnode)) {
  6660. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6661. oldCh[idxInOld] = undefined;
  6662. canMove &&
  6663. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6664. }
  6665. else {
  6666. // same key but different element. treat as new element
  6667. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6668. }
  6669. }
  6670. newStartVnode = newCh[++newStartIdx];
  6671. }
  6672. }
  6673. if (oldStartIdx > oldEndIdx) {
  6674. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6675. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6676. }
  6677. else if (newStartIdx > newEndIdx) {
  6678. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6679. }
  6680. }
  6681. function checkDuplicateKeys(children) {
  6682. const seenKeys = {};
  6683. for (let i = 0; i < children.length; i++) {
  6684. const vnode = children[i];
  6685. const key = vnode.key;
  6686. if (isDef(key)) {
  6687. if (seenKeys[key]) {
  6688. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6689. }
  6690. else {
  6691. seenKeys[key] = true;
  6692. }
  6693. }
  6694. }
  6695. }
  6696. function findIdxInOld(node, oldCh, start, end) {
  6697. for (let i = start; i < end; i++) {
  6698. const c = oldCh[i];
  6699. if (isDef(c) && sameVnode(node, c))
  6700. return i;
  6701. }
  6702. }
  6703. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6704. if (oldVnode === vnode) {
  6705. return;
  6706. }
  6707. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6708. // clone reused vnode
  6709. vnode = ownerArray[index] = cloneVNode(vnode);
  6710. }
  6711. const elm = (vnode.elm = oldVnode.elm);
  6712. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6713. if (isDef(vnode.asyncFactory.resolved)) {
  6714. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6715. }
  6716. else {
  6717. vnode.isAsyncPlaceholder = true;
  6718. }
  6719. return;
  6720. }
  6721. // reuse element for static trees.
  6722. // note we only do this if the vnode is cloned -
  6723. // if the new node is not cloned it means the render functions have been
  6724. // reset by the hot-reload-api and we need to do a proper re-render.
  6725. if (isTrue(vnode.isStatic) &&
  6726. isTrue(oldVnode.isStatic) &&
  6727. vnode.key === oldVnode.key &&
  6728. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6729. vnode.componentInstance = oldVnode.componentInstance;
  6730. return;
  6731. }
  6732. let i;
  6733. const data = vnode.data;
  6734. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6735. i(oldVnode, vnode);
  6736. }
  6737. const oldCh = oldVnode.children;
  6738. const ch = vnode.children;
  6739. if (isDef(data) && isPatchable(vnode)) {
  6740. for (i = 0; i < cbs.update.length; ++i)
  6741. cbs.update[i](oldVnode, vnode);
  6742. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6743. i(oldVnode, vnode);
  6744. }
  6745. if (isUndef(vnode.text)) {
  6746. if (isDef(oldCh) && isDef(ch)) {
  6747. if (oldCh !== ch)
  6748. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6749. }
  6750. else if (isDef(ch)) {
  6751. {
  6752. checkDuplicateKeys(ch);
  6753. }
  6754. if (isDef(oldVnode.text))
  6755. nodeOps.setTextContent(elm, '');
  6756. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6757. }
  6758. else if (isDef(oldCh)) {
  6759. removeVnodes(oldCh, 0, oldCh.length - 1);
  6760. }
  6761. else if (isDef(oldVnode.text)) {
  6762. nodeOps.setTextContent(elm, '');
  6763. }
  6764. }
  6765. else if (oldVnode.text !== vnode.text) {
  6766. nodeOps.setTextContent(elm, vnode.text);
  6767. }
  6768. if (isDef(data)) {
  6769. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6770. i(oldVnode, vnode);
  6771. }
  6772. }
  6773. function invokeInsertHook(vnode, queue, initial) {
  6774. // delay insert hooks for component root nodes, invoke them after the
  6775. // element is really inserted
  6776. if (isTrue(initial) && isDef(vnode.parent)) {
  6777. vnode.parent.data.pendingInsert = queue;
  6778. }
  6779. else {
  6780. for (let i = 0; i < queue.length; ++i) {
  6781. queue[i].data.hook.insert(queue[i]);
  6782. }
  6783. }
  6784. }
  6785. let hydrationBailed = false;
  6786. // list of modules that can skip create hook during hydration because they
  6787. // are already rendered on the client or has no need for initialization
  6788. // Note: style is excluded because it relies on initial clone for future
  6789. // deep updates (#7063).
  6790. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6791. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6792. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6793. let i;
  6794. const { tag, data, children } = vnode;
  6795. inVPre = inVPre || (data && data.pre);
  6796. vnode.elm = elm;
  6797. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6798. vnode.isAsyncPlaceholder = true;
  6799. return true;
  6800. }
  6801. // assert node match
  6802. {
  6803. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6804. return false;
  6805. }
  6806. }
  6807. if (isDef(data)) {
  6808. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6809. i(vnode, true /* hydrating */);
  6810. if (isDef((i = vnode.componentInstance))) {
  6811. // child component. it should have hydrated its own tree.
  6812. initComponent(vnode, insertedVnodeQueue);
  6813. return true;
  6814. }
  6815. }
  6816. if (isDef(tag)) {
  6817. if (isDef(children)) {
  6818. // empty element, allow client to pick up and populate children
  6819. if (!elm.hasChildNodes()) {
  6820. createChildren(vnode, children, insertedVnodeQueue);
  6821. }
  6822. else {
  6823. // v-html and domProps: innerHTML
  6824. if (isDef((i = data)) &&
  6825. isDef((i = i.domProps)) &&
  6826. isDef((i = i.innerHTML))) {
  6827. if (i !== elm.innerHTML) {
  6828. /* istanbul ignore if */
  6829. if (typeof console !== 'undefined' &&
  6830. !hydrationBailed) {
  6831. hydrationBailed = true;
  6832. console.warn('Parent: ', elm);
  6833. console.warn('server innerHTML: ', i);
  6834. console.warn('client innerHTML: ', elm.innerHTML);
  6835. }
  6836. return false;
  6837. }
  6838. }
  6839. else {
  6840. // iterate and compare children lists
  6841. let childrenMatch = true;
  6842. let childNode = elm.firstChild;
  6843. for (let i = 0; i < children.length; i++) {
  6844. if (!childNode ||
  6845. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6846. childrenMatch = false;
  6847. break;
  6848. }
  6849. childNode = childNode.nextSibling;
  6850. }
  6851. // if childNode is not null, it means the actual childNodes list is
  6852. // longer than the virtual children list.
  6853. if (!childrenMatch || childNode) {
  6854. /* istanbul ignore if */
  6855. if (typeof console !== 'undefined' &&
  6856. !hydrationBailed) {
  6857. hydrationBailed = true;
  6858. console.warn('Parent: ', elm);
  6859. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6860. }
  6861. return false;
  6862. }
  6863. }
  6864. }
  6865. }
  6866. if (isDef(data)) {
  6867. let fullInvoke = false;
  6868. for (const key in data) {
  6869. if (!isRenderedModule(key)) {
  6870. fullInvoke = true;
  6871. invokeCreateHooks(vnode, insertedVnodeQueue);
  6872. break;
  6873. }
  6874. }
  6875. if (!fullInvoke && data['class']) {
  6876. // ensure collecting deps for deep class bindings for future updates
  6877. traverse(data['class']);
  6878. }
  6879. }
  6880. }
  6881. else if (elm.data !== vnode.text) {
  6882. elm.data = vnode.text;
  6883. }
  6884. return true;
  6885. }
  6886. function assertNodeMatch(node, vnode, inVPre) {
  6887. if (isDef(vnode.tag)) {
  6888. return (vnode.tag.indexOf('vue-component') === 0 ||
  6889. (!isUnknownElement(vnode, inVPre) &&
  6890. vnode.tag.toLowerCase() ===
  6891. (node.tagName && node.tagName.toLowerCase())));
  6892. }
  6893. else {
  6894. return node.nodeType === (vnode.isComment ? 8 : 3);
  6895. }
  6896. }
  6897. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6898. if (isUndef(vnode)) {
  6899. if (isDef(oldVnode))
  6900. invokeDestroyHook(oldVnode);
  6901. return;
  6902. }
  6903. let isInitialPatch = false;
  6904. const insertedVnodeQueue = [];
  6905. if (isUndef(oldVnode)) {
  6906. // empty mount (likely as component), create new root element
  6907. isInitialPatch = true;
  6908. createElm(vnode, insertedVnodeQueue);
  6909. }
  6910. else {
  6911. const isRealElement = isDef(oldVnode.nodeType);
  6912. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6913. // patch existing root node
  6914. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6915. }
  6916. else {
  6917. if (isRealElement) {
  6918. // mounting to a real element
  6919. // check if this is server-rendered content and if we can perform
  6920. // a successful hydration.
  6921. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6922. oldVnode.removeAttribute(SSR_ATTR);
  6923. hydrating = true;
  6924. }
  6925. if (isTrue(hydrating)) {
  6926. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6927. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6928. return oldVnode;
  6929. }
  6930. else {
  6931. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6932. 'server-rendered content. This is likely caused by incorrect ' +
  6933. 'HTML markup, for example nesting block-level elements inside ' +
  6934. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6935. 'full client-side render.');
  6936. }
  6937. }
  6938. // either not server-rendered, or hydration failed.
  6939. // create an empty node and replace it
  6940. oldVnode = emptyNodeAt(oldVnode);
  6941. }
  6942. // replacing existing element
  6943. const oldElm = oldVnode.elm;
  6944. const parentElm = nodeOps.parentNode(oldElm);
  6945. // create new node
  6946. createElm(vnode, insertedVnodeQueue,
  6947. // extremely rare edge case: do not insert if old element is in a
  6948. // leaving transition. Only happens when combining transition +
  6949. // keep-alive + HOCs. (#4590)
  6950. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6951. // update parent placeholder node element, recursively
  6952. if (isDef(vnode.parent)) {
  6953. let ancestor = vnode.parent;
  6954. const patchable = isPatchable(vnode);
  6955. while (ancestor) {
  6956. for (let i = 0; i < cbs.destroy.length; ++i) {
  6957. cbs.destroy[i](ancestor);
  6958. }
  6959. ancestor.elm = vnode.elm;
  6960. if (patchable) {
  6961. for (let i = 0; i < cbs.create.length; ++i) {
  6962. cbs.create[i](emptyNode, ancestor);
  6963. }
  6964. // #6513
  6965. // invoke insert hooks that may have been merged by create hooks.
  6966. // e.g. for directives that uses the "inserted" hook.
  6967. const insert = ancestor.data.hook.insert;
  6968. if (insert.merged) {
  6969. // start at index 1 to avoid re-invoking component mounted hook
  6970. for (let i = 1; i < insert.fns.length; i++) {
  6971. insert.fns[i]();
  6972. }
  6973. }
  6974. }
  6975. else {
  6976. registerRef(ancestor);
  6977. }
  6978. ancestor = ancestor.parent;
  6979. }
  6980. }
  6981. // destroy old node
  6982. if (isDef(parentElm)) {
  6983. removeVnodes([oldVnode], 0, 0);
  6984. }
  6985. else if (isDef(oldVnode.tag)) {
  6986. invokeDestroyHook(oldVnode);
  6987. }
  6988. }
  6989. }
  6990. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6991. return vnode.elm;
  6992. };
  6993. }
  6994. var directives$1 = {
  6995. create: updateDirectives,
  6996. update: updateDirectives,
  6997. destroy: function unbindDirectives(vnode) {
  6998. // @ts-expect-error emptyNode is not VNodeWithData
  6999. updateDirectives(vnode, emptyNode);
  7000. }
  7001. };
  7002. function updateDirectives(oldVnode, vnode) {
  7003. if (oldVnode.data.directives || vnode.data.directives) {
  7004. _update(oldVnode, vnode);
  7005. }
  7006. }
  7007. function _update(oldVnode, vnode) {
  7008. const isCreate = oldVnode === emptyNode;
  7009. const isDestroy = vnode === emptyNode;
  7010. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7011. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7012. const dirsWithInsert = [];
  7013. const dirsWithPostpatch = [];
  7014. let key, oldDir, dir;
  7015. for (key in newDirs) {
  7016. oldDir = oldDirs[key];
  7017. dir = newDirs[key];
  7018. if (!oldDir) {
  7019. // new directive, bind
  7020. callHook(dir, 'bind', vnode, oldVnode);
  7021. if (dir.def && dir.def.inserted) {
  7022. dirsWithInsert.push(dir);
  7023. }
  7024. }
  7025. else {
  7026. // existing directive, update
  7027. dir.oldValue = oldDir.value;
  7028. dir.oldArg = oldDir.arg;
  7029. callHook(dir, 'update', vnode, oldVnode);
  7030. if (dir.def && dir.def.componentUpdated) {
  7031. dirsWithPostpatch.push(dir);
  7032. }
  7033. }
  7034. }
  7035. if (dirsWithInsert.length) {
  7036. const callInsert = () => {
  7037. for (let i = 0; i < dirsWithInsert.length; i++) {
  7038. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7039. }
  7040. };
  7041. if (isCreate) {
  7042. mergeVNodeHook(vnode, 'insert', callInsert);
  7043. }
  7044. else {
  7045. callInsert();
  7046. }
  7047. }
  7048. if (dirsWithPostpatch.length) {
  7049. mergeVNodeHook(vnode, 'postpatch', () => {
  7050. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7051. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7052. }
  7053. });
  7054. }
  7055. if (!isCreate) {
  7056. for (key in oldDirs) {
  7057. if (!newDirs[key]) {
  7058. // no longer present, unbind
  7059. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7060. }
  7061. }
  7062. }
  7063. }
  7064. const emptyModifiers = Object.create(null);
  7065. function normalizeDirectives(dirs, vm) {
  7066. const res = Object.create(null);
  7067. if (!dirs) {
  7068. // $flow-disable-line
  7069. return res;
  7070. }
  7071. let i, dir;
  7072. for (i = 0; i < dirs.length; i++) {
  7073. dir = dirs[i];
  7074. if (!dir.modifiers) {
  7075. // $flow-disable-line
  7076. dir.modifiers = emptyModifiers;
  7077. }
  7078. res[getRawDirName(dir)] = dir;
  7079. if (vm._setupState && vm._setupState.__sfc) {
  7080. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7081. if (typeof setupDef === 'function') {
  7082. dir.def = {
  7083. bind: setupDef,
  7084. update: setupDef,
  7085. };
  7086. }
  7087. else {
  7088. dir.def = setupDef;
  7089. }
  7090. }
  7091. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7092. }
  7093. // $flow-disable-line
  7094. return res;
  7095. }
  7096. function getRawDirName(dir) {
  7097. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7098. }
  7099. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7100. const fn = dir.def && dir.def[hook];
  7101. if (fn) {
  7102. try {
  7103. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7104. }
  7105. catch (e) {
  7106. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7107. }
  7108. }
  7109. }
  7110. var baseModules = [ref, directives$1];
  7111. function updateAttrs(oldVnode, vnode) {
  7112. const opts = vnode.componentOptions;
  7113. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7114. return;
  7115. }
  7116. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7117. return;
  7118. }
  7119. let key, cur, old;
  7120. const elm = vnode.elm;
  7121. const oldAttrs = oldVnode.data.attrs || {};
  7122. let attrs = vnode.data.attrs || {};
  7123. // clone observed objects, as the user probably wants to mutate it
  7124. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7125. attrs = vnode.data.attrs = extend({}, attrs);
  7126. }
  7127. for (key in attrs) {
  7128. cur = attrs[key];
  7129. old = oldAttrs[key];
  7130. if (old !== cur) {
  7131. setAttr(elm, key, cur, vnode.data.pre);
  7132. }
  7133. }
  7134. // #4391: in IE9, setting type can reset value for input[type=radio]
  7135. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7136. /* istanbul ignore if */
  7137. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7138. setAttr(elm, 'value', attrs.value);
  7139. }
  7140. for (key in oldAttrs) {
  7141. if (isUndef(attrs[key])) {
  7142. if (isXlink(key)) {
  7143. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7144. }
  7145. else if (!isEnumeratedAttr(key)) {
  7146. elm.removeAttribute(key);
  7147. }
  7148. }
  7149. }
  7150. }
  7151. function setAttr(el, key, value, isInPre) {
  7152. if (isInPre || el.tagName.indexOf('-') > -1) {
  7153. baseSetAttr(el, key, value);
  7154. }
  7155. else if (isBooleanAttr(key)) {
  7156. // set attribute for blank value
  7157. // e.g. <option disabled>Select one</option>
  7158. if (isFalsyAttrValue(value)) {
  7159. el.removeAttribute(key);
  7160. }
  7161. else {
  7162. // technically allowfullscreen is a boolean attribute for <iframe>,
  7163. // but Flash expects a value of "true" when used on <embed> tag
  7164. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7165. el.setAttribute(key, value);
  7166. }
  7167. }
  7168. else if (isEnumeratedAttr(key)) {
  7169. el.setAttribute(key, convertEnumeratedValue(key, value));
  7170. }
  7171. else if (isXlink(key)) {
  7172. if (isFalsyAttrValue(value)) {
  7173. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7174. }
  7175. else {
  7176. el.setAttributeNS(xlinkNS, key, value);
  7177. }
  7178. }
  7179. else {
  7180. baseSetAttr(el, key, value);
  7181. }
  7182. }
  7183. function baseSetAttr(el, key, value) {
  7184. if (isFalsyAttrValue(value)) {
  7185. el.removeAttribute(key);
  7186. }
  7187. else {
  7188. // #7138: IE10 & 11 fires input event when setting placeholder on
  7189. // <textarea>... block the first input event and remove the blocker
  7190. // immediately.
  7191. /* istanbul ignore if */
  7192. if (isIE &&
  7193. !isIE9 &&
  7194. el.tagName === 'TEXTAREA' &&
  7195. key === 'placeholder' &&
  7196. value !== '' &&
  7197. !el.__ieph) {
  7198. const blocker = e => {
  7199. e.stopImmediatePropagation();
  7200. el.removeEventListener('input', blocker);
  7201. };
  7202. el.addEventListener('input', blocker);
  7203. // $flow-disable-line
  7204. el.__ieph = true; /* IE placeholder patched */
  7205. }
  7206. el.setAttribute(key, value);
  7207. }
  7208. }
  7209. var attrs = {
  7210. create: updateAttrs,
  7211. update: updateAttrs
  7212. };
  7213. function updateClass(oldVnode, vnode) {
  7214. const el = vnode.elm;
  7215. const data = vnode.data;
  7216. const oldData = oldVnode.data;
  7217. if (isUndef(data.staticClass) &&
  7218. isUndef(data.class) &&
  7219. (isUndef(oldData) ||
  7220. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7221. return;
  7222. }
  7223. let cls = genClassForVnode(vnode);
  7224. // handle transition classes
  7225. const transitionClass = el._transitionClasses;
  7226. if (isDef(transitionClass)) {
  7227. cls = concat(cls, stringifyClass(transitionClass));
  7228. }
  7229. // set the class
  7230. if (cls !== el._prevClass) {
  7231. el.setAttribute('class', cls);
  7232. el._prevClass = cls;
  7233. }
  7234. }
  7235. var klass$1 = {
  7236. create: updateClass,
  7237. update: updateClass
  7238. };
  7239. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7240. function parseFilters(exp) {
  7241. let inSingle = false;
  7242. let inDouble = false;
  7243. let inTemplateString = false;
  7244. let inRegex = false;
  7245. let curly = 0;
  7246. let square = 0;
  7247. let paren = 0;
  7248. let lastFilterIndex = 0;
  7249. let c, prev, i, expression, filters;
  7250. for (i = 0; i < exp.length; i++) {
  7251. prev = c;
  7252. c = exp.charCodeAt(i);
  7253. if (inSingle) {
  7254. if (c === 0x27 && prev !== 0x5c)
  7255. inSingle = false;
  7256. }
  7257. else if (inDouble) {
  7258. if (c === 0x22 && prev !== 0x5c)
  7259. inDouble = false;
  7260. }
  7261. else if (inTemplateString) {
  7262. if (c === 0x60 && prev !== 0x5c)
  7263. inTemplateString = false;
  7264. }
  7265. else if (inRegex) {
  7266. if (c === 0x2f && prev !== 0x5c)
  7267. inRegex = false;
  7268. }
  7269. else if (c === 0x7c && // pipe
  7270. exp.charCodeAt(i + 1) !== 0x7c &&
  7271. exp.charCodeAt(i - 1) !== 0x7c &&
  7272. !curly &&
  7273. !square &&
  7274. !paren) {
  7275. if (expression === undefined) {
  7276. // first filter, end of expression
  7277. lastFilterIndex = i + 1;
  7278. expression = exp.slice(0, i).trim();
  7279. }
  7280. else {
  7281. pushFilter();
  7282. }
  7283. }
  7284. else {
  7285. switch (c) {
  7286. case 0x22:
  7287. inDouble = true;
  7288. break; // "
  7289. case 0x27:
  7290. inSingle = true;
  7291. break; // '
  7292. case 0x60:
  7293. inTemplateString = true;
  7294. break; // `
  7295. case 0x28:
  7296. paren++;
  7297. break; // (
  7298. case 0x29:
  7299. paren--;
  7300. break; // )
  7301. case 0x5b:
  7302. square++;
  7303. break; // [
  7304. case 0x5d:
  7305. square--;
  7306. break; // ]
  7307. case 0x7b:
  7308. curly++;
  7309. break; // {
  7310. case 0x7d:
  7311. curly--;
  7312. break; // }
  7313. }
  7314. if (c === 0x2f) {
  7315. // /
  7316. let j = i - 1;
  7317. let p;
  7318. // find first non-whitespace prev char
  7319. for (; j >= 0; j--) {
  7320. p = exp.charAt(j);
  7321. if (p !== ' ')
  7322. break;
  7323. }
  7324. if (!p || !validDivisionCharRE.test(p)) {
  7325. inRegex = true;
  7326. }
  7327. }
  7328. }
  7329. }
  7330. if (expression === undefined) {
  7331. expression = exp.slice(0, i).trim();
  7332. }
  7333. else if (lastFilterIndex !== 0) {
  7334. pushFilter();
  7335. }
  7336. function pushFilter() {
  7337. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7338. lastFilterIndex = i + 1;
  7339. }
  7340. if (filters) {
  7341. for (i = 0; i < filters.length; i++) {
  7342. expression = wrapFilter(expression, filters[i]);
  7343. }
  7344. }
  7345. return expression;
  7346. }
  7347. function wrapFilter(exp, filter) {
  7348. const i = filter.indexOf('(');
  7349. if (i < 0) {
  7350. // _f: resolveFilter
  7351. return `_f("${filter}")(${exp})`;
  7352. }
  7353. else {
  7354. const name = filter.slice(0, i);
  7355. const args = filter.slice(i + 1);
  7356. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7357. }
  7358. }
  7359. /* eslint-disable no-unused-vars */
  7360. function baseWarn(msg, range) {
  7361. console.error(`[Vue compiler]: ${msg}`);
  7362. }
  7363. /* eslint-enable no-unused-vars */
  7364. function pluckModuleFunction(modules, key) {
  7365. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7366. }
  7367. function addProp(el, name, value, range, dynamic) {
  7368. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7369. el.plain = false;
  7370. }
  7371. function addAttr(el, name, value, range, dynamic) {
  7372. const attrs = dynamic
  7373. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7374. : el.attrs || (el.attrs = []);
  7375. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7376. el.plain = false;
  7377. }
  7378. // add a raw attr (use this in preTransforms)
  7379. function addRawAttr(el, name, value, range) {
  7380. el.attrsMap[name] = value;
  7381. el.attrsList.push(rangeSetItem({ name, value }, range));
  7382. }
  7383. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7384. (el.directives || (el.directives = [])).push(rangeSetItem({
  7385. name,
  7386. rawName,
  7387. value,
  7388. arg,
  7389. isDynamicArg,
  7390. modifiers
  7391. }, range));
  7392. el.plain = false;
  7393. }
  7394. function prependModifierMarker(symbol, name, dynamic) {
  7395. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7396. }
  7397. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7398. modifiers = modifiers || emptyObject;
  7399. // warn prevent and passive modifier
  7400. /* istanbul ignore if */
  7401. if (warn && modifiers.prevent && modifiers.passive) {
  7402. warn("passive and prevent can't be used together. " +
  7403. "Passive handler can't prevent default event.", range);
  7404. }
  7405. // normalize click.right and click.middle since they don't actually fire
  7406. // this is technically browser-specific, but at least for now browsers are
  7407. // the only target envs that have right/middle clicks.
  7408. if (modifiers.right) {
  7409. if (dynamic) {
  7410. name = `(${name})==='click'?'contextmenu':(${name})`;
  7411. }
  7412. else if (name === 'click') {
  7413. name = 'contextmenu';
  7414. delete modifiers.right;
  7415. }
  7416. }
  7417. else if (modifiers.middle) {
  7418. if (dynamic) {
  7419. name = `(${name})==='click'?'mouseup':(${name})`;
  7420. }
  7421. else if (name === 'click') {
  7422. name = 'mouseup';
  7423. }
  7424. }
  7425. // check capture modifier
  7426. if (modifiers.capture) {
  7427. delete modifiers.capture;
  7428. name = prependModifierMarker('!', name, dynamic);
  7429. }
  7430. if (modifiers.once) {
  7431. delete modifiers.once;
  7432. name = prependModifierMarker('~', name, dynamic);
  7433. }
  7434. /* istanbul ignore if */
  7435. if (modifiers.passive) {
  7436. delete modifiers.passive;
  7437. name = prependModifierMarker('&', name, dynamic);
  7438. }
  7439. let events;
  7440. if (modifiers.native) {
  7441. delete modifiers.native;
  7442. events = el.nativeEvents || (el.nativeEvents = {});
  7443. }
  7444. else {
  7445. events = el.events || (el.events = {});
  7446. }
  7447. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7448. if (modifiers !== emptyObject) {
  7449. newHandler.modifiers = modifiers;
  7450. }
  7451. const handlers = events[name];
  7452. /* istanbul ignore if */
  7453. if (Array.isArray(handlers)) {
  7454. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7455. }
  7456. else if (handlers) {
  7457. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7458. }
  7459. else {
  7460. events[name] = newHandler;
  7461. }
  7462. el.plain = false;
  7463. }
  7464. function getRawBindingAttr(el, name) {
  7465. return (el.rawAttrsMap[':' + name] ||
  7466. el.rawAttrsMap['v-bind:' + name] ||
  7467. el.rawAttrsMap[name]);
  7468. }
  7469. function getBindingAttr(el, name, getStatic) {
  7470. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7471. if (dynamicValue != null) {
  7472. return parseFilters(dynamicValue);
  7473. }
  7474. else if (getStatic !== false) {
  7475. const staticValue = getAndRemoveAttr(el, name);
  7476. if (staticValue != null) {
  7477. return JSON.stringify(staticValue);
  7478. }
  7479. }
  7480. }
  7481. // note: this only removes the attr from the Array (attrsList) so that it
  7482. // doesn't get processed by processAttrs.
  7483. // By default it does NOT remove it from the map (attrsMap) because the map is
  7484. // needed during codegen.
  7485. function getAndRemoveAttr(el, name, removeFromMap) {
  7486. let val;
  7487. if ((val = el.attrsMap[name]) != null) {
  7488. const list = el.attrsList;
  7489. for (let i = 0, l = list.length; i < l; i++) {
  7490. if (list[i].name === name) {
  7491. list.splice(i, 1);
  7492. break;
  7493. }
  7494. }
  7495. }
  7496. if (removeFromMap) {
  7497. delete el.attrsMap[name];
  7498. }
  7499. return val;
  7500. }
  7501. function getAndRemoveAttrByRegex(el, name) {
  7502. const list = el.attrsList;
  7503. for (let i = 0, l = list.length; i < l; i++) {
  7504. const attr = list[i];
  7505. if (name.test(attr.name)) {
  7506. list.splice(i, 1);
  7507. return attr;
  7508. }
  7509. }
  7510. }
  7511. function rangeSetItem(item, range) {
  7512. if (range) {
  7513. if (range.start != null) {
  7514. item.start = range.start;
  7515. }
  7516. if (range.end != null) {
  7517. item.end = range.end;
  7518. }
  7519. }
  7520. return item;
  7521. }
  7522. /**
  7523. * Cross-platform code generation for component v-model
  7524. */
  7525. function genComponentModel(el, value, modifiers) {
  7526. const { number, trim } = modifiers || {};
  7527. const baseValueExpression = '$$v';
  7528. let valueExpression = baseValueExpression;
  7529. if (trim) {
  7530. valueExpression =
  7531. `(typeof ${baseValueExpression} === 'string'` +
  7532. `? ${baseValueExpression}.trim()` +
  7533. `: ${baseValueExpression})`;
  7534. }
  7535. if (number) {
  7536. valueExpression = `_n(${valueExpression})`;
  7537. }
  7538. const assignment = genAssignmentCode(value, valueExpression);
  7539. el.model = {
  7540. value: `(${value})`,
  7541. expression: JSON.stringify(value),
  7542. callback: `function (${baseValueExpression}) {${assignment}}`
  7543. };
  7544. }
  7545. /**
  7546. * Cross-platform codegen helper for generating v-model value assignment code.
  7547. */
  7548. function genAssignmentCode(value, assignment) {
  7549. const res = parseModel(value);
  7550. if (res.key === null) {
  7551. return `${value}=${assignment}`;
  7552. }
  7553. else {
  7554. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7555. }
  7556. }
  7557. /**
  7558. * Parse a v-model expression into a base path and a final key segment.
  7559. * Handles both dot-path and possible square brackets.
  7560. *
  7561. * Possible cases:
  7562. *
  7563. * - test
  7564. * - test[key]
  7565. * - test[test1[key]]
  7566. * - test["a"][key]
  7567. * - xxx.test[a[a].test1[key]]
  7568. * - test.xxx.a["asa"][test1[key]]
  7569. *
  7570. */
  7571. let len, str, chr, index, expressionPos, expressionEndPos;
  7572. function parseModel(val) {
  7573. // Fix https://github.com/vuejs/vue/pull/7730
  7574. // allow v-model="obj.val " (trailing whitespace)
  7575. val = val.trim();
  7576. len = val.length;
  7577. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7578. index = val.lastIndexOf('.');
  7579. if (index > -1) {
  7580. return {
  7581. exp: val.slice(0, index),
  7582. key: '"' + val.slice(index + 1) + '"'
  7583. };
  7584. }
  7585. else {
  7586. return {
  7587. exp: val,
  7588. key: null
  7589. };
  7590. }
  7591. }
  7592. str = val;
  7593. index = expressionPos = expressionEndPos = 0;
  7594. while (!eof()) {
  7595. chr = next();
  7596. /* istanbul ignore if */
  7597. if (isStringStart(chr)) {
  7598. parseString(chr);
  7599. }
  7600. else if (chr === 0x5b) {
  7601. parseBracket(chr);
  7602. }
  7603. }
  7604. return {
  7605. exp: val.slice(0, expressionPos),
  7606. key: val.slice(expressionPos + 1, expressionEndPos)
  7607. };
  7608. }
  7609. function next() {
  7610. return str.charCodeAt(++index);
  7611. }
  7612. function eof() {
  7613. return index >= len;
  7614. }
  7615. function isStringStart(chr) {
  7616. return chr === 0x22 || chr === 0x27;
  7617. }
  7618. function parseBracket(chr) {
  7619. let inBracket = 1;
  7620. expressionPos = index;
  7621. while (!eof()) {
  7622. chr = next();
  7623. if (isStringStart(chr)) {
  7624. parseString(chr);
  7625. continue;
  7626. }
  7627. if (chr === 0x5b)
  7628. inBracket++;
  7629. if (chr === 0x5d)
  7630. inBracket--;
  7631. if (inBracket === 0) {
  7632. expressionEndPos = index;
  7633. break;
  7634. }
  7635. }
  7636. }
  7637. function parseString(chr) {
  7638. const stringQuote = chr;
  7639. while (!eof()) {
  7640. chr = next();
  7641. if (chr === stringQuote) {
  7642. break;
  7643. }
  7644. }
  7645. }
  7646. let warn$1;
  7647. // in some cases, the event used has to be determined at runtime
  7648. // so we used some reserved tokens during compile.
  7649. const RANGE_TOKEN = '__r';
  7650. const CHECKBOX_RADIO_TOKEN = '__c';
  7651. function model$1(el, dir, _warn) {
  7652. warn$1 = _warn;
  7653. const value = dir.value;
  7654. const modifiers = dir.modifiers;
  7655. const tag = el.tag;
  7656. const type = el.attrsMap.type;
  7657. {
  7658. // inputs with type="file" are read only and setting the input's
  7659. // value will throw an error.
  7660. if (tag === 'input' && type === 'file') {
  7661. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7662. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7663. }
  7664. }
  7665. if (el.component) {
  7666. genComponentModel(el, value, modifiers);
  7667. // component v-model doesn't need extra runtime
  7668. return false;
  7669. }
  7670. else if (tag === 'select') {
  7671. genSelect(el, value, modifiers);
  7672. }
  7673. else if (tag === 'input' && type === 'checkbox') {
  7674. genCheckboxModel(el, value, modifiers);
  7675. }
  7676. else if (tag === 'input' && type === 'radio') {
  7677. genRadioModel(el, value, modifiers);
  7678. }
  7679. else if (tag === 'input' || tag === 'textarea') {
  7680. genDefaultModel(el, value, modifiers);
  7681. }
  7682. else if (!config.isReservedTag(tag)) {
  7683. genComponentModel(el, value, modifiers);
  7684. // component v-model doesn't need extra runtime
  7685. return false;
  7686. }
  7687. else {
  7688. warn$1(`<${el.tag} v-model="${value}">: ` +
  7689. `v-model is not supported on this element type. ` +
  7690. "If you are working with contenteditable, it's recommended to " +
  7691. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7692. }
  7693. // ensure runtime directive metadata
  7694. return true;
  7695. }
  7696. function genCheckboxModel(el, value, modifiers) {
  7697. const number = modifiers && modifiers.number;
  7698. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7699. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7700. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7701. addProp(el, 'checked', `Array.isArray(${value})` +
  7702. `?_i(${value},${valueBinding})>-1` +
  7703. (trueValueBinding === 'true'
  7704. ? `:(${value})`
  7705. : `:_q(${value},${trueValueBinding})`));
  7706. addHandler(el, 'change', `var $$a=${value},` +
  7707. '$$el=$event.target,' +
  7708. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7709. 'if(Array.isArray($$a)){' +
  7710. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7711. '$$i=_i($$a,$$v);' +
  7712. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7713. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7714. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7715. }
  7716. function genRadioModel(el, value, modifiers) {
  7717. const number = modifiers && modifiers.number;
  7718. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7719. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7720. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7721. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7722. }
  7723. function genSelect(el, value, modifiers) {
  7724. const number = modifiers && modifiers.number;
  7725. const selectedVal = `Array.prototype.filter` +
  7726. `.call($event.target.options,function(o){return o.selected})` +
  7727. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7728. `return ${number ? '_n(val)' : 'val'}})`;
  7729. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7730. let code = `var $$selectedVal = ${selectedVal};`;
  7731. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7732. addHandler(el, 'change', code, null, true);
  7733. }
  7734. function genDefaultModel(el, value, modifiers) {
  7735. const type = el.attrsMap.type;
  7736. // warn if v-bind:value conflicts with v-model
  7737. // except for inputs with v-bind:type
  7738. {
  7739. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7740. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7741. if (value && !typeBinding) {
  7742. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7743. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7744. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7745. }
  7746. }
  7747. const { lazy, number, trim } = modifiers || {};
  7748. const needCompositionGuard = !lazy && type !== 'range';
  7749. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7750. let valueExpression = '$event.target.value';
  7751. if (trim) {
  7752. valueExpression = `$event.target.value.trim()`;
  7753. }
  7754. if (number) {
  7755. valueExpression = `_n(${valueExpression})`;
  7756. }
  7757. let code = genAssignmentCode(value, valueExpression);
  7758. if (needCompositionGuard) {
  7759. code = `if($event.target.composing)return;${code}`;
  7760. }
  7761. addProp(el, 'value', `(${value})`);
  7762. addHandler(el, event, code, null, true);
  7763. if (trim || number) {
  7764. addHandler(el, 'blur', '$forceUpdate()');
  7765. }
  7766. }
  7767. // normalize v-model event tokens that can only be determined at runtime.
  7768. // it's important to place the event as the first in the array because
  7769. // the whole point is ensuring the v-model callback gets called before
  7770. // user-attached handlers.
  7771. function normalizeEvents(on) {
  7772. /* istanbul ignore if */
  7773. if (isDef(on[RANGE_TOKEN])) {
  7774. // IE input[type=range] only supports `change` event
  7775. const event = isIE ? 'change' : 'input';
  7776. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7777. delete on[RANGE_TOKEN];
  7778. }
  7779. // This was originally intended to fix #4521 but no longer necessary
  7780. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7781. /* istanbul ignore if */
  7782. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7783. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7784. delete on[CHECKBOX_RADIO_TOKEN];
  7785. }
  7786. }
  7787. let target;
  7788. function createOnceHandler(event, handler, capture) {
  7789. const _target = target; // save current target element in closure
  7790. return function onceHandler() {
  7791. const res = handler.apply(null, arguments);
  7792. if (res !== null) {
  7793. remove(event, onceHandler, capture, _target);
  7794. }
  7795. };
  7796. }
  7797. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7798. // implementation and does not fire microtasks in between event propagation, so
  7799. // safe to exclude.
  7800. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7801. function add(name, handler, capture, passive) {
  7802. // async edge case #6566: inner click event triggers patch, event handler
  7803. // attached to outer element during patch, and triggered again. This
  7804. // happens because browsers fire microtask ticks between event propagation.
  7805. // the solution is simple: we save the timestamp when a handler is attached,
  7806. // and the handler would only fire if the event passed to it was fired
  7807. // AFTER it was attached.
  7808. if (useMicrotaskFix) {
  7809. const attachedTimestamp = currentFlushTimestamp;
  7810. const original = handler;
  7811. //@ts-expect-error
  7812. handler = original._wrapper = function (e) {
  7813. if (
  7814. // no bubbling, should always fire.
  7815. // this is just a safety net in case event.timeStamp is unreliable in
  7816. // certain weird environments...
  7817. e.target === e.currentTarget ||
  7818. // event is fired after handler attachment
  7819. e.timeStamp >= attachedTimestamp ||
  7820. // bail for environments that have buggy event.timeStamp implementations
  7821. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7822. // #9681 QtWebEngine event.timeStamp is negative value
  7823. e.timeStamp <= 0 ||
  7824. // #9448 bail if event is fired in another document in a multi-page
  7825. // electron/nw.js app, since event.timeStamp will be using a different
  7826. // starting reference
  7827. e.target.ownerDocument !== document) {
  7828. return original.apply(this, arguments);
  7829. }
  7830. };
  7831. }
  7832. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7833. }
  7834. function remove(name, handler, capture, _target) {
  7835. (_target || target).removeEventListener(name,
  7836. //@ts-expect-error
  7837. handler._wrapper || handler, capture);
  7838. }
  7839. function updateDOMListeners(oldVnode, vnode) {
  7840. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7841. return;
  7842. }
  7843. const on = vnode.data.on || {};
  7844. const oldOn = oldVnode.data.on || {};
  7845. // vnode is empty when removing all listeners,
  7846. // and use old vnode dom element
  7847. target = vnode.elm || oldVnode.elm;
  7848. normalizeEvents(on);
  7849. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7850. target = undefined;
  7851. }
  7852. var events = {
  7853. create: updateDOMListeners,
  7854. update: updateDOMListeners,
  7855. // @ts-expect-error emptyNode has actually data
  7856. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7857. };
  7858. let svgContainer;
  7859. function updateDOMProps(oldVnode, vnode) {
  7860. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7861. return;
  7862. }
  7863. let key, cur;
  7864. const elm = vnode.elm;
  7865. const oldProps = oldVnode.data.domProps || {};
  7866. let props = vnode.data.domProps || {};
  7867. // clone observed objects, as the user probably wants to mutate it
  7868. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7869. props = vnode.data.domProps = extend({}, props);
  7870. }
  7871. for (key in oldProps) {
  7872. if (!(key in props)) {
  7873. elm[key] = '';
  7874. }
  7875. }
  7876. for (key in props) {
  7877. cur = props[key];
  7878. // ignore children if the node has textContent or innerHTML,
  7879. // as these will throw away existing DOM nodes and cause removal errors
  7880. // on subsequent patches (#3360)
  7881. if (key === 'textContent' || key === 'innerHTML') {
  7882. if (vnode.children)
  7883. vnode.children.length = 0;
  7884. if (cur === oldProps[key])
  7885. continue;
  7886. // #6601 work around Chrome version <= 55 bug where single textNode
  7887. // replaced by innerHTML/textContent retains its parentNode property
  7888. if (elm.childNodes.length === 1) {
  7889. elm.removeChild(elm.childNodes[0]);
  7890. }
  7891. }
  7892. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7893. // store value as _value as well since
  7894. // non-string values will be stringified
  7895. elm._value = cur;
  7896. // avoid resetting cursor position when value is the same
  7897. const strCur = isUndef(cur) ? '' : String(cur);
  7898. if (shouldUpdateValue(elm, strCur)) {
  7899. elm.value = strCur;
  7900. }
  7901. }
  7902. else if (key === 'innerHTML' &&
  7903. isSVG(elm.tagName) &&
  7904. isUndef(elm.innerHTML)) {
  7905. // IE doesn't support innerHTML for SVG elements
  7906. svgContainer = svgContainer || document.createElement('div');
  7907. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7908. const svg = svgContainer.firstChild;
  7909. while (elm.firstChild) {
  7910. elm.removeChild(elm.firstChild);
  7911. }
  7912. while (svg.firstChild) {
  7913. elm.appendChild(svg.firstChild);
  7914. }
  7915. }
  7916. else if (
  7917. // skip the update if old and new VDOM state is the same.
  7918. // `value` is handled separately because the DOM value may be temporarily
  7919. // out of sync with VDOM state due to focus, composition and modifiers.
  7920. // This #4521 by skipping the unnecessary `checked` update.
  7921. cur !== oldProps[key]) {
  7922. // some property updates can throw
  7923. // e.g. `value` on <progress> w/ non-finite value
  7924. try {
  7925. elm[key] = cur;
  7926. }
  7927. catch (e) { }
  7928. }
  7929. }
  7930. }
  7931. function shouldUpdateValue(elm, checkVal) {
  7932. return (
  7933. //@ts-expect-error
  7934. !elm.composing &&
  7935. (elm.tagName === 'OPTION' ||
  7936. isNotInFocusAndDirty(elm, checkVal) ||
  7937. isDirtyWithModifiers(elm, checkVal)));
  7938. }
  7939. function isNotInFocusAndDirty(elm, checkVal) {
  7940. // return true when textbox (.number and .trim) loses focus and its value is
  7941. // not equal to the updated value
  7942. let notInFocus = true;
  7943. // #6157
  7944. // work around IE bug when accessing document.activeElement in an iframe
  7945. try {
  7946. notInFocus = document.activeElement !== elm;
  7947. }
  7948. catch (e) { }
  7949. return notInFocus && elm.value !== checkVal;
  7950. }
  7951. function isDirtyWithModifiers(elm, newVal) {
  7952. const value = elm.value;
  7953. const modifiers = elm._vModifiers; // injected by v-model runtime
  7954. if (isDef(modifiers)) {
  7955. if (modifiers.number) {
  7956. return toNumber(value) !== toNumber(newVal);
  7957. }
  7958. if (modifiers.trim) {
  7959. return value.trim() !== newVal.trim();
  7960. }
  7961. }
  7962. return value !== newVal;
  7963. }
  7964. var domProps = {
  7965. create: updateDOMProps,
  7966. update: updateDOMProps
  7967. };
  7968. const parseStyleText = cached(function (cssText) {
  7969. const res = {};
  7970. const listDelimiter = /;(?![^(]*\))/g;
  7971. const propertyDelimiter = /:(.+)/;
  7972. cssText.split(listDelimiter).forEach(function (item) {
  7973. if (item) {
  7974. const tmp = item.split(propertyDelimiter);
  7975. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7976. }
  7977. });
  7978. return res;
  7979. });
  7980. // merge static and dynamic style data on the same vnode
  7981. function normalizeStyleData(data) {
  7982. const style = normalizeStyleBinding(data.style);
  7983. // static style is pre-processed into an object during compilation
  7984. // and is always a fresh object, so it's safe to merge into it
  7985. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7986. }
  7987. // normalize possible array / string values into Object
  7988. function normalizeStyleBinding(bindingStyle) {
  7989. if (Array.isArray(bindingStyle)) {
  7990. return toObject(bindingStyle);
  7991. }
  7992. if (typeof bindingStyle === 'string') {
  7993. return parseStyleText(bindingStyle);
  7994. }
  7995. return bindingStyle;
  7996. }
  7997. /**
  7998. * parent component style should be after child's
  7999. * so that parent component's style could override it
  8000. */
  8001. function getStyle(vnode, checkChild) {
  8002. const res = {};
  8003. let styleData;
  8004. if (checkChild) {
  8005. let childNode = vnode;
  8006. while (childNode.componentInstance) {
  8007. childNode = childNode.componentInstance._vnode;
  8008. if (childNode &&
  8009. childNode.data &&
  8010. (styleData = normalizeStyleData(childNode.data))) {
  8011. extend(res, styleData);
  8012. }
  8013. }
  8014. }
  8015. if ((styleData = normalizeStyleData(vnode.data))) {
  8016. extend(res, styleData);
  8017. }
  8018. let parentNode = vnode;
  8019. // @ts-expect-error parentNode.parent not VNodeWithData
  8020. while ((parentNode = parentNode.parent)) {
  8021. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  8022. extend(res, styleData);
  8023. }
  8024. }
  8025. return res;
  8026. }
  8027. const cssVarRE = /^--/;
  8028. const importantRE = /\s*!important$/;
  8029. const setProp = (el, name, val) => {
  8030. /* istanbul ignore if */
  8031. if (cssVarRE.test(name)) {
  8032. el.style.setProperty(name, val);
  8033. }
  8034. else if (importantRE.test(val)) {
  8035. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8036. }
  8037. else {
  8038. const normalizedName = normalize(name);
  8039. if (Array.isArray(val)) {
  8040. // Support values array created by autoprefixer, e.g.
  8041. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8042. // Set them one by one, and the browser will only set those it can recognize
  8043. for (let i = 0, len = val.length; i < len; i++) {
  8044. el.style[normalizedName] = val[i];
  8045. }
  8046. }
  8047. else {
  8048. el.style[normalizedName] = val;
  8049. }
  8050. }
  8051. };
  8052. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8053. let emptyStyle;
  8054. const normalize = cached(function (prop) {
  8055. emptyStyle = emptyStyle || document.createElement('div').style;
  8056. prop = camelize(prop);
  8057. if (prop !== 'filter' && prop in emptyStyle) {
  8058. return prop;
  8059. }
  8060. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8061. for (let i = 0; i < vendorNames.length; i++) {
  8062. const name = vendorNames[i] + capName;
  8063. if (name in emptyStyle) {
  8064. return name;
  8065. }
  8066. }
  8067. });
  8068. function updateStyle(oldVnode, vnode) {
  8069. const data = vnode.data;
  8070. const oldData = oldVnode.data;
  8071. if (isUndef(data.staticStyle) &&
  8072. isUndef(data.style) &&
  8073. isUndef(oldData.staticStyle) &&
  8074. isUndef(oldData.style)) {
  8075. return;
  8076. }
  8077. let cur, name;
  8078. const el = vnode.elm;
  8079. const oldStaticStyle = oldData.staticStyle;
  8080. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8081. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8082. const oldStyle = oldStaticStyle || oldStyleBinding;
  8083. const style = normalizeStyleBinding(vnode.data.style) || {};
  8084. // store normalized style under a different key for next diff
  8085. // make sure to clone it if it's reactive, since the user likely wants
  8086. // to mutate it.
  8087. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8088. const newStyle = getStyle(vnode, true);
  8089. for (name in oldStyle) {
  8090. if (isUndef(newStyle[name])) {
  8091. setProp(el, name, '');
  8092. }
  8093. }
  8094. for (name in newStyle) {
  8095. cur = newStyle[name];
  8096. if (cur !== oldStyle[name]) {
  8097. // ie9 setting to null has no effect, must use empty string
  8098. setProp(el, name, cur == null ? '' : cur);
  8099. }
  8100. }
  8101. }
  8102. var style$1 = {
  8103. create: updateStyle,
  8104. update: updateStyle
  8105. };
  8106. const whitespaceRE$1 = /\s+/;
  8107. /**
  8108. * Add class with compatibility for SVG since classList is not supported on
  8109. * SVG elements in IE
  8110. */
  8111. function addClass(el, cls) {
  8112. /* istanbul ignore if */
  8113. if (!cls || !(cls = cls.trim())) {
  8114. return;
  8115. }
  8116. /* istanbul ignore else */
  8117. if (el.classList) {
  8118. if (cls.indexOf(' ') > -1) {
  8119. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8120. }
  8121. else {
  8122. el.classList.add(cls);
  8123. }
  8124. }
  8125. else {
  8126. const cur = ` ${el.getAttribute('class') || ''} `;
  8127. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8128. el.setAttribute('class', (cur + cls).trim());
  8129. }
  8130. }
  8131. }
  8132. /**
  8133. * Remove class with compatibility for SVG since classList is not supported on
  8134. * SVG elements in IE
  8135. */
  8136. function removeClass(el, cls) {
  8137. /* istanbul ignore if */
  8138. if (!cls || !(cls = cls.trim())) {
  8139. return;
  8140. }
  8141. /* istanbul ignore else */
  8142. if (el.classList) {
  8143. if (cls.indexOf(' ') > -1) {
  8144. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8145. }
  8146. else {
  8147. el.classList.remove(cls);
  8148. }
  8149. if (!el.classList.length) {
  8150. el.removeAttribute('class');
  8151. }
  8152. }
  8153. else {
  8154. let cur = ` ${el.getAttribute('class') || ''} `;
  8155. const tar = ' ' + cls + ' ';
  8156. while (cur.indexOf(tar) >= 0) {
  8157. cur = cur.replace(tar, ' ');
  8158. }
  8159. cur = cur.trim();
  8160. if (cur) {
  8161. el.setAttribute('class', cur);
  8162. }
  8163. else {
  8164. el.removeAttribute('class');
  8165. }
  8166. }
  8167. }
  8168. function resolveTransition(def) {
  8169. if (!def) {
  8170. return;
  8171. }
  8172. /* istanbul ignore else */
  8173. if (typeof def === 'object') {
  8174. const res = {};
  8175. if (def.css !== false) {
  8176. extend(res, autoCssTransition(def.name || 'v'));
  8177. }
  8178. extend(res, def);
  8179. return res;
  8180. }
  8181. else if (typeof def === 'string') {
  8182. return autoCssTransition(def);
  8183. }
  8184. }
  8185. const autoCssTransition = cached(name => {
  8186. return {
  8187. enterClass: `${name}-enter`,
  8188. enterToClass: `${name}-enter-to`,
  8189. enterActiveClass: `${name}-enter-active`,
  8190. leaveClass: `${name}-leave`,
  8191. leaveToClass: `${name}-leave-to`,
  8192. leaveActiveClass: `${name}-leave-active`
  8193. };
  8194. });
  8195. const hasTransition = inBrowser && !isIE9;
  8196. const TRANSITION = 'transition';
  8197. const ANIMATION = 'animation';
  8198. // Transition property/event sniffing
  8199. let transitionProp = 'transition';
  8200. let transitionEndEvent = 'transitionend';
  8201. let animationProp = 'animation';
  8202. let animationEndEvent = 'animationend';
  8203. if (hasTransition) {
  8204. /* istanbul ignore if */
  8205. if (window.ontransitionend === undefined &&
  8206. window.onwebkittransitionend !== undefined) {
  8207. transitionProp = 'WebkitTransition';
  8208. transitionEndEvent = 'webkitTransitionEnd';
  8209. }
  8210. if (window.onanimationend === undefined &&
  8211. window.onwebkitanimationend !== undefined) {
  8212. animationProp = 'WebkitAnimation';
  8213. animationEndEvent = 'webkitAnimationEnd';
  8214. }
  8215. }
  8216. // binding to window is necessary to make hot reload work in IE in strict mode
  8217. const raf = inBrowser
  8218. ? window.requestAnimationFrame
  8219. ? window.requestAnimationFrame.bind(window)
  8220. : setTimeout
  8221. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8222. function nextFrame(fn) {
  8223. raf(() => {
  8224. // @ts-expect-error
  8225. raf(fn);
  8226. });
  8227. }
  8228. function addTransitionClass(el, cls) {
  8229. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8230. if (transitionClasses.indexOf(cls) < 0) {
  8231. transitionClasses.push(cls);
  8232. addClass(el, cls);
  8233. }
  8234. }
  8235. function removeTransitionClass(el, cls) {
  8236. if (el._transitionClasses) {
  8237. remove$2(el._transitionClasses, cls);
  8238. }
  8239. removeClass(el, cls);
  8240. }
  8241. function whenTransitionEnds(el, expectedType, cb) {
  8242. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8243. if (!type)
  8244. return cb();
  8245. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8246. let ended = 0;
  8247. const end = () => {
  8248. el.removeEventListener(event, onEnd);
  8249. cb();
  8250. };
  8251. const onEnd = e => {
  8252. if (e.target === el) {
  8253. if (++ended >= propCount) {
  8254. end();
  8255. }
  8256. }
  8257. };
  8258. setTimeout(() => {
  8259. if (ended < propCount) {
  8260. end();
  8261. }
  8262. }, timeout + 1);
  8263. el.addEventListener(event, onEnd);
  8264. }
  8265. const transformRE = /\b(transform|all)(,|$)/;
  8266. function getTransitionInfo(el, expectedType) {
  8267. const styles = window.getComputedStyle(el);
  8268. // JSDOM may return undefined for transition properties
  8269. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8270. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8271. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8272. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8273. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8274. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8275. let type;
  8276. let timeout = 0;
  8277. let propCount = 0;
  8278. /* istanbul ignore if */
  8279. if (expectedType === TRANSITION) {
  8280. if (transitionTimeout > 0) {
  8281. type = TRANSITION;
  8282. timeout = transitionTimeout;
  8283. propCount = transitionDurations.length;
  8284. }
  8285. }
  8286. else if (expectedType === ANIMATION) {
  8287. if (animationTimeout > 0) {
  8288. type = ANIMATION;
  8289. timeout = animationTimeout;
  8290. propCount = animationDurations.length;
  8291. }
  8292. }
  8293. else {
  8294. timeout = Math.max(transitionTimeout, animationTimeout);
  8295. type =
  8296. timeout > 0
  8297. ? transitionTimeout > animationTimeout
  8298. ? TRANSITION
  8299. : ANIMATION
  8300. : null;
  8301. propCount = type
  8302. ? type === TRANSITION
  8303. ? transitionDurations.length
  8304. : animationDurations.length
  8305. : 0;
  8306. }
  8307. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8308. return {
  8309. type,
  8310. timeout,
  8311. propCount,
  8312. hasTransform
  8313. };
  8314. }
  8315. function getTimeout(delays, durations) {
  8316. /* istanbul ignore next */
  8317. while (delays.length < durations.length) {
  8318. delays = delays.concat(delays);
  8319. }
  8320. return Math.max.apply(null, durations.map((d, i) => {
  8321. return toMs(d) + toMs(delays[i]);
  8322. }));
  8323. }
  8324. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8325. // in a locale-dependent way, using a comma instead of a dot.
  8326. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8327. // as a floor function) causing unexpected behaviors
  8328. function toMs(s) {
  8329. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8330. }
  8331. function enter(vnode, toggleDisplay) {
  8332. const el = vnode.elm;
  8333. // call leave callback now
  8334. if (isDef(el._leaveCb)) {
  8335. el._leaveCb.cancelled = true;
  8336. el._leaveCb();
  8337. }
  8338. const data = resolveTransition(vnode.data.transition);
  8339. if (isUndef(data)) {
  8340. return;
  8341. }
  8342. /* istanbul ignore if */
  8343. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8344. return;
  8345. }
  8346. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8347. // activeInstance will always be the <transition> component managing this
  8348. // transition. One edge case to check is when the <transition> is placed
  8349. // as the root node of a child component. In that case we need to check
  8350. // <transition>'s parent for appear check.
  8351. let context = activeInstance;
  8352. let transitionNode = activeInstance.$vnode;
  8353. while (transitionNode && transitionNode.parent) {
  8354. context = transitionNode.context;
  8355. transitionNode = transitionNode.parent;
  8356. }
  8357. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8358. if (isAppear && !appear && appear !== '') {
  8359. return;
  8360. }
  8361. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8362. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8363. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8364. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8365. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8366. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8367. const enterCancelledHook = isAppear
  8368. ? appearCancelled || enterCancelled
  8369. : enterCancelled;
  8370. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8371. if (explicitEnterDuration != null) {
  8372. checkDuration(explicitEnterDuration, 'enter', vnode);
  8373. }
  8374. const expectsCSS = css !== false && !isIE9;
  8375. const userWantsControl = getHookArgumentsLength(enterHook);
  8376. const cb = (el._enterCb = once(() => {
  8377. if (expectsCSS) {
  8378. removeTransitionClass(el, toClass);
  8379. removeTransitionClass(el, activeClass);
  8380. }
  8381. // @ts-expect-error
  8382. if (cb.cancelled) {
  8383. if (expectsCSS) {
  8384. removeTransitionClass(el, startClass);
  8385. }
  8386. enterCancelledHook && enterCancelledHook(el);
  8387. }
  8388. else {
  8389. afterEnterHook && afterEnterHook(el);
  8390. }
  8391. el._enterCb = null;
  8392. }));
  8393. if (!vnode.data.show) {
  8394. // remove pending leave element on enter by injecting an insert hook
  8395. mergeVNodeHook(vnode, 'insert', () => {
  8396. const parent = el.parentNode;
  8397. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8398. if (pendingNode &&
  8399. pendingNode.tag === vnode.tag &&
  8400. pendingNode.elm._leaveCb) {
  8401. pendingNode.elm._leaveCb();
  8402. }
  8403. enterHook && enterHook(el, cb);
  8404. });
  8405. }
  8406. // start enter transition
  8407. beforeEnterHook && beforeEnterHook(el);
  8408. if (expectsCSS) {
  8409. addTransitionClass(el, startClass);
  8410. addTransitionClass(el, activeClass);
  8411. nextFrame(() => {
  8412. removeTransitionClass(el, startClass);
  8413. // @ts-expect-error
  8414. if (!cb.cancelled) {
  8415. addTransitionClass(el, toClass);
  8416. if (!userWantsControl) {
  8417. if (isValidDuration(explicitEnterDuration)) {
  8418. setTimeout(cb, explicitEnterDuration);
  8419. }
  8420. else {
  8421. whenTransitionEnds(el, type, cb);
  8422. }
  8423. }
  8424. }
  8425. });
  8426. }
  8427. if (vnode.data.show) {
  8428. toggleDisplay && toggleDisplay();
  8429. enterHook && enterHook(el, cb);
  8430. }
  8431. if (!expectsCSS && !userWantsControl) {
  8432. cb();
  8433. }
  8434. }
  8435. function leave(vnode, rm) {
  8436. const el = vnode.elm;
  8437. // call enter callback now
  8438. if (isDef(el._enterCb)) {
  8439. el._enterCb.cancelled = true;
  8440. el._enterCb();
  8441. }
  8442. const data = resolveTransition(vnode.data.transition);
  8443. if (isUndef(data) || el.nodeType !== 1) {
  8444. return rm();
  8445. }
  8446. /* istanbul ignore if */
  8447. if (isDef(el._leaveCb)) {
  8448. return;
  8449. }
  8450. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8451. const expectsCSS = css !== false && !isIE9;
  8452. const userWantsControl = getHookArgumentsLength(leave);
  8453. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8454. if (isDef(explicitLeaveDuration)) {
  8455. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8456. }
  8457. const cb = (el._leaveCb = once(() => {
  8458. if (el.parentNode && el.parentNode._pending) {
  8459. el.parentNode._pending[vnode.key] = null;
  8460. }
  8461. if (expectsCSS) {
  8462. removeTransitionClass(el, leaveToClass);
  8463. removeTransitionClass(el, leaveActiveClass);
  8464. }
  8465. // @ts-expect-error
  8466. if (cb.cancelled) {
  8467. if (expectsCSS) {
  8468. removeTransitionClass(el, leaveClass);
  8469. }
  8470. leaveCancelled && leaveCancelled(el);
  8471. }
  8472. else {
  8473. rm();
  8474. afterLeave && afterLeave(el);
  8475. }
  8476. el._leaveCb = null;
  8477. }));
  8478. if (delayLeave) {
  8479. delayLeave(performLeave);
  8480. }
  8481. else {
  8482. performLeave();
  8483. }
  8484. function performLeave() {
  8485. // the delayed leave may have already been cancelled
  8486. // @ts-expect-error
  8487. if (cb.cancelled) {
  8488. return;
  8489. }
  8490. // record leaving element
  8491. if (!vnode.data.show && el.parentNode) {
  8492. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8493. vnode;
  8494. }
  8495. beforeLeave && beforeLeave(el);
  8496. if (expectsCSS) {
  8497. addTransitionClass(el, leaveClass);
  8498. addTransitionClass(el, leaveActiveClass);
  8499. nextFrame(() => {
  8500. removeTransitionClass(el, leaveClass);
  8501. // @ts-expect-error
  8502. if (!cb.cancelled) {
  8503. addTransitionClass(el, leaveToClass);
  8504. if (!userWantsControl) {
  8505. if (isValidDuration(explicitLeaveDuration)) {
  8506. setTimeout(cb, explicitLeaveDuration);
  8507. }
  8508. else {
  8509. whenTransitionEnds(el, type, cb);
  8510. }
  8511. }
  8512. }
  8513. });
  8514. }
  8515. leave && leave(el, cb);
  8516. if (!expectsCSS && !userWantsControl) {
  8517. cb();
  8518. }
  8519. }
  8520. }
  8521. // only used in dev mode
  8522. function checkDuration(val, name, vnode) {
  8523. if (typeof val !== 'number') {
  8524. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8525. `got ${JSON.stringify(val)}.`, vnode.context);
  8526. }
  8527. else if (isNaN(val)) {
  8528. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8529. 'the duration expression might be incorrect.', vnode.context);
  8530. }
  8531. }
  8532. function isValidDuration(val) {
  8533. return typeof val === 'number' && !isNaN(val);
  8534. }
  8535. /**
  8536. * Normalize a transition hook's argument length. The hook may be:
  8537. * - a merged hook (invoker) with the original in .fns
  8538. * - a wrapped component method (check ._length)
  8539. * - a plain function (.length)
  8540. */
  8541. function getHookArgumentsLength(fn) {
  8542. if (isUndef(fn)) {
  8543. return false;
  8544. }
  8545. // @ts-expect-error
  8546. const invokerFns = fn.fns;
  8547. if (isDef(invokerFns)) {
  8548. // invoker
  8549. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8550. }
  8551. else {
  8552. // @ts-expect-error
  8553. return (fn._length || fn.length) > 1;
  8554. }
  8555. }
  8556. function _enter(_, vnode) {
  8557. if (vnode.data.show !== true) {
  8558. enter(vnode);
  8559. }
  8560. }
  8561. var transition = inBrowser
  8562. ? {
  8563. create: _enter,
  8564. activate: _enter,
  8565. remove(vnode, rm) {
  8566. /* istanbul ignore else */
  8567. if (vnode.data.show !== true) {
  8568. // @ts-expect-error
  8569. leave(vnode, rm);
  8570. }
  8571. else {
  8572. rm();
  8573. }
  8574. }
  8575. }
  8576. : {};
  8577. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8578. // the directive module should be applied last, after all
  8579. // built-in modules have been applied.
  8580. const modules$1 = platformModules.concat(baseModules);
  8581. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8582. /**
  8583. * Not type checking this file because flow doesn't like attaching
  8584. * properties to Elements.
  8585. */
  8586. /* istanbul ignore if */
  8587. if (isIE9) {
  8588. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8589. document.addEventListener('selectionchange', () => {
  8590. const el = document.activeElement;
  8591. // @ts-expect-error
  8592. if (el && el.vmodel) {
  8593. trigger(el, 'input');
  8594. }
  8595. });
  8596. }
  8597. const directive = {
  8598. inserted(el, binding, vnode, oldVnode) {
  8599. if (vnode.tag === 'select') {
  8600. // #6903
  8601. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8602. mergeVNodeHook(vnode, 'postpatch', () => {
  8603. directive.componentUpdated(el, binding, vnode);
  8604. });
  8605. }
  8606. else {
  8607. setSelected(el, binding, vnode.context);
  8608. }
  8609. el._vOptions = [].map.call(el.options, getValue);
  8610. }
  8611. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8612. el._vModifiers = binding.modifiers;
  8613. if (!binding.modifiers.lazy) {
  8614. el.addEventListener('compositionstart', onCompositionStart);
  8615. el.addEventListener('compositionend', onCompositionEnd);
  8616. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8617. // switching focus before confirming composition choice
  8618. // this also fixes the issue where some browsers e.g. iOS Chrome
  8619. // fires "change" instead of "input" on autocomplete.
  8620. el.addEventListener('change', onCompositionEnd);
  8621. /* istanbul ignore if */
  8622. if (isIE9) {
  8623. el.vmodel = true;
  8624. }
  8625. }
  8626. }
  8627. },
  8628. componentUpdated(el, binding, vnode) {
  8629. if (vnode.tag === 'select') {
  8630. setSelected(el, binding, vnode.context);
  8631. // in case the options rendered by v-for have changed,
  8632. // it's possible that the value is out-of-sync with the rendered options.
  8633. // detect such cases and filter out values that no longer has a matching
  8634. // option in the DOM.
  8635. const prevOptions = el._vOptions;
  8636. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8637. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8638. // trigger change event if
  8639. // no matching option found for at least one value
  8640. const needReset = el.multiple
  8641. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8642. : binding.value !== binding.oldValue &&
  8643. hasNoMatchingOption(binding.value, curOptions);
  8644. if (needReset) {
  8645. trigger(el, 'change');
  8646. }
  8647. }
  8648. }
  8649. }
  8650. };
  8651. function setSelected(el, binding, vm) {
  8652. actuallySetSelected(el, binding, vm);
  8653. /* istanbul ignore if */
  8654. if (isIE || isEdge) {
  8655. setTimeout(() => {
  8656. actuallySetSelected(el, binding, vm);
  8657. }, 0);
  8658. }
  8659. }
  8660. function actuallySetSelected(el, binding, vm) {
  8661. const value = binding.value;
  8662. const isMultiple = el.multiple;
  8663. if (isMultiple && !Array.isArray(value)) {
  8664. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8665. `expects an Array value for its binding, but got ${Object.prototype.toString
  8666. .call(value)
  8667. .slice(8, -1)}`, vm);
  8668. return;
  8669. }
  8670. let selected, option;
  8671. for (let i = 0, l = el.options.length; i < l; i++) {
  8672. option = el.options[i];
  8673. if (isMultiple) {
  8674. selected = looseIndexOf(value, getValue(option)) > -1;
  8675. if (option.selected !== selected) {
  8676. option.selected = selected;
  8677. }
  8678. }
  8679. else {
  8680. if (looseEqual(getValue(option), value)) {
  8681. if (el.selectedIndex !== i) {
  8682. el.selectedIndex = i;
  8683. }
  8684. return;
  8685. }
  8686. }
  8687. }
  8688. if (!isMultiple) {
  8689. el.selectedIndex = -1;
  8690. }
  8691. }
  8692. function hasNoMatchingOption(value, options) {
  8693. return options.every(o => !looseEqual(o, value));
  8694. }
  8695. function getValue(option) {
  8696. return '_value' in option ? option._value : option.value;
  8697. }
  8698. function onCompositionStart(e) {
  8699. e.target.composing = true;
  8700. }
  8701. function onCompositionEnd(e) {
  8702. // prevent triggering an input event for no reason
  8703. if (!e.target.composing)
  8704. return;
  8705. e.target.composing = false;
  8706. trigger(e.target, 'input');
  8707. }
  8708. function trigger(el, type) {
  8709. const e = document.createEvent('HTMLEvents');
  8710. e.initEvent(type, true, true);
  8711. el.dispatchEvent(e);
  8712. }
  8713. // recursively search for possible transition defined inside the component root
  8714. function locateNode(vnode) {
  8715. // @ts-expect-error
  8716. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8717. ? locateNode(vnode.componentInstance._vnode)
  8718. : vnode;
  8719. }
  8720. var show = {
  8721. bind(el, { value }, vnode) {
  8722. vnode = locateNode(vnode);
  8723. const transition = vnode.data && vnode.data.transition;
  8724. const originalDisplay = (el.__vOriginalDisplay =
  8725. el.style.display === 'none' ? '' : el.style.display);
  8726. if (value && transition) {
  8727. vnode.data.show = true;
  8728. enter(vnode, () => {
  8729. el.style.display = originalDisplay;
  8730. });
  8731. }
  8732. else {
  8733. el.style.display = value ? originalDisplay : 'none';
  8734. }
  8735. },
  8736. update(el, { value, oldValue }, vnode) {
  8737. /* istanbul ignore if */
  8738. if (!value === !oldValue)
  8739. return;
  8740. vnode = locateNode(vnode);
  8741. const transition = vnode.data && vnode.data.transition;
  8742. if (transition) {
  8743. vnode.data.show = true;
  8744. if (value) {
  8745. enter(vnode, () => {
  8746. el.style.display = el.__vOriginalDisplay;
  8747. });
  8748. }
  8749. else {
  8750. leave(vnode, () => {
  8751. el.style.display = 'none';
  8752. });
  8753. }
  8754. }
  8755. else {
  8756. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8757. }
  8758. },
  8759. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8760. if (!isDestroy) {
  8761. el.style.display = el.__vOriginalDisplay;
  8762. }
  8763. }
  8764. };
  8765. var platformDirectives = {
  8766. model: directive,
  8767. show
  8768. };
  8769. // Provides transition support for a single element/component.
  8770. const transitionProps = {
  8771. name: String,
  8772. appear: Boolean,
  8773. css: Boolean,
  8774. mode: String,
  8775. type: String,
  8776. enterClass: String,
  8777. leaveClass: String,
  8778. enterToClass: String,
  8779. leaveToClass: String,
  8780. enterActiveClass: String,
  8781. leaveActiveClass: String,
  8782. appearClass: String,
  8783. appearActiveClass: String,
  8784. appearToClass: String,
  8785. duration: [Number, String, Object]
  8786. };
  8787. // in case the child is also an abstract component, e.g. <keep-alive>
  8788. // we want to recursively retrieve the real component to be rendered
  8789. function getRealChild(vnode) {
  8790. const compOptions = vnode && vnode.componentOptions;
  8791. if (compOptions && compOptions.Ctor.options.abstract) {
  8792. return getRealChild(getFirstComponentChild(compOptions.children));
  8793. }
  8794. else {
  8795. return vnode;
  8796. }
  8797. }
  8798. function extractTransitionData(comp) {
  8799. const data = {};
  8800. const options = comp.$options;
  8801. // props
  8802. for (const key in options.propsData) {
  8803. data[key] = comp[key];
  8804. }
  8805. // events.
  8806. // extract listeners and pass them directly to the transition methods
  8807. const listeners = options._parentListeners;
  8808. for (const key in listeners) {
  8809. data[camelize(key)] = listeners[key];
  8810. }
  8811. return data;
  8812. }
  8813. function placeholder(h, rawChild) {
  8814. // @ts-expect-error
  8815. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8816. return h('keep-alive', {
  8817. props: rawChild.componentOptions.propsData
  8818. });
  8819. }
  8820. }
  8821. function hasParentTransition(vnode) {
  8822. while ((vnode = vnode.parent)) {
  8823. if (vnode.data.transition) {
  8824. return true;
  8825. }
  8826. }
  8827. }
  8828. function isSameChild(child, oldChild) {
  8829. return oldChild.key === child.key && oldChild.tag === child.tag;
  8830. }
  8831. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8832. const isVShowDirective = d => d.name === 'show';
  8833. var Transition = {
  8834. name: 'transition',
  8835. props: transitionProps,
  8836. abstract: true,
  8837. render(h) {
  8838. let children = this.$slots.default;
  8839. if (!children) {
  8840. return;
  8841. }
  8842. // filter out text nodes (possible whitespaces)
  8843. children = children.filter(isNotTextNode);
  8844. /* istanbul ignore if */
  8845. if (!children.length) {
  8846. return;
  8847. }
  8848. // warn multiple elements
  8849. if (children.length > 1) {
  8850. warn$2('<transition> can only be used on a single element. Use ' +
  8851. '<transition-group> for lists.', this.$parent);
  8852. }
  8853. const mode = this.mode;
  8854. // warn invalid mode
  8855. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8856. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8857. }
  8858. const rawChild = children[0];
  8859. // if this is a component root node and the component's
  8860. // parent container node also has transition, skip.
  8861. if (hasParentTransition(this.$vnode)) {
  8862. return rawChild;
  8863. }
  8864. // apply transition data to child
  8865. // use getRealChild() to ignore abstract components e.g. keep-alive
  8866. const child = getRealChild(rawChild);
  8867. /* istanbul ignore if */
  8868. if (!child) {
  8869. return rawChild;
  8870. }
  8871. if (this._leaving) {
  8872. return placeholder(h, rawChild);
  8873. }
  8874. // ensure a key that is unique to the vnode type and to this transition
  8875. // component instance. This key will be used to remove pending leaving nodes
  8876. // during entering.
  8877. const id = `__transition-${this._uid}-`;
  8878. child.key =
  8879. child.key == null
  8880. ? child.isComment
  8881. ? id + 'comment'
  8882. : id + child.tag
  8883. : isPrimitive(child.key)
  8884. ? String(child.key).indexOf(id) === 0
  8885. ? child.key
  8886. : id + child.key
  8887. : child.key;
  8888. const data = ((child.data || (child.data = {})).transition =
  8889. extractTransitionData(this));
  8890. const oldRawChild = this._vnode;
  8891. const oldChild = getRealChild(oldRawChild);
  8892. // mark v-show
  8893. // so that the transition module can hand over the control to the directive
  8894. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8895. child.data.show = true;
  8896. }
  8897. if (oldChild &&
  8898. oldChild.data &&
  8899. !isSameChild(child, oldChild) &&
  8900. !isAsyncPlaceholder(oldChild) &&
  8901. // #6687 component root is a comment node
  8902. !(oldChild.componentInstance &&
  8903. oldChild.componentInstance._vnode.isComment)) {
  8904. // replace old child transition data with fresh one
  8905. // important for dynamic transitions!
  8906. const oldData = (oldChild.data.transition = extend({}, data));
  8907. // handle transition mode
  8908. if (mode === 'out-in') {
  8909. // return placeholder node and queue update when leave finishes
  8910. this._leaving = true;
  8911. mergeVNodeHook(oldData, 'afterLeave', () => {
  8912. this._leaving = false;
  8913. this.$forceUpdate();
  8914. });
  8915. return placeholder(h, rawChild);
  8916. }
  8917. else if (mode === 'in-out') {
  8918. if (isAsyncPlaceholder(child)) {
  8919. return oldRawChild;
  8920. }
  8921. let delayedLeave;
  8922. const performLeave = () => {
  8923. delayedLeave();
  8924. };
  8925. mergeVNodeHook(data, 'afterEnter', performLeave);
  8926. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8927. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8928. delayedLeave = leave;
  8929. });
  8930. }
  8931. }
  8932. return rawChild;
  8933. }
  8934. };
  8935. // Provides transition support for list items.
  8936. const props = extend({
  8937. tag: String,
  8938. moveClass: String
  8939. }, transitionProps);
  8940. delete props.mode;
  8941. var TransitionGroup = {
  8942. props,
  8943. beforeMount() {
  8944. const update = this._update;
  8945. this._update = (vnode, hydrating) => {
  8946. const restoreActiveInstance = setActiveInstance(this);
  8947. // force removing pass
  8948. this.__patch__(this._vnode, this.kept, false, // hydrating
  8949. true // removeOnly (!important, avoids unnecessary moves)
  8950. );
  8951. this._vnode = this.kept;
  8952. restoreActiveInstance();
  8953. update.call(this, vnode, hydrating);
  8954. };
  8955. },
  8956. render(h) {
  8957. const tag = this.tag || this.$vnode.data.tag || 'span';
  8958. const map = Object.create(null);
  8959. const prevChildren = (this.prevChildren = this.children);
  8960. const rawChildren = this.$slots.default || [];
  8961. const children = (this.children = []);
  8962. const transitionData = extractTransitionData(this);
  8963. for (let i = 0; i < rawChildren.length; i++) {
  8964. const c = rawChildren[i];
  8965. if (c.tag) {
  8966. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8967. children.push(c);
  8968. map[c.key] = c;
  8969. (c.data || (c.data = {})).transition = transitionData;
  8970. }
  8971. else {
  8972. const opts = c.componentOptions;
  8973. const name = opts
  8974. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8975. : c.tag;
  8976. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8977. }
  8978. }
  8979. }
  8980. if (prevChildren) {
  8981. const kept = [];
  8982. const removed = [];
  8983. for (let i = 0; i < prevChildren.length; i++) {
  8984. const c = prevChildren[i];
  8985. c.data.transition = transitionData;
  8986. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8987. c.data.pos = c.elm.getBoundingClientRect();
  8988. if (map[c.key]) {
  8989. kept.push(c);
  8990. }
  8991. else {
  8992. removed.push(c);
  8993. }
  8994. }
  8995. this.kept = h(tag, null, kept);
  8996. this.removed = removed;
  8997. }
  8998. return h(tag, null, children);
  8999. },
  9000. updated() {
  9001. const children = this.prevChildren;
  9002. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  9003. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  9004. return;
  9005. }
  9006. // we divide the work into three loops to avoid mixing DOM reads and writes
  9007. // in each iteration - which helps prevent layout thrashing.
  9008. children.forEach(callPendingCbs);
  9009. children.forEach(recordPosition);
  9010. children.forEach(applyTranslation);
  9011. // force reflow to put everything in position
  9012. // assign to this to avoid being removed in tree-shaking
  9013. // $flow-disable-line
  9014. this._reflow = document.body.offsetHeight;
  9015. children.forEach((c) => {
  9016. if (c.data.moved) {
  9017. const el = c.elm;
  9018. const s = el.style;
  9019. addTransitionClass(el, moveClass);
  9020. s.transform = s.WebkitTransform = s.transitionDuration = '';
  9021. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  9022. if (e && e.target !== el) {
  9023. return;
  9024. }
  9025. if (!e || /transform$/.test(e.propertyName)) {
  9026. el.removeEventListener(transitionEndEvent, cb);
  9027. el._moveCb = null;
  9028. removeTransitionClass(el, moveClass);
  9029. }
  9030. }));
  9031. }
  9032. });
  9033. },
  9034. methods: {
  9035. hasMove(el, moveClass) {
  9036. /* istanbul ignore if */
  9037. if (!hasTransition) {
  9038. return false;
  9039. }
  9040. /* istanbul ignore if */
  9041. if (this._hasMove) {
  9042. return this._hasMove;
  9043. }
  9044. // Detect whether an element with the move class applied has
  9045. // CSS transitions. Since the element may be inside an entering
  9046. // transition at this very moment, we make a clone of it and remove
  9047. // all other transition classes applied to ensure only the move class
  9048. // is applied.
  9049. const clone = el.cloneNode();
  9050. if (el._transitionClasses) {
  9051. el._transitionClasses.forEach((cls) => {
  9052. removeClass(clone, cls);
  9053. });
  9054. }
  9055. addClass(clone, moveClass);
  9056. clone.style.display = 'none';
  9057. this.$el.appendChild(clone);
  9058. const info = getTransitionInfo(clone);
  9059. this.$el.removeChild(clone);
  9060. return (this._hasMove = info.hasTransform);
  9061. }
  9062. }
  9063. };
  9064. function callPendingCbs(c) {
  9065. /* istanbul ignore if */
  9066. if (c.elm._moveCb) {
  9067. c.elm._moveCb();
  9068. }
  9069. /* istanbul ignore if */
  9070. if (c.elm._enterCb) {
  9071. c.elm._enterCb();
  9072. }
  9073. }
  9074. function recordPosition(c) {
  9075. c.data.newPos = c.elm.getBoundingClientRect();
  9076. }
  9077. function applyTranslation(c) {
  9078. const oldPos = c.data.pos;
  9079. const newPos = c.data.newPos;
  9080. const dx = oldPos.left - newPos.left;
  9081. const dy = oldPos.top - newPos.top;
  9082. if (dx || dy) {
  9083. c.data.moved = true;
  9084. const s = c.elm.style;
  9085. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9086. s.transitionDuration = '0s';
  9087. }
  9088. }
  9089. var platformComponents = {
  9090. Transition,
  9091. TransitionGroup
  9092. };
  9093. // install platform specific utils
  9094. Vue.config.mustUseProp = mustUseProp;
  9095. Vue.config.isReservedTag = isReservedTag;
  9096. Vue.config.isReservedAttr = isReservedAttr;
  9097. Vue.config.getTagNamespace = getTagNamespace;
  9098. Vue.config.isUnknownElement = isUnknownElement;
  9099. // install platform runtime directives & components
  9100. extend(Vue.options.directives, platformDirectives);
  9101. extend(Vue.options.components, platformComponents);
  9102. // install platform patch function
  9103. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9104. // public mount method
  9105. Vue.prototype.$mount = function (el, hydrating) {
  9106. el = el && inBrowser ? query(el) : undefined;
  9107. return mountComponent(this, el, hydrating);
  9108. };
  9109. // devtools global hook
  9110. /* istanbul ignore next */
  9111. if (inBrowser) {
  9112. setTimeout(() => {
  9113. if (config.devtools) {
  9114. if (devtools) {
  9115. devtools.emit('init', Vue);
  9116. }
  9117. else {
  9118. // @ts-expect-error
  9119. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9120. 'https://github.com/vuejs/vue-devtools');
  9121. }
  9122. }
  9123. if (config.productionTip !== false &&
  9124. typeof console !== 'undefined') {
  9125. // @ts-expect-error
  9126. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9127. `Make sure to turn on production mode when deploying for production.\n` +
  9128. `See more tips at https://vuejs.org/guide/deployment.html`);
  9129. }
  9130. }, 0);
  9131. }
  9132. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9133. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9134. const buildRegex = cached(delimiters => {
  9135. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9136. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9137. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9138. });
  9139. function parseText(text, delimiters) {
  9140. //@ts-expect-error
  9141. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9142. if (!tagRE.test(text)) {
  9143. return;
  9144. }
  9145. const tokens = [];
  9146. const rawTokens = [];
  9147. let lastIndex = (tagRE.lastIndex = 0);
  9148. let match, index, tokenValue;
  9149. while ((match = tagRE.exec(text))) {
  9150. index = match.index;
  9151. // push text token
  9152. if (index > lastIndex) {
  9153. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9154. tokens.push(JSON.stringify(tokenValue));
  9155. }
  9156. // tag token
  9157. const exp = parseFilters(match[1].trim());
  9158. tokens.push(`_s(${exp})`);
  9159. rawTokens.push({ '@binding': exp });
  9160. lastIndex = index + match[0].length;
  9161. }
  9162. if (lastIndex < text.length) {
  9163. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9164. tokens.push(JSON.stringify(tokenValue));
  9165. }
  9166. return {
  9167. expression: tokens.join('+'),
  9168. tokens: rawTokens
  9169. };
  9170. }
  9171. function transformNode$1(el, options) {
  9172. const warn = options.warn || baseWarn;
  9173. const staticClass = getAndRemoveAttr(el, 'class');
  9174. if (staticClass) {
  9175. const res = parseText(staticClass, options.delimiters);
  9176. if (res) {
  9177. warn(`class="${staticClass}": ` +
  9178. 'Interpolation inside attributes has been removed. ' +
  9179. 'Use v-bind or the colon shorthand instead. For example, ' +
  9180. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9181. }
  9182. }
  9183. if (staticClass) {
  9184. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9185. }
  9186. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9187. if (classBinding) {
  9188. el.classBinding = classBinding;
  9189. }
  9190. }
  9191. function genData$2(el) {
  9192. let data = '';
  9193. if (el.staticClass) {
  9194. data += `staticClass:${el.staticClass},`;
  9195. }
  9196. if (el.classBinding) {
  9197. data += `class:${el.classBinding},`;
  9198. }
  9199. return data;
  9200. }
  9201. var klass = {
  9202. staticKeys: ['staticClass'],
  9203. transformNode: transformNode$1,
  9204. genData: genData$2
  9205. };
  9206. function transformNode(el, options) {
  9207. const warn = options.warn || baseWarn;
  9208. const staticStyle = getAndRemoveAttr(el, 'style');
  9209. if (staticStyle) {
  9210. /* istanbul ignore if */
  9211. {
  9212. const res = parseText(staticStyle, options.delimiters);
  9213. if (res) {
  9214. warn(`style="${staticStyle}": ` +
  9215. 'Interpolation inside attributes has been removed. ' +
  9216. 'Use v-bind or the colon shorthand instead. For example, ' +
  9217. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9218. }
  9219. }
  9220. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9221. }
  9222. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9223. if (styleBinding) {
  9224. el.styleBinding = styleBinding;
  9225. }
  9226. }
  9227. function genData$1(el) {
  9228. let data = '';
  9229. if (el.staticStyle) {
  9230. data += `staticStyle:${el.staticStyle},`;
  9231. }
  9232. if (el.styleBinding) {
  9233. data += `style:(${el.styleBinding}),`;
  9234. }
  9235. return data;
  9236. }
  9237. var style = {
  9238. staticKeys: ['staticStyle'],
  9239. transformNode,
  9240. genData: genData$1
  9241. };
  9242. let decoder;
  9243. var he = {
  9244. decode(html) {
  9245. decoder = decoder || document.createElement('div');
  9246. decoder.innerHTML = html;
  9247. return decoder.textContent;
  9248. }
  9249. };
  9250. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9251. 'link,meta,param,source,track,wbr');
  9252. // Elements that you can, intentionally, leave open
  9253. // (and which close themselves)
  9254. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9255. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9256. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9257. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9258. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9259. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9260. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9261. 'title,tr,track');
  9262. /**
  9263. * Not type-checking this file because it's mostly vendor code.
  9264. */
  9265. // Regular Expressions for parsing tags and attributes
  9266. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9267. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9268. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9269. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9270. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9271. const startTagClose = /^\s*(\/?)>/;
  9272. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9273. const doctype = /^<!DOCTYPE [^>]+>/i;
  9274. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9275. const comment = /^<!\--/;
  9276. const conditionalComment = /^<!\[/;
  9277. // Special Elements (can contain anything)
  9278. const isPlainTextElement = makeMap('script,style,textarea', true);
  9279. const reCache = {};
  9280. const decodingMap = {
  9281. '&lt;': '<',
  9282. '&gt;': '>',
  9283. '&quot;': '"',
  9284. '&amp;': '&',
  9285. '&#10;': '\n',
  9286. '&#9;': '\t',
  9287. '&#39;': "'"
  9288. };
  9289. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9290. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9291. // #5992
  9292. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9293. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9294. function decodeAttr(value, shouldDecodeNewlines) {
  9295. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9296. return value.replace(re, match => decodingMap[match]);
  9297. }
  9298. function parseHTML(html, options) {
  9299. const stack = [];
  9300. const expectHTML = options.expectHTML;
  9301. const isUnaryTag = options.isUnaryTag || no;
  9302. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9303. let index = 0;
  9304. let last, lastTag;
  9305. while (html) {
  9306. last = html;
  9307. // Make sure we're not in a plaintext content element like script/style
  9308. if (!lastTag || !isPlainTextElement(lastTag)) {
  9309. let textEnd = html.indexOf('<');
  9310. if (textEnd === 0) {
  9311. // Comment:
  9312. if (comment.test(html)) {
  9313. const commentEnd = html.indexOf('-->');
  9314. if (commentEnd >= 0) {
  9315. if (options.shouldKeepComment && options.comment) {
  9316. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9317. }
  9318. advance(commentEnd + 3);
  9319. continue;
  9320. }
  9321. }
  9322. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9323. if (conditionalComment.test(html)) {
  9324. const conditionalEnd = html.indexOf(']>');
  9325. if (conditionalEnd >= 0) {
  9326. advance(conditionalEnd + 2);
  9327. continue;
  9328. }
  9329. }
  9330. // Doctype:
  9331. const doctypeMatch = html.match(doctype);
  9332. if (doctypeMatch) {
  9333. advance(doctypeMatch[0].length);
  9334. continue;
  9335. }
  9336. // End tag:
  9337. const endTagMatch = html.match(endTag);
  9338. if (endTagMatch) {
  9339. const curIndex = index;
  9340. advance(endTagMatch[0].length);
  9341. parseEndTag(endTagMatch[1], curIndex, index);
  9342. continue;
  9343. }
  9344. // Start tag:
  9345. const startTagMatch = parseStartTag();
  9346. if (startTagMatch) {
  9347. handleStartTag(startTagMatch);
  9348. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9349. advance(1);
  9350. }
  9351. continue;
  9352. }
  9353. }
  9354. let text, rest, next;
  9355. if (textEnd >= 0) {
  9356. rest = html.slice(textEnd);
  9357. while (!endTag.test(rest) &&
  9358. !startTagOpen.test(rest) &&
  9359. !comment.test(rest) &&
  9360. !conditionalComment.test(rest)) {
  9361. // < in plain text, be forgiving and treat it as text
  9362. next = rest.indexOf('<', 1);
  9363. if (next < 0)
  9364. break;
  9365. textEnd += next;
  9366. rest = html.slice(textEnd);
  9367. }
  9368. text = html.substring(0, textEnd);
  9369. }
  9370. if (textEnd < 0) {
  9371. text = html;
  9372. }
  9373. if (text) {
  9374. advance(text.length);
  9375. }
  9376. if (options.chars && text) {
  9377. options.chars(text, index - text.length, index);
  9378. }
  9379. }
  9380. else {
  9381. let endTagLength = 0;
  9382. const stackedTag = lastTag.toLowerCase();
  9383. const reStackedTag = reCache[stackedTag] ||
  9384. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9385. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9386. endTagLength = endTag.length;
  9387. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9388. text = text
  9389. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9390. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9391. }
  9392. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9393. text = text.slice(1);
  9394. }
  9395. if (options.chars) {
  9396. options.chars(text);
  9397. }
  9398. return '';
  9399. });
  9400. index += html.length - rest.length;
  9401. html = rest;
  9402. parseEndTag(stackedTag, index - endTagLength, index);
  9403. }
  9404. if (html === last) {
  9405. options.chars && options.chars(html);
  9406. if (!stack.length && options.warn) {
  9407. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9408. start: index + html.length
  9409. });
  9410. }
  9411. break;
  9412. }
  9413. }
  9414. // Clean up any remaining tags
  9415. parseEndTag();
  9416. function advance(n) {
  9417. index += n;
  9418. html = html.substring(n);
  9419. }
  9420. function parseStartTag() {
  9421. const start = html.match(startTagOpen);
  9422. if (start) {
  9423. const match = {
  9424. tagName: start[1],
  9425. attrs: [],
  9426. start: index
  9427. };
  9428. advance(start[0].length);
  9429. let end, attr;
  9430. while (!(end = html.match(startTagClose)) &&
  9431. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9432. attr.start = index;
  9433. advance(attr[0].length);
  9434. attr.end = index;
  9435. match.attrs.push(attr);
  9436. }
  9437. if (end) {
  9438. match.unarySlash = end[1];
  9439. advance(end[0].length);
  9440. match.end = index;
  9441. return match;
  9442. }
  9443. }
  9444. }
  9445. function handleStartTag(match) {
  9446. const tagName = match.tagName;
  9447. const unarySlash = match.unarySlash;
  9448. if (expectHTML) {
  9449. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9450. parseEndTag(lastTag);
  9451. }
  9452. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9453. parseEndTag(tagName);
  9454. }
  9455. }
  9456. const unary = isUnaryTag(tagName) || !!unarySlash;
  9457. const l = match.attrs.length;
  9458. const attrs = new Array(l);
  9459. for (let i = 0; i < l; i++) {
  9460. const args = match.attrs[i];
  9461. const value = args[3] || args[4] || args[5] || '';
  9462. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9463. ? options.shouldDecodeNewlinesForHref
  9464. : options.shouldDecodeNewlines;
  9465. attrs[i] = {
  9466. name: args[1],
  9467. value: decodeAttr(value, shouldDecodeNewlines)
  9468. };
  9469. if (options.outputSourceRange) {
  9470. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9471. attrs[i].end = args.end;
  9472. }
  9473. }
  9474. if (!unary) {
  9475. stack.push({
  9476. tag: tagName,
  9477. lowerCasedTag: tagName.toLowerCase(),
  9478. attrs: attrs,
  9479. start: match.start,
  9480. end: match.end
  9481. });
  9482. lastTag = tagName;
  9483. }
  9484. if (options.start) {
  9485. options.start(tagName, attrs, unary, match.start, match.end);
  9486. }
  9487. }
  9488. function parseEndTag(tagName, start, end) {
  9489. let pos, lowerCasedTagName;
  9490. if (start == null)
  9491. start = index;
  9492. if (end == null)
  9493. end = index;
  9494. // Find the closest opened tag of the same type
  9495. if (tagName) {
  9496. lowerCasedTagName = tagName.toLowerCase();
  9497. for (pos = stack.length - 1; pos >= 0; pos--) {
  9498. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9499. break;
  9500. }
  9501. }
  9502. }
  9503. else {
  9504. // If no tag name is provided, clean shop
  9505. pos = 0;
  9506. }
  9507. if (pos >= 0) {
  9508. // Close all the open elements, up the stack
  9509. for (let i = stack.length - 1; i >= pos; i--) {
  9510. if ((i > pos || !tagName) && options.warn) {
  9511. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9512. start: stack[i].start,
  9513. end: stack[i].end
  9514. });
  9515. }
  9516. if (options.end) {
  9517. options.end(stack[i].tag, start, end);
  9518. }
  9519. }
  9520. // Remove the open elements from the stack
  9521. stack.length = pos;
  9522. lastTag = pos && stack[pos - 1].tag;
  9523. }
  9524. else if (lowerCasedTagName === 'br') {
  9525. if (options.start) {
  9526. options.start(tagName, [], true, start, end);
  9527. }
  9528. }
  9529. else if (lowerCasedTagName === 'p') {
  9530. if (options.start) {
  9531. options.start(tagName, [], false, start, end);
  9532. }
  9533. if (options.end) {
  9534. options.end(tagName, start, end);
  9535. }
  9536. }
  9537. }
  9538. }
  9539. const onRE = /^@|^v-on:/;
  9540. const dirRE = /^v-|^@|^:|^#/;
  9541. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9542. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9543. const stripParensRE = /^\(|\)$/g;
  9544. const dynamicArgRE = /^\[.*\]$/;
  9545. const argRE = /:(.*)$/;
  9546. const bindRE = /^:|^\.|^v-bind:/;
  9547. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9548. const slotRE = /^v-slot(:|$)|^#/;
  9549. const lineBreakRE = /[\r\n]/;
  9550. const whitespaceRE = /[ \f\t\r\n]+/g;
  9551. const invalidAttributeRE = /[\s"'<>\/=]/;
  9552. const decodeHTMLCached = cached(he.decode);
  9553. const emptySlotScopeToken = `_empty_`;
  9554. // configurable state
  9555. let warn;
  9556. let delimiters;
  9557. let transforms;
  9558. let preTransforms;
  9559. let postTransforms;
  9560. let platformIsPreTag;
  9561. let platformMustUseProp;
  9562. let platformGetTagNamespace;
  9563. let maybeComponent;
  9564. function createASTElement(tag, attrs, parent) {
  9565. return {
  9566. type: 1,
  9567. tag,
  9568. attrsList: attrs,
  9569. attrsMap: makeAttrsMap(attrs),
  9570. rawAttrsMap: {},
  9571. parent,
  9572. children: []
  9573. };
  9574. }
  9575. /**
  9576. * Convert HTML string to AST.
  9577. */
  9578. function parse(template, options) {
  9579. warn = options.warn || baseWarn;
  9580. platformIsPreTag = options.isPreTag || no;
  9581. platformMustUseProp = options.mustUseProp || no;
  9582. platformGetTagNamespace = options.getTagNamespace || no;
  9583. const isReservedTag = options.isReservedTag || no;
  9584. maybeComponent = (el) => !!(el.component ||
  9585. el.attrsMap[':is'] ||
  9586. el.attrsMap['v-bind:is'] ||
  9587. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9588. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9589. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9590. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9591. delimiters = options.delimiters;
  9592. const stack = [];
  9593. const preserveWhitespace = options.preserveWhitespace !== false;
  9594. const whitespaceOption = options.whitespace;
  9595. let root;
  9596. let currentParent;
  9597. let inVPre = false;
  9598. let inPre = false;
  9599. let warned = false;
  9600. function warnOnce(msg, range) {
  9601. if (!warned) {
  9602. warned = true;
  9603. warn(msg, range);
  9604. }
  9605. }
  9606. function closeElement(element) {
  9607. trimEndingWhitespace(element);
  9608. if (!inVPre && !element.processed) {
  9609. element = processElement(element, options);
  9610. }
  9611. // tree management
  9612. if (!stack.length && element !== root) {
  9613. // allow root elements with v-if, v-else-if and v-else
  9614. if (root.if && (element.elseif || element.else)) {
  9615. {
  9616. checkRootConstraints(element);
  9617. }
  9618. addIfCondition(root, {
  9619. exp: element.elseif,
  9620. block: element
  9621. });
  9622. }
  9623. else {
  9624. warnOnce(`Component template should contain exactly one root element. ` +
  9625. `If you are using v-if on multiple elements, ` +
  9626. `use v-else-if to chain them instead.`, { start: element.start });
  9627. }
  9628. }
  9629. if (currentParent && !element.forbidden) {
  9630. if (element.elseif || element.else) {
  9631. processIfConditions(element, currentParent);
  9632. }
  9633. else {
  9634. if (element.slotScope) {
  9635. // scoped slot
  9636. // keep it in the children list so that v-else(-if) conditions can
  9637. // find it as the prev node.
  9638. const name = element.slotTarget || '"default"';
  9639. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9640. }
  9641. currentParent.children.push(element);
  9642. element.parent = currentParent;
  9643. }
  9644. }
  9645. // final children cleanup
  9646. // filter out scoped slots
  9647. element.children = element.children.filter(c => !c.slotScope);
  9648. // remove trailing whitespace node again
  9649. trimEndingWhitespace(element);
  9650. // check pre state
  9651. if (element.pre) {
  9652. inVPre = false;
  9653. }
  9654. if (platformIsPreTag(element.tag)) {
  9655. inPre = false;
  9656. }
  9657. // apply post-transforms
  9658. for (let i = 0; i < postTransforms.length; i++) {
  9659. postTransforms[i](element, options);
  9660. }
  9661. }
  9662. function trimEndingWhitespace(el) {
  9663. // remove trailing whitespace node
  9664. if (!inPre) {
  9665. let lastNode;
  9666. while ((lastNode = el.children[el.children.length - 1]) &&
  9667. lastNode.type === 3 &&
  9668. lastNode.text === ' ') {
  9669. el.children.pop();
  9670. }
  9671. }
  9672. }
  9673. function checkRootConstraints(el) {
  9674. if (el.tag === 'slot' || el.tag === 'template') {
  9675. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9676. 'contain multiple nodes.', { start: el.start });
  9677. }
  9678. if (el.attrsMap.hasOwnProperty('v-for')) {
  9679. warnOnce('Cannot use v-for on stateful component root element because ' +
  9680. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9681. }
  9682. }
  9683. parseHTML(template, {
  9684. warn,
  9685. expectHTML: options.expectHTML,
  9686. isUnaryTag: options.isUnaryTag,
  9687. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9688. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9689. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9690. shouldKeepComment: options.comments,
  9691. outputSourceRange: options.outputSourceRange,
  9692. start(tag, attrs, unary, start, end) {
  9693. // check namespace.
  9694. // inherit parent ns if there is one
  9695. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9696. // handle IE svg bug
  9697. /* istanbul ignore if */
  9698. if (isIE && ns === 'svg') {
  9699. attrs = guardIESVGBug(attrs);
  9700. }
  9701. let element = createASTElement(tag, attrs, currentParent);
  9702. if (ns) {
  9703. element.ns = ns;
  9704. }
  9705. {
  9706. if (options.outputSourceRange) {
  9707. element.start = start;
  9708. element.end = end;
  9709. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9710. cumulated[attr.name] = attr;
  9711. return cumulated;
  9712. }, {});
  9713. }
  9714. attrs.forEach(attr => {
  9715. if (invalidAttributeRE.test(attr.name)) {
  9716. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9717. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9718. ? {
  9719. start: attr.start + attr.name.indexOf(`[`),
  9720. end: attr.start + attr.name.length
  9721. }
  9722. : undefined);
  9723. }
  9724. });
  9725. }
  9726. if (isForbiddenTag(element) && !isServerRendering()) {
  9727. element.forbidden = true;
  9728. warn('Templates should only be responsible for mapping the state to the ' +
  9729. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9730. `<${tag}>` +
  9731. ', as they will not be parsed.', { start: element.start });
  9732. }
  9733. // apply pre-transforms
  9734. for (let i = 0; i < preTransforms.length; i++) {
  9735. element = preTransforms[i](element, options) || element;
  9736. }
  9737. if (!inVPre) {
  9738. processPre(element);
  9739. if (element.pre) {
  9740. inVPre = true;
  9741. }
  9742. }
  9743. if (platformIsPreTag(element.tag)) {
  9744. inPre = true;
  9745. }
  9746. if (inVPre) {
  9747. processRawAttrs(element);
  9748. }
  9749. else if (!element.processed) {
  9750. // structural directives
  9751. processFor(element);
  9752. processIf(element);
  9753. processOnce(element);
  9754. }
  9755. if (!root) {
  9756. root = element;
  9757. {
  9758. checkRootConstraints(root);
  9759. }
  9760. }
  9761. if (!unary) {
  9762. currentParent = element;
  9763. stack.push(element);
  9764. }
  9765. else {
  9766. closeElement(element);
  9767. }
  9768. },
  9769. end(tag, start, end) {
  9770. const element = stack[stack.length - 1];
  9771. // pop stack
  9772. stack.length -= 1;
  9773. currentParent = stack[stack.length - 1];
  9774. if (options.outputSourceRange) {
  9775. element.end = end;
  9776. }
  9777. closeElement(element);
  9778. },
  9779. chars(text, start, end) {
  9780. if (!currentParent) {
  9781. {
  9782. if (text === template) {
  9783. warnOnce('Component template requires a root element, rather than just text.', { start });
  9784. }
  9785. else if ((text = text.trim())) {
  9786. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9787. start
  9788. });
  9789. }
  9790. }
  9791. return;
  9792. }
  9793. // IE textarea placeholder bug
  9794. /* istanbul ignore if */
  9795. if (isIE &&
  9796. currentParent.tag === 'textarea' &&
  9797. currentParent.attrsMap.placeholder === text) {
  9798. return;
  9799. }
  9800. const children = currentParent.children;
  9801. if (inPre || text.trim()) {
  9802. text = isTextTag(currentParent)
  9803. ? text
  9804. : decodeHTMLCached(text);
  9805. }
  9806. else if (!children.length) {
  9807. // remove the whitespace-only node right after an opening tag
  9808. text = '';
  9809. }
  9810. else if (whitespaceOption) {
  9811. if (whitespaceOption === 'condense') {
  9812. // in condense mode, remove the whitespace node if it contains
  9813. // line break, otherwise condense to a single space
  9814. text = lineBreakRE.test(text) ? '' : ' ';
  9815. }
  9816. else {
  9817. text = ' ';
  9818. }
  9819. }
  9820. else {
  9821. text = preserveWhitespace ? ' ' : '';
  9822. }
  9823. if (text) {
  9824. if (!inPre && whitespaceOption === 'condense') {
  9825. // condense consecutive whitespaces into single space
  9826. text = text.replace(whitespaceRE, ' ');
  9827. }
  9828. let res;
  9829. let child;
  9830. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9831. child = {
  9832. type: 2,
  9833. expression: res.expression,
  9834. tokens: res.tokens,
  9835. text
  9836. };
  9837. }
  9838. else if (text !== ' ' ||
  9839. !children.length ||
  9840. children[children.length - 1].text !== ' ') {
  9841. child = {
  9842. type: 3,
  9843. text
  9844. };
  9845. }
  9846. if (child) {
  9847. if (options.outputSourceRange) {
  9848. child.start = start;
  9849. child.end = end;
  9850. }
  9851. children.push(child);
  9852. }
  9853. }
  9854. },
  9855. comment(text, start, end) {
  9856. // adding anything as a sibling to the root node is forbidden
  9857. // comments should still be allowed, but ignored
  9858. if (currentParent) {
  9859. const child = {
  9860. type: 3,
  9861. text,
  9862. isComment: true
  9863. };
  9864. if (options.outputSourceRange) {
  9865. child.start = start;
  9866. child.end = end;
  9867. }
  9868. currentParent.children.push(child);
  9869. }
  9870. }
  9871. });
  9872. return root;
  9873. }
  9874. function processPre(el) {
  9875. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9876. el.pre = true;
  9877. }
  9878. }
  9879. function processRawAttrs(el) {
  9880. const list = el.attrsList;
  9881. const len = list.length;
  9882. if (len) {
  9883. const attrs = (el.attrs = new Array(len));
  9884. for (let i = 0; i < len; i++) {
  9885. attrs[i] = {
  9886. name: list[i].name,
  9887. value: JSON.stringify(list[i].value)
  9888. };
  9889. if (list[i].start != null) {
  9890. attrs[i].start = list[i].start;
  9891. attrs[i].end = list[i].end;
  9892. }
  9893. }
  9894. }
  9895. else if (!el.pre) {
  9896. // non root node in pre blocks with no attributes
  9897. el.plain = true;
  9898. }
  9899. }
  9900. function processElement(element, options) {
  9901. processKey(element);
  9902. // determine whether this is a plain element after
  9903. // removing structural attributes
  9904. element.plain =
  9905. !element.key && !element.scopedSlots && !element.attrsList.length;
  9906. processRef(element);
  9907. processSlotContent(element);
  9908. processSlotOutlet(element);
  9909. processComponent(element);
  9910. for (let i = 0; i < transforms.length; i++) {
  9911. element = transforms[i](element, options) || element;
  9912. }
  9913. processAttrs(element);
  9914. return element;
  9915. }
  9916. function processKey(el) {
  9917. const exp = getBindingAttr(el, 'key');
  9918. if (exp) {
  9919. {
  9920. if (el.tag === 'template') {
  9921. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9922. }
  9923. if (el.for) {
  9924. const iterator = el.iterator2 || el.iterator1;
  9925. const parent = el.parent;
  9926. if (iterator &&
  9927. iterator === exp &&
  9928. parent &&
  9929. parent.tag === 'transition-group') {
  9930. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9931. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9932. }
  9933. }
  9934. }
  9935. el.key = exp;
  9936. }
  9937. }
  9938. function processRef(el) {
  9939. const ref = getBindingAttr(el, 'ref');
  9940. if (ref) {
  9941. el.ref = ref;
  9942. el.refInFor = checkInFor(el);
  9943. }
  9944. }
  9945. function processFor(el) {
  9946. let exp;
  9947. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9948. const res = parseFor(exp);
  9949. if (res) {
  9950. extend(el, res);
  9951. }
  9952. else {
  9953. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9954. }
  9955. }
  9956. }
  9957. function parseFor(exp) {
  9958. const inMatch = exp.match(forAliasRE);
  9959. if (!inMatch)
  9960. return;
  9961. const res = {};
  9962. res.for = inMatch[2].trim();
  9963. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9964. const iteratorMatch = alias.match(forIteratorRE);
  9965. if (iteratorMatch) {
  9966. res.alias = alias.replace(forIteratorRE, '').trim();
  9967. res.iterator1 = iteratorMatch[1].trim();
  9968. if (iteratorMatch[2]) {
  9969. res.iterator2 = iteratorMatch[2].trim();
  9970. }
  9971. }
  9972. else {
  9973. res.alias = alias;
  9974. }
  9975. return res;
  9976. }
  9977. function processIf(el) {
  9978. const exp = getAndRemoveAttr(el, 'v-if');
  9979. if (exp) {
  9980. el.if = exp;
  9981. addIfCondition(el, {
  9982. exp: exp,
  9983. block: el
  9984. });
  9985. }
  9986. else {
  9987. if (getAndRemoveAttr(el, 'v-else') != null) {
  9988. el.else = true;
  9989. }
  9990. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9991. if (elseif) {
  9992. el.elseif = elseif;
  9993. }
  9994. }
  9995. }
  9996. function processIfConditions(el, parent) {
  9997. const prev = findPrevElement(parent.children);
  9998. if (prev && prev.if) {
  9999. addIfCondition(prev, {
  10000. exp: el.elseif,
  10001. block: el
  10002. });
  10003. }
  10004. else {
  10005. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  10006. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  10007. }
  10008. }
  10009. function findPrevElement(children) {
  10010. let i = children.length;
  10011. while (i--) {
  10012. if (children[i].type === 1) {
  10013. return children[i];
  10014. }
  10015. else {
  10016. if (children[i].text !== ' ') {
  10017. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  10018. `will be ignored.`, children[i]);
  10019. }
  10020. children.pop();
  10021. }
  10022. }
  10023. }
  10024. function addIfCondition(el, condition) {
  10025. if (!el.ifConditions) {
  10026. el.ifConditions = [];
  10027. }
  10028. el.ifConditions.push(condition);
  10029. }
  10030. function processOnce(el) {
  10031. const once = getAndRemoveAttr(el, 'v-once');
  10032. if (once != null) {
  10033. el.once = true;
  10034. }
  10035. }
  10036. // handle content being passed to a component as slot,
  10037. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10038. function processSlotContent(el) {
  10039. let slotScope;
  10040. if (el.tag === 'template') {
  10041. slotScope = getAndRemoveAttr(el, 'scope');
  10042. /* istanbul ignore if */
  10043. if (slotScope) {
  10044. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10045. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10046. `can also be used on plain elements in addition to <template> to ` +
  10047. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10048. }
  10049. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10050. }
  10051. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10052. /* istanbul ignore if */
  10053. if (el.attrsMap['v-for']) {
  10054. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10055. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10056. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10057. }
  10058. el.slotScope = slotScope;
  10059. }
  10060. // slot="xxx"
  10061. const slotTarget = getBindingAttr(el, 'slot');
  10062. if (slotTarget) {
  10063. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10064. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10065. // preserve slot as an attribute for native shadow DOM compat
  10066. // only for non-scoped slots.
  10067. if (el.tag !== 'template' && !el.slotScope) {
  10068. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10069. }
  10070. }
  10071. // 2.6 v-slot syntax
  10072. {
  10073. if (el.tag === 'template') {
  10074. // v-slot on <template>
  10075. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10076. if (slotBinding) {
  10077. {
  10078. if (el.slotTarget || el.slotScope) {
  10079. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10080. }
  10081. if (el.parent && !maybeComponent(el.parent)) {
  10082. warn(`<template v-slot> can only appear at the root level inside ` +
  10083. `the receiving component`, el);
  10084. }
  10085. }
  10086. const { name, dynamic } = getSlotName(slotBinding);
  10087. el.slotTarget = name;
  10088. el.slotTargetDynamic = dynamic;
  10089. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10090. }
  10091. }
  10092. else {
  10093. // v-slot on component, denotes default slot
  10094. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10095. if (slotBinding) {
  10096. {
  10097. if (!maybeComponent(el)) {
  10098. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10099. }
  10100. if (el.slotScope || el.slotTarget) {
  10101. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10102. }
  10103. if (el.scopedSlots) {
  10104. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10105. `<template> syntax when there are other named slots.`, slotBinding);
  10106. }
  10107. }
  10108. // add the component's children to its default slot
  10109. const slots = el.scopedSlots || (el.scopedSlots = {});
  10110. const { name, dynamic } = getSlotName(slotBinding);
  10111. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10112. slotContainer.slotTarget = name;
  10113. slotContainer.slotTargetDynamic = dynamic;
  10114. slotContainer.children = el.children.filter((c) => {
  10115. if (!c.slotScope) {
  10116. c.parent = slotContainer;
  10117. return true;
  10118. }
  10119. });
  10120. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10121. // remove children as they are returned from scopedSlots now
  10122. el.children = [];
  10123. // mark el non-plain so data gets generated
  10124. el.plain = false;
  10125. }
  10126. }
  10127. }
  10128. }
  10129. function getSlotName(binding) {
  10130. let name = binding.name.replace(slotRE, '');
  10131. if (!name) {
  10132. if (binding.name[0] !== '#') {
  10133. name = 'default';
  10134. }
  10135. else {
  10136. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10137. }
  10138. }
  10139. return dynamicArgRE.test(name)
  10140. ? // dynamic [name]
  10141. { name: name.slice(1, -1), dynamic: true }
  10142. : // static name
  10143. { name: `"${name}"`, dynamic: false };
  10144. }
  10145. // handle <slot/> outlets
  10146. function processSlotOutlet(el) {
  10147. if (el.tag === 'slot') {
  10148. el.slotName = getBindingAttr(el, 'name');
  10149. if (el.key) {
  10150. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10151. `and can possibly expand into multiple elements. ` +
  10152. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10153. }
  10154. }
  10155. }
  10156. function processComponent(el) {
  10157. let binding;
  10158. if ((binding = getBindingAttr(el, 'is'))) {
  10159. el.component = binding;
  10160. }
  10161. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10162. el.inlineTemplate = true;
  10163. }
  10164. }
  10165. function processAttrs(el) {
  10166. const list = el.attrsList;
  10167. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10168. for (i = 0, l = list.length; i < l; i++) {
  10169. name = rawName = list[i].name;
  10170. value = list[i].value;
  10171. if (dirRE.test(name)) {
  10172. // mark element as dynamic
  10173. el.hasBindings = true;
  10174. // modifiers
  10175. modifiers = parseModifiers(name.replace(dirRE, ''));
  10176. // support .foo shorthand syntax for the .prop modifier
  10177. if (modifiers) {
  10178. name = name.replace(modifierRE, '');
  10179. }
  10180. if (bindRE.test(name)) {
  10181. // v-bind
  10182. name = name.replace(bindRE, '');
  10183. value = parseFilters(value);
  10184. isDynamic = dynamicArgRE.test(name);
  10185. if (isDynamic) {
  10186. name = name.slice(1, -1);
  10187. }
  10188. if (value.trim().length === 0) {
  10189. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10190. }
  10191. if (modifiers) {
  10192. if (modifiers.prop && !isDynamic) {
  10193. name = camelize(name);
  10194. if (name === 'innerHtml')
  10195. name = 'innerHTML';
  10196. }
  10197. if (modifiers.camel && !isDynamic) {
  10198. name = camelize(name);
  10199. }
  10200. if (modifiers.sync) {
  10201. syncGen = genAssignmentCode(value, `$event`);
  10202. if (!isDynamic) {
  10203. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10204. if (hyphenate(name) !== camelize(name)) {
  10205. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10206. }
  10207. }
  10208. else {
  10209. // handler w/ dynamic event name
  10210. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10211. );
  10212. }
  10213. }
  10214. }
  10215. if ((modifiers && modifiers.prop) ||
  10216. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10217. addProp(el, name, value, list[i], isDynamic);
  10218. }
  10219. else {
  10220. addAttr(el, name, value, list[i], isDynamic);
  10221. }
  10222. }
  10223. else if (onRE.test(name)) {
  10224. // v-on
  10225. name = name.replace(onRE, '');
  10226. isDynamic = dynamicArgRE.test(name);
  10227. if (isDynamic) {
  10228. name = name.slice(1, -1);
  10229. }
  10230. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10231. }
  10232. else {
  10233. // normal directives
  10234. name = name.replace(dirRE, '');
  10235. // parse arg
  10236. const argMatch = name.match(argRE);
  10237. let arg = argMatch && argMatch[1];
  10238. isDynamic = false;
  10239. if (arg) {
  10240. name = name.slice(0, -(arg.length + 1));
  10241. if (dynamicArgRE.test(arg)) {
  10242. arg = arg.slice(1, -1);
  10243. isDynamic = true;
  10244. }
  10245. }
  10246. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10247. if (name === 'model') {
  10248. checkForAliasModel(el, value);
  10249. }
  10250. }
  10251. }
  10252. else {
  10253. // literal attribute
  10254. {
  10255. const res = parseText(value, delimiters);
  10256. if (res) {
  10257. warn(`${name}="${value}": ` +
  10258. 'Interpolation inside attributes has been removed. ' +
  10259. 'Use v-bind or the colon shorthand instead. For example, ' +
  10260. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10261. }
  10262. }
  10263. addAttr(el, name, JSON.stringify(value), list[i]);
  10264. // #6887 firefox doesn't update muted state if set via attribute
  10265. // even immediately after element creation
  10266. if (!el.component &&
  10267. name === 'muted' &&
  10268. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10269. addProp(el, name, 'true', list[i]);
  10270. }
  10271. }
  10272. }
  10273. }
  10274. function checkInFor(el) {
  10275. let parent = el;
  10276. while (parent) {
  10277. if (parent.for !== undefined) {
  10278. return true;
  10279. }
  10280. parent = parent.parent;
  10281. }
  10282. return false;
  10283. }
  10284. function parseModifiers(name) {
  10285. const match = name.match(modifierRE);
  10286. if (match) {
  10287. const ret = {};
  10288. match.forEach(m => {
  10289. ret[m.slice(1)] = true;
  10290. });
  10291. return ret;
  10292. }
  10293. }
  10294. function makeAttrsMap(attrs) {
  10295. const map = {};
  10296. for (let i = 0, l = attrs.length; i < l; i++) {
  10297. if (map[attrs[i].name] && !isIE && !isEdge) {
  10298. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10299. }
  10300. map[attrs[i].name] = attrs[i].value;
  10301. }
  10302. return map;
  10303. }
  10304. // for script (e.g. type="x/template") or style, do not decode content
  10305. function isTextTag(el) {
  10306. return el.tag === 'script' || el.tag === 'style';
  10307. }
  10308. function isForbiddenTag(el) {
  10309. return (el.tag === 'style' ||
  10310. (el.tag === 'script' &&
  10311. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10312. }
  10313. const ieNSBug = /^xmlns:NS\d+/;
  10314. const ieNSPrefix = /^NS\d+:/;
  10315. /* istanbul ignore next */
  10316. function guardIESVGBug(attrs) {
  10317. const res = [];
  10318. for (let i = 0; i < attrs.length; i++) {
  10319. const attr = attrs[i];
  10320. if (!ieNSBug.test(attr.name)) {
  10321. attr.name = attr.name.replace(ieNSPrefix, '');
  10322. res.push(attr);
  10323. }
  10324. }
  10325. return res;
  10326. }
  10327. function checkForAliasModel(el, value) {
  10328. let _el = el;
  10329. while (_el) {
  10330. if (_el.for && _el.alias === value) {
  10331. warn(`<${el.tag} v-model="${value}">: ` +
  10332. `You are binding v-model directly to a v-for iteration alias. ` +
  10333. `This will not be able to modify the v-for source array because ` +
  10334. `writing to the alias is like modifying a function local variable. ` +
  10335. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10336. }
  10337. _el = _el.parent;
  10338. }
  10339. }
  10340. /**
  10341. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10342. * Turn this:
  10343. * <input v-model="data[type]" :type="type">
  10344. * into this:
  10345. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10346. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10347. * <input v-else :type="type" v-model="data[type]">
  10348. */
  10349. function preTransformNode(el, options) {
  10350. if (el.tag === 'input') {
  10351. const map = el.attrsMap;
  10352. if (!map['v-model']) {
  10353. return;
  10354. }
  10355. let typeBinding;
  10356. if (map[':type'] || map['v-bind:type']) {
  10357. typeBinding = getBindingAttr(el, 'type');
  10358. }
  10359. if (!map.type && !typeBinding && map['v-bind']) {
  10360. typeBinding = `(${map['v-bind']}).type`;
  10361. }
  10362. if (typeBinding) {
  10363. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10364. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10365. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10366. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10367. // 1. checkbox
  10368. const branch0 = cloneASTElement(el);
  10369. // process for on the main node
  10370. processFor(branch0);
  10371. addRawAttr(branch0, 'type', 'checkbox');
  10372. processElement(branch0, options);
  10373. branch0.processed = true; // prevent it from double-processed
  10374. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10375. addIfCondition(branch0, {
  10376. exp: branch0.if,
  10377. block: branch0
  10378. });
  10379. // 2. add radio else-if condition
  10380. const branch1 = cloneASTElement(el);
  10381. getAndRemoveAttr(branch1, 'v-for', true);
  10382. addRawAttr(branch1, 'type', 'radio');
  10383. processElement(branch1, options);
  10384. addIfCondition(branch0, {
  10385. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10386. block: branch1
  10387. });
  10388. // 3. other
  10389. const branch2 = cloneASTElement(el);
  10390. getAndRemoveAttr(branch2, 'v-for', true);
  10391. addRawAttr(branch2, ':type', typeBinding);
  10392. processElement(branch2, options);
  10393. addIfCondition(branch0, {
  10394. exp: ifCondition,
  10395. block: branch2
  10396. });
  10397. if (hasElse) {
  10398. branch0.else = true;
  10399. }
  10400. else if (elseIfCondition) {
  10401. branch0.elseif = elseIfCondition;
  10402. }
  10403. return branch0;
  10404. }
  10405. }
  10406. }
  10407. function cloneASTElement(el) {
  10408. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10409. }
  10410. var model = {
  10411. preTransformNode
  10412. };
  10413. var modules = [klass, style, model];
  10414. function text(el, dir) {
  10415. if (dir.value) {
  10416. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10417. }
  10418. }
  10419. function html(el, dir) {
  10420. if (dir.value) {
  10421. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10422. }
  10423. }
  10424. var directives = {
  10425. model: model$1,
  10426. text,
  10427. html
  10428. };
  10429. const baseOptions = {
  10430. expectHTML: true,
  10431. modules,
  10432. directives,
  10433. isPreTag,
  10434. isUnaryTag,
  10435. mustUseProp,
  10436. canBeLeftOpenTag,
  10437. isReservedTag,
  10438. getTagNamespace,
  10439. staticKeys: genStaticKeys$1(modules)
  10440. };
  10441. let isStaticKey;
  10442. let isPlatformReservedTag;
  10443. const genStaticKeysCached = cached(genStaticKeys);
  10444. /**
  10445. * Goal of the optimizer: walk the generated template AST tree
  10446. * and detect sub-trees that are purely static, i.e. parts of
  10447. * the DOM that never needs to change.
  10448. *
  10449. * Once we detect these sub-trees, we can:
  10450. *
  10451. * 1. Hoist them into constants, so that we no longer need to
  10452. * create fresh nodes for them on each re-render;
  10453. * 2. Completely skip them in the patching process.
  10454. */
  10455. function optimize(root, options) {
  10456. if (!root)
  10457. return;
  10458. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10459. isPlatformReservedTag = options.isReservedTag || no;
  10460. // first pass: mark all non-static nodes.
  10461. markStatic(root);
  10462. // second pass: mark static roots.
  10463. markStaticRoots(root, false);
  10464. }
  10465. function genStaticKeys(keys) {
  10466. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10467. (keys ? ',' + keys : ''));
  10468. }
  10469. function markStatic(node) {
  10470. node.static = isStatic(node);
  10471. if (node.type === 1) {
  10472. // do not make component slot content static. this avoids
  10473. // 1. components not able to mutate slot nodes
  10474. // 2. static slot content fails for hot-reloading
  10475. if (!isPlatformReservedTag(node.tag) &&
  10476. node.tag !== 'slot' &&
  10477. node.attrsMap['inline-template'] == null) {
  10478. return;
  10479. }
  10480. for (let i = 0, l = node.children.length; i < l; i++) {
  10481. const child = node.children[i];
  10482. markStatic(child);
  10483. if (!child.static) {
  10484. node.static = false;
  10485. }
  10486. }
  10487. if (node.ifConditions) {
  10488. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10489. const block = node.ifConditions[i].block;
  10490. markStatic(block);
  10491. if (!block.static) {
  10492. node.static = false;
  10493. }
  10494. }
  10495. }
  10496. }
  10497. }
  10498. function markStaticRoots(node, isInFor) {
  10499. if (node.type === 1) {
  10500. if (node.static || node.once) {
  10501. node.staticInFor = isInFor;
  10502. }
  10503. // For a node to qualify as a static root, it should have children that
  10504. // are not just static text. Otherwise the cost of hoisting out will
  10505. // outweigh the benefits and it's better off to just always render it fresh.
  10506. if (node.static &&
  10507. node.children.length &&
  10508. !(node.children.length === 1 && node.children[0].type === 3)) {
  10509. node.staticRoot = true;
  10510. return;
  10511. }
  10512. else {
  10513. node.staticRoot = false;
  10514. }
  10515. if (node.children) {
  10516. for (let i = 0, l = node.children.length; i < l; i++) {
  10517. markStaticRoots(node.children[i], isInFor || !!node.for);
  10518. }
  10519. }
  10520. if (node.ifConditions) {
  10521. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10522. markStaticRoots(node.ifConditions[i].block, isInFor);
  10523. }
  10524. }
  10525. }
  10526. }
  10527. function isStatic(node) {
  10528. if (node.type === 2) {
  10529. // expression
  10530. return false;
  10531. }
  10532. if (node.type === 3) {
  10533. // text
  10534. return true;
  10535. }
  10536. return !!(node.pre ||
  10537. (!node.hasBindings && // no dynamic bindings
  10538. !node.if &&
  10539. !node.for && // not v-if or v-for or v-else
  10540. !isBuiltInTag(node.tag) && // not a built-in
  10541. isPlatformReservedTag(node.tag) && // not a component
  10542. !isDirectChildOfTemplateFor(node) &&
  10543. Object.keys(node).every(isStaticKey)));
  10544. }
  10545. function isDirectChildOfTemplateFor(node) {
  10546. while (node.parent) {
  10547. node = node.parent;
  10548. if (node.tag !== 'template') {
  10549. return false;
  10550. }
  10551. if (node.for) {
  10552. return true;
  10553. }
  10554. }
  10555. return false;
  10556. }
  10557. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10558. const fnInvokeRE = /\([^)]*?\);*$/;
  10559. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10560. // KeyboardEvent.keyCode aliases
  10561. const keyCodes = {
  10562. esc: 27,
  10563. tab: 9,
  10564. enter: 13,
  10565. space: 32,
  10566. up: 38,
  10567. left: 37,
  10568. right: 39,
  10569. down: 40,
  10570. delete: [8, 46]
  10571. };
  10572. // KeyboardEvent.key aliases
  10573. const keyNames = {
  10574. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10575. esc: ['Esc', 'Escape'],
  10576. tab: 'Tab',
  10577. enter: 'Enter',
  10578. // #9112: IE11 uses `Spacebar` for Space key name.
  10579. space: [' ', 'Spacebar'],
  10580. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10581. up: ['Up', 'ArrowUp'],
  10582. left: ['Left', 'ArrowLeft'],
  10583. right: ['Right', 'ArrowRight'],
  10584. down: ['Down', 'ArrowDown'],
  10585. // #9112: IE11 uses `Del` for Delete key name.
  10586. delete: ['Backspace', 'Delete', 'Del']
  10587. };
  10588. // #4868: modifiers that prevent the execution of the listener
  10589. // need to explicitly return null so that we can determine whether to remove
  10590. // the listener for .once
  10591. const genGuard = condition => `if(${condition})return null;`;
  10592. const modifierCode = {
  10593. stop: '$event.stopPropagation();',
  10594. prevent: '$event.preventDefault();',
  10595. self: genGuard(`$event.target !== $event.currentTarget`),
  10596. ctrl: genGuard(`!$event.ctrlKey`),
  10597. shift: genGuard(`!$event.shiftKey`),
  10598. alt: genGuard(`!$event.altKey`),
  10599. meta: genGuard(`!$event.metaKey`),
  10600. left: genGuard(`'button' in $event && $event.button !== 0`),
  10601. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10602. right: genGuard(`'button' in $event && $event.button !== 2`)
  10603. };
  10604. function genHandlers(events, isNative) {
  10605. const prefix = isNative ? 'nativeOn:' : 'on:';
  10606. let staticHandlers = ``;
  10607. let dynamicHandlers = ``;
  10608. for (const name in events) {
  10609. const handlerCode = genHandler(events[name]);
  10610. //@ts-expect-error
  10611. if (events[name] && events[name].dynamic) {
  10612. dynamicHandlers += `${name},${handlerCode},`;
  10613. }
  10614. else {
  10615. staticHandlers += `"${name}":${handlerCode},`;
  10616. }
  10617. }
  10618. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10619. if (dynamicHandlers) {
  10620. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10621. }
  10622. else {
  10623. return prefix + staticHandlers;
  10624. }
  10625. }
  10626. function genHandler(handler) {
  10627. if (!handler) {
  10628. return 'function(){}';
  10629. }
  10630. if (Array.isArray(handler)) {
  10631. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10632. }
  10633. const isMethodPath = simplePathRE.test(handler.value);
  10634. const isFunctionExpression = fnExpRE.test(handler.value);
  10635. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10636. if (!handler.modifiers) {
  10637. if (isMethodPath || isFunctionExpression) {
  10638. return handler.value;
  10639. }
  10640. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10641. }
  10642. else {
  10643. let code = '';
  10644. let genModifierCode = '';
  10645. const keys = [];
  10646. for (const key in handler.modifiers) {
  10647. if (modifierCode[key]) {
  10648. genModifierCode += modifierCode[key];
  10649. // left/right
  10650. if (keyCodes[key]) {
  10651. keys.push(key);
  10652. }
  10653. }
  10654. else if (key === 'exact') {
  10655. const modifiers = handler.modifiers;
  10656. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10657. .filter(keyModifier => !modifiers[keyModifier])
  10658. .map(keyModifier => `$event.${keyModifier}Key`)
  10659. .join('||'));
  10660. }
  10661. else {
  10662. keys.push(key);
  10663. }
  10664. }
  10665. if (keys.length) {
  10666. code += genKeyFilter(keys);
  10667. }
  10668. // Make sure modifiers like prevent and stop get executed after key filtering
  10669. if (genModifierCode) {
  10670. code += genModifierCode;
  10671. }
  10672. const handlerCode = isMethodPath
  10673. ? `return ${handler.value}.apply(null, arguments)`
  10674. : isFunctionExpression
  10675. ? `return (${handler.value}).apply(null, arguments)`
  10676. : isFunctionInvocation
  10677. ? `return ${handler.value}`
  10678. : handler.value;
  10679. return `function($event){${code}${handlerCode}}`;
  10680. }
  10681. }
  10682. function genKeyFilter(keys) {
  10683. return (
  10684. // make sure the key filters only apply to KeyboardEvents
  10685. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10686. // key events that do not have keyCode property...
  10687. `if(!$event.type.indexOf('key')&&` +
  10688. `${keys.map(genFilterCode).join('&&')})return null;`);
  10689. }
  10690. function genFilterCode(key) {
  10691. const keyVal = parseInt(key, 10);
  10692. if (keyVal) {
  10693. return `$event.keyCode!==${keyVal}`;
  10694. }
  10695. const keyCode = keyCodes[key];
  10696. const keyName = keyNames[key];
  10697. return (`_k($event.keyCode,` +
  10698. `${JSON.stringify(key)},` +
  10699. `${JSON.stringify(keyCode)},` +
  10700. `$event.key,` +
  10701. `${JSON.stringify(keyName)}` +
  10702. `)`);
  10703. }
  10704. function on(el, dir) {
  10705. if (dir.modifiers) {
  10706. warn$2(`v-on without argument does not support modifiers.`);
  10707. }
  10708. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10709. }
  10710. function bind(el, dir) {
  10711. el.wrapData = (code) => {
  10712. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10713. };
  10714. }
  10715. var baseDirectives = {
  10716. on,
  10717. bind,
  10718. cloak: noop
  10719. };
  10720. class CodegenState {
  10721. constructor(options) {
  10722. this.options = options;
  10723. this.warn = options.warn || baseWarn;
  10724. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10725. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10726. this.directives = extend(extend({}, baseDirectives), options.directives);
  10727. const isReservedTag = options.isReservedTag || no;
  10728. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10729. this.onceId = 0;
  10730. this.staticRenderFns = [];
  10731. this.pre = false;
  10732. }
  10733. }
  10734. function generate(ast, options) {
  10735. const state = new CodegenState(options);
  10736. // fix #11483, Root level <script> tags should not be rendered.
  10737. const code = ast
  10738. ? ast.tag === 'script'
  10739. ? 'null'
  10740. : genElement(ast, state)
  10741. : '_c("div")';
  10742. return {
  10743. render: `with(this){return ${code}}`,
  10744. staticRenderFns: state.staticRenderFns
  10745. };
  10746. }
  10747. function genElement(el, state) {
  10748. if (el.parent) {
  10749. el.pre = el.pre || el.parent.pre;
  10750. }
  10751. if (el.staticRoot && !el.staticProcessed) {
  10752. return genStatic(el, state);
  10753. }
  10754. else if (el.once && !el.onceProcessed) {
  10755. return genOnce(el, state);
  10756. }
  10757. else if (el.for && !el.forProcessed) {
  10758. return genFor(el, state);
  10759. }
  10760. else if (el.if && !el.ifProcessed) {
  10761. return genIf(el, state);
  10762. }
  10763. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10764. return genChildren(el, state) || 'void 0';
  10765. }
  10766. else if (el.tag === 'slot') {
  10767. return genSlot(el, state);
  10768. }
  10769. else {
  10770. // component or element
  10771. let code;
  10772. if (el.component) {
  10773. code = genComponent(el.component, el, state);
  10774. }
  10775. else {
  10776. let data;
  10777. const maybeComponent = state.maybeComponent(el);
  10778. if (!el.plain || (el.pre && maybeComponent)) {
  10779. data = genData(el, state);
  10780. }
  10781. let tag;
  10782. // check if this is a component in <script setup>
  10783. const bindings = state.options.bindings;
  10784. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10785. tag = checkBindingType(bindings, el.tag);
  10786. }
  10787. if (!tag)
  10788. tag = `'${el.tag}'`;
  10789. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10790. code = `_c(${tag}${data ? `,${data}` : '' // data
  10791. }${children ? `,${children}` : '' // children
  10792. })`;
  10793. }
  10794. // module transforms
  10795. for (let i = 0; i < state.transforms.length; i++) {
  10796. code = state.transforms[i](el, code);
  10797. }
  10798. return code;
  10799. }
  10800. }
  10801. function checkBindingType(bindings, key) {
  10802. const camelName = camelize(key);
  10803. const PascalName = capitalize(camelName);
  10804. const checkType = (type) => {
  10805. if (bindings[key] === type) {
  10806. return key;
  10807. }
  10808. if (bindings[camelName] === type) {
  10809. return camelName;
  10810. }
  10811. if (bindings[PascalName] === type) {
  10812. return PascalName;
  10813. }
  10814. };
  10815. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10816. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10817. if (fromConst) {
  10818. return fromConst;
  10819. }
  10820. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10821. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10822. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10823. if (fromMaybeRef) {
  10824. return fromMaybeRef;
  10825. }
  10826. }
  10827. // hoist static sub-trees out
  10828. function genStatic(el, state) {
  10829. el.staticProcessed = true;
  10830. // Some elements (templates) need to behave differently inside of a v-pre
  10831. // node. All pre nodes are static roots, so we can use this as a location to
  10832. // wrap a state change and reset it upon exiting the pre node.
  10833. const originalPreState = state.pre;
  10834. if (el.pre) {
  10835. state.pre = el.pre;
  10836. }
  10837. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10838. state.pre = originalPreState;
  10839. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10840. }
  10841. // v-once
  10842. function genOnce(el, state) {
  10843. el.onceProcessed = true;
  10844. if (el.if && !el.ifProcessed) {
  10845. return genIf(el, state);
  10846. }
  10847. else if (el.staticInFor) {
  10848. let key = '';
  10849. let parent = el.parent;
  10850. while (parent) {
  10851. if (parent.for) {
  10852. key = parent.key;
  10853. break;
  10854. }
  10855. parent = parent.parent;
  10856. }
  10857. if (!key) {
  10858. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10859. return genElement(el, state);
  10860. }
  10861. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10862. }
  10863. else {
  10864. return genStatic(el, state);
  10865. }
  10866. }
  10867. function genIf(el, state, altGen, altEmpty) {
  10868. el.ifProcessed = true; // avoid recursion
  10869. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10870. }
  10871. function genIfConditions(conditions, state, altGen, altEmpty) {
  10872. if (!conditions.length) {
  10873. return altEmpty || '_e()';
  10874. }
  10875. const condition = conditions.shift();
  10876. if (condition.exp) {
  10877. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10878. }
  10879. else {
  10880. return `${genTernaryExp(condition.block)}`;
  10881. }
  10882. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10883. function genTernaryExp(el) {
  10884. return altGen
  10885. ? altGen(el, state)
  10886. : el.once
  10887. ? genOnce(el, state)
  10888. : genElement(el, state);
  10889. }
  10890. }
  10891. function genFor(el, state, altGen, altHelper) {
  10892. const exp = el.for;
  10893. const alias = el.alias;
  10894. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10895. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10896. if (state.maybeComponent(el) &&
  10897. el.tag !== 'slot' &&
  10898. el.tag !== 'template' &&
  10899. !el.key) {
  10900. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10901. `v-for should have explicit keys. ` +
  10902. `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10903. }
  10904. el.forProcessed = true; // avoid recursion
  10905. return (`${altHelper || '_l'}((${exp}),` +
  10906. `function(${alias}${iterator1}${iterator2}){` +
  10907. `return ${(altGen || genElement)(el, state)}` +
  10908. '})');
  10909. }
  10910. function genData(el, state) {
  10911. let data = '{';
  10912. // directives first.
  10913. // directives may mutate the el's other properties before they are generated.
  10914. const dirs = genDirectives(el, state);
  10915. if (dirs)
  10916. data += dirs + ',';
  10917. // key
  10918. if (el.key) {
  10919. data += `key:${el.key},`;
  10920. }
  10921. // ref
  10922. if (el.ref) {
  10923. data += `ref:${el.ref},`;
  10924. }
  10925. if (el.refInFor) {
  10926. data += `refInFor:true,`;
  10927. }
  10928. // pre
  10929. if (el.pre) {
  10930. data += `pre:true,`;
  10931. }
  10932. // record original tag name for components using "is" attribute
  10933. if (el.component) {
  10934. data += `tag:"${el.tag}",`;
  10935. }
  10936. // module data generation functions
  10937. for (let i = 0; i < state.dataGenFns.length; i++) {
  10938. data += state.dataGenFns[i](el);
  10939. }
  10940. // attributes
  10941. if (el.attrs) {
  10942. data += `attrs:${genProps(el.attrs)},`;
  10943. }
  10944. // DOM props
  10945. if (el.props) {
  10946. data += `domProps:${genProps(el.props)},`;
  10947. }
  10948. // event handlers
  10949. if (el.events) {
  10950. data += `${genHandlers(el.events, false)},`;
  10951. }
  10952. if (el.nativeEvents) {
  10953. data += `${genHandlers(el.nativeEvents, true)},`;
  10954. }
  10955. // slot target
  10956. // only for non-scoped slots
  10957. if (el.slotTarget && !el.slotScope) {
  10958. data += `slot:${el.slotTarget},`;
  10959. }
  10960. // scoped slots
  10961. if (el.scopedSlots) {
  10962. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10963. }
  10964. // component v-model
  10965. if (el.model) {
  10966. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10967. }
  10968. // inline-template
  10969. if (el.inlineTemplate) {
  10970. const inlineTemplate = genInlineTemplate(el, state);
  10971. if (inlineTemplate) {
  10972. data += `${inlineTemplate},`;
  10973. }
  10974. }
  10975. data = data.replace(/,$/, '') + '}';
  10976. // v-bind dynamic argument wrap
  10977. // v-bind with dynamic arguments must be applied using the same v-bind object
  10978. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10979. if (el.dynamicAttrs) {
  10980. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10981. }
  10982. // v-bind data wrap
  10983. if (el.wrapData) {
  10984. data = el.wrapData(data);
  10985. }
  10986. // v-on data wrap
  10987. if (el.wrapListeners) {
  10988. data = el.wrapListeners(data);
  10989. }
  10990. return data;
  10991. }
  10992. function genDirectives(el, state) {
  10993. const dirs = el.directives;
  10994. if (!dirs)
  10995. return;
  10996. let res = 'directives:[';
  10997. let hasRuntime = false;
  10998. let i, l, dir, needRuntime;
  10999. for (i = 0, l = dirs.length; i < l; i++) {
  11000. dir = dirs[i];
  11001. needRuntime = true;
  11002. const gen = state.directives[dir.name];
  11003. if (gen) {
  11004. // compile-time directive that manipulates AST.
  11005. // returns true if it also needs a runtime counterpart.
  11006. needRuntime = !!gen(el, dir, state.warn);
  11007. }
  11008. if (needRuntime) {
  11009. hasRuntime = true;
  11010. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11011. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11012. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11013. }
  11014. }
  11015. if (hasRuntime) {
  11016. return res.slice(0, -1) + ']';
  11017. }
  11018. }
  11019. function genInlineTemplate(el, state) {
  11020. const ast = el.children[0];
  11021. if ((el.children.length !== 1 || ast.type !== 1)) {
  11022. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11023. }
  11024. if (ast && ast.type === 1) {
  11025. const inlineRenderFns = generate(ast, state.options);
  11026. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11027. .map(code => `function(){${code}}`)
  11028. .join(',')}]}`;
  11029. }
  11030. }
  11031. function genScopedSlots(el, slots, state) {
  11032. // by default scoped slots are considered "stable", this allows child
  11033. // components with only scoped slots to skip forced updates from parent.
  11034. // but in some cases we have to bail-out of this optimization
  11035. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11036. let needsForceUpdate = el.for ||
  11037. Object.keys(slots).some(key => {
  11038. const slot = slots[key];
  11039. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11040. );
  11041. });
  11042. // #9534: if a component with scoped slots is inside a conditional branch,
  11043. // it's possible for the same component to be reused but with different
  11044. // compiled slot content. To avoid that, we generate a unique key based on
  11045. // the generated code of all the slot contents.
  11046. let needsKey = !!el.if;
  11047. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11048. // disconnected due to the intermediate scope variable)
  11049. // #9438, #9506
  11050. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11051. // and skip force updating ones that do not actually use scope variables.
  11052. if (!needsForceUpdate) {
  11053. let parent = el.parent;
  11054. while (parent) {
  11055. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11056. parent.for) {
  11057. needsForceUpdate = true;
  11058. break;
  11059. }
  11060. if (parent.if) {
  11061. needsKey = true;
  11062. }
  11063. parent = parent.parent;
  11064. }
  11065. }
  11066. const generatedSlots = Object.keys(slots)
  11067. .map(key => genScopedSlot(slots[key], state))
  11068. .join(',');
  11069. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11070. }
  11071. function hash(str) {
  11072. let hash = 5381;
  11073. let i = str.length;
  11074. while (i) {
  11075. hash = (hash * 33) ^ str.charCodeAt(--i);
  11076. }
  11077. return hash >>> 0;
  11078. }
  11079. function containsSlotChild(el) {
  11080. if (el.type === 1) {
  11081. if (el.tag === 'slot') {
  11082. return true;
  11083. }
  11084. return el.children.some(containsSlotChild);
  11085. }
  11086. return false;
  11087. }
  11088. function genScopedSlot(el, state) {
  11089. const isLegacySyntax = el.attrsMap['slot-scope'];
  11090. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11091. return genIf(el, state, genScopedSlot, `null`);
  11092. }
  11093. if (el.for && !el.forProcessed) {
  11094. return genFor(el, state, genScopedSlot);
  11095. }
  11096. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11097. const fn = `function(${slotScope}){` +
  11098. `return ${el.tag === 'template'
  11099. ? el.if && isLegacySyntax
  11100. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11101. : genChildren(el, state) || 'undefined'
  11102. : genElement(el, state)}}`;
  11103. // reverse proxy v-slot without scope on this.$slots
  11104. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11105. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11106. }
  11107. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11108. const children = el.children;
  11109. if (children.length) {
  11110. const el = children[0];
  11111. // optimize single v-for
  11112. if (children.length === 1 &&
  11113. el.for &&
  11114. el.tag !== 'template' &&
  11115. el.tag !== 'slot') {
  11116. const normalizationType = checkSkip
  11117. ? state.maybeComponent(el)
  11118. ? `,1`
  11119. : `,0`
  11120. : ``;
  11121. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11122. }
  11123. const normalizationType = checkSkip
  11124. ? getNormalizationType(children, state.maybeComponent)
  11125. : 0;
  11126. const gen = altGenNode || genNode;
  11127. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11128. }
  11129. }
  11130. // determine the normalization needed for the children array.
  11131. // 0: no normalization needed
  11132. // 1: simple normalization needed (possible 1-level deep nested array)
  11133. // 2: full normalization needed
  11134. function getNormalizationType(children, maybeComponent) {
  11135. let res = 0;
  11136. for (let i = 0; i < children.length; i++) {
  11137. const el = children[i];
  11138. if (el.type !== 1) {
  11139. continue;
  11140. }
  11141. if (needsNormalization(el) ||
  11142. (el.ifConditions &&
  11143. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11144. res = 2;
  11145. break;
  11146. }
  11147. if (maybeComponent(el) ||
  11148. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11149. res = 1;
  11150. }
  11151. }
  11152. return res;
  11153. }
  11154. function needsNormalization(el) {
  11155. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11156. }
  11157. function genNode(node, state) {
  11158. if (node.type === 1) {
  11159. return genElement(node, state);
  11160. }
  11161. else if (node.type === 3 && node.isComment) {
  11162. return genComment(node);
  11163. }
  11164. else {
  11165. return genText(node);
  11166. }
  11167. }
  11168. function genText(text) {
  11169. return `_v(${text.type === 2
  11170. ? text.expression // no need for () because already wrapped in _s()
  11171. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11172. }
  11173. function genComment(comment) {
  11174. return `_e(${JSON.stringify(comment.text)})`;
  11175. }
  11176. function genSlot(el, state) {
  11177. const slotName = el.slotName || '"default"';
  11178. const children = genChildren(el, state);
  11179. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11180. const attrs = el.attrs || el.dynamicAttrs
  11181. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11182. // slot props are camelized
  11183. name: camelize(attr.name),
  11184. value: attr.value,
  11185. dynamic: attr.dynamic
  11186. })))
  11187. : null;
  11188. const bind = el.attrsMap['v-bind'];
  11189. if ((attrs || bind) && !children) {
  11190. res += `,null`;
  11191. }
  11192. if (attrs) {
  11193. res += `,${attrs}`;
  11194. }
  11195. if (bind) {
  11196. res += `${attrs ? '' : ',null'},${bind}`;
  11197. }
  11198. return res + ')';
  11199. }
  11200. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11201. function genComponent(componentName, el, state) {
  11202. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11203. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11204. }
  11205. function genProps(props) {
  11206. let staticProps = ``;
  11207. let dynamicProps = ``;
  11208. for (let i = 0; i < props.length; i++) {
  11209. const prop = props[i];
  11210. const value = transformSpecialNewlines(prop.value);
  11211. if (prop.dynamic) {
  11212. dynamicProps += `${prop.name},${value},`;
  11213. }
  11214. else {
  11215. staticProps += `"${prop.name}":${value},`;
  11216. }
  11217. }
  11218. staticProps = `{${staticProps.slice(0, -1)}}`;
  11219. if (dynamicProps) {
  11220. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11221. }
  11222. else {
  11223. return staticProps;
  11224. }
  11225. }
  11226. // #3895, #4268
  11227. function transformSpecialNewlines(text) {
  11228. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11229. }
  11230. // these keywords should not appear inside expressions, but operators like
  11231. // typeof, instanceof and in are allowed
  11232. const prohibitedKeywordRE = new RegExp('\\b' +
  11233. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11234. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11235. 'extends,finally,continue,debugger,function,arguments')
  11236. .split(',')
  11237. .join('\\b|\\b') +
  11238. '\\b');
  11239. // these unary operators should not be used as property/method names
  11240. const unaryOperatorsRE = new RegExp('\\b' +
  11241. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11242. '\\s*\\([^\\)]*\\)');
  11243. // strip strings in expressions
  11244. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11245. // detect problematic expressions in a template
  11246. function detectErrors(ast, warn) {
  11247. if (ast) {
  11248. checkNode(ast, warn);
  11249. }
  11250. }
  11251. function checkNode(node, warn) {
  11252. if (node.type === 1) {
  11253. for (const name in node.attrsMap) {
  11254. if (dirRE.test(name)) {
  11255. const value = node.attrsMap[name];
  11256. if (value) {
  11257. const range = node.rawAttrsMap[name];
  11258. if (name === 'v-for') {
  11259. checkFor(node, `v-for="${value}"`, warn, range);
  11260. }
  11261. else if (name === 'v-slot' || name[0] === '#') {
  11262. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11263. }
  11264. else if (onRE.test(name)) {
  11265. checkEvent(value, `${name}="${value}"`, warn, range);
  11266. }
  11267. else {
  11268. checkExpression(value, `${name}="${value}"`, warn, range);
  11269. }
  11270. }
  11271. }
  11272. }
  11273. if (node.children) {
  11274. for (let i = 0; i < node.children.length; i++) {
  11275. checkNode(node.children[i], warn);
  11276. }
  11277. }
  11278. }
  11279. else if (node.type === 2) {
  11280. checkExpression(node.expression, node.text, warn, node);
  11281. }
  11282. }
  11283. function checkEvent(exp, text, warn, range) {
  11284. const stripped = exp.replace(stripStringRE, '');
  11285. const keywordMatch = stripped.match(unaryOperatorsRE);
  11286. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11287. warn(`avoid using JavaScript unary operator as property name: ` +
  11288. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11289. }
  11290. checkExpression(exp, text, warn, range);
  11291. }
  11292. function checkFor(node, text, warn, range) {
  11293. checkExpression(node.for || '', text, warn, range);
  11294. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11295. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11296. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11297. }
  11298. function checkIdentifier(ident, type, text, warn, range) {
  11299. if (typeof ident === 'string') {
  11300. try {
  11301. new Function(`var ${ident}=_`);
  11302. }
  11303. catch (e) {
  11304. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11305. }
  11306. }
  11307. }
  11308. function checkExpression(exp, text, warn, range) {
  11309. try {
  11310. new Function(`return ${exp}`);
  11311. }
  11312. catch (e) {
  11313. const keywordMatch = exp
  11314. .replace(stripStringRE, '')
  11315. .match(prohibitedKeywordRE);
  11316. if (keywordMatch) {
  11317. warn(`avoid using JavaScript keyword as property name: ` +
  11318. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11319. }
  11320. else {
  11321. warn(`invalid expression: ${e.message} in\n\n` +
  11322. ` ${exp}\n\n` +
  11323. ` Raw expression: ${text.trim()}\n`, range);
  11324. }
  11325. }
  11326. }
  11327. function checkFunctionParameterExpression(exp, text, warn, range) {
  11328. try {
  11329. new Function(exp, '');
  11330. }
  11331. catch (e) {
  11332. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11333. ` ${exp}\n\n` +
  11334. ` Raw expression: ${text.trim()}\n`, range);
  11335. }
  11336. }
  11337. const range = 2;
  11338. function generateCodeFrame(source, start = 0, end = source.length) {
  11339. const lines = source.split(/\r?\n/);
  11340. let count = 0;
  11341. const res = [];
  11342. for (let i = 0; i < lines.length; i++) {
  11343. count += lines[i].length + 1;
  11344. if (count >= start) {
  11345. for (let j = i - range; j <= i + range || end > count; j++) {
  11346. if (j < 0 || j >= lines.length)
  11347. continue;
  11348. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11349. const lineLength = lines[j].length;
  11350. if (j === i) {
  11351. // push underline
  11352. const pad = start - (count - lineLength) + 1;
  11353. const length = end > count ? lineLength - pad : end - start;
  11354. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11355. }
  11356. else if (j > i) {
  11357. if (end > count) {
  11358. const length = Math.min(end - count, lineLength);
  11359. res.push(` | ` + repeat(`^`, length));
  11360. }
  11361. count += lineLength + 1;
  11362. }
  11363. }
  11364. break;
  11365. }
  11366. }
  11367. return res.join('\n');
  11368. }
  11369. function repeat(str, n) {
  11370. let result = '';
  11371. if (n > 0) {
  11372. // eslint-disable-next-line no-constant-condition
  11373. while (true) {
  11374. // eslint-disable-line
  11375. if (n & 1)
  11376. result += str;
  11377. n >>>= 1;
  11378. if (n <= 0)
  11379. break;
  11380. str += str;
  11381. }
  11382. }
  11383. return result;
  11384. }
  11385. function createFunction(code, errors) {
  11386. try {
  11387. return new Function(code);
  11388. }
  11389. catch (err) {
  11390. errors.push({ err, code });
  11391. return noop;
  11392. }
  11393. }
  11394. function createCompileToFunctionFn(compile) {
  11395. const cache = Object.create(null);
  11396. return function compileToFunctions(template, options, vm) {
  11397. options = extend({}, options);
  11398. const warn = options.warn || warn$2;
  11399. delete options.warn;
  11400. /* istanbul ignore if */
  11401. {
  11402. // detect possible CSP restriction
  11403. try {
  11404. new Function('return 1');
  11405. }
  11406. catch (e) {
  11407. if (e.toString().match(/unsafe-eval|CSP/)) {
  11408. warn('It seems you are using the standalone build of Vue.js in an ' +
  11409. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11410. 'The template compiler cannot work in this environment. Consider ' +
  11411. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11412. 'templates into render functions.');
  11413. }
  11414. }
  11415. }
  11416. // check cache
  11417. const key = options.delimiters
  11418. ? String(options.delimiters) + template
  11419. : template;
  11420. if (cache[key]) {
  11421. return cache[key];
  11422. }
  11423. // compile
  11424. const compiled = compile(template, options);
  11425. // check compilation errors/tips
  11426. {
  11427. if (compiled.errors && compiled.errors.length) {
  11428. if (options.outputSourceRange) {
  11429. compiled.errors.forEach(e => {
  11430. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11431. generateCodeFrame(template, e.start, e.end), vm);
  11432. });
  11433. }
  11434. else {
  11435. warn(`Error compiling template:\n\n${template}\n\n` +
  11436. compiled.errors.map(e => `- ${e}`).join('\n') +
  11437. '\n', vm);
  11438. }
  11439. }
  11440. if (compiled.tips && compiled.tips.length) {
  11441. if (options.outputSourceRange) {
  11442. compiled.tips.forEach(e => tip(e.msg, vm));
  11443. }
  11444. else {
  11445. compiled.tips.forEach(msg => tip(msg, vm));
  11446. }
  11447. }
  11448. }
  11449. // turn code into functions
  11450. const res = {};
  11451. const fnGenErrors = [];
  11452. res.render = createFunction(compiled.render, fnGenErrors);
  11453. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11454. return createFunction(code, fnGenErrors);
  11455. });
  11456. // check function generation errors.
  11457. // this should only happen if there is a bug in the compiler itself.
  11458. // mostly for codegen development use
  11459. /* istanbul ignore if */
  11460. {
  11461. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11462. warn(`Failed to generate render function:\n\n` +
  11463. fnGenErrors
  11464. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11465. .join('\n'), vm);
  11466. }
  11467. }
  11468. return (cache[key] = res);
  11469. };
  11470. }
  11471. function createCompilerCreator(baseCompile) {
  11472. return function createCompiler(baseOptions) {
  11473. function compile(template, options) {
  11474. const finalOptions = Object.create(baseOptions);
  11475. const errors = [];
  11476. const tips = [];
  11477. let warn = (msg, range, tip) => {
  11478. (tip ? tips : errors).push(msg);
  11479. };
  11480. if (options) {
  11481. if (options.outputSourceRange) {
  11482. // $flow-disable-line
  11483. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11484. warn = (msg, range, tip) => {
  11485. const data = typeof msg === 'string' ? { msg } : msg;
  11486. if (range) {
  11487. if (range.start != null) {
  11488. data.start = range.start + leadingSpaceLength;
  11489. }
  11490. if (range.end != null) {
  11491. data.end = range.end + leadingSpaceLength;
  11492. }
  11493. }
  11494. (tip ? tips : errors).push(data);
  11495. };
  11496. }
  11497. // merge custom modules
  11498. if (options.modules) {
  11499. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11500. }
  11501. // merge custom directives
  11502. if (options.directives) {
  11503. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11504. }
  11505. // copy other options
  11506. for (const key in options) {
  11507. if (key !== 'modules' && key !== 'directives') {
  11508. finalOptions[key] = options[key];
  11509. }
  11510. }
  11511. }
  11512. finalOptions.warn = warn;
  11513. const compiled = baseCompile(template.trim(), finalOptions);
  11514. {
  11515. detectErrors(compiled.ast, warn);
  11516. }
  11517. compiled.errors = errors;
  11518. compiled.tips = tips;
  11519. return compiled;
  11520. }
  11521. return {
  11522. compile,
  11523. compileToFunctions: createCompileToFunctionFn(compile)
  11524. };
  11525. };
  11526. }
  11527. // `createCompilerCreator` allows creating compilers that use alternative
  11528. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11529. // Here we just export a default compiler using the default parts.
  11530. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11531. const ast = parse(template.trim(), options);
  11532. if (options.optimize !== false) {
  11533. optimize(ast, options);
  11534. }
  11535. const code = generate(ast, options);
  11536. return {
  11537. ast,
  11538. render: code.render,
  11539. staticRenderFns: code.staticRenderFns
  11540. };
  11541. });
  11542. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11543. // check whether current browser encodes a char inside attribute values
  11544. let div;
  11545. function getShouldDecode(href) {
  11546. div = div || document.createElement('div');
  11547. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11548. return div.innerHTML.indexOf('&#10;') > 0;
  11549. }
  11550. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11551. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11552. // #6828: chrome encodes content in a[href]
  11553. const shouldDecodeNewlinesForHref = inBrowser
  11554. ? getShouldDecode(true)
  11555. : false;
  11556. const idToTemplate = cached(id => {
  11557. const el = query(id);
  11558. return el && el.innerHTML;
  11559. });
  11560. const mount = Vue.prototype.$mount;
  11561. Vue.prototype.$mount = function (el, hydrating) {
  11562. el = el && query(el);
  11563. /* istanbul ignore if */
  11564. if (el === document.body || el === document.documentElement) {
  11565. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11566. return this;
  11567. }
  11568. const options = this.$options;
  11569. // resolve template/el and convert to render function
  11570. if (!options.render) {
  11571. let template = options.template;
  11572. if (template) {
  11573. if (typeof template === 'string') {
  11574. if (template.charAt(0) === '#') {
  11575. template = idToTemplate(template);
  11576. /* istanbul ignore if */
  11577. if (!template) {
  11578. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11579. }
  11580. }
  11581. }
  11582. else if (template.nodeType) {
  11583. template = template.innerHTML;
  11584. }
  11585. else {
  11586. {
  11587. warn$2('invalid template option:' + template, this);
  11588. }
  11589. return this;
  11590. }
  11591. }
  11592. else if (el) {
  11593. // @ts-expect-error
  11594. template = getOuterHTML(el);
  11595. }
  11596. if (template) {
  11597. /* istanbul ignore if */
  11598. if (config.performance && mark) {
  11599. mark('compile');
  11600. }
  11601. const { render, staticRenderFns } = compileToFunctions(template, {
  11602. outputSourceRange: true,
  11603. shouldDecodeNewlines,
  11604. shouldDecodeNewlinesForHref,
  11605. delimiters: options.delimiters,
  11606. comments: options.comments
  11607. }, this);
  11608. options.render = render;
  11609. options.staticRenderFns = staticRenderFns;
  11610. /* istanbul ignore if */
  11611. if (config.performance && mark) {
  11612. mark('compile end');
  11613. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11614. }
  11615. }
  11616. }
  11617. return mount.call(this, el, hydrating);
  11618. };
  11619. /**
  11620. * Get outerHTML of elements, taking care
  11621. * of SVG elements in IE as well.
  11622. */
  11623. function getOuterHTML(el) {
  11624. if (el.outerHTML) {
  11625. return el.outerHTML;
  11626. }
  11627. else {
  11628. const container = document.createElement('div');
  11629. container.appendChild(el.cloneNode(true));
  11630. return container.innerHTML;
  11631. }
  11632. }
  11633. Vue.compile = compileToFunctions;
  11634. // export type EffectScheduler = (...args: any[]) => any
  11635. /**
  11636. * @internal since we are not exposing this in Vue 2, it's used only for
  11637. * internal testing.
  11638. */
  11639. function effect(fn, scheduler) {
  11640. const watcher = new Watcher(currentInstance, fn, noop, {
  11641. sync: true
  11642. });
  11643. if (scheduler) {
  11644. watcher.update = () => {
  11645. scheduler(() => watcher.run());
  11646. };
  11647. }
  11648. }
  11649. extend(Vue, vca);
  11650. Vue.effect = effect;
  11651. module.exports = Vue;