vue.common.dev.js 390 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818
  1. /*!
  2. * Vue.js v2.7.16
  3. * (c) 2014-2023 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, replacer, 2)
  81. : String(val);
  82. }
  83. function replacer(_key, val) {
  84. // avoid circular deps from v3
  85. if (val && val.__v_isRef) {
  86. return val.value;
  87. }
  88. return val;
  89. }
  90. /**
  91. * Convert an input value to a number for persistence.
  92. * If the conversion fails, return original string.
  93. */
  94. function toNumber(val) {
  95. const n = parseFloat(val);
  96. return isNaN(n) ? val : n;
  97. }
  98. /**
  99. * Make a map and return a function for checking if a key
  100. * is in that map.
  101. */
  102. function makeMap(str, expectsLowerCase) {
  103. const map = Object.create(null);
  104. const list = str.split(',');
  105. for (let i = 0; i < list.length; i++) {
  106. map[list[i]] = true;
  107. }
  108. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  109. }
  110. /**
  111. * Check if a tag is a built-in tag.
  112. */
  113. const isBuiltInTag = makeMap('slot,component', true);
  114. /**
  115. * Check if an attribute is a reserved attribute.
  116. */
  117. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  118. /**
  119. * Remove an item from an array.
  120. */
  121. function remove$2(arr, item) {
  122. const len = arr.length;
  123. if (len) {
  124. // fast path for the only / last item
  125. if (item === arr[len - 1]) {
  126. arr.length = len - 1;
  127. return;
  128. }
  129. const index = arr.indexOf(item);
  130. if (index > -1) {
  131. return arr.splice(index, 1);
  132. }
  133. }
  134. }
  135. /**
  136. * Check whether an object has the property.
  137. */
  138. const hasOwnProperty = Object.prototype.hasOwnProperty;
  139. function hasOwn(obj, key) {
  140. return hasOwnProperty.call(obj, key);
  141. }
  142. /**
  143. * Create a cached version of a pure function.
  144. */
  145. function cached(fn) {
  146. const cache = Object.create(null);
  147. return function cachedFn(str) {
  148. const hit = cache[str];
  149. return hit || (cache[str] = fn(str));
  150. };
  151. }
  152. /**
  153. * Camelize a hyphen-delimited string.
  154. */
  155. const camelizeRE = /-(\w)/g;
  156. const camelize = cached((str) => {
  157. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  158. });
  159. /**
  160. * Capitalize a string.
  161. */
  162. const capitalize = cached((str) => {
  163. return str.charAt(0).toUpperCase() + str.slice(1);
  164. });
  165. /**
  166. * Hyphenate a camelCase string.
  167. */
  168. const hyphenateRE = /\B([A-Z])/g;
  169. const hyphenate = cached((str) => {
  170. return str.replace(hyphenateRE, '-$1').toLowerCase();
  171. });
  172. /**
  173. * Simple bind polyfill for environments that do not support it,
  174. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  175. * since native bind is now performant enough in most browsers.
  176. * But removing it would mean breaking code that was able to run in
  177. * PhantomJS 1.x, so this must be kept for backward compatibility.
  178. */
  179. /* istanbul ignore next */
  180. function polyfillBind(fn, ctx) {
  181. function boundFn(a) {
  182. const l = arguments.length;
  183. return l
  184. ? l > 1
  185. ? fn.apply(ctx, arguments)
  186. : fn.call(ctx, a)
  187. : fn.call(ctx);
  188. }
  189. boundFn._length = fn.length;
  190. return boundFn;
  191. }
  192. function nativeBind(fn, ctx) {
  193. return fn.bind(ctx);
  194. }
  195. // @ts-expect-error bind cannot be `undefined`
  196. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  197. /**
  198. * Convert an Array-like object to a real Array.
  199. */
  200. function toArray(list, start) {
  201. start = start || 0;
  202. let i = list.length - start;
  203. const ret = new Array(i);
  204. while (i--) {
  205. ret[i] = list[i + start];
  206. }
  207. return ret;
  208. }
  209. /**
  210. * Mix properties into target object.
  211. */
  212. function extend(to, _from) {
  213. for (const key in _from) {
  214. to[key] = _from[key];
  215. }
  216. return to;
  217. }
  218. /**
  219. * Merge an Array of Objects into a single Object.
  220. */
  221. function toObject(arr) {
  222. const res = {};
  223. for (let i = 0; i < arr.length; i++) {
  224. if (arr[i]) {
  225. extend(res, arr[i]);
  226. }
  227. }
  228. return res;
  229. }
  230. /* eslint-disable no-unused-vars */
  231. /**
  232. * Perform no operation.
  233. * Stubbing args to make Flow happy without leaving useless transpiled code
  234. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  235. */
  236. function noop(a, b, c) { }
  237. /**
  238. * Always return false.
  239. */
  240. const no = (a, b, c) => false;
  241. /* eslint-enable no-unused-vars */
  242. /**
  243. * Return the same value.
  244. */
  245. const identity = (_) => _;
  246. /**
  247. * Generate a string containing static keys from compiler modules.
  248. */
  249. function genStaticKeys$1(modules) {
  250. return modules
  251. .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
  252. .join(',');
  253. }
  254. /**
  255. * Check if two values are loosely equal - that is,
  256. * if they are plain objects, do they have the same shape?
  257. */
  258. function looseEqual(a, b) {
  259. if (a === b)
  260. return true;
  261. const isObjectA = isObject(a);
  262. const isObjectB = isObject(b);
  263. if (isObjectA && isObjectB) {
  264. try {
  265. const isArrayA = Array.isArray(a);
  266. const isArrayB = Array.isArray(b);
  267. if (isArrayA && isArrayB) {
  268. return (a.length === b.length &&
  269. a.every((e, i) => {
  270. return looseEqual(e, b[i]);
  271. }));
  272. }
  273. else if (a instanceof Date && b instanceof Date) {
  274. return a.getTime() === b.getTime();
  275. }
  276. else if (!isArrayA && !isArrayB) {
  277. const keysA = Object.keys(a);
  278. const keysB = Object.keys(b);
  279. return (keysA.length === keysB.length &&
  280. keysA.every(key => {
  281. return looseEqual(a[key], b[key]);
  282. }));
  283. }
  284. else {
  285. /* istanbul ignore next */
  286. return false;
  287. }
  288. }
  289. catch (e) {
  290. /* istanbul ignore next */
  291. return false;
  292. }
  293. }
  294. else if (!isObjectA && !isObjectB) {
  295. return String(a) === String(b);
  296. }
  297. else {
  298. return false;
  299. }
  300. }
  301. /**
  302. * Return the first index at which a loosely equal value can be
  303. * found in the array (if value is a plain object, the array must
  304. * contain an object of the same shape), or -1 if it is not present.
  305. */
  306. function looseIndexOf(arr, val) {
  307. for (let i = 0; i < arr.length; i++) {
  308. if (looseEqual(arr[i], val))
  309. return i;
  310. }
  311. return -1;
  312. }
  313. /**
  314. * Ensure a function is called only once.
  315. */
  316. function once(fn) {
  317. let called = false;
  318. return function () {
  319. if (!called) {
  320. called = true;
  321. fn.apply(this, arguments);
  322. }
  323. };
  324. }
  325. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  326. function hasChanged(x, y) {
  327. if (x === y) {
  328. return x === 0 && 1 / x !== 1 / y;
  329. }
  330. else {
  331. return x === x || y === y;
  332. }
  333. }
  334. const SSR_ATTR = 'data-server-rendered';
  335. const ASSET_TYPES = ['component', 'directive', 'filter'];
  336. const LIFECYCLE_HOOKS = [
  337. 'beforeCreate',
  338. 'created',
  339. 'beforeMount',
  340. 'mounted',
  341. 'beforeUpdate',
  342. 'updated',
  343. 'beforeDestroy',
  344. 'destroyed',
  345. 'activated',
  346. 'deactivated',
  347. 'errorCaptured',
  348. 'serverPrefetch',
  349. 'renderTracked',
  350. 'renderTriggered'
  351. ];
  352. var config = {
  353. /**
  354. * Option merge strategies (used in core/util/options)
  355. */
  356. // $flow-disable-line
  357. optionMergeStrategies: Object.create(null),
  358. /**
  359. * Whether to suppress warnings.
  360. */
  361. silent: false,
  362. /**
  363. * Show production mode tip message on boot?
  364. */
  365. productionTip: true,
  366. /**
  367. * Whether to enable devtools
  368. */
  369. devtools: true,
  370. /**
  371. * Whether to record perf
  372. */
  373. performance: false,
  374. /**
  375. * Error handler for watcher errors
  376. */
  377. errorHandler: null,
  378. /**
  379. * Warn handler for watcher warns
  380. */
  381. warnHandler: null,
  382. /**
  383. * Ignore certain custom elements
  384. */
  385. ignoredElements: [],
  386. /**
  387. * Custom user key aliases for v-on
  388. */
  389. // $flow-disable-line
  390. keyCodes: Object.create(null),
  391. /**
  392. * Check if a tag is reserved so that it cannot be registered as a
  393. * component. This is platform-dependent and may be overwritten.
  394. */
  395. isReservedTag: no,
  396. /**
  397. * Check if an attribute is reserved so that it cannot be used as a component
  398. * prop. This is platform-dependent and may be overwritten.
  399. */
  400. isReservedAttr: no,
  401. /**
  402. * Check if a tag is an unknown element.
  403. * Platform-dependent.
  404. */
  405. isUnknownElement: no,
  406. /**
  407. * Get the namespace of an element
  408. */
  409. getTagNamespace: noop,
  410. /**
  411. * Parse the real tag name for the specific platform.
  412. */
  413. parsePlatformTagName: identity,
  414. /**
  415. * Check if an attribute must be bound using property, e.g. value
  416. * Platform-dependent.
  417. */
  418. mustUseProp: no,
  419. /**
  420. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  421. * This will significantly reduce performance if set to false.
  422. */
  423. async: true,
  424. /**
  425. * Exposed for legacy reasons
  426. */
  427. _lifecycleHooks: LIFECYCLE_HOOKS
  428. };
  429. /**
  430. * unicode letters used for parsing html tags, component names and property paths.
  431. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  432. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  433. */
  434. 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/;
  435. /**
  436. * Check if a string starts with $ or _
  437. */
  438. function isReserved(str) {
  439. const c = (str + '').charCodeAt(0);
  440. return c === 0x24 || c === 0x5f;
  441. }
  442. /**
  443. * Define a property.
  444. */
  445. function def(obj, key, val, enumerable) {
  446. Object.defineProperty(obj, key, {
  447. value: val,
  448. enumerable: !!enumerable,
  449. writable: true,
  450. configurable: true
  451. });
  452. }
  453. /**
  454. * Parse simple path.
  455. */
  456. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  457. function parsePath(path) {
  458. if (bailRE.test(path)) {
  459. return;
  460. }
  461. const segments = path.split('.');
  462. return function (obj) {
  463. for (let i = 0; i < segments.length; i++) {
  464. if (!obj)
  465. return;
  466. obj = obj[segments[i]];
  467. }
  468. return obj;
  469. };
  470. }
  471. // can we use __proto__?
  472. const hasProto = '__proto__' in {};
  473. // Browser environment sniffing
  474. const inBrowser = typeof window !== 'undefined';
  475. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  476. const isIE = UA && /msie|trident/.test(UA);
  477. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  478. const isEdge = UA && UA.indexOf('edge/') > 0;
  479. UA && UA.indexOf('android') > 0;
  480. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  481. UA && /chrome\/\d+/.test(UA) && !isEdge;
  482. UA && /phantomjs/.test(UA);
  483. const isFF = UA && UA.match(/firefox\/(\d+)/);
  484. // Firefox has a "watch" function on Object.prototype...
  485. // @ts-expect-error firebox support
  486. const nativeWatch = {}.watch;
  487. let supportsPassive = false;
  488. if (inBrowser) {
  489. try {
  490. const opts = {};
  491. Object.defineProperty(opts, 'passive', {
  492. get() {
  493. /* istanbul ignore next */
  494. supportsPassive = true;
  495. }
  496. }); // https://github.com/facebook/flow/issues/285
  497. window.addEventListener('test-passive', null, opts);
  498. }
  499. catch (e) { }
  500. }
  501. // this needs to be lazy-evaled because vue may be required before
  502. // vue-server-renderer can set VUE_ENV
  503. let _isServer;
  504. const isServerRendering = () => {
  505. if (_isServer === undefined) {
  506. /* istanbul ignore if */
  507. if (!inBrowser && typeof global !== 'undefined') {
  508. // detect presence of vue-server-renderer and avoid
  509. // Webpack shimming the process
  510. _isServer =
  511. global['process'] && global['process'].env.VUE_ENV === 'server';
  512. }
  513. else {
  514. _isServer = false;
  515. }
  516. }
  517. return _isServer;
  518. };
  519. // detect devtools
  520. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  521. /* istanbul ignore next */
  522. function isNative(Ctor) {
  523. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  524. }
  525. const hasSymbol = typeof Symbol !== 'undefined' &&
  526. isNative(Symbol) &&
  527. typeof Reflect !== 'undefined' &&
  528. isNative(Reflect.ownKeys);
  529. let _Set; // $flow-disable-line
  530. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  531. // use native Set when available.
  532. _Set = Set;
  533. }
  534. else {
  535. // a non-standard Set polyfill that only works with primitive keys.
  536. _Set = class Set {
  537. constructor() {
  538. this.set = Object.create(null);
  539. }
  540. has(key) {
  541. return this.set[key] === true;
  542. }
  543. add(key) {
  544. this.set[key] = true;
  545. }
  546. clear() {
  547. this.set = Object.create(null);
  548. }
  549. };
  550. }
  551. let currentInstance = null;
  552. /**
  553. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  554. * relies on it). Do not use this internally, just use `currentInstance`.
  555. *
  556. * @internal this function needs manual type declaration because it relies
  557. * on previously manually authored types from Vue 2
  558. */
  559. function getCurrentInstance() {
  560. return currentInstance && { proxy: currentInstance };
  561. }
  562. /**
  563. * @internal
  564. */
  565. function setCurrentInstance(vm = null) {
  566. if (!vm)
  567. currentInstance && currentInstance._scope.off();
  568. currentInstance = vm;
  569. vm && vm._scope.on();
  570. }
  571. /**
  572. * @internal
  573. */
  574. class VNode {
  575. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  576. this.tag = tag;
  577. this.data = data;
  578. this.children = children;
  579. this.text = text;
  580. this.elm = elm;
  581. this.ns = undefined;
  582. this.context = context;
  583. this.fnContext = undefined;
  584. this.fnOptions = undefined;
  585. this.fnScopeId = undefined;
  586. this.key = data && data.key;
  587. this.componentOptions = componentOptions;
  588. this.componentInstance = undefined;
  589. this.parent = undefined;
  590. this.raw = false;
  591. this.isStatic = false;
  592. this.isRootInsert = true;
  593. this.isComment = false;
  594. this.isCloned = false;
  595. this.isOnce = false;
  596. this.asyncFactory = asyncFactory;
  597. this.asyncMeta = undefined;
  598. this.isAsyncPlaceholder = false;
  599. }
  600. // DEPRECATED: alias for componentInstance for backwards compat.
  601. /* istanbul ignore next */
  602. get child() {
  603. return this.componentInstance;
  604. }
  605. }
  606. const createEmptyVNode = (text = '') => {
  607. const node = new VNode();
  608. node.text = text;
  609. node.isComment = true;
  610. return node;
  611. };
  612. function createTextVNode(val) {
  613. return new VNode(undefined, undefined, undefined, String(val));
  614. }
  615. // optimized shallow clone
  616. // used for static nodes and slot nodes because they may be reused across
  617. // multiple renders, cloning them avoids errors when DOM manipulations rely
  618. // on their elm reference.
  619. function cloneVNode(vnode) {
  620. const cloned = new VNode(vnode.tag, vnode.data,
  621. // #7975
  622. // clone children array to avoid mutating original in case of cloning
  623. // a child.
  624. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  625. cloned.ns = vnode.ns;
  626. cloned.isStatic = vnode.isStatic;
  627. cloned.key = vnode.key;
  628. cloned.isComment = vnode.isComment;
  629. cloned.fnContext = vnode.fnContext;
  630. cloned.fnOptions = vnode.fnOptions;
  631. cloned.fnScopeId = vnode.fnScopeId;
  632. cloned.asyncMeta = vnode.asyncMeta;
  633. cloned.isCloned = true;
  634. return cloned;
  635. }
  636. /* not type checking this file because flow doesn't play well with Proxy */
  637. let initProxy;
  638. {
  639. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  640. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  641. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  642. 'require' // for Webpack/Browserify
  643. );
  644. const warnNonPresent = (target, key) => {
  645. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  646. 'referenced during render. Make sure that this property is reactive, ' +
  647. 'either in the data option, or for class-based components, by ' +
  648. 'initializing the property. ' +
  649. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  650. };
  651. const warnReservedPrefix = (target, key) => {
  652. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  653. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  654. 'prevent conflicts with Vue internals. ' +
  655. 'See: https://v2.vuejs.org/v2/api/#data', target);
  656. };
  657. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  658. if (hasProxy) {
  659. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  660. config.keyCodes = new Proxy(config.keyCodes, {
  661. set(target, key, value) {
  662. if (isBuiltInModifier(key)) {
  663. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  664. return false;
  665. }
  666. else {
  667. target[key] = value;
  668. return true;
  669. }
  670. }
  671. });
  672. }
  673. const hasHandler = {
  674. has(target, key) {
  675. const has = key in target;
  676. const isAllowed = allowedGlobals(key) ||
  677. (typeof key === 'string' &&
  678. key.charAt(0) === '_' &&
  679. !(key in target.$data));
  680. if (!has && !isAllowed) {
  681. if (key in target.$data)
  682. warnReservedPrefix(target, key);
  683. else
  684. warnNonPresent(target, key);
  685. }
  686. return has || !isAllowed;
  687. }
  688. };
  689. const getHandler = {
  690. get(target, key) {
  691. if (typeof key === 'string' && !(key in target)) {
  692. if (key in target.$data)
  693. warnReservedPrefix(target, key);
  694. else
  695. warnNonPresent(target, key);
  696. }
  697. return target[key];
  698. }
  699. };
  700. initProxy = function initProxy(vm) {
  701. if (hasProxy) {
  702. // determine which proxy handler to use
  703. const options = vm.$options;
  704. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  705. vm._renderProxy = new Proxy(vm, handlers);
  706. }
  707. else {
  708. vm._renderProxy = vm;
  709. }
  710. };
  711. }
  712. let uid$2 = 0;
  713. const pendingCleanupDeps = [];
  714. const cleanupDeps = () => {
  715. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  716. const dep = pendingCleanupDeps[i];
  717. dep.subs = dep.subs.filter(s => s);
  718. dep._pending = false;
  719. }
  720. pendingCleanupDeps.length = 0;
  721. };
  722. /**
  723. * A dep is an observable that can have multiple
  724. * directives subscribing to it.
  725. * @internal
  726. */
  727. class Dep {
  728. constructor() {
  729. // pending subs cleanup
  730. this._pending = false;
  731. this.id = uid$2++;
  732. this.subs = [];
  733. }
  734. addSub(sub) {
  735. this.subs.push(sub);
  736. }
  737. removeSub(sub) {
  738. // #12696 deps with massive amount of subscribers are extremely slow to
  739. // clean up in Chromium
  740. // to workaround this, we unset the sub for now, and clear them on
  741. // next scheduler flush.
  742. this.subs[this.subs.indexOf(sub)] = null;
  743. if (!this._pending) {
  744. this._pending = true;
  745. pendingCleanupDeps.push(this);
  746. }
  747. }
  748. depend(info) {
  749. if (Dep.target) {
  750. Dep.target.addDep(this);
  751. if (info && Dep.target.onTrack) {
  752. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  753. }
  754. }
  755. }
  756. notify(info) {
  757. // stabilize the subscriber list first
  758. const subs = this.subs.filter(s => s);
  759. if (!config.async) {
  760. // subs aren't sorted in scheduler if not running async
  761. // we need to sort them now to make sure they fire in correct
  762. // order
  763. subs.sort((a, b) => a.id - b.id);
  764. }
  765. for (let i = 0, l = subs.length; i < l; i++) {
  766. const sub = subs[i];
  767. if (info) {
  768. sub.onTrigger &&
  769. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  770. }
  771. sub.update();
  772. }
  773. }
  774. }
  775. // The current target watcher being evaluated.
  776. // This is globally unique because only one watcher
  777. // can be evaluated at a time.
  778. Dep.target = null;
  779. const targetStack = [];
  780. function pushTarget(target) {
  781. targetStack.push(target);
  782. Dep.target = target;
  783. }
  784. function popTarget() {
  785. targetStack.pop();
  786. Dep.target = targetStack[targetStack.length - 1];
  787. }
  788. /*
  789. * not type checking this file because flow doesn't play well with
  790. * dynamically accessing methods on Array prototype
  791. */
  792. const arrayProto = Array.prototype;
  793. const arrayMethods = Object.create(arrayProto);
  794. const methodsToPatch = [
  795. 'push',
  796. 'pop',
  797. 'shift',
  798. 'unshift',
  799. 'splice',
  800. 'sort',
  801. 'reverse'
  802. ];
  803. /**
  804. * Intercept mutating methods and emit events
  805. */
  806. methodsToPatch.forEach(function (method) {
  807. // cache original method
  808. const original = arrayProto[method];
  809. def(arrayMethods, method, function mutator(...args) {
  810. const result = original.apply(this, args);
  811. const ob = this.__ob__;
  812. let inserted;
  813. switch (method) {
  814. case 'push':
  815. case 'unshift':
  816. inserted = args;
  817. break;
  818. case 'splice':
  819. inserted = args.slice(2);
  820. break;
  821. }
  822. if (inserted)
  823. ob.observeArray(inserted);
  824. // notify change
  825. {
  826. ob.dep.notify({
  827. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  828. target: this,
  829. key: method
  830. });
  831. }
  832. return result;
  833. });
  834. });
  835. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  836. const NO_INITIAL_VALUE = {};
  837. /**
  838. * In some cases we may want to disable observation inside a component's
  839. * update computation.
  840. */
  841. let shouldObserve = true;
  842. function toggleObserving(value) {
  843. shouldObserve = value;
  844. }
  845. // ssr mock dep
  846. const mockDep = {
  847. notify: noop,
  848. depend: noop,
  849. addSub: noop,
  850. removeSub: noop
  851. };
  852. /**
  853. * Observer class that is attached to each observed
  854. * object. Once attached, the observer converts the target
  855. * object's property keys into getter/setters that
  856. * collect dependencies and dispatch updates.
  857. */
  858. class Observer {
  859. constructor(value, shallow = false, mock = false) {
  860. this.value = value;
  861. this.shallow = shallow;
  862. this.mock = mock;
  863. // this.value = value
  864. this.dep = mock ? mockDep : new Dep();
  865. this.vmCount = 0;
  866. def(value, '__ob__', this);
  867. if (isArray(value)) {
  868. if (!mock) {
  869. if (hasProto) {
  870. value.__proto__ = arrayMethods;
  871. /* eslint-enable no-proto */
  872. }
  873. else {
  874. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  875. const key = arrayKeys[i];
  876. def(value, key, arrayMethods[key]);
  877. }
  878. }
  879. }
  880. if (!shallow) {
  881. this.observeArray(value);
  882. }
  883. }
  884. else {
  885. /**
  886. * Walk through all properties and convert them into
  887. * getter/setters. This method should only be called when
  888. * value type is Object.
  889. */
  890. const keys = Object.keys(value);
  891. for (let i = 0; i < keys.length; i++) {
  892. const key = keys[i];
  893. defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
  894. }
  895. }
  896. }
  897. /**
  898. * Observe a list of Array items.
  899. */
  900. observeArray(value) {
  901. for (let i = 0, l = value.length; i < l; i++) {
  902. observe(value[i], false, this.mock);
  903. }
  904. }
  905. }
  906. // helpers
  907. /**
  908. * Attempt to create an observer instance for a value,
  909. * returns the new observer if successfully observed,
  910. * or the existing observer if the value already has one.
  911. */
  912. function observe(value, shallow, ssrMockReactivity) {
  913. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  914. return value.__ob__;
  915. }
  916. if (shouldObserve &&
  917. (ssrMockReactivity || !isServerRendering()) &&
  918. (isArray(value) || isPlainObject(value)) &&
  919. Object.isExtensible(value) &&
  920. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  921. !isRef(value) &&
  922. !(value instanceof VNode)) {
  923. return new Observer(value, shallow, ssrMockReactivity);
  924. }
  925. }
  926. /**
  927. * Define a reactive property on an Object.
  928. */
  929. function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) {
  930. const dep = new Dep();
  931. const property = Object.getOwnPropertyDescriptor(obj, key);
  932. if (property && property.configurable === false) {
  933. return;
  934. }
  935. // cater for pre-defined getter/setters
  936. const getter = property && property.get;
  937. const setter = property && property.set;
  938. if ((!getter || setter) &&
  939. (val === NO_INITIAL_VALUE || arguments.length === 2)) {
  940. val = obj[key];
  941. }
  942. let childOb = shallow ? val && val.__ob__ : observe(val, false, mock);
  943. Object.defineProperty(obj, key, {
  944. enumerable: true,
  945. configurable: true,
  946. get: function reactiveGetter() {
  947. const value = getter ? getter.call(obj) : val;
  948. if (Dep.target) {
  949. {
  950. dep.depend({
  951. target: obj,
  952. type: "get" /* TrackOpTypes.GET */,
  953. key
  954. });
  955. }
  956. if (childOb) {
  957. childOb.dep.depend();
  958. if (isArray(value)) {
  959. dependArray(value);
  960. }
  961. }
  962. }
  963. return isRef(value) && !shallow ? value.value : value;
  964. },
  965. set: function reactiveSetter(newVal) {
  966. const value = getter ? getter.call(obj) : val;
  967. if (!hasChanged(value, newVal)) {
  968. return;
  969. }
  970. if (customSetter) {
  971. customSetter();
  972. }
  973. if (setter) {
  974. setter.call(obj, newVal);
  975. }
  976. else if (getter) {
  977. // #7981: for accessor properties without setter
  978. return;
  979. }
  980. else if (!shallow && isRef(value) && !isRef(newVal)) {
  981. value.value = newVal;
  982. return;
  983. }
  984. else {
  985. val = newVal;
  986. }
  987. childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock);
  988. {
  989. dep.notify({
  990. type: "set" /* TriggerOpTypes.SET */,
  991. target: obj,
  992. key,
  993. newValue: newVal,
  994. oldValue: value
  995. });
  996. }
  997. }
  998. });
  999. return dep;
  1000. }
  1001. function set(target, key, val) {
  1002. if ((isUndef(target) || isPrimitive(target))) {
  1003. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  1004. }
  1005. if (isReadonly(target)) {
  1006. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1007. return;
  1008. }
  1009. const ob = target.__ob__;
  1010. if (isArray(target) && isValidArrayIndex(key)) {
  1011. target.length = Math.max(target.length, key);
  1012. target.splice(key, 1, val);
  1013. // when mocking for SSR, array methods are not hijacked
  1014. if (ob && !ob.shallow && ob.mock) {
  1015. observe(val, false, true);
  1016. }
  1017. return val;
  1018. }
  1019. if (key in target && !(key in Object.prototype)) {
  1020. target[key] = val;
  1021. return val;
  1022. }
  1023. if (target._isVue || (ob && ob.vmCount)) {
  1024. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1025. 'at runtime - declare it upfront in the data option.');
  1026. return val;
  1027. }
  1028. if (!ob) {
  1029. target[key] = val;
  1030. return val;
  1031. }
  1032. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1033. {
  1034. ob.dep.notify({
  1035. type: "add" /* TriggerOpTypes.ADD */,
  1036. target: target,
  1037. key,
  1038. newValue: val,
  1039. oldValue: undefined
  1040. });
  1041. }
  1042. return val;
  1043. }
  1044. function del(target, key) {
  1045. if ((isUndef(target) || isPrimitive(target))) {
  1046. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1047. }
  1048. if (isArray(target) && isValidArrayIndex(key)) {
  1049. target.splice(key, 1);
  1050. return;
  1051. }
  1052. const ob = target.__ob__;
  1053. if (target._isVue || (ob && ob.vmCount)) {
  1054. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1055. '- just set it to null.');
  1056. return;
  1057. }
  1058. if (isReadonly(target)) {
  1059. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1060. return;
  1061. }
  1062. if (!hasOwn(target, key)) {
  1063. return;
  1064. }
  1065. delete target[key];
  1066. if (!ob) {
  1067. return;
  1068. }
  1069. {
  1070. ob.dep.notify({
  1071. type: "delete" /* TriggerOpTypes.DELETE */,
  1072. target: target,
  1073. key
  1074. });
  1075. }
  1076. }
  1077. /**
  1078. * Collect dependencies on array elements when the array is touched, since
  1079. * we cannot intercept array element access like property getters.
  1080. */
  1081. function dependArray(value) {
  1082. for (let e, i = 0, l = value.length; i < l; i++) {
  1083. e = value[i];
  1084. if (e && e.__ob__) {
  1085. e.__ob__.dep.depend();
  1086. }
  1087. if (isArray(e)) {
  1088. dependArray(e);
  1089. }
  1090. }
  1091. }
  1092. function reactive(target) {
  1093. makeReactive(target, false);
  1094. return target;
  1095. }
  1096. /**
  1097. * Return a shallowly-reactive copy of the original object, where only the root
  1098. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1099. * root level).
  1100. */
  1101. function shallowReactive(target) {
  1102. makeReactive(target, true);
  1103. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1104. return target;
  1105. }
  1106. function makeReactive(target, shallow) {
  1107. // if trying to observe a readonly proxy, return the readonly version.
  1108. if (!isReadonly(target)) {
  1109. {
  1110. if (isArray(target)) {
  1111. 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.`);
  1112. }
  1113. const existingOb = target && target.__ob__;
  1114. if (existingOb && existingOb.shallow !== shallow) {
  1115. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1116. }
  1117. }
  1118. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1119. if (!ob) {
  1120. if (target == null || isPrimitive(target)) {
  1121. warn$2(`value cannot be made reactive: ${String(target)}`);
  1122. }
  1123. if (isCollectionType(target)) {
  1124. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1125. }
  1126. }
  1127. }
  1128. }
  1129. function isReactive(value) {
  1130. if (isReadonly(value)) {
  1131. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1132. }
  1133. return !!(value && value.__ob__);
  1134. }
  1135. function isShallow(value) {
  1136. return !!(value && value.__v_isShallow);
  1137. }
  1138. function isReadonly(value) {
  1139. return !!(value && value.__v_isReadonly);
  1140. }
  1141. function isProxy(value) {
  1142. return isReactive(value) || isReadonly(value);
  1143. }
  1144. function toRaw(observed) {
  1145. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1146. return raw ? toRaw(raw) : observed;
  1147. }
  1148. function markRaw(value) {
  1149. // non-extensible objects won't be observed anyway
  1150. if (Object.isExtensible(value)) {
  1151. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1152. }
  1153. return value;
  1154. }
  1155. /**
  1156. * @internal
  1157. */
  1158. function isCollectionType(value) {
  1159. const type = toRawType(value);
  1160. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1161. }
  1162. /**
  1163. * @internal
  1164. */
  1165. const RefFlag = `__v_isRef`;
  1166. function isRef(r) {
  1167. return !!(r && r.__v_isRef === true);
  1168. }
  1169. function ref$1(value) {
  1170. return createRef(value, false);
  1171. }
  1172. function shallowRef(value) {
  1173. return createRef(value, true);
  1174. }
  1175. function createRef(rawValue, shallow) {
  1176. if (isRef(rawValue)) {
  1177. return rawValue;
  1178. }
  1179. const ref = {};
  1180. def(ref, RefFlag, true);
  1181. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1182. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1183. return ref;
  1184. }
  1185. function triggerRef(ref) {
  1186. if (!ref.dep) {
  1187. warn$2(`received object is not a triggerable ref.`);
  1188. }
  1189. {
  1190. ref.dep &&
  1191. ref.dep.notify({
  1192. type: "set" /* TriggerOpTypes.SET */,
  1193. target: ref,
  1194. key: 'value'
  1195. });
  1196. }
  1197. }
  1198. function unref(ref) {
  1199. return isRef(ref) ? ref.value : ref;
  1200. }
  1201. function proxyRefs(objectWithRefs) {
  1202. if (isReactive(objectWithRefs)) {
  1203. return objectWithRefs;
  1204. }
  1205. const proxy = {};
  1206. const keys = Object.keys(objectWithRefs);
  1207. for (let i = 0; i < keys.length; i++) {
  1208. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1209. }
  1210. return proxy;
  1211. }
  1212. function proxyWithRefUnwrap(target, source, key) {
  1213. Object.defineProperty(target, key, {
  1214. enumerable: true,
  1215. configurable: true,
  1216. get: () => {
  1217. const val = source[key];
  1218. if (isRef(val)) {
  1219. return val.value;
  1220. }
  1221. else {
  1222. const ob = val && val.__ob__;
  1223. if (ob)
  1224. ob.dep.depend();
  1225. return val;
  1226. }
  1227. },
  1228. set: value => {
  1229. const oldValue = source[key];
  1230. if (isRef(oldValue) && !isRef(value)) {
  1231. oldValue.value = value;
  1232. }
  1233. else {
  1234. source[key] = value;
  1235. }
  1236. }
  1237. });
  1238. }
  1239. function customRef(factory) {
  1240. const dep = new Dep();
  1241. const { get, set } = factory(() => {
  1242. {
  1243. dep.depend({
  1244. target: ref,
  1245. type: "get" /* TrackOpTypes.GET */,
  1246. key: 'value'
  1247. });
  1248. }
  1249. }, () => {
  1250. {
  1251. dep.notify({
  1252. target: ref,
  1253. type: "set" /* TriggerOpTypes.SET */,
  1254. key: 'value'
  1255. });
  1256. }
  1257. });
  1258. const ref = {
  1259. get value() {
  1260. return get();
  1261. },
  1262. set value(newVal) {
  1263. set(newVal);
  1264. }
  1265. };
  1266. def(ref, RefFlag, true);
  1267. return ref;
  1268. }
  1269. function toRefs(object) {
  1270. if (!isReactive(object)) {
  1271. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1272. }
  1273. const ret = isArray(object) ? new Array(object.length) : {};
  1274. for (const key in object) {
  1275. ret[key] = toRef(object, key);
  1276. }
  1277. return ret;
  1278. }
  1279. function toRef(object, key, defaultValue) {
  1280. const val = object[key];
  1281. if (isRef(val)) {
  1282. return val;
  1283. }
  1284. const ref = {
  1285. get value() {
  1286. const val = object[key];
  1287. return val === undefined ? defaultValue : val;
  1288. },
  1289. set value(newVal) {
  1290. object[key] = newVal;
  1291. }
  1292. };
  1293. def(ref, RefFlag, true);
  1294. return ref;
  1295. }
  1296. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1297. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1298. function readonly(target) {
  1299. return createReadonly(target, false);
  1300. }
  1301. function createReadonly(target, shallow) {
  1302. if (!isPlainObject(target)) {
  1303. {
  1304. if (isArray(target)) {
  1305. warn$2(`Vue 2 does not support readonly arrays.`);
  1306. }
  1307. else if (isCollectionType(target)) {
  1308. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1309. }
  1310. else {
  1311. warn$2(`value cannot be made readonly: ${typeof target}`);
  1312. }
  1313. }
  1314. return target;
  1315. }
  1316. if (!Object.isExtensible(target)) {
  1317. warn$2(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1318. }
  1319. // already a readonly object
  1320. if (isReadonly(target)) {
  1321. return target;
  1322. }
  1323. // already has a readonly proxy
  1324. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1325. const existingProxy = target[existingFlag];
  1326. if (existingProxy) {
  1327. return existingProxy;
  1328. }
  1329. const proxy = Object.create(Object.getPrototypeOf(target));
  1330. def(target, existingFlag, proxy);
  1331. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1332. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1333. if (isRef(target)) {
  1334. def(proxy, RefFlag, true);
  1335. }
  1336. if (shallow || isShallow(target)) {
  1337. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1338. }
  1339. const keys = Object.keys(target);
  1340. for (let i = 0; i < keys.length; i++) {
  1341. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1342. }
  1343. return proxy;
  1344. }
  1345. function defineReadonlyProperty(proxy, target, key, shallow) {
  1346. Object.defineProperty(proxy, key, {
  1347. enumerable: true,
  1348. configurable: true,
  1349. get() {
  1350. const val = target[key];
  1351. return shallow || !isPlainObject(val) ? val : readonly(val);
  1352. },
  1353. set() {
  1354. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1355. }
  1356. });
  1357. }
  1358. /**
  1359. * Returns a reactive-copy of the original object, where only the root level
  1360. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1361. * returned properties.
  1362. * This is used for creating the props proxy object for stateful components.
  1363. */
  1364. function shallowReadonly(target) {
  1365. return createReadonly(target, true);
  1366. }
  1367. function computed(getterOrOptions, debugOptions) {
  1368. let getter;
  1369. let setter;
  1370. const onlyGetter = isFunction(getterOrOptions);
  1371. if (onlyGetter) {
  1372. getter = getterOrOptions;
  1373. setter = () => {
  1374. warn$2('Write operation failed: computed value is readonly');
  1375. }
  1376. ;
  1377. }
  1378. else {
  1379. getter = getterOrOptions.get;
  1380. setter = getterOrOptions.set;
  1381. }
  1382. const watcher = isServerRendering()
  1383. ? null
  1384. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1385. if (watcher && debugOptions) {
  1386. watcher.onTrack = debugOptions.onTrack;
  1387. watcher.onTrigger = debugOptions.onTrigger;
  1388. }
  1389. const ref = {
  1390. // some libs rely on the presence effect for checking computed refs
  1391. // from normal refs, but the implementation doesn't matter
  1392. effect: watcher,
  1393. get value() {
  1394. if (watcher) {
  1395. if (watcher.dirty) {
  1396. watcher.evaluate();
  1397. }
  1398. if (Dep.target) {
  1399. if (Dep.target.onTrack) {
  1400. Dep.target.onTrack({
  1401. effect: Dep.target,
  1402. target: ref,
  1403. type: "get" /* TrackOpTypes.GET */,
  1404. key: 'value'
  1405. });
  1406. }
  1407. watcher.depend();
  1408. }
  1409. return watcher.value;
  1410. }
  1411. else {
  1412. return getter();
  1413. }
  1414. },
  1415. set value(newVal) {
  1416. setter(newVal);
  1417. }
  1418. };
  1419. def(ref, RefFlag, true);
  1420. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1421. return ref;
  1422. }
  1423. let mark;
  1424. let measure;
  1425. {
  1426. const perf = inBrowser && window.performance;
  1427. /* istanbul ignore if */
  1428. if (perf &&
  1429. // @ts-ignore
  1430. perf.mark &&
  1431. // @ts-ignore
  1432. perf.measure &&
  1433. // @ts-ignore
  1434. perf.clearMarks &&
  1435. // @ts-ignore
  1436. perf.clearMeasures) {
  1437. mark = tag => perf.mark(tag);
  1438. measure = (name, startTag, endTag) => {
  1439. perf.measure(name, startTag, endTag);
  1440. perf.clearMarks(startTag);
  1441. perf.clearMarks(endTag);
  1442. // perf.clearMeasures(name)
  1443. };
  1444. }
  1445. }
  1446. const normalizeEvent = cached((name) => {
  1447. const passive = name.charAt(0) === '&';
  1448. name = passive ? name.slice(1) : name;
  1449. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1450. name = once ? name.slice(1) : name;
  1451. const capture = name.charAt(0) === '!';
  1452. name = capture ? name.slice(1) : name;
  1453. return {
  1454. name,
  1455. once,
  1456. capture,
  1457. passive
  1458. };
  1459. });
  1460. function createFnInvoker(fns, vm) {
  1461. function invoker() {
  1462. const fns = invoker.fns;
  1463. if (isArray(fns)) {
  1464. const cloned = fns.slice();
  1465. for (let i = 0; i < cloned.length; i++) {
  1466. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1467. }
  1468. }
  1469. else {
  1470. // return handler return value for single handlers
  1471. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1472. }
  1473. }
  1474. invoker.fns = fns;
  1475. return invoker;
  1476. }
  1477. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1478. let name, cur, old, event;
  1479. for (name in on) {
  1480. cur = on[name];
  1481. old = oldOn[name];
  1482. event = normalizeEvent(name);
  1483. if (isUndef(cur)) {
  1484. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1485. }
  1486. else if (isUndef(old)) {
  1487. if (isUndef(cur.fns)) {
  1488. cur = on[name] = createFnInvoker(cur, vm);
  1489. }
  1490. if (isTrue(event.once)) {
  1491. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1492. }
  1493. add(event.name, cur, event.capture, event.passive, event.params);
  1494. }
  1495. else if (cur !== old) {
  1496. old.fns = cur;
  1497. on[name] = old;
  1498. }
  1499. }
  1500. for (name in oldOn) {
  1501. if (isUndef(on[name])) {
  1502. event = normalizeEvent(name);
  1503. remove(event.name, oldOn[name], event.capture);
  1504. }
  1505. }
  1506. }
  1507. function mergeVNodeHook(def, hookKey, hook) {
  1508. if (def instanceof VNode) {
  1509. def = def.data.hook || (def.data.hook = {});
  1510. }
  1511. let invoker;
  1512. const oldHook = def[hookKey];
  1513. function wrappedHook() {
  1514. hook.apply(this, arguments);
  1515. // important: remove merged hook to ensure it's called only once
  1516. // and prevent memory leak
  1517. remove$2(invoker.fns, wrappedHook);
  1518. }
  1519. if (isUndef(oldHook)) {
  1520. // no existing hook
  1521. invoker = createFnInvoker([wrappedHook]);
  1522. }
  1523. else {
  1524. /* istanbul ignore if */
  1525. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1526. // already a merged invoker
  1527. invoker = oldHook;
  1528. invoker.fns.push(wrappedHook);
  1529. }
  1530. else {
  1531. // existing plain hook
  1532. invoker = createFnInvoker([oldHook, wrappedHook]);
  1533. }
  1534. }
  1535. invoker.merged = true;
  1536. def[hookKey] = invoker;
  1537. }
  1538. function extractPropsFromVNodeData(data, Ctor, tag) {
  1539. // we are only extracting raw values here.
  1540. // validation and default values are handled in the child
  1541. // component itself.
  1542. const propOptions = Ctor.options.props;
  1543. if (isUndef(propOptions)) {
  1544. return;
  1545. }
  1546. const res = {};
  1547. const { attrs, props } = data;
  1548. if (isDef(attrs) || isDef(props)) {
  1549. for (const key in propOptions) {
  1550. const altKey = hyphenate(key);
  1551. {
  1552. const keyInLowerCase = key.toLowerCase();
  1553. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1554. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1555. `${formatComponentName(
  1556. // @ts-expect-error tag is string
  1557. tag || Ctor)}, but the declared prop name is` +
  1558. ` "${key}". ` +
  1559. `Note that HTML attributes are case-insensitive and camelCased ` +
  1560. `props need to use their kebab-case equivalents when using in-DOM ` +
  1561. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1562. }
  1563. }
  1564. checkProp(res, props, key, altKey, true) ||
  1565. checkProp(res, attrs, key, altKey, false);
  1566. }
  1567. }
  1568. return res;
  1569. }
  1570. function checkProp(res, hash, key, altKey, preserve) {
  1571. if (isDef(hash)) {
  1572. if (hasOwn(hash, key)) {
  1573. res[key] = hash[key];
  1574. if (!preserve) {
  1575. delete hash[key];
  1576. }
  1577. return true;
  1578. }
  1579. else if (hasOwn(hash, altKey)) {
  1580. res[key] = hash[altKey];
  1581. if (!preserve) {
  1582. delete hash[altKey];
  1583. }
  1584. return true;
  1585. }
  1586. }
  1587. return false;
  1588. }
  1589. // The template compiler attempts to minimize the need for normalization by
  1590. // statically analyzing the template at compile time.
  1591. //
  1592. // For plain HTML markup, normalization can be completely skipped because the
  1593. // generated render function is guaranteed to return Array<VNode>. There are
  1594. // two cases where extra normalization is needed:
  1595. // 1. When the children contains components - because a functional component
  1596. // may return an Array instead of a single root. In this case, just a simple
  1597. // normalization is needed - if any child is an Array, we flatten the whole
  1598. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1599. // because functional components already normalize their own children.
  1600. function simpleNormalizeChildren(children) {
  1601. for (let i = 0; i < children.length; i++) {
  1602. if (isArray(children[i])) {
  1603. return Array.prototype.concat.apply([], children);
  1604. }
  1605. }
  1606. return children;
  1607. }
  1608. // 2. When the children contains constructs that always generated nested Arrays,
  1609. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1610. // with hand-written render functions / JSX. In such cases a full normalization
  1611. // is needed to cater to all possible types of children values.
  1612. function normalizeChildren(children) {
  1613. return isPrimitive(children)
  1614. ? [createTextVNode(children)]
  1615. : isArray(children)
  1616. ? normalizeArrayChildren(children)
  1617. : undefined;
  1618. }
  1619. function isTextNode(node) {
  1620. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1621. }
  1622. function normalizeArrayChildren(children, nestedIndex) {
  1623. const res = [];
  1624. let i, c, lastIndex, last;
  1625. for (i = 0; i < children.length; i++) {
  1626. c = children[i];
  1627. if (isUndef(c) || typeof c === 'boolean')
  1628. continue;
  1629. lastIndex = res.length - 1;
  1630. last = res[lastIndex];
  1631. // nested
  1632. if (isArray(c)) {
  1633. if (c.length > 0) {
  1634. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1635. // merge adjacent text nodes
  1636. if (isTextNode(c[0]) && isTextNode(last)) {
  1637. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1638. c.shift();
  1639. }
  1640. res.push.apply(res, c);
  1641. }
  1642. }
  1643. else if (isPrimitive(c)) {
  1644. if (isTextNode(last)) {
  1645. // merge adjacent text nodes
  1646. // this is necessary for SSR hydration because text nodes are
  1647. // essentially merged when rendered to HTML strings
  1648. res[lastIndex] = createTextVNode(last.text + c);
  1649. }
  1650. else if (c !== '') {
  1651. // convert primitive to vnode
  1652. res.push(createTextVNode(c));
  1653. }
  1654. }
  1655. else {
  1656. if (isTextNode(c) && isTextNode(last)) {
  1657. // merge adjacent text nodes
  1658. res[lastIndex] = createTextVNode(last.text + c.text);
  1659. }
  1660. else {
  1661. // default key for nested array children (likely generated by v-for)
  1662. if (isTrue(children._isVList) &&
  1663. isDef(c.tag) &&
  1664. isUndef(c.key) &&
  1665. isDef(nestedIndex)) {
  1666. c.key = `__vlist${nestedIndex}_${i}__`;
  1667. }
  1668. res.push(c);
  1669. }
  1670. }
  1671. }
  1672. return res;
  1673. }
  1674. const SIMPLE_NORMALIZE = 1;
  1675. const ALWAYS_NORMALIZE = 2;
  1676. // wrapper function for providing a more flexible interface
  1677. // without getting yelled at by flow
  1678. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1679. if (isArray(data) || isPrimitive(data)) {
  1680. normalizationType = children;
  1681. children = data;
  1682. data = undefined;
  1683. }
  1684. if (isTrue(alwaysNormalize)) {
  1685. normalizationType = ALWAYS_NORMALIZE;
  1686. }
  1687. return _createElement(context, tag, data, children, normalizationType);
  1688. }
  1689. function _createElement(context, tag, data, children, normalizationType) {
  1690. if (isDef(data) && isDef(data.__ob__)) {
  1691. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1692. return createEmptyVNode();
  1693. }
  1694. // object syntax in v-bind
  1695. if (isDef(data) && isDef(data.is)) {
  1696. tag = data.is;
  1697. }
  1698. if (!tag) {
  1699. // in case of component :is set to falsy value
  1700. return createEmptyVNode();
  1701. }
  1702. // warn against non-primitive key
  1703. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1704. warn$2('Avoid using non-primitive value as key, ' +
  1705. 'use string/number value instead.', context);
  1706. }
  1707. // support single function children as default scoped slot
  1708. if (isArray(children) && isFunction(children[0])) {
  1709. data = data || {};
  1710. data.scopedSlots = { default: children[0] };
  1711. children.length = 0;
  1712. }
  1713. if (normalizationType === ALWAYS_NORMALIZE) {
  1714. children = normalizeChildren(children);
  1715. }
  1716. else if (normalizationType === SIMPLE_NORMALIZE) {
  1717. children = simpleNormalizeChildren(children);
  1718. }
  1719. let vnode, ns;
  1720. if (typeof tag === 'string') {
  1721. let Ctor;
  1722. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1723. if (config.isReservedTag(tag)) {
  1724. // platform built-in elements
  1725. if (isDef(data) &&
  1726. isDef(data.nativeOn) &&
  1727. data.tag !== 'component') {
  1728. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1729. }
  1730. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1731. }
  1732. else if ((!data || !data.pre) &&
  1733. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1734. // component
  1735. vnode = createComponent(Ctor, data, context, children, tag);
  1736. }
  1737. else {
  1738. // unknown or unlisted namespaced elements
  1739. // check at runtime because it may get assigned a namespace when its
  1740. // parent normalizes children
  1741. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1742. }
  1743. }
  1744. else {
  1745. // direct component options / constructor
  1746. vnode = createComponent(tag, data, context, children);
  1747. }
  1748. if (isArray(vnode)) {
  1749. return vnode;
  1750. }
  1751. else if (isDef(vnode)) {
  1752. if (isDef(ns))
  1753. applyNS(vnode, ns);
  1754. if (isDef(data))
  1755. registerDeepBindings(data);
  1756. return vnode;
  1757. }
  1758. else {
  1759. return createEmptyVNode();
  1760. }
  1761. }
  1762. function applyNS(vnode, ns, force) {
  1763. vnode.ns = ns;
  1764. if (vnode.tag === 'foreignObject') {
  1765. // use default namespace inside foreignObject
  1766. ns = undefined;
  1767. force = true;
  1768. }
  1769. if (isDef(vnode.children)) {
  1770. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1771. const child = vnode.children[i];
  1772. if (isDef(child.tag) &&
  1773. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1774. applyNS(child, ns, force);
  1775. }
  1776. }
  1777. }
  1778. }
  1779. // ref #5318
  1780. // necessary to ensure parent re-render when deep bindings like :style and
  1781. // :class are used on slot nodes
  1782. function registerDeepBindings(data) {
  1783. if (isObject(data.style)) {
  1784. traverse(data.style);
  1785. }
  1786. if (isObject(data.class)) {
  1787. traverse(data.class);
  1788. }
  1789. }
  1790. /**
  1791. * Runtime helper for rendering v-for lists.
  1792. */
  1793. function renderList(val, render) {
  1794. let ret = null, i, l, keys, key;
  1795. if (isArray(val) || typeof val === 'string') {
  1796. ret = new Array(val.length);
  1797. for (i = 0, l = val.length; i < l; i++) {
  1798. ret[i] = render(val[i], i);
  1799. }
  1800. }
  1801. else if (typeof val === 'number') {
  1802. ret = new Array(val);
  1803. for (i = 0; i < val; i++) {
  1804. ret[i] = render(i + 1, i);
  1805. }
  1806. }
  1807. else if (isObject(val)) {
  1808. if (hasSymbol && val[Symbol.iterator]) {
  1809. ret = [];
  1810. const iterator = val[Symbol.iterator]();
  1811. let result = iterator.next();
  1812. while (!result.done) {
  1813. ret.push(render(result.value, ret.length));
  1814. result = iterator.next();
  1815. }
  1816. }
  1817. else {
  1818. keys = Object.keys(val);
  1819. ret = new Array(keys.length);
  1820. for (i = 0, l = keys.length; i < l; i++) {
  1821. key = keys[i];
  1822. ret[i] = render(val[key], key, i);
  1823. }
  1824. }
  1825. }
  1826. if (!isDef(ret)) {
  1827. ret = [];
  1828. }
  1829. ret._isVList = true;
  1830. return ret;
  1831. }
  1832. /**
  1833. * Runtime helper for rendering <slot>
  1834. */
  1835. function renderSlot(name, fallbackRender, props, bindObject) {
  1836. const scopedSlotFn = this.$scopedSlots[name];
  1837. let nodes;
  1838. if (scopedSlotFn) {
  1839. // scoped slot
  1840. props = props || {};
  1841. if (bindObject) {
  1842. if (!isObject(bindObject)) {
  1843. warn$2('slot v-bind without argument expects an Object', this);
  1844. }
  1845. props = extend(extend({}, bindObject), props);
  1846. }
  1847. nodes =
  1848. scopedSlotFn(props) ||
  1849. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1850. }
  1851. else {
  1852. nodes =
  1853. this.$slots[name] ||
  1854. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1855. }
  1856. const target = props && props.slot;
  1857. if (target) {
  1858. return this.$createElement('template', { slot: target }, nodes);
  1859. }
  1860. else {
  1861. return nodes;
  1862. }
  1863. }
  1864. /**
  1865. * Runtime helper for resolving filters
  1866. */
  1867. function resolveFilter(id) {
  1868. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1869. }
  1870. function isKeyNotMatch(expect, actual) {
  1871. if (isArray(expect)) {
  1872. return expect.indexOf(actual) === -1;
  1873. }
  1874. else {
  1875. return expect !== actual;
  1876. }
  1877. }
  1878. /**
  1879. * Runtime helper for checking keyCodes from config.
  1880. * exposed as Vue.prototype._k
  1881. * passing in eventKeyName as last argument separately for backwards compat
  1882. */
  1883. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1884. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1885. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1886. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1887. }
  1888. else if (mappedKeyCode) {
  1889. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1890. }
  1891. else if (eventKeyName) {
  1892. return hyphenate(eventKeyName) !== key;
  1893. }
  1894. return eventKeyCode === undefined;
  1895. }
  1896. /**
  1897. * Runtime helper for merging v-bind="object" into a VNode's data.
  1898. */
  1899. function bindObjectProps(data, tag, value, asProp, isSync) {
  1900. if (value) {
  1901. if (!isObject(value)) {
  1902. warn$2('v-bind without argument expects an Object or Array value', this);
  1903. }
  1904. else {
  1905. if (isArray(value)) {
  1906. value = toObject(value);
  1907. }
  1908. let hash;
  1909. for (const key in value) {
  1910. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1911. hash = data;
  1912. }
  1913. else {
  1914. const type = data.attrs && data.attrs.type;
  1915. hash =
  1916. asProp || config.mustUseProp(tag, type, key)
  1917. ? data.domProps || (data.domProps = {})
  1918. : data.attrs || (data.attrs = {});
  1919. }
  1920. const camelizedKey = camelize(key);
  1921. const hyphenatedKey = hyphenate(key);
  1922. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1923. hash[key] = value[key];
  1924. if (isSync) {
  1925. const on = data.on || (data.on = {});
  1926. on[`update:${key}`] = function ($event) {
  1927. value[key] = $event;
  1928. };
  1929. }
  1930. }
  1931. }
  1932. }
  1933. }
  1934. return data;
  1935. }
  1936. /**
  1937. * Runtime helper for rendering static trees.
  1938. */
  1939. function renderStatic(index, isInFor) {
  1940. const cached = this._staticTrees || (this._staticTrees = []);
  1941. let tree = cached[index];
  1942. // if has already-rendered static tree and not inside v-for,
  1943. // we can reuse the same tree.
  1944. if (tree && !isInFor) {
  1945. return tree;
  1946. }
  1947. // otherwise, render a fresh tree.
  1948. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1949. );
  1950. markStatic$1(tree, `__static__${index}`, false);
  1951. return tree;
  1952. }
  1953. /**
  1954. * Runtime helper for v-once.
  1955. * Effectively it means marking the node as static with a unique key.
  1956. */
  1957. function markOnce(tree, index, key) {
  1958. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1959. return tree;
  1960. }
  1961. function markStatic$1(tree, key, isOnce) {
  1962. if (isArray(tree)) {
  1963. for (let i = 0; i < tree.length; i++) {
  1964. if (tree[i] && typeof tree[i] !== 'string') {
  1965. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1966. }
  1967. }
  1968. }
  1969. else {
  1970. markStaticNode(tree, key, isOnce);
  1971. }
  1972. }
  1973. function markStaticNode(node, key, isOnce) {
  1974. node.isStatic = true;
  1975. node.key = key;
  1976. node.isOnce = isOnce;
  1977. }
  1978. function bindObjectListeners(data, value) {
  1979. if (value) {
  1980. if (!isPlainObject(value)) {
  1981. warn$2('v-on without argument expects an Object value', this);
  1982. }
  1983. else {
  1984. const on = (data.on = data.on ? extend({}, data.on) : {});
  1985. for (const key in value) {
  1986. const existing = on[key];
  1987. const ours = value[key];
  1988. on[key] = existing ? [].concat(existing, ours) : ours;
  1989. }
  1990. }
  1991. }
  1992. return data;
  1993. }
  1994. function resolveScopedSlots(fns, res,
  1995. // the following are added in 2.6
  1996. hasDynamicKeys, contentHashKey) {
  1997. res = res || { $stable: !hasDynamicKeys };
  1998. for (let i = 0; i < fns.length; i++) {
  1999. const slot = fns[i];
  2000. if (isArray(slot)) {
  2001. resolveScopedSlots(slot, res, hasDynamicKeys);
  2002. }
  2003. else if (slot) {
  2004. // marker for reverse proxying v-slot without scope on this.$slots
  2005. // @ts-expect-error
  2006. if (slot.proxy) {
  2007. // @ts-expect-error
  2008. slot.fn.proxy = true;
  2009. }
  2010. res[slot.key] = slot.fn;
  2011. }
  2012. }
  2013. if (contentHashKey) {
  2014. res.$key = contentHashKey;
  2015. }
  2016. return res;
  2017. }
  2018. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2019. function bindDynamicKeys(baseObj, values) {
  2020. for (let i = 0; i < values.length; i += 2) {
  2021. const key = values[i];
  2022. if (typeof key === 'string' && key) {
  2023. baseObj[values[i]] = values[i + 1];
  2024. }
  2025. else if (key !== '' && key !== null) {
  2026. // null is a special value for explicitly removing a binding
  2027. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2028. }
  2029. }
  2030. return baseObj;
  2031. }
  2032. // helper to dynamically append modifier runtime markers to event names.
  2033. // ensure only append when value is already string, otherwise it will be cast
  2034. // to string and cause the type check to miss.
  2035. function prependModifier(value, symbol) {
  2036. return typeof value === 'string' ? symbol + value : value;
  2037. }
  2038. function installRenderHelpers(target) {
  2039. target._o = markOnce;
  2040. target._n = toNumber;
  2041. target._s = toString;
  2042. target._l = renderList;
  2043. target._t = renderSlot;
  2044. target._q = looseEqual;
  2045. target._i = looseIndexOf;
  2046. target._m = renderStatic;
  2047. target._f = resolveFilter;
  2048. target._k = checkKeyCodes;
  2049. target._b = bindObjectProps;
  2050. target._v = createTextVNode;
  2051. target._e = createEmptyVNode;
  2052. target._u = resolveScopedSlots;
  2053. target._g = bindObjectListeners;
  2054. target._d = bindDynamicKeys;
  2055. target._p = prependModifier;
  2056. }
  2057. /**
  2058. * Runtime helper for resolving raw children VNodes into a slot object.
  2059. */
  2060. function resolveSlots(children, context) {
  2061. if (!children || !children.length) {
  2062. return {};
  2063. }
  2064. const slots = {};
  2065. for (let i = 0, l = children.length; i < l; i++) {
  2066. const child = children[i];
  2067. const data = child.data;
  2068. // remove slot attribute if the node is resolved as a Vue slot node
  2069. if (data && data.attrs && data.attrs.slot) {
  2070. delete data.attrs.slot;
  2071. }
  2072. // named slots should only be respected if the vnode was rendered in the
  2073. // same context.
  2074. if ((child.context === context || child.fnContext === context) &&
  2075. data &&
  2076. data.slot != null) {
  2077. const name = data.slot;
  2078. const slot = slots[name] || (slots[name] = []);
  2079. if (child.tag === 'template') {
  2080. slot.push.apply(slot, child.children || []);
  2081. }
  2082. else {
  2083. slot.push(child);
  2084. }
  2085. }
  2086. else {
  2087. (slots.default || (slots.default = [])).push(child);
  2088. }
  2089. }
  2090. // ignore slots that contains only whitespace
  2091. for (const name in slots) {
  2092. if (slots[name].every(isWhitespace)) {
  2093. delete slots[name];
  2094. }
  2095. }
  2096. return slots;
  2097. }
  2098. function isWhitespace(node) {
  2099. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2100. }
  2101. function isAsyncPlaceholder(node) {
  2102. // @ts-expect-error not really boolean type
  2103. return node.isComment && node.asyncFactory;
  2104. }
  2105. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2106. let res;
  2107. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2108. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2109. const key = scopedSlots && scopedSlots.$key;
  2110. if (!scopedSlots) {
  2111. res = {};
  2112. }
  2113. else if (scopedSlots._normalized) {
  2114. // fast path 1: child component re-render only, parent did not change
  2115. return scopedSlots._normalized;
  2116. }
  2117. else if (isStable &&
  2118. prevScopedSlots &&
  2119. prevScopedSlots !== emptyObject &&
  2120. key === prevScopedSlots.$key &&
  2121. !hasNormalSlots &&
  2122. !prevScopedSlots.$hasNormal) {
  2123. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2124. // only need to normalize once
  2125. return prevScopedSlots;
  2126. }
  2127. else {
  2128. res = {};
  2129. for (const key in scopedSlots) {
  2130. if (scopedSlots[key] && key[0] !== '$') {
  2131. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2132. }
  2133. }
  2134. }
  2135. // expose normal slots on scopedSlots
  2136. for (const key in normalSlots) {
  2137. if (!(key in res)) {
  2138. res[key] = proxyNormalSlot(normalSlots, key);
  2139. }
  2140. }
  2141. // avoriaz seems to mock a non-extensible $scopedSlots object
  2142. // and when that is passed down this would cause an error
  2143. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2144. scopedSlots._normalized = res;
  2145. }
  2146. def(res, '$stable', isStable);
  2147. def(res, '$key', key);
  2148. def(res, '$hasNormal', hasNormalSlots);
  2149. return res;
  2150. }
  2151. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2152. const normalized = function () {
  2153. const cur = currentInstance;
  2154. setCurrentInstance(vm);
  2155. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2156. res =
  2157. res && typeof res === 'object' && !isArray(res)
  2158. ? [res] // single vnode
  2159. : normalizeChildren(res);
  2160. const vnode = res && res[0];
  2161. setCurrentInstance(cur);
  2162. return res &&
  2163. (!vnode ||
  2164. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2165. ? undefined
  2166. : res;
  2167. };
  2168. // this is a slot using the new v-slot syntax without scope. although it is
  2169. // compiled as a scoped slot, render fn users would expect it to be present
  2170. // on this.$slots because the usage is semantically a normal slot.
  2171. if (fn.proxy) {
  2172. Object.defineProperty(normalSlots, key, {
  2173. get: normalized,
  2174. enumerable: true,
  2175. configurable: true
  2176. });
  2177. }
  2178. return normalized;
  2179. }
  2180. function proxyNormalSlot(slots, key) {
  2181. return () => slots[key];
  2182. }
  2183. function initSetup(vm) {
  2184. const options = vm.$options;
  2185. const setup = options.setup;
  2186. if (setup) {
  2187. const ctx = (vm._setupContext = createSetupContext(vm));
  2188. setCurrentInstance(vm);
  2189. pushTarget();
  2190. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2191. popTarget();
  2192. setCurrentInstance();
  2193. if (isFunction(setupResult)) {
  2194. // render function
  2195. // @ts-ignore
  2196. options.render = setupResult;
  2197. }
  2198. else if (isObject(setupResult)) {
  2199. // bindings
  2200. if (setupResult instanceof VNode) {
  2201. warn$2(`setup() should not return VNodes directly - ` +
  2202. `return a render function instead.`);
  2203. }
  2204. vm._setupState = setupResult;
  2205. // __sfc indicates compiled bindings from <script setup>
  2206. if (!setupResult.__sfc) {
  2207. for (const key in setupResult) {
  2208. if (!isReserved(key)) {
  2209. proxyWithRefUnwrap(vm, setupResult, key);
  2210. }
  2211. else {
  2212. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2213. }
  2214. }
  2215. }
  2216. else {
  2217. // exposed for compiled render fn
  2218. const proxy = (vm._setupProxy = {});
  2219. for (const key in setupResult) {
  2220. if (key !== '__sfc') {
  2221. proxyWithRefUnwrap(proxy, setupResult, key);
  2222. }
  2223. }
  2224. }
  2225. }
  2226. else if (setupResult !== undefined) {
  2227. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2228. }
  2229. }
  2230. }
  2231. function createSetupContext(vm) {
  2232. let exposeCalled = false;
  2233. return {
  2234. get attrs() {
  2235. if (!vm._attrsProxy) {
  2236. const proxy = (vm._attrsProxy = {});
  2237. def(proxy, '_v_attr_proxy', true);
  2238. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2239. }
  2240. return vm._attrsProxy;
  2241. },
  2242. get listeners() {
  2243. if (!vm._listenersProxy) {
  2244. const proxy = (vm._listenersProxy = {});
  2245. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2246. }
  2247. return vm._listenersProxy;
  2248. },
  2249. get slots() {
  2250. return initSlotsProxy(vm);
  2251. },
  2252. emit: bind$1(vm.$emit, vm),
  2253. expose(exposed) {
  2254. {
  2255. if (exposeCalled) {
  2256. warn$2(`expose() should be called only once per setup().`, vm);
  2257. }
  2258. exposeCalled = true;
  2259. }
  2260. if (exposed) {
  2261. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2262. }
  2263. }
  2264. };
  2265. }
  2266. function syncSetupProxy(to, from, prev, instance, type) {
  2267. let changed = false;
  2268. for (const key in from) {
  2269. if (!(key in to)) {
  2270. changed = true;
  2271. defineProxyAttr(to, key, instance, type);
  2272. }
  2273. else if (from[key] !== prev[key]) {
  2274. changed = true;
  2275. }
  2276. }
  2277. for (const key in to) {
  2278. if (!(key in from)) {
  2279. changed = true;
  2280. delete to[key];
  2281. }
  2282. }
  2283. return changed;
  2284. }
  2285. function defineProxyAttr(proxy, key, instance, type) {
  2286. Object.defineProperty(proxy, key, {
  2287. enumerable: true,
  2288. configurable: true,
  2289. get() {
  2290. return instance[type][key];
  2291. }
  2292. });
  2293. }
  2294. function initSlotsProxy(vm) {
  2295. if (!vm._slotsProxy) {
  2296. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2297. }
  2298. return vm._slotsProxy;
  2299. }
  2300. function syncSetupSlots(to, from) {
  2301. for (const key in from) {
  2302. to[key] = from[key];
  2303. }
  2304. for (const key in to) {
  2305. if (!(key in from)) {
  2306. delete to[key];
  2307. }
  2308. }
  2309. }
  2310. /**
  2311. * @internal use manual type def because public setup context type relies on
  2312. * legacy VNode types
  2313. */
  2314. function useSlots() {
  2315. return getContext().slots;
  2316. }
  2317. /**
  2318. * @internal use manual type def because public setup context type relies on
  2319. * legacy VNode types
  2320. */
  2321. function useAttrs() {
  2322. return getContext().attrs;
  2323. }
  2324. /**
  2325. * Vue 2 only
  2326. * @internal use manual type def because public setup context type relies on
  2327. * legacy VNode types
  2328. */
  2329. function useListeners() {
  2330. return getContext().listeners;
  2331. }
  2332. function getContext() {
  2333. if (!currentInstance) {
  2334. warn$2(`useContext() called without active instance.`);
  2335. }
  2336. const vm = currentInstance;
  2337. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2338. }
  2339. /**
  2340. * Runtime helper for merging default declarations. Imported by compiled code
  2341. * only.
  2342. * @internal
  2343. */
  2344. function mergeDefaults(raw, defaults) {
  2345. const props = isArray(raw)
  2346. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2347. : raw;
  2348. for (const key in defaults) {
  2349. const opt = props[key];
  2350. if (opt) {
  2351. if (isArray(opt) || isFunction(opt)) {
  2352. props[key] = { type: opt, default: defaults[key] };
  2353. }
  2354. else {
  2355. opt.default = defaults[key];
  2356. }
  2357. }
  2358. else if (opt === null) {
  2359. props[key] = { default: defaults[key] };
  2360. }
  2361. else {
  2362. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2363. }
  2364. }
  2365. return props;
  2366. }
  2367. function initRender(vm) {
  2368. vm._vnode = null; // the root of the child tree
  2369. vm._staticTrees = null; // v-once cached trees
  2370. const options = vm.$options;
  2371. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2372. const renderContext = parentVnode && parentVnode.context;
  2373. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2374. vm.$scopedSlots = parentVnode
  2375. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2376. : emptyObject;
  2377. // bind the createElement fn to this instance
  2378. // so that we get proper render context inside it.
  2379. // args order: tag, data, children, normalizationType, alwaysNormalize
  2380. // internal version is used by render functions compiled from templates
  2381. // @ts-expect-error
  2382. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2383. // normalization is always applied for the public version, used in
  2384. // user-written render functions.
  2385. // @ts-expect-error
  2386. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2387. // $attrs & $listeners are exposed for easier HOC creation.
  2388. // they need to be reactive so that HOCs using them are always updated
  2389. const parentData = parentVnode && parentVnode.data;
  2390. /* istanbul ignore else */
  2391. {
  2392. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2393. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2394. }, true);
  2395. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2396. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2397. }, true);
  2398. }
  2399. }
  2400. let currentRenderingInstance = null;
  2401. function renderMixin(Vue) {
  2402. // install runtime convenience helpers
  2403. installRenderHelpers(Vue.prototype);
  2404. Vue.prototype.$nextTick = function (fn) {
  2405. return nextTick(fn, this);
  2406. };
  2407. Vue.prototype._render = function () {
  2408. const vm = this;
  2409. const { render, _parentVnode } = vm.$options;
  2410. if (_parentVnode && vm._isMounted) {
  2411. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2412. if (vm._slotsProxy) {
  2413. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2414. }
  2415. }
  2416. // set parent vnode. this allows render functions to have access
  2417. // to the data on the placeholder node.
  2418. vm.$vnode = _parentVnode;
  2419. // render self
  2420. const prevInst = currentInstance;
  2421. const prevRenderInst = currentRenderingInstance;
  2422. let vnode;
  2423. try {
  2424. setCurrentInstance(vm);
  2425. currentRenderingInstance = vm;
  2426. vnode = render.call(vm._renderProxy, vm.$createElement);
  2427. }
  2428. catch (e) {
  2429. handleError(e, vm, `render`);
  2430. // return error render result,
  2431. // or previous vnode to prevent render error causing blank component
  2432. /* istanbul ignore else */
  2433. if (vm.$options.renderError) {
  2434. try {
  2435. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2436. }
  2437. catch (e) {
  2438. handleError(e, vm, `renderError`);
  2439. vnode = vm._vnode;
  2440. }
  2441. }
  2442. else {
  2443. vnode = vm._vnode;
  2444. }
  2445. }
  2446. finally {
  2447. currentRenderingInstance = prevRenderInst;
  2448. setCurrentInstance(prevInst);
  2449. }
  2450. // if the returned array contains only a single node, allow it
  2451. if (isArray(vnode) && vnode.length === 1) {
  2452. vnode = vnode[0];
  2453. }
  2454. // return empty vnode in case the render function errored out
  2455. if (!(vnode instanceof VNode)) {
  2456. if (isArray(vnode)) {
  2457. warn$2('Multiple root nodes returned from render function. Render function ' +
  2458. 'should return a single root node.', vm);
  2459. }
  2460. vnode = createEmptyVNode();
  2461. }
  2462. // set parent
  2463. vnode.parent = _parentVnode;
  2464. return vnode;
  2465. };
  2466. }
  2467. function ensureCtor(comp, base) {
  2468. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2469. comp = comp.default;
  2470. }
  2471. return isObject(comp) ? base.extend(comp) : comp;
  2472. }
  2473. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2474. const node = createEmptyVNode();
  2475. node.asyncFactory = factory;
  2476. node.asyncMeta = { data, context, children, tag };
  2477. return node;
  2478. }
  2479. function resolveAsyncComponent(factory, baseCtor) {
  2480. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2481. return factory.errorComp;
  2482. }
  2483. if (isDef(factory.resolved)) {
  2484. return factory.resolved;
  2485. }
  2486. const owner = currentRenderingInstance;
  2487. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2488. // already pending
  2489. factory.owners.push(owner);
  2490. }
  2491. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2492. return factory.loadingComp;
  2493. }
  2494. if (owner && !isDef(factory.owners)) {
  2495. const owners = (factory.owners = [owner]);
  2496. let sync = true;
  2497. let timerLoading = null;
  2498. let timerTimeout = null;
  2499. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2500. const forceRender = (renderCompleted) => {
  2501. for (let i = 0, l = owners.length; i < l; i++) {
  2502. owners[i].$forceUpdate();
  2503. }
  2504. if (renderCompleted) {
  2505. owners.length = 0;
  2506. if (timerLoading !== null) {
  2507. clearTimeout(timerLoading);
  2508. timerLoading = null;
  2509. }
  2510. if (timerTimeout !== null) {
  2511. clearTimeout(timerTimeout);
  2512. timerTimeout = null;
  2513. }
  2514. }
  2515. };
  2516. const resolve = once((res) => {
  2517. // cache resolved
  2518. factory.resolved = ensureCtor(res, baseCtor);
  2519. // invoke callbacks only if this is not a synchronous resolve
  2520. // (async resolves are shimmed as synchronous during SSR)
  2521. if (!sync) {
  2522. forceRender(true);
  2523. }
  2524. else {
  2525. owners.length = 0;
  2526. }
  2527. });
  2528. const reject = once(reason => {
  2529. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2530. (reason ? `\nReason: ${reason}` : ''));
  2531. if (isDef(factory.errorComp)) {
  2532. factory.error = true;
  2533. forceRender(true);
  2534. }
  2535. });
  2536. const res = factory(resolve, reject);
  2537. if (isObject(res)) {
  2538. if (isPromise(res)) {
  2539. // () => Promise
  2540. if (isUndef(factory.resolved)) {
  2541. res.then(resolve, reject);
  2542. }
  2543. }
  2544. else if (isPromise(res.component)) {
  2545. res.component.then(resolve, reject);
  2546. if (isDef(res.error)) {
  2547. factory.errorComp = ensureCtor(res.error, baseCtor);
  2548. }
  2549. if (isDef(res.loading)) {
  2550. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2551. if (res.delay === 0) {
  2552. factory.loading = true;
  2553. }
  2554. else {
  2555. // @ts-expect-error NodeJS timeout type
  2556. timerLoading = setTimeout(() => {
  2557. timerLoading = null;
  2558. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2559. factory.loading = true;
  2560. forceRender(false);
  2561. }
  2562. }, res.delay || 200);
  2563. }
  2564. }
  2565. if (isDef(res.timeout)) {
  2566. // @ts-expect-error NodeJS timeout type
  2567. timerTimeout = setTimeout(() => {
  2568. timerTimeout = null;
  2569. if (isUndef(factory.resolved)) {
  2570. reject(`timeout (${res.timeout}ms)` );
  2571. }
  2572. }, res.timeout);
  2573. }
  2574. }
  2575. }
  2576. sync = false;
  2577. // return in case resolved synchronously
  2578. return factory.loading ? factory.loadingComp : factory.resolved;
  2579. }
  2580. }
  2581. function getFirstComponentChild(children) {
  2582. if (isArray(children)) {
  2583. for (let i = 0; i < children.length; i++) {
  2584. const c = children[i];
  2585. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2586. return c;
  2587. }
  2588. }
  2589. }
  2590. }
  2591. function initEvents(vm) {
  2592. vm._events = Object.create(null);
  2593. vm._hasHookEvent = false;
  2594. // init parent attached events
  2595. const listeners = vm.$options._parentListeners;
  2596. if (listeners) {
  2597. updateComponentListeners(vm, listeners);
  2598. }
  2599. }
  2600. let target$1;
  2601. function add$1(event, fn) {
  2602. target$1.$on(event, fn);
  2603. }
  2604. function remove$1(event, fn) {
  2605. target$1.$off(event, fn);
  2606. }
  2607. function createOnceHandler$1(event, fn) {
  2608. const _target = target$1;
  2609. return function onceHandler() {
  2610. const res = fn.apply(null, arguments);
  2611. if (res !== null) {
  2612. _target.$off(event, onceHandler);
  2613. }
  2614. };
  2615. }
  2616. function updateComponentListeners(vm, listeners, oldListeners) {
  2617. target$1 = vm;
  2618. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2619. target$1 = undefined;
  2620. }
  2621. function eventsMixin(Vue) {
  2622. const hookRE = /^hook:/;
  2623. Vue.prototype.$on = function (event, fn) {
  2624. const vm = this;
  2625. if (isArray(event)) {
  2626. for (let i = 0, l = event.length; i < l; i++) {
  2627. vm.$on(event[i], fn);
  2628. }
  2629. }
  2630. else {
  2631. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2632. // optimize hook:event cost by using a boolean flag marked at registration
  2633. // instead of a hash lookup
  2634. if (hookRE.test(event)) {
  2635. vm._hasHookEvent = true;
  2636. }
  2637. }
  2638. return vm;
  2639. };
  2640. Vue.prototype.$once = function (event, fn) {
  2641. const vm = this;
  2642. function on() {
  2643. vm.$off(event, on);
  2644. fn.apply(vm, arguments);
  2645. }
  2646. on.fn = fn;
  2647. vm.$on(event, on);
  2648. return vm;
  2649. };
  2650. Vue.prototype.$off = function (event, fn) {
  2651. const vm = this;
  2652. // all
  2653. if (!arguments.length) {
  2654. vm._events = Object.create(null);
  2655. return vm;
  2656. }
  2657. // array of events
  2658. if (isArray(event)) {
  2659. for (let i = 0, l = event.length; i < l; i++) {
  2660. vm.$off(event[i], fn);
  2661. }
  2662. return vm;
  2663. }
  2664. // specific event
  2665. const cbs = vm._events[event];
  2666. if (!cbs) {
  2667. return vm;
  2668. }
  2669. if (!fn) {
  2670. vm._events[event] = null;
  2671. return vm;
  2672. }
  2673. // specific handler
  2674. let cb;
  2675. let i = cbs.length;
  2676. while (i--) {
  2677. cb = cbs[i];
  2678. if (cb === fn || cb.fn === fn) {
  2679. cbs.splice(i, 1);
  2680. break;
  2681. }
  2682. }
  2683. return vm;
  2684. };
  2685. Vue.prototype.$emit = function (event) {
  2686. const vm = this;
  2687. {
  2688. const lowerCaseEvent = event.toLowerCase();
  2689. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2690. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2691. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2692. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2693. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2694. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2695. }
  2696. }
  2697. let cbs = vm._events[event];
  2698. if (cbs) {
  2699. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2700. const args = toArray(arguments, 1);
  2701. const info = `event handler for "${event}"`;
  2702. for (let i = 0, l = cbs.length; i < l; i++) {
  2703. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2704. }
  2705. }
  2706. return vm;
  2707. };
  2708. }
  2709. let activeEffectScope;
  2710. class EffectScope {
  2711. constructor(detached = false) {
  2712. this.detached = detached;
  2713. /**
  2714. * @internal
  2715. */
  2716. this.active = true;
  2717. /**
  2718. * @internal
  2719. */
  2720. this.effects = [];
  2721. /**
  2722. * @internal
  2723. */
  2724. this.cleanups = [];
  2725. this.parent = activeEffectScope;
  2726. if (!detached && activeEffectScope) {
  2727. this.index =
  2728. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  2729. }
  2730. }
  2731. run(fn) {
  2732. if (this.active) {
  2733. const currentEffectScope = activeEffectScope;
  2734. try {
  2735. activeEffectScope = this;
  2736. return fn();
  2737. }
  2738. finally {
  2739. activeEffectScope = currentEffectScope;
  2740. }
  2741. }
  2742. else {
  2743. warn$2(`cannot run an inactive effect scope.`);
  2744. }
  2745. }
  2746. /**
  2747. * This should only be called on non-detached scopes
  2748. * @internal
  2749. */
  2750. on() {
  2751. activeEffectScope = this;
  2752. }
  2753. /**
  2754. * This should only be called on non-detached scopes
  2755. * @internal
  2756. */
  2757. off() {
  2758. activeEffectScope = this.parent;
  2759. }
  2760. stop(fromParent) {
  2761. if (this.active) {
  2762. let i, l;
  2763. for (i = 0, l = this.effects.length; i < l; i++) {
  2764. this.effects[i].teardown();
  2765. }
  2766. for (i = 0, l = this.cleanups.length; i < l; i++) {
  2767. this.cleanups[i]();
  2768. }
  2769. if (this.scopes) {
  2770. for (i = 0, l = this.scopes.length; i < l; i++) {
  2771. this.scopes[i].stop(true);
  2772. }
  2773. }
  2774. // nested scope, dereference from parent to avoid memory leaks
  2775. if (!this.detached && this.parent && !fromParent) {
  2776. // optimized O(1) removal
  2777. const last = this.parent.scopes.pop();
  2778. if (last && last !== this) {
  2779. this.parent.scopes[this.index] = last;
  2780. last.index = this.index;
  2781. }
  2782. }
  2783. this.parent = undefined;
  2784. this.active = false;
  2785. }
  2786. }
  2787. }
  2788. function effectScope(detached) {
  2789. return new EffectScope(detached);
  2790. }
  2791. /**
  2792. * @internal
  2793. */
  2794. function recordEffectScope(effect, scope = activeEffectScope) {
  2795. if (scope && scope.active) {
  2796. scope.effects.push(effect);
  2797. }
  2798. }
  2799. function getCurrentScope() {
  2800. return activeEffectScope;
  2801. }
  2802. function onScopeDispose(fn) {
  2803. if (activeEffectScope) {
  2804. activeEffectScope.cleanups.push(fn);
  2805. }
  2806. else {
  2807. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  2808. ` to be associated with.`);
  2809. }
  2810. }
  2811. let activeInstance = null;
  2812. let isUpdatingChildComponent = false;
  2813. function setActiveInstance(vm) {
  2814. const prevActiveInstance = activeInstance;
  2815. activeInstance = vm;
  2816. return () => {
  2817. activeInstance = prevActiveInstance;
  2818. };
  2819. }
  2820. function initLifecycle(vm) {
  2821. const options = vm.$options;
  2822. // locate first non-abstract parent
  2823. let parent = options.parent;
  2824. if (parent && !options.abstract) {
  2825. while (parent.$options.abstract && parent.$parent) {
  2826. parent = parent.$parent;
  2827. }
  2828. parent.$children.push(vm);
  2829. }
  2830. vm.$parent = parent;
  2831. vm.$root = parent ? parent.$root : vm;
  2832. vm.$children = [];
  2833. vm.$refs = {};
  2834. vm._provided = parent ? parent._provided : Object.create(null);
  2835. vm._watcher = null;
  2836. vm._inactive = null;
  2837. vm._directInactive = false;
  2838. vm._isMounted = false;
  2839. vm._isDestroyed = false;
  2840. vm._isBeingDestroyed = false;
  2841. }
  2842. function lifecycleMixin(Vue) {
  2843. Vue.prototype._update = function (vnode, hydrating) {
  2844. const vm = this;
  2845. const prevEl = vm.$el;
  2846. const prevVnode = vm._vnode;
  2847. const restoreActiveInstance = setActiveInstance(vm);
  2848. vm._vnode = vnode;
  2849. // Vue.prototype.__patch__ is injected in entry points
  2850. // based on the rendering backend used.
  2851. if (!prevVnode) {
  2852. // initial render
  2853. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2854. }
  2855. else {
  2856. // updates
  2857. vm.$el = vm.__patch__(prevVnode, vnode);
  2858. }
  2859. restoreActiveInstance();
  2860. // update __vue__ reference
  2861. if (prevEl) {
  2862. prevEl.__vue__ = null;
  2863. }
  2864. if (vm.$el) {
  2865. vm.$el.__vue__ = vm;
  2866. }
  2867. // if parent is an HOC, update its $el as well
  2868. let wrapper = vm;
  2869. while (wrapper &&
  2870. wrapper.$vnode &&
  2871. wrapper.$parent &&
  2872. wrapper.$vnode === wrapper.$parent._vnode) {
  2873. wrapper.$parent.$el = wrapper.$el;
  2874. wrapper = wrapper.$parent;
  2875. }
  2876. // updated hook is called by the scheduler to ensure that children are
  2877. // updated in a parent's updated hook.
  2878. };
  2879. Vue.prototype.$forceUpdate = function () {
  2880. const vm = this;
  2881. if (vm._watcher) {
  2882. vm._watcher.update();
  2883. }
  2884. };
  2885. Vue.prototype.$destroy = function () {
  2886. const vm = this;
  2887. if (vm._isBeingDestroyed) {
  2888. return;
  2889. }
  2890. callHook$1(vm, 'beforeDestroy');
  2891. vm._isBeingDestroyed = true;
  2892. // remove self from parent
  2893. const parent = vm.$parent;
  2894. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2895. remove$2(parent.$children, vm);
  2896. }
  2897. // teardown scope. this includes both the render watcher and other
  2898. // watchers created
  2899. vm._scope.stop();
  2900. // remove reference from data ob
  2901. // frozen object may not have observer.
  2902. if (vm._data.__ob__) {
  2903. vm._data.__ob__.vmCount--;
  2904. }
  2905. // call the last hook...
  2906. vm._isDestroyed = true;
  2907. // invoke destroy hooks on current rendered tree
  2908. vm.__patch__(vm._vnode, null);
  2909. // fire destroyed hook
  2910. callHook$1(vm, 'destroyed');
  2911. // turn off all instance listeners.
  2912. vm.$off();
  2913. // remove __vue__ reference
  2914. if (vm.$el) {
  2915. vm.$el.__vue__ = null;
  2916. }
  2917. // release circular reference (#6759)
  2918. if (vm.$vnode) {
  2919. vm.$vnode.parent = null;
  2920. }
  2921. };
  2922. }
  2923. function mountComponent(vm, el, hydrating) {
  2924. vm.$el = el;
  2925. if (!vm.$options.render) {
  2926. // @ts-expect-error invalid type
  2927. vm.$options.render = createEmptyVNode;
  2928. {
  2929. /* istanbul ignore if */
  2930. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2931. vm.$options.el ||
  2932. el) {
  2933. warn$2('You are using the runtime-only build of Vue where the template ' +
  2934. 'compiler is not available. Either pre-compile the templates into ' +
  2935. 'render functions, or use the compiler-included build.', vm);
  2936. }
  2937. else {
  2938. warn$2('Failed to mount component: template or render function not defined.', vm);
  2939. }
  2940. }
  2941. }
  2942. callHook$1(vm, 'beforeMount');
  2943. let updateComponent;
  2944. /* istanbul ignore if */
  2945. if (config.performance && mark) {
  2946. updateComponent = () => {
  2947. const name = vm._name;
  2948. const id = vm._uid;
  2949. const startTag = `vue-perf-start:${id}`;
  2950. const endTag = `vue-perf-end:${id}`;
  2951. mark(startTag);
  2952. const vnode = vm._render();
  2953. mark(endTag);
  2954. measure(`vue ${name} render`, startTag, endTag);
  2955. mark(startTag);
  2956. vm._update(vnode, hydrating);
  2957. mark(endTag);
  2958. measure(`vue ${name} patch`, startTag, endTag);
  2959. };
  2960. }
  2961. else {
  2962. updateComponent = () => {
  2963. vm._update(vm._render(), hydrating);
  2964. };
  2965. }
  2966. const watcherOptions = {
  2967. before() {
  2968. if (vm._isMounted && !vm._isDestroyed) {
  2969. callHook$1(vm, 'beforeUpdate');
  2970. }
  2971. }
  2972. };
  2973. {
  2974. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2975. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2976. }
  2977. // we set this to vm._watcher inside the watcher's constructor
  2978. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2979. // component's mounted hook), which relies on vm._watcher being already defined
  2980. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2981. hydrating = false;
  2982. // flush buffer for flush: "pre" watchers queued in setup()
  2983. const preWatchers = vm._preWatchers;
  2984. if (preWatchers) {
  2985. for (let i = 0; i < preWatchers.length; i++) {
  2986. preWatchers[i].run();
  2987. }
  2988. }
  2989. // manually mounted instance, call mounted on self
  2990. // mounted is called for render-created child components in its inserted hook
  2991. if (vm.$vnode == null) {
  2992. vm._isMounted = true;
  2993. callHook$1(vm, 'mounted');
  2994. }
  2995. return vm;
  2996. }
  2997. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2998. {
  2999. isUpdatingChildComponent = true;
  3000. }
  3001. // determine whether component has slot children
  3002. // we need to do this before overwriting $options._renderChildren.
  3003. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3004. // dynamic slot names). Static scoped slots compiled from template has the
  3005. // "$stable" marker.
  3006. const newScopedSlots = parentVnode.data.scopedSlots;
  3007. const oldScopedSlots = vm.$scopedSlots;
  3008. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3009. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3010. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3011. (!newScopedSlots && vm.$scopedSlots.$key));
  3012. // Any static slot children from the parent may have changed during parent's
  3013. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3014. // update is necessary to ensure correctness.
  3015. let needsForceUpdate = !!(renderChildren || // has new static slots
  3016. vm.$options._renderChildren || // has old static slots
  3017. hasDynamicScopedSlot);
  3018. const prevVNode = vm.$vnode;
  3019. vm.$options._parentVnode = parentVnode;
  3020. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3021. if (vm._vnode) {
  3022. // update child tree's parent
  3023. vm._vnode.parent = parentVnode;
  3024. }
  3025. vm.$options._renderChildren = renderChildren;
  3026. // update $attrs and $listeners hash
  3027. // these are also reactive so they may trigger child update if the child
  3028. // used them during render
  3029. const attrs = parentVnode.data.attrs || emptyObject;
  3030. if (vm._attrsProxy) {
  3031. // force update if attrs are accessed and has changed since it may be
  3032. // passed to a child component.
  3033. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3034. needsForceUpdate = true;
  3035. }
  3036. }
  3037. vm.$attrs = attrs;
  3038. // update listeners
  3039. listeners = listeners || emptyObject;
  3040. const prevListeners = vm.$options._parentListeners;
  3041. if (vm._listenersProxy) {
  3042. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3043. }
  3044. vm.$listeners = vm.$options._parentListeners = listeners;
  3045. updateComponentListeners(vm, listeners, prevListeners);
  3046. // update props
  3047. if (propsData && vm.$options.props) {
  3048. toggleObserving(false);
  3049. const props = vm._props;
  3050. const propKeys = vm.$options._propKeys || [];
  3051. for (let i = 0; i < propKeys.length; i++) {
  3052. const key = propKeys[i];
  3053. const propOptions = vm.$options.props; // wtf flow?
  3054. props[key] = validateProp(key, propOptions, propsData, vm);
  3055. }
  3056. toggleObserving(true);
  3057. // keep a copy of raw propsData
  3058. vm.$options.propsData = propsData;
  3059. }
  3060. // resolve slots + force update if has children
  3061. if (needsForceUpdate) {
  3062. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3063. vm.$forceUpdate();
  3064. }
  3065. {
  3066. isUpdatingChildComponent = false;
  3067. }
  3068. }
  3069. function isInInactiveTree(vm) {
  3070. while (vm && (vm = vm.$parent)) {
  3071. if (vm._inactive)
  3072. return true;
  3073. }
  3074. return false;
  3075. }
  3076. function activateChildComponent(vm, direct) {
  3077. if (direct) {
  3078. vm._directInactive = false;
  3079. if (isInInactiveTree(vm)) {
  3080. return;
  3081. }
  3082. }
  3083. else if (vm._directInactive) {
  3084. return;
  3085. }
  3086. if (vm._inactive || vm._inactive === null) {
  3087. vm._inactive = false;
  3088. for (let i = 0; i < vm.$children.length; i++) {
  3089. activateChildComponent(vm.$children[i]);
  3090. }
  3091. callHook$1(vm, 'activated');
  3092. }
  3093. }
  3094. function deactivateChildComponent(vm, direct) {
  3095. if (direct) {
  3096. vm._directInactive = true;
  3097. if (isInInactiveTree(vm)) {
  3098. return;
  3099. }
  3100. }
  3101. if (!vm._inactive) {
  3102. vm._inactive = true;
  3103. for (let i = 0; i < vm.$children.length; i++) {
  3104. deactivateChildComponent(vm.$children[i]);
  3105. }
  3106. callHook$1(vm, 'deactivated');
  3107. }
  3108. }
  3109. function callHook$1(vm, hook, args, setContext = true) {
  3110. // #7573 disable dep collection when invoking lifecycle hooks
  3111. pushTarget();
  3112. const prevInst = currentInstance;
  3113. const prevScope = getCurrentScope();
  3114. setContext && setCurrentInstance(vm);
  3115. const handlers = vm.$options[hook];
  3116. const info = `${hook} hook`;
  3117. if (handlers) {
  3118. for (let i = 0, j = handlers.length; i < j; i++) {
  3119. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3120. }
  3121. }
  3122. if (vm._hasHookEvent) {
  3123. vm.$emit('hook:' + hook);
  3124. }
  3125. if (setContext) {
  3126. setCurrentInstance(prevInst);
  3127. prevScope && prevScope.on();
  3128. }
  3129. popTarget();
  3130. }
  3131. const MAX_UPDATE_COUNT = 100;
  3132. const queue = [];
  3133. const activatedChildren = [];
  3134. let has = {};
  3135. let circular = {};
  3136. let waiting = false;
  3137. let flushing = false;
  3138. let index$1 = 0;
  3139. /**
  3140. * Reset the scheduler's state.
  3141. */
  3142. function resetSchedulerState() {
  3143. index$1 = queue.length = activatedChildren.length = 0;
  3144. has = {};
  3145. {
  3146. circular = {};
  3147. }
  3148. waiting = flushing = false;
  3149. }
  3150. // Async edge case #6566 requires saving the timestamp when event listeners are
  3151. // attached. However, calling performance.now() has a perf overhead especially
  3152. // if the page has thousands of event listeners. Instead, we take a timestamp
  3153. // every time the scheduler flushes and use that for all event listeners
  3154. // attached during that flush.
  3155. let currentFlushTimestamp = 0;
  3156. // Async edge case fix requires storing an event listener's attach timestamp.
  3157. let getNow = Date.now;
  3158. // Determine what event timestamp the browser is using. Annoyingly, the
  3159. // timestamp can either be hi-res (relative to page load) or low-res
  3160. // (relative to UNIX epoch), so in order to compare time we have to use the
  3161. // same timestamp type when saving the flush timestamp.
  3162. // All IE versions use low-res event timestamps, and have problematic clock
  3163. // implementations (#9632)
  3164. if (inBrowser && !isIE) {
  3165. const performance = window.performance;
  3166. if (performance &&
  3167. typeof performance.now === 'function' &&
  3168. getNow() > document.createEvent('Event').timeStamp) {
  3169. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3170. // smaller than it, it means the event is using a hi-res timestamp,
  3171. // and we need to use the hi-res version for event listener timestamps as
  3172. // well.
  3173. getNow = () => performance.now();
  3174. }
  3175. }
  3176. const sortCompareFn = (a, b) => {
  3177. if (a.post) {
  3178. if (!b.post)
  3179. return 1;
  3180. }
  3181. else if (b.post) {
  3182. return -1;
  3183. }
  3184. return a.id - b.id;
  3185. };
  3186. /**
  3187. * Flush both queues and run the watchers.
  3188. */
  3189. function flushSchedulerQueue() {
  3190. currentFlushTimestamp = getNow();
  3191. flushing = true;
  3192. let watcher, id;
  3193. // Sort queue before flush.
  3194. // This ensures that:
  3195. // 1. Components are updated from parent to child. (because parent is always
  3196. // created before the child)
  3197. // 2. A component's user watchers are run before its render watcher (because
  3198. // user watchers are created before the render watcher)
  3199. // 3. If a component is destroyed during a parent component's watcher run,
  3200. // its watchers can be skipped.
  3201. queue.sort(sortCompareFn);
  3202. // do not cache length because more watchers might be pushed
  3203. // as we run existing watchers
  3204. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3205. watcher = queue[index$1];
  3206. if (watcher.before) {
  3207. watcher.before();
  3208. }
  3209. id = watcher.id;
  3210. has[id] = null;
  3211. watcher.run();
  3212. // in dev build, check and stop circular updates.
  3213. if (has[id] != null) {
  3214. circular[id] = (circular[id] || 0) + 1;
  3215. if (circular[id] > MAX_UPDATE_COUNT) {
  3216. warn$2('You may have an infinite update loop ' +
  3217. (watcher.user
  3218. ? `in watcher with expression "${watcher.expression}"`
  3219. : `in a component render function.`), watcher.vm);
  3220. break;
  3221. }
  3222. }
  3223. }
  3224. // keep copies of post queues before resetting state
  3225. const activatedQueue = activatedChildren.slice();
  3226. const updatedQueue = queue.slice();
  3227. resetSchedulerState();
  3228. // call component updated and activated hooks
  3229. callActivatedHooks(activatedQueue);
  3230. callUpdatedHooks(updatedQueue);
  3231. cleanupDeps();
  3232. // devtool hook
  3233. /* istanbul ignore if */
  3234. if (devtools && config.devtools) {
  3235. devtools.emit('flush');
  3236. }
  3237. }
  3238. function callUpdatedHooks(queue) {
  3239. let i = queue.length;
  3240. while (i--) {
  3241. const watcher = queue[i];
  3242. const vm = watcher.vm;
  3243. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3244. callHook$1(vm, 'updated');
  3245. }
  3246. }
  3247. }
  3248. /**
  3249. * Queue a kept-alive component that was activated during patch.
  3250. * The queue will be processed after the entire tree has been patched.
  3251. */
  3252. function queueActivatedComponent(vm) {
  3253. // setting _inactive to false here so that a render function can
  3254. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3255. vm._inactive = false;
  3256. activatedChildren.push(vm);
  3257. }
  3258. function callActivatedHooks(queue) {
  3259. for (let i = 0; i < queue.length; i++) {
  3260. queue[i]._inactive = true;
  3261. activateChildComponent(queue[i], true /* true */);
  3262. }
  3263. }
  3264. /**
  3265. * Push a watcher into the watcher queue.
  3266. * Jobs with duplicate IDs will be skipped unless it's
  3267. * pushed when the queue is being flushed.
  3268. */
  3269. function queueWatcher(watcher) {
  3270. const id = watcher.id;
  3271. if (has[id] != null) {
  3272. return;
  3273. }
  3274. if (watcher === Dep.target && watcher.noRecurse) {
  3275. return;
  3276. }
  3277. has[id] = true;
  3278. if (!flushing) {
  3279. queue.push(watcher);
  3280. }
  3281. else {
  3282. // if already flushing, splice the watcher based on its id
  3283. // if already past its id, it will be run next immediately.
  3284. let i = queue.length - 1;
  3285. while (i > index$1 && queue[i].id > watcher.id) {
  3286. i--;
  3287. }
  3288. queue.splice(i + 1, 0, watcher);
  3289. }
  3290. // queue the flush
  3291. if (!waiting) {
  3292. waiting = true;
  3293. if (!config.async) {
  3294. flushSchedulerQueue();
  3295. return;
  3296. }
  3297. nextTick(flushSchedulerQueue);
  3298. }
  3299. }
  3300. const WATCHER = `watcher`;
  3301. const WATCHER_CB = `${WATCHER} callback`;
  3302. const WATCHER_GETTER = `${WATCHER} getter`;
  3303. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3304. // Simple effect.
  3305. function watchEffect(effect, options) {
  3306. return doWatch(effect, null, options);
  3307. }
  3308. function watchPostEffect(effect, options) {
  3309. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3310. }
  3311. function watchSyncEffect(effect, options) {
  3312. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3313. }
  3314. // initial value for watchers to trigger on undefined initial values
  3315. const INITIAL_WATCHER_VALUE = {};
  3316. // implementation
  3317. function watch(source, cb, options) {
  3318. if (typeof cb !== 'function') {
  3319. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3320. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3321. `supports \`watch(source, cb, options?) signature.`);
  3322. }
  3323. return doWatch(source, cb, options);
  3324. }
  3325. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3326. if (!cb) {
  3327. if (immediate !== undefined) {
  3328. warn$2(`watch() "immediate" option is only respected when using the ` +
  3329. `watch(source, callback, options?) signature.`);
  3330. }
  3331. if (deep !== undefined) {
  3332. warn$2(`watch() "deep" option is only respected when using the ` +
  3333. `watch(source, callback, options?) signature.`);
  3334. }
  3335. }
  3336. const warnInvalidSource = (s) => {
  3337. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3338. `function, a ref, a reactive object, or an array of these types.`);
  3339. };
  3340. const instance = currentInstance;
  3341. const call = (fn, type, args = null) => {
  3342. const res = invokeWithErrorHandling(fn, null, args, instance, type);
  3343. if (deep && res && res.__ob__)
  3344. res.__ob__.dep.depend();
  3345. return res;
  3346. };
  3347. let getter;
  3348. let forceTrigger = false;
  3349. let isMultiSource = false;
  3350. if (isRef(source)) {
  3351. getter = () => source.value;
  3352. forceTrigger = isShallow(source);
  3353. }
  3354. else if (isReactive(source)) {
  3355. getter = () => {
  3356. source.__ob__.dep.depend();
  3357. return source;
  3358. };
  3359. deep = true;
  3360. }
  3361. else if (isArray(source)) {
  3362. isMultiSource = true;
  3363. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3364. getter = () => source.map(s => {
  3365. if (isRef(s)) {
  3366. return s.value;
  3367. }
  3368. else if (isReactive(s)) {
  3369. s.__ob__.dep.depend();
  3370. return traverse(s);
  3371. }
  3372. else if (isFunction(s)) {
  3373. return call(s, WATCHER_GETTER);
  3374. }
  3375. else {
  3376. warnInvalidSource(s);
  3377. }
  3378. });
  3379. }
  3380. else if (isFunction(source)) {
  3381. if (cb) {
  3382. // getter with cb
  3383. getter = () => call(source, WATCHER_GETTER);
  3384. }
  3385. else {
  3386. // no cb -> simple effect
  3387. getter = () => {
  3388. if (instance && instance._isDestroyed) {
  3389. return;
  3390. }
  3391. if (cleanup) {
  3392. cleanup();
  3393. }
  3394. return call(source, WATCHER, [onCleanup]);
  3395. };
  3396. }
  3397. }
  3398. else {
  3399. getter = noop;
  3400. warnInvalidSource(source);
  3401. }
  3402. if (cb && deep) {
  3403. const baseGetter = getter;
  3404. getter = () => traverse(baseGetter());
  3405. }
  3406. let cleanup;
  3407. let onCleanup = (fn) => {
  3408. cleanup = watcher.onStop = () => {
  3409. call(fn, WATCHER_CLEANUP);
  3410. };
  3411. };
  3412. // in SSR there is no need to setup an actual effect, and it should be noop
  3413. // unless it's eager
  3414. if (isServerRendering()) {
  3415. // we will also not call the invalidate callback (+ runner is not set up)
  3416. onCleanup = noop;
  3417. if (!cb) {
  3418. getter();
  3419. }
  3420. else if (immediate) {
  3421. call(cb, WATCHER_CB, [
  3422. getter(),
  3423. isMultiSource ? [] : undefined,
  3424. onCleanup
  3425. ]);
  3426. }
  3427. return noop;
  3428. }
  3429. const watcher = new Watcher(currentInstance, getter, noop, {
  3430. lazy: true
  3431. });
  3432. watcher.noRecurse = !cb;
  3433. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3434. // overwrite default run
  3435. watcher.run = () => {
  3436. if (!watcher.active) {
  3437. return;
  3438. }
  3439. if (cb) {
  3440. // watch(source, cb)
  3441. const newValue = watcher.get();
  3442. if (deep ||
  3443. forceTrigger ||
  3444. (isMultiSource
  3445. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3446. : hasChanged(newValue, oldValue))) {
  3447. // cleanup before running cb again
  3448. if (cleanup) {
  3449. cleanup();
  3450. }
  3451. call(cb, WATCHER_CB, [
  3452. newValue,
  3453. // pass undefined as the old value when it's changed for the first time
  3454. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3455. onCleanup
  3456. ]);
  3457. oldValue = newValue;
  3458. }
  3459. }
  3460. else {
  3461. // watchEffect
  3462. watcher.get();
  3463. }
  3464. };
  3465. if (flush === 'sync') {
  3466. watcher.update = watcher.run;
  3467. }
  3468. else if (flush === 'post') {
  3469. watcher.post = true;
  3470. watcher.update = () => queueWatcher(watcher);
  3471. }
  3472. else {
  3473. // pre
  3474. watcher.update = () => {
  3475. if (instance && instance === currentInstance && !instance._isMounted) {
  3476. // pre-watcher triggered before
  3477. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3478. if (buffer.indexOf(watcher) < 0)
  3479. buffer.push(watcher);
  3480. }
  3481. else {
  3482. queueWatcher(watcher);
  3483. }
  3484. };
  3485. }
  3486. {
  3487. watcher.onTrack = onTrack;
  3488. watcher.onTrigger = onTrigger;
  3489. }
  3490. // initial run
  3491. if (cb) {
  3492. if (immediate) {
  3493. watcher.run();
  3494. }
  3495. else {
  3496. oldValue = watcher.get();
  3497. }
  3498. }
  3499. else if (flush === 'post' && instance) {
  3500. instance.$once('hook:mounted', () => watcher.get());
  3501. }
  3502. else {
  3503. watcher.get();
  3504. }
  3505. return () => {
  3506. watcher.teardown();
  3507. };
  3508. }
  3509. function provide(key, value) {
  3510. if (!currentInstance) {
  3511. {
  3512. warn$2(`provide() can only be used inside setup().`);
  3513. }
  3514. }
  3515. else {
  3516. // TS doesn't allow symbol as index type
  3517. resolveProvided(currentInstance)[key] = value;
  3518. }
  3519. }
  3520. function resolveProvided(vm) {
  3521. // by default an instance inherits its parent's provides object
  3522. // but when it needs to provide values of its own, it creates its
  3523. // own provides object using parent provides object as prototype.
  3524. // this way in `inject` we can simply look up injections from direct
  3525. // parent and let the prototype chain do the work.
  3526. const existing = vm._provided;
  3527. const parentProvides = vm.$parent && vm.$parent._provided;
  3528. if (parentProvides === existing) {
  3529. return (vm._provided = Object.create(parentProvides));
  3530. }
  3531. else {
  3532. return existing;
  3533. }
  3534. }
  3535. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3536. // fallback to `currentRenderingInstance` so that this can be called in
  3537. // a functional component
  3538. const instance = currentInstance;
  3539. if (instance) {
  3540. // #2400
  3541. // to support `app.use` plugins,
  3542. // fallback to appContext's `provides` if the instance is at root
  3543. const provides = instance.$parent && instance.$parent._provided;
  3544. if (provides && key in provides) {
  3545. // TS doesn't allow symbol as index type
  3546. return provides[key];
  3547. }
  3548. else if (arguments.length > 1) {
  3549. return treatDefaultAsFactory && isFunction(defaultValue)
  3550. ? defaultValue.call(instance)
  3551. : defaultValue;
  3552. }
  3553. else {
  3554. warn$2(`injection "${String(key)}" not found.`);
  3555. }
  3556. }
  3557. else {
  3558. warn$2(`inject() can only be used inside setup() or functional components.`);
  3559. }
  3560. }
  3561. /**
  3562. * @internal this function needs manual public type declaration because it relies
  3563. * on previously manually authored types from Vue 2
  3564. */
  3565. function h(type, props, children) {
  3566. if (!currentInstance) {
  3567. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3568. `component instance, e.g. synchronously in a component's render or setup function.`);
  3569. }
  3570. return createElement$1(currentInstance, type, props, children, 2, true);
  3571. }
  3572. function handleError(err, vm, info) {
  3573. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3574. // See: https://github.com/vuejs/vuex/issues/1505
  3575. pushTarget();
  3576. try {
  3577. if (vm) {
  3578. let cur = vm;
  3579. while ((cur = cur.$parent)) {
  3580. const hooks = cur.$options.errorCaptured;
  3581. if (hooks) {
  3582. for (let i = 0; i < hooks.length; i++) {
  3583. try {
  3584. const capture = hooks[i].call(cur, err, vm, info) === false;
  3585. if (capture)
  3586. return;
  3587. }
  3588. catch (e) {
  3589. globalHandleError(e, cur, 'errorCaptured hook');
  3590. }
  3591. }
  3592. }
  3593. }
  3594. }
  3595. globalHandleError(err, vm, info);
  3596. }
  3597. finally {
  3598. popTarget();
  3599. }
  3600. }
  3601. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3602. let res;
  3603. try {
  3604. res = args ? handler.apply(context, args) : handler.call(context);
  3605. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3606. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3607. res._handled = true;
  3608. }
  3609. }
  3610. catch (e) {
  3611. handleError(e, vm, info);
  3612. }
  3613. return res;
  3614. }
  3615. function globalHandleError(err, vm, info) {
  3616. if (config.errorHandler) {
  3617. try {
  3618. return config.errorHandler.call(null, err, vm, info);
  3619. }
  3620. catch (e) {
  3621. // if the user intentionally throws the original error in the handler,
  3622. // do not log it twice
  3623. if (e !== err) {
  3624. logError(e, null, 'config.errorHandler');
  3625. }
  3626. }
  3627. }
  3628. logError(err, vm, info);
  3629. }
  3630. function logError(err, vm, info) {
  3631. {
  3632. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3633. }
  3634. /* istanbul ignore else */
  3635. if (inBrowser && typeof console !== 'undefined') {
  3636. console.error(err);
  3637. }
  3638. else {
  3639. throw err;
  3640. }
  3641. }
  3642. /* globals MutationObserver */
  3643. let isUsingMicroTask = false;
  3644. const callbacks = [];
  3645. let pending = false;
  3646. function flushCallbacks() {
  3647. pending = false;
  3648. const copies = callbacks.slice(0);
  3649. callbacks.length = 0;
  3650. for (let i = 0; i < copies.length; i++) {
  3651. copies[i]();
  3652. }
  3653. }
  3654. // Here we have async deferring wrappers using microtasks.
  3655. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3656. // However, it has subtle problems when state is changed right before repaint
  3657. // (e.g. #6813, out-in transitions).
  3658. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3659. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3660. // So we now use microtasks everywhere, again.
  3661. // A major drawback of this tradeoff is that there are some scenarios
  3662. // where microtasks have too high a priority and fire in between supposedly
  3663. // sequential events (e.g. #4521, #6690, which have workarounds)
  3664. // or even between bubbling of the same event (#6566).
  3665. let timerFunc;
  3666. // The nextTick behavior leverages the microtask queue, which can be accessed
  3667. // via either native Promise.then or MutationObserver.
  3668. // MutationObserver has wider support, however it is seriously bugged in
  3669. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3670. // completely stops working after triggering a few times... so, if native
  3671. // Promise is available, we will use it:
  3672. /* istanbul ignore next, $flow-disable-line */
  3673. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3674. const p = Promise.resolve();
  3675. timerFunc = () => {
  3676. p.then(flushCallbacks);
  3677. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3678. // it can get stuck in a weird state where callbacks are pushed into the
  3679. // microtask queue but the queue isn't being flushed, until the browser
  3680. // needs to do some other work, e.g. handle a timer. Therefore we can
  3681. // "force" the microtask queue to be flushed by adding an empty timer.
  3682. if (isIOS)
  3683. setTimeout(noop);
  3684. };
  3685. isUsingMicroTask = true;
  3686. }
  3687. else if (!isIE &&
  3688. typeof MutationObserver !== 'undefined' &&
  3689. (isNative(MutationObserver) ||
  3690. // PhantomJS and iOS 7.x
  3691. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3692. // Use MutationObserver where native Promise is not available,
  3693. // e.g. PhantomJS, iOS7, Android 4.4
  3694. // (#6466 MutationObserver is unreliable in IE11)
  3695. let counter = 1;
  3696. const observer = new MutationObserver(flushCallbacks);
  3697. const textNode = document.createTextNode(String(counter));
  3698. observer.observe(textNode, {
  3699. characterData: true
  3700. });
  3701. timerFunc = () => {
  3702. counter = (counter + 1) % 2;
  3703. textNode.data = String(counter);
  3704. };
  3705. isUsingMicroTask = true;
  3706. }
  3707. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3708. // Fallback to setImmediate.
  3709. // Technically it leverages the (macro) task queue,
  3710. // but it is still a better choice than setTimeout.
  3711. timerFunc = () => {
  3712. setImmediate(flushCallbacks);
  3713. };
  3714. }
  3715. else {
  3716. // Fallback to setTimeout.
  3717. timerFunc = () => {
  3718. setTimeout(flushCallbacks, 0);
  3719. };
  3720. }
  3721. /**
  3722. * @internal
  3723. */
  3724. function nextTick(cb, ctx) {
  3725. let _resolve;
  3726. callbacks.push(() => {
  3727. if (cb) {
  3728. try {
  3729. cb.call(ctx);
  3730. }
  3731. catch (e) {
  3732. handleError(e, ctx, 'nextTick');
  3733. }
  3734. }
  3735. else if (_resolve) {
  3736. _resolve(ctx);
  3737. }
  3738. });
  3739. if (!pending) {
  3740. pending = true;
  3741. timerFunc();
  3742. }
  3743. // $flow-disable-line
  3744. if (!cb && typeof Promise !== 'undefined') {
  3745. return new Promise(resolve => {
  3746. _resolve = resolve;
  3747. });
  3748. }
  3749. }
  3750. function useCssModule(name = '$style') {
  3751. /* istanbul ignore else */
  3752. {
  3753. if (!currentInstance) {
  3754. warn$2(`useCssModule must be called inside setup()`);
  3755. return emptyObject;
  3756. }
  3757. const mod = currentInstance[name];
  3758. if (!mod) {
  3759. warn$2(`Current instance does not have CSS module named "${name}".`);
  3760. return emptyObject;
  3761. }
  3762. return mod;
  3763. }
  3764. }
  3765. /**
  3766. * Runtime helper for SFC's CSS variable injection feature.
  3767. * @private
  3768. */
  3769. function useCssVars(getter) {
  3770. if (!inBrowser && !false)
  3771. return;
  3772. const instance = currentInstance;
  3773. if (!instance) {
  3774. warn$2(`useCssVars is called without current active component instance.`);
  3775. return;
  3776. }
  3777. watchPostEffect(() => {
  3778. const el = instance.$el;
  3779. const vars = getter(instance, instance._setupProxy);
  3780. if (el && el.nodeType === 1) {
  3781. const style = el.style;
  3782. for (const key in vars) {
  3783. style.setProperty(`--${key}`, vars[key]);
  3784. }
  3785. }
  3786. });
  3787. }
  3788. /**
  3789. * v3-compatible async component API.
  3790. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3791. * because it relies on existing manual types
  3792. */
  3793. function defineAsyncComponent(source) {
  3794. if (isFunction(source)) {
  3795. source = { loader: source };
  3796. }
  3797. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3798. suspensible = false, // in Vue 3 default is true
  3799. onError: userOnError } = source;
  3800. if (suspensible) {
  3801. warn$2(`The suspensible option for async components is not supported in Vue2. It is ignored.`);
  3802. }
  3803. let pendingRequest = null;
  3804. let retries = 0;
  3805. const retry = () => {
  3806. retries++;
  3807. pendingRequest = null;
  3808. return load();
  3809. };
  3810. const load = () => {
  3811. let thisRequest;
  3812. return (pendingRequest ||
  3813. (thisRequest = pendingRequest =
  3814. loader()
  3815. .catch(err => {
  3816. err = err instanceof Error ? err : new Error(String(err));
  3817. if (userOnError) {
  3818. return new Promise((resolve, reject) => {
  3819. const userRetry = () => resolve(retry());
  3820. const userFail = () => reject(err);
  3821. userOnError(err, userRetry, userFail, retries + 1);
  3822. });
  3823. }
  3824. else {
  3825. throw err;
  3826. }
  3827. })
  3828. .then((comp) => {
  3829. if (thisRequest !== pendingRequest && pendingRequest) {
  3830. return pendingRequest;
  3831. }
  3832. if (!comp) {
  3833. warn$2(`Async component loader resolved to undefined. ` +
  3834. `If you are using retry(), make sure to return its return value.`);
  3835. }
  3836. // interop module default
  3837. if (comp &&
  3838. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3839. comp = comp.default;
  3840. }
  3841. if (comp && !isObject(comp) && !isFunction(comp)) {
  3842. throw new Error(`Invalid async component load result: ${comp}`);
  3843. }
  3844. return comp;
  3845. })));
  3846. };
  3847. return () => {
  3848. const component = load();
  3849. return {
  3850. component,
  3851. delay,
  3852. timeout,
  3853. error: errorComponent,
  3854. loading: loadingComponent
  3855. };
  3856. };
  3857. }
  3858. function createLifeCycle(hookName) {
  3859. return (fn, target = currentInstance) => {
  3860. if (!target) {
  3861. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3862. `associated with. ` +
  3863. `Lifecycle injection APIs can only be used during execution of setup().`);
  3864. return;
  3865. }
  3866. return injectHook(target, hookName, fn);
  3867. };
  3868. }
  3869. function formatName(name) {
  3870. if (name === 'beforeDestroy') {
  3871. name = 'beforeUnmount';
  3872. }
  3873. else if (name === 'destroyed') {
  3874. name = 'unmounted';
  3875. }
  3876. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3877. }
  3878. function injectHook(instance, hookName, fn) {
  3879. const options = instance.$options;
  3880. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3881. }
  3882. const onBeforeMount = createLifeCycle('beforeMount');
  3883. const onMounted = createLifeCycle('mounted');
  3884. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3885. const onUpdated = createLifeCycle('updated');
  3886. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3887. const onUnmounted = createLifeCycle('destroyed');
  3888. const onActivated = createLifeCycle('activated');
  3889. const onDeactivated = createLifeCycle('deactivated');
  3890. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3891. const onRenderTracked = createLifeCycle('renderTracked');
  3892. const onRenderTriggered = createLifeCycle('renderTriggered');
  3893. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3894. function onErrorCaptured(hook, target = currentInstance) {
  3895. injectErrorCapturedHook(hook, target);
  3896. }
  3897. /**
  3898. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3899. */
  3900. const version = '2.7.16';
  3901. /**
  3902. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3903. */
  3904. function defineComponent(options) {
  3905. return options;
  3906. }
  3907. var vca = /*#__PURE__*/Object.freeze({
  3908. __proto__: null,
  3909. version: version,
  3910. defineComponent: defineComponent,
  3911. ref: ref$1,
  3912. shallowRef: shallowRef,
  3913. isRef: isRef,
  3914. toRef: toRef,
  3915. toRefs: toRefs,
  3916. unref: unref,
  3917. proxyRefs: proxyRefs,
  3918. customRef: customRef,
  3919. triggerRef: triggerRef,
  3920. reactive: reactive,
  3921. isReactive: isReactive,
  3922. isReadonly: isReadonly,
  3923. isShallow: isShallow,
  3924. isProxy: isProxy,
  3925. shallowReactive: shallowReactive,
  3926. markRaw: markRaw,
  3927. toRaw: toRaw,
  3928. readonly: readonly,
  3929. shallowReadonly: shallowReadonly,
  3930. computed: computed,
  3931. watch: watch,
  3932. watchEffect: watchEffect,
  3933. watchPostEffect: watchPostEffect,
  3934. watchSyncEffect: watchSyncEffect,
  3935. EffectScope: EffectScope,
  3936. effectScope: effectScope,
  3937. onScopeDispose: onScopeDispose,
  3938. getCurrentScope: getCurrentScope,
  3939. provide: provide,
  3940. inject: inject,
  3941. h: h,
  3942. getCurrentInstance: getCurrentInstance,
  3943. useSlots: useSlots,
  3944. useAttrs: useAttrs,
  3945. useListeners: useListeners,
  3946. mergeDefaults: mergeDefaults,
  3947. nextTick: nextTick,
  3948. set: set,
  3949. del: del,
  3950. useCssModule: useCssModule,
  3951. useCssVars: useCssVars,
  3952. defineAsyncComponent: defineAsyncComponent,
  3953. onBeforeMount: onBeforeMount,
  3954. onMounted: onMounted,
  3955. onBeforeUpdate: onBeforeUpdate,
  3956. onUpdated: onUpdated,
  3957. onBeforeUnmount: onBeforeUnmount,
  3958. onUnmounted: onUnmounted,
  3959. onActivated: onActivated,
  3960. onDeactivated: onDeactivated,
  3961. onServerPrefetch: onServerPrefetch,
  3962. onRenderTracked: onRenderTracked,
  3963. onRenderTriggered: onRenderTriggered,
  3964. onErrorCaptured: onErrorCaptured
  3965. });
  3966. const seenObjects = new _Set();
  3967. /**
  3968. * Recursively traverse an object to evoke all converted
  3969. * getters, so that every nested property inside the object
  3970. * is collected as a "deep" dependency.
  3971. */
  3972. function traverse(val) {
  3973. _traverse(val, seenObjects);
  3974. seenObjects.clear();
  3975. return val;
  3976. }
  3977. function _traverse(val, seen) {
  3978. let i, keys;
  3979. const isA = isArray(val);
  3980. if ((!isA && !isObject(val)) ||
  3981. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3982. Object.isFrozen(val) ||
  3983. val instanceof VNode) {
  3984. return;
  3985. }
  3986. if (val.__ob__) {
  3987. const depId = val.__ob__.dep.id;
  3988. if (seen.has(depId)) {
  3989. return;
  3990. }
  3991. seen.add(depId);
  3992. }
  3993. if (isA) {
  3994. i = val.length;
  3995. while (i--)
  3996. _traverse(val[i], seen);
  3997. }
  3998. else if (isRef(val)) {
  3999. _traverse(val.value, seen);
  4000. }
  4001. else {
  4002. keys = Object.keys(val);
  4003. i = keys.length;
  4004. while (i--)
  4005. _traverse(val[keys[i]], seen);
  4006. }
  4007. }
  4008. let uid$1 = 0;
  4009. /**
  4010. * A watcher parses an expression, collects dependencies,
  4011. * and fires callback when the expression value changes.
  4012. * This is used for both the $watch() api and directives.
  4013. * @internal
  4014. */
  4015. class Watcher {
  4016. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  4017. recordEffectScope(this,
  4018. // if the active effect scope is manually created (not a component scope),
  4019. // prioritize it
  4020. activeEffectScope && !activeEffectScope._vm
  4021. ? activeEffectScope
  4022. : vm
  4023. ? vm._scope
  4024. : undefined);
  4025. if ((this.vm = vm) && isRenderWatcher) {
  4026. vm._watcher = this;
  4027. }
  4028. // options
  4029. if (options) {
  4030. this.deep = !!options.deep;
  4031. this.user = !!options.user;
  4032. this.lazy = !!options.lazy;
  4033. this.sync = !!options.sync;
  4034. this.before = options.before;
  4035. {
  4036. this.onTrack = options.onTrack;
  4037. this.onTrigger = options.onTrigger;
  4038. }
  4039. }
  4040. else {
  4041. this.deep = this.user = this.lazy = this.sync = false;
  4042. }
  4043. this.cb = cb;
  4044. this.id = ++uid$1; // uid for batching
  4045. this.active = true;
  4046. this.post = false;
  4047. this.dirty = this.lazy; // for lazy watchers
  4048. this.deps = [];
  4049. this.newDeps = [];
  4050. this.depIds = new _Set();
  4051. this.newDepIds = new _Set();
  4052. this.expression = expOrFn.toString() ;
  4053. // parse expression for getter
  4054. if (isFunction(expOrFn)) {
  4055. this.getter = expOrFn;
  4056. }
  4057. else {
  4058. this.getter = parsePath(expOrFn);
  4059. if (!this.getter) {
  4060. this.getter = noop;
  4061. warn$2(`Failed watching path: "${expOrFn}" ` +
  4062. 'Watcher only accepts simple dot-delimited paths. ' +
  4063. 'For full control, use a function instead.', vm);
  4064. }
  4065. }
  4066. this.value = this.lazy ? undefined : this.get();
  4067. }
  4068. /**
  4069. * Evaluate the getter, and re-collect dependencies.
  4070. */
  4071. get() {
  4072. pushTarget(this);
  4073. let value;
  4074. const vm = this.vm;
  4075. try {
  4076. value = this.getter.call(vm, vm);
  4077. }
  4078. catch (e) {
  4079. if (this.user) {
  4080. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4081. }
  4082. else {
  4083. throw e;
  4084. }
  4085. }
  4086. finally {
  4087. // "touch" every property so they are all tracked as
  4088. // dependencies for deep watching
  4089. if (this.deep) {
  4090. traverse(value);
  4091. }
  4092. popTarget();
  4093. this.cleanupDeps();
  4094. }
  4095. return value;
  4096. }
  4097. /**
  4098. * Add a dependency to this directive.
  4099. */
  4100. addDep(dep) {
  4101. const id = dep.id;
  4102. if (!this.newDepIds.has(id)) {
  4103. this.newDepIds.add(id);
  4104. this.newDeps.push(dep);
  4105. if (!this.depIds.has(id)) {
  4106. dep.addSub(this);
  4107. }
  4108. }
  4109. }
  4110. /**
  4111. * Clean up for dependency collection.
  4112. */
  4113. cleanupDeps() {
  4114. let i = this.deps.length;
  4115. while (i--) {
  4116. const dep = this.deps[i];
  4117. if (!this.newDepIds.has(dep.id)) {
  4118. dep.removeSub(this);
  4119. }
  4120. }
  4121. let tmp = this.depIds;
  4122. this.depIds = this.newDepIds;
  4123. this.newDepIds = tmp;
  4124. this.newDepIds.clear();
  4125. tmp = this.deps;
  4126. this.deps = this.newDeps;
  4127. this.newDeps = tmp;
  4128. this.newDeps.length = 0;
  4129. }
  4130. /**
  4131. * Subscriber interface.
  4132. * Will be called when a dependency changes.
  4133. */
  4134. update() {
  4135. /* istanbul ignore else */
  4136. if (this.lazy) {
  4137. this.dirty = true;
  4138. }
  4139. else if (this.sync) {
  4140. this.run();
  4141. }
  4142. else {
  4143. queueWatcher(this);
  4144. }
  4145. }
  4146. /**
  4147. * Scheduler job interface.
  4148. * Will be called by the scheduler.
  4149. */
  4150. run() {
  4151. if (this.active) {
  4152. const value = this.get();
  4153. if (value !== this.value ||
  4154. // Deep watchers and watchers on Object/Arrays should fire even
  4155. // when the value is the same, because the value may
  4156. // have mutated.
  4157. isObject(value) ||
  4158. this.deep) {
  4159. // set new value
  4160. const oldValue = this.value;
  4161. this.value = value;
  4162. if (this.user) {
  4163. const info = `callback for watcher "${this.expression}"`;
  4164. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4165. }
  4166. else {
  4167. this.cb.call(this.vm, value, oldValue);
  4168. }
  4169. }
  4170. }
  4171. }
  4172. /**
  4173. * Evaluate the value of the watcher.
  4174. * This only gets called for lazy watchers.
  4175. */
  4176. evaluate() {
  4177. this.value = this.get();
  4178. this.dirty = false;
  4179. }
  4180. /**
  4181. * Depend on all deps collected by this watcher.
  4182. */
  4183. depend() {
  4184. let i = this.deps.length;
  4185. while (i--) {
  4186. this.deps[i].depend();
  4187. }
  4188. }
  4189. /**
  4190. * Remove self from all dependencies' subscriber list.
  4191. */
  4192. teardown() {
  4193. if (this.vm && !this.vm._isBeingDestroyed) {
  4194. remove$2(this.vm._scope.effects, this);
  4195. }
  4196. if (this.active) {
  4197. let i = this.deps.length;
  4198. while (i--) {
  4199. this.deps[i].removeSub(this);
  4200. }
  4201. this.active = false;
  4202. if (this.onStop) {
  4203. this.onStop();
  4204. }
  4205. }
  4206. }
  4207. }
  4208. const sharedPropertyDefinition = {
  4209. enumerable: true,
  4210. configurable: true,
  4211. get: noop,
  4212. set: noop
  4213. };
  4214. function proxy(target, sourceKey, key) {
  4215. sharedPropertyDefinition.get = function proxyGetter() {
  4216. return this[sourceKey][key];
  4217. };
  4218. sharedPropertyDefinition.set = function proxySetter(val) {
  4219. this[sourceKey][key] = val;
  4220. };
  4221. Object.defineProperty(target, key, sharedPropertyDefinition);
  4222. }
  4223. function initState(vm) {
  4224. const opts = vm.$options;
  4225. if (opts.props)
  4226. initProps$1(vm, opts.props);
  4227. // Composition API
  4228. initSetup(vm);
  4229. if (opts.methods)
  4230. initMethods(vm, opts.methods);
  4231. if (opts.data) {
  4232. initData(vm);
  4233. }
  4234. else {
  4235. const ob = observe((vm._data = {}));
  4236. ob && ob.vmCount++;
  4237. }
  4238. if (opts.computed)
  4239. initComputed$1(vm, opts.computed);
  4240. if (opts.watch && opts.watch !== nativeWatch) {
  4241. initWatch(vm, opts.watch);
  4242. }
  4243. }
  4244. function initProps$1(vm, propsOptions) {
  4245. const propsData = vm.$options.propsData || {};
  4246. const props = (vm._props = shallowReactive({}));
  4247. // cache prop keys so that future props updates can iterate using Array
  4248. // instead of dynamic object key enumeration.
  4249. const keys = (vm.$options._propKeys = []);
  4250. const isRoot = !vm.$parent;
  4251. // root instance props should be converted
  4252. if (!isRoot) {
  4253. toggleObserving(false);
  4254. }
  4255. for (const key in propsOptions) {
  4256. keys.push(key);
  4257. const value = validateProp(key, propsOptions, propsData, vm);
  4258. /* istanbul ignore else */
  4259. {
  4260. const hyphenatedKey = hyphenate(key);
  4261. if (isReservedAttribute(hyphenatedKey) ||
  4262. config.isReservedAttr(hyphenatedKey)) {
  4263. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4264. }
  4265. defineReactive(props, key, value, () => {
  4266. if (!isRoot && !isUpdatingChildComponent) {
  4267. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4268. `overwritten whenever the parent component re-renders. ` +
  4269. `Instead, use a data or computed property based on the prop's ` +
  4270. `value. Prop being mutated: "${key}"`, vm);
  4271. }
  4272. }, true /* shallow */);
  4273. }
  4274. // static props are already proxied on the component's prototype
  4275. // during Vue.extend(). We only need to proxy props defined at
  4276. // instantiation here.
  4277. if (!(key in vm)) {
  4278. proxy(vm, `_props`, key);
  4279. }
  4280. }
  4281. toggleObserving(true);
  4282. }
  4283. function initData(vm) {
  4284. let data = vm.$options.data;
  4285. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4286. if (!isPlainObject(data)) {
  4287. data = {};
  4288. warn$2('data functions should return an object:\n' +
  4289. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4290. }
  4291. // proxy data on instance
  4292. const keys = Object.keys(data);
  4293. const props = vm.$options.props;
  4294. const methods = vm.$options.methods;
  4295. let i = keys.length;
  4296. while (i--) {
  4297. const key = keys[i];
  4298. {
  4299. if (methods && hasOwn(methods, key)) {
  4300. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4301. }
  4302. }
  4303. if (props && hasOwn(props, key)) {
  4304. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4305. `Use prop default value instead.`, vm);
  4306. }
  4307. else if (!isReserved(key)) {
  4308. proxy(vm, `_data`, key);
  4309. }
  4310. }
  4311. // observe data
  4312. const ob = observe(data);
  4313. ob && ob.vmCount++;
  4314. }
  4315. function getData(data, vm) {
  4316. // #7573 disable dep collection when invoking data getters
  4317. pushTarget();
  4318. try {
  4319. return data.call(vm, vm);
  4320. }
  4321. catch (e) {
  4322. handleError(e, vm, `data()`);
  4323. return {};
  4324. }
  4325. finally {
  4326. popTarget();
  4327. }
  4328. }
  4329. const computedWatcherOptions = { lazy: true };
  4330. function initComputed$1(vm, computed) {
  4331. // $flow-disable-line
  4332. const watchers = (vm._computedWatchers = Object.create(null));
  4333. // computed properties are just getters during SSR
  4334. const isSSR = isServerRendering();
  4335. for (const key in computed) {
  4336. const userDef = computed[key];
  4337. const getter = isFunction(userDef) ? userDef : userDef.get;
  4338. if (getter == null) {
  4339. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4340. }
  4341. if (!isSSR) {
  4342. // create internal watcher for the computed property.
  4343. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4344. }
  4345. // component-defined computed properties are already defined on the
  4346. // component prototype. We only need to define computed properties defined
  4347. // at instantiation here.
  4348. if (!(key in vm)) {
  4349. defineComputed(vm, key, userDef);
  4350. }
  4351. else {
  4352. if (key in vm.$data) {
  4353. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4354. }
  4355. else if (vm.$options.props && key in vm.$options.props) {
  4356. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4357. }
  4358. else if (vm.$options.methods && key in vm.$options.methods) {
  4359. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4360. }
  4361. }
  4362. }
  4363. }
  4364. function defineComputed(target, key, userDef) {
  4365. const shouldCache = !isServerRendering();
  4366. if (isFunction(userDef)) {
  4367. sharedPropertyDefinition.get = shouldCache
  4368. ? createComputedGetter(key)
  4369. : createGetterInvoker(userDef);
  4370. sharedPropertyDefinition.set = noop;
  4371. }
  4372. else {
  4373. sharedPropertyDefinition.get = userDef.get
  4374. ? shouldCache && userDef.cache !== false
  4375. ? createComputedGetter(key)
  4376. : createGetterInvoker(userDef.get)
  4377. : noop;
  4378. sharedPropertyDefinition.set = userDef.set || noop;
  4379. }
  4380. if (sharedPropertyDefinition.set === noop) {
  4381. sharedPropertyDefinition.set = function () {
  4382. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4383. };
  4384. }
  4385. Object.defineProperty(target, key, sharedPropertyDefinition);
  4386. }
  4387. function createComputedGetter(key) {
  4388. return function computedGetter() {
  4389. const watcher = this._computedWatchers && this._computedWatchers[key];
  4390. if (watcher) {
  4391. if (watcher.dirty) {
  4392. watcher.evaluate();
  4393. }
  4394. if (Dep.target) {
  4395. if (Dep.target.onTrack) {
  4396. Dep.target.onTrack({
  4397. effect: Dep.target,
  4398. target: this,
  4399. type: "get" /* TrackOpTypes.GET */,
  4400. key
  4401. });
  4402. }
  4403. watcher.depend();
  4404. }
  4405. return watcher.value;
  4406. }
  4407. };
  4408. }
  4409. function createGetterInvoker(fn) {
  4410. return function computedGetter() {
  4411. return fn.call(this, this);
  4412. };
  4413. }
  4414. function initMethods(vm, methods) {
  4415. const props = vm.$options.props;
  4416. for (const key in methods) {
  4417. {
  4418. if (typeof methods[key] !== 'function') {
  4419. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4420. `Did you reference the function correctly?`, vm);
  4421. }
  4422. if (props && hasOwn(props, key)) {
  4423. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4424. }
  4425. if (key in vm && isReserved(key)) {
  4426. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4427. `Avoid defining component methods that start with _ or $.`);
  4428. }
  4429. }
  4430. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4431. }
  4432. }
  4433. function initWatch(vm, watch) {
  4434. for (const key in watch) {
  4435. const handler = watch[key];
  4436. if (isArray(handler)) {
  4437. for (let i = 0; i < handler.length; i++) {
  4438. createWatcher(vm, key, handler[i]);
  4439. }
  4440. }
  4441. else {
  4442. createWatcher(vm, key, handler);
  4443. }
  4444. }
  4445. }
  4446. function createWatcher(vm, expOrFn, handler, options) {
  4447. if (isPlainObject(handler)) {
  4448. options = handler;
  4449. handler = handler.handler;
  4450. }
  4451. if (typeof handler === 'string') {
  4452. handler = vm[handler];
  4453. }
  4454. return vm.$watch(expOrFn, handler, options);
  4455. }
  4456. function stateMixin(Vue) {
  4457. // flow somehow has problems with directly declared definition object
  4458. // when using Object.defineProperty, so we have to procedurally build up
  4459. // the object here.
  4460. const dataDef = {};
  4461. dataDef.get = function () {
  4462. return this._data;
  4463. };
  4464. const propsDef = {};
  4465. propsDef.get = function () {
  4466. return this._props;
  4467. };
  4468. {
  4469. dataDef.set = function () {
  4470. warn$2('Avoid replacing instance root $data. ' +
  4471. 'Use nested data properties instead.', this);
  4472. };
  4473. propsDef.set = function () {
  4474. warn$2(`$props is readonly.`, this);
  4475. };
  4476. }
  4477. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4478. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4479. Vue.prototype.$set = set;
  4480. Vue.prototype.$delete = del;
  4481. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4482. const vm = this;
  4483. if (isPlainObject(cb)) {
  4484. return createWatcher(vm, expOrFn, cb, options);
  4485. }
  4486. options = options || {};
  4487. options.user = true;
  4488. const watcher = new Watcher(vm, expOrFn, cb, options);
  4489. if (options.immediate) {
  4490. const info = `callback for immediate watcher "${watcher.expression}"`;
  4491. pushTarget();
  4492. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4493. popTarget();
  4494. }
  4495. return function unwatchFn() {
  4496. watcher.teardown();
  4497. };
  4498. };
  4499. }
  4500. function initProvide(vm) {
  4501. const provideOption = vm.$options.provide;
  4502. if (provideOption) {
  4503. const provided = isFunction(provideOption)
  4504. ? provideOption.call(vm)
  4505. : provideOption;
  4506. if (!isObject(provided)) {
  4507. return;
  4508. }
  4509. const source = resolveProvided(vm);
  4510. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4511. // iterate the keys ourselves.
  4512. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4513. for (let i = 0; i < keys.length; i++) {
  4514. const key = keys[i];
  4515. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4516. }
  4517. }
  4518. }
  4519. function initInjections(vm) {
  4520. const result = resolveInject(vm.$options.inject, vm);
  4521. if (result) {
  4522. toggleObserving(false);
  4523. Object.keys(result).forEach(key => {
  4524. /* istanbul ignore else */
  4525. {
  4526. defineReactive(vm, key, result[key], () => {
  4527. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4528. `overwritten whenever the provided component re-renders. ` +
  4529. `injection being mutated: "${key}"`, vm);
  4530. });
  4531. }
  4532. });
  4533. toggleObserving(true);
  4534. }
  4535. }
  4536. function resolveInject(inject, vm) {
  4537. if (inject) {
  4538. // inject is :any because flow is not smart enough to figure out cached
  4539. const result = Object.create(null);
  4540. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4541. for (let i = 0; i < keys.length; i++) {
  4542. const key = keys[i];
  4543. // #6574 in case the inject object is observed...
  4544. if (key === '__ob__')
  4545. continue;
  4546. const provideKey = inject[key].from;
  4547. if (provideKey in vm._provided) {
  4548. result[key] = vm._provided[provideKey];
  4549. }
  4550. else if ('default' in inject[key]) {
  4551. const provideDefault = inject[key].default;
  4552. result[key] = isFunction(provideDefault)
  4553. ? provideDefault.call(vm)
  4554. : provideDefault;
  4555. }
  4556. else {
  4557. warn$2(`Injection "${key}" not found`, vm);
  4558. }
  4559. }
  4560. return result;
  4561. }
  4562. }
  4563. let uid = 0;
  4564. function initMixin$1(Vue) {
  4565. Vue.prototype._init = function (options) {
  4566. const vm = this;
  4567. // a uid
  4568. vm._uid = uid++;
  4569. let startTag, endTag;
  4570. /* istanbul ignore if */
  4571. if (config.performance && mark) {
  4572. startTag = `vue-perf-start:${vm._uid}`;
  4573. endTag = `vue-perf-end:${vm._uid}`;
  4574. mark(startTag);
  4575. }
  4576. // a flag to mark this as a Vue instance without having to do instanceof
  4577. // check
  4578. vm._isVue = true;
  4579. // avoid instances from being observed
  4580. vm.__v_skip = true;
  4581. // effect scope
  4582. vm._scope = new EffectScope(true /* detached */);
  4583. // #13134 edge case where a child component is manually created during the
  4584. // render of a parent component
  4585. vm._scope.parent = undefined;
  4586. vm._scope._vm = true;
  4587. // merge options
  4588. if (options && options._isComponent) {
  4589. // optimize internal component instantiation
  4590. // since dynamic options merging is pretty slow, and none of the
  4591. // internal component options needs special treatment.
  4592. initInternalComponent(vm, options);
  4593. }
  4594. else {
  4595. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4596. }
  4597. /* istanbul ignore else */
  4598. {
  4599. initProxy(vm);
  4600. }
  4601. // expose real self
  4602. vm._self = vm;
  4603. initLifecycle(vm);
  4604. initEvents(vm);
  4605. initRender(vm);
  4606. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4607. initInjections(vm); // resolve injections before data/props
  4608. initState(vm);
  4609. initProvide(vm); // resolve provide after data/props
  4610. callHook$1(vm, 'created');
  4611. /* istanbul ignore if */
  4612. if (config.performance && mark) {
  4613. vm._name = formatComponentName(vm, false);
  4614. mark(endTag);
  4615. measure(`vue ${vm._name} init`, startTag, endTag);
  4616. }
  4617. if (vm.$options.el) {
  4618. vm.$mount(vm.$options.el);
  4619. }
  4620. };
  4621. }
  4622. function initInternalComponent(vm, options) {
  4623. const opts = (vm.$options = Object.create(vm.constructor.options));
  4624. // doing this because it's faster than dynamic enumeration.
  4625. const parentVnode = options._parentVnode;
  4626. opts.parent = options.parent;
  4627. opts._parentVnode = parentVnode;
  4628. const vnodeComponentOptions = parentVnode.componentOptions;
  4629. opts.propsData = vnodeComponentOptions.propsData;
  4630. opts._parentListeners = vnodeComponentOptions.listeners;
  4631. opts._renderChildren = vnodeComponentOptions.children;
  4632. opts._componentTag = vnodeComponentOptions.tag;
  4633. if (options.render) {
  4634. opts.render = options.render;
  4635. opts.staticRenderFns = options.staticRenderFns;
  4636. }
  4637. }
  4638. function resolveConstructorOptions(Ctor) {
  4639. let options = Ctor.options;
  4640. if (Ctor.super) {
  4641. const superOptions = resolveConstructorOptions(Ctor.super);
  4642. const cachedSuperOptions = Ctor.superOptions;
  4643. if (superOptions !== cachedSuperOptions) {
  4644. // super option changed,
  4645. // need to resolve new options.
  4646. Ctor.superOptions = superOptions;
  4647. // check if there are any late-modified/attached options (#4976)
  4648. const modifiedOptions = resolveModifiedOptions(Ctor);
  4649. // update base extend options
  4650. if (modifiedOptions) {
  4651. extend(Ctor.extendOptions, modifiedOptions);
  4652. }
  4653. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4654. if (options.name) {
  4655. options.components[options.name] = Ctor;
  4656. }
  4657. }
  4658. }
  4659. return options;
  4660. }
  4661. function resolveModifiedOptions(Ctor) {
  4662. let modified;
  4663. const latest = Ctor.options;
  4664. const sealed = Ctor.sealedOptions;
  4665. for (const key in latest) {
  4666. if (latest[key] !== sealed[key]) {
  4667. if (!modified)
  4668. modified = {};
  4669. modified[key] = latest[key];
  4670. }
  4671. }
  4672. return modified;
  4673. }
  4674. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4675. const options = Ctor.options;
  4676. // ensure the createElement function in functional components
  4677. // gets a unique context - this is necessary for correct named slot check
  4678. let contextVm;
  4679. if (hasOwn(parent, '_uid')) {
  4680. contextVm = Object.create(parent);
  4681. contextVm._original = parent;
  4682. }
  4683. else {
  4684. // the context vm passed in is a functional context as well.
  4685. // in this case we want to make sure we are able to get a hold to the
  4686. // real context instance.
  4687. contextVm = parent;
  4688. // @ts-ignore
  4689. parent = parent._original;
  4690. }
  4691. const isCompiled = isTrue(options._compiled);
  4692. const needNormalization = !isCompiled;
  4693. this.data = data;
  4694. this.props = props;
  4695. this.children = children;
  4696. this.parent = parent;
  4697. this.listeners = data.on || emptyObject;
  4698. this.injections = resolveInject(options.inject, parent);
  4699. this.slots = () => {
  4700. if (!this.$slots) {
  4701. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4702. }
  4703. return this.$slots;
  4704. };
  4705. Object.defineProperty(this, 'scopedSlots', {
  4706. enumerable: true,
  4707. get() {
  4708. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4709. }
  4710. });
  4711. // support for compiled functional template
  4712. if (isCompiled) {
  4713. // exposing $options for renderStatic()
  4714. this.$options = options;
  4715. // pre-resolve slots for renderSlot()
  4716. this.$slots = this.slots();
  4717. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4718. }
  4719. if (options._scopeId) {
  4720. this._c = (a, b, c, d) => {
  4721. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4722. if (vnode && !isArray(vnode)) {
  4723. vnode.fnScopeId = options._scopeId;
  4724. vnode.fnContext = parent;
  4725. }
  4726. return vnode;
  4727. };
  4728. }
  4729. else {
  4730. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4731. }
  4732. }
  4733. installRenderHelpers(FunctionalRenderContext.prototype);
  4734. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4735. const options = Ctor.options;
  4736. const props = {};
  4737. const propOptions = options.props;
  4738. if (isDef(propOptions)) {
  4739. for (const key in propOptions) {
  4740. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4741. }
  4742. }
  4743. else {
  4744. if (isDef(data.attrs))
  4745. mergeProps(props, data.attrs);
  4746. if (isDef(data.props))
  4747. mergeProps(props, data.props);
  4748. }
  4749. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4750. const vnode = options.render.call(null, renderContext._c, renderContext);
  4751. if (vnode instanceof VNode) {
  4752. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4753. }
  4754. else if (isArray(vnode)) {
  4755. const vnodes = normalizeChildren(vnode) || [];
  4756. const res = new Array(vnodes.length);
  4757. for (let i = 0; i < vnodes.length; i++) {
  4758. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4759. }
  4760. return res;
  4761. }
  4762. }
  4763. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4764. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4765. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4766. // that should not be matched to match.
  4767. const clone = cloneVNode(vnode);
  4768. clone.fnContext = contextVm;
  4769. clone.fnOptions = options;
  4770. {
  4771. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4772. renderContext;
  4773. }
  4774. if (data.slot) {
  4775. (clone.data || (clone.data = {})).slot = data.slot;
  4776. }
  4777. return clone;
  4778. }
  4779. function mergeProps(to, from) {
  4780. for (const key in from) {
  4781. to[camelize(key)] = from[key];
  4782. }
  4783. }
  4784. function getComponentName(options) {
  4785. return options.name || options.__name || options._componentTag;
  4786. }
  4787. // inline hooks to be invoked on component VNodes during patch
  4788. const componentVNodeHooks = {
  4789. init(vnode, hydrating) {
  4790. if (vnode.componentInstance &&
  4791. !vnode.componentInstance._isDestroyed &&
  4792. vnode.data.keepAlive) {
  4793. // kept-alive components, treat as a patch
  4794. const mountedNode = vnode; // work around flow
  4795. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4796. }
  4797. else {
  4798. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4799. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4800. }
  4801. },
  4802. prepatch(oldVnode, vnode) {
  4803. const options = vnode.componentOptions;
  4804. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4805. updateChildComponent(child, options.propsData, // updated props
  4806. options.listeners, // updated listeners
  4807. vnode, // new parent vnode
  4808. options.children // new children
  4809. );
  4810. },
  4811. insert(vnode) {
  4812. const { context, componentInstance } = vnode;
  4813. if (!componentInstance._isMounted) {
  4814. componentInstance._isMounted = true;
  4815. callHook$1(componentInstance, 'mounted');
  4816. }
  4817. if (vnode.data.keepAlive) {
  4818. if (context._isMounted) {
  4819. // vue-router#1212
  4820. // During updates, a kept-alive component's child components may
  4821. // change, so directly walking the tree here may call activated hooks
  4822. // on incorrect children. Instead we push them into a queue which will
  4823. // be processed after the whole patch process ended.
  4824. queueActivatedComponent(componentInstance);
  4825. }
  4826. else {
  4827. activateChildComponent(componentInstance, true /* direct */);
  4828. }
  4829. }
  4830. },
  4831. destroy(vnode) {
  4832. const { componentInstance } = vnode;
  4833. if (!componentInstance._isDestroyed) {
  4834. if (!vnode.data.keepAlive) {
  4835. componentInstance.$destroy();
  4836. }
  4837. else {
  4838. deactivateChildComponent(componentInstance, true /* direct */);
  4839. }
  4840. }
  4841. }
  4842. };
  4843. const hooksToMerge = Object.keys(componentVNodeHooks);
  4844. function createComponent(Ctor, data, context, children, tag) {
  4845. if (isUndef(Ctor)) {
  4846. return;
  4847. }
  4848. const baseCtor = context.$options._base;
  4849. // plain options object: turn it into a constructor
  4850. if (isObject(Ctor)) {
  4851. Ctor = baseCtor.extend(Ctor);
  4852. }
  4853. // if at this stage it's not a constructor or an async component factory,
  4854. // reject.
  4855. if (typeof Ctor !== 'function') {
  4856. {
  4857. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4858. }
  4859. return;
  4860. }
  4861. // async component
  4862. let asyncFactory;
  4863. // @ts-expect-error
  4864. if (isUndef(Ctor.cid)) {
  4865. asyncFactory = Ctor;
  4866. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4867. if (Ctor === undefined) {
  4868. // return a placeholder node for async component, which is rendered
  4869. // as a comment node but preserves all the raw information for the node.
  4870. // the information will be used for async server-rendering and hydration.
  4871. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4872. }
  4873. }
  4874. data = data || {};
  4875. // resolve constructor options in case global mixins are applied after
  4876. // component constructor creation
  4877. resolveConstructorOptions(Ctor);
  4878. // transform component v-model data into props & events
  4879. if (isDef(data.model)) {
  4880. // @ts-expect-error
  4881. transformModel(Ctor.options, data);
  4882. }
  4883. // extract props
  4884. // @ts-expect-error
  4885. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4886. // functional component
  4887. // @ts-expect-error
  4888. if (isTrue(Ctor.options.functional)) {
  4889. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4890. }
  4891. // extract listeners, since these needs to be treated as
  4892. // child component listeners instead of DOM listeners
  4893. const listeners = data.on;
  4894. // replace with listeners with .native modifier
  4895. // so it gets processed during parent component patch.
  4896. data.on = data.nativeOn;
  4897. // @ts-expect-error
  4898. if (isTrue(Ctor.options.abstract)) {
  4899. // abstract components do not keep anything
  4900. // other than props & listeners & slot
  4901. // work around flow
  4902. const slot = data.slot;
  4903. data = {};
  4904. if (slot) {
  4905. data.slot = slot;
  4906. }
  4907. }
  4908. // install component management hooks onto the placeholder node
  4909. installComponentHooks(data);
  4910. // return a placeholder vnode
  4911. // @ts-expect-error
  4912. const name = getComponentName(Ctor.options) || tag;
  4913. const vnode = new VNode(
  4914. // @ts-expect-error
  4915. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4916. // @ts-expect-error
  4917. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4918. return vnode;
  4919. }
  4920. function createComponentInstanceForVnode(
  4921. // we know it's MountedComponentVNode but flow doesn't
  4922. vnode,
  4923. // activeInstance in lifecycle state
  4924. parent) {
  4925. const options = {
  4926. _isComponent: true,
  4927. _parentVnode: vnode,
  4928. parent
  4929. };
  4930. // check inline-template render functions
  4931. const inlineTemplate = vnode.data.inlineTemplate;
  4932. if (isDef(inlineTemplate)) {
  4933. options.render = inlineTemplate.render;
  4934. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4935. }
  4936. return new vnode.componentOptions.Ctor(options);
  4937. }
  4938. function installComponentHooks(data) {
  4939. const hooks = data.hook || (data.hook = {});
  4940. for (let i = 0; i < hooksToMerge.length; i++) {
  4941. const key = hooksToMerge[i];
  4942. const existing = hooks[key];
  4943. const toMerge = componentVNodeHooks[key];
  4944. // @ts-expect-error
  4945. if (existing !== toMerge && !(existing && existing._merged)) {
  4946. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4947. }
  4948. }
  4949. }
  4950. function mergeHook(f1, f2) {
  4951. const merged = (a, b) => {
  4952. // flow complains about extra args which is why we use any
  4953. f1(a, b);
  4954. f2(a, b);
  4955. };
  4956. merged._merged = true;
  4957. return merged;
  4958. }
  4959. // transform component v-model info (value and callback) into
  4960. // prop and event handler respectively.
  4961. function transformModel(options, data) {
  4962. const prop = (options.model && options.model.prop) || 'value';
  4963. const event = (options.model && options.model.event) || 'input';
  4964. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4965. const on = data.on || (data.on = {});
  4966. const existing = on[event];
  4967. const callback = data.model.callback;
  4968. if (isDef(existing)) {
  4969. if (isArray(existing)
  4970. ? existing.indexOf(callback) === -1
  4971. : existing !== callback) {
  4972. on[event] = [callback].concat(existing);
  4973. }
  4974. }
  4975. else {
  4976. on[event] = callback;
  4977. }
  4978. }
  4979. let warn$2 = noop;
  4980. let tip = noop;
  4981. let generateComponentTrace; // work around flow check
  4982. let formatComponentName;
  4983. {
  4984. const hasConsole = typeof console !== 'undefined';
  4985. const classifyRE = /(?:^|[-_])(\w)/g;
  4986. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4987. warn$2 = (msg, vm = currentInstance) => {
  4988. const trace = vm ? generateComponentTrace(vm) : '';
  4989. if (config.warnHandler) {
  4990. config.warnHandler.call(null, msg, vm, trace);
  4991. }
  4992. else if (hasConsole && !config.silent) {
  4993. console.error(`[Vue warn]: ${msg}${trace}`);
  4994. }
  4995. };
  4996. tip = (msg, vm) => {
  4997. if (hasConsole && !config.silent) {
  4998. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4999. }
  5000. };
  5001. formatComponentName = (vm, includeFile) => {
  5002. if (vm.$root === vm) {
  5003. return '<Root>';
  5004. }
  5005. const options = isFunction(vm) && vm.cid != null
  5006. ? vm.options
  5007. : vm._isVue
  5008. ? vm.$options || vm.constructor.options
  5009. : vm;
  5010. let name = getComponentName(options);
  5011. const file = options.__file;
  5012. if (!name && file) {
  5013. const match = file.match(/([^/\\]+)\.vue$/);
  5014. name = match && match[1];
  5015. }
  5016. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  5017. (file && includeFile !== false ? ` at ${file}` : ''));
  5018. };
  5019. const repeat = (str, n) => {
  5020. let res = '';
  5021. while (n) {
  5022. if (n % 2 === 1)
  5023. res += str;
  5024. if (n > 1)
  5025. str += str;
  5026. n >>= 1;
  5027. }
  5028. return res;
  5029. };
  5030. generateComponentTrace = (vm) => {
  5031. if (vm._isVue && vm.$parent) {
  5032. const tree = [];
  5033. let currentRecursiveSequence = 0;
  5034. while (vm) {
  5035. if (tree.length > 0) {
  5036. const last = tree[tree.length - 1];
  5037. if (last.constructor === vm.constructor) {
  5038. currentRecursiveSequence++;
  5039. vm = vm.$parent;
  5040. continue;
  5041. }
  5042. else if (currentRecursiveSequence > 0) {
  5043. tree[tree.length - 1] = [last, currentRecursiveSequence];
  5044. currentRecursiveSequence = 0;
  5045. }
  5046. }
  5047. tree.push(vm);
  5048. vm = vm.$parent;
  5049. }
  5050. return ('\n\nfound in\n\n' +
  5051. tree
  5052. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  5053. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  5054. : formatComponentName(vm)}`)
  5055. .join('\n'));
  5056. }
  5057. else {
  5058. return `\n\n(found in ${formatComponentName(vm)})`;
  5059. }
  5060. };
  5061. }
  5062. /**
  5063. * Option overwriting strategies are functions that handle
  5064. * how to merge a parent option value and a child option
  5065. * value into the final value.
  5066. */
  5067. const strats = config.optionMergeStrategies;
  5068. /**
  5069. * Options with restrictions
  5070. */
  5071. {
  5072. strats.el = strats.propsData = function (parent, child, vm, key) {
  5073. if (!vm) {
  5074. warn$2(`option "${key}" can only be used during instance ` +
  5075. 'creation with the `new` keyword.');
  5076. }
  5077. return defaultStrat(parent, child);
  5078. };
  5079. }
  5080. /**
  5081. * Helper that recursively merges two data objects together.
  5082. */
  5083. function mergeData(to, from, recursive = true) {
  5084. if (!from)
  5085. return to;
  5086. let key, toVal, fromVal;
  5087. const keys = hasSymbol
  5088. ? Reflect.ownKeys(from)
  5089. : Object.keys(from);
  5090. for (let i = 0; i < keys.length; i++) {
  5091. key = keys[i];
  5092. // in case the object is already observed...
  5093. if (key === '__ob__')
  5094. continue;
  5095. toVal = to[key];
  5096. fromVal = from[key];
  5097. if (!recursive || !hasOwn(to, key)) {
  5098. set(to, key, fromVal);
  5099. }
  5100. else if (toVal !== fromVal &&
  5101. isPlainObject(toVal) &&
  5102. isPlainObject(fromVal)) {
  5103. mergeData(toVal, fromVal);
  5104. }
  5105. }
  5106. return to;
  5107. }
  5108. /**
  5109. * Data
  5110. */
  5111. function mergeDataOrFn(parentVal, childVal, vm) {
  5112. if (!vm) {
  5113. // in a Vue.extend merge, both should be functions
  5114. if (!childVal) {
  5115. return parentVal;
  5116. }
  5117. if (!parentVal) {
  5118. return childVal;
  5119. }
  5120. // when parentVal & childVal are both present,
  5121. // we need to return a function that returns the
  5122. // merged result of both functions... no need to
  5123. // check if parentVal is a function here because
  5124. // it has to be a function to pass previous merges.
  5125. return function mergedDataFn() {
  5126. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5127. };
  5128. }
  5129. else {
  5130. return function mergedInstanceDataFn() {
  5131. // instance merge
  5132. const instanceData = isFunction(childVal)
  5133. ? childVal.call(vm, vm)
  5134. : childVal;
  5135. const defaultData = isFunction(parentVal)
  5136. ? parentVal.call(vm, vm)
  5137. : parentVal;
  5138. if (instanceData) {
  5139. return mergeData(instanceData, defaultData);
  5140. }
  5141. else {
  5142. return defaultData;
  5143. }
  5144. };
  5145. }
  5146. }
  5147. strats.data = function (parentVal, childVal, vm) {
  5148. if (!vm) {
  5149. if (childVal && typeof childVal !== 'function') {
  5150. warn$2('The "data" option should be a function ' +
  5151. 'that returns a per-instance value in component ' +
  5152. 'definitions.', vm);
  5153. return parentVal;
  5154. }
  5155. return mergeDataOrFn(parentVal, childVal);
  5156. }
  5157. return mergeDataOrFn(parentVal, childVal, vm);
  5158. };
  5159. /**
  5160. * Hooks and props are merged as arrays.
  5161. */
  5162. function mergeLifecycleHook(parentVal, childVal) {
  5163. const res = childVal
  5164. ? parentVal
  5165. ? parentVal.concat(childVal)
  5166. : isArray(childVal)
  5167. ? childVal
  5168. : [childVal]
  5169. : parentVal;
  5170. return res ? dedupeHooks(res) : res;
  5171. }
  5172. function dedupeHooks(hooks) {
  5173. const res = [];
  5174. for (let i = 0; i < hooks.length; i++) {
  5175. if (res.indexOf(hooks[i]) === -1) {
  5176. res.push(hooks[i]);
  5177. }
  5178. }
  5179. return res;
  5180. }
  5181. LIFECYCLE_HOOKS.forEach(hook => {
  5182. strats[hook] = mergeLifecycleHook;
  5183. });
  5184. /**
  5185. * Assets
  5186. *
  5187. * When a vm is present (instance creation), we need to do
  5188. * a three-way merge between constructor options, instance
  5189. * options and parent options.
  5190. */
  5191. function mergeAssets(parentVal, childVal, vm, key) {
  5192. const res = Object.create(parentVal || null);
  5193. if (childVal) {
  5194. assertObjectType(key, childVal, vm);
  5195. return extend(res, childVal);
  5196. }
  5197. else {
  5198. return res;
  5199. }
  5200. }
  5201. ASSET_TYPES.forEach(function (type) {
  5202. strats[type + 's'] = mergeAssets;
  5203. });
  5204. /**
  5205. * Watchers.
  5206. *
  5207. * Watchers hashes should not overwrite one
  5208. * another, so we merge them as arrays.
  5209. */
  5210. strats.watch = function (parentVal, childVal, vm, key) {
  5211. // work around Firefox's Object.prototype.watch...
  5212. //@ts-expect-error work around
  5213. if (parentVal === nativeWatch)
  5214. parentVal = undefined;
  5215. //@ts-expect-error work around
  5216. if (childVal === nativeWatch)
  5217. childVal = undefined;
  5218. /* istanbul ignore if */
  5219. if (!childVal)
  5220. return Object.create(parentVal || null);
  5221. {
  5222. assertObjectType(key, childVal, vm);
  5223. }
  5224. if (!parentVal)
  5225. return childVal;
  5226. const ret = {};
  5227. extend(ret, parentVal);
  5228. for (const key in childVal) {
  5229. let parent = ret[key];
  5230. const child = childVal[key];
  5231. if (parent && !isArray(parent)) {
  5232. parent = [parent];
  5233. }
  5234. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5235. }
  5236. return ret;
  5237. };
  5238. /**
  5239. * Other object hashes.
  5240. */
  5241. strats.props =
  5242. strats.methods =
  5243. strats.inject =
  5244. strats.computed =
  5245. function (parentVal, childVal, vm, key) {
  5246. if (childVal && true) {
  5247. assertObjectType(key, childVal, vm);
  5248. }
  5249. if (!parentVal)
  5250. return childVal;
  5251. const ret = Object.create(null);
  5252. extend(ret, parentVal);
  5253. if (childVal)
  5254. extend(ret, childVal);
  5255. return ret;
  5256. };
  5257. strats.provide = function (parentVal, childVal) {
  5258. if (!parentVal)
  5259. return childVal;
  5260. return function () {
  5261. const ret = Object.create(null);
  5262. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5263. if (childVal) {
  5264. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5265. );
  5266. }
  5267. return ret;
  5268. };
  5269. };
  5270. /**
  5271. * Default strategy.
  5272. */
  5273. const defaultStrat = function (parentVal, childVal) {
  5274. return childVal === undefined ? parentVal : childVal;
  5275. };
  5276. /**
  5277. * Validate component names
  5278. */
  5279. function checkComponents(options) {
  5280. for (const key in options.components) {
  5281. validateComponentName(key);
  5282. }
  5283. }
  5284. function validateComponentName(name) {
  5285. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5286. warn$2('Invalid component name: "' +
  5287. name +
  5288. '". Component names ' +
  5289. 'should conform to valid custom element name in html5 specification.');
  5290. }
  5291. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5292. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5293. 'id: ' +
  5294. name);
  5295. }
  5296. }
  5297. /**
  5298. * Ensure all props option syntax are normalized into the
  5299. * Object-based format.
  5300. */
  5301. function normalizeProps(options, vm) {
  5302. const props = options.props;
  5303. if (!props)
  5304. return;
  5305. const res = {};
  5306. let i, val, name;
  5307. if (isArray(props)) {
  5308. i = props.length;
  5309. while (i--) {
  5310. val = props[i];
  5311. if (typeof val === 'string') {
  5312. name = camelize(val);
  5313. res[name] = { type: null };
  5314. }
  5315. else {
  5316. warn$2('props must be strings when using array syntax.');
  5317. }
  5318. }
  5319. }
  5320. else if (isPlainObject(props)) {
  5321. for (const key in props) {
  5322. val = props[key];
  5323. name = camelize(key);
  5324. res[name] = isPlainObject(val) ? val : { type: val };
  5325. }
  5326. }
  5327. else {
  5328. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5329. `but got ${toRawType(props)}.`, vm);
  5330. }
  5331. options.props = res;
  5332. }
  5333. /**
  5334. * Normalize all injections into Object-based format
  5335. */
  5336. function normalizeInject(options, vm) {
  5337. const inject = options.inject;
  5338. if (!inject)
  5339. return;
  5340. const normalized = (options.inject = {});
  5341. if (isArray(inject)) {
  5342. for (let i = 0; i < inject.length; i++) {
  5343. normalized[inject[i]] = { from: inject[i] };
  5344. }
  5345. }
  5346. else if (isPlainObject(inject)) {
  5347. for (const key in inject) {
  5348. const val = inject[key];
  5349. normalized[key] = isPlainObject(val)
  5350. ? extend({ from: key }, val)
  5351. : { from: val };
  5352. }
  5353. }
  5354. else {
  5355. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5356. `but got ${toRawType(inject)}.`, vm);
  5357. }
  5358. }
  5359. /**
  5360. * Normalize raw function directives into object format.
  5361. */
  5362. function normalizeDirectives$1(options) {
  5363. const dirs = options.directives;
  5364. if (dirs) {
  5365. for (const key in dirs) {
  5366. const def = dirs[key];
  5367. if (isFunction(def)) {
  5368. dirs[key] = { bind: def, update: def };
  5369. }
  5370. }
  5371. }
  5372. }
  5373. function assertObjectType(name, value, vm) {
  5374. if (!isPlainObject(value)) {
  5375. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5376. `but got ${toRawType(value)}.`, vm);
  5377. }
  5378. }
  5379. /**
  5380. * Merge two option objects into a new one.
  5381. * Core utility used in both instantiation and inheritance.
  5382. */
  5383. function mergeOptions(parent, child, vm) {
  5384. {
  5385. checkComponents(child);
  5386. }
  5387. if (isFunction(child)) {
  5388. // @ts-expect-error
  5389. child = child.options;
  5390. }
  5391. normalizeProps(child, vm);
  5392. normalizeInject(child, vm);
  5393. normalizeDirectives$1(child);
  5394. // Apply extends and mixins on the child options,
  5395. // but only if it is a raw options object that isn't
  5396. // the result of another mergeOptions call.
  5397. // Only merged options has the _base property.
  5398. if (!child._base) {
  5399. if (child.extends) {
  5400. parent = mergeOptions(parent, child.extends, vm);
  5401. }
  5402. if (child.mixins) {
  5403. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5404. parent = mergeOptions(parent, child.mixins[i], vm);
  5405. }
  5406. }
  5407. }
  5408. const options = {};
  5409. let key;
  5410. for (key in parent) {
  5411. mergeField(key);
  5412. }
  5413. for (key in child) {
  5414. if (!hasOwn(parent, key)) {
  5415. mergeField(key);
  5416. }
  5417. }
  5418. function mergeField(key) {
  5419. const strat = strats[key] || defaultStrat;
  5420. options[key] = strat(parent[key], child[key], vm, key);
  5421. }
  5422. return options;
  5423. }
  5424. /**
  5425. * Resolve an asset.
  5426. * This function is used because child instances need access
  5427. * to assets defined in its ancestor chain.
  5428. */
  5429. function resolveAsset(options, type, id, warnMissing) {
  5430. /* istanbul ignore if */
  5431. if (typeof id !== 'string') {
  5432. return;
  5433. }
  5434. const assets = options[type];
  5435. // check local registration variations first
  5436. if (hasOwn(assets, id))
  5437. return assets[id];
  5438. const camelizedId = camelize(id);
  5439. if (hasOwn(assets, camelizedId))
  5440. return assets[camelizedId];
  5441. const PascalCaseId = capitalize(camelizedId);
  5442. if (hasOwn(assets, PascalCaseId))
  5443. return assets[PascalCaseId];
  5444. // fallback to prototype chain
  5445. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5446. if (warnMissing && !res) {
  5447. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5448. }
  5449. return res;
  5450. }
  5451. function validateProp(key, propOptions, propsData, vm) {
  5452. const prop = propOptions[key];
  5453. const absent = !hasOwn(propsData, key);
  5454. let value = propsData[key];
  5455. // boolean casting
  5456. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5457. if (booleanIndex > -1) {
  5458. if (absent && !hasOwn(prop, 'default')) {
  5459. value = false;
  5460. }
  5461. else if (value === '' || value === hyphenate(key)) {
  5462. // only cast empty string / same name to boolean if
  5463. // boolean has higher priority
  5464. const stringIndex = getTypeIndex(String, prop.type);
  5465. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5466. value = true;
  5467. }
  5468. }
  5469. }
  5470. // check default value
  5471. if (value === undefined) {
  5472. value = getPropDefaultValue(vm, prop, key);
  5473. // since the default value is a fresh copy,
  5474. // make sure to observe it.
  5475. const prevShouldObserve = shouldObserve;
  5476. toggleObserving(true);
  5477. observe(value);
  5478. toggleObserving(prevShouldObserve);
  5479. }
  5480. {
  5481. assertProp(prop, key, value, vm, absent);
  5482. }
  5483. return value;
  5484. }
  5485. /**
  5486. * Get the default value of a prop.
  5487. */
  5488. function getPropDefaultValue(vm, prop, key) {
  5489. // no default, return undefined
  5490. if (!hasOwn(prop, 'default')) {
  5491. return undefined;
  5492. }
  5493. const def = prop.default;
  5494. // warn against non-factory defaults for Object & Array
  5495. if (isObject(def)) {
  5496. warn$2('Invalid default value for prop "' +
  5497. key +
  5498. '": ' +
  5499. 'Props with type Object/Array must use a factory function ' +
  5500. 'to return the default value.', vm);
  5501. }
  5502. // the raw prop value was also undefined from previous render,
  5503. // return previous default value to avoid unnecessary watcher trigger
  5504. if (vm &&
  5505. vm.$options.propsData &&
  5506. vm.$options.propsData[key] === undefined &&
  5507. vm._props[key] !== undefined) {
  5508. return vm._props[key];
  5509. }
  5510. // call factory function for non-Function types
  5511. // a value is Function if its prototype is function even across different execution context
  5512. return isFunction(def) && getType(prop.type) !== 'Function'
  5513. ? def.call(vm)
  5514. : def;
  5515. }
  5516. /**
  5517. * Assert whether a prop is valid.
  5518. */
  5519. function assertProp(prop, name, value, vm, absent) {
  5520. if (prop.required && absent) {
  5521. warn$2('Missing required prop: "' + name + '"', vm);
  5522. return;
  5523. }
  5524. if (value == null && !prop.required) {
  5525. return;
  5526. }
  5527. let type = prop.type;
  5528. let valid = !type || type === true;
  5529. const expectedTypes = [];
  5530. if (type) {
  5531. if (!isArray(type)) {
  5532. type = [type];
  5533. }
  5534. for (let i = 0; i < type.length && !valid; i++) {
  5535. const assertedType = assertType(value, type[i], vm);
  5536. expectedTypes.push(assertedType.expectedType || '');
  5537. valid = assertedType.valid;
  5538. }
  5539. }
  5540. const haveExpectedTypes = expectedTypes.some(t => t);
  5541. if (!valid && haveExpectedTypes) {
  5542. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5543. return;
  5544. }
  5545. const validator = prop.validator;
  5546. if (validator) {
  5547. if (!validator(value)) {
  5548. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5549. }
  5550. }
  5551. }
  5552. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5553. function assertType(value, type, vm) {
  5554. let valid;
  5555. const expectedType = getType(type);
  5556. if (simpleCheckRE.test(expectedType)) {
  5557. const t = typeof value;
  5558. valid = t === expectedType.toLowerCase();
  5559. // for primitive wrapper objects
  5560. if (!valid && t === 'object') {
  5561. valid = value instanceof type;
  5562. }
  5563. }
  5564. else if (expectedType === 'Object') {
  5565. valid = isPlainObject(value);
  5566. }
  5567. else if (expectedType === 'Array') {
  5568. valid = isArray(value);
  5569. }
  5570. else {
  5571. try {
  5572. valid = value instanceof type;
  5573. }
  5574. catch (e) {
  5575. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5576. valid = false;
  5577. }
  5578. }
  5579. return {
  5580. valid,
  5581. expectedType
  5582. };
  5583. }
  5584. const functionTypeCheckRE = /^\s*function (\w+)/;
  5585. /**
  5586. * Use function string name to check built-in types,
  5587. * because a simple equality check will fail when running
  5588. * across different vms / iframes.
  5589. */
  5590. function getType(fn) {
  5591. const match = fn && fn.toString().match(functionTypeCheckRE);
  5592. return match ? match[1] : '';
  5593. }
  5594. function isSameType(a, b) {
  5595. return getType(a) === getType(b);
  5596. }
  5597. function getTypeIndex(type, expectedTypes) {
  5598. if (!isArray(expectedTypes)) {
  5599. return isSameType(expectedTypes, type) ? 0 : -1;
  5600. }
  5601. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5602. if (isSameType(expectedTypes[i], type)) {
  5603. return i;
  5604. }
  5605. }
  5606. return -1;
  5607. }
  5608. function getInvalidTypeMessage(name, value, expectedTypes) {
  5609. let message = `Invalid prop: type check failed for prop "${name}".` +
  5610. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5611. const expectedType = expectedTypes[0];
  5612. const receivedType = toRawType(value);
  5613. // check if we need to specify expected value
  5614. if (expectedTypes.length === 1 &&
  5615. isExplicable(expectedType) &&
  5616. isExplicable(typeof value) &&
  5617. !isBoolean(expectedType, receivedType)) {
  5618. message += ` with value ${styleValue(value, expectedType)}`;
  5619. }
  5620. message += `, got ${receivedType} `;
  5621. // check if we need to specify received value
  5622. if (isExplicable(receivedType)) {
  5623. message += `with value ${styleValue(value, receivedType)}.`;
  5624. }
  5625. return message;
  5626. }
  5627. function styleValue(value, type) {
  5628. if (type === 'String') {
  5629. return `"${value}"`;
  5630. }
  5631. else if (type === 'Number') {
  5632. return `${Number(value)}`;
  5633. }
  5634. else {
  5635. return `${value}`;
  5636. }
  5637. }
  5638. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5639. function isExplicable(value) {
  5640. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5641. }
  5642. function isBoolean(...args) {
  5643. return args.some(elem => elem.toLowerCase() === 'boolean');
  5644. }
  5645. function Vue(options) {
  5646. if (!(this instanceof Vue)) {
  5647. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5648. }
  5649. this._init(options);
  5650. }
  5651. //@ts-expect-error Vue has function type
  5652. initMixin$1(Vue);
  5653. //@ts-expect-error Vue has function type
  5654. stateMixin(Vue);
  5655. //@ts-expect-error Vue has function type
  5656. eventsMixin(Vue);
  5657. //@ts-expect-error Vue has function type
  5658. lifecycleMixin(Vue);
  5659. //@ts-expect-error Vue has function type
  5660. renderMixin(Vue);
  5661. function initUse(Vue) {
  5662. Vue.use = function (plugin) {
  5663. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5664. if (installedPlugins.indexOf(plugin) > -1) {
  5665. return this;
  5666. }
  5667. // additional parameters
  5668. const args = toArray(arguments, 1);
  5669. args.unshift(this);
  5670. if (isFunction(plugin.install)) {
  5671. plugin.install.apply(plugin, args);
  5672. }
  5673. else if (isFunction(plugin)) {
  5674. plugin.apply(null, args);
  5675. }
  5676. installedPlugins.push(plugin);
  5677. return this;
  5678. };
  5679. }
  5680. function initMixin(Vue) {
  5681. Vue.mixin = function (mixin) {
  5682. this.options = mergeOptions(this.options, mixin);
  5683. return this;
  5684. };
  5685. }
  5686. function initExtend(Vue) {
  5687. /**
  5688. * Each instance constructor, including Vue, has a unique
  5689. * cid. This enables us to create wrapped "child
  5690. * constructors" for prototypal inheritance and cache them.
  5691. */
  5692. Vue.cid = 0;
  5693. let cid = 1;
  5694. /**
  5695. * Class inheritance
  5696. */
  5697. Vue.extend = function (extendOptions) {
  5698. extendOptions = extendOptions || {};
  5699. const Super = this;
  5700. const SuperId = Super.cid;
  5701. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5702. if (cachedCtors[SuperId]) {
  5703. return cachedCtors[SuperId];
  5704. }
  5705. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5706. if (name) {
  5707. validateComponentName(name);
  5708. }
  5709. const Sub = function VueComponent(options) {
  5710. this._init(options);
  5711. };
  5712. Sub.prototype = Object.create(Super.prototype);
  5713. Sub.prototype.constructor = Sub;
  5714. Sub.cid = cid++;
  5715. Sub.options = mergeOptions(Super.options, extendOptions);
  5716. Sub['super'] = Super;
  5717. // For props and computed properties, we define the proxy getters on
  5718. // the Vue instances at extension time, on the extended prototype. This
  5719. // avoids Object.defineProperty calls for each instance created.
  5720. if (Sub.options.props) {
  5721. initProps(Sub);
  5722. }
  5723. if (Sub.options.computed) {
  5724. initComputed(Sub);
  5725. }
  5726. // allow further extension/mixin/plugin usage
  5727. Sub.extend = Super.extend;
  5728. Sub.mixin = Super.mixin;
  5729. Sub.use = Super.use;
  5730. // create asset registers, so extended classes
  5731. // can have their private assets too.
  5732. ASSET_TYPES.forEach(function (type) {
  5733. Sub[type] = Super[type];
  5734. });
  5735. // enable recursive self-lookup
  5736. if (name) {
  5737. Sub.options.components[name] = Sub;
  5738. }
  5739. // keep a reference to the super options at extension time.
  5740. // later at instantiation we can check if Super's options have
  5741. // been updated.
  5742. Sub.superOptions = Super.options;
  5743. Sub.extendOptions = extendOptions;
  5744. Sub.sealedOptions = extend({}, Sub.options);
  5745. // cache constructor
  5746. cachedCtors[SuperId] = Sub;
  5747. return Sub;
  5748. };
  5749. }
  5750. function initProps(Comp) {
  5751. const props = Comp.options.props;
  5752. for (const key in props) {
  5753. proxy(Comp.prototype, `_props`, key);
  5754. }
  5755. }
  5756. function initComputed(Comp) {
  5757. const computed = Comp.options.computed;
  5758. for (const key in computed) {
  5759. defineComputed(Comp.prototype, key, computed[key]);
  5760. }
  5761. }
  5762. function initAssetRegisters(Vue) {
  5763. /**
  5764. * Create asset registration methods.
  5765. */
  5766. ASSET_TYPES.forEach(type => {
  5767. // @ts-expect-error function is not exact same type
  5768. Vue[type] = function (id, definition) {
  5769. if (!definition) {
  5770. return this.options[type + 's'][id];
  5771. }
  5772. else {
  5773. /* istanbul ignore if */
  5774. if (type === 'component') {
  5775. validateComponentName(id);
  5776. }
  5777. if (type === 'component' && isPlainObject(definition)) {
  5778. // @ts-expect-error
  5779. definition.name = definition.name || id;
  5780. definition = this.options._base.extend(definition);
  5781. }
  5782. if (type === 'directive' && isFunction(definition)) {
  5783. definition = { bind: definition, update: definition };
  5784. }
  5785. this.options[type + 's'][id] = definition;
  5786. return definition;
  5787. }
  5788. };
  5789. });
  5790. }
  5791. function _getComponentName(opts) {
  5792. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5793. }
  5794. function matches(pattern, name) {
  5795. if (isArray(pattern)) {
  5796. return pattern.indexOf(name) > -1;
  5797. }
  5798. else if (typeof pattern === 'string') {
  5799. return pattern.split(',').indexOf(name) > -1;
  5800. }
  5801. else if (isRegExp(pattern)) {
  5802. return pattern.test(name);
  5803. }
  5804. /* istanbul ignore next */
  5805. return false;
  5806. }
  5807. function pruneCache(keepAliveInstance, filter) {
  5808. const { cache, keys, _vnode, $vnode } = keepAliveInstance;
  5809. for (const key in cache) {
  5810. const entry = cache[key];
  5811. if (entry) {
  5812. const name = entry.name;
  5813. if (name && !filter(name)) {
  5814. pruneCacheEntry(cache, key, keys, _vnode);
  5815. }
  5816. }
  5817. }
  5818. $vnode.componentOptions.children = undefined;
  5819. }
  5820. function pruneCacheEntry(cache, key, keys, current) {
  5821. const entry = cache[key];
  5822. if (entry && (!current || entry.tag !== current.tag)) {
  5823. // @ts-expect-error can be undefined
  5824. entry.componentInstance.$destroy();
  5825. }
  5826. cache[key] = null;
  5827. remove$2(keys, key);
  5828. }
  5829. const patternTypes = [String, RegExp, Array];
  5830. // TODO defineComponent
  5831. var KeepAlive = {
  5832. name: 'keep-alive',
  5833. abstract: true,
  5834. props: {
  5835. include: patternTypes,
  5836. exclude: patternTypes,
  5837. max: [String, Number]
  5838. },
  5839. methods: {
  5840. cacheVNode() {
  5841. const { cache, keys, vnodeToCache, keyToCache } = this;
  5842. if (vnodeToCache) {
  5843. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5844. cache[keyToCache] = {
  5845. name: _getComponentName(componentOptions),
  5846. tag,
  5847. componentInstance
  5848. };
  5849. keys.push(keyToCache);
  5850. // prune oldest entry
  5851. if (this.max && keys.length > parseInt(this.max)) {
  5852. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5853. }
  5854. this.vnodeToCache = null;
  5855. }
  5856. }
  5857. },
  5858. created() {
  5859. this.cache = Object.create(null);
  5860. this.keys = [];
  5861. },
  5862. destroyed() {
  5863. for (const key in this.cache) {
  5864. pruneCacheEntry(this.cache, key, this.keys);
  5865. }
  5866. },
  5867. mounted() {
  5868. this.cacheVNode();
  5869. this.$watch('include', val => {
  5870. pruneCache(this, name => matches(val, name));
  5871. });
  5872. this.$watch('exclude', val => {
  5873. pruneCache(this, name => !matches(val, name));
  5874. });
  5875. },
  5876. updated() {
  5877. this.cacheVNode();
  5878. },
  5879. render() {
  5880. const slot = this.$slots.default;
  5881. const vnode = getFirstComponentChild(slot);
  5882. const componentOptions = vnode && vnode.componentOptions;
  5883. if (componentOptions) {
  5884. // check pattern
  5885. const name = _getComponentName(componentOptions);
  5886. const { include, exclude } = this;
  5887. if (
  5888. // not included
  5889. (include && (!name || !matches(include, name))) ||
  5890. // excluded
  5891. (exclude && name && matches(exclude, name))) {
  5892. return vnode;
  5893. }
  5894. const { cache, keys } = this;
  5895. const key = vnode.key == null
  5896. ? // same constructor may get registered as different local components
  5897. // so cid alone is not enough (#3269)
  5898. componentOptions.Ctor.cid +
  5899. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5900. : vnode.key;
  5901. if (cache[key]) {
  5902. vnode.componentInstance = cache[key].componentInstance;
  5903. // make current key freshest
  5904. remove$2(keys, key);
  5905. keys.push(key);
  5906. }
  5907. else {
  5908. // delay setting the cache until update
  5909. this.vnodeToCache = vnode;
  5910. this.keyToCache = key;
  5911. }
  5912. // @ts-expect-error can vnode.data can be undefined
  5913. vnode.data.keepAlive = true;
  5914. }
  5915. return vnode || (slot && slot[0]);
  5916. }
  5917. };
  5918. var builtInComponents = {
  5919. KeepAlive
  5920. };
  5921. function initGlobalAPI(Vue) {
  5922. // config
  5923. const configDef = {};
  5924. configDef.get = () => config;
  5925. {
  5926. configDef.set = () => {
  5927. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5928. };
  5929. }
  5930. Object.defineProperty(Vue, 'config', configDef);
  5931. // exposed util methods.
  5932. // NOTE: these are not considered part of the public API - avoid relying on
  5933. // them unless you are aware of the risk.
  5934. Vue.util = {
  5935. warn: warn$2,
  5936. extend,
  5937. mergeOptions,
  5938. defineReactive
  5939. };
  5940. Vue.set = set;
  5941. Vue.delete = del;
  5942. Vue.nextTick = nextTick;
  5943. // 2.6 explicit observable API
  5944. Vue.observable = (obj) => {
  5945. observe(obj);
  5946. return obj;
  5947. };
  5948. Vue.options = Object.create(null);
  5949. ASSET_TYPES.forEach(type => {
  5950. Vue.options[type + 's'] = Object.create(null);
  5951. });
  5952. // this is used to identify the "base" constructor to extend all plain-object
  5953. // components with in Weex's multi-instance scenarios.
  5954. Vue.options._base = Vue;
  5955. extend(Vue.options.components, builtInComponents);
  5956. initUse(Vue);
  5957. initMixin(Vue);
  5958. initExtend(Vue);
  5959. initAssetRegisters(Vue);
  5960. }
  5961. initGlobalAPI(Vue);
  5962. Object.defineProperty(Vue.prototype, '$isServer', {
  5963. get: isServerRendering
  5964. });
  5965. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5966. get() {
  5967. /* istanbul ignore next */
  5968. return this.$vnode && this.$vnode.ssrContext;
  5969. }
  5970. });
  5971. // expose FunctionalRenderContext for ssr runtime helper installation
  5972. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5973. value: FunctionalRenderContext
  5974. });
  5975. Vue.version = version;
  5976. // these are reserved for web because they are directly compiled away
  5977. // during template compilation
  5978. const isReservedAttr = makeMap('style,class');
  5979. // attributes that should be using props for binding
  5980. const acceptValue = makeMap('input,textarea,option,select,progress');
  5981. const mustUseProp = (tag, type, attr) => {
  5982. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5983. (attr === 'selected' && tag === 'option') ||
  5984. (attr === 'checked' && tag === 'input') ||
  5985. (attr === 'muted' && tag === 'video'));
  5986. };
  5987. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5988. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5989. const convertEnumeratedValue = (key, value) => {
  5990. return isFalsyAttrValue(value) || value === 'false'
  5991. ? 'false'
  5992. : // allow arbitrary string value for contenteditable
  5993. key === 'contenteditable' && isValidContentEditableValue(value)
  5994. ? value
  5995. : 'true';
  5996. };
  5997. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5998. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5999. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  6000. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  6001. 'required,reversed,scoped,seamless,selected,sortable,' +
  6002. 'truespeed,typemustmatch,visible');
  6003. const xlinkNS = 'http://www.w3.org/1999/xlink';
  6004. const isXlink = (name) => {
  6005. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  6006. };
  6007. const getXlinkProp = (name) => {
  6008. return isXlink(name) ? name.slice(6, name.length) : '';
  6009. };
  6010. const isFalsyAttrValue = (val) => {
  6011. return val == null || val === false;
  6012. };
  6013. function genClassForVnode(vnode) {
  6014. let data = vnode.data;
  6015. let parentNode = vnode;
  6016. let childNode = vnode;
  6017. while (isDef(childNode.componentInstance)) {
  6018. childNode = childNode.componentInstance._vnode;
  6019. if (childNode && childNode.data) {
  6020. data = mergeClassData(childNode.data, data);
  6021. }
  6022. }
  6023. // @ts-expect-error parentNode.parent not VNodeWithData
  6024. while (isDef((parentNode = parentNode.parent))) {
  6025. if (parentNode && parentNode.data) {
  6026. data = mergeClassData(data, parentNode.data);
  6027. }
  6028. }
  6029. return renderClass(data.staticClass, data.class);
  6030. }
  6031. function mergeClassData(child, parent) {
  6032. return {
  6033. staticClass: concat(child.staticClass, parent.staticClass),
  6034. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6035. };
  6036. }
  6037. function renderClass(staticClass, dynamicClass) {
  6038. if (isDef(staticClass) || isDef(dynamicClass)) {
  6039. return concat(staticClass, stringifyClass(dynamicClass));
  6040. }
  6041. /* istanbul ignore next */
  6042. return '';
  6043. }
  6044. function concat(a, b) {
  6045. return a ? (b ? a + ' ' + b : a) : b || '';
  6046. }
  6047. function stringifyClass(value) {
  6048. if (Array.isArray(value)) {
  6049. return stringifyArray(value);
  6050. }
  6051. if (isObject(value)) {
  6052. return stringifyObject(value);
  6053. }
  6054. if (typeof value === 'string') {
  6055. return value;
  6056. }
  6057. /* istanbul ignore next */
  6058. return '';
  6059. }
  6060. function stringifyArray(value) {
  6061. let res = '';
  6062. let stringified;
  6063. for (let i = 0, l = value.length; i < l; i++) {
  6064. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6065. if (res)
  6066. res += ' ';
  6067. res += stringified;
  6068. }
  6069. }
  6070. return res;
  6071. }
  6072. function stringifyObject(value) {
  6073. let res = '';
  6074. for (const key in value) {
  6075. if (value[key]) {
  6076. if (res)
  6077. res += ' ';
  6078. res += key;
  6079. }
  6080. }
  6081. return res;
  6082. }
  6083. const namespaceMap = {
  6084. svg: 'http://www.w3.org/2000/svg',
  6085. math: 'http://www.w3.org/1998/Math/MathML'
  6086. };
  6087. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6088. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6089. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6090. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6091. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6092. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6093. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6094. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6095. 'output,progress,select,textarea,' +
  6096. 'details,dialog,menu,menuitem,summary,' +
  6097. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6098. // this map is intentionally selective, only covering SVG elements that may
  6099. // contain child elements.
  6100. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6101. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6102. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6103. const isPreTag = (tag) => tag === 'pre';
  6104. const isReservedTag = (tag) => {
  6105. return isHTMLTag(tag) || isSVG(tag);
  6106. };
  6107. function getTagNamespace(tag) {
  6108. if (isSVG(tag)) {
  6109. return 'svg';
  6110. }
  6111. // basic support for MathML
  6112. // note it doesn't support other MathML elements being component roots
  6113. if (tag === 'math') {
  6114. return 'math';
  6115. }
  6116. }
  6117. const unknownElementCache = Object.create(null);
  6118. function isUnknownElement(tag) {
  6119. /* istanbul ignore if */
  6120. if (!inBrowser) {
  6121. return true;
  6122. }
  6123. if (isReservedTag(tag)) {
  6124. return false;
  6125. }
  6126. tag = tag.toLowerCase();
  6127. /* istanbul ignore if */
  6128. if (unknownElementCache[tag] != null) {
  6129. return unknownElementCache[tag];
  6130. }
  6131. const el = document.createElement(tag);
  6132. if (tag.indexOf('-') > -1) {
  6133. // https://stackoverflow.com/a/28210364/1070244
  6134. return (unknownElementCache[tag] =
  6135. el.constructor === window.HTMLUnknownElement ||
  6136. el.constructor === window.HTMLElement);
  6137. }
  6138. else {
  6139. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6140. }
  6141. }
  6142. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6143. /**
  6144. * Query an element selector if it's not an element already.
  6145. */
  6146. function query(el) {
  6147. if (typeof el === 'string') {
  6148. const selected = document.querySelector(el);
  6149. if (!selected) {
  6150. warn$2('Cannot find element: ' + el);
  6151. return document.createElement('div');
  6152. }
  6153. return selected;
  6154. }
  6155. else {
  6156. return el;
  6157. }
  6158. }
  6159. function createElement(tagName, vnode) {
  6160. const elm = document.createElement(tagName);
  6161. if (tagName !== 'select') {
  6162. return elm;
  6163. }
  6164. // false or null will remove the attribute but undefined will not
  6165. if (vnode.data &&
  6166. vnode.data.attrs &&
  6167. vnode.data.attrs.multiple !== undefined) {
  6168. elm.setAttribute('multiple', 'multiple');
  6169. }
  6170. return elm;
  6171. }
  6172. function createElementNS(namespace, tagName) {
  6173. return document.createElementNS(namespaceMap[namespace], tagName);
  6174. }
  6175. function createTextNode(text) {
  6176. return document.createTextNode(text);
  6177. }
  6178. function createComment(text) {
  6179. return document.createComment(text);
  6180. }
  6181. function insertBefore(parentNode, newNode, referenceNode) {
  6182. parentNode.insertBefore(newNode, referenceNode);
  6183. }
  6184. function removeChild(node, child) {
  6185. node.removeChild(child);
  6186. }
  6187. function appendChild(node, child) {
  6188. node.appendChild(child);
  6189. }
  6190. function parentNode(node) {
  6191. return node.parentNode;
  6192. }
  6193. function nextSibling(node) {
  6194. return node.nextSibling;
  6195. }
  6196. function tagName(node) {
  6197. return node.tagName;
  6198. }
  6199. function setTextContent(node, text) {
  6200. node.textContent = text;
  6201. }
  6202. function setStyleScope(node, scopeId) {
  6203. node.setAttribute(scopeId, '');
  6204. }
  6205. var nodeOps = /*#__PURE__*/Object.freeze({
  6206. __proto__: null,
  6207. createElement: createElement,
  6208. createElementNS: createElementNS,
  6209. createTextNode: createTextNode,
  6210. createComment: createComment,
  6211. insertBefore: insertBefore,
  6212. removeChild: removeChild,
  6213. appendChild: appendChild,
  6214. parentNode: parentNode,
  6215. nextSibling: nextSibling,
  6216. tagName: tagName,
  6217. setTextContent: setTextContent,
  6218. setStyleScope: setStyleScope
  6219. });
  6220. var ref = {
  6221. create(_, vnode) {
  6222. registerRef(vnode);
  6223. },
  6224. update(oldVnode, vnode) {
  6225. if (oldVnode.data.ref !== vnode.data.ref) {
  6226. registerRef(oldVnode, true);
  6227. registerRef(vnode);
  6228. }
  6229. },
  6230. destroy(vnode) {
  6231. registerRef(vnode, true);
  6232. }
  6233. };
  6234. function registerRef(vnode, isRemoval) {
  6235. const ref = vnode.data.ref;
  6236. if (!isDef(ref))
  6237. return;
  6238. const vm = vnode.context;
  6239. const refValue = vnode.componentInstance || vnode.elm;
  6240. const value = isRemoval ? null : refValue;
  6241. const $refsValue = isRemoval ? undefined : refValue;
  6242. if (isFunction(ref)) {
  6243. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6244. return;
  6245. }
  6246. const isFor = vnode.data.refInFor;
  6247. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6248. const _isRef = isRef(ref);
  6249. const refs = vm.$refs;
  6250. if (_isString || _isRef) {
  6251. if (isFor) {
  6252. const existing = _isString ? refs[ref] : ref.value;
  6253. if (isRemoval) {
  6254. isArray(existing) && remove$2(existing, refValue);
  6255. }
  6256. else {
  6257. if (!isArray(existing)) {
  6258. if (_isString) {
  6259. refs[ref] = [refValue];
  6260. setSetupRef(vm, ref, refs[ref]);
  6261. }
  6262. else {
  6263. ref.value = [refValue];
  6264. }
  6265. }
  6266. else if (!existing.includes(refValue)) {
  6267. existing.push(refValue);
  6268. }
  6269. }
  6270. }
  6271. else if (_isString) {
  6272. if (isRemoval && refs[ref] !== refValue) {
  6273. return;
  6274. }
  6275. refs[ref] = $refsValue;
  6276. setSetupRef(vm, ref, value);
  6277. }
  6278. else if (_isRef) {
  6279. if (isRemoval && ref.value !== refValue) {
  6280. return;
  6281. }
  6282. ref.value = value;
  6283. }
  6284. else {
  6285. warn$2(`Invalid template ref type: ${typeof ref}`);
  6286. }
  6287. }
  6288. }
  6289. function setSetupRef({ _setupState }, key, val) {
  6290. if (_setupState && hasOwn(_setupState, key)) {
  6291. if (isRef(_setupState[key])) {
  6292. _setupState[key].value = val;
  6293. }
  6294. else {
  6295. _setupState[key] = val;
  6296. }
  6297. }
  6298. }
  6299. /**
  6300. * Virtual DOM patching algorithm based on Snabbdom by
  6301. * Simon Friis Vindum (@paldepind)
  6302. * Licensed under the MIT License
  6303. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6304. *
  6305. * modified by Evan You (@yyx990803)
  6306. *
  6307. * Not type-checking this because this file is perf-critical and the cost
  6308. * of making flow understand it is not worth it.
  6309. */
  6310. const emptyNode = new VNode('', {}, []);
  6311. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6312. function sameVnode(a, b) {
  6313. return (a.key === b.key &&
  6314. a.asyncFactory === b.asyncFactory &&
  6315. ((a.tag === b.tag &&
  6316. a.isComment === b.isComment &&
  6317. isDef(a.data) === isDef(b.data) &&
  6318. sameInputType(a, b)) ||
  6319. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6320. }
  6321. function sameInputType(a, b) {
  6322. if (a.tag !== 'input')
  6323. return true;
  6324. let i;
  6325. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6326. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6327. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6328. }
  6329. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6330. let i, key;
  6331. const map = {};
  6332. for (i = beginIdx; i <= endIdx; ++i) {
  6333. key = children[i].key;
  6334. if (isDef(key))
  6335. map[key] = i;
  6336. }
  6337. return map;
  6338. }
  6339. function createPatchFunction(backend) {
  6340. let i, j;
  6341. const cbs = {};
  6342. const { modules, nodeOps } = backend;
  6343. for (i = 0; i < hooks.length; ++i) {
  6344. cbs[hooks[i]] = [];
  6345. for (j = 0; j < modules.length; ++j) {
  6346. if (isDef(modules[j][hooks[i]])) {
  6347. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6348. }
  6349. }
  6350. }
  6351. function emptyNodeAt(elm) {
  6352. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6353. }
  6354. function createRmCb(childElm, listeners) {
  6355. function remove() {
  6356. if (--remove.listeners === 0) {
  6357. removeNode(childElm);
  6358. }
  6359. }
  6360. remove.listeners = listeners;
  6361. return remove;
  6362. }
  6363. function removeNode(el) {
  6364. const parent = nodeOps.parentNode(el);
  6365. // element may have already been removed due to v-html / v-text
  6366. if (isDef(parent)) {
  6367. nodeOps.removeChild(parent, el);
  6368. }
  6369. }
  6370. function isUnknownElement(vnode, inVPre) {
  6371. return (!inVPre &&
  6372. !vnode.ns &&
  6373. !(config.ignoredElements.length &&
  6374. config.ignoredElements.some(ignore => {
  6375. return isRegExp(ignore)
  6376. ? ignore.test(vnode.tag)
  6377. : ignore === vnode.tag;
  6378. })) &&
  6379. config.isUnknownElement(vnode.tag));
  6380. }
  6381. let creatingElmInVPre = 0;
  6382. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6383. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6384. // This vnode was used in a previous render!
  6385. // now it's used as a new node, overwriting its elm would cause
  6386. // potential patch errors down the road when it's used as an insertion
  6387. // reference node. Instead, we clone the node on-demand before creating
  6388. // associated DOM element for it.
  6389. vnode = ownerArray[index] = cloneVNode(vnode);
  6390. }
  6391. vnode.isRootInsert = !nested; // for transition enter check
  6392. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6393. return;
  6394. }
  6395. const data = vnode.data;
  6396. const children = vnode.children;
  6397. const tag = vnode.tag;
  6398. if (isDef(tag)) {
  6399. {
  6400. if (data && data.pre) {
  6401. creatingElmInVPre++;
  6402. }
  6403. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6404. warn$2('Unknown custom element: <' +
  6405. tag +
  6406. '> - did you ' +
  6407. 'register the component correctly? For recursive components, ' +
  6408. 'make sure to provide the "name" option.', vnode.context);
  6409. }
  6410. }
  6411. vnode.elm = vnode.ns
  6412. ? nodeOps.createElementNS(vnode.ns, tag)
  6413. : nodeOps.createElement(tag, vnode);
  6414. setScope(vnode);
  6415. createChildren(vnode, children, insertedVnodeQueue);
  6416. if (isDef(data)) {
  6417. invokeCreateHooks(vnode, insertedVnodeQueue);
  6418. }
  6419. insert(parentElm, vnode.elm, refElm);
  6420. if (data && data.pre) {
  6421. creatingElmInVPre--;
  6422. }
  6423. }
  6424. else if (isTrue(vnode.isComment)) {
  6425. vnode.elm = nodeOps.createComment(vnode.text);
  6426. insert(parentElm, vnode.elm, refElm);
  6427. }
  6428. else {
  6429. vnode.elm = nodeOps.createTextNode(vnode.text);
  6430. insert(parentElm, vnode.elm, refElm);
  6431. }
  6432. }
  6433. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6434. let i = vnode.data;
  6435. if (isDef(i)) {
  6436. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6437. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6438. i(vnode, false /* hydrating */);
  6439. }
  6440. // after calling the init hook, if the vnode is a child component
  6441. // it should've created a child instance and mounted it. the child
  6442. // component also has set the placeholder vnode's elm.
  6443. // in that case we can just return the element and be done.
  6444. if (isDef(vnode.componentInstance)) {
  6445. initComponent(vnode, insertedVnodeQueue);
  6446. insert(parentElm, vnode.elm, refElm);
  6447. if (isTrue(isReactivated)) {
  6448. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6449. }
  6450. return true;
  6451. }
  6452. }
  6453. }
  6454. function initComponent(vnode, insertedVnodeQueue) {
  6455. if (isDef(vnode.data.pendingInsert)) {
  6456. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6457. vnode.data.pendingInsert = null;
  6458. }
  6459. vnode.elm = vnode.componentInstance.$el;
  6460. if (isPatchable(vnode)) {
  6461. invokeCreateHooks(vnode, insertedVnodeQueue);
  6462. setScope(vnode);
  6463. }
  6464. else {
  6465. // empty component root.
  6466. // skip all element-related modules except for ref (#3455)
  6467. registerRef(vnode);
  6468. // make sure to invoke the insert hook
  6469. insertedVnodeQueue.push(vnode);
  6470. }
  6471. }
  6472. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6473. let i;
  6474. // hack for #4339: a reactivated component with inner transition
  6475. // does not trigger because the inner node's created hooks are not called
  6476. // again. It's not ideal to involve module-specific logic in here but
  6477. // there doesn't seem to be a better way to do it.
  6478. let innerNode = vnode;
  6479. while (innerNode.componentInstance) {
  6480. innerNode = innerNode.componentInstance._vnode;
  6481. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6482. for (i = 0; i < cbs.activate.length; ++i) {
  6483. cbs.activate[i](emptyNode, innerNode);
  6484. }
  6485. insertedVnodeQueue.push(innerNode);
  6486. break;
  6487. }
  6488. }
  6489. // unlike a newly created component,
  6490. // a reactivated keep-alive component doesn't insert itself
  6491. insert(parentElm, vnode.elm, refElm);
  6492. }
  6493. function insert(parent, elm, ref) {
  6494. if (isDef(parent)) {
  6495. if (isDef(ref)) {
  6496. if (nodeOps.parentNode(ref) === parent) {
  6497. nodeOps.insertBefore(parent, elm, ref);
  6498. }
  6499. }
  6500. else {
  6501. nodeOps.appendChild(parent, elm);
  6502. }
  6503. }
  6504. }
  6505. function createChildren(vnode, children, insertedVnodeQueue) {
  6506. if (isArray(children)) {
  6507. {
  6508. checkDuplicateKeys(children);
  6509. }
  6510. for (let i = 0; i < children.length; ++i) {
  6511. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6512. }
  6513. }
  6514. else if (isPrimitive(vnode.text)) {
  6515. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6516. }
  6517. }
  6518. function isPatchable(vnode) {
  6519. while (vnode.componentInstance) {
  6520. vnode = vnode.componentInstance._vnode;
  6521. }
  6522. return isDef(vnode.tag);
  6523. }
  6524. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6525. for (let i = 0; i < cbs.create.length; ++i) {
  6526. cbs.create[i](emptyNode, vnode);
  6527. }
  6528. i = vnode.data.hook; // Reuse variable
  6529. if (isDef(i)) {
  6530. if (isDef(i.create))
  6531. i.create(emptyNode, vnode);
  6532. if (isDef(i.insert))
  6533. insertedVnodeQueue.push(vnode);
  6534. }
  6535. }
  6536. // set scope id attribute for scoped CSS.
  6537. // this is implemented as a special case to avoid the overhead
  6538. // of going through the normal attribute patching process.
  6539. function setScope(vnode) {
  6540. let i;
  6541. if (isDef((i = vnode.fnScopeId))) {
  6542. nodeOps.setStyleScope(vnode.elm, i);
  6543. }
  6544. else {
  6545. let ancestor = vnode;
  6546. while (ancestor) {
  6547. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6548. nodeOps.setStyleScope(vnode.elm, i);
  6549. }
  6550. ancestor = ancestor.parent;
  6551. }
  6552. }
  6553. // for slot content they should also get the scopeId from the host instance.
  6554. if (isDef((i = activeInstance)) &&
  6555. i !== vnode.context &&
  6556. i !== vnode.fnContext &&
  6557. isDef((i = i.$options._scopeId))) {
  6558. nodeOps.setStyleScope(vnode.elm, i);
  6559. }
  6560. }
  6561. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6562. for (; startIdx <= endIdx; ++startIdx) {
  6563. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6564. }
  6565. }
  6566. function invokeDestroyHook(vnode) {
  6567. let i, j;
  6568. const data = vnode.data;
  6569. if (isDef(data)) {
  6570. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6571. i(vnode);
  6572. for (i = 0; i < cbs.destroy.length; ++i)
  6573. cbs.destroy[i](vnode);
  6574. }
  6575. if (isDef((i = vnode.children))) {
  6576. for (j = 0; j < vnode.children.length; ++j) {
  6577. invokeDestroyHook(vnode.children[j]);
  6578. }
  6579. }
  6580. }
  6581. function removeVnodes(vnodes, startIdx, endIdx) {
  6582. for (; startIdx <= endIdx; ++startIdx) {
  6583. const ch = vnodes[startIdx];
  6584. if (isDef(ch)) {
  6585. if (isDef(ch.tag)) {
  6586. removeAndInvokeRemoveHook(ch);
  6587. invokeDestroyHook(ch);
  6588. }
  6589. else {
  6590. // Text node
  6591. removeNode(ch.elm);
  6592. }
  6593. }
  6594. }
  6595. }
  6596. function removeAndInvokeRemoveHook(vnode, rm) {
  6597. if (isDef(rm) || isDef(vnode.data)) {
  6598. let i;
  6599. const listeners = cbs.remove.length + 1;
  6600. if (isDef(rm)) {
  6601. // we have a recursively passed down rm callback
  6602. // increase the listeners count
  6603. rm.listeners += listeners;
  6604. }
  6605. else {
  6606. // directly removing
  6607. rm = createRmCb(vnode.elm, listeners);
  6608. }
  6609. // recursively invoke hooks on child component root node
  6610. if (isDef((i = vnode.componentInstance)) &&
  6611. isDef((i = i._vnode)) &&
  6612. isDef(i.data)) {
  6613. removeAndInvokeRemoveHook(i, rm);
  6614. }
  6615. for (i = 0; i < cbs.remove.length; ++i) {
  6616. cbs.remove[i](vnode, rm);
  6617. }
  6618. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6619. i(vnode, rm);
  6620. }
  6621. else {
  6622. rm();
  6623. }
  6624. }
  6625. else {
  6626. removeNode(vnode.elm);
  6627. }
  6628. }
  6629. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6630. let oldStartIdx = 0;
  6631. let newStartIdx = 0;
  6632. let oldEndIdx = oldCh.length - 1;
  6633. let oldStartVnode = oldCh[0];
  6634. let oldEndVnode = oldCh[oldEndIdx];
  6635. let newEndIdx = newCh.length - 1;
  6636. let newStartVnode = newCh[0];
  6637. let newEndVnode = newCh[newEndIdx];
  6638. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6639. // removeOnly is a special flag used only by <transition-group>
  6640. // to ensure removed elements stay in correct relative positions
  6641. // during leaving transitions
  6642. const canMove = !removeOnly;
  6643. {
  6644. checkDuplicateKeys(newCh);
  6645. }
  6646. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6647. if (isUndef(oldStartVnode)) {
  6648. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6649. }
  6650. else if (isUndef(oldEndVnode)) {
  6651. oldEndVnode = oldCh[--oldEndIdx];
  6652. }
  6653. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6654. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6655. oldStartVnode = oldCh[++oldStartIdx];
  6656. newStartVnode = newCh[++newStartIdx];
  6657. }
  6658. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6659. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6660. oldEndVnode = oldCh[--oldEndIdx];
  6661. newEndVnode = newCh[--newEndIdx];
  6662. }
  6663. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6664. // Vnode moved right
  6665. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6666. canMove &&
  6667. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6668. oldStartVnode = oldCh[++oldStartIdx];
  6669. newEndVnode = newCh[--newEndIdx];
  6670. }
  6671. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6672. // Vnode moved left
  6673. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6674. canMove &&
  6675. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6676. oldEndVnode = oldCh[--oldEndIdx];
  6677. newStartVnode = newCh[++newStartIdx];
  6678. }
  6679. else {
  6680. if (isUndef(oldKeyToIdx))
  6681. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6682. idxInOld = isDef(newStartVnode.key)
  6683. ? oldKeyToIdx[newStartVnode.key]
  6684. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6685. if (isUndef(idxInOld)) {
  6686. // New element
  6687. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6688. }
  6689. else {
  6690. vnodeToMove = oldCh[idxInOld];
  6691. if (sameVnode(vnodeToMove, newStartVnode)) {
  6692. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6693. oldCh[idxInOld] = undefined;
  6694. canMove &&
  6695. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6696. }
  6697. else {
  6698. // same key but different element. treat as new element
  6699. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6700. }
  6701. }
  6702. newStartVnode = newCh[++newStartIdx];
  6703. }
  6704. }
  6705. if (oldStartIdx > oldEndIdx) {
  6706. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6707. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6708. }
  6709. else if (newStartIdx > newEndIdx) {
  6710. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6711. }
  6712. }
  6713. function checkDuplicateKeys(children) {
  6714. const seenKeys = {};
  6715. for (let i = 0; i < children.length; i++) {
  6716. const vnode = children[i];
  6717. const key = vnode.key;
  6718. if (isDef(key)) {
  6719. if (seenKeys[key]) {
  6720. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6721. }
  6722. else {
  6723. seenKeys[key] = true;
  6724. }
  6725. }
  6726. }
  6727. }
  6728. function findIdxInOld(node, oldCh, start, end) {
  6729. for (let i = start; i < end; i++) {
  6730. const c = oldCh[i];
  6731. if (isDef(c) && sameVnode(node, c))
  6732. return i;
  6733. }
  6734. }
  6735. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6736. if (oldVnode === vnode) {
  6737. return;
  6738. }
  6739. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6740. // clone reused vnode
  6741. vnode = ownerArray[index] = cloneVNode(vnode);
  6742. }
  6743. const elm = (vnode.elm = oldVnode.elm);
  6744. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6745. if (isDef(vnode.asyncFactory.resolved)) {
  6746. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6747. }
  6748. else {
  6749. vnode.isAsyncPlaceholder = true;
  6750. }
  6751. return;
  6752. }
  6753. // reuse element for static trees.
  6754. // note we only do this if the vnode is cloned -
  6755. // if the new node is not cloned it means the render functions have been
  6756. // reset by the hot-reload-api and we need to do a proper re-render.
  6757. if (isTrue(vnode.isStatic) &&
  6758. isTrue(oldVnode.isStatic) &&
  6759. vnode.key === oldVnode.key &&
  6760. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6761. vnode.componentInstance = oldVnode.componentInstance;
  6762. return;
  6763. }
  6764. let i;
  6765. const data = vnode.data;
  6766. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6767. i(oldVnode, vnode);
  6768. }
  6769. const oldCh = oldVnode.children;
  6770. const ch = vnode.children;
  6771. if (isDef(data) && isPatchable(vnode)) {
  6772. for (i = 0; i < cbs.update.length; ++i)
  6773. cbs.update[i](oldVnode, vnode);
  6774. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6775. i(oldVnode, vnode);
  6776. }
  6777. if (isUndef(vnode.text)) {
  6778. if (isDef(oldCh) && isDef(ch)) {
  6779. if (oldCh !== ch)
  6780. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6781. }
  6782. else if (isDef(ch)) {
  6783. {
  6784. checkDuplicateKeys(ch);
  6785. }
  6786. if (isDef(oldVnode.text))
  6787. nodeOps.setTextContent(elm, '');
  6788. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6789. }
  6790. else if (isDef(oldCh)) {
  6791. removeVnodes(oldCh, 0, oldCh.length - 1);
  6792. }
  6793. else if (isDef(oldVnode.text)) {
  6794. nodeOps.setTextContent(elm, '');
  6795. }
  6796. }
  6797. else if (oldVnode.text !== vnode.text) {
  6798. nodeOps.setTextContent(elm, vnode.text);
  6799. }
  6800. if (isDef(data)) {
  6801. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6802. i(oldVnode, vnode);
  6803. }
  6804. }
  6805. function invokeInsertHook(vnode, queue, initial) {
  6806. // delay insert hooks for component root nodes, invoke them after the
  6807. // element is really inserted
  6808. if (isTrue(initial) && isDef(vnode.parent)) {
  6809. vnode.parent.data.pendingInsert = queue;
  6810. }
  6811. else {
  6812. for (let i = 0; i < queue.length; ++i) {
  6813. queue[i].data.hook.insert(queue[i]);
  6814. }
  6815. }
  6816. }
  6817. let hydrationBailed = false;
  6818. // list of modules that can skip create hook during hydration because they
  6819. // are already rendered on the client or has no need for initialization
  6820. // Note: style is excluded because it relies on initial clone for future
  6821. // deep updates (#7063).
  6822. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6823. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6824. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6825. let i;
  6826. const { tag, data, children } = vnode;
  6827. inVPre = inVPre || (data && data.pre);
  6828. vnode.elm = elm;
  6829. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6830. vnode.isAsyncPlaceholder = true;
  6831. return true;
  6832. }
  6833. // assert node match
  6834. {
  6835. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6836. return false;
  6837. }
  6838. }
  6839. if (isDef(data)) {
  6840. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6841. i(vnode, true /* hydrating */);
  6842. if (isDef((i = vnode.componentInstance))) {
  6843. // child component. it should have hydrated its own tree.
  6844. initComponent(vnode, insertedVnodeQueue);
  6845. return true;
  6846. }
  6847. }
  6848. if (isDef(tag)) {
  6849. if (isDef(children)) {
  6850. // empty element, allow client to pick up and populate children
  6851. if (!elm.hasChildNodes()) {
  6852. createChildren(vnode, children, insertedVnodeQueue);
  6853. }
  6854. else {
  6855. // v-html and domProps: innerHTML
  6856. if (isDef((i = data)) &&
  6857. isDef((i = i.domProps)) &&
  6858. isDef((i = i.innerHTML))) {
  6859. if (i !== elm.innerHTML) {
  6860. /* istanbul ignore if */
  6861. if (typeof console !== 'undefined' &&
  6862. !hydrationBailed) {
  6863. hydrationBailed = true;
  6864. console.warn('Parent: ', elm);
  6865. console.warn('server innerHTML: ', i);
  6866. console.warn('client innerHTML: ', elm.innerHTML);
  6867. }
  6868. return false;
  6869. }
  6870. }
  6871. else {
  6872. // iterate and compare children lists
  6873. let childrenMatch = true;
  6874. let childNode = elm.firstChild;
  6875. for (let i = 0; i < children.length; i++) {
  6876. if (!childNode ||
  6877. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6878. childrenMatch = false;
  6879. break;
  6880. }
  6881. childNode = childNode.nextSibling;
  6882. }
  6883. // if childNode is not null, it means the actual childNodes list is
  6884. // longer than the virtual children list.
  6885. if (!childrenMatch || childNode) {
  6886. /* istanbul ignore if */
  6887. if (typeof console !== 'undefined' &&
  6888. !hydrationBailed) {
  6889. hydrationBailed = true;
  6890. console.warn('Parent: ', elm);
  6891. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6892. }
  6893. return false;
  6894. }
  6895. }
  6896. }
  6897. }
  6898. if (isDef(data)) {
  6899. let fullInvoke = false;
  6900. for (const key in data) {
  6901. if (!isRenderedModule(key)) {
  6902. fullInvoke = true;
  6903. invokeCreateHooks(vnode, insertedVnodeQueue);
  6904. break;
  6905. }
  6906. }
  6907. if (!fullInvoke && data['class']) {
  6908. // ensure collecting deps for deep class bindings for future updates
  6909. traverse(data['class']);
  6910. }
  6911. }
  6912. }
  6913. else if (elm.data !== vnode.text) {
  6914. elm.data = vnode.text;
  6915. }
  6916. return true;
  6917. }
  6918. function assertNodeMatch(node, vnode, inVPre) {
  6919. if (isDef(vnode.tag)) {
  6920. return (vnode.tag.indexOf('vue-component') === 0 ||
  6921. (!isUnknownElement(vnode, inVPre) &&
  6922. vnode.tag.toLowerCase() ===
  6923. (node.tagName && node.tagName.toLowerCase())));
  6924. }
  6925. else {
  6926. return node.nodeType === (vnode.isComment ? 8 : 3);
  6927. }
  6928. }
  6929. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6930. if (isUndef(vnode)) {
  6931. if (isDef(oldVnode))
  6932. invokeDestroyHook(oldVnode);
  6933. return;
  6934. }
  6935. let isInitialPatch = false;
  6936. const insertedVnodeQueue = [];
  6937. if (isUndef(oldVnode)) {
  6938. // empty mount (likely as component), create new root element
  6939. isInitialPatch = true;
  6940. createElm(vnode, insertedVnodeQueue);
  6941. }
  6942. else {
  6943. const isRealElement = isDef(oldVnode.nodeType);
  6944. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6945. // patch existing root node
  6946. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6947. }
  6948. else {
  6949. if (isRealElement) {
  6950. // mounting to a real element
  6951. // check if this is server-rendered content and if we can perform
  6952. // a successful hydration.
  6953. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6954. oldVnode.removeAttribute(SSR_ATTR);
  6955. hydrating = true;
  6956. }
  6957. if (isTrue(hydrating)) {
  6958. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6959. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6960. return oldVnode;
  6961. }
  6962. else {
  6963. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6964. 'server-rendered content. This is likely caused by incorrect ' +
  6965. 'HTML markup, for example nesting block-level elements inside ' +
  6966. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6967. 'full client-side render.');
  6968. }
  6969. }
  6970. // either not server-rendered, or hydration failed.
  6971. // create an empty node and replace it
  6972. oldVnode = emptyNodeAt(oldVnode);
  6973. }
  6974. // replacing existing element
  6975. const oldElm = oldVnode.elm;
  6976. const parentElm = nodeOps.parentNode(oldElm);
  6977. // create new node
  6978. createElm(vnode, insertedVnodeQueue,
  6979. // extremely rare edge case: do not insert if old element is in a
  6980. // leaving transition. Only happens when combining transition +
  6981. // keep-alive + HOCs. (#4590)
  6982. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6983. // update parent placeholder node element, recursively
  6984. if (isDef(vnode.parent)) {
  6985. let ancestor = vnode.parent;
  6986. const patchable = isPatchable(vnode);
  6987. while (ancestor) {
  6988. for (let i = 0; i < cbs.destroy.length; ++i) {
  6989. cbs.destroy[i](ancestor);
  6990. }
  6991. ancestor.elm = vnode.elm;
  6992. if (patchable) {
  6993. for (let i = 0; i < cbs.create.length; ++i) {
  6994. cbs.create[i](emptyNode, ancestor);
  6995. }
  6996. // #6513
  6997. // invoke insert hooks that may have been merged by create hooks.
  6998. // e.g. for directives that uses the "inserted" hook.
  6999. const insert = ancestor.data.hook.insert;
  7000. if (insert.merged) {
  7001. // start at index 1 to avoid re-invoking component mounted hook
  7002. // clone insert hooks to avoid being mutated during iteration.
  7003. // e.g. for customed directives under transition group.
  7004. const cloned = insert.fns.slice(1);
  7005. for (let i = 0; i < cloned.length; i++) {
  7006. cloned[i]();
  7007. }
  7008. }
  7009. }
  7010. else {
  7011. registerRef(ancestor);
  7012. }
  7013. ancestor = ancestor.parent;
  7014. }
  7015. }
  7016. // destroy old node
  7017. if (isDef(parentElm)) {
  7018. removeVnodes([oldVnode], 0, 0);
  7019. }
  7020. else if (isDef(oldVnode.tag)) {
  7021. invokeDestroyHook(oldVnode);
  7022. }
  7023. }
  7024. }
  7025. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  7026. return vnode.elm;
  7027. };
  7028. }
  7029. var directives$1 = {
  7030. create: updateDirectives,
  7031. update: updateDirectives,
  7032. destroy: function unbindDirectives(vnode) {
  7033. // @ts-expect-error emptyNode is not VNodeWithData
  7034. updateDirectives(vnode, emptyNode);
  7035. }
  7036. };
  7037. function updateDirectives(oldVnode, vnode) {
  7038. if (oldVnode.data.directives || vnode.data.directives) {
  7039. _update(oldVnode, vnode);
  7040. }
  7041. }
  7042. function _update(oldVnode, vnode) {
  7043. const isCreate = oldVnode === emptyNode;
  7044. const isDestroy = vnode === emptyNode;
  7045. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7046. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7047. const dirsWithInsert = [];
  7048. const dirsWithPostpatch = [];
  7049. let key, oldDir, dir;
  7050. for (key in newDirs) {
  7051. oldDir = oldDirs[key];
  7052. dir = newDirs[key];
  7053. if (!oldDir) {
  7054. // new directive, bind
  7055. callHook(dir, 'bind', vnode, oldVnode);
  7056. if (dir.def && dir.def.inserted) {
  7057. dirsWithInsert.push(dir);
  7058. }
  7059. }
  7060. else {
  7061. // existing directive, update
  7062. dir.oldValue = oldDir.value;
  7063. dir.oldArg = oldDir.arg;
  7064. callHook(dir, 'update', vnode, oldVnode);
  7065. if (dir.def && dir.def.componentUpdated) {
  7066. dirsWithPostpatch.push(dir);
  7067. }
  7068. }
  7069. }
  7070. if (dirsWithInsert.length) {
  7071. const callInsert = () => {
  7072. for (let i = 0; i < dirsWithInsert.length; i++) {
  7073. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7074. }
  7075. };
  7076. if (isCreate) {
  7077. mergeVNodeHook(vnode, 'insert', callInsert);
  7078. }
  7079. else {
  7080. callInsert();
  7081. }
  7082. }
  7083. if (dirsWithPostpatch.length) {
  7084. mergeVNodeHook(vnode, 'postpatch', () => {
  7085. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7086. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7087. }
  7088. });
  7089. }
  7090. if (!isCreate) {
  7091. for (key in oldDirs) {
  7092. if (!newDirs[key]) {
  7093. // no longer present, unbind
  7094. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7095. }
  7096. }
  7097. }
  7098. }
  7099. const emptyModifiers = Object.create(null);
  7100. function normalizeDirectives(dirs, vm) {
  7101. const res = Object.create(null);
  7102. if (!dirs) {
  7103. // $flow-disable-line
  7104. return res;
  7105. }
  7106. let i, dir;
  7107. for (i = 0; i < dirs.length; i++) {
  7108. dir = dirs[i];
  7109. if (!dir.modifiers) {
  7110. // $flow-disable-line
  7111. dir.modifiers = emptyModifiers;
  7112. }
  7113. res[getRawDirName(dir)] = dir;
  7114. if (vm._setupState && vm._setupState.__sfc) {
  7115. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7116. if (typeof setupDef === 'function') {
  7117. dir.def = {
  7118. bind: setupDef,
  7119. update: setupDef,
  7120. };
  7121. }
  7122. else {
  7123. dir.def = setupDef;
  7124. }
  7125. }
  7126. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7127. }
  7128. // $flow-disable-line
  7129. return res;
  7130. }
  7131. function getRawDirName(dir) {
  7132. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7133. }
  7134. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7135. const fn = dir.def && dir.def[hook];
  7136. if (fn) {
  7137. try {
  7138. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7139. }
  7140. catch (e) {
  7141. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7142. }
  7143. }
  7144. }
  7145. var baseModules = [ref, directives$1];
  7146. function updateAttrs(oldVnode, vnode) {
  7147. const opts = vnode.componentOptions;
  7148. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7149. return;
  7150. }
  7151. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7152. return;
  7153. }
  7154. let key, cur, old;
  7155. const elm = vnode.elm;
  7156. const oldAttrs = oldVnode.data.attrs || {};
  7157. let attrs = vnode.data.attrs || {};
  7158. // clone observed objects, as the user probably wants to mutate it
  7159. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7160. attrs = vnode.data.attrs = extend({}, attrs);
  7161. }
  7162. for (key in attrs) {
  7163. cur = attrs[key];
  7164. old = oldAttrs[key];
  7165. if (old !== cur) {
  7166. setAttr(elm, key, cur, vnode.data.pre);
  7167. }
  7168. }
  7169. // #4391: in IE9, setting type can reset value for input[type=radio]
  7170. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7171. /* istanbul ignore if */
  7172. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7173. setAttr(elm, 'value', attrs.value);
  7174. }
  7175. for (key in oldAttrs) {
  7176. if (isUndef(attrs[key])) {
  7177. if (isXlink(key)) {
  7178. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7179. }
  7180. else if (!isEnumeratedAttr(key)) {
  7181. elm.removeAttribute(key);
  7182. }
  7183. }
  7184. }
  7185. }
  7186. function setAttr(el, key, value, isInPre) {
  7187. if (isInPre || el.tagName.indexOf('-') > -1) {
  7188. baseSetAttr(el, key, value);
  7189. }
  7190. else if (isBooleanAttr(key)) {
  7191. // set attribute for blank value
  7192. // e.g. <option disabled>Select one</option>
  7193. if (isFalsyAttrValue(value)) {
  7194. el.removeAttribute(key);
  7195. }
  7196. else {
  7197. // technically allowfullscreen is a boolean attribute for <iframe>,
  7198. // but Flash expects a value of "true" when used on <embed> tag
  7199. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7200. el.setAttribute(key, value);
  7201. }
  7202. }
  7203. else if (isEnumeratedAttr(key)) {
  7204. el.setAttribute(key, convertEnumeratedValue(key, value));
  7205. }
  7206. else if (isXlink(key)) {
  7207. if (isFalsyAttrValue(value)) {
  7208. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7209. }
  7210. else {
  7211. el.setAttributeNS(xlinkNS, key, value);
  7212. }
  7213. }
  7214. else {
  7215. baseSetAttr(el, key, value);
  7216. }
  7217. }
  7218. function baseSetAttr(el, key, value) {
  7219. if (isFalsyAttrValue(value)) {
  7220. el.removeAttribute(key);
  7221. }
  7222. else {
  7223. // #7138: IE10 & 11 fires input event when setting placeholder on
  7224. // <textarea>... block the first input event and remove the blocker
  7225. // immediately.
  7226. /* istanbul ignore if */
  7227. if (isIE &&
  7228. !isIE9 &&
  7229. el.tagName === 'TEXTAREA' &&
  7230. key === 'placeholder' &&
  7231. value !== '' &&
  7232. !el.__ieph) {
  7233. const blocker = e => {
  7234. e.stopImmediatePropagation();
  7235. el.removeEventListener('input', blocker);
  7236. };
  7237. el.addEventListener('input', blocker);
  7238. // $flow-disable-line
  7239. el.__ieph = true; /* IE placeholder patched */
  7240. }
  7241. el.setAttribute(key, value);
  7242. }
  7243. }
  7244. var attrs = {
  7245. create: updateAttrs,
  7246. update: updateAttrs
  7247. };
  7248. function updateClass(oldVnode, vnode) {
  7249. const el = vnode.elm;
  7250. const data = vnode.data;
  7251. const oldData = oldVnode.data;
  7252. if (isUndef(data.staticClass) &&
  7253. isUndef(data.class) &&
  7254. (isUndef(oldData) ||
  7255. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7256. return;
  7257. }
  7258. let cls = genClassForVnode(vnode);
  7259. // handle transition classes
  7260. const transitionClass = el._transitionClasses;
  7261. if (isDef(transitionClass)) {
  7262. cls = concat(cls, stringifyClass(transitionClass));
  7263. }
  7264. // set the class
  7265. if (cls !== el._prevClass) {
  7266. el.setAttribute('class', cls);
  7267. el._prevClass = cls;
  7268. }
  7269. }
  7270. var klass$1 = {
  7271. create: updateClass,
  7272. update: updateClass
  7273. };
  7274. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7275. function parseFilters(exp) {
  7276. let inSingle = false;
  7277. let inDouble = false;
  7278. let inTemplateString = false;
  7279. let inRegex = false;
  7280. let curly = 0;
  7281. let square = 0;
  7282. let paren = 0;
  7283. let lastFilterIndex = 0;
  7284. let c, prev, i, expression, filters;
  7285. for (i = 0; i < exp.length; i++) {
  7286. prev = c;
  7287. c = exp.charCodeAt(i);
  7288. if (inSingle) {
  7289. if (c === 0x27 && prev !== 0x5c)
  7290. inSingle = false;
  7291. }
  7292. else if (inDouble) {
  7293. if (c === 0x22 && prev !== 0x5c)
  7294. inDouble = false;
  7295. }
  7296. else if (inTemplateString) {
  7297. if (c === 0x60 && prev !== 0x5c)
  7298. inTemplateString = false;
  7299. }
  7300. else if (inRegex) {
  7301. if (c === 0x2f && prev !== 0x5c)
  7302. inRegex = false;
  7303. }
  7304. else if (c === 0x7c && // pipe
  7305. exp.charCodeAt(i + 1) !== 0x7c &&
  7306. exp.charCodeAt(i - 1) !== 0x7c &&
  7307. !curly &&
  7308. !square &&
  7309. !paren) {
  7310. if (expression === undefined) {
  7311. // first filter, end of expression
  7312. lastFilterIndex = i + 1;
  7313. expression = exp.slice(0, i).trim();
  7314. }
  7315. else {
  7316. pushFilter();
  7317. }
  7318. }
  7319. else {
  7320. switch (c) {
  7321. case 0x22:
  7322. inDouble = true;
  7323. break; // "
  7324. case 0x27:
  7325. inSingle = true;
  7326. break; // '
  7327. case 0x60:
  7328. inTemplateString = true;
  7329. break; // `
  7330. case 0x28:
  7331. paren++;
  7332. break; // (
  7333. case 0x29:
  7334. paren--;
  7335. break; // )
  7336. case 0x5b:
  7337. square++;
  7338. break; // [
  7339. case 0x5d:
  7340. square--;
  7341. break; // ]
  7342. case 0x7b:
  7343. curly++;
  7344. break; // {
  7345. case 0x7d:
  7346. curly--;
  7347. break; // }
  7348. }
  7349. if (c === 0x2f) {
  7350. // /
  7351. let j = i - 1;
  7352. let p;
  7353. // find first non-whitespace prev char
  7354. for (; j >= 0; j--) {
  7355. p = exp.charAt(j);
  7356. if (p !== ' ')
  7357. break;
  7358. }
  7359. if (!p || !validDivisionCharRE.test(p)) {
  7360. inRegex = true;
  7361. }
  7362. }
  7363. }
  7364. }
  7365. if (expression === undefined) {
  7366. expression = exp.slice(0, i).trim();
  7367. }
  7368. else if (lastFilterIndex !== 0) {
  7369. pushFilter();
  7370. }
  7371. function pushFilter() {
  7372. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7373. lastFilterIndex = i + 1;
  7374. }
  7375. if (filters) {
  7376. for (i = 0; i < filters.length; i++) {
  7377. expression = wrapFilter(expression, filters[i]);
  7378. }
  7379. }
  7380. return expression;
  7381. }
  7382. function wrapFilter(exp, filter) {
  7383. const i = filter.indexOf('(');
  7384. if (i < 0) {
  7385. // _f: resolveFilter
  7386. return `_f("${filter}")(${exp})`;
  7387. }
  7388. else {
  7389. const name = filter.slice(0, i);
  7390. const args = filter.slice(i + 1);
  7391. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7392. }
  7393. }
  7394. /* eslint-disable no-unused-vars */
  7395. function baseWarn(msg, range) {
  7396. console.error(`[Vue compiler]: ${msg}`);
  7397. }
  7398. /* eslint-enable no-unused-vars */
  7399. function pluckModuleFunction(modules, key) {
  7400. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7401. }
  7402. function addProp(el, name, value, range, dynamic) {
  7403. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7404. el.plain = false;
  7405. }
  7406. function addAttr(el, name, value, range, dynamic) {
  7407. const attrs = dynamic
  7408. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7409. : el.attrs || (el.attrs = []);
  7410. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7411. el.plain = false;
  7412. }
  7413. // add a raw attr (use this in preTransforms)
  7414. function addRawAttr(el, name, value, range) {
  7415. el.attrsMap[name] = value;
  7416. el.attrsList.push(rangeSetItem({ name, value }, range));
  7417. }
  7418. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7419. (el.directives || (el.directives = [])).push(rangeSetItem({
  7420. name,
  7421. rawName,
  7422. value,
  7423. arg,
  7424. isDynamicArg,
  7425. modifiers
  7426. }, range));
  7427. el.plain = false;
  7428. }
  7429. function prependModifierMarker(symbol, name, dynamic) {
  7430. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7431. }
  7432. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7433. modifiers = modifiers || emptyObject;
  7434. // warn prevent and passive modifier
  7435. /* istanbul ignore if */
  7436. if (warn && modifiers.prevent && modifiers.passive) {
  7437. warn("passive and prevent can't be used together. " +
  7438. "Passive handler can't prevent default event.", range);
  7439. }
  7440. // normalize click.right and click.middle since they don't actually fire
  7441. // this is technically browser-specific, but at least for now browsers are
  7442. // the only target envs that have right/middle clicks.
  7443. if (modifiers.right) {
  7444. if (dynamic) {
  7445. name = `(${name})==='click'?'contextmenu':(${name})`;
  7446. }
  7447. else if (name === 'click') {
  7448. name = 'contextmenu';
  7449. delete modifiers.right;
  7450. }
  7451. }
  7452. else if (modifiers.middle) {
  7453. if (dynamic) {
  7454. name = `(${name})==='click'?'mouseup':(${name})`;
  7455. }
  7456. else if (name === 'click') {
  7457. name = 'mouseup';
  7458. }
  7459. }
  7460. // check capture modifier
  7461. if (modifiers.capture) {
  7462. delete modifiers.capture;
  7463. name = prependModifierMarker('!', name, dynamic);
  7464. }
  7465. if (modifiers.once) {
  7466. delete modifiers.once;
  7467. name = prependModifierMarker('~', name, dynamic);
  7468. }
  7469. /* istanbul ignore if */
  7470. if (modifiers.passive) {
  7471. delete modifiers.passive;
  7472. name = prependModifierMarker('&', name, dynamic);
  7473. }
  7474. let events;
  7475. if (modifiers.native) {
  7476. delete modifiers.native;
  7477. events = el.nativeEvents || (el.nativeEvents = {});
  7478. }
  7479. else {
  7480. events = el.events || (el.events = {});
  7481. }
  7482. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7483. if (modifiers !== emptyObject) {
  7484. newHandler.modifiers = modifiers;
  7485. }
  7486. const handlers = events[name];
  7487. /* istanbul ignore if */
  7488. if (Array.isArray(handlers)) {
  7489. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7490. }
  7491. else if (handlers) {
  7492. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7493. }
  7494. else {
  7495. events[name] = newHandler;
  7496. }
  7497. el.plain = false;
  7498. }
  7499. function getRawBindingAttr(el, name) {
  7500. return (el.rawAttrsMap[':' + name] ||
  7501. el.rawAttrsMap['v-bind:' + name] ||
  7502. el.rawAttrsMap[name]);
  7503. }
  7504. function getBindingAttr(el, name, getStatic) {
  7505. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7506. if (dynamicValue != null) {
  7507. return parseFilters(dynamicValue);
  7508. }
  7509. else if (getStatic !== false) {
  7510. const staticValue = getAndRemoveAttr(el, name);
  7511. if (staticValue != null) {
  7512. return JSON.stringify(staticValue);
  7513. }
  7514. }
  7515. }
  7516. // note: this only removes the attr from the Array (attrsList) so that it
  7517. // doesn't get processed by processAttrs.
  7518. // By default it does NOT remove it from the map (attrsMap) because the map is
  7519. // needed during codegen.
  7520. function getAndRemoveAttr(el, name, removeFromMap) {
  7521. let val;
  7522. if ((val = el.attrsMap[name]) != null) {
  7523. const list = el.attrsList;
  7524. for (let i = 0, l = list.length; i < l; i++) {
  7525. if (list[i].name === name) {
  7526. list.splice(i, 1);
  7527. break;
  7528. }
  7529. }
  7530. }
  7531. if (removeFromMap) {
  7532. delete el.attrsMap[name];
  7533. }
  7534. return val;
  7535. }
  7536. function getAndRemoveAttrByRegex(el, name) {
  7537. const list = el.attrsList;
  7538. for (let i = 0, l = list.length; i < l; i++) {
  7539. const attr = list[i];
  7540. if (name.test(attr.name)) {
  7541. list.splice(i, 1);
  7542. return attr;
  7543. }
  7544. }
  7545. }
  7546. function rangeSetItem(item, range) {
  7547. if (range) {
  7548. if (range.start != null) {
  7549. item.start = range.start;
  7550. }
  7551. if (range.end != null) {
  7552. item.end = range.end;
  7553. }
  7554. }
  7555. return item;
  7556. }
  7557. /**
  7558. * Cross-platform code generation for component v-model
  7559. */
  7560. function genComponentModel(el, value, modifiers) {
  7561. const { number, trim } = modifiers || {};
  7562. const baseValueExpression = '$$v';
  7563. let valueExpression = baseValueExpression;
  7564. if (trim) {
  7565. valueExpression =
  7566. `(typeof ${baseValueExpression} === 'string'` +
  7567. `? ${baseValueExpression}.trim()` +
  7568. `: ${baseValueExpression})`;
  7569. }
  7570. if (number) {
  7571. valueExpression = `_n(${valueExpression})`;
  7572. }
  7573. const assignment = genAssignmentCode(value, valueExpression);
  7574. el.model = {
  7575. value: `(${value})`,
  7576. expression: JSON.stringify(value),
  7577. callback: `function (${baseValueExpression}) {${assignment}}`
  7578. };
  7579. }
  7580. /**
  7581. * Cross-platform codegen helper for generating v-model value assignment code.
  7582. */
  7583. function genAssignmentCode(value, assignment) {
  7584. const res = parseModel(value);
  7585. if (res.key === null) {
  7586. return `${value}=${assignment}`;
  7587. }
  7588. else {
  7589. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7590. }
  7591. }
  7592. /**
  7593. * Parse a v-model expression into a base path and a final key segment.
  7594. * Handles both dot-path and possible square brackets.
  7595. *
  7596. * Possible cases:
  7597. *
  7598. * - test
  7599. * - test[key]
  7600. * - test[test1[key]]
  7601. * - test["a"][key]
  7602. * - xxx.test[a[a].test1[key]]
  7603. * - test.xxx.a["asa"][test1[key]]
  7604. *
  7605. */
  7606. let len, str, chr, index, expressionPos, expressionEndPos;
  7607. function parseModel(val) {
  7608. // Fix https://github.com/vuejs/vue/pull/7730
  7609. // allow v-model="obj.val " (trailing whitespace)
  7610. val = val.trim();
  7611. len = val.length;
  7612. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7613. index = val.lastIndexOf('.');
  7614. if (index > -1) {
  7615. return {
  7616. exp: val.slice(0, index),
  7617. key: '"' + val.slice(index + 1) + '"'
  7618. };
  7619. }
  7620. else {
  7621. return {
  7622. exp: val,
  7623. key: null
  7624. };
  7625. }
  7626. }
  7627. str = val;
  7628. index = expressionPos = expressionEndPos = 0;
  7629. while (!eof()) {
  7630. chr = next();
  7631. /* istanbul ignore if */
  7632. if (isStringStart(chr)) {
  7633. parseString(chr);
  7634. }
  7635. else if (chr === 0x5b) {
  7636. parseBracket(chr);
  7637. }
  7638. }
  7639. return {
  7640. exp: val.slice(0, expressionPos),
  7641. key: val.slice(expressionPos + 1, expressionEndPos)
  7642. };
  7643. }
  7644. function next() {
  7645. return str.charCodeAt(++index);
  7646. }
  7647. function eof() {
  7648. return index >= len;
  7649. }
  7650. function isStringStart(chr) {
  7651. return chr === 0x22 || chr === 0x27;
  7652. }
  7653. function parseBracket(chr) {
  7654. let inBracket = 1;
  7655. expressionPos = index;
  7656. while (!eof()) {
  7657. chr = next();
  7658. if (isStringStart(chr)) {
  7659. parseString(chr);
  7660. continue;
  7661. }
  7662. if (chr === 0x5b)
  7663. inBracket++;
  7664. if (chr === 0x5d)
  7665. inBracket--;
  7666. if (inBracket === 0) {
  7667. expressionEndPos = index;
  7668. break;
  7669. }
  7670. }
  7671. }
  7672. function parseString(chr) {
  7673. const stringQuote = chr;
  7674. while (!eof()) {
  7675. chr = next();
  7676. if (chr === stringQuote) {
  7677. break;
  7678. }
  7679. }
  7680. }
  7681. let warn$1;
  7682. // in some cases, the event used has to be determined at runtime
  7683. // so we used some reserved tokens during compile.
  7684. const RANGE_TOKEN = '__r';
  7685. const CHECKBOX_RADIO_TOKEN = '__c';
  7686. function model$1(el, dir, _warn) {
  7687. warn$1 = _warn;
  7688. const value = dir.value;
  7689. const modifiers = dir.modifiers;
  7690. const tag = el.tag;
  7691. const type = el.attrsMap.type;
  7692. {
  7693. // inputs with type="file" are read only and setting the input's
  7694. // value will throw an error.
  7695. if (tag === 'input' && type === 'file') {
  7696. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7697. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7698. }
  7699. }
  7700. if (el.component) {
  7701. genComponentModel(el, value, modifiers);
  7702. // component v-model doesn't need extra runtime
  7703. return false;
  7704. }
  7705. else if (tag === 'select') {
  7706. genSelect(el, value, modifiers);
  7707. }
  7708. else if (tag === 'input' && type === 'checkbox') {
  7709. genCheckboxModel(el, value, modifiers);
  7710. }
  7711. else if (tag === 'input' && type === 'radio') {
  7712. genRadioModel(el, value, modifiers);
  7713. }
  7714. else if (tag === 'input' || tag === 'textarea') {
  7715. genDefaultModel(el, value, modifiers);
  7716. }
  7717. else if (!config.isReservedTag(tag)) {
  7718. genComponentModel(el, value, modifiers);
  7719. // component v-model doesn't need extra runtime
  7720. return false;
  7721. }
  7722. else {
  7723. warn$1(`<${el.tag} v-model="${value}">: ` +
  7724. `v-model is not supported on this element type. ` +
  7725. "If you are working with contenteditable, it's recommended to " +
  7726. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7727. }
  7728. // ensure runtime directive metadata
  7729. return true;
  7730. }
  7731. function genCheckboxModel(el, value, modifiers) {
  7732. const number = modifiers && modifiers.number;
  7733. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7734. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7735. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7736. addProp(el, 'checked', `Array.isArray(${value})` +
  7737. `?_i(${value},${valueBinding})>-1` +
  7738. (trueValueBinding === 'true'
  7739. ? `:(${value})`
  7740. : `:_q(${value},${trueValueBinding})`));
  7741. addHandler(el, 'change', `var $$a=${value},` +
  7742. '$$el=$event.target,' +
  7743. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7744. 'if(Array.isArray($$a)){' +
  7745. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7746. '$$i=_i($$a,$$v);' +
  7747. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7748. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7749. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7750. }
  7751. function genRadioModel(el, value, modifiers) {
  7752. const number = modifiers && modifiers.number;
  7753. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7754. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7755. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7756. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7757. }
  7758. function genSelect(el, value, modifiers) {
  7759. const number = modifiers && modifiers.number;
  7760. const selectedVal = `Array.prototype.filter` +
  7761. `.call($event.target.options,function(o){return o.selected})` +
  7762. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7763. `return ${number ? '_n(val)' : 'val'}})`;
  7764. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7765. let code = `var $$selectedVal = ${selectedVal};`;
  7766. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7767. addHandler(el, 'change', code, null, true);
  7768. }
  7769. function genDefaultModel(el, value, modifiers) {
  7770. const type = el.attrsMap.type;
  7771. // warn if v-bind:value conflicts with v-model
  7772. // except for inputs with v-bind:type
  7773. {
  7774. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7775. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7776. if (value && !typeBinding) {
  7777. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7778. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7779. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7780. }
  7781. }
  7782. const { lazy, number, trim } = modifiers || {};
  7783. const needCompositionGuard = !lazy && type !== 'range';
  7784. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7785. let valueExpression = '$event.target.value';
  7786. if (trim) {
  7787. valueExpression = `$event.target.value.trim()`;
  7788. }
  7789. if (number) {
  7790. valueExpression = `_n(${valueExpression})`;
  7791. }
  7792. let code = genAssignmentCode(value, valueExpression);
  7793. if (needCompositionGuard) {
  7794. code = `if($event.target.composing)return;${code}`;
  7795. }
  7796. addProp(el, 'value', `(${value})`);
  7797. addHandler(el, event, code, null, true);
  7798. if (trim || number) {
  7799. addHandler(el, 'blur', '$forceUpdate()');
  7800. }
  7801. }
  7802. // normalize v-model event tokens that can only be determined at runtime.
  7803. // it's important to place the event as the first in the array because
  7804. // the whole point is ensuring the v-model callback gets called before
  7805. // user-attached handlers.
  7806. function normalizeEvents(on) {
  7807. /* istanbul ignore if */
  7808. if (isDef(on[RANGE_TOKEN])) {
  7809. // IE input[type=range] only supports `change` event
  7810. const event = isIE ? 'change' : 'input';
  7811. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7812. delete on[RANGE_TOKEN];
  7813. }
  7814. // This was originally intended to fix #4521 but no longer necessary
  7815. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7816. /* istanbul ignore if */
  7817. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7818. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7819. delete on[CHECKBOX_RADIO_TOKEN];
  7820. }
  7821. }
  7822. let target;
  7823. function createOnceHandler(event, handler, capture) {
  7824. const _target = target; // save current target element in closure
  7825. return function onceHandler() {
  7826. const res = handler.apply(null, arguments);
  7827. if (res !== null) {
  7828. remove(event, onceHandler, capture, _target);
  7829. }
  7830. };
  7831. }
  7832. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7833. // implementation and does not fire microtasks in between event propagation, so
  7834. // safe to exclude.
  7835. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7836. function add(name, handler, capture, passive) {
  7837. // async edge case #6566: inner click event triggers patch, event handler
  7838. // attached to outer element during patch, and triggered again. This
  7839. // happens because browsers fire microtask ticks between event propagation.
  7840. // the solution is simple: we save the timestamp when a handler is attached,
  7841. // and the handler would only fire if the event passed to it was fired
  7842. // AFTER it was attached.
  7843. if (useMicrotaskFix) {
  7844. const attachedTimestamp = currentFlushTimestamp;
  7845. const original = handler;
  7846. //@ts-expect-error
  7847. handler = original._wrapper = function (e) {
  7848. if (
  7849. // no bubbling, should always fire.
  7850. // this is just a safety net in case event.timeStamp is unreliable in
  7851. // certain weird environments...
  7852. e.target === e.currentTarget ||
  7853. // event is fired after handler attachment
  7854. e.timeStamp >= attachedTimestamp ||
  7855. // bail for environments that have buggy event.timeStamp implementations
  7856. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7857. // #9681 QtWebEngine event.timeStamp is negative value
  7858. e.timeStamp <= 0 ||
  7859. // #9448 bail if event is fired in another document in a multi-page
  7860. // electron/nw.js app, since event.timeStamp will be using a different
  7861. // starting reference
  7862. e.target.ownerDocument !== document) {
  7863. return original.apply(this, arguments);
  7864. }
  7865. };
  7866. }
  7867. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7868. }
  7869. function remove(name, handler, capture, _target) {
  7870. (_target || target).removeEventListener(name,
  7871. //@ts-expect-error
  7872. handler._wrapper || handler, capture);
  7873. }
  7874. function updateDOMListeners(oldVnode, vnode) {
  7875. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7876. return;
  7877. }
  7878. const on = vnode.data.on || {};
  7879. const oldOn = oldVnode.data.on || {};
  7880. // vnode is empty when removing all listeners,
  7881. // and use old vnode dom element
  7882. target = vnode.elm || oldVnode.elm;
  7883. normalizeEvents(on);
  7884. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7885. target = undefined;
  7886. }
  7887. var events = {
  7888. create: updateDOMListeners,
  7889. update: updateDOMListeners,
  7890. // @ts-expect-error emptyNode has actually data
  7891. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7892. };
  7893. let svgContainer;
  7894. function updateDOMProps(oldVnode, vnode) {
  7895. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7896. return;
  7897. }
  7898. let key, cur;
  7899. const elm = vnode.elm;
  7900. const oldProps = oldVnode.data.domProps || {};
  7901. let props = vnode.data.domProps || {};
  7902. // clone observed objects, as the user probably wants to mutate it
  7903. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7904. props = vnode.data.domProps = extend({}, props);
  7905. }
  7906. for (key in oldProps) {
  7907. if (!(key in props)) {
  7908. elm[key] = '';
  7909. }
  7910. }
  7911. for (key in props) {
  7912. cur = props[key];
  7913. // ignore children if the node has textContent or innerHTML,
  7914. // as these will throw away existing DOM nodes and cause removal errors
  7915. // on subsequent patches (#3360)
  7916. if (key === 'textContent' || key === 'innerHTML') {
  7917. if (vnode.children)
  7918. vnode.children.length = 0;
  7919. if (cur === oldProps[key])
  7920. continue;
  7921. // #6601 work around Chrome version <= 55 bug where single textNode
  7922. // replaced by innerHTML/textContent retains its parentNode property
  7923. if (elm.childNodes.length === 1) {
  7924. elm.removeChild(elm.childNodes[0]);
  7925. }
  7926. }
  7927. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7928. // store value as _value as well since
  7929. // non-string values will be stringified
  7930. elm._value = cur;
  7931. // avoid resetting cursor position when value is the same
  7932. const strCur = isUndef(cur) ? '' : String(cur);
  7933. if (shouldUpdateValue(elm, strCur)) {
  7934. elm.value = strCur;
  7935. }
  7936. }
  7937. else if (key === 'innerHTML' &&
  7938. isSVG(elm.tagName) &&
  7939. isUndef(elm.innerHTML)) {
  7940. // IE doesn't support innerHTML for SVG elements
  7941. svgContainer = svgContainer || document.createElement('div');
  7942. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7943. const svg = svgContainer.firstChild;
  7944. while (elm.firstChild) {
  7945. elm.removeChild(elm.firstChild);
  7946. }
  7947. while (svg.firstChild) {
  7948. elm.appendChild(svg.firstChild);
  7949. }
  7950. }
  7951. else if (
  7952. // skip the update if old and new VDOM state is the same.
  7953. // `value` is handled separately because the DOM value may be temporarily
  7954. // out of sync with VDOM state due to focus, composition and modifiers.
  7955. // This #4521 by skipping the unnecessary `checked` update.
  7956. cur !== oldProps[key]) {
  7957. // some property updates can throw
  7958. // e.g. `value` on <progress> w/ non-finite value
  7959. try {
  7960. elm[key] = cur;
  7961. }
  7962. catch (e) { }
  7963. }
  7964. }
  7965. }
  7966. function shouldUpdateValue(elm, checkVal) {
  7967. return (
  7968. //@ts-expect-error
  7969. !elm.composing &&
  7970. (elm.tagName === 'OPTION' ||
  7971. isNotInFocusAndDirty(elm, checkVal) ||
  7972. isDirtyWithModifiers(elm, checkVal)));
  7973. }
  7974. function isNotInFocusAndDirty(elm, checkVal) {
  7975. // return true when textbox (.number and .trim) loses focus and its value is
  7976. // not equal to the updated value
  7977. let notInFocus = true;
  7978. // #6157
  7979. // work around IE bug when accessing document.activeElement in an iframe
  7980. try {
  7981. notInFocus = document.activeElement !== elm;
  7982. }
  7983. catch (e) { }
  7984. return notInFocus && elm.value !== checkVal;
  7985. }
  7986. function isDirtyWithModifiers(elm, newVal) {
  7987. const value = elm.value;
  7988. const modifiers = elm._vModifiers; // injected by v-model runtime
  7989. if (isDef(modifiers)) {
  7990. if (modifiers.number) {
  7991. return toNumber(value) !== toNumber(newVal);
  7992. }
  7993. if (modifiers.trim) {
  7994. return value.trim() !== newVal.trim();
  7995. }
  7996. }
  7997. return value !== newVal;
  7998. }
  7999. var domProps = {
  8000. create: updateDOMProps,
  8001. update: updateDOMProps
  8002. };
  8003. const parseStyleText = cached(function (cssText) {
  8004. const res = {};
  8005. const listDelimiter = /;(?![^(]*\))/g;
  8006. const propertyDelimiter = /:(.+)/;
  8007. cssText.split(listDelimiter).forEach(function (item) {
  8008. if (item) {
  8009. const tmp = item.split(propertyDelimiter);
  8010. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  8011. }
  8012. });
  8013. return res;
  8014. });
  8015. // merge static and dynamic style data on the same vnode
  8016. function normalizeStyleData(data) {
  8017. const style = normalizeStyleBinding(data.style);
  8018. // static style is pre-processed into an object during compilation
  8019. // and is always a fresh object, so it's safe to merge into it
  8020. return data.staticStyle ? extend(data.staticStyle, style) : style;
  8021. }
  8022. // normalize possible array / string values into Object
  8023. function normalizeStyleBinding(bindingStyle) {
  8024. if (Array.isArray(bindingStyle)) {
  8025. return toObject(bindingStyle);
  8026. }
  8027. if (typeof bindingStyle === 'string') {
  8028. return parseStyleText(bindingStyle);
  8029. }
  8030. return bindingStyle;
  8031. }
  8032. /**
  8033. * parent component style should be after child's
  8034. * so that parent component's style could override it
  8035. */
  8036. function getStyle(vnode, checkChild) {
  8037. const res = {};
  8038. let styleData;
  8039. if (checkChild) {
  8040. let childNode = vnode;
  8041. while (childNode.componentInstance) {
  8042. childNode = childNode.componentInstance._vnode;
  8043. if (childNode &&
  8044. childNode.data &&
  8045. (styleData = normalizeStyleData(childNode.data))) {
  8046. extend(res, styleData);
  8047. }
  8048. }
  8049. }
  8050. if ((styleData = normalizeStyleData(vnode.data))) {
  8051. extend(res, styleData);
  8052. }
  8053. let parentNode = vnode;
  8054. // @ts-expect-error parentNode.parent not VNodeWithData
  8055. while ((parentNode = parentNode.parent)) {
  8056. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  8057. extend(res, styleData);
  8058. }
  8059. }
  8060. return res;
  8061. }
  8062. const cssVarRE = /^--/;
  8063. const importantRE = /\s*!important$/;
  8064. const setProp = (el, name, val) => {
  8065. /* istanbul ignore if */
  8066. if (cssVarRE.test(name)) {
  8067. el.style.setProperty(name, val);
  8068. }
  8069. else if (importantRE.test(val)) {
  8070. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8071. }
  8072. else {
  8073. const normalizedName = normalize(name);
  8074. if (Array.isArray(val)) {
  8075. // Support values array created by autoprefixer, e.g.
  8076. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8077. // Set them one by one, and the browser will only set those it can recognize
  8078. for (let i = 0, len = val.length; i < len; i++) {
  8079. el.style[normalizedName] = val[i];
  8080. }
  8081. }
  8082. else {
  8083. el.style[normalizedName] = val;
  8084. }
  8085. }
  8086. };
  8087. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8088. let emptyStyle;
  8089. const normalize = cached(function (prop) {
  8090. emptyStyle = emptyStyle || document.createElement('div').style;
  8091. prop = camelize(prop);
  8092. if (prop !== 'filter' && prop in emptyStyle) {
  8093. return prop;
  8094. }
  8095. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8096. for (let i = 0; i < vendorNames.length; i++) {
  8097. const name = vendorNames[i] + capName;
  8098. if (name in emptyStyle) {
  8099. return name;
  8100. }
  8101. }
  8102. });
  8103. function updateStyle(oldVnode, vnode) {
  8104. const data = vnode.data;
  8105. const oldData = oldVnode.data;
  8106. if (isUndef(data.staticStyle) &&
  8107. isUndef(data.style) &&
  8108. isUndef(oldData.staticStyle) &&
  8109. isUndef(oldData.style)) {
  8110. return;
  8111. }
  8112. let cur, name;
  8113. const el = vnode.elm;
  8114. const oldStaticStyle = oldData.staticStyle;
  8115. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8116. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8117. const oldStyle = oldStaticStyle || oldStyleBinding;
  8118. const style = normalizeStyleBinding(vnode.data.style) || {};
  8119. // store normalized style under a different key for next diff
  8120. // make sure to clone it if it's reactive, since the user likely wants
  8121. // to mutate it.
  8122. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8123. const newStyle = getStyle(vnode, true);
  8124. for (name in oldStyle) {
  8125. if (isUndef(newStyle[name])) {
  8126. setProp(el, name, '');
  8127. }
  8128. }
  8129. for (name in newStyle) {
  8130. cur = newStyle[name];
  8131. // ie9 setting to null has no effect, must use empty string
  8132. setProp(el, name, cur == null ? '' : cur);
  8133. }
  8134. }
  8135. var style$1 = {
  8136. create: updateStyle,
  8137. update: updateStyle
  8138. };
  8139. const whitespaceRE$1 = /\s+/;
  8140. /**
  8141. * Add class with compatibility for SVG since classList is not supported on
  8142. * SVG elements in IE
  8143. */
  8144. function addClass(el, cls) {
  8145. /* istanbul ignore if */
  8146. if (!cls || !(cls = cls.trim())) {
  8147. return;
  8148. }
  8149. /* istanbul ignore else */
  8150. if (el.classList) {
  8151. if (cls.indexOf(' ') > -1) {
  8152. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8153. }
  8154. else {
  8155. el.classList.add(cls);
  8156. }
  8157. }
  8158. else {
  8159. const cur = ` ${el.getAttribute('class') || ''} `;
  8160. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8161. el.setAttribute('class', (cur + cls).trim());
  8162. }
  8163. }
  8164. }
  8165. /**
  8166. * Remove class with compatibility for SVG since classList is not supported on
  8167. * SVG elements in IE
  8168. */
  8169. function removeClass(el, cls) {
  8170. /* istanbul ignore if */
  8171. if (!cls || !(cls = cls.trim())) {
  8172. return;
  8173. }
  8174. /* istanbul ignore else */
  8175. if (el.classList) {
  8176. if (cls.indexOf(' ') > -1) {
  8177. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8178. }
  8179. else {
  8180. el.classList.remove(cls);
  8181. }
  8182. if (!el.classList.length) {
  8183. el.removeAttribute('class');
  8184. }
  8185. }
  8186. else {
  8187. let cur = ` ${el.getAttribute('class') || ''} `;
  8188. const tar = ' ' + cls + ' ';
  8189. while (cur.indexOf(tar) >= 0) {
  8190. cur = cur.replace(tar, ' ');
  8191. }
  8192. cur = cur.trim();
  8193. if (cur) {
  8194. el.setAttribute('class', cur);
  8195. }
  8196. else {
  8197. el.removeAttribute('class');
  8198. }
  8199. }
  8200. }
  8201. function resolveTransition(def) {
  8202. if (!def) {
  8203. return;
  8204. }
  8205. /* istanbul ignore else */
  8206. if (typeof def === 'object') {
  8207. const res = {};
  8208. if (def.css !== false) {
  8209. extend(res, autoCssTransition(def.name || 'v'));
  8210. }
  8211. extend(res, def);
  8212. return res;
  8213. }
  8214. else if (typeof def === 'string') {
  8215. return autoCssTransition(def);
  8216. }
  8217. }
  8218. const autoCssTransition = cached(name => {
  8219. return {
  8220. enterClass: `${name}-enter`,
  8221. enterToClass: `${name}-enter-to`,
  8222. enterActiveClass: `${name}-enter-active`,
  8223. leaveClass: `${name}-leave`,
  8224. leaveToClass: `${name}-leave-to`,
  8225. leaveActiveClass: `${name}-leave-active`
  8226. };
  8227. });
  8228. const hasTransition = inBrowser && !isIE9;
  8229. const TRANSITION = 'transition';
  8230. const ANIMATION = 'animation';
  8231. // Transition property/event sniffing
  8232. let transitionProp = 'transition';
  8233. let transitionEndEvent = 'transitionend';
  8234. let animationProp = 'animation';
  8235. let animationEndEvent = 'animationend';
  8236. if (hasTransition) {
  8237. /* istanbul ignore if */
  8238. if (window.ontransitionend === undefined &&
  8239. window.onwebkittransitionend !== undefined) {
  8240. transitionProp = 'WebkitTransition';
  8241. transitionEndEvent = 'webkitTransitionEnd';
  8242. }
  8243. if (window.onanimationend === undefined &&
  8244. window.onwebkitanimationend !== undefined) {
  8245. animationProp = 'WebkitAnimation';
  8246. animationEndEvent = 'webkitAnimationEnd';
  8247. }
  8248. }
  8249. // binding to window is necessary to make hot reload work in IE in strict mode
  8250. const raf = inBrowser
  8251. ? window.requestAnimationFrame
  8252. ? window.requestAnimationFrame.bind(window)
  8253. : setTimeout
  8254. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8255. function nextFrame(fn) {
  8256. raf(() => {
  8257. // @ts-expect-error
  8258. raf(fn);
  8259. });
  8260. }
  8261. function addTransitionClass(el, cls) {
  8262. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8263. if (transitionClasses.indexOf(cls) < 0) {
  8264. transitionClasses.push(cls);
  8265. addClass(el, cls);
  8266. }
  8267. }
  8268. function removeTransitionClass(el, cls) {
  8269. if (el._transitionClasses) {
  8270. remove$2(el._transitionClasses, cls);
  8271. }
  8272. removeClass(el, cls);
  8273. }
  8274. function whenTransitionEnds(el, expectedType, cb) {
  8275. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8276. if (!type)
  8277. return cb();
  8278. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8279. let ended = 0;
  8280. const end = () => {
  8281. el.removeEventListener(event, onEnd);
  8282. cb();
  8283. };
  8284. const onEnd = e => {
  8285. if (e.target === el) {
  8286. if (++ended >= propCount) {
  8287. end();
  8288. }
  8289. }
  8290. };
  8291. setTimeout(() => {
  8292. if (ended < propCount) {
  8293. end();
  8294. }
  8295. }, timeout + 1);
  8296. el.addEventListener(event, onEnd);
  8297. }
  8298. const transformRE = /\b(transform|all)(,|$)/;
  8299. function getTransitionInfo(el, expectedType) {
  8300. const styles = window.getComputedStyle(el);
  8301. // JSDOM may return undefined for transition properties
  8302. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8303. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8304. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8305. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8306. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8307. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8308. let type;
  8309. let timeout = 0;
  8310. let propCount = 0;
  8311. /* istanbul ignore if */
  8312. if (expectedType === TRANSITION) {
  8313. if (transitionTimeout > 0) {
  8314. type = TRANSITION;
  8315. timeout = transitionTimeout;
  8316. propCount = transitionDurations.length;
  8317. }
  8318. }
  8319. else if (expectedType === ANIMATION) {
  8320. if (animationTimeout > 0) {
  8321. type = ANIMATION;
  8322. timeout = animationTimeout;
  8323. propCount = animationDurations.length;
  8324. }
  8325. }
  8326. else {
  8327. timeout = Math.max(transitionTimeout, animationTimeout);
  8328. type =
  8329. timeout > 0
  8330. ? transitionTimeout > animationTimeout
  8331. ? TRANSITION
  8332. : ANIMATION
  8333. : null;
  8334. propCount = type
  8335. ? type === TRANSITION
  8336. ? transitionDurations.length
  8337. : animationDurations.length
  8338. : 0;
  8339. }
  8340. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8341. return {
  8342. type,
  8343. timeout,
  8344. propCount,
  8345. hasTransform
  8346. };
  8347. }
  8348. function getTimeout(delays, durations) {
  8349. /* istanbul ignore next */
  8350. while (delays.length < durations.length) {
  8351. delays = delays.concat(delays);
  8352. }
  8353. return Math.max.apply(null, durations.map((d, i) => {
  8354. return toMs(d) + toMs(delays[i]);
  8355. }));
  8356. }
  8357. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8358. // in a locale-dependent way, using a comma instead of a dot.
  8359. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8360. // as a floor function) causing unexpected behaviors
  8361. function toMs(s) {
  8362. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8363. }
  8364. function enter(vnode, toggleDisplay) {
  8365. const el = vnode.elm;
  8366. // call leave callback now
  8367. if (isDef(el._leaveCb)) {
  8368. el._leaveCb.cancelled = true;
  8369. el._leaveCb();
  8370. }
  8371. const data = resolveTransition(vnode.data.transition);
  8372. if (isUndef(data)) {
  8373. return;
  8374. }
  8375. /* istanbul ignore if */
  8376. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8377. return;
  8378. }
  8379. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8380. // activeInstance will always be the <transition> component managing this
  8381. // transition. One edge case to check is when the <transition> is placed
  8382. // as the root node of a child component. In that case we need to check
  8383. // <transition>'s parent for appear check.
  8384. let context = activeInstance;
  8385. let transitionNode = activeInstance.$vnode;
  8386. while (transitionNode && transitionNode.parent) {
  8387. context = transitionNode.context;
  8388. transitionNode = transitionNode.parent;
  8389. }
  8390. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8391. if (isAppear && !appear && appear !== '') {
  8392. return;
  8393. }
  8394. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8395. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8396. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8397. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8398. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8399. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8400. const enterCancelledHook = isAppear
  8401. ? appearCancelled || enterCancelled
  8402. : enterCancelled;
  8403. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8404. if (explicitEnterDuration != null) {
  8405. checkDuration(explicitEnterDuration, 'enter', vnode);
  8406. }
  8407. const expectsCSS = css !== false && !isIE9;
  8408. const userWantsControl = getHookArgumentsLength(enterHook);
  8409. const cb = (el._enterCb = once(() => {
  8410. if (expectsCSS) {
  8411. removeTransitionClass(el, toClass);
  8412. removeTransitionClass(el, activeClass);
  8413. }
  8414. // @ts-expect-error
  8415. if (cb.cancelled) {
  8416. if (expectsCSS) {
  8417. removeTransitionClass(el, startClass);
  8418. }
  8419. enterCancelledHook && enterCancelledHook(el);
  8420. }
  8421. else {
  8422. afterEnterHook && afterEnterHook(el);
  8423. }
  8424. el._enterCb = null;
  8425. }));
  8426. if (!vnode.data.show) {
  8427. // remove pending leave element on enter by injecting an insert hook
  8428. mergeVNodeHook(vnode, 'insert', () => {
  8429. const parent = el.parentNode;
  8430. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8431. if (pendingNode &&
  8432. pendingNode.tag === vnode.tag &&
  8433. pendingNode.elm._leaveCb) {
  8434. pendingNode.elm._leaveCb();
  8435. }
  8436. enterHook && enterHook(el, cb);
  8437. });
  8438. }
  8439. // start enter transition
  8440. beforeEnterHook && beforeEnterHook(el);
  8441. if (expectsCSS) {
  8442. addTransitionClass(el, startClass);
  8443. addTransitionClass(el, activeClass);
  8444. nextFrame(() => {
  8445. removeTransitionClass(el, startClass);
  8446. // @ts-expect-error
  8447. if (!cb.cancelled) {
  8448. addTransitionClass(el, toClass);
  8449. if (!userWantsControl) {
  8450. if (isValidDuration(explicitEnterDuration)) {
  8451. setTimeout(cb, explicitEnterDuration);
  8452. }
  8453. else {
  8454. whenTransitionEnds(el, type, cb);
  8455. }
  8456. }
  8457. }
  8458. });
  8459. }
  8460. if (vnode.data.show) {
  8461. toggleDisplay && toggleDisplay();
  8462. enterHook && enterHook(el, cb);
  8463. }
  8464. if (!expectsCSS && !userWantsControl) {
  8465. cb();
  8466. }
  8467. }
  8468. function leave(vnode, rm) {
  8469. const el = vnode.elm;
  8470. // call enter callback now
  8471. if (isDef(el._enterCb)) {
  8472. el._enterCb.cancelled = true;
  8473. el._enterCb();
  8474. }
  8475. const data = resolveTransition(vnode.data.transition);
  8476. if (isUndef(data) || el.nodeType !== 1) {
  8477. return rm();
  8478. }
  8479. /* istanbul ignore if */
  8480. if (isDef(el._leaveCb)) {
  8481. return;
  8482. }
  8483. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8484. const expectsCSS = css !== false && !isIE9;
  8485. const userWantsControl = getHookArgumentsLength(leave);
  8486. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8487. if (isDef(explicitLeaveDuration)) {
  8488. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8489. }
  8490. const cb = (el._leaveCb = once(() => {
  8491. if (el.parentNode && el.parentNode._pending) {
  8492. el.parentNode._pending[vnode.key] = null;
  8493. }
  8494. if (expectsCSS) {
  8495. removeTransitionClass(el, leaveToClass);
  8496. removeTransitionClass(el, leaveActiveClass);
  8497. }
  8498. // @ts-expect-error
  8499. if (cb.cancelled) {
  8500. if (expectsCSS) {
  8501. removeTransitionClass(el, leaveClass);
  8502. }
  8503. leaveCancelled && leaveCancelled(el);
  8504. }
  8505. else {
  8506. rm();
  8507. afterLeave && afterLeave(el);
  8508. }
  8509. el._leaveCb = null;
  8510. }));
  8511. if (delayLeave) {
  8512. delayLeave(performLeave);
  8513. }
  8514. else {
  8515. performLeave();
  8516. }
  8517. function performLeave() {
  8518. // the delayed leave may have already been cancelled
  8519. // @ts-expect-error
  8520. if (cb.cancelled) {
  8521. return;
  8522. }
  8523. // record leaving element
  8524. if (!vnode.data.show && el.parentNode) {
  8525. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8526. vnode;
  8527. }
  8528. beforeLeave && beforeLeave(el);
  8529. if (expectsCSS) {
  8530. addTransitionClass(el, leaveClass);
  8531. addTransitionClass(el, leaveActiveClass);
  8532. nextFrame(() => {
  8533. removeTransitionClass(el, leaveClass);
  8534. // @ts-expect-error
  8535. if (!cb.cancelled) {
  8536. addTransitionClass(el, leaveToClass);
  8537. if (!userWantsControl) {
  8538. if (isValidDuration(explicitLeaveDuration)) {
  8539. setTimeout(cb, explicitLeaveDuration);
  8540. }
  8541. else {
  8542. whenTransitionEnds(el, type, cb);
  8543. }
  8544. }
  8545. }
  8546. });
  8547. }
  8548. leave && leave(el, cb);
  8549. if (!expectsCSS && !userWantsControl) {
  8550. cb();
  8551. }
  8552. }
  8553. }
  8554. // only used in dev mode
  8555. function checkDuration(val, name, vnode) {
  8556. if (typeof val !== 'number') {
  8557. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8558. `got ${JSON.stringify(val)}.`, vnode.context);
  8559. }
  8560. else if (isNaN(val)) {
  8561. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8562. 'the duration expression might be incorrect.', vnode.context);
  8563. }
  8564. }
  8565. function isValidDuration(val) {
  8566. return typeof val === 'number' && !isNaN(val);
  8567. }
  8568. /**
  8569. * Normalize a transition hook's argument length. The hook may be:
  8570. * - a merged hook (invoker) with the original in .fns
  8571. * - a wrapped component method (check ._length)
  8572. * - a plain function (.length)
  8573. */
  8574. function getHookArgumentsLength(fn) {
  8575. if (isUndef(fn)) {
  8576. return false;
  8577. }
  8578. // @ts-expect-error
  8579. const invokerFns = fn.fns;
  8580. if (isDef(invokerFns)) {
  8581. // invoker
  8582. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8583. }
  8584. else {
  8585. // @ts-expect-error
  8586. return (fn._length || fn.length) > 1;
  8587. }
  8588. }
  8589. function _enter(_, vnode) {
  8590. if (vnode.data.show !== true) {
  8591. enter(vnode);
  8592. }
  8593. }
  8594. var transition = inBrowser
  8595. ? {
  8596. create: _enter,
  8597. activate: _enter,
  8598. remove(vnode, rm) {
  8599. /* istanbul ignore else */
  8600. if (vnode.data.show !== true) {
  8601. // @ts-expect-error
  8602. leave(vnode, rm);
  8603. }
  8604. else {
  8605. rm();
  8606. }
  8607. }
  8608. }
  8609. : {};
  8610. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8611. // the directive module should be applied last, after all
  8612. // built-in modules have been applied.
  8613. const modules$1 = platformModules.concat(baseModules);
  8614. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8615. /**
  8616. * Not type checking this file because flow doesn't like attaching
  8617. * properties to Elements.
  8618. */
  8619. /* istanbul ignore if */
  8620. if (isIE9) {
  8621. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8622. document.addEventListener('selectionchange', () => {
  8623. const el = document.activeElement;
  8624. // @ts-expect-error
  8625. if (el && el.vmodel) {
  8626. trigger(el, 'input');
  8627. }
  8628. });
  8629. }
  8630. const directive = {
  8631. inserted(el, binding, vnode, oldVnode) {
  8632. if (vnode.tag === 'select') {
  8633. // #6903
  8634. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8635. mergeVNodeHook(vnode, 'postpatch', () => {
  8636. directive.componentUpdated(el, binding, vnode);
  8637. });
  8638. }
  8639. else {
  8640. setSelected(el, binding, vnode.context);
  8641. }
  8642. el._vOptions = [].map.call(el.options, getValue);
  8643. }
  8644. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8645. el._vModifiers = binding.modifiers;
  8646. if (!binding.modifiers.lazy) {
  8647. el.addEventListener('compositionstart', onCompositionStart);
  8648. el.addEventListener('compositionend', onCompositionEnd);
  8649. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8650. // switching focus before confirming composition choice
  8651. // this also fixes the issue where some browsers e.g. iOS Chrome
  8652. // fires "change" instead of "input" on autocomplete.
  8653. el.addEventListener('change', onCompositionEnd);
  8654. /* istanbul ignore if */
  8655. if (isIE9) {
  8656. el.vmodel = true;
  8657. }
  8658. }
  8659. }
  8660. },
  8661. componentUpdated(el, binding, vnode) {
  8662. if (vnode.tag === 'select') {
  8663. setSelected(el, binding, vnode.context);
  8664. // in case the options rendered by v-for have changed,
  8665. // it's possible that the value is out-of-sync with the rendered options.
  8666. // detect such cases and filter out values that no longer has a matching
  8667. // option in the DOM.
  8668. const prevOptions = el._vOptions;
  8669. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8670. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8671. // trigger change event if
  8672. // no matching option found for at least one value
  8673. const needReset = el.multiple
  8674. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8675. : binding.value !== binding.oldValue &&
  8676. hasNoMatchingOption(binding.value, curOptions);
  8677. if (needReset) {
  8678. trigger(el, 'change');
  8679. }
  8680. }
  8681. }
  8682. }
  8683. };
  8684. function setSelected(el, binding, vm) {
  8685. actuallySetSelected(el, binding, vm);
  8686. /* istanbul ignore if */
  8687. if (isIE || isEdge) {
  8688. setTimeout(() => {
  8689. actuallySetSelected(el, binding, vm);
  8690. }, 0);
  8691. }
  8692. }
  8693. function actuallySetSelected(el, binding, vm) {
  8694. const value = binding.value;
  8695. const isMultiple = el.multiple;
  8696. if (isMultiple && !Array.isArray(value)) {
  8697. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8698. `expects an Array value for its binding, but got ${Object.prototype.toString
  8699. .call(value)
  8700. .slice(8, -1)}`, vm);
  8701. return;
  8702. }
  8703. let selected, option;
  8704. for (let i = 0, l = el.options.length; i < l; i++) {
  8705. option = el.options[i];
  8706. if (isMultiple) {
  8707. selected = looseIndexOf(value, getValue(option)) > -1;
  8708. if (option.selected !== selected) {
  8709. option.selected = selected;
  8710. }
  8711. }
  8712. else {
  8713. if (looseEqual(getValue(option), value)) {
  8714. if (el.selectedIndex !== i) {
  8715. el.selectedIndex = i;
  8716. }
  8717. return;
  8718. }
  8719. }
  8720. }
  8721. if (!isMultiple) {
  8722. el.selectedIndex = -1;
  8723. }
  8724. }
  8725. function hasNoMatchingOption(value, options) {
  8726. return options.every(o => !looseEqual(o, value));
  8727. }
  8728. function getValue(option) {
  8729. return '_value' in option ? option._value : option.value;
  8730. }
  8731. function onCompositionStart(e) {
  8732. e.target.composing = true;
  8733. }
  8734. function onCompositionEnd(e) {
  8735. // prevent triggering an input event for no reason
  8736. if (!e.target.composing)
  8737. return;
  8738. e.target.composing = false;
  8739. trigger(e.target, 'input');
  8740. }
  8741. function trigger(el, type) {
  8742. const e = document.createEvent('HTMLEvents');
  8743. e.initEvent(type, true, true);
  8744. el.dispatchEvent(e);
  8745. }
  8746. // recursively search for possible transition defined inside the component root
  8747. function locateNode(vnode) {
  8748. // @ts-expect-error
  8749. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8750. ? locateNode(vnode.componentInstance._vnode)
  8751. : vnode;
  8752. }
  8753. var show = {
  8754. bind(el, { value }, vnode) {
  8755. vnode = locateNode(vnode);
  8756. const transition = vnode.data && vnode.data.transition;
  8757. const originalDisplay = (el.__vOriginalDisplay =
  8758. el.style.display === 'none' ? '' : el.style.display);
  8759. if (value && transition) {
  8760. vnode.data.show = true;
  8761. enter(vnode, () => {
  8762. el.style.display = originalDisplay;
  8763. });
  8764. }
  8765. else {
  8766. el.style.display = value ? originalDisplay : 'none';
  8767. }
  8768. },
  8769. update(el, { value, oldValue }, vnode) {
  8770. /* istanbul ignore if */
  8771. if (!value === !oldValue)
  8772. return;
  8773. vnode = locateNode(vnode);
  8774. const transition = vnode.data && vnode.data.transition;
  8775. if (transition) {
  8776. vnode.data.show = true;
  8777. if (value) {
  8778. enter(vnode, () => {
  8779. el.style.display = el.__vOriginalDisplay;
  8780. });
  8781. }
  8782. else {
  8783. leave(vnode, () => {
  8784. el.style.display = 'none';
  8785. });
  8786. }
  8787. }
  8788. else {
  8789. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8790. }
  8791. },
  8792. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8793. if (!isDestroy) {
  8794. el.style.display = el.__vOriginalDisplay;
  8795. }
  8796. }
  8797. };
  8798. var platformDirectives = {
  8799. model: directive,
  8800. show
  8801. };
  8802. // Provides transition support for a single element/component.
  8803. const transitionProps = {
  8804. name: String,
  8805. appear: Boolean,
  8806. css: Boolean,
  8807. mode: String,
  8808. type: String,
  8809. enterClass: String,
  8810. leaveClass: String,
  8811. enterToClass: String,
  8812. leaveToClass: String,
  8813. enterActiveClass: String,
  8814. leaveActiveClass: String,
  8815. appearClass: String,
  8816. appearActiveClass: String,
  8817. appearToClass: String,
  8818. duration: [Number, String, Object]
  8819. };
  8820. // in case the child is also an abstract component, e.g. <keep-alive>
  8821. // we want to recursively retrieve the real component to be rendered
  8822. function getRealChild(vnode) {
  8823. const compOptions = vnode && vnode.componentOptions;
  8824. if (compOptions && compOptions.Ctor.options.abstract) {
  8825. return getRealChild(getFirstComponentChild(compOptions.children));
  8826. }
  8827. else {
  8828. return vnode;
  8829. }
  8830. }
  8831. function extractTransitionData(comp) {
  8832. const data = {};
  8833. const options = comp.$options;
  8834. // props
  8835. for (const key in options.propsData) {
  8836. data[key] = comp[key];
  8837. }
  8838. // events.
  8839. // extract listeners and pass them directly to the transition methods
  8840. const listeners = options._parentListeners;
  8841. for (const key in listeners) {
  8842. data[camelize(key)] = listeners[key];
  8843. }
  8844. return data;
  8845. }
  8846. function placeholder(h, rawChild) {
  8847. // @ts-expect-error
  8848. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8849. return h('keep-alive', {
  8850. props: rawChild.componentOptions.propsData
  8851. });
  8852. }
  8853. }
  8854. function hasParentTransition(vnode) {
  8855. while ((vnode = vnode.parent)) {
  8856. if (vnode.data.transition) {
  8857. return true;
  8858. }
  8859. }
  8860. }
  8861. function isSameChild(child, oldChild) {
  8862. return oldChild.key === child.key && oldChild.tag === child.tag;
  8863. }
  8864. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8865. const isVShowDirective = d => d.name === 'show';
  8866. var Transition = {
  8867. name: 'transition',
  8868. props: transitionProps,
  8869. abstract: true,
  8870. render(h) {
  8871. let children = this.$slots.default;
  8872. if (!children) {
  8873. return;
  8874. }
  8875. // filter out text nodes (possible whitespaces)
  8876. children = children.filter(isNotTextNode);
  8877. /* istanbul ignore if */
  8878. if (!children.length) {
  8879. return;
  8880. }
  8881. // warn multiple elements
  8882. if (children.length > 1) {
  8883. warn$2('<transition> can only be used on a single element. Use ' +
  8884. '<transition-group> for lists.', this.$parent);
  8885. }
  8886. const mode = this.mode;
  8887. // warn invalid mode
  8888. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8889. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8890. }
  8891. const rawChild = children[0];
  8892. // if this is a component root node and the component's
  8893. // parent container node also has transition, skip.
  8894. if (hasParentTransition(this.$vnode)) {
  8895. return rawChild;
  8896. }
  8897. // apply transition data to child
  8898. // use getRealChild() to ignore abstract components e.g. keep-alive
  8899. const child = getRealChild(rawChild);
  8900. /* istanbul ignore if */
  8901. if (!child) {
  8902. return rawChild;
  8903. }
  8904. if (this._leaving) {
  8905. return placeholder(h, rawChild);
  8906. }
  8907. // ensure a key that is unique to the vnode type and to this transition
  8908. // component instance. This key will be used to remove pending leaving nodes
  8909. // during entering.
  8910. const id = `__transition-${this._uid}-`;
  8911. child.key =
  8912. child.key == null
  8913. ? child.isComment
  8914. ? id + 'comment'
  8915. : id + child.tag
  8916. : isPrimitive(child.key)
  8917. ? String(child.key).indexOf(id) === 0
  8918. ? child.key
  8919. : id + child.key
  8920. : child.key;
  8921. const data = ((child.data || (child.data = {})).transition =
  8922. extractTransitionData(this));
  8923. const oldRawChild = this._vnode;
  8924. const oldChild = getRealChild(oldRawChild);
  8925. // mark v-show
  8926. // so that the transition module can hand over the control to the directive
  8927. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8928. child.data.show = true;
  8929. }
  8930. if (oldChild &&
  8931. oldChild.data &&
  8932. !isSameChild(child, oldChild) &&
  8933. !isAsyncPlaceholder(oldChild) &&
  8934. // #6687 component root is a comment node
  8935. !(oldChild.componentInstance &&
  8936. oldChild.componentInstance._vnode.isComment)) {
  8937. // replace old child transition data with fresh one
  8938. // important for dynamic transitions!
  8939. const oldData = (oldChild.data.transition = extend({}, data));
  8940. // handle transition mode
  8941. if (mode === 'out-in') {
  8942. // return placeholder node and queue update when leave finishes
  8943. this._leaving = true;
  8944. mergeVNodeHook(oldData, 'afterLeave', () => {
  8945. this._leaving = false;
  8946. this.$forceUpdate();
  8947. });
  8948. return placeholder(h, rawChild);
  8949. }
  8950. else if (mode === 'in-out') {
  8951. if (isAsyncPlaceholder(child)) {
  8952. return oldRawChild;
  8953. }
  8954. let delayedLeave;
  8955. const performLeave = () => {
  8956. delayedLeave();
  8957. };
  8958. mergeVNodeHook(data, 'afterEnter', performLeave);
  8959. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8960. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8961. delayedLeave = leave;
  8962. });
  8963. }
  8964. }
  8965. return rawChild;
  8966. }
  8967. };
  8968. // Provides transition support for list items.
  8969. const props = extend({
  8970. tag: String,
  8971. moveClass: String
  8972. }, transitionProps);
  8973. delete props.mode;
  8974. var TransitionGroup = {
  8975. props,
  8976. beforeMount() {
  8977. const update = this._update;
  8978. this._update = (vnode, hydrating) => {
  8979. const restoreActiveInstance = setActiveInstance(this);
  8980. // force removing pass
  8981. this.__patch__(this._vnode, this.kept, false, // hydrating
  8982. true // removeOnly (!important, avoids unnecessary moves)
  8983. );
  8984. this._vnode = this.kept;
  8985. restoreActiveInstance();
  8986. update.call(this, vnode, hydrating);
  8987. };
  8988. },
  8989. render(h) {
  8990. const tag = this.tag || this.$vnode.data.tag || 'span';
  8991. const map = Object.create(null);
  8992. const prevChildren = (this.prevChildren = this.children);
  8993. const rawChildren = this.$slots.default || [];
  8994. const children = (this.children = []);
  8995. const transitionData = extractTransitionData(this);
  8996. for (let i = 0; i < rawChildren.length; i++) {
  8997. const c = rawChildren[i];
  8998. if (c.tag) {
  8999. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  9000. children.push(c);
  9001. map[c.key] = c;
  9002. (c.data || (c.data = {})).transition = transitionData;
  9003. }
  9004. else {
  9005. const opts = c.componentOptions;
  9006. const name = opts
  9007. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  9008. : c.tag;
  9009. warn$2(`<transition-group> children must be keyed: <${name}>`);
  9010. }
  9011. }
  9012. }
  9013. if (prevChildren) {
  9014. const kept = [];
  9015. const removed = [];
  9016. for (let i = 0; i < prevChildren.length; i++) {
  9017. const c = prevChildren[i];
  9018. c.data.transition = transitionData;
  9019. // @ts-expect-error .getBoundingClientRect is not typed in Node
  9020. c.data.pos = c.elm.getBoundingClientRect();
  9021. if (map[c.key]) {
  9022. kept.push(c);
  9023. }
  9024. else {
  9025. removed.push(c);
  9026. }
  9027. }
  9028. this.kept = h(tag, null, kept);
  9029. this.removed = removed;
  9030. }
  9031. return h(tag, null, children);
  9032. },
  9033. updated() {
  9034. const children = this.prevChildren;
  9035. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  9036. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  9037. return;
  9038. }
  9039. // we divide the work into three loops to avoid mixing DOM reads and writes
  9040. // in each iteration - which helps prevent layout thrashing.
  9041. children.forEach(callPendingCbs);
  9042. children.forEach(recordPosition);
  9043. children.forEach(applyTranslation);
  9044. // force reflow to put everything in position
  9045. // assign to this to avoid being removed in tree-shaking
  9046. // $flow-disable-line
  9047. this._reflow = document.body.offsetHeight;
  9048. children.forEach((c) => {
  9049. if (c.data.moved) {
  9050. const el = c.elm;
  9051. const s = el.style;
  9052. addTransitionClass(el, moveClass);
  9053. s.transform = s.WebkitTransform = s.transitionDuration = '';
  9054. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  9055. if (e && e.target !== el) {
  9056. return;
  9057. }
  9058. if (!e || /transform$/.test(e.propertyName)) {
  9059. el.removeEventListener(transitionEndEvent, cb);
  9060. el._moveCb = null;
  9061. removeTransitionClass(el, moveClass);
  9062. }
  9063. }));
  9064. }
  9065. });
  9066. },
  9067. methods: {
  9068. hasMove(el, moveClass) {
  9069. /* istanbul ignore if */
  9070. if (!hasTransition) {
  9071. return false;
  9072. }
  9073. /* istanbul ignore if */
  9074. if (this._hasMove) {
  9075. return this._hasMove;
  9076. }
  9077. // Detect whether an element with the move class applied has
  9078. // CSS transitions. Since the element may be inside an entering
  9079. // transition at this very moment, we make a clone of it and remove
  9080. // all other transition classes applied to ensure only the move class
  9081. // is applied.
  9082. const clone = el.cloneNode();
  9083. if (el._transitionClasses) {
  9084. el._transitionClasses.forEach((cls) => {
  9085. removeClass(clone, cls);
  9086. });
  9087. }
  9088. addClass(clone, moveClass);
  9089. clone.style.display = 'none';
  9090. this.$el.appendChild(clone);
  9091. const info = getTransitionInfo(clone);
  9092. this.$el.removeChild(clone);
  9093. return (this._hasMove = info.hasTransform);
  9094. }
  9095. }
  9096. };
  9097. function callPendingCbs(c) {
  9098. /* istanbul ignore if */
  9099. if (c.elm._moveCb) {
  9100. c.elm._moveCb();
  9101. }
  9102. /* istanbul ignore if */
  9103. if (c.elm._enterCb) {
  9104. c.elm._enterCb();
  9105. }
  9106. }
  9107. function recordPosition(c) {
  9108. c.data.newPos = c.elm.getBoundingClientRect();
  9109. }
  9110. function applyTranslation(c) {
  9111. const oldPos = c.data.pos;
  9112. const newPos = c.data.newPos;
  9113. const dx = oldPos.left - newPos.left;
  9114. const dy = oldPos.top - newPos.top;
  9115. if (dx || dy) {
  9116. c.data.moved = true;
  9117. const s = c.elm.style;
  9118. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9119. s.transitionDuration = '0s';
  9120. }
  9121. }
  9122. var platformComponents = {
  9123. Transition,
  9124. TransitionGroup
  9125. };
  9126. // install platform specific utils
  9127. Vue.config.mustUseProp = mustUseProp;
  9128. Vue.config.isReservedTag = isReservedTag;
  9129. Vue.config.isReservedAttr = isReservedAttr;
  9130. Vue.config.getTagNamespace = getTagNamespace;
  9131. Vue.config.isUnknownElement = isUnknownElement;
  9132. // install platform runtime directives & components
  9133. extend(Vue.options.directives, platformDirectives);
  9134. extend(Vue.options.components, platformComponents);
  9135. // install platform patch function
  9136. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9137. // public mount method
  9138. Vue.prototype.$mount = function (el, hydrating) {
  9139. el = el && inBrowser ? query(el) : undefined;
  9140. return mountComponent(this, el, hydrating);
  9141. };
  9142. // devtools global hook
  9143. /* istanbul ignore next */
  9144. if (inBrowser) {
  9145. setTimeout(() => {
  9146. if (config.devtools) {
  9147. if (devtools) {
  9148. devtools.emit('init', Vue);
  9149. }
  9150. else {
  9151. // @ts-expect-error
  9152. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9153. 'https://github.com/vuejs/vue-devtools');
  9154. }
  9155. }
  9156. if (config.productionTip !== false &&
  9157. typeof console !== 'undefined') {
  9158. // @ts-expect-error
  9159. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9160. `Make sure to turn on production mode when deploying for production.\n` +
  9161. `See more tips at https://vuejs.org/guide/deployment.html`);
  9162. }
  9163. }, 0);
  9164. }
  9165. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9166. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9167. const buildRegex = cached(delimiters => {
  9168. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9169. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9170. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9171. });
  9172. function parseText(text, delimiters) {
  9173. //@ts-expect-error
  9174. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9175. if (!tagRE.test(text)) {
  9176. return;
  9177. }
  9178. const tokens = [];
  9179. const rawTokens = [];
  9180. let lastIndex = (tagRE.lastIndex = 0);
  9181. let match, index, tokenValue;
  9182. while ((match = tagRE.exec(text))) {
  9183. index = match.index;
  9184. // push text token
  9185. if (index > lastIndex) {
  9186. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9187. tokens.push(JSON.stringify(tokenValue));
  9188. }
  9189. // tag token
  9190. const exp = parseFilters(match[1].trim());
  9191. tokens.push(`_s(${exp})`);
  9192. rawTokens.push({ '@binding': exp });
  9193. lastIndex = index + match[0].length;
  9194. }
  9195. if (lastIndex < text.length) {
  9196. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9197. tokens.push(JSON.stringify(tokenValue));
  9198. }
  9199. return {
  9200. expression: tokens.join('+'),
  9201. tokens: rawTokens
  9202. };
  9203. }
  9204. function transformNode$1(el, options) {
  9205. const warn = options.warn || baseWarn;
  9206. const staticClass = getAndRemoveAttr(el, 'class');
  9207. if (staticClass) {
  9208. const res = parseText(staticClass, options.delimiters);
  9209. if (res) {
  9210. warn(`class="${staticClass}": ` +
  9211. 'Interpolation inside attributes has been removed. ' +
  9212. 'Use v-bind or the colon shorthand instead. For example, ' +
  9213. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9214. }
  9215. }
  9216. if (staticClass) {
  9217. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9218. }
  9219. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9220. if (classBinding) {
  9221. el.classBinding = classBinding;
  9222. }
  9223. }
  9224. function genData$2(el) {
  9225. let data = '';
  9226. if (el.staticClass) {
  9227. data += `staticClass:${el.staticClass},`;
  9228. }
  9229. if (el.classBinding) {
  9230. data += `class:${el.classBinding},`;
  9231. }
  9232. return data;
  9233. }
  9234. var klass = {
  9235. staticKeys: ['staticClass'],
  9236. transformNode: transformNode$1,
  9237. genData: genData$2
  9238. };
  9239. function transformNode(el, options) {
  9240. const warn = options.warn || baseWarn;
  9241. const staticStyle = getAndRemoveAttr(el, 'style');
  9242. if (staticStyle) {
  9243. /* istanbul ignore if */
  9244. {
  9245. const res = parseText(staticStyle, options.delimiters);
  9246. if (res) {
  9247. warn(`style="${staticStyle}": ` +
  9248. 'Interpolation inside attributes has been removed. ' +
  9249. 'Use v-bind or the colon shorthand instead. For example, ' +
  9250. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9251. }
  9252. }
  9253. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9254. }
  9255. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9256. if (styleBinding) {
  9257. el.styleBinding = styleBinding;
  9258. }
  9259. }
  9260. function genData$1(el) {
  9261. let data = '';
  9262. if (el.staticStyle) {
  9263. data += `staticStyle:${el.staticStyle},`;
  9264. }
  9265. if (el.styleBinding) {
  9266. data += `style:(${el.styleBinding}),`;
  9267. }
  9268. return data;
  9269. }
  9270. var style = {
  9271. staticKeys: ['staticStyle'],
  9272. transformNode,
  9273. genData: genData$1
  9274. };
  9275. let decoder;
  9276. var he = {
  9277. decode(html) {
  9278. decoder = decoder || document.createElement('div');
  9279. decoder.innerHTML = html;
  9280. return decoder.textContent;
  9281. }
  9282. };
  9283. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9284. 'link,meta,param,source,track,wbr');
  9285. // Elements that you can, intentionally, leave open
  9286. // (and which close themselves)
  9287. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9288. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9289. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9290. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9291. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9292. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9293. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9294. 'title,tr,track');
  9295. /**
  9296. * Not type-checking this file because it's mostly vendor code.
  9297. */
  9298. // Regular Expressions for parsing tags and attributes
  9299. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9300. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9301. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9302. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9303. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9304. const startTagClose = /^\s*(\/?)>/;
  9305. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9306. const doctype = /^<!DOCTYPE [^>]+>/i;
  9307. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9308. const comment = /^<!\--/;
  9309. const conditionalComment = /^<!\[/;
  9310. // Special Elements (can contain anything)
  9311. const isPlainTextElement = makeMap('script,style,textarea', true);
  9312. const reCache = {};
  9313. const decodingMap = {
  9314. '&lt;': '<',
  9315. '&gt;': '>',
  9316. '&quot;': '"',
  9317. '&amp;': '&',
  9318. '&#10;': '\n',
  9319. '&#9;': '\t',
  9320. '&#39;': "'"
  9321. };
  9322. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9323. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9324. // #5992
  9325. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9326. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9327. function decodeAttr(value, shouldDecodeNewlines) {
  9328. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9329. return value.replace(re, match => decodingMap[match]);
  9330. }
  9331. function parseHTML(html, options) {
  9332. const stack = [];
  9333. const expectHTML = options.expectHTML;
  9334. const isUnaryTag = options.isUnaryTag || no;
  9335. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9336. let index = 0;
  9337. let last, lastTag;
  9338. while (html) {
  9339. last = html;
  9340. // Make sure we're not in a plaintext content element like script/style
  9341. if (!lastTag || !isPlainTextElement(lastTag)) {
  9342. let textEnd = html.indexOf('<');
  9343. if (textEnd === 0) {
  9344. // Comment:
  9345. if (comment.test(html)) {
  9346. const commentEnd = html.indexOf('-->');
  9347. if (commentEnd >= 0) {
  9348. if (options.shouldKeepComment && options.comment) {
  9349. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9350. }
  9351. advance(commentEnd + 3);
  9352. continue;
  9353. }
  9354. }
  9355. // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9356. if (conditionalComment.test(html)) {
  9357. const conditionalEnd = html.indexOf(']>');
  9358. if (conditionalEnd >= 0) {
  9359. advance(conditionalEnd + 2);
  9360. continue;
  9361. }
  9362. }
  9363. // Doctype:
  9364. const doctypeMatch = html.match(doctype);
  9365. if (doctypeMatch) {
  9366. advance(doctypeMatch[0].length);
  9367. continue;
  9368. }
  9369. // End tag:
  9370. const endTagMatch = html.match(endTag);
  9371. if (endTagMatch) {
  9372. const curIndex = index;
  9373. advance(endTagMatch[0].length);
  9374. parseEndTag(endTagMatch[1], curIndex, index);
  9375. continue;
  9376. }
  9377. // Start tag:
  9378. const startTagMatch = parseStartTag();
  9379. if (startTagMatch) {
  9380. handleStartTag(startTagMatch);
  9381. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9382. advance(1);
  9383. }
  9384. continue;
  9385. }
  9386. }
  9387. let text, rest, next;
  9388. if (textEnd >= 0) {
  9389. rest = html.slice(textEnd);
  9390. while (!endTag.test(rest) &&
  9391. !startTagOpen.test(rest) &&
  9392. !comment.test(rest) &&
  9393. !conditionalComment.test(rest)) {
  9394. // < in plain text, be forgiving and treat it as text
  9395. next = rest.indexOf('<', 1);
  9396. if (next < 0)
  9397. break;
  9398. textEnd += next;
  9399. rest = html.slice(textEnd);
  9400. }
  9401. text = html.substring(0, textEnd);
  9402. }
  9403. if (textEnd < 0) {
  9404. text = html;
  9405. }
  9406. if (text) {
  9407. advance(text.length);
  9408. }
  9409. if (options.chars && text) {
  9410. options.chars(text, index - text.length, index);
  9411. }
  9412. }
  9413. else {
  9414. let endTagLength = 0;
  9415. const stackedTag = lastTag.toLowerCase();
  9416. const reStackedTag = reCache[stackedTag] ||
  9417. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9418. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9419. endTagLength = endTag.length;
  9420. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9421. text = text
  9422. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9423. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9424. }
  9425. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9426. text = text.slice(1);
  9427. }
  9428. if (options.chars) {
  9429. options.chars(text);
  9430. }
  9431. return '';
  9432. });
  9433. index += html.length - rest.length;
  9434. html = rest;
  9435. parseEndTag(stackedTag, index - endTagLength, index);
  9436. }
  9437. if (html === last) {
  9438. options.chars && options.chars(html);
  9439. if (!stack.length && options.warn) {
  9440. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9441. start: index + html.length
  9442. });
  9443. }
  9444. break;
  9445. }
  9446. }
  9447. // Clean up any remaining tags
  9448. parseEndTag();
  9449. function advance(n) {
  9450. index += n;
  9451. html = html.substring(n);
  9452. }
  9453. function parseStartTag() {
  9454. const start = html.match(startTagOpen);
  9455. if (start) {
  9456. const match = {
  9457. tagName: start[1],
  9458. attrs: [],
  9459. start: index
  9460. };
  9461. advance(start[0].length);
  9462. let end, attr;
  9463. while (!(end = html.match(startTagClose)) &&
  9464. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9465. attr.start = index;
  9466. advance(attr[0].length);
  9467. attr.end = index;
  9468. match.attrs.push(attr);
  9469. }
  9470. if (end) {
  9471. match.unarySlash = end[1];
  9472. advance(end[0].length);
  9473. match.end = index;
  9474. return match;
  9475. }
  9476. }
  9477. }
  9478. function handleStartTag(match) {
  9479. const tagName = match.tagName;
  9480. const unarySlash = match.unarySlash;
  9481. if (expectHTML) {
  9482. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9483. parseEndTag(lastTag);
  9484. }
  9485. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9486. parseEndTag(tagName);
  9487. }
  9488. }
  9489. const unary = isUnaryTag(tagName) || !!unarySlash;
  9490. const l = match.attrs.length;
  9491. const attrs = new Array(l);
  9492. for (let i = 0; i < l; i++) {
  9493. const args = match.attrs[i];
  9494. const value = args[3] || args[4] || args[5] || '';
  9495. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9496. ? options.shouldDecodeNewlinesForHref
  9497. : options.shouldDecodeNewlines;
  9498. attrs[i] = {
  9499. name: args[1],
  9500. value: decodeAttr(value, shouldDecodeNewlines)
  9501. };
  9502. if (options.outputSourceRange) {
  9503. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9504. attrs[i].end = args.end;
  9505. }
  9506. }
  9507. if (!unary) {
  9508. stack.push({
  9509. tag: tagName,
  9510. lowerCasedTag: tagName.toLowerCase(),
  9511. attrs: attrs,
  9512. start: match.start,
  9513. end: match.end
  9514. });
  9515. lastTag = tagName;
  9516. }
  9517. if (options.start) {
  9518. options.start(tagName, attrs, unary, match.start, match.end);
  9519. }
  9520. }
  9521. function parseEndTag(tagName, start, end) {
  9522. let pos, lowerCasedTagName;
  9523. if (start == null)
  9524. start = index;
  9525. if (end == null)
  9526. end = index;
  9527. // Find the closest opened tag of the same type
  9528. if (tagName) {
  9529. lowerCasedTagName = tagName.toLowerCase();
  9530. for (pos = stack.length - 1; pos >= 0; pos--) {
  9531. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9532. break;
  9533. }
  9534. }
  9535. }
  9536. else {
  9537. // If no tag name is provided, clean shop
  9538. pos = 0;
  9539. }
  9540. if (pos >= 0) {
  9541. // Close all the open elements, up the stack
  9542. for (let i = stack.length - 1; i >= pos; i--) {
  9543. if ((i > pos || !tagName) && options.warn) {
  9544. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9545. start: stack[i].start,
  9546. end: stack[i].end
  9547. });
  9548. }
  9549. if (options.end) {
  9550. options.end(stack[i].tag, start, end);
  9551. }
  9552. }
  9553. // Remove the open elements from the stack
  9554. stack.length = pos;
  9555. lastTag = pos && stack[pos - 1].tag;
  9556. }
  9557. else if (lowerCasedTagName === 'br') {
  9558. if (options.start) {
  9559. options.start(tagName, [], true, start, end);
  9560. }
  9561. }
  9562. else if (lowerCasedTagName === 'p') {
  9563. if (options.start) {
  9564. options.start(tagName, [], false, start, end);
  9565. }
  9566. if (options.end) {
  9567. options.end(tagName, start, end);
  9568. }
  9569. }
  9570. }
  9571. }
  9572. const onRE = /^@|^v-on:/;
  9573. const dirRE = /^v-|^@|^:|^#/;
  9574. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9575. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9576. const stripParensRE = /^\(|\)$/g;
  9577. const dynamicArgRE = /^\[.*\]$/;
  9578. const argRE = /:(.*)$/;
  9579. const bindRE = /^:|^\.|^v-bind:/;
  9580. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9581. const slotRE = /^v-slot(:|$)|^#/;
  9582. const lineBreakRE = /[\r\n]/;
  9583. const whitespaceRE = /[ \f\t\r\n]+/g;
  9584. const invalidAttributeRE = /[\s"'<>\/=]/;
  9585. const decodeHTMLCached = cached(he.decode);
  9586. const emptySlotScopeToken = `_empty_`;
  9587. // configurable state
  9588. let warn;
  9589. let delimiters;
  9590. let transforms;
  9591. let preTransforms;
  9592. let postTransforms;
  9593. let platformIsPreTag;
  9594. let platformMustUseProp;
  9595. let platformGetTagNamespace;
  9596. let maybeComponent;
  9597. function createASTElement(tag, attrs, parent) {
  9598. return {
  9599. type: 1,
  9600. tag,
  9601. attrsList: attrs,
  9602. attrsMap: makeAttrsMap(attrs),
  9603. rawAttrsMap: {},
  9604. parent,
  9605. children: []
  9606. };
  9607. }
  9608. /**
  9609. * Convert HTML string to AST.
  9610. */
  9611. function parse(template, options) {
  9612. warn = options.warn || baseWarn;
  9613. platformIsPreTag = options.isPreTag || no;
  9614. platformMustUseProp = options.mustUseProp || no;
  9615. platformGetTagNamespace = options.getTagNamespace || no;
  9616. const isReservedTag = options.isReservedTag || no;
  9617. maybeComponent = (el) => !!(el.component ||
  9618. el.attrsMap[':is'] ||
  9619. el.attrsMap['v-bind:is'] ||
  9620. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9621. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9622. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9623. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9624. delimiters = options.delimiters;
  9625. const stack = [];
  9626. const preserveWhitespace = options.preserveWhitespace !== false;
  9627. const whitespaceOption = options.whitespace;
  9628. let root;
  9629. let currentParent;
  9630. let inVPre = false;
  9631. let inPre = false;
  9632. let warned = false;
  9633. function warnOnce(msg, range) {
  9634. if (!warned) {
  9635. warned = true;
  9636. warn(msg, range);
  9637. }
  9638. }
  9639. function closeElement(element) {
  9640. trimEndingWhitespace(element);
  9641. if (!inVPre && !element.processed) {
  9642. element = processElement(element, options);
  9643. }
  9644. // tree management
  9645. if (!stack.length && element !== root) {
  9646. // allow root elements with v-if, v-else-if and v-else
  9647. if (root.if && (element.elseif || element.else)) {
  9648. {
  9649. checkRootConstraints(element);
  9650. }
  9651. addIfCondition(root, {
  9652. exp: element.elseif,
  9653. block: element
  9654. });
  9655. }
  9656. else {
  9657. warnOnce(`Component template should contain exactly one root element. ` +
  9658. `If you are using v-if on multiple elements, ` +
  9659. `use v-else-if to chain them instead.`, { start: element.start });
  9660. }
  9661. }
  9662. if (currentParent && !element.forbidden) {
  9663. if (element.elseif || element.else) {
  9664. processIfConditions(element, currentParent);
  9665. }
  9666. else {
  9667. if (element.slotScope) {
  9668. // scoped slot
  9669. // keep it in the children list so that v-else(-if) conditions can
  9670. // find it as the prev node.
  9671. const name = element.slotTarget || '"default"';
  9672. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9673. }
  9674. currentParent.children.push(element);
  9675. element.parent = currentParent;
  9676. }
  9677. }
  9678. // final children cleanup
  9679. // filter out scoped slots
  9680. element.children = element.children.filter(c => !c.slotScope);
  9681. // remove trailing whitespace node again
  9682. trimEndingWhitespace(element);
  9683. // check pre state
  9684. if (element.pre) {
  9685. inVPre = false;
  9686. }
  9687. if (platformIsPreTag(element.tag)) {
  9688. inPre = false;
  9689. }
  9690. // apply post-transforms
  9691. for (let i = 0; i < postTransforms.length; i++) {
  9692. postTransforms[i](element, options);
  9693. }
  9694. }
  9695. function trimEndingWhitespace(el) {
  9696. // remove trailing whitespace node
  9697. if (!inPre) {
  9698. let lastNode;
  9699. while ((lastNode = el.children[el.children.length - 1]) &&
  9700. lastNode.type === 3 &&
  9701. lastNode.text === ' ') {
  9702. el.children.pop();
  9703. }
  9704. }
  9705. }
  9706. function checkRootConstraints(el) {
  9707. if (el.tag === 'slot' || el.tag === 'template') {
  9708. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9709. 'contain multiple nodes.', { start: el.start });
  9710. }
  9711. if (el.attrsMap.hasOwnProperty('v-for')) {
  9712. warnOnce('Cannot use v-for on stateful component root element because ' +
  9713. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9714. }
  9715. }
  9716. parseHTML(template, {
  9717. warn,
  9718. expectHTML: options.expectHTML,
  9719. isUnaryTag: options.isUnaryTag,
  9720. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9721. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9722. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9723. shouldKeepComment: options.comments,
  9724. outputSourceRange: options.outputSourceRange,
  9725. start(tag, attrs, unary, start, end) {
  9726. // check namespace.
  9727. // inherit parent ns if there is one
  9728. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9729. // handle IE svg bug
  9730. /* istanbul ignore if */
  9731. if (isIE && ns === 'svg') {
  9732. attrs = guardIESVGBug(attrs);
  9733. }
  9734. let element = createASTElement(tag, attrs, currentParent);
  9735. if (ns) {
  9736. element.ns = ns;
  9737. }
  9738. {
  9739. if (options.outputSourceRange) {
  9740. element.start = start;
  9741. element.end = end;
  9742. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9743. cumulated[attr.name] = attr;
  9744. return cumulated;
  9745. }, {});
  9746. }
  9747. attrs.forEach(attr => {
  9748. if (invalidAttributeRE.test(attr.name)) {
  9749. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9750. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9751. ? {
  9752. start: attr.start + attr.name.indexOf(`[`),
  9753. end: attr.start + attr.name.length
  9754. }
  9755. : undefined);
  9756. }
  9757. });
  9758. }
  9759. if (isForbiddenTag(element) && !isServerRendering()) {
  9760. element.forbidden = true;
  9761. warn('Templates should only be responsible for mapping the state to the ' +
  9762. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9763. `<${tag}>` +
  9764. ', as they will not be parsed.', { start: element.start });
  9765. }
  9766. // apply pre-transforms
  9767. for (let i = 0; i < preTransforms.length; i++) {
  9768. element = preTransforms[i](element, options) || element;
  9769. }
  9770. if (!inVPre) {
  9771. processPre(element);
  9772. if (element.pre) {
  9773. inVPre = true;
  9774. }
  9775. }
  9776. if (platformIsPreTag(element.tag)) {
  9777. inPre = true;
  9778. }
  9779. if (inVPre) {
  9780. processRawAttrs(element);
  9781. }
  9782. else if (!element.processed) {
  9783. // structural directives
  9784. processFor(element);
  9785. processIf(element);
  9786. processOnce(element);
  9787. }
  9788. if (!root) {
  9789. root = element;
  9790. {
  9791. checkRootConstraints(root);
  9792. }
  9793. }
  9794. if (!unary) {
  9795. currentParent = element;
  9796. stack.push(element);
  9797. }
  9798. else {
  9799. closeElement(element);
  9800. }
  9801. },
  9802. end(tag, start, end) {
  9803. const element = stack[stack.length - 1];
  9804. // pop stack
  9805. stack.length -= 1;
  9806. currentParent = stack[stack.length - 1];
  9807. if (options.outputSourceRange) {
  9808. element.end = end;
  9809. }
  9810. closeElement(element);
  9811. },
  9812. chars(text, start, end) {
  9813. if (!currentParent) {
  9814. {
  9815. if (text === template) {
  9816. warnOnce('Component template requires a root element, rather than just text.', { start });
  9817. }
  9818. else if ((text = text.trim())) {
  9819. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9820. start
  9821. });
  9822. }
  9823. }
  9824. return;
  9825. }
  9826. // IE textarea placeholder bug
  9827. /* istanbul ignore if */
  9828. if (isIE &&
  9829. currentParent.tag === 'textarea' &&
  9830. currentParent.attrsMap.placeholder === text) {
  9831. return;
  9832. }
  9833. const children = currentParent.children;
  9834. if (inPre || text.trim()) {
  9835. text = isTextTag(currentParent)
  9836. ? text
  9837. : decodeHTMLCached(text);
  9838. }
  9839. else if (!children.length) {
  9840. // remove the whitespace-only node right after an opening tag
  9841. text = '';
  9842. }
  9843. else if (whitespaceOption) {
  9844. if (whitespaceOption === 'condense') {
  9845. // in condense mode, remove the whitespace node if it contains
  9846. // line break, otherwise condense to a single space
  9847. text = lineBreakRE.test(text) ? '' : ' ';
  9848. }
  9849. else {
  9850. text = ' ';
  9851. }
  9852. }
  9853. else {
  9854. text = preserveWhitespace ? ' ' : '';
  9855. }
  9856. if (text) {
  9857. if (!inPre && whitespaceOption === 'condense') {
  9858. // condense consecutive whitespaces into single space
  9859. text = text.replace(whitespaceRE, ' ');
  9860. }
  9861. let res;
  9862. let child;
  9863. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9864. child = {
  9865. type: 2,
  9866. expression: res.expression,
  9867. tokens: res.tokens,
  9868. text
  9869. };
  9870. }
  9871. else if (text !== ' ' ||
  9872. !children.length ||
  9873. children[children.length - 1].text !== ' ') {
  9874. child = {
  9875. type: 3,
  9876. text
  9877. };
  9878. }
  9879. if (child) {
  9880. if (options.outputSourceRange) {
  9881. child.start = start;
  9882. child.end = end;
  9883. }
  9884. children.push(child);
  9885. }
  9886. }
  9887. },
  9888. comment(text, start, end) {
  9889. // adding anything as a sibling to the root node is forbidden
  9890. // comments should still be allowed, but ignored
  9891. if (currentParent) {
  9892. const child = {
  9893. type: 3,
  9894. text,
  9895. isComment: true
  9896. };
  9897. if (options.outputSourceRange) {
  9898. child.start = start;
  9899. child.end = end;
  9900. }
  9901. currentParent.children.push(child);
  9902. }
  9903. }
  9904. });
  9905. return root;
  9906. }
  9907. function processPre(el) {
  9908. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9909. el.pre = true;
  9910. }
  9911. }
  9912. function processRawAttrs(el) {
  9913. const list = el.attrsList;
  9914. const len = list.length;
  9915. if (len) {
  9916. const attrs = (el.attrs = new Array(len));
  9917. for (let i = 0; i < len; i++) {
  9918. attrs[i] = {
  9919. name: list[i].name,
  9920. value: JSON.stringify(list[i].value)
  9921. };
  9922. if (list[i].start != null) {
  9923. attrs[i].start = list[i].start;
  9924. attrs[i].end = list[i].end;
  9925. }
  9926. }
  9927. }
  9928. else if (!el.pre) {
  9929. // non root node in pre blocks with no attributes
  9930. el.plain = true;
  9931. }
  9932. }
  9933. function processElement(element, options) {
  9934. processKey(element);
  9935. // determine whether this is a plain element after
  9936. // removing structural attributes
  9937. element.plain =
  9938. !element.key && !element.scopedSlots && !element.attrsList.length;
  9939. processRef(element);
  9940. processSlotContent(element);
  9941. processSlotOutlet(element);
  9942. processComponent(element);
  9943. for (let i = 0; i < transforms.length; i++) {
  9944. element = transforms[i](element, options) || element;
  9945. }
  9946. processAttrs(element);
  9947. return element;
  9948. }
  9949. function processKey(el) {
  9950. const exp = getBindingAttr(el, 'key');
  9951. if (exp) {
  9952. {
  9953. if (el.tag === 'template') {
  9954. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9955. }
  9956. if (el.for) {
  9957. const iterator = el.iterator2 || el.iterator1;
  9958. const parent = el.parent;
  9959. if (iterator &&
  9960. iterator === exp &&
  9961. parent &&
  9962. parent.tag === 'transition-group') {
  9963. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9964. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9965. }
  9966. }
  9967. }
  9968. el.key = exp;
  9969. }
  9970. }
  9971. function processRef(el) {
  9972. const ref = getBindingAttr(el, 'ref');
  9973. if (ref) {
  9974. el.ref = ref;
  9975. el.refInFor = checkInFor(el);
  9976. }
  9977. }
  9978. function processFor(el) {
  9979. let exp;
  9980. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9981. const res = parseFor(exp);
  9982. if (res) {
  9983. extend(el, res);
  9984. }
  9985. else {
  9986. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9987. }
  9988. }
  9989. }
  9990. function parseFor(exp) {
  9991. const inMatch = exp.match(forAliasRE);
  9992. if (!inMatch)
  9993. return;
  9994. const res = {};
  9995. res.for = inMatch[2].trim();
  9996. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9997. const iteratorMatch = alias.match(forIteratorRE);
  9998. if (iteratorMatch) {
  9999. res.alias = alias.replace(forIteratorRE, '').trim();
  10000. res.iterator1 = iteratorMatch[1].trim();
  10001. if (iteratorMatch[2]) {
  10002. res.iterator2 = iteratorMatch[2].trim();
  10003. }
  10004. }
  10005. else {
  10006. res.alias = alias;
  10007. }
  10008. return res;
  10009. }
  10010. function processIf(el) {
  10011. const exp = getAndRemoveAttr(el, 'v-if');
  10012. if (exp) {
  10013. el.if = exp;
  10014. addIfCondition(el, {
  10015. exp: exp,
  10016. block: el
  10017. });
  10018. }
  10019. else {
  10020. if (getAndRemoveAttr(el, 'v-else') != null) {
  10021. el.else = true;
  10022. }
  10023. const elseif = getAndRemoveAttr(el, 'v-else-if');
  10024. if (elseif) {
  10025. el.elseif = elseif;
  10026. }
  10027. }
  10028. }
  10029. function processIfConditions(el, parent) {
  10030. const prev = findPrevElement(parent.children);
  10031. if (prev && prev.if) {
  10032. addIfCondition(prev, {
  10033. exp: el.elseif,
  10034. block: el
  10035. });
  10036. }
  10037. else {
  10038. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  10039. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  10040. }
  10041. }
  10042. function findPrevElement(children) {
  10043. let i = children.length;
  10044. while (i--) {
  10045. if (children[i].type === 1) {
  10046. return children[i];
  10047. }
  10048. else {
  10049. if (children[i].text !== ' ') {
  10050. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  10051. `will be ignored.`, children[i]);
  10052. }
  10053. children.pop();
  10054. }
  10055. }
  10056. }
  10057. function addIfCondition(el, condition) {
  10058. if (!el.ifConditions) {
  10059. el.ifConditions = [];
  10060. }
  10061. el.ifConditions.push(condition);
  10062. }
  10063. function processOnce(el) {
  10064. const once = getAndRemoveAttr(el, 'v-once');
  10065. if (once != null) {
  10066. el.once = true;
  10067. }
  10068. }
  10069. // handle content being passed to a component as slot,
  10070. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10071. function processSlotContent(el) {
  10072. let slotScope;
  10073. if (el.tag === 'template') {
  10074. slotScope = getAndRemoveAttr(el, 'scope');
  10075. /* istanbul ignore if */
  10076. if (slotScope) {
  10077. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10078. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10079. `can also be used on plain elements in addition to <template> to ` +
  10080. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10081. }
  10082. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10083. }
  10084. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10085. /* istanbul ignore if */
  10086. if (el.attrsMap['v-for']) {
  10087. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10088. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10089. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10090. }
  10091. el.slotScope = slotScope;
  10092. }
  10093. // slot="xxx"
  10094. const slotTarget = getBindingAttr(el, 'slot');
  10095. if (slotTarget) {
  10096. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10097. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10098. // preserve slot as an attribute for native shadow DOM compat
  10099. // only for non-scoped slots.
  10100. if (el.tag !== 'template' && !el.slotScope) {
  10101. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10102. }
  10103. }
  10104. // 2.6 v-slot syntax
  10105. {
  10106. if (el.tag === 'template') {
  10107. // v-slot on <template>
  10108. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10109. if (slotBinding) {
  10110. {
  10111. if (el.slotTarget || el.slotScope) {
  10112. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10113. }
  10114. if (el.parent && !maybeComponent(el.parent)) {
  10115. warn(`<template v-slot> can only appear at the root level inside ` +
  10116. `the receiving component`, el);
  10117. }
  10118. }
  10119. const { name, dynamic } = getSlotName(slotBinding);
  10120. el.slotTarget = name;
  10121. el.slotTargetDynamic = dynamic;
  10122. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10123. }
  10124. }
  10125. else {
  10126. // v-slot on component, denotes default slot
  10127. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10128. if (slotBinding) {
  10129. {
  10130. if (!maybeComponent(el)) {
  10131. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10132. }
  10133. if (el.slotScope || el.slotTarget) {
  10134. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10135. }
  10136. if (el.scopedSlots) {
  10137. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10138. `<template> syntax when there are other named slots.`, slotBinding);
  10139. }
  10140. }
  10141. // add the component's children to its default slot
  10142. const slots = el.scopedSlots || (el.scopedSlots = {});
  10143. const { name, dynamic } = getSlotName(slotBinding);
  10144. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10145. slotContainer.slotTarget = name;
  10146. slotContainer.slotTargetDynamic = dynamic;
  10147. slotContainer.children = el.children.filter((c) => {
  10148. if (!c.slotScope) {
  10149. c.parent = slotContainer;
  10150. return true;
  10151. }
  10152. });
  10153. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10154. // remove children as they are returned from scopedSlots now
  10155. el.children = [];
  10156. // mark el non-plain so data gets generated
  10157. el.plain = false;
  10158. }
  10159. }
  10160. }
  10161. }
  10162. function getSlotName(binding) {
  10163. let name = binding.name.replace(slotRE, '');
  10164. if (!name) {
  10165. if (binding.name[0] !== '#') {
  10166. name = 'default';
  10167. }
  10168. else {
  10169. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10170. }
  10171. }
  10172. return dynamicArgRE.test(name)
  10173. ? // dynamic [name]
  10174. { name: name.slice(1, -1), dynamic: true }
  10175. : // static name
  10176. { name: `"${name}"`, dynamic: false };
  10177. }
  10178. // handle <slot/> outlets
  10179. function processSlotOutlet(el) {
  10180. if (el.tag === 'slot') {
  10181. el.slotName = getBindingAttr(el, 'name');
  10182. if (el.key) {
  10183. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10184. `and can possibly expand into multiple elements. ` +
  10185. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10186. }
  10187. }
  10188. }
  10189. function processComponent(el) {
  10190. let binding;
  10191. if ((binding = getBindingAttr(el, 'is'))) {
  10192. el.component = binding;
  10193. }
  10194. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10195. el.inlineTemplate = true;
  10196. }
  10197. }
  10198. function processAttrs(el) {
  10199. const list = el.attrsList;
  10200. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10201. for (i = 0, l = list.length; i < l; i++) {
  10202. name = rawName = list[i].name;
  10203. value = list[i].value;
  10204. if (dirRE.test(name)) {
  10205. // mark element as dynamic
  10206. el.hasBindings = true;
  10207. // modifiers
  10208. modifiers = parseModifiers(name.replace(dirRE, ''));
  10209. // support .foo shorthand syntax for the .prop modifier
  10210. if (modifiers) {
  10211. name = name.replace(modifierRE, '');
  10212. }
  10213. if (bindRE.test(name)) {
  10214. // v-bind
  10215. name = name.replace(bindRE, '');
  10216. value = parseFilters(value);
  10217. isDynamic = dynamicArgRE.test(name);
  10218. if (isDynamic) {
  10219. name = name.slice(1, -1);
  10220. }
  10221. if (value.trim().length === 0) {
  10222. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10223. }
  10224. if (modifiers) {
  10225. if (modifiers.prop && !isDynamic) {
  10226. name = camelize(name);
  10227. if (name === 'innerHtml')
  10228. name = 'innerHTML';
  10229. }
  10230. if (modifiers.camel && !isDynamic) {
  10231. name = camelize(name);
  10232. }
  10233. if (modifiers.sync) {
  10234. syncGen = genAssignmentCode(value, `$event`);
  10235. if (!isDynamic) {
  10236. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10237. if (hyphenate(name) !== camelize(name)) {
  10238. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10239. }
  10240. }
  10241. else {
  10242. // handler w/ dynamic event name
  10243. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10244. );
  10245. }
  10246. }
  10247. }
  10248. if ((modifiers && modifiers.prop) ||
  10249. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10250. addProp(el, name, value, list[i], isDynamic);
  10251. }
  10252. else {
  10253. addAttr(el, name, value, list[i], isDynamic);
  10254. }
  10255. }
  10256. else if (onRE.test(name)) {
  10257. // v-on
  10258. name = name.replace(onRE, '');
  10259. isDynamic = dynamicArgRE.test(name);
  10260. if (isDynamic) {
  10261. name = name.slice(1, -1);
  10262. }
  10263. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10264. }
  10265. else {
  10266. // normal directives
  10267. name = name.replace(dirRE, '');
  10268. // parse arg
  10269. const argMatch = name.match(argRE);
  10270. let arg = argMatch && argMatch[1];
  10271. isDynamic = false;
  10272. if (arg) {
  10273. name = name.slice(0, -(arg.length + 1));
  10274. if (dynamicArgRE.test(arg)) {
  10275. arg = arg.slice(1, -1);
  10276. isDynamic = true;
  10277. }
  10278. }
  10279. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10280. if (name === 'model') {
  10281. checkForAliasModel(el, value);
  10282. }
  10283. }
  10284. }
  10285. else {
  10286. // literal attribute
  10287. {
  10288. const res = parseText(value, delimiters);
  10289. if (res) {
  10290. warn(`${name}="${value}": ` +
  10291. 'Interpolation inside attributes has been removed. ' +
  10292. 'Use v-bind or the colon shorthand instead. For example, ' +
  10293. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10294. }
  10295. }
  10296. addAttr(el, name, JSON.stringify(value), list[i]);
  10297. // #6887 firefox doesn't update muted state if set via attribute
  10298. // even immediately after element creation
  10299. if (!el.component &&
  10300. name === 'muted' &&
  10301. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10302. addProp(el, name, 'true', list[i]);
  10303. }
  10304. }
  10305. }
  10306. }
  10307. function checkInFor(el) {
  10308. let parent = el;
  10309. while (parent) {
  10310. if (parent.for !== undefined) {
  10311. return true;
  10312. }
  10313. parent = parent.parent;
  10314. }
  10315. return false;
  10316. }
  10317. function parseModifiers(name) {
  10318. const match = name.match(modifierRE);
  10319. if (match) {
  10320. const ret = {};
  10321. match.forEach(m => {
  10322. ret[m.slice(1)] = true;
  10323. });
  10324. return ret;
  10325. }
  10326. }
  10327. function makeAttrsMap(attrs) {
  10328. const map = {};
  10329. for (let i = 0, l = attrs.length; i < l; i++) {
  10330. if (map[attrs[i].name] && !isIE && !isEdge) {
  10331. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10332. }
  10333. map[attrs[i].name] = attrs[i].value;
  10334. }
  10335. return map;
  10336. }
  10337. // for script (e.g. type="x/template") or style, do not decode content
  10338. function isTextTag(el) {
  10339. return el.tag === 'script' || el.tag === 'style';
  10340. }
  10341. function isForbiddenTag(el) {
  10342. return (el.tag === 'style' ||
  10343. (el.tag === 'script' &&
  10344. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10345. }
  10346. const ieNSBug = /^xmlns:NS\d+/;
  10347. const ieNSPrefix = /^NS\d+:/;
  10348. /* istanbul ignore next */
  10349. function guardIESVGBug(attrs) {
  10350. const res = [];
  10351. for (let i = 0; i < attrs.length; i++) {
  10352. const attr = attrs[i];
  10353. if (!ieNSBug.test(attr.name)) {
  10354. attr.name = attr.name.replace(ieNSPrefix, '');
  10355. res.push(attr);
  10356. }
  10357. }
  10358. return res;
  10359. }
  10360. function checkForAliasModel(el, value) {
  10361. let _el = el;
  10362. while (_el) {
  10363. if (_el.for && _el.alias === value) {
  10364. warn(`<${el.tag} v-model="${value}">: ` +
  10365. `You are binding v-model directly to a v-for iteration alias. ` +
  10366. `This will not be able to modify the v-for source array because ` +
  10367. `writing to the alias is like modifying a function local variable. ` +
  10368. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10369. }
  10370. _el = _el.parent;
  10371. }
  10372. }
  10373. /**
  10374. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10375. * Turn this:
  10376. * <input v-model="data[type]" :type="type">
  10377. * into this:
  10378. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10379. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10380. * <input v-else :type="type" v-model="data[type]">
  10381. */
  10382. function preTransformNode(el, options) {
  10383. if (el.tag === 'input') {
  10384. const map = el.attrsMap;
  10385. if (!map['v-model']) {
  10386. return;
  10387. }
  10388. let typeBinding;
  10389. if (map[':type'] || map['v-bind:type']) {
  10390. typeBinding = getBindingAttr(el, 'type');
  10391. }
  10392. if (!map.type && !typeBinding && map['v-bind']) {
  10393. typeBinding = `(${map['v-bind']}).type`;
  10394. }
  10395. if (typeBinding) {
  10396. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10397. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10398. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10399. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10400. // 1. checkbox
  10401. const branch0 = cloneASTElement(el);
  10402. // process for on the main node
  10403. processFor(branch0);
  10404. addRawAttr(branch0, 'type', 'checkbox');
  10405. processElement(branch0, options);
  10406. branch0.processed = true; // prevent it from double-processed
  10407. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10408. addIfCondition(branch0, {
  10409. exp: branch0.if,
  10410. block: branch0
  10411. });
  10412. // 2. add radio else-if condition
  10413. const branch1 = cloneASTElement(el);
  10414. getAndRemoveAttr(branch1, 'v-for', true);
  10415. addRawAttr(branch1, 'type', 'radio');
  10416. processElement(branch1, options);
  10417. addIfCondition(branch0, {
  10418. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10419. block: branch1
  10420. });
  10421. // 3. other
  10422. const branch2 = cloneASTElement(el);
  10423. getAndRemoveAttr(branch2, 'v-for', true);
  10424. addRawAttr(branch2, ':type', typeBinding);
  10425. processElement(branch2, options);
  10426. addIfCondition(branch0, {
  10427. exp: ifCondition,
  10428. block: branch2
  10429. });
  10430. if (hasElse) {
  10431. branch0.else = true;
  10432. }
  10433. else if (elseIfCondition) {
  10434. branch0.elseif = elseIfCondition;
  10435. }
  10436. return branch0;
  10437. }
  10438. }
  10439. }
  10440. function cloneASTElement(el) {
  10441. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10442. }
  10443. var model = {
  10444. preTransformNode
  10445. };
  10446. var modules = [klass, style, model];
  10447. function text(el, dir) {
  10448. if (dir.value) {
  10449. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10450. }
  10451. }
  10452. function html(el, dir) {
  10453. if (dir.value) {
  10454. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10455. }
  10456. }
  10457. var directives = {
  10458. model: model$1,
  10459. text,
  10460. html
  10461. };
  10462. const baseOptions = {
  10463. expectHTML: true,
  10464. modules,
  10465. directives,
  10466. isPreTag,
  10467. isUnaryTag,
  10468. mustUseProp,
  10469. canBeLeftOpenTag,
  10470. isReservedTag,
  10471. getTagNamespace,
  10472. staticKeys: genStaticKeys$1(modules)
  10473. };
  10474. let isStaticKey;
  10475. let isPlatformReservedTag;
  10476. const genStaticKeysCached = cached(genStaticKeys);
  10477. /**
  10478. * Goal of the optimizer: walk the generated template AST tree
  10479. * and detect sub-trees that are purely static, i.e. parts of
  10480. * the DOM that never needs to change.
  10481. *
  10482. * Once we detect these sub-trees, we can:
  10483. *
  10484. * 1. Hoist them into constants, so that we no longer need to
  10485. * create fresh nodes for them on each re-render;
  10486. * 2. Completely skip them in the patching process.
  10487. */
  10488. function optimize(root, options) {
  10489. if (!root)
  10490. return;
  10491. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10492. isPlatformReservedTag = options.isReservedTag || no;
  10493. // first pass: mark all non-static nodes.
  10494. markStatic(root);
  10495. // second pass: mark static roots.
  10496. markStaticRoots(root, false);
  10497. }
  10498. function genStaticKeys(keys) {
  10499. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10500. (keys ? ',' + keys : ''));
  10501. }
  10502. function markStatic(node) {
  10503. node.static = isStatic(node);
  10504. if (node.type === 1) {
  10505. // do not make component slot content static. this avoids
  10506. // 1. components not able to mutate slot nodes
  10507. // 2. static slot content fails for hot-reloading
  10508. if (!isPlatformReservedTag(node.tag) &&
  10509. node.tag !== 'slot' &&
  10510. node.attrsMap['inline-template'] == null) {
  10511. return;
  10512. }
  10513. for (let i = 0, l = node.children.length; i < l; i++) {
  10514. const child = node.children[i];
  10515. markStatic(child);
  10516. if (!child.static) {
  10517. node.static = false;
  10518. }
  10519. }
  10520. if (node.ifConditions) {
  10521. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10522. const block = node.ifConditions[i].block;
  10523. markStatic(block);
  10524. if (!block.static) {
  10525. node.static = false;
  10526. }
  10527. }
  10528. }
  10529. }
  10530. }
  10531. function markStaticRoots(node, isInFor) {
  10532. if (node.type === 1) {
  10533. if (node.static || node.once) {
  10534. node.staticInFor = isInFor;
  10535. }
  10536. // For a node to qualify as a static root, it should have children that
  10537. // are not just static text. Otherwise the cost of hoisting out will
  10538. // outweigh the benefits and it's better off to just always render it fresh.
  10539. if (node.static &&
  10540. node.children.length &&
  10541. !(node.children.length === 1 && node.children[0].type === 3)) {
  10542. node.staticRoot = true;
  10543. return;
  10544. }
  10545. else {
  10546. node.staticRoot = false;
  10547. }
  10548. if (node.children) {
  10549. for (let i = 0, l = node.children.length; i < l; i++) {
  10550. markStaticRoots(node.children[i], isInFor || !!node.for);
  10551. }
  10552. }
  10553. if (node.ifConditions) {
  10554. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10555. markStaticRoots(node.ifConditions[i].block, isInFor);
  10556. }
  10557. }
  10558. }
  10559. }
  10560. function isStatic(node) {
  10561. if (node.type === 2) {
  10562. // expression
  10563. return false;
  10564. }
  10565. if (node.type === 3) {
  10566. // text
  10567. return true;
  10568. }
  10569. return !!(node.pre ||
  10570. (!node.hasBindings && // no dynamic bindings
  10571. !node.if &&
  10572. !node.for && // not v-if or v-for or v-else
  10573. !isBuiltInTag(node.tag) && // not a built-in
  10574. isPlatformReservedTag(node.tag) && // not a component
  10575. !isDirectChildOfTemplateFor(node) &&
  10576. Object.keys(node).every(isStaticKey)));
  10577. }
  10578. function isDirectChildOfTemplateFor(node) {
  10579. while (node.parent) {
  10580. node = node.parent;
  10581. if (node.tag !== 'template') {
  10582. return false;
  10583. }
  10584. if (node.for) {
  10585. return true;
  10586. }
  10587. }
  10588. return false;
  10589. }
  10590. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10591. const fnInvokeRE = /\([^)]*?\);*$/;
  10592. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10593. // KeyboardEvent.keyCode aliases
  10594. const keyCodes = {
  10595. esc: 27,
  10596. tab: 9,
  10597. enter: 13,
  10598. space: 32,
  10599. up: 38,
  10600. left: 37,
  10601. right: 39,
  10602. down: 40,
  10603. delete: [8, 46]
  10604. };
  10605. // KeyboardEvent.key aliases
  10606. const keyNames = {
  10607. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10608. esc: ['Esc', 'Escape'],
  10609. tab: 'Tab',
  10610. enter: 'Enter',
  10611. // #9112: IE11 uses `Spacebar` for Space key name.
  10612. space: [' ', 'Spacebar'],
  10613. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10614. up: ['Up', 'ArrowUp'],
  10615. left: ['Left', 'ArrowLeft'],
  10616. right: ['Right', 'ArrowRight'],
  10617. down: ['Down', 'ArrowDown'],
  10618. // #9112: IE11 uses `Del` for Delete key name.
  10619. delete: ['Backspace', 'Delete', 'Del']
  10620. };
  10621. // #4868: modifiers that prevent the execution of the listener
  10622. // need to explicitly return null so that we can determine whether to remove
  10623. // the listener for .once
  10624. const genGuard = condition => `if(${condition})return null;`;
  10625. const modifierCode = {
  10626. stop: '$event.stopPropagation();',
  10627. prevent: '$event.preventDefault();',
  10628. self: genGuard(`$event.target !== $event.currentTarget`),
  10629. ctrl: genGuard(`!$event.ctrlKey`),
  10630. shift: genGuard(`!$event.shiftKey`),
  10631. alt: genGuard(`!$event.altKey`),
  10632. meta: genGuard(`!$event.metaKey`),
  10633. left: genGuard(`'button' in $event && $event.button !== 0`),
  10634. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10635. right: genGuard(`'button' in $event && $event.button !== 2`)
  10636. };
  10637. function genHandlers(events, isNative) {
  10638. const prefix = isNative ? 'nativeOn:' : 'on:';
  10639. let staticHandlers = ``;
  10640. let dynamicHandlers = ``;
  10641. for (const name in events) {
  10642. const handlerCode = genHandler(events[name]);
  10643. //@ts-expect-error
  10644. if (events[name] && events[name].dynamic) {
  10645. dynamicHandlers += `${name},${handlerCode},`;
  10646. }
  10647. else {
  10648. staticHandlers += `"${name}":${handlerCode},`;
  10649. }
  10650. }
  10651. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10652. if (dynamicHandlers) {
  10653. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10654. }
  10655. else {
  10656. return prefix + staticHandlers;
  10657. }
  10658. }
  10659. function genHandler(handler) {
  10660. if (!handler) {
  10661. return 'function(){}';
  10662. }
  10663. if (Array.isArray(handler)) {
  10664. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10665. }
  10666. const isMethodPath = simplePathRE.test(handler.value);
  10667. const isFunctionExpression = fnExpRE.test(handler.value);
  10668. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10669. if (!handler.modifiers) {
  10670. if (isMethodPath || isFunctionExpression) {
  10671. return handler.value;
  10672. }
  10673. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10674. }
  10675. else {
  10676. let code = '';
  10677. let genModifierCode = '';
  10678. const keys = [];
  10679. for (const key in handler.modifiers) {
  10680. if (modifierCode[key]) {
  10681. genModifierCode += modifierCode[key];
  10682. // left/right
  10683. if (keyCodes[key]) {
  10684. keys.push(key);
  10685. }
  10686. }
  10687. else if (key === 'exact') {
  10688. const modifiers = handler.modifiers;
  10689. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10690. .filter(keyModifier => !modifiers[keyModifier])
  10691. .map(keyModifier => `$event.${keyModifier}Key`)
  10692. .join('||'));
  10693. }
  10694. else {
  10695. keys.push(key);
  10696. }
  10697. }
  10698. if (keys.length) {
  10699. code += genKeyFilter(keys);
  10700. }
  10701. // Make sure modifiers like prevent and stop get executed after key filtering
  10702. if (genModifierCode) {
  10703. code += genModifierCode;
  10704. }
  10705. const handlerCode = isMethodPath
  10706. ? `return ${handler.value}.apply(null, arguments)`
  10707. : isFunctionExpression
  10708. ? `return (${handler.value}).apply(null, arguments)`
  10709. : isFunctionInvocation
  10710. ? `return ${handler.value}`
  10711. : handler.value;
  10712. return `function($event){${code}${handlerCode}}`;
  10713. }
  10714. }
  10715. function genKeyFilter(keys) {
  10716. return (
  10717. // make sure the key filters only apply to KeyboardEvents
  10718. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10719. // key events that do not have keyCode property...
  10720. `if(!$event.type.indexOf('key')&&` +
  10721. `${keys.map(genFilterCode).join('&&')})return null;`);
  10722. }
  10723. function genFilterCode(key) {
  10724. const keyVal = parseInt(key, 10);
  10725. if (keyVal) {
  10726. return `$event.keyCode!==${keyVal}`;
  10727. }
  10728. const keyCode = keyCodes[key];
  10729. const keyName = keyNames[key];
  10730. return (`_k($event.keyCode,` +
  10731. `${JSON.stringify(key)},` +
  10732. `${JSON.stringify(keyCode)},` +
  10733. `$event.key,` +
  10734. `${JSON.stringify(keyName)}` +
  10735. `)`);
  10736. }
  10737. function on(el, dir) {
  10738. if (dir.modifiers) {
  10739. warn$2(`v-on without argument does not support modifiers.`);
  10740. }
  10741. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10742. }
  10743. function bind(el, dir) {
  10744. el.wrapData = (code) => {
  10745. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10746. };
  10747. }
  10748. var baseDirectives = {
  10749. on,
  10750. bind,
  10751. cloak: noop
  10752. };
  10753. class CodegenState {
  10754. constructor(options) {
  10755. this.options = options;
  10756. this.warn = options.warn || baseWarn;
  10757. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10758. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10759. this.directives = extend(extend({}, baseDirectives), options.directives);
  10760. const isReservedTag = options.isReservedTag || no;
  10761. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10762. this.onceId = 0;
  10763. this.staticRenderFns = [];
  10764. this.pre = false;
  10765. }
  10766. }
  10767. function generate(ast, options) {
  10768. const state = new CodegenState(options);
  10769. // fix #11483, Root level <script> tags should not be rendered.
  10770. const code = ast
  10771. ? ast.tag === 'script'
  10772. ? 'null'
  10773. : genElement(ast, state)
  10774. : '_c("div")';
  10775. return {
  10776. render: `with(this){return ${code}}`,
  10777. staticRenderFns: state.staticRenderFns
  10778. };
  10779. }
  10780. function genElement(el, state) {
  10781. if (el.parent) {
  10782. el.pre = el.pre || el.parent.pre;
  10783. }
  10784. if (el.staticRoot && !el.staticProcessed) {
  10785. return genStatic(el, state);
  10786. }
  10787. else if (el.once && !el.onceProcessed) {
  10788. return genOnce(el, state);
  10789. }
  10790. else if (el.for && !el.forProcessed) {
  10791. return genFor(el, state);
  10792. }
  10793. else if (el.if && !el.ifProcessed) {
  10794. return genIf(el, state);
  10795. }
  10796. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10797. return genChildren(el, state) || 'void 0';
  10798. }
  10799. else if (el.tag === 'slot') {
  10800. return genSlot(el, state);
  10801. }
  10802. else {
  10803. // component or element
  10804. let code;
  10805. if (el.component) {
  10806. code = genComponent(el.component, el, state);
  10807. }
  10808. else {
  10809. let data;
  10810. const maybeComponent = state.maybeComponent(el);
  10811. if (!el.plain || (el.pre && maybeComponent)) {
  10812. data = genData(el, state);
  10813. }
  10814. let tag;
  10815. // check if this is a component in <script setup>
  10816. const bindings = state.options.bindings;
  10817. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10818. tag = checkBindingType(bindings, el.tag);
  10819. }
  10820. if (!tag)
  10821. tag = `'${el.tag}'`;
  10822. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10823. code = `_c(${tag}${data ? `,${data}` : '' // data
  10824. }${children ? `,${children}` : '' // children
  10825. })`;
  10826. }
  10827. // module transforms
  10828. for (let i = 0; i < state.transforms.length; i++) {
  10829. code = state.transforms[i](el, code);
  10830. }
  10831. return code;
  10832. }
  10833. }
  10834. function checkBindingType(bindings, key) {
  10835. const camelName = camelize(key);
  10836. const PascalName = capitalize(camelName);
  10837. const checkType = (type) => {
  10838. if (bindings[key] === type) {
  10839. return key;
  10840. }
  10841. if (bindings[camelName] === type) {
  10842. return camelName;
  10843. }
  10844. if (bindings[PascalName] === type) {
  10845. return PascalName;
  10846. }
  10847. };
  10848. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10849. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10850. if (fromConst) {
  10851. return fromConst;
  10852. }
  10853. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10854. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10855. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10856. if (fromMaybeRef) {
  10857. return fromMaybeRef;
  10858. }
  10859. }
  10860. // hoist static sub-trees out
  10861. function genStatic(el, state) {
  10862. el.staticProcessed = true;
  10863. // Some elements (templates) need to behave differently inside of a v-pre
  10864. // node. All pre nodes are static roots, so we can use this as a location to
  10865. // wrap a state change and reset it upon exiting the pre node.
  10866. const originalPreState = state.pre;
  10867. if (el.pre) {
  10868. state.pre = el.pre;
  10869. }
  10870. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10871. state.pre = originalPreState;
  10872. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10873. }
  10874. // v-once
  10875. function genOnce(el, state) {
  10876. el.onceProcessed = true;
  10877. if (el.if && !el.ifProcessed) {
  10878. return genIf(el, state);
  10879. }
  10880. else if (el.staticInFor) {
  10881. let key = '';
  10882. let parent = el.parent;
  10883. while (parent) {
  10884. if (parent.for) {
  10885. key = parent.key;
  10886. break;
  10887. }
  10888. parent = parent.parent;
  10889. }
  10890. if (!key) {
  10891. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10892. return genElement(el, state);
  10893. }
  10894. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10895. }
  10896. else {
  10897. return genStatic(el, state);
  10898. }
  10899. }
  10900. function genIf(el, state, altGen, altEmpty) {
  10901. el.ifProcessed = true; // avoid recursion
  10902. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10903. }
  10904. function genIfConditions(conditions, state, altGen, altEmpty) {
  10905. if (!conditions.length) {
  10906. return altEmpty || '_e()';
  10907. }
  10908. const condition = conditions.shift();
  10909. if (condition.exp) {
  10910. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10911. }
  10912. else {
  10913. return `${genTernaryExp(condition.block)}`;
  10914. }
  10915. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10916. function genTernaryExp(el) {
  10917. return altGen
  10918. ? altGen(el, state)
  10919. : el.once
  10920. ? genOnce(el, state)
  10921. : genElement(el, state);
  10922. }
  10923. }
  10924. function genFor(el, state, altGen, altHelper) {
  10925. const exp = el.for;
  10926. const alias = el.alias;
  10927. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10928. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10929. if (state.maybeComponent(el) &&
  10930. el.tag !== 'slot' &&
  10931. el.tag !== 'template' &&
  10932. !el.key) {
  10933. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10934. `v-for should have explicit keys. ` +
  10935. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10936. }
  10937. el.forProcessed = true; // avoid recursion
  10938. return (`${altHelper || '_l'}((${exp}),` +
  10939. `function(${alias}${iterator1}${iterator2}){` +
  10940. `return ${(altGen || genElement)(el, state)}` +
  10941. '})');
  10942. }
  10943. function genData(el, state) {
  10944. let data = '{';
  10945. // directives first.
  10946. // directives may mutate the el's other properties before they are generated.
  10947. const dirs = genDirectives(el, state);
  10948. if (dirs)
  10949. data += dirs + ',';
  10950. // key
  10951. if (el.key) {
  10952. data += `key:${el.key},`;
  10953. }
  10954. // ref
  10955. if (el.ref) {
  10956. data += `ref:${el.ref},`;
  10957. }
  10958. if (el.refInFor) {
  10959. data += `refInFor:true,`;
  10960. }
  10961. // pre
  10962. if (el.pre) {
  10963. data += `pre:true,`;
  10964. }
  10965. // record original tag name for components using "is" attribute
  10966. if (el.component) {
  10967. data += `tag:"${el.tag}",`;
  10968. }
  10969. // module data generation functions
  10970. for (let i = 0; i < state.dataGenFns.length; i++) {
  10971. data += state.dataGenFns[i](el);
  10972. }
  10973. // attributes
  10974. if (el.attrs) {
  10975. data += `attrs:${genProps(el.attrs)},`;
  10976. }
  10977. // DOM props
  10978. if (el.props) {
  10979. data += `domProps:${genProps(el.props)},`;
  10980. }
  10981. // event handlers
  10982. if (el.events) {
  10983. data += `${genHandlers(el.events, false)},`;
  10984. }
  10985. if (el.nativeEvents) {
  10986. data += `${genHandlers(el.nativeEvents, true)},`;
  10987. }
  10988. // slot target
  10989. // only for non-scoped slots
  10990. if (el.slotTarget && !el.slotScope) {
  10991. data += `slot:${el.slotTarget},`;
  10992. }
  10993. // scoped slots
  10994. if (el.scopedSlots) {
  10995. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10996. }
  10997. // component v-model
  10998. if (el.model) {
  10999. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  11000. }
  11001. // inline-template
  11002. if (el.inlineTemplate) {
  11003. const inlineTemplate = genInlineTemplate(el, state);
  11004. if (inlineTemplate) {
  11005. data += `${inlineTemplate},`;
  11006. }
  11007. }
  11008. data = data.replace(/,$/, '') + '}';
  11009. // v-bind dynamic argument wrap
  11010. // v-bind with dynamic arguments must be applied using the same v-bind object
  11011. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  11012. if (el.dynamicAttrs) {
  11013. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  11014. }
  11015. // v-bind data wrap
  11016. if (el.wrapData) {
  11017. data = el.wrapData(data);
  11018. }
  11019. // v-on data wrap
  11020. if (el.wrapListeners) {
  11021. data = el.wrapListeners(data);
  11022. }
  11023. return data;
  11024. }
  11025. function genDirectives(el, state) {
  11026. const dirs = el.directives;
  11027. if (!dirs)
  11028. return;
  11029. let res = 'directives:[';
  11030. let hasRuntime = false;
  11031. let i, l, dir, needRuntime;
  11032. for (i = 0, l = dirs.length; i < l; i++) {
  11033. dir = dirs[i];
  11034. needRuntime = true;
  11035. const gen = state.directives[dir.name];
  11036. if (gen) {
  11037. // compile-time directive that manipulates AST.
  11038. // returns true if it also needs a runtime counterpart.
  11039. needRuntime = !!gen(el, dir, state.warn);
  11040. }
  11041. if (needRuntime) {
  11042. hasRuntime = true;
  11043. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11044. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11045. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11046. }
  11047. }
  11048. if (hasRuntime) {
  11049. return res.slice(0, -1) + ']';
  11050. }
  11051. }
  11052. function genInlineTemplate(el, state) {
  11053. const ast = el.children[0];
  11054. if ((el.children.length !== 1 || ast.type !== 1)) {
  11055. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11056. }
  11057. if (ast && ast.type === 1) {
  11058. const inlineRenderFns = generate(ast, state.options);
  11059. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11060. .map(code => `function(){${code}}`)
  11061. .join(',')}]}`;
  11062. }
  11063. }
  11064. function genScopedSlots(el, slots, state) {
  11065. // by default scoped slots are considered "stable", this allows child
  11066. // components with only scoped slots to skip forced updates from parent.
  11067. // but in some cases we have to bail-out of this optimization
  11068. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11069. let needsForceUpdate = el.for ||
  11070. Object.keys(slots).some(key => {
  11071. const slot = slots[key];
  11072. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11073. );
  11074. });
  11075. // #9534: if a component with scoped slots is inside a conditional branch,
  11076. // it's possible for the same component to be reused but with different
  11077. // compiled slot content. To avoid that, we generate a unique key based on
  11078. // the generated code of all the slot contents.
  11079. let needsKey = !!el.if;
  11080. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11081. // disconnected due to the intermediate scope variable)
  11082. // #9438, #9506
  11083. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11084. // and skip force updating ones that do not actually use scope variables.
  11085. if (!needsForceUpdate) {
  11086. let parent = el.parent;
  11087. while (parent) {
  11088. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11089. parent.for) {
  11090. needsForceUpdate = true;
  11091. break;
  11092. }
  11093. if (parent.if) {
  11094. needsKey = true;
  11095. }
  11096. parent = parent.parent;
  11097. }
  11098. }
  11099. const generatedSlots = Object.keys(slots)
  11100. .map(key => genScopedSlot(slots[key], state))
  11101. .join(',');
  11102. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11103. }
  11104. function hash(str) {
  11105. let hash = 5381;
  11106. let i = str.length;
  11107. while (i) {
  11108. hash = (hash * 33) ^ str.charCodeAt(--i);
  11109. }
  11110. return hash >>> 0;
  11111. }
  11112. function containsSlotChild(el) {
  11113. if (el.type === 1) {
  11114. if (el.tag === 'slot') {
  11115. return true;
  11116. }
  11117. return el.children.some(containsSlotChild);
  11118. }
  11119. return false;
  11120. }
  11121. function genScopedSlot(el, state) {
  11122. const isLegacySyntax = el.attrsMap['slot-scope'];
  11123. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11124. return genIf(el, state, genScopedSlot, `null`);
  11125. }
  11126. if (el.for && !el.forProcessed) {
  11127. return genFor(el, state, genScopedSlot);
  11128. }
  11129. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11130. const fn = `function(${slotScope}){` +
  11131. `return ${el.tag === 'template'
  11132. ? el.if && isLegacySyntax
  11133. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11134. : genChildren(el, state) || 'undefined'
  11135. : genElement(el, state)}}`;
  11136. // reverse proxy v-slot without scope on this.$slots
  11137. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11138. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11139. }
  11140. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11141. const children = el.children;
  11142. if (children.length) {
  11143. const el = children[0];
  11144. // optimize single v-for
  11145. if (children.length === 1 &&
  11146. el.for &&
  11147. el.tag !== 'template' &&
  11148. el.tag !== 'slot') {
  11149. const normalizationType = checkSkip
  11150. ? state.maybeComponent(el)
  11151. ? `,1`
  11152. : `,0`
  11153. : ``;
  11154. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11155. }
  11156. const normalizationType = checkSkip
  11157. ? getNormalizationType(children, state.maybeComponent)
  11158. : 0;
  11159. const gen = altGenNode || genNode;
  11160. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11161. }
  11162. }
  11163. // determine the normalization needed for the children array.
  11164. // 0: no normalization needed
  11165. // 1: simple normalization needed (possible 1-level deep nested array)
  11166. // 2: full normalization needed
  11167. function getNormalizationType(children, maybeComponent) {
  11168. let res = 0;
  11169. for (let i = 0; i < children.length; i++) {
  11170. const el = children[i];
  11171. if (el.type !== 1) {
  11172. continue;
  11173. }
  11174. if (needsNormalization(el) ||
  11175. (el.ifConditions &&
  11176. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11177. res = 2;
  11178. break;
  11179. }
  11180. if (maybeComponent(el) ||
  11181. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11182. res = 1;
  11183. }
  11184. }
  11185. return res;
  11186. }
  11187. function needsNormalization(el) {
  11188. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11189. }
  11190. function genNode(node, state) {
  11191. if (node.type === 1) {
  11192. return genElement(node, state);
  11193. }
  11194. else if (node.type === 3 && node.isComment) {
  11195. return genComment(node);
  11196. }
  11197. else {
  11198. return genText(node);
  11199. }
  11200. }
  11201. function genText(text) {
  11202. return `_v(${text.type === 2
  11203. ? text.expression // no need for () because already wrapped in _s()
  11204. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11205. }
  11206. function genComment(comment) {
  11207. return `_e(${JSON.stringify(comment.text)})`;
  11208. }
  11209. function genSlot(el, state) {
  11210. const slotName = el.slotName || '"default"';
  11211. const children = genChildren(el, state);
  11212. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11213. const attrs = el.attrs || el.dynamicAttrs
  11214. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11215. // slot props are camelized
  11216. name: camelize(attr.name),
  11217. value: attr.value,
  11218. dynamic: attr.dynamic
  11219. })))
  11220. : null;
  11221. const bind = el.attrsMap['v-bind'];
  11222. if ((attrs || bind) && !children) {
  11223. res += `,null`;
  11224. }
  11225. if (attrs) {
  11226. res += `,${attrs}`;
  11227. }
  11228. if (bind) {
  11229. res += `${attrs ? '' : ',null'},${bind}`;
  11230. }
  11231. return res + ')';
  11232. }
  11233. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11234. function genComponent(componentName, el, state) {
  11235. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11236. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11237. }
  11238. function genProps(props) {
  11239. let staticProps = ``;
  11240. let dynamicProps = ``;
  11241. for (let i = 0; i < props.length; i++) {
  11242. const prop = props[i];
  11243. const value = transformSpecialNewlines(prop.value);
  11244. if (prop.dynamic) {
  11245. dynamicProps += `${prop.name},${value},`;
  11246. }
  11247. else {
  11248. staticProps += `"${prop.name}":${value},`;
  11249. }
  11250. }
  11251. staticProps = `{${staticProps.slice(0, -1)}}`;
  11252. if (dynamicProps) {
  11253. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11254. }
  11255. else {
  11256. return staticProps;
  11257. }
  11258. }
  11259. // #3895, #4268
  11260. function transformSpecialNewlines(text) {
  11261. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11262. }
  11263. // these keywords should not appear inside expressions, but operators like
  11264. // typeof, instanceof and in are allowed
  11265. const prohibitedKeywordRE = new RegExp('\\b' +
  11266. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11267. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11268. 'extends,finally,continue,debugger,function,arguments')
  11269. .split(',')
  11270. .join('\\b|\\b') +
  11271. '\\b');
  11272. // these unary operators should not be used as property/method names
  11273. const unaryOperatorsRE = new RegExp('\\b' +
  11274. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11275. '\\s*\\([^\\)]*\\)');
  11276. // strip strings in expressions
  11277. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11278. // detect problematic expressions in a template
  11279. function detectErrors(ast, warn) {
  11280. if (ast) {
  11281. checkNode(ast, warn);
  11282. }
  11283. }
  11284. function checkNode(node, warn) {
  11285. if (node.type === 1) {
  11286. for (const name in node.attrsMap) {
  11287. if (dirRE.test(name)) {
  11288. const value = node.attrsMap[name];
  11289. if (value) {
  11290. const range = node.rawAttrsMap[name];
  11291. if (name === 'v-for') {
  11292. checkFor(node, `v-for="${value}"`, warn, range);
  11293. }
  11294. else if (name === 'v-slot' || name[0] === '#') {
  11295. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11296. }
  11297. else if (onRE.test(name)) {
  11298. checkEvent(value, `${name}="${value}"`, warn, range);
  11299. }
  11300. else {
  11301. checkExpression(value, `${name}="${value}"`, warn, range);
  11302. }
  11303. }
  11304. }
  11305. }
  11306. if (node.children) {
  11307. for (let i = 0; i < node.children.length; i++) {
  11308. checkNode(node.children[i], warn);
  11309. }
  11310. }
  11311. }
  11312. else if (node.type === 2) {
  11313. checkExpression(node.expression, node.text, warn, node);
  11314. }
  11315. }
  11316. function checkEvent(exp, text, warn, range) {
  11317. const stripped = exp.replace(stripStringRE, '');
  11318. const keywordMatch = stripped.match(unaryOperatorsRE);
  11319. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11320. warn(`avoid using JavaScript unary operator as property name: ` +
  11321. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11322. }
  11323. checkExpression(exp, text, warn, range);
  11324. }
  11325. function checkFor(node, text, warn, range) {
  11326. checkExpression(node.for || '', text, warn, range);
  11327. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11328. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11329. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11330. }
  11331. function checkIdentifier(ident, type, text, warn, range) {
  11332. if (typeof ident === 'string') {
  11333. try {
  11334. new Function(`var ${ident}=_`);
  11335. }
  11336. catch (e) {
  11337. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11338. }
  11339. }
  11340. }
  11341. function checkExpression(exp, text, warn, range) {
  11342. try {
  11343. new Function(`return ${exp}`);
  11344. }
  11345. catch (e) {
  11346. const keywordMatch = exp
  11347. .replace(stripStringRE, '')
  11348. .match(prohibitedKeywordRE);
  11349. if (keywordMatch) {
  11350. warn(`avoid using JavaScript keyword as property name: ` +
  11351. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11352. }
  11353. else {
  11354. warn(`invalid expression: ${e.message} in\n\n` +
  11355. ` ${exp}\n\n` +
  11356. ` Raw expression: ${text.trim()}\n`, range);
  11357. }
  11358. }
  11359. }
  11360. function checkFunctionParameterExpression(exp, text, warn, range) {
  11361. try {
  11362. new Function(exp, '');
  11363. }
  11364. catch (e) {
  11365. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11366. ` ${exp}\n\n` +
  11367. ` Raw expression: ${text.trim()}\n`, range);
  11368. }
  11369. }
  11370. const range = 2;
  11371. function generateCodeFrame(source, start = 0, end = source.length) {
  11372. const lines = source.split(/\r?\n/);
  11373. let count = 0;
  11374. const res = [];
  11375. for (let i = 0; i < lines.length; i++) {
  11376. count += lines[i].length + 1;
  11377. if (count >= start) {
  11378. for (let j = i - range; j <= i + range || end > count; j++) {
  11379. if (j < 0 || j >= lines.length)
  11380. continue;
  11381. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11382. const lineLength = lines[j].length;
  11383. if (j === i) {
  11384. // push underline
  11385. const pad = start - (count - lineLength) + 1;
  11386. const length = end > count ? lineLength - pad : end - start;
  11387. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11388. }
  11389. else if (j > i) {
  11390. if (end > count) {
  11391. const length = Math.min(end - count, lineLength);
  11392. res.push(` | ` + repeat(`^`, length));
  11393. }
  11394. count += lineLength + 1;
  11395. }
  11396. }
  11397. break;
  11398. }
  11399. }
  11400. return res.join('\n');
  11401. }
  11402. function repeat(str, n) {
  11403. let result = '';
  11404. if (n > 0) {
  11405. // eslint-disable-next-line no-constant-condition
  11406. while (true) {
  11407. // eslint-disable-line
  11408. if (n & 1)
  11409. result += str;
  11410. n >>>= 1;
  11411. if (n <= 0)
  11412. break;
  11413. str += str;
  11414. }
  11415. }
  11416. return result;
  11417. }
  11418. function createFunction(code, errors) {
  11419. try {
  11420. return new Function(code);
  11421. }
  11422. catch (err) {
  11423. errors.push({ err, code });
  11424. return noop;
  11425. }
  11426. }
  11427. function createCompileToFunctionFn(compile) {
  11428. const cache = Object.create(null);
  11429. return function compileToFunctions(template, options, vm) {
  11430. options = extend({}, options);
  11431. const warn = options.warn || warn$2;
  11432. delete options.warn;
  11433. /* istanbul ignore if */
  11434. {
  11435. // detect possible CSP restriction
  11436. try {
  11437. new Function('return 1');
  11438. }
  11439. catch (e) {
  11440. if (e.toString().match(/unsafe-eval|CSP/)) {
  11441. warn('It seems you are using the standalone build of Vue.js in an ' +
  11442. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11443. 'The template compiler cannot work in this environment. Consider ' +
  11444. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11445. 'templates into render functions.');
  11446. }
  11447. }
  11448. }
  11449. // check cache
  11450. const key = options.delimiters
  11451. ? String(options.delimiters) + template
  11452. : template;
  11453. if (cache[key]) {
  11454. return cache[key];
  11455. }
  11456. // compile
  11457. const compiled = compile(template, options);
  11458. // check compilation errors/tips
  11459. {
  11460. if (compiled.errors && compiled.errors.length) {
  11461. if (options.outputSourceRange) {
  11462. compiled.errors.forEach(e => {
  11463. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11464. generateCodeFrame(template, e.start, e.end), vm);
  11465. });
  11466. }
  11467. else {
  11468. warn(`Error compiling template:\n\n${template}\n\n` +
  11469. compiled.errors.map(e => `- ${e}`).join('\n') +
  11470. '\n', vm);
  11471. }
  11472. }
  11473. if (compiled.tips && compiled.tips.length) {
  11474. if (options.outputSourceRange) {
  11475. compiled.tips.forEach(e => tip(e.msg, vm));
  11476. }
  11477. else {
  11478. compiled.tips.forEach(msg => tip(msg, vm));
  11479. }
  11480. }
  11481. }
  11482. // turn code into functions
  11483. const res = {};
  11484. const fnGenErrors = [];
  11485. res.render = createFunction(compiled.render, fnGenErrors);
  11486. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11487. return createFunction(code, fnGenErrors);
  11488. });
  11489. // check function generation errors.
  11490. // this should only happen if there is a bug in the compiler itself.
  11491. // mostly for codegen development use
  11492. /* istanbul ignore if */
  11493. {
  11494. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11495. warn(`Failed to generate render function:\n\n` +
  11496. fnGenErrors
  11497. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11498. .join('\n'), vm);
  11499. }
  11500. }
  11501. return (cache[key] = res);
  11502. };
  11503. }
  11504. function createCompilerCreator(baseCompile) {
  11505. return function createCompiler(baseOptions) {
  11506. function compile(template, options) {
  11507. const finalOptions = Object.create(baseOptions);
  11508. const errors = [];
  11509. const tips = [];
  11510. let warn = (msg, range, tip) => {
  11511. (tip ? tips : errors).push(msg);
  11512. };
  11513. if (options) {
  11514. if (options.outputSourceRange) {
  11515. // $flow-disable-line
  11516. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11517. warn = (msg, range, tip) => {
  11518. const data = typeof msg === 'string' ? { msg } : msg;
  11519. if (range) {
  11520. if (range.start != null) {
  11521. data.start = range.start + leadingSpaceLength;
  11522. }
  11523. if (range.end != null) {
  11524. data.end = range.end + leadingSpaceLength;
  11525. }
  11526. }
  11527. (tip ? tips : errors).push(data);
  11528. };
  11529. }
  11530. // merge custom modules
  11531. if (options.modules) {
  11532. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11533. }
  11534. // merge custom directives
  11535. if (options.directives) {
  11536. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11537. }
  11538. // copy other options
  11539. for (const key in options) {
  11540. if (key !== 'modules' && key !== 'directives') {
  11541. finalOptions[key] = options[key];
  11542. }
  11543. }
  11544. }
  11545. finalOptions.warn = warn;
  11546. const compiled = baseCompile(template.trim(), finalOptions);
  11547. {
  11548. detectErrors(compiled.ast, warn);
  11549. }
  11550. compiled.errors = errors;
  11551. compiled.tips = tips;
  11552. return compiled;
  11553. }
  11554. return {
  11555. compile,
  11556. compileToFunctions: createCompileToFunctionFn(compile)
  11557. };
  11558. };
  11559. }
  11560. // `createCompilerCreator` allows creating compilers that use alternative
  11561. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11562. // Here we just export a default compiler using the default parts.
  11563. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11564. const ast = parse(template.trim(), options);
  11565. if (options.optimize !== false) {
  11566. optimize(ast, options);
  11567. }
  11568. const code = generate(ast, options);
  11569. return {
  11570. ast,
  11571. render: code.render,
  11572. staticRenderFns: code.staticRenderFns
  11573. };
  11574. });
  11575. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11576. // check whether current browser encodes a char inside attribute values
  11577. let div;
  11578. function getShouldDecode(href) {
  11579. div = div || document.createElement('div');
  11580. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11581. return div.innerHTML.indexOf('&#10;') > 0;
  11582. }
  11583. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11584. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11585. // #6828: chrome encodes content in a[href]
  11586. const shouldDecodeNewlinesForHref = inBrowser
  11587. ? getShouldDecode(true)
  11588. : false;
  11589. const idToTemplate = cached(id => {
  11590. const el = query(id);
  11591. return el && el.innerHTML;
  11592. });
  11593. const mount = Vue.prototype.$mount;
  11594. Vue.prototype.$mount = function (el, hydrating) {
  11595. el = el && query(el);
  11596. /* istanbul ignore if */
  11597. if (el === document.body || el === document.documentElement) {
  11598. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11599. return this;
  11600. }
  11601. const options = this.$options;
  11602. // resolve template/el and convert to render function
  11603. if (!options.render) {
  11604. let template = options.template;
  11605. if (template) {
  11606. if (typeof template === 'string') {
  11607. if (template.charAt(0) === '#') {
  11608. template = idToTemplate(template);
  11609. /* istanbul ignore if */
  11610. if (!template) {
  11611. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11612. }
  11613. }
  11614. }
  11615. else if (template.nodeType) {
  11616. template = template.innerHTML;
  11617. }
  11618. else {
  11619. {
  11620. warn$2('invalid template option:' + template, this);
  11621. }
  11622. return this;
  11623. }
  11624. }
  11625. else if (el) {
  11626. // @ts-expect-error
  11627. template = getOuterHTML(el);
  11628. }
  11629. if (template) {
  11630. /* istanbul ignore if */
  11631. if (config.performance && mark) {
  11632. mark('compile');
  11633. }
  11634. const { render, staticRenderFns } = compileToFunctions(template, {
  11635. outputSourceRange: true,
  11636. shouldDecodeNewlines,
  11637. shouldDecodeNewlinesForHref,
  11638. delimiters: options.delimiters,
  11639. comments: options.comments
  11640. }, this);
  11641. options.render = render;
  11642. options.staticRenderFns = staticRenderFns;
  11643. /* istanbul ignore if */
  11644. if (config.performance && mark) {
  11645. mark('compile end');
  11646. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11647. }
  11648. }
  11649. }
  11650. return mount.call(this, el, hydrating);
  11651. };
  11652. /**
  11653. * Get outerHTML of elements, taking care
  11654. * of SVG elements in IE as well.
  11655. */
  11656. function getOuterHTML(el) {
  11657. if (el.outerHTML) {
  11658. return el.outerHTML;
  11659. }
  11660. else {
  11661. const container = document.createElement('div');
  11662. container.appendChild(el.cloneNode(true));
  11663. return container.innerHTML;
  11664. }
  11665. }
  11666. Vue.compile = compileToFunctions;
  11667. // export type EffectScheduler = (...args: any[]) => any
  11668. /**
  11669. * @internal since we are not exposing this in Vue 2, it's used only for
  11670. * internal testing.
  11671. */
  11672. function effect(fn, scheduler) {
  11673. const watcher = new Watcher(currentInstance, fn, noop, {
  11674. sync: true
  11675. });
  11676. if (scheduler) {
  11677. watcher.update = () => {
  11678. scheduler(() => watcher.run());
  11679. };
  11680. }
  11681. }
  11682. extend(Vue, vca);
  11683. Vue.effect = effect;
  11684. module.exports = Vue;