vue.common.dev.js 390 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804
  1. /*!
  2. * Vue.js v2.7.15
  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, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind$1 = Function.prototype.bind ? nativeBind : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray(list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret;
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend(to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to;
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject(arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res;
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop(a, b, c) { }
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys$1(modules) {
  243. return modules
  244. .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
  245. .join(',');
  246. }
  247. /**
  248. * Check if two values are loosely equal - that is,
  249. * if they are plain objects, do they have the same shape?
  250. */
  251. function looseEqual(a, b) {
  252. if (a === b)
  253. return true;
  254. const isObjectA = isObject(a);
  255. const isObjectB = isObject(b);
  256. if (isObjectA && isObjectB) {
  257. try {
  258. const isArrayA = Array.isArray(a);
  259. const isArrayB = Array.isArray(b);
  260. if (isArrayA && isArrayB) {
  261. return (a.length === b.length &&
  262. a.every((e, i) => {
  263. return looseEqual(e, b[i]);
  264. }));
  265. }
  266. else if (a instanceof Date && b instanceof Date) {
  267. return a.getTime() === b.getTime();
  268. }
  269. else if (!isArrayA && !isArrayB) {
  270. const keysA = Object.keys(a);
  271. const keysB = Object.keys(b);
  272. return (keysA.length === keysB.length &&
  273. keysA.every(key => {
  274. return looseEqual(a[key], b[key]);
  275. }));
  276. }
  277. else {
  278. /* istanbul ignore next */
  279. return false;
  280. }
  281. }
  282. catch (e) {
  283. /* istanbul ignore next */
  284. return false;
  285. }
  286. }
  287. else if (!isObjectA && !isObjectB) {
  288. return String(a) === String(b);
  289. }
  290. else {
  291. return false;
  292. }
  293. }
  294. /**
  295. * Return the first index at which a loosely equal value can be
  296. * found in the array (if value is a plain object, the array must
  297. * contain an object of the same shape), or -1 if it is not present.
  298. */
  299. function looseIndexOf(arr, val) {
  300. for (let i = 0; i < arr.length; i++) {
  301. if (looseEqual(arr[i], val))
  302. return i;
  303. }
  304. return -1;
  305. }
  306. /**
  307. * Ensure a function is called only once.
  308. */
  309. function once(fn) {
  310. let called = false;
  311. return function () {
  312. if (!called) {
  313. called = true;
  314. fn.apply(this, arguments);
  315. }
  316. };
  317. }
  318. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  319. function hasChanged(x, y) {
  320. if (x === y) {
  321. return x === 0 && 1 / x !== 1 / y;
  322. }
  323. else {
  324. return x === x || y === y;
  325. }
  326. }
  327. const SSR_ATTR = 'data-server-rendered';
  328. const ASSET_TYPES = ['component', 'directive', 'filter'];
  329. const LIFECYCLE_HOOKS = [
  330. 'beforeCreate',
  331. 'created',
  332. 'beforeMount',
  333. 'mounted',
  334. 'beforeUpdate',
  335. 'updated',
  336. 'beforeDestroy',
  337. 'destroyed',
  338. 'activated',
  339. 'deactivated',
  340. 'errorCaptured',
  341. 'serverPrefetch',
  342. 'renderTracked',
  343. 'renderTriggered'
  344. ];
  345. var config = {
  346. /**
  347. * Option merge strategies (used in core/util/options)
  348. */
  349. // $flow-disable-line
  350. optionMergeStrategies: Object.create(null),
  351. /**
  352. * Whether to suppress warnings.
  353. */
  354. silent: false,
  355. /**
  356. * Show production mode tip message on boot?
  357. */
  358. productionTip: true,
  359. /**
  360. * Whether to enable devtools
  361. */
  362. devtools: true,
  363. /**
  364. * Whether to record perf
  365. */
  366. performance: false,
  367. /**
  368. * Error handler for watcher errors
  369. */
  370. errorHandler: null,
  371. /**
  372. * Warn handler for watcher warns
  373. */
  374. warnHandler: null,
  375. /**
  376. * Ignore certain custom elements
  377. */
  378. ignoredElements: [],
  379. /**
  380. * Custom user key aliases for v-on
  381. */
  382. // $flow-disable-line
  383. keyCodes: Object.create(null),
  384. /**
  385. * Check if a tag is reserved so that it cannot be registered as a
  386. * component. This is platform-dependent and may be overwritten.
  387. */
  388. isReservedTag: no,
  389. /**
  390. * Check if an attribute is reserved so that it cannot be used as a component
  391. * prop. This is platform-dependent and may be overwritten.
  392. */
  393. isReservedAttr: no,
  394. /**
  395. * Check if a tag is an unknown element.
  396. * Platform-dependent.
  397. */
  398. isUnknownElement: no,
  399. /**
  400. * Get the namespace of an element
  401. */
  402. getTagNamespace: noop,
  403. /**
  404. * Parse the real tag name for the specific platform.
  405. */
  406. parsePlatformTagName: identity,
  407. /**
  408. * Check if an attribute must be bound using property, e.g. value
  409. * Platform-dependent.
  410. */
  411. mustUseProp: no,
  412. /**
  413. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  414. * This will significantly reduce performance if set to false.
  415. */
  416. async: true,
  417. /**
  418. * Exposed for legacy reasons
  419. */
  420. _lifecycleHooks: LIFECYCLE_HOOKS
  421. };
  422. /**
  423. * unicode letters used for parsing html tags, component names and property paths.
  424. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  425. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  426. */
  427. 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/;
  428. /**
  429. * Check if a string starts with $ or _
  430. */
  431. function isReserved(str) {
  432. const c = (str + '').charCodeAt(0);
  433. return c === 0x24 || c === 0x5f;
  434. }
  435. /**
  436. * Define a property.
  437. */
  438. function def(obj, key, val, enumerable) {
  439. Object.defineProperty(obj, key, {
  440. value: val,
  441. enumerable: !!enumerable,
  442. writable: true,
  443. configurable: true
  444. });
  445. }
  446. /**
  447. * Parse simple path.
  448. */
  449. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  450. function parsePath(path) {
  451. if (bailRE.test(path)) {
  452. return;
  453. }
  454. const segments = path.split('.');
  455. return function (obj) {
  456. for (let i = 0; i < segments.length; i++) {
  457. if (!obj)
  458. return;
  459. obj = obj[segments[i]];
  460. }
  461. return obj;
  462. };
  463. }
  464. // can we use __proto__?
  465. const hasProto = '__proto__' in {};
  466. // Browser environment sniffing
  467. const inBrowser = typeof window !== 'undefined';
  468. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  469. const isIE = UA && /msie|trident/.test(UA);
  470. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  471. const isEdge = UA && UA.indexOf('edge/') > 0;
  472. UA && UA.indexOf('android') > 0;
  473. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  474. UA && /chrome\/\d+/.test(UA) && !isEdge;
  475. UA && /phantomjs/.test(UA);
  476. const isFF = UA && UA.match(/firefox\/(\d+)/);
  477. // Firefox has a "watch" function on Object.prototype...
  478. // @ts-expect-error firebox support
  479. const nativeWatch = {}.watch;
  480. let supportsPassive = false;
  481. if (inBrowser) {
  482. try {
  483. const opts = {};
  484. Object.defineProperty(opts, 'passive', {
  485. get() {
  486. /* istanbul ignore next */
  487. supportsPassive = true;
  488. }
  489. }); // https://github.com/facebook/flow/issues/285
  490. window.addEventListener('test-passive', null, opts);
  491. }
  492. catch (e) { }
  493. }
  494. // this needs to be lazy-evaled because vue may be required before
  495. // vue-server-renderer can set VUE_ENV
  496. let _isServer;
  497. const isServerRendering = () => {
  498. if (_isServer === undefined) {
  499. /* istanbul ignore if */
  500. if (!inBrowser && typeof global !== 'undefined') {
  501. // detect presence of vue-server-renderer and avoid
  502. // Webpack shimming the process
  503. _isServer =
  504. global['process'] && global['process'].env.VUE_ENV === 'server';
  505. }
  506. else {
  507. _isServer = false;
  508. }
  509. }
  510. return _isServer;
  511. };
  512. // detect devtools
  513. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  514. /* istanbul ignore next */
  515. function isNative(Ctor) {
  516. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  517. }
  518. const hasSymbol = typeof Symbol !== 'undefined' &&
  519. isNative(Symbol) &&
  520. typeof Reflect !== 'undefined' &&
  521. isNative(Reflect.ownKeys);
  522. let _Set; // $flow-disable-line
  523. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  524. // use native Set when available.
  525. _Set = Set;
  526. }
  527. else {
  528. // a non-standard Set polyfill that only works with primitive keys.
  529. _Set = class Set {
  530. constructor() {
  531. this.set = Object.create(null);
  532. }
  533. has(key) {
  534. return this.set[key] === true;
  535. }
  536. add(key) {
  537. this.set[key] = true;
  538. }
  539. clear() {
  540. this.set = Object.create(null);
  541. }
  542. };
  543. }
  544. let currentInstance = null;
  545. /**
  546. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  547. * relies on it). Do not use this internally, just use `currentInstance`.
  548. *
  549. * @internal this function needs manual type declaration because it relies
  550. * on previously manually authored types from Vue 2
  551. */
  552. function getCurrentInstance() {
  553. return currentInstance && { proxy: currentInstance };
  554. }
  555. /**
  556. * @internal
  557. */
  558. function setCurrentInstance(vm = null) {
  559. if (!vm)
  560. currentInstance && currentInstance._scope.off();
  561. currentInstance = vm;
  562. vm && vm._scope.on();
  563. }
  564. /**
  565. * @internal
  566. */
  567. class VNode {
  568. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  569. this.tag = tag;
  570. this.data = data;
  571. this.children = children;
  572. this.text = text;
  573. this.elm = elm;
  574. this.ns = undefined;
  575. this.context = context;
  576. this.fnContext = undefined;
  577. this.fnOptions = undefined;
  578. this.fnScopeId = undefined;
  579. this.key = data && data.key;
  580. this.componentOptions = componentOptions;
  581. this.componentInstance = undefined;
  582. this.parent = undefined;
  583. this.raw = false;
  584. this.isStatic = false;
  585. this.isRootInsert = true;
  586. this.isComment = false;
  587. this.isCloned = false;
  588. this.isOnce = false;
  589. this.asyncFactory = asyncFactory;
  590. this.asyncMeta = undefined;
  591. this.isAsyncPlaceholder = false;
  592. }
  593. // DEPRECATED: alias for componentInstance for backwards compat.
  594. /* istanbul ignore next */
  595. get child() {
  596. return this.componentInstance;
  597. }
  598. }
  599. const createEmptyVNode = (text = '') => {
  600. const node = new VNode();
  601. node.text = text;
  602. node.isComment = true;
  603. return node;
  604. };
  605. function createTextVNode(val) {
  606. return new VNode(undefined, undefined, undefined, String(val));
  607. }
  608. // optimized shallow clone
  609. // used for static nodes and slot nodes because they may be reused across
  610. // multiple renders, cloning them avoids errors when DOM manipulations rely
  611. // on their elm reference.
  612. function cloneVNode(vnode) {
  613. const cloned = new VNode(vnode.tag, vnode.data,
  614. // #7975
  615. // clone children array to avoid mutating original in case of cloning
  616. // a child.
  617. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  618. cloned.ns = vnode.ns;
  619. cloned.isStatic = vnode.isStatic;
  620. cloned.key = vnode.key;
  621. cloned.isComment = vnode.isComment;
  622. cloned.fnContext = vnode.fnContext;
  623. cloned.fnOptions = vnode.fnOptions;
  624. cloned.fnScopeId = vnode.fnScopeId;
  625. cloned.asyncMeta = vnode.asyncMeta;
  626. cloned.isCloned = true;
  627. return cloned;
  628. }
  629. /* not type checking this file because flow doesn't play well with Proxy */
  630. let initProxy;
  631. {
  632. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  633. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  634. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  635. 'require' // for Webpack/Browserify
  636. );
  637. const warnNonPresent = (target, key) => {
  638. warn$2(`Property or method "${key}" is not defined on the instance but ` +
  639. 'referenced during render. Make sure that this property is reactive, ' +
  640. 'either in the data option, or for class-based components, by ' +
  641. 'initializing the property. ' +
  642. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  643. };
  644. const warnReservedPrefix = (target, key) => {
  645. warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
  646. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  647. 'prevent conflicts with Vue internals. ' +
  648. 'See: https://v2.vuejs.org/v2/api/#data', target);
  649. };
  650. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  651. if (hasProxy) {
  652. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  653. config.keyCodes = new Proxy(config.keyCodes, {
  654. set(target, key, value) {
  655. if (isBuiltInModifier(key)) {
  656. warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  657. return false;
  658. }
  659. else {
  660. target[key] = value;
  661. return true;
  662. }
  663. }
  664. });
  665. }
  666. const hasHandler = {
  667. has(target, key) {
  668. const has = key in target;
  669. const isAllowed = allowedGlobals(key) ||
  670. (typeof key === 'string' &&
  671. key.charAt(0) === '_' &&
  672. !(key in target.$data));
  673. if (!has && !isAllowed) {
  674. if (key in target.$data)
  675. warnReservedPrefix(target, key);
  676. else
  677. warnNonPresent(target, key);
  678. }
  679. return has || !isAllowed;
  680. }
  681. };
  682. const getHandler = {
  683. get(target, key) {
  684. if (typeof key === 'string' && !(key in target)) {
  685. if (key in target.$data)
  686. warnReservedPrefix(target, key);
  687. else
  688. warnNonPresent(target, key);
  689. }
  690. return target[key];
  691. }
  692. };
  693. initProxy = function initProxy(vm) {
  694. if (hasProxy) {
  695. // determine which proxy handler to use
  696. const options = vm.$options;
  697. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  698. vm._renderProxy = new Proxy(vm, handlers);
  699. }
  700. else {
  701. vm._renderProxy = vm;
  702. }
  703. };
  704. }
  705. let uid$2 = 0;
  706. const pendingCleanupDeps = [];
  707. const cleanupDeps = () => {
  708. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  709. const dep = pendingCleanupDeps[i];
  710. dep.subs = dep.subs.filter(s => s);
  711. dep._pending = false;
  712. }
  713. pendingCleanupDeps.length = 0;
  714. };
  715. /**
  716. * A dep is an observable that can have multiple
  717. * directives subscribing to it.
  718. * @internal
  719. */
  720. class Dep {
  721. constructor() {
  722. // pending subs cleanup
  723. this._pending = false;
  724. this.id = uid$2++;
  725. this.subs = [];
  726. }
  727. addSub(sub) {
  728. this.subs.push(sub);
  729. }
  730. removeSub(sub) {
  731. // #12696 deps with massive amount of subscribers are extremely slow to
  732. // clean up in Chromium
  733. // to workaround this, we unset the sub for now, and clear them on
  734. // next scheduler flush.
  735. this.subs[this.subs.indexOf(sub)] = null;
  736. if (!this._pending) {
  737. this._pending = true;
  738. pendingCleanupDeps.push(this);
  739. }
  740. }
  741. depend(info) {
  742. if (Dep.target) {
  743. Dep.target.addDep(this);
  744. if (info && Dep.target.onTrack) {
  745. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  746. }
  747. }
  748. }
  749. notify(info) {
  750. // stabilize the subscriber list first
  751. const subs = this.subs.filter(s => s);
  752. if (!config.async) {
  753. // subs aren't sorted in scheduler if not running async
  754. // we need to sort them now to make sure they fire in correct
  755. // order
  756. subs.sort((a, b) => a.id - b.id);
  757. }
  758. for (let i = 0, l = subs.length; i < l; i++) {
  759. const sub = subs[i];
  760. if (info) {
  761. sub.onTrigger &&
  762. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  763. }
  764. sub.update();
  765. }
  766. }
  767. }
  768. // The current target watcher being evaluated.
  769. // This is globally unique because only one watcher
  770. // can be evaluated at a time.
  771. Dep.target = null;
  772. const targetStack = [];
  773. function pushTarget(target) {
  774. targetStack.push(target);
  775. Dep.target = target;
  776. }
  777. function popTarget() {
  778. targetStack.pop();
  779. Dep.target = targetStack[targetStack.length - 1];
  780. }
  781. /*
  782. * not type checking this file because flow doesn't play well with
  783. * dynamically accessing methods on Array prototype
  784. */
  785. const arrayProto = Array.prototype;
  786. const arrayMethods = Object.create(arrayProto);
  787. const methodsToPatch = [
  788. 'push',
  789. 'pop',
  790. 'shift',
  791. 'unshift',
  792. 'splice',
  793. 'sort',
  794. 'reverse'
  795. ];
  796. /**
  797. * Intercept mutating methods and emit events
  798. */
  799. methodsToPatch.forEach(function (method) {
  800. // cache original method
  801. const original = arrayProto[method];
  802. def(arrayMethods, method, function mutator(...args) {
  803. const result = original.apply(this, args);
  804. const ob = this.__ob__;
  805. let inserted;
  806. switch (method) {
  807. case 'push':
  808. case 'unshift':
  809. inserted = args;
  810. break;
  811. case 'splice':
  812. inserted = args.slice(2);
  813. break;
  814. }
  815. if (inserted)
  816. ob.observeArray(inserted);
  817. // notify change
  818. {
  819. ob.dep.notify({
  820. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  821. target: this,
  822. key: method
  823. });
  824. }
  825. return result;
  826. });
  827. });
  828. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  829. const NO_INITIAL_VALUE = {};
  830. /**
  831. * In some cases we may want to disable observation inside a component's
  832. * update computation.
  833. */
  834. let shouldObserve = true;
  835. function toggleObserving(value) {
  836. shouldObserve = value;
  837. }
  838. // ssr mock dep
  839. const mockDep = {
  840. notify: noop,
  841. depend: noop,
  842. addSub: noop,
  843. removeSub: noop
  844. };
  845. /**
  846. * Observer class that is attached to each observed
  847. * object. Once attached, the observer converts the target
  848. * object's property keys into getter/setters that
  849. * collect dependencies and dispatch updates.
  850. */
  851. class Observer {
  852. constructor(value, shallow = false, mock = false) {
  853. this.value = value;
  854. this.shallow = shallow;
  855. this.mock = mock;
  856. // this.value = value
  857. this.dep = mock ? mockDep : new Dep();
  858. this.vmCount = 0;
  859. def(value, '__ob__', this);
  860. if (isArray(value)) {
  861. if (!mock) {
  862. if (hasProto) {
  863. value.__proto__ = arrayMethods;
  864. /* eslint-enable no-proto */
  865. }
  866. else {
  867. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  868. const key = arrayKeys[i];
  869. def(value, key, arrayMethods[key]);
  870. }
  871. }
  872. }
  873. if (!shallow) {
  874. this.observeArray(value);
  875. }
  876. }
  877. else {
  878. /**
  879. * Walk through all properties and convert them into
  880. * getter/setters. This method should only be called when
  881. * value type is Object.
  882. */
  883. const keys = Object.keys(value);
  884. for (let i = 0; i < keys.length; i++) {
  885. const key = keys[i];
  886. defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
  887. }
  888. }
  889. }
  890. /**
  891. * Observe a list of Array items.
  892. */
  893. observeArray(value) {
  894. for (let i = 0, l = value.length; i < l; i++) {
  895. observe(value[i], false, this.mock);
  896. }
  897. }
  898. }
  899. // helpers
  900. /**
  901. * Attempt to create an observer instance for a value,
  902. * returns the new observer if successfully observed,
  903. * or the existing observer if the value already has one.
  904. */
  905. function observe(value, shallow, ssrMockReactivity) {
  906. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  907. return value.__ob__;
  908. }
  909. if (shouldObserve &&
  910. (ssrMockReactivity || !isServerRendering()) &&
  911. (isArray(value) || isPlainObject(value)) &&
  912. Object.isExtensible(value) &&
  913. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  914. !isRef(value) &&
  915. !(value instanceof VNode)) {
  916. return new Observer(value, shallow, ssrMockReactivity);
  917. }
  918. }
  919. /**
  920. * Define a reactive property on an Object.
  921. */
  922. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  923. const dep = new Dep();
  924. const property = Object.getOwnPropertyDescriptor(obj, key);
  925. if (property && property.configurable === false) {
  926. return;
  927. }
  928. // cater for pre-defined getter/setters
  929. const getter = property && property.get;
  930. const setter = property && property.set;
  931. if ((!getter || setter) &&
  932. (val === NO_INITIAL_VALUE || arguments.length === 2)) {
  933. val = obj[key];
  934. }
  935. let childOb = !shallow && observe(val, false, mock);
  936. Object.defineProperty(obj, key, {
  937. enumerable: true,
  938. configurable: true,
  939. get: function reactiveGetter() {
  940. const value = getter ? getter.call(obj) : val;
  941. if (Dep.target) {
  942. {
  943. dep.depend({
  944. target: obj,
  945. type: "get" /* TrackOpTypes.GET */,
  946. key
  947. });
  948. }
  949. if (childOb) {
  950. childOb.dep.depend();
  951. if (isArray(value)) {
  952. dependArray(value);
  953. }
  954. }
  955. }
  956. return isRef(value) && !shallow ? value.value : value;
  957. },
  958. set: function reactiveSetter(newVal) {
  959. const value = getter ? getter.call(obj) : val;
  960. if (!hasChanged(value, newVal)) {
  961. return;
  962. }
  963. if (customSetter) {
  964. customSetter();
  965. }
  966. if (setter) {
  967. setter.call(obj, newVal);
  968. }
  969. else if (getter) {
  970. // #7981: for accessor properties without setter
  971. return;
  972. }
  973. else if (!shallow && isRef(value) && !isRef(newVal)) {
  974. value.value = newVal;
  975. return;
  976. }
  977. else {
  978. val = newVal;
  979. }
  980. childOb = !shallow && observe(newVal, false, mock);
  981. {
  982. dep.notify({
  983. type: "set" /* TriggerOpTypes.SET */,
  984. target: obj,
  985. key,
  986. newValue: newVal,
  987. oldValue: value
  988. });
  989. }
  990. }
  991. });
  992. return dep;
  993. }
  994. function set(target, key, val) {
  995. if ((isUndef(target) || isPrimitive(target))) {
  996. warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  997. }
  998. if (isReadonly(target)) {
  999. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1000. return;
  1001. }
  1002. const ob = target.__ob__;
  1003. if (isArray(target) && isValidArrayIndex(key)) {
  1004. target.length = Math.max(target.length, key);
  1005. target.splice(key, 1, val);
  1006. // when mocking for SSR, array methods are not hijacked
  1007. if (ob && !ob.shallow && ob.mock) {
  1008. observe(val, false, true);
  1009. }
  1010. return val;
  1011. }
  1012. if (key in target && !(key in Object.prototype)) {
  1013. target[key] = val;
  1014. return val;
  1015. }
  1016. if (target._isVue || (ob && ob.vmCount)) {
  1017. warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1018. 'at runtime - declare it upfront in the data option.');
  1019. return val;
  1020. }
  1021. if (!ob) {
  1022. target[key] = val;
  1023. return val;
  1024. }
  1025. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1026. {
  1027. ob.dep.notify({
  1028. type: "add" /* TriggerOpTypes.ADD */,
  1029. target: target,
  1030. key,
  1031. newValue: val,
  1032. oldValue: undefined
  1033. });
  1034. }
  1035. return val;
  1036. }
  1037. function del(target, key) {
  1038. if ((isUndef(target) || isPrimitive(target))) {
  1039. warn$2(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1040. }
  1041. if (isArray(target) && isValidArrayIndex(key)) {
  1042. target.splice(key, 1);
  1043. return;
  1044. }
  1045. const ob = target.__ob__;
  1046. if (target._isVue || (ob && ob.vmCount)) {
  1047. warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
  1048. '- just set it to null.');
  1049. return;
  1050. }
  1051. if (isReadonly(target)) {
  1052. warn$2(`Delete operation on key "${key}" failed: target is readonly.`);
  1053. return;
  1054. }
  1055. if (!hasOwn(target, key)) {
  1056. return;
  1057. }
  1058. delete target[key];
  1059. if (!ob) {
  1060. return;
  1061. }
  1062. {
  1063. ob.dep.notify({
  1064. type: "delete" /* TriggerOpTypes.DELETE */,
  1065. target: target,
  1066. key
  1067. });
  1068. }
  1069. }
  1070. /**
  1071. * Collect dependencies on array elements when the array is touched, since
  1072. * we cannot intercept array element access like property getters.
  1073. */
  1074. function dependArray(value) {
  1075. for (let e, i = 0, l = value.length; i < l; i++) {
  1076. e = value[i];
  1077. if (e && e.__ob__) {
  1078. e.__ob__.dep.depend();
  1079. }
  1080. if (isArray(e)) {
  1081. dependArray(e);
  1082. }
  1083. }
  1084. }
  1085. function reactive(target) {
  1086. makeReactive(target, false);
  1087. return target;
  1088. }
  1089. /**
  1090. * Return a shallowly-reactive copy of the original object, where only the root
  1091. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1092. * root level).
  1093. */
  1094. function shallowReactive(target) {
  1095. makeReactive(target, true);
  1096. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1097. return target;
  1098. }
  1099. function makeReactive(target, shallow) {
  1100. // if trying to observe a readonly proxy, return the readonly version.
  1101. if (!isReadonly(target)) {
  1102. {
  1103. if (isArray(target)) {
  1104. 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.`);
  1105. }
  1106. const existingOb = target && target.__ob__;
  1107. if (existingOb && existingOb.shallow !== shallow) {
  1108. warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1109. }
  1110. }
  1111. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1112. if (!ob) {
  1113. if (target == null || isPrimitive(target)) {
  1114. warn$2(`value cannot be made reactive: ${String(target)}`);
  1115. }
  1116. if (isCollectionType(target)) {
  1117. warn$2(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1118. }
  1119. }
  1120. }
  1121. }
  1122. function isReactive(value) {
  1123. if (isReadonly(value)) {
  1124. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1125. }
  1126. return !!(value && value.__ob__);
  1127. }
  1128. function isShallow(value) {
  1129. return !!(value && value.__v_isShallow);
  1130. }
  1131. function isReadonly(value) {
  1132. return !!(value && value.__v_isReadonly);
  1133. }
  1134. function isProxy(value) {
  1135. return isReactive(value) || isReadonly(value);
  1136. }
  1137. function toRaw(observed) {
  1138. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1139. return raw ? toRaw(raw) : observed;
  1140. }
  1141. function markRaw(value) {
  1142. // non-extensible objects won't be observed anyway
  1143. if (Object.isExtensible(value)) {
  1144. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1145. }
  1146. return value;
  1147. }
  1148. /**
  1149. * @internal
  1150. */
  1151. function isCollectionType(value) {
  1152. const type = toRawType(value);
  1153. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1154. }
  1155. /**
  1156. * @internal
  1157. */
  1158. const RefFlag = `__v_isRef`;
  1159. function isRef(r) {
  1160. return !!(r && r.__v_isRef === true);
  1161. }
  1162. function ref$1(value) {
  1163. return createRef(value, false);
  1164. }
  1165. function shallowRef(value) {
  1166. return createRef(value, true);
  1167. }
  1168. function createRef(rawValue, shallow) {
  1169. if (isRef(rawValue)) {
  1170. return rawValue;
  1171. }
  1172. const ref = {};
  1173. def(ref, RefFlag, true);
  1174. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1175. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1176. return ref;
  1177. }
  1178. function triggerRef(ref) {
  1179. if (!ref.dep) {
  1180. warn$2(`received object is not a triggerable ref.`);
  1181. }
  1182. {
  1183. ref.dep &&
  1184. ref.dep.notify({
  1185. type: "set" /* TriggerOpTypes.SET */,
  1186. target: ref,
  1187. key: 'value'
  1188. });
  1189. }
  1190. }
  1191. function unref(ref) {
  1192. return isRef(ref) ? ref.value : ref;
  1193. }
  1194. function proxyRefs(objectWithRefs) {
  1195. if (isReactive(objectWithRefs)) {
  1196. return objectWithRefs;
  1197. }
  1198. const proxy = {};
  1199. const keys = Object.keys(objectWithRefs);
  1200. for (let i = 0; i < keys.length; i++) {
  1201. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1202. }
  1203. return proxy;
  1204. }
  1205. function proxyWithRefUnwrap(target, source, key) {
  1206. Object.defineProperty(target, key, {
  1207. enumerable: true,
  1208. configurable: true,
  1209. get: () => {
  1210. const val = source[key];
  1211. if (isRef(val)) {
  1212. return val.value;
  1213. }
  1214. else {
  1215. const ob = val && val.__ob__;
  1216. if (ob)
  1217. ob.dep.depend();
  1218. return val;
  1219. }
  1220. },
  1221. set: value => {
  1222. const oldValue = source[key];
  1223. if (isRef(oldValue) && !isRef(value)) {
  1224. oldValue.value = value;
  1225. }
  1226. else {
  1227. source[key] = value;
  1228. }
  1229. }
  1230. });
  1231. }
  1232. function customRef(factory) {
  1233. const dep = new Dep();
  1234. const { get, set } = factory(() => {
  1235. {
  1236. dep.depend({
  1237. target: ref,
  1238. type: "get" /* TrackOpTypes.GET */,
  1239. key: 'value'
  1240. });
  1241. }
  1242. }, () => {
  1243. {
  1244. dep.notify({
  1245. target: ref,
  1246. type: "set" /* TriggerOpTypes.SET */,
  1247. key: 'value'
  1248. });
  1249. }
  1250. });
  1251. const ref = {
  1252. get value() {
  1253. return get();
  1254. },
  1255. set value(newVal) {
  1256. set(newVal);
  1257. }
  1258. };
  1259. def(ref, RefFlag, true);
  1260. return ref;
  1261. }
  1262. function toRefs(object) {
  1263. if (!isReactive(object)) {
  1264. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1265. }
  1266. const ret = isArray(object) ? new Array(object.length) : {};
  1267. for (const key in object) {
  1268. ret[key] = toRef(object, key);
  1269. }
  1270. return ret;
  1271. }
  1272. function toRef(object, key, defaultValue) {
  1273. const val = object[key];
  1274. if (isRef(val)) {
  1275. return val;
  1276. }
  1277. const ref = {
  1278. get value() {
  1279. const val = object[key];
  1280. return val === undefined ? defaultValue : val;
  1281. },
  1282. set value(newVal) {
  1283. object[key] = newVal;
  1284. }
  1285. };
  1286. def(ref, RefFlag, true);
  1287. return ref;
  1288. }
  1289. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1290. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1291. function readonly(target) {
  1292. return createReadonly(target, false);
  1293. }
  1294. function createReadonly(target, shallow) {
  1295. if (!isPlainObject(target)) {
  1296. {
  1297. if (isArray(target)) {
  1298. warn$2(`Vue 2 does not support readonly arrays.`);
  1299. }
  1300. else if (isCollectionType(target)) {
  1301. warn$2(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1302. }
  1303. else {
  1304. warn$2(`value cannot be made readonly: ${typeof target}`);
  1305. }
  1306. }
  1307. return target;
  1308. }
  1309. if (!Object.isExtensible(target)) {
  1310. warn$2(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1311. }
  1312. // already a readonly object
  1313. if (isReadonly(target)) {
  1314. return target;
  1315. }
  1316. // already has a readonly proxy
  1317. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1318. const existingProxy = target[existingFlag];
  1319. if (existingProxy) {
  1320. return existingProxy;
  1321. }
  1322. const proxy = Object.create(Object.getPrototypeOf(target));
  1323. def(target, existingFlag, proxy);
  1324. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1325. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1326. if (isRef(target)) {
  1327. def(proxy, RefFlag, true);
  1328. }
  1329. if (shallow || isShallow(target)) {
  1330. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1331. }
  1332. const keys = Object.keys(target);
  1333. for (let i = 0; i < keys.length; i++) {
  1334. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1335. }
  1336. return proxy;
  1337. }
  1338. function defineReadonlyProperty(proxy, target, key, shallow) {
  1339. Object.defineProperty(proxy, key, {
  1340. enumerable: true,
  1341. configurable: true,
  1342. get() {
  1343. const val = target[key];
  1344. return shallow || !isPlainObject(val) ? val : readonly(val);
  1345. },
  1346. set() {
  1347. warn$2(`Set operation on key "${key}" failed: target is readonly.`);
  1348. }
  1349. });
  1350. }
  1351. /**
  1352. * Returns a reactive-copy of the original object, where only the root level
  1353. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1354. * returned properties.
  1355. * This is used for creating the props proxy object for stateful components.
  1356. */
  1357. function shallowReadonly(target) {
  1358. return createReadonly(target, true);
  1359. }
  1360. function computed(getterOrOptions, debugOptions) {
  1361. let getter;
  1362. let setter;
  1363. const onlyGetter = isFunction(getterOrOptions);
  1364. if (onlyGetter) {
  1365. getter = getterOrOptions;
  1366. setter = () => {
  1367. warn$2('Write operation failed: computed value is readonly');
  1368. }
  1369. ;
  1370. }
  1371. else {
  1372. getter = getterOrOptions.get;
  1373. setter = getterOrOptions.set;
  1374. }
  1375. const watcher = isServerRendering()
  1376. ? null
  1377. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1378. if (watcher && debugOptions) {
  1379. watcher.onTrack = debugOptions.onTrack;
  1380. watcher.onTrigger = debugOptions.onTrigger;
  1381. }
  1382. const ref = {
  1383. // some libs rely on the presence effect for checking computed refs
  1384. // from normal refs, but the implementation doesn't matter
  1385. effect: watcher,
  1386. get value() {
  1387. if (watcher) {
  1388. if (watcher.dirty) {
  1389. watcher.evaluate();
  1390. }
  1391. if (Dep.target) {
  1392. if (Dep.target.onTrack) {
  1393. Dep.target.onTrack({
  1394. effect: Dep.target,
  1395. target: ref,
  1396. type: "get" /* TrackOpTypes.GET */,
  1397. key: 'value'
  1398. });
  1399. }
  1400. watcher.depend();
  1401. }
  1402. return watcher.value;
  1403. }
  1404. else {
  1405. return getter();
  1406. }
  1407. },
  1408. set value(newVal) {
  1409. setter(newVal);
  1410. }
  1411. };
  1412. def(ref, RefFlag, true);
  1413. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1414. return ref;
  1415. }
  1416. let mark;
  1417. let measure;
  1418. {
  1419. const perf = inBrowser && window.performance;
  1420. /* istanbul ignore if */
  1421. if (perf &&
  1422. // @ts-ignore
  1423. perf.mark &&
  1424. // @ts-ignore
  1425. perf.measure &&
  1426. // @ts-ignore
  1427. perf.clearMarks &&
  1428. // @ts-ignore
  1429. perf.clearMeasures) {
  1430. mark = tag => perf.mark(tag);
  1431. measure = (name, startTag, endTag) => {
  1432. perf.measure(name, startTag, endTag);
  1433. perf.clearMarks(startTag);
  1434. perf.clearMarks(endTag);
  1435. // perf.clearMeasures(name)
  1436. };
  1437. }
  1438. }
  1439. const normalizeEvent = cached((name) => {
  1440. const passive = name.charAt(0) === '&';
  1441. name = passive ? name.slice(1) : name;
  1442. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1443. name = once ? name.slice(1) : name;
  1444. const capture = name.charAt(0) === '!';
  1445. name = capture ? name.slice(1) : name;
  1446. return {
  1447. name,
  1448. once,
  1449. capture,
  1450. passive
  1451. };
  1452. });
  1453. function createFnInvoker(fns, vm) {
  1454. function invoker() {
  1455. const fns = invoker.fns;
  1456. if (isArray(fns)) {
  1457. const cloned = fns.slice();
  1458. for (let i = 0; i < cloned.length; i++) {
  1459. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1460. }
  1461. }
  1462. else {
  1463. // return handler return value for single handlers
  1464. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1465. }
  1466. }
  1467. invoker.fns = fns;
  1468. return invoker;
  1469. }
  1470. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1471. let name, cur, old, event;
  1472. for (name in on) {
  1473. cur = on[name];
  1474. old = oldOn[name];
  1475. event = normalizeEvent(name);
  1476. if (isUndef(cur)) {
  1477. warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1478. }
  1479. else if (isUndef(old)) {
  1480. if (isUndef(cur.fns)) {
  1481. cur = on[name] = createFnInvoker(cur, vm);
  1482. }
  1483. if (isTrue(event.once)) {
  1484. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1485. }
  1486. add(event.name, cur, event.capture, event.passive, event.params);
  1487. }
  1488. else if (cur !== old) {
  1489. old.fns = cur;
  1490. on[name] = old;
  1491. }
  1492. }
  1493. for (name in oldOn) {
  1494. if (isUndef(on[name])) {
  1495. event = normalizeEvent(name);
  1496. remove(event.name, oldOn[name], event.capture);
  1497. }
  1498. }
  1499. }
  1500. function mergeVNodeHook(def, hookKey, hook) {
  1501. if (def instanceof VNode) {
  1502. def = def.data.hook || (def.data.hook = {});
  1503. }
  1504. let invoker;
  1505. const oldHook = def[hookKey];
  1506. function wrappedHook() {
  1507. hook.apply(this, arguments);
  1508. // important: remove merged hook to ensure it's called only once
  1509. // and prevent memory leak
  1510. remove$2(invoker.fns, wrappedHook);
  1511. }
  1512. if (isUndef(oldHook)) {
  1513. // no existing hook
  1514. invoker = createFnInvoker([wrappedHook]);
  1515. }
  1516. else {
  1517. /* istanbul ignore if */
  1518. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1519. // already a merged invoker
  1520. invoker = oldHook;
  1521. invoker.fns.push(wrappedHook);
  1522. }
  1523. else {
  1524. // existing plain hook
  1525. invoker = createFnInvoker([oldHook, wrappedHook]);
  1526. }
  1527. }
  1528. invoker.merged = true;
  1529. def[hookKey] = invoker;
  1530. }
  1531. function extractPropsFromVNodeData(data, Ctor, tag) {
  1532. // we are only extracting raw values here.
  1533. // validation and default values are handled in the child
  1534. // component itself.
  1535. const propOptions = Ctor.options.props;
  1536. if (isUndef(propOptions)) {
  1537. return;
  1538. }
  1539. const res = {};
  1540. const { attrs, props } = data;
  1541. if (isDef(attrs) || isDef(props)) {
  1542. for (const key in propOptions) {
  1543. const altKey = hyphenate(key);
  1544. {
  1545. const keyInLowerCase = key.toLowerCase();
  1546. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1547. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1548. `${formatComponentName(
  1549. // @ts-expect-error tag is string
  1550. tag || Ctor)}, but the declared prop name is` +
  1551. ` "${key}". ` +
  1552. `Note that HTML attributes are case-insensitive and camelCased ` +
  1553. `props need to use their kebab-case equivalents when using in-DOM ` +
  1554. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1555. }
  1556. }
  1557. checkProp(res, props, key, altKey, true) ||
  1558. checkProp(res, attrs, key, altKey, false);
  1559. }
  1560. }
  1561. return res;
  1562. }
  1563. function checkProp(res, hash, key, altKey, preserve) {
  1564. if (isDef(hash)) {
  1565. if (hasOwn(hash, key)) {
  1566. res[key] = hash[key];
  1567. if (!preserve) {
  1568. delete hash[key];
  1569. }
  1570. return true;
  1571. }
  1572. else if (hasOwn(hash, altKey)) {
  1573. res[key] = hash[altKey];
  1574. if (!preserve) {
  1575. delete hash[altKey];
  1576. }
  1577. return true;
  1578. }
  1579. }
  1580. return false;
  1581. }
  1582. // The template compiler attempts to minimize the need for normalization by
  1583. // statically analyzing the template at compile time.
  1584. //
  1585. // For plain HTML markup, normalization can be completely skipped because the
  1586. // generated render function is guaranteed to return Array<VNode>. There are
  1587. // two cases where extra normalization is needed:
  1588. // 1. When the children contains components - because a functional component
  1589. // may return an Array instead of a single root. In this case, just a simple
  1590. // normalization is needed - if any child is an Array, we flatten the whole
  1591. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1592. // because functional components already normalize their own children.
  1593. function simpleNormalizeChildren(children) {
  1594. for (let i = 0; i < children.length; i++) {
  1595. if (isArray(children[i])) {
  1596. return Array.prototype.concat.apply([], children);
  1597. }
  1598. }
  1599. return children;
  1600. }
  1601. // 2. When the children contains constructs that always generated nested Arrays,
  1602. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1603. // with hand-written render functions / JSX. In such cases a full normalization
  1604. // is needed to cater to all possible types of children values.
  1605. function normalizeChildren(children) {
  1606. return isPrimitive(children)
  1607. ? [createTextVNode(children)]
  1608. : isArray(children)
  1609. ? normalizeArrayChildren(children)
  1610. : undefined;
  1611. }
  1612. function isTextNode(node) {
  1613. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1614. }
  1615. function normalizeArrayChildren(children, nestedIndex) {
  1616. const res = [];
  1617. let i, c, lastIndex, last;
  1618. for (i = 0; i < children.length; i++) {
  1619. c = children[i];
  1620. if (isUndef(c) || typeof c === 'boolean')
  1621. continue;
  1622. lastIndex = res.length - 1;
  1623. last = res[lastIndex];
  1624. // nested
  1625. if (isArray(c)) {
  1626. if (c.length > 0) {
  1627. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1628. // merge adjacent text nodes
  1629. if (isTextNode(c[0]) && isTextNode(last)) {
  1630. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1631. c.shift();
  1632. }
  1633. res.push.apply(res, c);
  1634. }
  1635. }
  1636. else if (isPrimitive(c)) {
  1637. if (isTextNode(last)) {
  1638. // merge adjacent text nodes
  1639. // this is necessary for SSR hydration because text nodes are
  1640. // essentially merged when rendered to HTML strings
  1641. res[lastIndex] = createTextVNode(last.text + c);
  1642. }
  1643. else if (c !== '') {
  1644. // convert primitive to vnode
  1645. res.push(createTextVNode(c));
  1646. }
  1647. }
  1648. else {
  1649. if (isTextNode(c) && isTextNode(last)) {
  1650. // merge adjacent text nodes
  1651. res[lastIndex] = createTextVNode(last.text + c.text);
  1652. }
  1653. else {
  1654. // default key for nested array children (likely generated by v-for)
  1655. if (isTrue(children._isVList) &&
  1656. isDef(c.tag) &&
  1657. isUndef(c.key) &&
  1658. isDef(nestedIndex)) {
  1659. c.key = `__vlist${nestedIndex}_${i}__`;
  1660. }
  1661. res.push(c);
  1662. }
  1663. }
  1664. }
  1665. return res;
  1666. }
  1667. const SIMPLE_NORMALIZE = 1;
  1668. const ALWAYS_NORMALIZE = 2;
  1669. // wrapper function for providing a more flexible interface
  1670. // without getting yelled at by flow
  1671. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  1672. if (isArray(data) || isPrimitive(data)) {
  1673. normalizationType = children;
  1674. children = data;
  1675. data = undefined;
  1676. }
  1677. if (isTrue(alwaysNormalize)) {
  1678. normalizationType = ALWAYS_NORMALIZE;
  1679. }
  1680. return _createElement(context, tag, data, children, normalizationType);
  1681. }
  1682. function _createElement(context, tag, data, children, normalizationType) {
  1683. if (isDef(data) && isDef(data.__ob__)) {
  1684. warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  1685. return createEmptyVNode();
  1686. }
  1687. // object syntax in v-bind
  1688. if (isDef(data) && isDef(data.is)) {
  1689. tag = data.is;
  1690. }
  1691. if (!tag) {
  1692. // in case of component :is set to falsy value
  1693. return createEmptyVNode();
  1694. }
  1695. // warn against non-primitive key
  1696. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  1697. warn$2('Avoid using non-primitive value as key, ' +
  1698. 'use string/number value instead.', context);
  1699. }
  1700. // support single function children as default scoped slot
  1701. if (isArray(children) && isFunction(children[0])) {
  1702. data = data || {};
  1703. data.scopedSlots = { default: children[0] };
  1704. children.length = 0;
  1705. }
  1706. if (normalizationType === ALWAYS_NORMALIZE) {
  1707. children = normalizeChildren(children);
  1708. }
  1709. else if (normalizationType === SIMPLE_NORMALIZE) {
  1710. children = simpleNormalizeChildren(children);
  1711. }
  1712. let vnode, ns;
  1713. if (typeof tag === 'string') {
  1714. let Ctor;
  1715. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  1716. if (config.isReservedTag(tag)) {
  1717. // platform built-in elements
  1718. if (isDef(data) &&
  1719. isDef(data.nativeOn) &&
  1720. data.tag !== 'component') {
  1721. warn$2(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  1722. }
  1723. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  1724. }
  1725. else if ((!data || !data.pre) &&
  1726. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  1727. // component
  1728. vnode = createComponent(Ctor, data, context, children, tag);
  1729. }
  1730. else {
  1731. // unknown or unlisted namespaced elements
  1732. // check at runtime because it may get assigned a namespace when its
  1733. // parent normalizes children
  1734. vnode = new VNode(tag, data, children, undefined, undefined, context);
  1735. }
  1736. }
  1737. else {
  1738. // direct component options / constructor
  1739. vnode = createComponent(tag, data, context, children);
  1740. }
  1741. if (isArray(vnode)) {
  1742. return vnode;
  1743. }
  1744. else if (isDef(vnode)) {
  1745. if (isDef(ns))
  1746. applyNS(vnode, ns);
  1747. if (isDef(data))
  1748. registerDeepBindings(data);
  1749. return vnode;
  1750. }
  1751. else {
  1752. return createEmptyVNode();
  1753. }
  1754. }
  1755. function applyNS(vnode, ns, force) {
  1756. vnode.ns = ns;
  1757. if (vnode.tag === 'foreignObject') {
  1758. // use default namespace inside foreignObject
  1759. ns = undefined;
  1760. force = true;
  1761. }
  1762. if (isDef(vnode.children)) {
  1763. for (let i = 0, l = vnode.children.length; i < l; i++) {
  1764. const child = vnode.children[i];
  1765. if (isDef(child.tag) &&
  1766. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  1767. applyNS(child, ns, force);
  1768. }
  1769. }
  1770. }
  1771. }
  1772. // ref #5318
  1773. // necessary to ensure parent re-render when deep bindings like :style and
  1774. // :class are used on slot nodes
  1775. function registerDeepBindings(data) {
  1776. if (isObject(data.style)) {
  1777. traverse(data.style);
  1778. }
  1779. if (isObject(data.class)) {
  1780. traverse(data.class);
  1781. }
  1782. }
  1783. /**
  1784. * Runtime helper for rendering v-for lists.
  1785. */
  1786. function renderList(val, render) {
  1787. let ret = null, i, l, keys, key;
  1788. if (isArray(val) || typeof val === 'string') {
  1789. ret = new Array(val.length);
  1790. for (i = 0, l = val.length; i < l; i++) {
  1791. ret[i] = render(val[i], i);
  1792. }
  1793. }
  1794. else if (typeof val === 'number') {
  1795. ret = new Array(val);
  1796. for (i = 0; i < val; i++) {
  1797. ret[i] = render(i + 1, i);
  1798. }
  1799. }
  1800. else if (isObject(val)) {
  1801. if (hasSymbol && val[Symbol.iterator]) {
  1802. ret = [];
  1803. const iterator = val[Symbol.iterator]();
  1804. let result = iterator.next();
  1805. while (!result.done) {
  1806. ret.push(render(result.value, ret.length));
  1807. result = iterator.next();
  1808. }
  1809. }
  1810. else {
  1811. keys = Object.keys(val);
  1812. ret = new Array(keys.length);
  1813. for (i = 0, l = keys.length; i < l; i++) {
  1814. key = keys[i];
  1815. ret[i] = render(val[key], key, i);
  1816. }
  1817. }
  1818. }
  1819. if (!isDef(ret)) {
  1820. ret = [];
  1821. }
  1822. ret._isVList = true;
  1823. return ret;
  1824. }
  1825. /**
  1826. * Runtime helper for rendering <slot>
  1827. */
  1828. function renderSlot(name, fallbackRender, props, bindObject) {
  1829. const scopedSlotFn = this.$scopedSlots[name];
  1830. let nodes;
  1831. if (scopedSlotFn) {
  1832. // scoped slot
  1833. props = props || {};
  1834. if (bindObject) {
  1835. if (!isObject(bindObject)) {
  1836. warn$2('slot v-bind without argument expects an Object', this);
  1837. }
  1838. props = extend(extend({}, bindObject), props);
  1839. }
  1840. nodes =
  1841. scopedSlotFn(props) ||
  1842. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1843. }
  1844. else {
  1845. nodes =
  1846. this.$slots[name] ||
  1847. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1848. }
  1849. const target = props && props.slot;
  1850. if (target) {
  1851. return this.$createElement('template', { slot: target }, nodes);
  1852. }
  1853. else {
  1854. return nodes;
  1855. }
  1856. }
  1857. /**
  1858. * Runtime helper for resolving filters
  1859. */
  1860. function resolveFilter(id) {
  1861. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1862. }
  1863. function isKeyNotMatch(expect, actual) {
  1864. if (isArray(expect)) {
  1865. return expect.indexOf(actual) === -1;
  1866. }
  1867. else {
  1868. return expect !== actual;
  1869. }
  1870. }
  1871. /**
  1872. * Runtime helper for checking keyCodes from config.
  1873. * exposed as Vue.prototype._k
  1874. * passing in eventKeyName as last argument separately for backwards compat
  1875. */
  1876. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  1877. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  1878. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  1879. return isKeyNotMatch(builtInKeyName, eventKeyName);
  1880. }
  1881. else if (mappedKeyCode) {
  1882. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  1883. }
  1884. else if (eventKeyName) {
  1885. return hyphenate(eventKeyName) !== key;
  1886. }
  1887. return eventKeyCode === undefined;
  1888. }
  1889. /**
  1890. * Runtime helper for merging v-bind="object" into a VNode's data.
  1891. */
  1892. function bindObjectProps(data, tag, value, asProp, isSync) {
  1893. if (value) {
  1894. if (!isObject(value)) {
  1895. warn$2('v-bind without argument expects an Object or Array value', this);
  1896. }
  1897. else {
  1898. if (isArray(value)) {
  1899. value = toObject(value);
  1900. }
  1901. let hash;
  1902. for (const key in value) {
  1903. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  1904. hash = data;
  1905. }
  1906. else {
  1907. const type = data.attrs && data.attrs.type;
  1908. hash =
  1909. asProp || config.mustUseProp(tag, type, key)
  1910. ? data.domProps || (data.domProps = {})
  1911. : data.attrs || (data.attrs = {});
  1912. }
  1913. const camelizedKey = camelize(key);
  1914. const hyphenatedKey = hyphenate(key);
  1915. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  1916. hash[key] = value[key];
  1917. if (isSync) {
  1918. const on = data.on || (data.on = {});
  1919. on[`update:${key}`] = function ($event) {
  1920. value[key] = $event;
  1921. };
  1922. }
  1923. }
  1924. }
  1925. }
  1926. }
  1927. return data;
  1928. }
  1929. /**
  1930. * Runtime helper for rendering static trees.
  1931. */
  1932. function renderStatic(index, isInFor) {
  1933. const cached = this._staticTrees || (this._staticTrees = []);
  1934. let tree = cached[index];
  1935. // if has already-rendered static tree and not inside v-for,
  1936. // we can reuse the same tree.
  1937. if (tree && !isInFor) {
  1938. return tree;
  1939. }
  1940. // otherwise, render a fresh tree.
  1941. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  1942. );
  1943. markStatic$1(tree, `__static__${index}`, false);
  1944. return tree;
  1945. }
  1946. /**
  1947. * Runtime helper for v-once.
  1948. * Effectively it means marking the node as static with a unique key.
  1949. */
  1950. function markOnce(tree, index, key) {
  1951. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  1952. return tree;
  1953. }
  1954. function markStatic$1(tree, key, isOnce) {
  1955. if (isArray(tree)) {
  1956. for (let i = 0; i < tree.length; i++) {
  1957. if (tree[i] && typeof tree[i] !== 'string') {
  1958. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  1959. }
  1960. }
  1961. }
  1962. else {
  1963. markStaticNode(tree, key, isOnce);
  1964. }
  1965. }
  1966. function markStaticNode(node, key, isOnce) {
  1967. node.isStatic = true;
  1968. node.key = key;
  1969. node.isOnce = isOnce;
  1970. }
  1971. function bindObjectListeners(data, value) {
  1972. if (value) {
  1973. if (!isPlainObject(value)) {
  1974. warn$2('v-on without argument expects an Object value', this);
  1975. }
  1976. else {
  1977. const on = (data.on = data.on ? extend({}, data.on) : {});
  1978. for (const key in value) {
  1979. const existing = on[key];
  1980. const ours = value[key];
  1981. on[key] = existing ? [].concat(existing, ours) : ours;
  1982. }
  1983. }
  1984. }
  1985. return data;
  1986. }
  1987. function resolveScopedSlots(fns, res,
  1988. // the following are added in 2.6
  1989. hasDynamicKeys, contentHashKey) {
  1990. res = res || { $stable: !hasDynamicKeys };
  1991. for (let i = 0; i < fns.length; i++) {
  1992. const slot = fns[i];
  1993. if (isArray(slot)) {
  1994. resolveScopedSlots(slot, res, hasDynamicKeys);
  1995. }
  1996. else if (slot) {
  1997. // marker for reverse proxying v-slot without scope on this.$slots
  1998. // @ts-expect-error
  1999. if (slot.proxy) {
  2000. // @ts-expect-error
  2001. slot.fn.proxy = true;
  2002. }
  2003. res[slot.key] = slot.fn;
  2004. }
  2005. }
  2006. if (contentHashKey) {
  2007. res.$key = contentHashKey;
  2008. }
  2009. return res;
  2010. }
  2011. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2012. function bindDynamicKeys(baseObj, values) {
  2013. for (let i = 0; i < values.length; i += 2) {
  2014. const key = values[i];
  2015. if (typeof key === 'string' && key) {
  2016. baseObj[values[i]] = values[i + 1];
  2017. }
  2018. else if (key !== '' && key !== null) {
  2019. // null is a special value for explicitly removing a binding
  2020. warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2021. }
  2022. }
  2023. return baseObj;
  2024. }
  2025. // helper to dynamically append modifier runtime markers to event names.
  2026. // ensure only append when value is already string, otherwise it will be cast
  2027. // to string and cause the type check to miss.
  2028. function prependModifier(value, symbol) {
  2029. return typeof value === 'string' ? symbol + value : value;
  2030. }
  2031. function installRenderHelpers(target) {
  2032. target._o = markOnce;
  2033. target._n = toNumber;
  2034. target._s = toString;
  2035. target._l = renderList;
  2036. target._t = renderSlot;
  2037. target._q = looseEqual;
  2038. target._i = looseIndexOf;
  2039. target._m = renderStatic;
  2040. target._f = resolveFilter;
  2041. target._k = checkKeyCodes;
  2042. target._b = bindObjectProps;
  2043. target._v = createTextVNode;
  2044. target._e = createEmptyVNode;
  2045. target._u = resolveScopedSlots;
  2046. target._g = bindObjectListeners;
  2047. target._d = bindDynamicKeys;
  2048. target._p = prependModifier;
  2049. }
  2050. /**
  2051. * Runtime helper for resolving raw children VNodes into a slot object.
  2052. */
  2053. function resolveSlots(children, context) {
  2054. if (!children || !children.length) {
  2055. return {};
  2056. }
  2057. const slots = {};
  2058. for (let i = 0, l = children.length; i < l; i++) {
  2059. const child = children[i];
  2060. const data = child.data;
  2061. // remove slot attribute if the node is resolved as a Vue slot node
  2062. if (data && data.attrs && data.attrs.slot) {
  2063. delete data.attrs.slot;
  2064. }
  2065. // named slots should only be respected if the vnode was rendered in the
  2066. // same context.
  2067. if ((child.context === context || child.fnContext === context) &&
  2068. data &&
  2069. data.slot != null) {
  2070. const name = data.slot;
  2071. const slot = slots[name] || (slots[name] = []);
  2072. if (child.tag === 'template') {
  2073. slot.push.apply(slot, child.children || []);
  2074. }
  2075. else {
  2076. slot.push(child);
  2077. }
  2078. }
  2079. else {
  2080. (slots.default || (slots.default = [])).push(child);
  2081. }
  2082. }
  2083. // ignore slots that contains only whitespace
  2084. for (const name in slots) {
  2085. if (slots[name].every(isWhitespace)) {
  2086. delete slots[name];
  2087. }
  2088. }
  2089. return slots;
  2090. }
  2091. function isWhitespace(node) {
  2092. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2093. }
  2094. function isAsyncPlaceholder(node) {
  2095. // @ts-expect-error not really boolean type
  2096. return node.isComment && node.asyncFactory;
  2097. }
  2098. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2099. let res;
  2100. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2101. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2102. const key = scopedSlots && scopedSlots.$key;
  2103. if (!scopedSlots) {
  2104. res = {};
  2105. }
  2106. else if (scopedSlots._normalized) {
  2107. // fast path 1: child component re-render only, parent did not change
  2108. return scopedSlots._normalized;
  2109. }
  2110. else if (isStable &&
  2111. prevScopedSlots &&
  2112. prevScopedSlots !== emptyObject &&
  2113. key === prevScopedSlots.$key &&
  2114. !hasNormalSlots &&
  2115. !prevScopedSlots.$hasNormal) {
  2116. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2117. // only need to normalize once
  2118. return prevScopedSlots;
  2119. }
  2120. else {
  2121. res = {};
  2122. for (const key in scopedSlots) {
  2123. if (scopedSlots[key] && key[0] !== '$') {
  2124. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2125. }
  2126. }
  2127. }
  2128. // expose normal slots on scopedSlots
  2129. for (const key in normalSlots) {
  2130. if (!(key in res)) {
  2131. res[key] = proxyNormalSlot(normalSlots, key);
  2132. }
  2133. }
  2134. // avoriaz seems to mock a non-extensible $scopedSlots object
  2135. // and when that is passed down this would cause an error
  2136. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2137. scopedSlots._normalized = res;
  2138. }
  2139. def(res, '$stable', isStable);
  2140. def(res, '$key', key);
  2141. def(res, '$hasNormal', hasNormalSlots);
  2142. return res;
  2143. }
  2144. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2145. const normalized = function () {
  2146. const cur = currentInstance;
  2147. setCurrentInstance(vm);
  2148. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2149. res =
  2150. res && typeof res === 'object' && !isArray(res)
  2151. ? [res] // single vnode
  2152. : normalizeChildren(res);
  2153. const vnode = res && res[0];
  2154. setCurrentInstance(cur);
  2155. return res &&
  2156. (!vnode ||
  2157. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2158. ? undefined
  2159. : res;
  2160. };
  2161. // this is a slot using the new v-slot syntax without scope. although it is
  2162. // compiled as a scoped slot, render fn users would expect it to be present
  2163. // on this.$slots because the usage is semantically a normal slot.
  2164. if (fn.proxy) {
  2165. Object.defineProperty(normalSlots, key, {
  2166. get: normalized,
  2167. enumerable: true,
  2168. configurable: true
  2169. });
  2170. }
  2171. return normalized;
  2172. }
  2173. function proxyNormalSlot(slots, key) {
  2174. return () => slots[key];
  2175. }
  2176. function initSetup(vm) {
  2177. const options = vm.$options;
  2178. const setup = options.setup;
  2179. if (setup) {
  2180. const ctx = (vm._setupContext = createSetupContext(vm));
  2181. setCurrentInstance(vm);
  2182. pushTarget();
  2183. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2184. popTarget();
  2185. setCurrentInstance();
  2186. if (isFunction(setupResult)) {
  2187. // render function
  2188. // @ts-ignore
  2189. options.render = setupResult;
  2190. }
  2191. else if (isObject(setupResult)) {
  2192. // bindings
  2193. if (setupResult instanceof VNode) {
  2194. warn$2(`setup() should not return VNodes directly - ` +
  2195. `return a render function instead.`);
  2196. }
  2197. vm._setupState = setupResult;
  2198. // __sfc indicates compiled bindings from <script setup>
  2199. if (!setupResult.__sfc) {
  2200. for (const key in setupResult) {
  2201. if (!isReserved(key)) {
  2202. proxyWithRefUnwrap(vm, setupResult, key);
  2203. }
  2204. else {
  2205. warn$2(`Avoid using variables that start with _ or $ in setup().`);
  2206. }
  2207. }
  2208. }
  2209. else {
  2210. // exposed for compiled render fn
  2211. const proxy = (vm._setupProxy = {});
  2212. for (const key in setupResult) {
  2213. if (key !== '__sfc') {
  2214. proxyWithRefUnwrap(proxy, setupResult, key);
  2215. }
  2216. }
  2217. }
  2218. }
  2219. else if (setupResult !== undefined) {
  2220. warn$2(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2221. }
  2222. }
  2223. }
  2224. function createSetupContext(vm) {
  2225. let exposeCalled = false;
  2226. return {
  2227. get attrs() {
  2228. if (!vm._attrsProxy) {
  2229. const proxy = (vm._attrsProxy = {});
  2230. def(proxy, '_v_attr_proxy', true);
  2231. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2232. }
  2233. return vm._attrsProxy;
  2234. },
  2235. get listeners() {
  2236. if (!vm._listenersProxy) {
  2237. const proxy = (vm._listenersProxy = {});
  2238. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2239. }
  2240. return vm._listenersProxy;
  2241. },
  2242. get slots() {
  2243. return initSlotsProxy(vm);
  2244. },
  2245. emit: bind$1(vm.$emit, vm),
  2246. expose(exposed) {
  2247. {
  2248. if (exposeCalled) {
  2249. warn$2(`expose() should be called only once per setup().`, vm);
  2250. }
  2251. exposeCalled = true;
  2252. }
  2253. if (exposed) {
  2254. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2255. }
  2256. }
  2257. };
  2258. }
  2259. function syncSetupProxy(to, from, prev, instance, type) {
  2260. let changed = false;
  2261. for (const key in from) {
  2262. if (!(key in to)) {
  2263. changed = true;
  2264. defineProxyAttr(to, key, instance, type);
  2265. }
  2266. else if (from[key] !== prev[key]) {
  2267. changed = true;
  2268. }
  2269. }
  2270. for (const key in to) {
  2271. if (!(key in from)) {
  2272. changed = true;
  2273. delete to[key];
  2274. }
  2275. }
  2276. return changed;
  2277. }
  2278. function defineProxyAttr(proxy, key, instance, type) {
  2279. Object.defineProperty(proxy, key, {
  2280. enumerable: true,
  2281. configurable: true,
  2282. get() {
  2283. return instance[type][key];
  2284. }
  2285. });
  2286. }
  2287. function initSlotsProxy(vm) {
  2288. if (!vm._slotsProxy) {
  2289. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2290. }
  2291. return vm._slotsProxy;
  2292. }
  2293. function syncSetupSlots(to, from) {
  2294. for (const key in from) {
  2295. to[key] = from[key];
  2296. }
  2297. for (const key in to) {
  2298. if (!(key in from)) {
  2299. delete to[key];
  2300. }
  2301. }
  2302. }
  2303. /**
  2304. * @internal use manual type def because public setup context type relies on
  2305. * legacy VNode types
  2306. */
  2307. function useSlots() {
  2308. return getContext().slots;
  2309. }
  2310. /**
  2311. * @internal use manual type def because public setup context type relies on
  2312. * legacy VNode types
  2313. */
  2314. function useAttrs() {
  2315. return getContext().attrs;
  2316. }
  2317. /**
  2318. * Vue 2 only
  2319. * @internal use manual type def because public setup context type relies on
  2320. * legacy VNode types
  2321. */
  2322. function useListeners() {
  2323. return getContext().listeners;
  2324. }
  2325. function getContext() {
  2326. if (!currentInstance) {
  2327. warn$2(`useContext() called without active instance.`);
  2328. }
  2329. const vm = currentInstance;
  2330. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2331. }
  2332. /**
  2333. * Runtime helper for merging default declarations. Imported by compiled code
  2334. * only.
  2335. * @internal
  2336. */
  2337. function mergeDefaults(raw, defaults) {
  2338. const props = isArray(raw)
  2339. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2340. : raw;
  2341. for (const key in defaults) {
  2342. const opt = props[key];
  2343. if (opt) {
  2344. if (isArray(opt) || isFunction(opt)) {
  2345. props[key] = { type: opt, default: defaults[key] };
  2346. }
  2347. else {
  2348. opt.default = defaults[key];
  2349. }
  2350. }
  2351. else if (opt === null) {
  2352. props[key] = { default: defaults[key] };
  2353. }
  2354. else {
  2355. warn$2(`props default key "${key}" has no corresponding declaration.`);
  2356. }
  2357. }
  2358. return props;
  2359. }
  2360. function initRender(vm) {
  2361. vm._vnode = null; // the root of the child tree
  2362. vm._staticTrees = null; // v-once cached trees
  2363. const options = vm.$options;
  2364. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2365. const renderContext = parentVnode && parentVnode.context;
  2366. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2367. vm.$scopedSlots = parentVnode
  2368. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2369. : emptyObject;
  2370. // bind the createElement fn to this instance
  2371. // so that we get proper render context inside it.
  2372. // args order: tag, data, children, normalizationType, alwaysNormalize
  2373. // internal version is used by render functions compiled from templates
  2374. // @ts-expect-error
  2375. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2376. // normalization is always applied for the public version, used in
  2377. // user-written render functions.
  2378. // @ts-expect-error
  2379. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2380. // $attrs & $listeners are exposed for easier HOC creation.
  2381. // they need to be reactive so that HOCs using them are always updated
  2382. const parentData = parentVnode && parentVnode.data;
  2383. /* istanbul ignore else */
  2384. {
  2385. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2386. !isUpdatingChildComponent && warn$2(`$attrs is readonly.`, vm);
  2387. }, true);
  2388. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2389. !isUpdatingChildComponent && warn$2(`$listeners is readonly.`, vm);
  2390. }, true);
  2391. }
  2392. }
  2393. let currentRenderingInstance = null;
  2394. function renderMixin(Vue) {
  2395. // install runtime convenience helpers
  2396. installRenderHelpers(Vue.prototype);
  2397. Vue.prototype.$nextTick = function (fn) {
  2398. return nextTick(fn, this);
  2399. };
  2400. Vue.prototype._render = function () {
  2401. const vm = this;
  2402. const { render, _parentVnode } = vm.$options;
  2403. if (_parentVnode && vm._isMounted) {
  2404. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2405. if (vm._slotsProxy) {
  2406. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2407. }
  2408. }
  2409. // set parent vnode. this allows render functions to have access
  2410. // to the data on the placeholder node.
  2411. vm.$vnode = _parentVnode;
  2412. // render self
  2413. let vnode;
  2414. try {
  2415. // There's no need to maintain a stack because all render fns are called
  2416. // separately from one another. Nested component's render fns are called
  2417. // when parent component is patched.
  2418. setCurrentInstance(vm);
  2419. currentRenderingInstance = vm;
  2420. vnode = render.call(vm._renderProxy, vm.$createElement);
  2421. }
  2422. catch (e) {
  2423. handleError(e, vm, `render`);
  2424. // return error render result,
  2425. // or previous vnode to prevent render error causing blank component
  2426. /* istanbul ignore else */
  2427. if (vm.$options.renderError) {
  2428. try {
  2429. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2430. }
  2431. catch (e) {
  2432. handleError(e, vm, `renderError`);
  2433. vnode = vm._vnode;
  2434. }
  2435. }
  2436. else {
  2437. vnode = vm._vnode;
  2438. }
  2439. }
  2440. finally {
  2441. currentRenderingInstance = null;
  2442. setCurrentInstance();
  2443. }
  2444. // if the returned array contains only a single node, allow it
  2445. if (isArray(vnode) && vnode.length === 1) {
  2446. vnode = vnode[0];
  2447. }
  2448. // return empty vnode in case the render function errored out
  2449. if (!(vnode instanceof VNode)) {
  2450. if (isArray(vnode)) {
  2451. warn$2('Multiple root nodes returned from render function. Render function ' +
  2452. 'should return a single root node.', vm);
  2453. }
  2454. vnode = createEmptyVNode();
  2455. }
  2456. // set parent
  2457. vnode.parent = _parentVnode;
  2458. return vnode;
  2459. };
  2460. }
  2461. function ensureCtor(comp, base) {
  2462. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2463. comp = comp.default;
  2464. }
  2465. return isObject(comp) ? base.extend(comp) : comp;
  2466. }
  2467. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2468. const node = createEmptyVNode();
  2469. node.asyncFactory = factory;
  2470. node.asyncMeta = { data, context, children, tag };
  2471. return node;
  2472. }
  2473. function resolveAsyncComponent(factory, baseCtor) {
  2474. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2475. return factory.errorComp;
  2476. }
  2477. if (isDef(factory.resolved)) {
  2478. return factory.resolved;
  2479. }
  2480. const owner = currentRenderingInstance;
  2481. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2482. // already pending
  2483. factory.owners.push(owner);
  2484. }
  2485. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2486. return factory.loadingComp;
  2487. }
  2488. if (owner && !isDef(factory.owners)) {
  2489. const owners = (factory.owners = [owner]);
  2490. let sync = true;
  2491. let timerLoading = null;
  2492. let timerTimeout = null;
  2493. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2494. const forceRender = (renderCompleted) => {
  2495. for (let i = 0, l = owners.length; i < l; i++) {
  2496. owners[i].$forceUpdate();
  2497. }
  2498. if (renderCompleted) {
  2499. owners.length = 0;
  2500. if (timerLoading !== null) {
  2501. clearTimeout(timerLoading);
  2502. timerLoading = null;
  2503. }
  2504. if (timerTimeout !== null) {
  2505. clearTimeout(timerTimeout);
  2506. timerTimeout = null;
  2507. }
  2508. }
  2509. };
  2510. const resolve = once((res) => {
  2511. // cache resolved
  2512. factory.resolved = ensureCtor(res, baseCtor);
  2513. // invoke callbacks only if this is not a synchronous resolve
  2514. // (async resolves are shimmed as synchronous during SSR)
  2515. if (!sync) {
  2516. forceRender(true);
  2517. }
  2518. else {
  2519. owners.length = 0;
  2520. }
  2521. });
  2522. const reject = once(reason => {
  2523. warn$2(`Failed to resolve async component: ${String(factory)}` +
  2524. (reason ? `\nReason: ${reason}` : ''));
  2525. if (isDef(factory.errorComp)) {
  2526. factory.error = true;
  2527. forceRender(true);
  2528. }
  2529. });
  2530. const res = factory(resolve, reject);
  2531. if (isObject(res)) {
  2532. if (isPromise(res)) {
  2533. // () => Promise
  2534. if (isUndef(factory.resolved)) {
  2535. res.then(resolve, reject);
  2536. }
  2537. }
  2538. else if (isPromise(res.component)) {
  2539. res.component.then(resolve, reject);
  2540. if (isDef(res.error)) {
  2541. factory.errorComp = ensureCtor(res.error, baseCtor);
  2542. }
  2543. if (isDef(res.loading)) {
  2544. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2545. if (res.delay === 0) {
  2546. factory.loading = true;
  2547. }
  2548. else {
  2549. // @ts-expect-error NodeJS timeout type
  2550. timerLoading = setTimeout(() => {
  2551. timerLoading = null;
  2552. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2553. factory.loading = true;
  2554. forceRender(false);
  2555. }
  2556. }, res.delay || 200);
  2557. }
  2558. }
  2559. if (isDef(res.timeout)) {
  2560. // @ts-expect-error NodeJS timeout type
  2561. timerTimeout = setTimeout(() => {
  2562. timerTimeout = null;
  2563. if (isUndef(factory.resolved)) {
  2564. reject(`timeout (${res.timeout}ms)` );
  2565. }
  2566. }, res.timeout);
  2567. }
  2568. }
  2569. }
  2570. sync = false;
  2571. // return in case resolved synchronously
  2572. return factory.loading ? factory.loadingComp : factory.resolved;
  2573. }
  2574. }
  2575. function getFirstComponentChild(children) {
  2576. if (isArray(children)) {
  2577. for (let i = 0; i < children.length; i++) {
  2578. const c = children[i];
  2579. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2580. return c;
  2581. }
  2582. }
  2583. }
  2584. }
  2585. function initEvents(vm) {
  2586. vm._events = Object.create(null);
  2587. vm._hasHookEvent = false;
  2588. // init parent attached events
  2589. const listeners = vm.$options._parentListeners;
  2590. if (listeners) {
  2591. updateComponentListeners(vm, listeners);
  2592. }
  2593. }
  2594. let target$1;
  2595. function add$1(event, fn) {
  2596. target$1.$on(event, fn);
  2597. }
  2598. function remove$1(event, fn) {
  2599. target$1.$off(event, fn);
  2600. }
  2601. function createOnceHandler$1(event, fn) {
  2602. const _target = target$1;
  2603. return function onceHandler() {
  2604. const res = fn.apply(null, arguments);
  2605. if (res !== null) {
  2606. _target.$off(event, onceHandler);
  2607. }
  2608. };
  2609. }
  2610. function updateComponentListeners(vm, listeners, oldListeners) {
  2611. target$1 = vm;
  2612. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  2613. target$1 = undefined;
  2614. }
  2615. function eventsMixin(Vue) {
  2616. const hookRE = /^hook:/;
  2617. Vue.prototype.$on = function (event, fn) {
  2618. const vm = this;
  2619. if (isArray(event)) {
  2620. for (let i = 0, l = event.length; i < l; i++) {
  2621. vm.$on(event[i], fn);
  2622. }
  2623. }
  2624. else {
  2625. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2626. // optimize hook:event cost by using a boolean flag marked at registration
  2627. // instead of a hash lookup
  2628. if (hookRE.test(event)) {
  2629. vm._hasHookEvent = true;
  2630. }
  2631. }
  2632. return vm;
  2633. };
  2634. Vue.prototype.$once = function (event, fn) {
  2635. const vm = this;
  2636. function on() {
  2637. vm.$off(event, on);
  2638. fn.apply(vm, arguments);
  2639. }
  2640. on.fn = fn;
  2641. vm.$on(event, on);
  2642. return vm;
  2643. };
  2644. Vue.prototype.$off = function (event, fn) {
  2645. const vm = this;
  2646. // all
  2647. if (!arguments.length) {
  2648. vm._events = Object.create(null);
  2649. return vm;
  2650. }
  2651. // array of events
  2652. if (isArray(event)) {
  2653. for (let i = 0, l = event.length; i < l; i++) {
  2654. vm.$off(event[i], fn);
  2655. }
  2656. return vm;
  2657. }
  2658. // specific event
  2659. const cbs = vm._events[event];
  2660. if (!cbs) {
  2661. return vm;
  2662. }
  2663. if (!fn) {
  2664. vm._events[event] = null;
  2665. return vm;
  2666. }
  2667. // specific handler
  2668. let cb;
  2669. let i = cbs.length;
  2670. while (i--) {
  2671. cb = cbs[i];
  2672. if (cb === fn || cb.fn === fn) {
  2673. cbs.splice(i, 1);
  2674. break;
  2675. }
  2676. }
  2677. return vm;
  2678. };
  2679. Vue.prototype.$emit = function (event) {
  2680. const vm = this;
  2681. {
  2682. const lowerCaseEvent = event.toLowerCase();
  2683. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2684. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  2685. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  2686. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2687. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2688. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2689. }
  2690. }
  2691. let cbs = vm._events[event];
  2692. if (cbs) {
  2693. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2694. const args = toArray(arguments, 1);
  2695. const info = `event handler for "${event}"`;
  2696. for (let i = 0, l = cbs.length; i < l; i++) {
  2697. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  2698. }
  2699. }
  2700. return vm;
  2701. };
  2702. }
  2703. let activeEffectScope;
  2704. class EffectScope {
  2705. constructor(detached = false) {
  2706. this.detached = detached;
  2707. /**
  2708. * @internal
  2709. */
  2710. this.active = true;
  2711. /**
  2712. * @internal
  2713. */
  2714. this.effects = [];
  2715. /**
  2716. * @internal
  2717. */
  2718. this.cleanups = [];
  2719. this.parent = activeEffectScope;
  2720. if (!detached && activeEffectScope) {
  2721. this.index =
  2722. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  2723. }
  2724. }
  2725. run(fn) {
  2726. if (this.active) {
  2727. const currentEffectScope = activeEffectScope;
  2728. try {
  2729. activeEffectScope = this;
  2730. return fn();
  2731. }
  2732. finally {
  2733. activeEffectScope = currentEffectScope;
  2734. }
  2735. }
  2736. else {
  2737. warn$2(`cannot run an inactive effect scope.`);
  2738. }
  2739. }
  2740. /**
  2741. * This should only be called on non-detached scopes
  2742. * @internal
  2743. */
  2744. on() {
  2745. activeEffectScope = this;
  2746. }
  2747. /**
  2748. * This should only be called on non-detached scopes
  2749. * @internal
  2750. */
  2751. off() {
  2752. activeEffectScope = this.parent;
  2753. }
  2754. stop(fromParent) {
  2755. if (this.active) {
  2756. let i, l;
  2757. for (i = 0, l = this.effects.length; i < l; i++) {
  2758. this.effects[i].teardown();
  2759. }
  2760. for (i = 0, l = this.cleanups.length; i < l; i++) {
  2761. this.cleanups[i]();
  2762. }
  2763. if (this.scopes) {
  2764. for (i = 0, l = this.scopes.length; i < l; i++) {
  2765. this.scopes[i].stop(true);
  2766. }
  2767. }
  2768. // nested scope, dereference from parent to avoid memory leaks
  2769. if (!this.detached && this.parent && !fromParent) {
  2770. // optimized O(1) removal
  2771. const last = this.parent.scopes.pop();
  2772. if (last && last !== this) {
  2773. this.parent.scopes[this.index] = last;
  2774. last.index = this.index;
  2775. }
  2776. }
  2777. this.parent = undefined;
  2778. this.active = false;
  2779. }
  2780. }
  2781. }
  2782. function effectScope(detached) {
  2783. return new EffectScope(detached);
  2784. }
  2785. /**
  2786. * @internal
  2787. */
  2788. function recordEffectScope(effect, scope = activeEffectScope) {
  2789. if (scope && scope.active) {
  2790. scope.effects.push(effect);
  2791. }
  2792. }
  2793. function getCurrentScope() {
  2794. return activeEffectScope;
  2795. }
  2796. function onScopeDispose(fn) {
  2797. if (activeEffectScope) {
  2798. activeEffectScope.cleanups.push(fn);
  2799. }
  2800. else {
  2801. warn$2(`onScopeDispose() is called when there is no active effect scope` +
  2802. ` to be associated with.`);
  2803. }
  2804. }
  2805. let activeInstance = null;
  2806. let isUpdatingChildComponent = false;
  2807. function setActiveInstance(vm) {
  2808. const prevActiveInstance = activeInstance;
  2809. activeInstance = vm;
  2810. return () => {
  2811. activeInstance = prevActiveInstance;
  2812. };
  2813. }
  2814. function initLifecycle(vm) {
  2815. const options = vm.$options;
  2816. // locate first non-abstract parent
  2817. let parent = options.parent;
  2818. if (parent && !options.abstract) {
  2819. while (parent.$options.abstract && parent.$parent) {
  2820. parent = parent.$parent;
  2821. }
  2822. parent.$children.push(vm);
  2823. }
  2824. vm.$parent = parent;
  2825. vm.$root = parent ? parent.$root : vm;
  2826. vm.$children = [];
  2827. vm.$refs = {};
  2828. vm._provided = parent ? parent._provided : Object.create(null);
  2829. vm._watcher = null;
  2830. vm._inactive = null;
  2831. vm._directInactive = false;
  2832. vm._isMounted = false;
  2833. vm._isDestroyed = false;
  2834. vm._isBeingDestroyed = false;
  2835. }
  2836. function lifecycleMixin(Vue) {
  2837. Vue.prototype._update = function (vnode, hydrating) {
  2838. const vm = this;
  2839. const prevEl = vm.$el;
  2840. const prevVnode = vm._vnode;
  2841. const restoreActiveInstance = setActiveInstance(vm);
  2842. vm._vnode = vnode;
  2843. // Vue.prototype.__patch__ is injected in entry points
  2844. // based on the rendering backend used.
  2845. if (!prevVnode) {
  2846. // initial render
  2847. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2848. }
  2849. else {
  2850. // updates
  2851. vm.$el = vm.__patch__(prevVnode, vnode);
  2852. }
  2853. restoreActiveInstance();
  2854. // update __vue__ reference
  2855. if (prevEl) {
  2856. prevEl.__vue__ = null;
  2857. }
  2858. if (vm.$el) {
  2859. vm.$el.__vue__ = vm;
  2860. }
  2861. // if parent is an HOC, update its $el as well
  2862. let wrapper = vm;
  2863. while (wrapper &&
  2864. wrapper.$vnode &&
  2865. wrapper.$parent &&
  2866. wrapper.$vnode === wrapper.$parent._vnode) {
  2867. wrapper.$parent.$el = wrapper.$el;
  2868. wrapper = wrapper.$parent;
  2869. }
  2870. // updated hook is called by the scheduler to ensure that children are
  2871. // updated in a parent's updated hook.
  2872. };
  2873. Vue.prototype.$forceUpdate = function () {
  2874. const vm = this;
  2875. if (vm._watcher) {
  2876. vm._watcher.update();
  2877. }
  2878. };
  2879. Vue.prototype.$destroy = function () {
  2880. const vm = this;
  2881. if (vm._isBeingDestroyed) {
  2882. return;
  2883. }
  2884. callHook$1(vm, 'beforeDestroy');
  2885. vm._isBeingDestroyed = true;
  2886. // remove self from parent
  2887. const parent = vm.$parent;
  2888. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2889. remove$2(parent.$children, vm);
  2890. }
  2891. // teardown scope. this includes both the render watcher and other
  2892. // watchers created
  2893. vm._scope.stop();
  2894. // remove reference from data ob
  2895. // frozen object may not have observer.
  2896. if (vm._data.__ob__) {
  2897. vm._data.__ob__.vmCount--;
  2898. }
  2899. // call the last hook...
  2900. vm._isDestroyed = true;
  2901. // invoke destroy hooks on current rendered tree
  2902. vm.__patch__(vm._vnode, null);
  2903. // fire destroyed hook
  2904. callHook$1(vm, 'destroyed');
  2905. // turn off all instance listeners.
  2906. vm.$off();
  2907. // remove __vue__ reference
  2908. if (vm.$el) {
  2909. vm.$el.__vue__ = null;
  2910. }
  2911. // release circular reference (#6759)
  2912. if (vm.$vnode) {
  2913. vm.$vnode.parent = null;
  2914. }
  2915. };
  2916. }
  2917. function mountComponent(vm, el, hydrating) {
  2918. vm.$el = el;
  2919. if (!vm.$options.render) {
  2920. // @ts-expect-error invalid type
  2921. vm.$options.render = createEmptyVNode;
  2922. {
  2923. /* istanbul ignore if */
  2924. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2925. vm.$options.el ||
  2926. el) {
  2927. warn$2('You are using the runtime-only build of Vue where the template ' +
  2928. 'compiler is not available. Either pre-compile the templates into ' +
  2929. 'render functions, or use the compiler-included build.', vm);
  2930. }
  2931. else {
  2932. warn$2('Failed to mount component: template or render function not defined.', vm);
  2933. }
  2934. }
  2935. }
  2936. callHook$1(vm, 'beforeMount');
  2937. let updateComponent;
  2938. /* istanbul ignore if */
  2939. if (config.performance && mark) {
  2940. updateComponent = () => {
  2941. const name = vm._name;
  2942. const id = vm._uid;
  2943. const startTag = `vue-perf-start:${id}`;
  2944. const endTag = `vue-perf-end:${id}`;
  2945. mark(startTag);
  2946. const vnode = vm._render();
  2947. mark(endTag);
  2948. measure(`vue ${name} render`, startTag, endTag);
  2949. mark(startTag);
  2950. vm._update(vnode, hydrating);
  2951. mark(endTag);
  2952. measure(`vue ${name} patch`, startTag, endTag);
  2953. };
  2954. }
  2955. else {
  2956. updateComponent = () => {
  2957. vm._update(vm._render(), hydrating);
  2958. };
  2959. }
  2960. const watcherOptions = {
  2961. before() {
  2962. if (vm._isMounted && !vm._isDestroyed) {
  2963. callHook$1(vm, 'beforeUpdate');
  2964. }
  2965. }
  2966. };
  2967. {
  2968. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  2969. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  2970. }
  2971. // we set this to vm._watcher inside the watcher's constructor
  2972. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2973. // component's mounted hook), which relies on vm._watcher being already defined
  2974. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  2975. hydrating = false;
  2976. // flush buffer for flush: "pre" watchers queued in setup()
  2977. const preWatchers = vm._preWatchers;
  2978. if (preWatchers) {
  2979. for (let i = 0; i < preWatchers.length; i++) {
  2980. preWatchers[i].run();
  2981. }
  2982. }
  2983. // manually mounted instance, call mounted on self
  2984. // mounted is called for render-created child components in its inserted hook
  2985. if (vm.$vnode == null) {
  2986. vm._isMounted = true;
  2987. callHook$1(vm, 'mounted');
  2988. }
  2989. return vm;
  2990. }
  2991. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  2992. {
  2993. isUpdatingChildComponent = true;
  2994. }
  2995. // determine whether component has slot children
  2996. // we need to do this before overwriting $options._renderChildren.
  2997. // check if there are dynamic scopedSlots (hand-written or compiled but with
  2998. // dynamic slot names). Static scoped slots compiled from template has the
  2999. // "$stable" marker.
  3000. const newScopedSlots = parentVnode.data.scopedSlots;
  3001. const oldScopedSlots = vm.$scopedSlots;
  3002. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3003. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3004. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3005. (!newScopedSlots && vm.$scopedSlots.$key));
  3006. // Any static slot children from the parent may have changed during parent's
  3007. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3008. // update is necessary to ensure correctness.
  3009. let needsForceUpdate = !!(renderChildren || // has new static slots
  3010. vm.$options._renderChildren || // has old static slots
  3011. hasDynamicScopedSlot);
  3012. const prevVNode = vm.$vnode;
  3013. vm.$options._parentVnode = parentVnode;
  3014. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3015. if (vm._vnode) {
  3016. // update child tree's parent
  3017. vm._vnode.parent = parentVnode;
  3018. }
  3019. vm.$options._renderChildren = renderChildren;
  3020. // update $attrs and $listeners hash
  3021. // these are also reactive so they may trigger child update if the child
  3022. // used them during render
  3023. const attrs = parentVnode.data.attrs || emptyObject;
  3024. if (vm._attrsProxy) {
  3025. // force update if attrs are accessed and has changed since it may be
  3026. // passed to a child component.
  3027. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3028. needsForceUpdate = true;
  3029. }
  3030. }
  3031. vm.$attrs = attrs;
  3032. // update listeners
  3033. listeners = listeners || emptyObject;
  3034. const prevListeners = vm.$options._parentListeners;
  3035. if (vm._listenersProxy) {
  3036. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3037. }
  3038. vm.$listeners = vm.$options._parentListeners = listeners;
  3039. updateComponentListeners(vm, listeners, prevListeners);
  3040. // update props
  3041. if (propsData && vm.$options.props) {
  3042. toggleObserving(false);
  3043. const props = vm._props;
  3044. const propKeys = vm.$options._propKeys || [];
  3045. for (let i = 0; i < propKeys.length; i++) {
  3046. const key = propKeys[i];
  3047. const propOptions = vm.$options.props; // wtf flow?
  3048. props[key] = validateProp(key, propOptions, propsData, vm);
  3049. }
  3050. toggleObserving(true);
  3051. // keep a copy of raw propsData
  3052. vm.$options.propsData = propsData;
  3053. }
  3054. // resolve slots + force update if has children
  3055. if (needsForceUpdate) {
  3056. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3057. vm.$forceUpdate();
  3058. }
  3059. {
  3060. isUpdatingChildComponent = false;
  3061. }
  3062. }
  3063. function isInInactiveTree(vm) {
  3064. while (vm && (vm = vm.$parent)) {
  3065. if (vm._inactive)
  3066. return true;
  3067. }
  3068. return false;
  3069. }
  3070. function activateChildComponent(vm, direct) {
  3071. if (direct) {
  3072. vm._directInactive = false;
  3073. if (isInInactiveTree(vm)) {
  3074. return;
  3075. }
  3076. }
  3077. else if (vm._directInactive) {
  3078. return;
  3079. }
  3080. if (vm._inactive || vm._inactive === null) {
  3081. vm._inactive = false;
  3082. for (let i = 0; i < vm.$children.length; i++) {
  3083. activateChildComponent(vm.$children[i]);
  3084. }
  3085. callHook$1(vm, 'activated');
  3086. }
  3087. }
  3088. function deactivateChildComponent(vm, direct) {
  3089. if (direct) {
  3090. vm._directInactive = true;
  3091. if (isInInactiveTree(vm)) {
  3092. return;
  3093. }
  3094. }
  3095. if (!vm._inactive) {
  3096. vm._inactive = true;
  3097. for (let i = 0; i < vm.$children.length; i++) {
  3098. deactivateChildComponent(vm.$children[i]);
  3099. }
  3100. callHook$1(vm, 'deactivated');
  3101. }
  3102. }
  3103. function callHook$1(vm, hook, args, setContext = true) {
  3104. // #7573 disable dep collection when invoking lifecycle hooks
  3105. pushTarget();
  3106. const prevInst = currentInstance;
  3107. const prevScope = getCurrentScope();
  3108. setContext && setCurrentInstance(vm);
  3109. const handlers = vm.$options[hook];
  3110. const info = `${hook} hook`;
  3111. if (handlers) {
  3112. for (let i = 0, j = handlers.length; i < j; i++) {
  3113. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3114. }
  3115. }
  3116. if (vm._hasHookEvent) {
  3117. vm.$emit('hook:' + hook);
  3118. }
  3119. if (setContext) {
  3120. setCurrentInstance(prevInst);
  3121. prevScope && prevScope.on();
  3122. }
  3123. popTarget();
  3124. }
  3125. const MAX_UPDATE_COUNT = 100;
  3126. const queue = [];
  3127. const activatedChildren = [];
  3128. let has = {};
  3129. let circular = {};
  3130. let waiting = false;
  3131. let flushing = false;
  3132. let index$1 = 0;
  3133. /**
  3134. * Reset the scheduler's state.
  3135. */
  3136. function resetSchedulerState() {
  3137. index$1 = queue.length = activatedChildren.length = 0;
  3138. has = {};
  3139. {
  3140. circular = {};
  3141. }
  3142. waiting = flushing = false;
  3143. }
  3144. // Async edge case #6566 requires saving the timestamp when event listeners are
  3145. // attached. However, calling performance.now() has a perf overhead especially
  3146. // if the page has thousands of event listeners. Instead, we take a timestamp
  3147. // every time the scheduler flushes and use that for all event listeners
  3148. // attached during that flush.
  3149. let currentFlushTimestamp = 0;
  3150. // Async edge case fix requires storing an event listener's attach timestamp.
  3151. let getNow = Date.now;
  3152. // Determine what event timestamp the browser is using. Annoyingly, the
  3153. // timestamp can either be hi-res (relative to page load) or low-res
  3154. // (relative to UNIX epoch), so in order to compare time we have to use the
  3155. // same timestamp type when saving the flush timestamp.
  3156. // All IE versions use low-res event timestamps, and have problematic clock
  3157. // implementations (#9632)
  3158. if (inBrowser && !isIE) {
  3159. const performance = window.performance;
  3160. if (performance &&
  3161. typeof performance.now === 'function' &&
  3162. getNow() > document.createEvent('Event').timeStamp) {
  3163. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3164. // smaller than it, it means the event is using a hi-res timestamp,
  3165. // and we need to use the hi-res version for event listener timestamps as
  3166. // well.
  3167. getNow = () => performance.now();
  3168. }
  3169. }
  3170. const sortCompareFn = (a, b) => {
  3171. if (a.post) {
  3172. if (!b.post)
  3173. return 1;
  3174. }
  3175. else if (b.post) {
  3176. return -1;
  3177. }
  3178. return a.id - b.id;
  3179. };
  3180. /**
  3181. * Flush both queues and run the watchers.
  3182. */
  3183. function flushSchedulerQueue() {
  3184. currentFlushTimestamp = getNow();
  3185. flushing = true;
  3186. let watcher, id;
  3187. // Sort queue before flush.
  3188. // This ensures that:
  3189. // 1. Components are updated from parent to child. (because parent is always
  3190. // created before the child)
  3191. // 2. A component's user watchers are run before its render watcher (because
  3192. // user watchers are created before the render watcher)
  3193. // 3. If a component is destroyed during a parent component's watcher run,
  3194. // its watchers can be skipped.
  3195. queue.sort(sortCompareFn);
  3196. // do not cache length because more watchers might be pushed
  3197. // as we run existing watchers
  3198. for (index$1 = 0; index$1 < queue.length; index$1++) {
  3199. watcher = queue[index$1];
  3200. if (watcher.before) {
  3201. watcher.before();
  3202. }
  3203. id = watcher.id;
  3204. has[id] = null;
  3205. watcher.run();
  3206. // in dev build, check and stop circular updates.
  3207. if (has[id] != null) {
  3208. circular[id] = (circular[id] || 0) + 1;
  3209. if (circular[id] > MAX_UPDATE_COUNT) {
  3210. warn$2('You may have an infinite update loop ' +
  3211. (watcher.user
  3212. ? `in watcher with expression "${watcher.expression}"`
  3213. : `in a component render function.`), watcher.vm);
  3214. break;
  3215. }
  3216. }
  3217. }
  3218. // keep copies of post queues before resetting state
  3219. const activatedQueue = activatedChildren.slice();
  3220. const updatedQueue = queue.slice();
  3221. resetSchedulerState();
  3222. // call component updated and activated hooks
  3223. callActivatedHooks(activatedQueue);
  3224. callUpdatedHooks(updatedQueue);
  3225. cleanupDeps();
  3226. // devtool hook
  3227. /* istanbul ignore if */
  3228. if (devtools && config.devtools) {
  3229. devtools.emit('flush');
  3230. }
  3231. }
  3232. function callUpdatedHooks(queue) {
  3233. let i = queue.length;
  3234. while (i--) {
  3235. const watcher = queue[i];
  3236. const vm = watcher.vm;
  3237. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3238. callHook$1(vm, 'updated');
  3239. }
  3240. }
  3241. }
  3242. /**
  3243. * Queue a kept-alive component that was activated during patch.
  3244. * The queue will be processed after the entire tree has been patched.
  3245. */
  3246. function queueActivatedComponent(vm) {
  3247. // setting _inactive to false here so that a render function can
  3248. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3249. vm._inactive = false;
  3250. activatedChildren.push(vm);
  3251. }
  3252. function callActivatedHooks(queue) {
  3253. for (let i = 0; i < queue.length; i++) {
  3254. queue[i]._inactive = true;
  3255. activateChildComponent(queue[i], true /* true */);
  3256. }
  3257. }
  3258. /**
  3259. * Push a watcher into the watcher queue.
  3260. * Jobs with duplicate IDs will be skipped unless it's
  3261. * pushed when the queue is being flushed.
  3262. */
  3263. function queueWatcher(watcher) {
  3264. const id = watcher.id;
  3265. if (has[id] != null) {
  3266. return;
  3267. }
  3268. if (watcher === Dep.target && watcher.noRecurse) {
  3269. return;
  3270. }
  3271. has[id] = true;
  3272. if (!flushing) {
  3273. queue.push(watcher);
  3274. }
  3275. else {
  3276. // if already flushing, splice the watcher based on its id
  3277. // if already past its id, it will be run next immediately.
  3278. let i = queue.length - 1;
  3279. while (i > index$1 && queue[i].id > watcher.id) {
  3280. i--;
  3281. }
  3282. queue.splice(i + 1, 0, watcher);
  3283. }
  3284. // queue the flush
  3285. if (!waiting) {
  3286. waiting = true;
  3287. if (!config.async) {
  3288. flushSchedulerQueue();
  3289. return;
  3290. }
  3291. nextTick(flushSchedulerQueue);
  3292. }
  3293. }
  3294. const WATCHER = `watcher`;
  3295. const WATCHER_CB = `${WATCHER} callback`;
  3296. const WATCHER_GETTER = `${WATCHER} getter`;
  3297. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  3298. // Simple effect.
  3299. function watchEffect(effect, options) {
  3300. return doWatch(effect, null, options);
  3301. }
  3302. function watchPostEffect(effect, options) {
  3303. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3304. }
  3305. function watchSyncEffect(effect, options) {
  3306. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3307. }
  3308. // initial value for watchers to trigger on undefined initial values
  3309. const INITIAL_WATCHER_VALUE = {};
  3310. // implementation
  3311. function watch(source, cb, options) {
  3312. if (typeof cb !== 'function') {
  3313. warn$2(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3314. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3315. `supports \`watch(source, cb, options?) signature.`);
  3316. }
  3317. return doWatch(source, cb, options);
  3318. }
  3319. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  3320. if (!cb) {
  3321. if (immediate !== undefined) {
  3322. warn$2(`watch() "immediate" option is only respected when using the ` +
  3323. `watch(source, callback, options?) signature.`);
  3324. }
  3325. if (deep !== undefined) {
  3326. warn$2(`watch() "deep" option is only respected when using the ` +
  3327. `watch(source, callback, options?) signature.`);
  3328. }
  3329. }
  3330. const warnInvalidSource = (s) => {
  3331. warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  3332. `function, a ref, a reactive object, or an array of these types.`);
  3333. };
  3334. const instance = currentInstance;
  3335. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  3336. let getter;
  3337. let forceTrigger = false;
  3338. let isMultiSource = false;
  3339. if (isRef(source)) {
  3340. getter = () => source.value;
  3341. forceTrigger = isShallow(source);
  3342. }
  3343. else if (isReactive(source)) {
  3344. getter = () => {
  3345. source.__ob__.dep.depend();
  3346. return source;
  3347. };
  3348. deep = true;
  3349. }
  3350. else if (isArray(source)) {
  3351. isMultiSource = true;
  3352. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3353. getter = () => source.map(s => {
  3354. if (isRef(s)) {
  3355. return s.value;
  3356. }
  3357. else if (isReactive(s)) {
  3358. return traverse(s);
  3359. }
  3360. else if (isFunction(s)) {
  3361. return call(s, WATCHER_GETTER);
  3362. }
  3363. else {
  3364. warnInvalidSource(s);
  3365. }
  3366. });
  3367. }
  3368. else if (isFunction(source)) {
  3369. if (cb) {
  3370. // getter with cb
  3371. getter = () => call(source, WATCHER_GETTER);
  3372. }
  3373. else {
  3374. // no cb -> simple effect
  3375. getter = () => {
  3376. if (instance && instance._isDestroyed) {
  3377. return;
  3378. }
  3379. if (cleanup) {
  3380. cleanup();
  3381. }
  3382. return call(source, WATCHER, [onCleanup]);
  3383. };
  3384. }
  3385. }
  3386. else {
  3387. getter = noop;
  3388. warnInvalidSource(source);
  3389. }
  3390. if (cb && deep) {
  3391. const baseGetter = getter;
  3392. getter = () => traverse(baseGetter());
  3393. }
  3394. let cleanup;
  3395. let onCleanup = (fn) => {
  3396. cleanup = watcher.onStop = () => {
  3397. call(fn, WATCHER_CLEANUP);
  3398. };
  3399. };
  3400. // in SSR there is no need to setup an actual effect, and it should be noop
  3401. // unless it's eager
  3402. if (isServerRendering()) {
  3403. // we will also not call the invalidate callback (+ runner is not set up)
  3404. onCleanup = noop;
  3405. if (!cb) {
  3406. getter();
  3407. }
  3408. else if (immediate) {
  3409. call(cb, WATCHER_CB, [
  3410. getter(),
  3411. isMultiSource ? [] : undefined,
  3412. onCleanup
  3413. ]);
  3414. }
  3415. return noop;
  3416. }
  3417. const watcher = new Watcher(currentInstance, getter, noop, {
  3418. lazy: true
  3419. });
  3420. watcher.noRecurse = !cb;
  3421. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3422. // overwrite default run
  3423. watcher.run = () => {
  3424. if (!watcher.active) {
  3425. return;
  3426. }
  3427. if (cb) {
  3428. // watch(source, cb)
  3429. const newValue = watcher.get();
  3430. if (deep ||
  3431. forceTrigger ||
  3432. (isMultiSource
  3433. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3434. : hasChanged(newValue, oldValue))) {
  3435. // cleanup before running cb again
  3436. if (cleanup) {
  3437. cleanup();
  3438. }
  3439. call(cb, WATCHER_CB, [
  3440. newValue,
  3441. // pass undefined as the old value when it's changed for the first time
  3442. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3443. onCleanup
  3444. ]);
  3445. oldValue = newValue;
  3446. }
  3447. }
  3448. else {
  3449. // watchEffect
  3450. watcher.get();
  3451. }
  3452. };
  3453. if (flush === 'sync') {
  3454. watcher.update = watcher.run;
  3455. }
  3456. else if (flush === 'post') {
  3457. watcher.post = true;
  3458. watcher.update = () => queueWatcher(watcher);
  3459. }
  3460. else {
  3461. // pre
  3462. watcher.update = () => {
  3463. if (instance && instance === currentInstance && !instance._isMounted) {
  3464. // pre-watcher triggered before
  3465. const buffer = instance._preWatchers || (instance._preWatchers = []);
  3466. if (buffer.indexOf(watcher) < 0)
  3467. buffer.push(watcher);
  3468. }
  3469. else {
  3470. queueWatcher(watcher);
  3471. }
  3472. };
  3473. }
  3474. {
  3475. watcher.onTrack = onTrack;
  3476. watcher.onTrigger = onTrigger;
  3477. }
  3478. // initial run
  3479. if (cb) {
  3480. if (immediate) {
  3481. watcher.run();
  3482. }
  3483. else {
  3484. oldValue = watcher.get();
  3485. }
  3486. }
  3487. else if (flush === 'post' && instance) {
  3488. instance.$once('hook:mounted', () => watcher.get());
  3489. }
  3490. else {
  3491. watcher.get();
  3492. }
  3493. return () => {
  3494. watcher.teardown();
  3495. };
  3496. }
  3497. function provide(key, value) {
  3498. if (!currentInstance) {
  3499. {
  3500. warn$2(`provide() can only be used inside setup().`);
  3501. }
  3502. }
  3503. else {
  3504. // TS doesn't allow symbol as index type
  3505. resolveProvided(currentInstance)[key] = value;
  3506. }
  3507. }
  3508. function resolveProvided(vm) {
  3509. // by default an instance inherits its parent's provides object
  3510. // but when it needs to provide values of its own, it creates its
  3511. // own provides object using parent provides object as prototype.
  3512. // this way in `inject` we can simply look up injections from direct
  3513. // parent and let the prototype chain do the work.
  3514. const existing = vm._provided;
  3515. const parentProvides = vm.$parent && vm.$parent._provided;
  3516. if (parentProvides === existing) {
  3517. return (vm._provided = Object.create(parentProvides));
  3518. }
  3519. else {
  3520. return existing;
  3521. }
  3522. }
  3523. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3524. // fallback to `currentRenderingInstance` so that this can be called in
  3525. // a functional component
  3526. const instance = currentInstance;
  3527. if (instance) {
  3528. // #2400
  3529. // to support `app.use` plugins,
  3530. // fallback to appContext's `provides` if the instance is at root
  3531. const provides = instance.$parent && instance.$parent._provided;
  3532. if (provides && key in provides) {
  3533. // TS doesn't allow symbol as index type
  3534. return provides[key];
  3535. }
  3536. else if (arguments.length > 1) {
  3537. return treatDefaultAsFactory && isFunction(defaultValue)
  3538. ? defaultValue.call(instance)
  3539. : defaultValue;
  3540. }
  3541. else {
  3542. warn$2(`injection "${String(key)}" not found.`);
  3543. }
  3544. }
  3545. else {
  3546. warn$2(`inject() can only be used inside setup() or functional components.`);
  3547. }
  3548. }
  3549. /**
  3550. * @internal this function needs manual public type declaration because it relies
  3551. * on previously manually authored types from Vue 2
  3552. */
  3553. function h(type, props, children) {
  3554. if (!currentInstance) {
  3555. warn$2(`globally imported h() can only be invoked when there is an active ` +
  3556. `component instance, e.g. synchronously in a component's render or setup function.`);
  3557. }
  3558. return createElement$1(currentInstance, type, props, children, 2, true);
  3559. }
  3560. function handleError(err, vm, info) {
  3561. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  3562. // See: https://github.com/vuejs/vuex/issues/1505
  3563. pushTarget();
  3564. try {
  3565. if (vm) {
  3566. let cur = vm;
  3567. while ((cur = cur.$parent)) {
  3568. const hooks = cur.$options.errorCaptured;
  3569. if (hooks) {
  3570. for (let i = 0; i < hooks.length; i++) {
  3571. try {
  3572. const capture = hooks[i].call(cur, err, vm, info) === false;
  3573. if (capture)
  3574. return;
  3575. }
  3576. catch (e) {
  3577. globalHandleError(e, cur, 'errorCaptured hook');
  3578. }
  3579. }
  3580. }
  3581. }
  3582. }
  3583. globalHandleError(err, vm, info);
  3584. }
  3585. finally {
  3586. popTarget();
  3587. }
  3588. }
  3589. function invokeWithErrorHandling(handler, context, args, vm, info) {
  3590. let res;
  3591. try {
  3592. res = args ? handler.apply(context, args) : handler.call(context);
  3593. if (res && !res._isVue && isPromise(res) && !res._handled) {
  3594. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  3595. res._handled = true;
  3596. }
  3597. }
  3598. catch (e) {
  3599. handleError(e, vm, info);
  3600. }
  3601. return res;
  3602. }
  3603. function globalHandleError(err, vm, info) {
  3604. if (config.errorHandler) {
  3605. try {
  3606. return config.errorHandler.call(null, err, vm, info);
  3607. }
  3608. catch (e) {
  3609. // if the user intentionally throws the original error in the handler,
  3610. // do not log it twice
  3611. if (e !== err) {
  3612. logError(e, null, 'config.errorHandler');
  3613. }
  3614. }
  3615. }
  3616. logError(err, vm, info);
  3617. }
  3618. function logError(err, vm, info) {
  3619. {
  3620. warn$2(`Error in ${info}: "${err.toString()}"`, vm);
  3621. }
  3622. /* istanbul ignore else */
  3623. if (inBrowser && typeof console !== 'undefined') {
  3624. console.error(err);
  3625. }
  3626. else {
  3627. throw err;
  3628. }
  3629. }
  3630. /* globals MutationObserver */
  3631. let isUsingMicroTask = false;
  3632. const callbacks = [];
  3633. let pending = false;
  3634. function flushCallbacks() {
  3635. pending = false;
  3636. const copies = callbacks.slice(0);
  3637. callbacks.length = 0;
  3638. for (let i = 0; i < copies.length; i++) {
  3639. copies[i]();
  3640. }
  3641. }
  3642. // Here we have async deferring wrappers using microtasks.
  3643. // In 2.5 we used (macro) tasks (in combination with microtasks).
  3644. // However, it has subtle problems when state is changed right before repaint
  3645. // (e.g. #6813, out-in transitions).
  3646. // Also, using (macro) tasks in event handler would cause some weird behaviors
  3647. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  3648. // So we now use microtasks everywhere, again.
  3649. // A major drawback of this tradeoff is that there are some scenarios
  3650. // where microtasks have too high a priority and fire in between supposedly
  3651. // sequential events (e.g. #4521, #6690, which have workarounds)
  3652. // or even between bubbling of the same event (#6566).
  3653. let timerFunc;
  3654. // The nextTick behavior leverages the microtask queue, which can be accessed
  3655. // via either native Promise.then or MutationObserver.
  3656. // MutationObserver has wider support, however it is seriously bugged in
  3657. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  3658. // completely stops working after triggering a few times... so, if native
  3659. // Promise is available, we will use it:
  3660. /* istanbul ignore next, $flow-disable-line */
  3661. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  3662. const p = Promise.resolve();
  3663. timerFunc = () => {
  3664. p.then(flushCallbacks);
  3665. // In problematic UIWebViews, Promise.then doesn't completely break, but
  3666. // it can get stuck in a weird state where callbacks are pushed into the
  3667. // microtask queue but the queue isn't being flushed, until the browser
  3668. // needs to do some other work, e.g. handle a timer. Therefore we can
  3669. // "force" the microtask queue to be flushed by adding an empty timer.
  3670. if (isIOS)
  3671. setTimeout(noop);
  3672. };
  3673. isUsingMicroTask = true;
  3674. }
  3675. else if (!isIE &&
  3676. typeof MutationObserver !== 'undefined' &&
  3677. (isNative(MutationObserver) ||
  3678. // PhantomJS and iOS 7.x
  3679. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  3680. // Use MutationObserver where native Promise is not available,
  3681. // e.g. PhantomJS, iOS7, Android 4.4
  3682. // (#6466 MutationObserver is unreliable in IE11)
  3683. let counter = 1;
  3684. const observer = new MutationObserver(flushCallbacks);
  3685. const textNode = document.createTextNode(String(counter));
  3686. observer.observe(textNode, {
  3687. characterData: true
  3688. });
  3689. timerFunc = () => {
  3690. counter = (counter + 1) % 2;
  3691. textNode.data = String(counter);
  3692. };
  3693. isUsingMicroTask = true;
  3694. }
  3695. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  3696. // Fallback to setImmediate.
  3697. // Technically it leverages the (macro) task queue,
  3698. // but it is still a better choice than setTimeout.
  3699. timerFunc = () => {
  3700. setImmediate(flushCallbacks);
  3701. };
  3702. }
  3703. else {
  3704. // Fallback to setTimeout.
  3705. timerFunc = () => {
  3706. setTimeout(flushCallbacks, 0);
  3707. };
  3708. }
  3709. /**
  3710. * @internal
  3711. */
  3712. function nextTick(cb, ctx) {
  3713. let _resolve;
  3714. callbacks.push(() => {
  3715. if (cb) {
  3716. try {
  3717. cb.call(ctx);
  3718. }
  3719. catch (e) {
  3720. handleError(e, ctx, 'nextTick');
  3721. }
  3722. }
  3723. else if (_resolve) {
  3724. _resolve(ctx);
  3725. }
  3726. });
  3727. if (!pending) {
  3728. pending = true;
  3729. timerFunc();
  3730. }
  3731. // $flow-disable-line
  3732. if (!cb && typeof Promise !== 'undefined') {
  3733. return new Promise(resolve => {
  3734. _resolve = resolve;
  3735. });
  3736. }
  3737. }
  3738. function useCssModule(name = '$style') {
  3739. /* istanbul ignore else */
  3740. {
  3741. if (!currentInstance) {
  3742. warn$2(`useCssModule must be called inside setup()`);
  3743. return emptyObject;
  3744. }
  3745. const mod = currentInstance[name];
  3746. if (!mod) {
  3747. warn$2(`Current instance does not have CSS module named "${name}".`);
  3748. return emptyObject;
  3749. }
  3750. return mod;
  3751. }
  3752. }
  3753. /**
  3754. * Runtime helper for SFC's CSS variable injection feature.
  3755. * @private
  3756. */
  3757. function useCssVars(getter) {
  3758. if (!inBrowser && !false)
  3759. return;
  3760. const instance = currentInstance;
  3761. if (!instance) {
  3762. warn$2(`useCssVars is called without current active component instance.`);
  3763. return;
  3764. }
  3765. watchPostEffect(() => {
  3766. const el = instance.$el;
  3767. const vars = getter(instance, instance._setupProxy);
  3768. if (el && el.nodeType === 1) {
  3769. const style = el.style;
  3770. for (const key in vars) {
  3771. style.setProperty(`--${key}`, vars[key]);
  3772. }
  3773. }
  3774. });
  3775. }
  3776. /**
  3777. * v3-compatible async component API.
  3778. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3779. * because it relies on existing manual types
  3780. */
  3781. function defineAsyncComponent(source) {
  3782. if (isFunction(source)) {
  3783. source = { loader: source };
  3784. }
  3785. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3786. suspensible = false, // in Vue 3 default is true
  3787. onError: userOnError } = source;
  3788. if (suspensible) {
  3789. warn$2(`The suspensible option for async components is not supported in Vue2. It is ignored.`);
  3790. }
  3791. let pendingRequest = null;
  3792. let retries = 0;
  3793. const retry = () => {
  3794. retries++;
  3795. pendingRequest = null;
  3796. return load();
  3797. };
  3798. const load = () => {
  3799. let thisRequest;
  3800. return (pendingRequest ||
  3801. (thisRequest = pendingRequest =
  3802. loader()
  3803. .catch(err => {
  3804. err = err instanceof Error ? err : new Error(String(err));
  3805. if (userOnError) {
  3806. return new Promise((resolve, reject) => {
  3807. const userRetry = () => resolve(retry());
  3808. const userFail = () => reject(err);
  3809. userOnError(err, userRetry, userFail, retries + 1);
  3810. });
  3811. }
  3812. else {
  3813. throw err;
  3814. }
  3815. })
  3816. .then((comp) => {
  3817. if (thisRequest !== pendingRequest && pendingRequest) {
  3818. return pendingRequest;
  3819. }
  3820. if (!comp) {
  3821. warn$2(`Async component loader resolved to undefined. ` +
  3822. `If you are using retry(), make sure to return its return value.`);
  3823. }
  3824. // interop module default
  3825. if (comp &&
  3826. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3827. comp = comp.default;
  3828. }
  3829. if (comp && !isObject(comp) && !isFunction(comp)) {
  3830. throw new Error(`Invalid async component load result: ${comp}`);
  3831. }
  3832. return comp;
  3833. })));
  3834. };
  3835. return () => {
  3836. const component = load();
  3837. return {
  3838. component,
  3839. delay,
  3840. timeout,
  3841. error: errorComponent,
  3842. loading: loadingComponent
  3843. };
  3844. };
  3845. }
  3846. function createLifeCycle(hookName) {
  3847. return (fn, target = currentInstance) => {
  3848. if (!target) {
  3849. warn$2(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3850. `associated with. ` +
  3851. `Lifecycle injection APIs can only be used during execution of setup().`);
  3852. return;
  3853. }
  3854. return injectHook(target, hookName, fn);
  3855. };
  3856. }
  3857. function formatName(name) {
  3858. if (name === 'beforeDestroy') {
  3859. name = 'beforeUnmount';
  3860. }
  3861. else if (name === 'destroyed') {
  3862. name = 'unmounted';
  3863. }
  3864. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3865. }
  3866. function injectHook(instance, hookName, fn) {
  3867. const options = instance.$options;
  3868. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3869. }
  3870. const onBeforeMount = createLifeCycle('beforeMount');
  3871. const onMounted = createLifeCycle('mounted');
  3872. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3873. const onUpdated = createLifeCycle('updated');
  3874. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3875. const onUnmounted = createLifeCycle('destroyed');
  3876. const onActivated = createLifeCycle('activated');
  3877. const onDeactivated = createLifeCycle('deactivated');
  3878. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3879. const onRenderTracked = createLifeCycle('renderTracked');
  3880. const onRenderTriggered = createLifeCycle('renderTriggered');
  3881. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3882. function onErrorCaptured(hook, target = currentInstance) {
  3883. injectErrorCapturedHook(hook, target);
  3884. }
  3885. /**
  3886. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3887. */
  3888. const version = '2.7.15';
  3889. /**
  3890. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3891. */
  3892. function defineComponent(options) {
  3893. return options;
  3894. }
  3895. var vca = /*#__PURE__*/Object.freeze({
  3896. __proto__: null,
  3897. version: version,
  3898. defineComponent: defineComponent,
  3899. ref: ref$1,
  3900. shallowRef: shallowRef,
  3901. isRef: isRef,
  3902. toRef: toRef,
  3903. toRefs: toRefs,
  3904. unref: unref,
  3905. proxyRefs: proxyRefs,
  3906. customRef: customRef,
  3907. triggerRef: triggerRef,
  3908. reactive: reactive,
  3909. isReactive: isReactive,
  3910. isReadonly: isReadonly,
  3911. isShallow: isShallow,
  3912. isProxy: isProxy,
  3913. shallowReactive: shallowReactive,
  3914. markRaw: markRaw,
  3915. toRaw: toRaw,
  3916. readonly: readonly,
  3917. shallowReadonly: shallowReadonly,
  3918. computed: computed,
  3919. watch: watch,
  3920. watchEffect: watchEffect,
  3921. watchPostEffect: watchPostEffect,
  3922. watchSyncEffect: watchSyncEffect,
  3923. EffectScope: EffectScope,
  3924. effectScope: effectScope,
  3925. onScopeDispose: onScopeDispose,
  3926. getCurrentScope: getCurrentScope,
  3927. provide: provide,
  3928. inject: inject,
  3929. h: h,
  3930. getCurrentInstance: getCurrentInstance,
  3931. useSlots: useSlots,
  3932. useAttrs: useAttrs,
  3933. useListeners: useListeners,
  3934. mergeDefaults: mergeDefaults,
  3935. nextTick: nextTick,
  3936. set: set,
  3937. del: del,
  3938. useCssModule: useCssModule,
  3939. useCssVars: useCssVars,
  3940. defineAsyncComponent: defineAsyncComponent,
  3941. onBeforeMount: onBeforeMount,
  3942. onMounted: onMounted,
  3943. onBeforeUpdate: onBeforeUpdate,
  3944. onUpdated: onUpdated,
  3945. onBeforeUnmount: onBeforeUnmount,
  3946. onUnmounted: onUnmounted,
  3947. onActivated: onActivated,
  3948. onDeactivated: onDeactivated,
  3949. onServerPrefetch: onServerPrefetch,
  3950. onRenderTracked: onRenderTracked,
  3951. onRenderTriggered: onRenderTriggered,
  3952. onErrorCaptured: onErrorCaptured
  3953. });
  3954. const seenObjects = new _Set();
  3955. /**
  3956. * Recursively traverse an object to evoke all converted
  3957. * getters, so that every nested property inside the object
  3958. * is collected as a "deep" dependency.
  3959. */
  3960. function traverse(val) {
  3961. _traverse(val, seenObjects);
  3962. seenObjects.clear();
  3963. return val;
  3964. }
  3965. function _traverse(val, seen) {
  3966. let i, keys;
  3967. const isA = isArray(val);
  3968. if ((!isA && !isObject(val)) ||
  3969. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3970. Object.isFrozen(val) ||
  3971. val instanceof VNode) {
  3972. return;
  3973. }
  3974. if (val.__ob__) {
  3975. const depId = val.__ob__.dep.id;
  3976. if (seen.has(depId)) {
  3977. return;
  3978. }
  3979. seen.add(depId);
  3980. }
  3981. if (isA) {
  3982. i = val.length;
  3983. while (i--)
  3984. _traverse(val[i], seen);
  3985. }
  3986. else if (isRef(val)) {
  3987. _traverse(val.value, seen);
  3988. }
  3989. else {
  3990. keys = Object.keys(val);
  3991. i = keys.length;
  3992. while (i--)
  3993. _traverse(val[keys[i]], seen);
  3994. }
  3995. }
  3996. let uid$1 = 0;
  3997. /**
  3998. * A watcher parses an expression, collects dependencies,
  3999. * and fires callback when the expression value changes.
  4000. * This is used for both the $watch() api and directives.
  4001. * @internal
  4002. */
  4003. class Watcher {
  4004. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  4005. recordEffectScope(this,
  4006. // if the active effect scope is manually created (not a component scope),
  4007. // prioritize it
  4008. activeEffectScope && !activeEffectScope._vm
  4009. ? activeEffectScope
  4010. : vm
  4011. ? vm._scope
  4012. : undefined);
  4013. if ((this.vm = vm) && isRenderWatcher) {
  4014. vm._watcher = this;
  4015. }
  4016. // options
  4017. if (options) {
  4018. this.deep = !!options.deep;
  4019. this.user = !!options.user;
  4020. this.lazy = !!options.lazy;
  4021. this.sync = !!options.sync;
  4022. this.before = options.before;
  4023. {
  4024. this.onTrack = options.onTrack;
  4025. this.onTrigger = options.onTrigger;
  4026. }
  4027. }
  4028. else {
  4029. this.deep = this.user = this.lazy = this.sync = false;
  4030. }
  4031. this.cb = cb;
  4032. this.id = ++uid$1; // uid for batching
  4033. this.active = true;
  4034. this.post = false;
  4035. this.dirty = this.lazy; // for lazy watchers
  4036. this.deps = [];
  4037. this.newDeps = [];
  4038. this.depIds = new _Set();
  4039. this.newDepIds = new _Set();
  4040. this.expression = expOrFn.toString() ;
  4041. // parse expression for getter
  4042. if (isFunction(expOrFn)) {
  4043. this.getter = expOrFn;
  4044. }
  4045. else {
  4046. this.getter = parsePath(expOrFn);
  4047. if (!this.getter) {
  4048. this.getter = noop;
  4049. warn$2(`Failed watching path: "${expOrFn}" ` +
  4050. 'Watcher only accepts simple dot-delimited paths. ' +
  4051. 'For full control, use a function instead.', vm);
  4052. }
  4053. }
  4054. this.value = this.lazy ? undefined : this.get();
  4055. }
  4056. /**
  4057. * Evaluate the getter, and re-collect dependencies.
  4058. */
  4059. get() {
  4060. pushTarget(this);
  4061. let value;
  4062. const vm = this.vm;
  4063. try {
  4064. value = this.getter.call(vm, vm);
  4065. }
  4066. catch (e) {
  4067. if (this.user) {
  4068. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4069. }
  4070. else {
  4071. throw e;
  4072. }
  4073. }
  4074. finally {
  4075. // "touch" every property so they are all tracked as
  4076. // dependencies for deep watching
  4077. if (this.deep) {
  4078. traverse(value);
  4079. }
  4080. popTarget();
  4081. this.cleanupDeps();
  4082. }
  4083. return value;
  4084. }
  4085. /**
  4086. * Add a dependency to this directive.
  4087. */
  4088. addDep(dep) {
  4089. const id = dep.id;
  4090. if (!this.newDepIds.has(id)) {
  4091. this.newDepIds.add(id);
  4092. this.newDeps.push(dep);
  4093. if (!this.depIds.has(id)) {
  4094. dep.addSub(this);
  4095. }
  4096. }
  4097. }
  4098. /**
  4099. * Clean up for dependency collection.
  4100. */
  4101. cleanupDeps() {
  4102. let i = this.deps.length;
  4103. while (i--) {
  4104. const dep = this.deps[i];
  4105. if (!this.newDepIds.has(dep.id)) {
  4106. dep.removeSub(this);
  4107. }
  4108. }
  4109. let tmp = this.depIds;
  4110. this.depIds = this.newDepIds;
  4111. this.newDepIds = tmp;
  4112. this.newDepIds.clear();
  4113. tmp = this.deps;
  4114. this.deps = this.newDeps;
  4115. this.newDeps = tmp;
  4116. this.newDeps.length = 0;
  4117. }
  4118. /**
  4119. * Subscriber interface.
  4120. * Will be called when a dependency changes.
  4121. */
  4122. update() {
  4123. /* istanbul ignore else */
  4124. if (this.lazy) {
  4125. this.dirty = true;
  4126. }
  4127. else if (this.sync) {
  4128. this.run();
  4129. }
  4130. else {
  4131. queueWatcher(this);
  4132. }
  4133. }
  4134. /**
  4135. * Scheduler job interface.
  4136. * Will be called by the scheduler.
  4137. */
  4138. run() {
  4139. if (this.active) {
  4140. const value = this.get();
  4141. if (value !== this.value ||
  4142. // Deep watchers and watchers on Object/Arrays should fire even
  4143. // when the value is the same, because the value may
  4144. // have mutated.
  4145. isObject(value) ||
  4146. this.deep) {
  4147. // set new value
  4148. const oldValue = this.value;
  4149. this.value = value;
  4150. if (this.user) {
  4151. const info = `callback for watcher "${this.expression}"`;
  4152. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4153. }
  4154. else {
  4155. this.cb.call(this.vm, value, oldValue);
  4156. }
  4157. }
  4158. }
  4159. }
  4160. /**
  4161. * Evaluate the value of the watcher.
  4162. * This only gets called for lazy watchers.
  4163. */
  4164. evaluate() {
  4165. this.value = this.get();
  4166. this.dirty = false;
  4167. }
  4168. /**
  4169. * Depend on all deps collected by this watcher.
  4170. */
  4171. depend() {
  4172. let i = this.deps.length;
  4173. while (i--) {
  4174. this.deps[i].depend();
  4175. }
  4176. }
  4177. /**
  4178. * Remove self from all dependencies' subscriber list.
  4179. */
  4180. teardown() {
  4181. if (this.vm && !this.vm._isBeingDestroyed) {
  4182. remove$2(this.vm._scope.effects, this);
  4183. }
  4184. if (this.active) {
  4185. let i = this.deps.length;
  4186. while (i--) {
  4187. this.deps[i].removeSub(this);
  4188. }
  4189. this.active = false;
  4190. if (this.onStop) {
  4191. this.onStop();
  4192. }
  4193. }
  4194. }
  4195. }
  4196. const sharedPropertyDefinition = {
  4197. enumerable: true,
  4198. configurable: true,
  4199. get: noop,
  4200. set: noop
  4201. };
  4202. function proxy(target, sourceKey, key) {
  4203. sharedPropertyDefinition.get = function proxyGetter() {
  4204. return this[sourceKey][key];
  4205. };
  4206. sharedPropertyDefinition.set = function proxySetter(val) {
  4207. this[sourceKey][key] = val;
  4208. };
  4209. Object.defineProperty(target, key, sharedPropertyDefinition);
  4210. }
  4211. function initState(vm) {
  4212. const opts = vm.$options;
  4213. if (opts.props)
  4214. initProps$1(vm, opts.props);
  4215. // Composition API
  4216. initSetup(vm);
  4217. if (opts.methods)
  4218. initMethods(vm, opts.methods);
  4219. if (opts.data) {
  4220. initData(vm);
  4221. }
  4222. else {
  4223. const ob = observe((vm._data = {}));
  4224. ob && ob.vmCount++;
  4225. }
  4226. if (opts.computed)
  4227. initComputed$1(vm, opts.computed);
  4228. if (opts.watch && opts.watch !== nativeWatch) {
  4229. initWatch(vm, opts.watch);
  4230. }
  4231. }
  4232. function initProps$1(vm, propsOptions) {
  4233. const propsData = vm.$options.propsData || {};
  4234. const props = (vm._props = shallowReactive({}));
  4235. // cache prop keys so that future props updates can iterate using Array
  4236. // instead of dynamic object key enumeration.
  4237. const keys = (vm.$options._propKeys = []);
  4238. const isRoot = !vm.$parent;
  4239. // root instance props should be converted
  4240. if (!isRoot) {
  4241. toggleObserving(false);
  4242. }
  4243. for (const key in propsOptions) {
  4244. keys.push(key);
  4245. const value = validateProp(key, propsOptions, propsData, vm);
  4246. /* istanbul ignore else */
  4247. {
  4248. const hyphenatedKey = hyphenate(key);
  4249. if (isReservedAttribute(hyphenatedKey) ||
  4250. config.isReservedAttr(hyphenatedKey)) {
  4251. warn$2(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  4252. }
  4253. defineReactive(props, key, value, () => {
  4254. if (!isRoot && !isUpdatingChildComponent) {
  4255. warn$2(`Avoid mutating a prop directly since the value will be ` +
  4256. `overwritten whenever the parent component re-renders. ` +
  4257. `Instead, use a data or computed property based on the prop's ` +
  4258. `value. Prop being mutated: "${key}"`, vm);
  4259. }
  4260. });
  4261. }
  4262. // static props are already proxied on the component's prototype
  4263. // during Vue.extend(). We only need to proxy props defined at
  4264. // instantiation here.
  4265. if (!(key in vm)) {
  4266. proxy(vm, `_props`, key);
  4267. }
  4268. }
  4269. toggleObserving(true);
  4270. }
  4271. function initData(vm) {
  4272. let data = vm.$options.data;
  4273. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  4274. if (!isPlainObject(data)) {
  4275. data = {};
  4276. warn$2('data functions should return an object:\n' +
  4277. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  4278. }
  4279. // proxy data on instance
  4280. const keys = Object.keys(data);
  4281. const props = vm.$options.props;
  4282. const methods = vm.$options.methods;
  4283. let i = keys.length;
  4284. while (i--) {
  4285. const key = keys[i];
  4286. {
  4287. if (methods && hasOwn(methods, key)) {
  4288. warn$2(`Method "${key}" has already been defined as a data property.`, vm);
  4289. }
  4290. }
  4291. if (props && hasOwn(props, key)) {
  4292. warn$2(`The data property "${key}" is already declared as a prop. ` +
  4293. `Use prop default value instead.`, vm);
  4294. }
  4295. else if (!isReserved(key)) {
  4296. proxy(vm, `_data`, key);
  4297. }
  4298. }
  4299. // observe data
  4300. const ob = observe(data);
  4301. ob && ob.vmCount++;
  4302. }
  4303. function getData(data, vm) {
  4304. // #7573 disable dep collection when invoking data getters
  4305. pushTarget();
  4306. try {
  4307. return data.call(vm, vm);
  4308. }
  4309. catch (e) {
  4310. handleError(e, vm, `data()`);
  4311. return {};
  4312. }
  4313. finally {
  4314. popTarget();
  4315. }
  4316. }
  4317. const computedWatcherOptions = { lazy: true };
  4318. function initComputed$1(vm, computed) {
  4319. // $flow-disable-line
  4320. const watchers = (vm._computedWatchers = Object.create(null));
  4321. // computed properties are just getters during SSR
  4322. const isSSR = isServerRendering();
  4323. for (const key in computed) {
  4324. const userDef = computed[key];
  4325. const getter = isFunction(userDef) ? userDef : userDef.get;
  4326. if (getter == null) {
  4327. warn$2(`Getter is missing for computed property "${key}".`, vm);
  4328. }
  4329. if (!isSSR) {
  4330. // create internal watcher for the computed property.
  4331. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  4332. }
  4333. // component-defined computed properties are already defined on the
  4334. // component prototype. We only need to define computed properties defined
  4335. // at instantiation here.
  4336. if (!(key in vm)) {
  4337. defineComputed(vm, key, userDef);
  4338. }
  4339. else {
  4340. if (key in vm.$data) {
  4341. warn$2(`The computed property "${key}" is already defined in data.`, vm);
  4342. }
  4343. else if (vm.$options.props && key in vm.$options.props) {
  4344. warn$2(`The computed property "${key}" is already defined as a prop.`, vm);
  4345. }
  4346. else if (vm.$options.methods && key in vm.$options.methods) {
  4347. warn$2(`The computed property "${key}" is already defined as a method.`, vm);
  4348. }
  4349. }
  4350. }
  4351. }
  4352. function defineComputed(target, key, userDef) {
  4353. const shouldCache = !isServerRendering();
  4354. if (isFunction(userDef)) {
  4355. sharedPropertyDefinition.get = shouldCache
  4356. ? createComputedGetter(key)
  4357. : createGetterInvoker(userDef);
  4358. sharedPropertyDefinition.set = noop;
  4359. }
  4360. else {
  4361. sharedPropertyDefinition.get = userDef.get
  4362. ? shouldCache && userDef.cache !== false
  4363. ? createComputedGetter(key)
  4364. : createGetterInvoker(userDef.get)
  4365. : noop;
  4366. sharedPropertyDefinition.set = userDef.set || noop;
  4367. }
  4368. if (sharedPropertyDefinition.set === noop) {
  4369. sharedPropertyDefinition.set = function () {
  4370. warn$2(`Computed property "${key}" was assigned to but it has no setter.`, this);
  4371. };
  4372. }
  4373. Object.defineProperty(target, key, sharedPropertyDefinition);
  4374. }
  4375. function createComputedGetter(key) {
  4376. return function computedGetter() {
  4377. const watcher = this._computedWatchers && this._computedWatchers[key];
  4378. if (watcher) {
  4379. if (watcher.dirty) {
  4380. watcher.evaluate();
  4381. }
  4382. if (Dep.target) {
  4383. if (Dep.target.onTrack) {
  4384. Dep.target.onTrack({
  4385. effect: Dep.target,
  4386. target: this,
  4387. type: "get" /* TrackOpTypes.GET */,
  4388. key
  4389. });
  4390. }
  4391. watcher.depend();
  4392. }
  4393. return watcher.value;
  4394. }
  4395. };
  4396. }
  4397. function createGetterInvoker(fn) {
  4398. return function computedGetter() {
  4399. return fn.call(this, this);
  4400. };
  4401. }
  4402. function initMethods(vm, methods) {
  4403. const props = vm.$options.props;
  4404. for (const key in methods) {
  4405. {
  4406. if (typeof methods[key] !== 'function') {
  4407. warn$2(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4408. `Did you reference the function correctly?`, vm);
  4409. }
  4410. if (props && hasOwn(props, key)) {
  4411. warn$2(`Method "${key}" has already been defined as a prop.`, vm);
  4412. }
  4413. if (key in vm && isReserved(key)) {
  4414. warn$2(`Method "${key}" conflicts with an existing Vue instance method. ` +
  4415. `Avoid defining component methods that start with _ or $.`);
  4416. }
  4417. }
  4418. vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm);
  4419. }
  4420. }
  4421. function initWatch(vm, watch) {
  4422. for (const key in watch) {
  4423. const handler = watch[key];
  4424. if (isArray(handler)) {
  4425. for (let i = 0; i < handler.length; i++) {
  4426. createWatcher(vm, key, handler[i]);
  4427. }
  4428. }
  4429. else {
  4430. createWatcher(vm, key, handler);
  4431. }
  4432. }
  4433. }
  4434. function createWatcher(vm, expOrFn, handler, options) {
  4435. if (isPlainObject(handler)) {
  4436. options = handler;
  4437. handler = handler.handler;
  4438. }
  4439. if (typeof handler === 'string') {
  4440. handler = vm[handler];
  4441. }
  4442. return vm.$watch(expOrFn, handler, options);
  4443. }
  4444. function stateMixin(Vue) {
  4445. // flow somehow has problems with directly declared definition object
  4446. // when using Object.defineProperty, so we have to procedurally build up
  4447. // the object here.
  4448. const dataDef = {};
  4449. dataDef.get = function () {
  4450. return this._data;
  4451. };
  4452. const propsDef = {};
  4453. propsDef.get = function () {
  4454. return this._props;
  4455. };
  4456. {
  4457. dataDef.set = function () {
  4458. warn$2('Avoid replacing instance root $data. ' +
  4459. 'Use nested data properties instead.', this);
  4460. };
  4461. propsDef.set = function () {
  4462. warn$2(`$props is readonly.`, this);
  4463. };
  4464. }
  4465. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4466. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4467. Vue.prototype.$set = set;
  4468. Vue.prototype.$delete = del;
  4469. Vue.prototype.$watch = function (expOrFn, cb, options) {
  4470. const vm = this;
  4471. if (isPlainObject(cb)) {
  4472. return createWatcher(vm, expOrFn, cb, options);
  4473. }
  4474. options = options || {};
  4475. options.user = true;
  4476. const watcher = new Watcher(vm, expOrFn, cb, options);
  4477. if (options.immediate) {
  4478. const info = `callback for immediate watcher "${watcher.expression}"`;
  4479. pushTarget();
  4480. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4481. popTarget();
  4482. }
  4483. return function unwatchFn() {
  4484. watcher.teardown();
  4485. };
  4486. };
  4487. }
  4488. function initProvide(vm) {
  4489. const provideOption = vm.$options.provide;
  4490. if (provideOption) {
  4491. const provided = isFunction(provideOption)
  4492. ? provideOption.call(vm)
  4493. : provideOption;
  4494. if (!isObject(provided)) {
  4495. return;
  4496. }
  4497. const source = resolveProvided(vm);
  4498. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4499. // iterate the keys ourselves.
  4500. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4501. for (let i = 0; i < keys.length; i++) {
  4502. const key = keys[i];
  4503. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4504. }
  4505. }
  4506. }
  4507. function initInjections(vm) {
  4508. const result = resolveInject(vm.$options.inject, vm);
  4509. if (result) {
  4510. toggleObserving(false);
  4511. Object.keys(result).forEach(key => {
  4512. /* istanbul ignore else */
  4513. {
  4514. defineReactive(vm, key, result[key], () => {
  4515. warn$2(`Avoid mutating an injected value directly since the changes will be ` +
  4516. `overwritten whenever the provided component re-renders. ` +
  4517. `injection being mutated: "${key}"`, vm);
  4518. });
  4519. }
  4520. });
  4521. toggleObserving(true);
  4522. }
  4523. }
  4524. function resolveInject(inject, vm) {
  4525. if (inject) {
  4526. // inject is :any because flow is not smart enough to figure out cached
  4527. const result = Object.create(null);
  4528. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4529. for (let i = 0; i < keys.length; i++) {
  4530. const key = keys[i];
  4531. // #6574 in case the inject object is observed...
  4532. if (key === '__ob__')
  4533. continue;
  4534. const provideKey = inject[key].from;
  4535. if (provideKey in vm._provided) {
  4536. result[key] = vm._provided[provideKey];
  4537. }
  4538. else if ('default' in inject[key]) {
  4539. const provideDefault = inject[key].default;
  4540. result[key] = isFunction(provideDefault)
  4541. ? provideDefault.call(vm)
  4542. : provideDefault;
  4543. }
  4544. else {
  4545. warn$2(`Injection "${key}" not found`, vm);
  4546. }
  4547. }
  4548. return result;
  4549. }
  4550. }
  4551. let uid = 0;
  4552. function initMixin$1(Vue) {
  4553. Vue.prototype._init = function (options) {
  4554. const vm = this;
  4555. // a uid
  4556. vm._uid = uid++;
  4557. let startTag, endTag;
  4558. /* istanbul ignore if */
  4559. if (config.performance && mark) {
  4560. startTag = `vue-perf-start:${vm._uid}`;
  4561. endTag = `vue-perf-end:${vm._uid}`;
  4562. mark(startTag);
  4563. }
  4564. // a flag to mark this as a Vue instance without having to do instanceof
  4565. // check
  4566. vm._isVue = true;
  4567. // avoid instances from being observed
  4568. vm.__v_skip = true;
  4569. // effect scope
  4570. vm._scope = new EffectScope(true /* detached */);
  4571. vm._scope._vm = true;
  4572. // merge options
  4573. if (options && options._isComponent) {
  4574. // optimize internal component instantiation
  4575. // since dynamic options merging is pretty slow, and none of the
  4576. // internal component options needs special treatment.
  4577. initInternalComponent(vm, options);
  4578. }
  4579. else {
  4580. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  4581. }
  4582. /* istanbul ignore else */
  4583. {
  4584. initProxy(vm);
  4585. }
  4586. // expose real self
  4587. vm._self = vm;
  4588. initLifecycle(vm);
  4589. initEvents(vm);
  4590. initRender(vm);
  4591. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  4592. initInjections(vm); // resolve injections before data/props
  4593. initState(vm);
  4594. initProvide(vm); // resolve provide after data/props
  4595. callHook$1(vm, 'created');
  4596. /* istanbul ignore if */
  4597. if (config.performance && mark) {
  4598. vm._name = formatComponentName(vm, false);
  4599. mark(endTag);
  4600. measure(`vue ${vm._name} init`, startTag, endTag);
  4601. }
  4602. if (vm.$options.el) {
  4603. vm.$mount(vm.$options.el);
  4604. }
  4605. };
  4606. }
  4607. function initInternalComponent(vm, options) {
  4608. const opts = (vm.$options = Object.create(vm.constructor.options));
  4609. // doing this because it's faster than dynamic enumeration.
  4610. const parentVnode = options._parentVnode;
  4611. opts.parent = options.parent;
  4612. opts._parentVnode = parentVnode;
  4613. const vnodeComponentOptions = parentVnode.componentOptions;
  4614. opts.propsData = vnodeComponentOptions.propsData;
  4615. opts._parentListeners = vnodeComponentOptions.listeners;
  4616. opts._renderChildren = vnodeComponentOptions.children;
  4617. opts._componentTag = vnodeComponentOptions.tag;
  4618. if (options.render) {
  4619. opts.render = options.render;
  4620. opts.staticRenderFns = options.staticRenderFns;
  4621. }
  4622. }
  4623. function resolveConstructorOptions(Ctor) {
  4624. let options = Ctor.options;
  4625. if (Ctor.super) {
  4626. const superOptions = resolveConstructorOptions(Ctor.super);
  4627. const cachedSuperOptions = Ctor.superOptions;
  4628. if (superOptions !== cachedSuperOptions) {
  4629. // super option changed,
  4630. // need to resolve new options.
  4631. Ctor.superOptions = superOptions;
  4632. // check if there are any late-modified/attached options (#4976)
  4633. const modifiedOptions = resolveModifiedOptions(Ctor);
  4634. // update base extend options
  4635. if (modifiedOptions) {
  4636. extend(Ctor.extendOptions, modifiedOptions);
  4637. }
  4638. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4639. if (options.name) {
  4640. options.components[options.name] = Ctor;
  4641. }
  4642. }
  4643. }
  4644. return options;
  4645. }
  4646. function resolveModifiedOptions(Ctor) {
  4647. let modified;
  4648. const latest = Ctor.options;
  4649. const sealed = Ctor.sealedOptions;
  4650. for (const key in latest) {
  4651. if (latest[key] !== sealed[key]) {
  4652. if (!modified)
  4653. modified = {};
  4654. modified[key] = latest[key];
  4655. }
  4656. }
  4657. return modified;
  4658. }
  4659. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4660. const options = Ctor.options;
  4661. // ensure the createElement function in functional components
  4662. // gets a unique context - this is necessary for correct named slot check
  4663. let contextVm;
  4664. if (hasOwn(parent, '_uid')) {
  4665. contextVm = Object.create(parent);
  4666. contextVm._original = parent;
  4667. }
  4668. else {
  4669. // the context vm passed in is a functional context as well.
  4670. // in this case we want to make sure we are able to get a hold to the
  4671. // real context instance.
  4672. contextVm = parent;
  4673. // @ts-ignore
  4674. parent = parent._original;
  4675. }
  4676. const isCompiled = isTrue(options._compiled);
  4677. const needNormalization = !isCompiled;
  4678. this.data = data;
  4679. this.props = props;
  4680. this.children = children;
  4681. this.parent = parent;
  4682. this.listeners = data.on || emptyObject;
  4683. this.injections = resolveInject(options.inject, parent);
  4684. this.slots = () => {
  4685. if (!this.$slots) {
  4686. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4687. }
  4688. return this.$slots;
  4689. };
  4690. Object.defineProperty(this, 'scopedSlots', {
  4691. enumerable: true,
  4692. get() {
  4693. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4694. }
  4695. });
  4696. // support for compiled functional template
  4697. if (isCompiled) {
  4698. // exposing $options for renderStatic()
  4699. this.$options = options;
  4700. // pre-resolve slots for renderSlot()
  4701. this.$slots = this.slots();
  4702. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4703. }
  4704. if (options._scopeId) {
  4705. this._c = (a, b, c, d) => {
  4706. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4707. if (vnode && !isArray(vnode)) {
  4708. vnode.fnScopeId = options._scopeId;
  4709. vnode.fnContext = parent;
  4710. }
  4711. return vnode;
  4712. };
  4713. }
  4714. else {
  4715. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4716. }
  4717. }
  4718. installRenderHelpers(FunctionalRenderContext.prototype);
  4719. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4720. const options = Ctor.options;
  4721. const props = {};
  4722. const propOptions = options.props;
  4723. if (isDef(propOptions)) {
  4724. for (const key in propOptions) {
  4725. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4726. }
  4727. }
  4728. else {
  4729. if (isDef(data.attrs))
  4730. mergeProps(props, data.attrs);
  4731. if (isDef(data.props))
  4732. mergeProps(props, data.props);
  4733. }
  4734. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4735. const vnode = options.render.call(null, renderContext._c, renderContext);
  4736. if (vnode instanceof VNode) {
  4737. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4738. }
  4739. else if (isArray(vnode)) {
  4740. const vnodes = normalizeChildren(vnode) || [];
  4741. const res = new Array(vnodes.length);
  4742. for (let i = 0; i < vnodes.length; i++) {
  4743. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4744. }
  4745. return res;
  4746. }
  4747. }
  4748. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4749. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4750. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4751. // that should not be matched to match.
  4752. const clone = cloneVNode(vnode);
  4753. clone.fnContext = contextVm;
  4754. clone.fnOptions = options;
  4755. {
  4756. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4757. renderContext;
  4758. }
  4759. if (data.slot) {
  4760. (clone.data || (clone.data = {})).slot = data.slot;
  4761. }
  4762. return clone;
  4763. }
  4764. function mergeProps(to, from) {
  4765. for (const key in from) {
  4766. to[camelize(key)] = from[key];
  4767. }
  4768. }
  4769. function getComponentName(options) {
  4770. return options.name || options.__name || options._componentTag;
  4771. }
  4772. // inline hooks to be invoked on component VNodes during patch
  4773. const componentVNodeHooks = {
  4774. init(vnode, hydrating) {
  4775. if (vnode.componentInstance &&
  4776. !vnode.componentInstance._isDestroyed &&
  4777. vnode.data.keepAlive) {
  4778. // kept-alive components, treat as a patch
  4779. const mountedNode = vnode; // work around flow
  4780. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4781. }
  4782. else {
  4783. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4784. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4785. }
  4786. },
  4787. prepatch(oldVnode, vnode) {
  4788. const options = vnode.componentOptions;
  4789. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4790. updateChildComponent(child, options.propsData, // updated props
  4791. options.listeners, // updated listeners
  4792. vnode, // new parent vnode
  4793. options.children // new children
  4794. );
  4795. },
  4796. insert(vnode) {
  4797. const { context, componentInstance } = vnode;
  4798. if (!componentInstance._isMounted) {
  4799. componentInstance._isMounted = true;
  4800. callHook$1(componentInstance, 'mounted');
  4801. }
  4802. if (vnode.data.keepAlive) {
  4803. if (context._isMounted) {
  4804. // vue-router#1212
  4805. // During updates, a kept-alive component's child components may
  4806. // change, so directly walking the tree here may call activated hooks
  4807. // on incorrect children. Instead we push them into a queue which will
  4808. // be processed after the whole patch process ended.
  4809. queueActivatedComponent(componentInstance);
  4810. }
  4811. else {
  4812. activateChildComponent(componentInstance, true /* direct */);
  4813. }
  4814. }
  4815. },
  4816. destroy(vnode) {
  4817. const { componentInstance } = vnode;
  4818. if (!componentInstance._isDestroyed) {
  4819. if (!vnode.data.keepAlive) {
  4820. componentInstance.$destroy();
  4821. }
  4822. else {
  4823. deactivateChildComponent(componentInstance, true /* direct */);
  4824. }
  4825. }
  4826. }
  4827. };
  4828. const hooksToMerge = Object.keys(componentVNodeHooks);
  4829. function createComponent(Ctor, data, context, children, tag) {
  4830. if (isUndef(Ctor)) {
  4831. return;
  4832. }
  4833. const baseCtor = context.$options._base;
  4834. // plain options object: turn it into a constructor
  4835. if (isObject(Ctor)) {
  4836. Ctor = baseCtor.extend(Ctor);
  4837. }
  4838. // if at this stage it's not a constructor or an async component factory,
  4839. // reject.
  4840. if (typeof Ctor !== 'function') {
  4841. {
  4842. warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
  4843. }
  4844. return;
  4845. }
  4846. // async component
  4847. let asyncFactory;
  4848. // @ts-expect-error
  4849. if (isUndef(Ctor.cid)) {
  4850. asyncFactory = Ctor;
  4851. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4852. if (Ctor === undefined) {
  4853. // return a placeholder node for async component, which is rendered
  4854. // as a comment node but preserves all the raw information for the node.
  4855. // the information will be used for async server-rendering and hydration.
  4856. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4857. }
  4858. }
  4859. data = data || {};
  4860. // resolve constructor options in case global mixins are applied after
  4861. // component constructor creation
  4862. resolveConstructorOptions(Ctor);
  4863. // transform component v-model data into props & events
  4864. if (isDef(data.model)) {
  4865. // @ts-expect-error
  4866. transformModel(Ctor.options, data);
  4867. }
  4868. // extract props
  4869. // @ts-expect-error
  4870. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4871. // functional component
  4872. // @ts-expect-error
  4873. if (isTrue(Ctor.options.functional)) {
  4874. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4875. }
  4876. // extract listeners, since these needs to be treated as
  4877. // child component listeners instead of DOM listeners
  4878. const listeners = data.on;
  4879. // replace with listeners with .native modifier
  4880. // so it gets processed during parent component patch.
  4881. data.on = data.nativeOn;
  4882. // @ts-expect-error
  4883. if (isTrue(Ctor.options.abstract)) {
  4884. // abstract components do not keep anything
  4885. // other than props & listeners & slot
  4886. // work around flow
  4887. const slot = data.slot;
  4888. data = {};
  4889. if (slot) {
  4890. data.slot = slot;
  4891. }
  4892. }
  4893. // install component management hooks onto the placeholder node
  4894. installComponentHooks(data);
  4895. // return a placeholder vnode
  4896. // @ts-expect-error
  4897. const name = getComponentName(Ctor.options) || tag;
  4898. const vnode = new VNode(
  4899. // @ts-expect-error
  4900. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4901. // @ts-expect-error
  4902. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4903. return vnode;
  4904. }
  4905. function createComponentInstanceForVnode(
  4906. // we know it's MountedComponentVNode but flow doesn't
  4907. vnode,
  4908. // activeInstance in lifecycle state
  4909. parent) {
  4910. const options = {
  4911. _isComponent: true,
  4912. _parentVnode: vnode,
  4913. parent
  4914. };
  4915. // check inline-template render functions
  4916. const inlineTemplate = vnode.data.inlineTemplate;
  4917. if (isDef(inlineTemplate)) {
  4918. options.render = inlineTemplate.render;
  4919. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4920. }
  4921. return new vnode.componentOptions.Ctor(options);
  4922. }
  4923. function installComponentHooks(data) {
  4924. const hooks = data.hook || (data.hook = {});
  4925. for (let i = 0; i < hooksToMerge.length; i++) {
  4926. const key = hooksToMerge[i];
  4927. const existing = hooks[key];
  4928. const toMerge = componentVNodeHooks[key];
  4929. // @ts-expect-error
  4930. if (existing !== toMerge && !(existing && existing._merged)) {
  4931. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4932. }
  4933. }
  4934. }
  4935. function mergeHook(f1, f2) {
  4936. const merged = (a, b) => {
  4937. // flow complains about extra args which is why we use any
  4938. f1(a, b);
  4939. f2(a, b);
  4940. };
  4941. merged._merged = true;
  4942. return merged;
  4943. }
  4944. // transform component v-model info (value and callback) into
  4945. // prop and event handler respectively.
  4946. function transformModel(options, data) {
  4947. const prop = (options.model && options.model.prop) || 'value';
  4948. const event = (options.model && options.model.event) || 'input';
  4949. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4950. const on = data.on || (data.on = {});
  4951. const existing = on[event];
  4952. const callback = data.model.callback;
  4953. if (isDef(existing)) {
  4954. if (isArray(existing)
  4955. ? existing.indexOf(callback) === -1
  4956. : existing !== callback) {
  4957. on[event] = [callback].concat(existing);
  4958. }
  4959. }
  4960. else {
  4961. on[event] = callback;
  4962. }
  4963. }
  4964. let warn$2 = noop;
  4965. let tip = noop;
  4966. let generateComponentTrace; // work around flow check
  4967. let formatComponentName;
  4968. {
  4969. const hasConsole = typeof console !== 'undefined';
  4970. const classifyRE = /(?:^|[-_])(\w)/g;
  4971. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4972. warn$2 = (msg, vm = currentInstance) => {
  4973. const trace = vm ? generateComponentTrace(vm) : '';
  4974. if (config.warnHandler) {
  4975. config.warnHandler.call(null, msg, vm, trace);
  4976. }
  4977. else if (hasConsole && !config.silent) {
  4978. console.error(`[Vue warn]: ${msg}${trace}`);
  4979. }
  4980. };
  4981. tip = (msg, vm) => {
  4982. if (hasConsole && !config.silent) {
  4983. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4984. }
  4985. };
  4986. formatComponentName = (vm, includeFile) => {
  4987. if (vm.$root === vm) {
  4988. return '<Root>';
  4989. }
  4990. const options = isFunction(vm) && vm.cid != null
  4991. ? vm.options
  4992. : vm._isVue
  4993. ? vm.$options || vm.constructor.options
  4994. : vm;
  4995. let name = getComponentName(options);
  4996. const file = options.__file;
  4997. if (!name && file) {
  4998. const match = file.match(/([^/\\]+)\.vue$/);
  4999. name = match && match[1];
  5000. }
  5001. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  5002. (file && includeFile !== false ? ` at ${file}` : ''));
  5003. };
  5004. const repeat = (str, n) => {
  5005. let res = '';
  5006. while (n) {
  5007. if (n % 2 === 1)
  5008. res += str;
  5009. if (n > 1)
  5010. str += str;
  5011. n >>= 1;
  5012. }
  5013. return res;
  5014. };
  5015. generateComponentTrace = (vm) => {
  5016. if (vm._isVue && vm.$parent) {
  5017. const tree = [];
  5018. let currentRecursiveSequence = 0;
  5019. while (vm) {
  5020. if (tree.length > 0) {
  5021. const last = tree[tree.length - 1];
  5022. if (last.constructor === vm.constructor) {
  5023. currentRecursiveSequence++;
  5024. vm = vm.$parent;
  5025. continue;
  5026. }
  5027. else if (currentRecursiveSequence > 0) {
  5028. tree[tree.length - 1] = [last, currentRecursiveSequence];
  5029. currentRecursiveSequence = 0;
  5030. }
  5031. }
  5032. tree.push(vm);
  5033. vm = vm.$parent;
  5034. }
  5035. return ('\n\nfound in\n\n' +
  5036. tree
  5037. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  5038. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  5039. : formatComponentName(vm)}`)
  5040. .join('\n'));
  5041. }
  5042. else {
  5043. return `\n\n(found in ${formatComponentName(vm)})`;
  5044. }
  5045. };
  5046. }
  5047. /**
  5048. * Option overwriting strategies are functions that handle
  5049. * how to merge a parent option value and a child option
  5050. * value into the final value.
  5051. */
  5052. const strats = config.optionMergeStrategies;
  5053. /**
  5054. * Options with restrictions
  5055. */
  5056. {
  5057. strats.el = strats.propsData = function (parent, child, vm, key) {
  5058. if (!vm) {
  5059. warn$2(`option "${key}" can only be used during instance ` +
  5060. 'creation with the `new` keyword.');
  5061. }
  5062. return defaultStrat(parent, child);
  5063. };
  5064. }
  5065. /**
  5066. * Helper that recursively merges two data objects together.
  5067. */
  5068. function mergeData(to, from, recursive = true) {
  5069. if (!from)
  5070. return to;
  5071. let key, toVal, fromVal;
  5072. const keys = hasSymbol
  5073. ? Reflect.ownKeys(from)
  5074. : Object.keys(from);
  5075. for (let i = 0; i < keys.length; i++) {
  5076. key = keys[i];
  5077. // in case the object is already observed...
  5078. if (key === '__ob__')
  5079. continue;
  5080. toVal = to[key];
  5081. fromVal = from[key];
  5082. if (!recursive || !hasOwn(to, key)) {
  5083. set(to, key, fromVal);
  5084. }
  5085. else if (toVal !== fromVal &&
  5086. isPlainObject(toVal) &&
  5087. isPlainObject(fromVal)) {
  5088. mergeData(toVal, fromVal);
  5089. }
  5090. }
  5091. return to;
  5092. }
  5093. /**
  5094. * Data
  5095. */
  5096. function mergeDataOrFn(parentVal, childVal, vm) {
  5097. if (!vm) {
  5098. // in a Vue.extend merge, both should be functions
  5099. if (!childVal) {
  5100. return parentVal;
  5101. }
  5102. if (!parentVal) {
  5103. return childVal;
  5104. }
  5105. // when parentVal & childVal are both present,
  5106. // we need to return a function that returns the
  5107. // merged result of both functions... no need to
  5108. // check if parentVal is a function here because
  5109. // it has to be a function to pass previous merges.
  5110. return function mergedDataFn() {
  5111. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5112. };
  5113. }
  5114. else {
  5115. return function mergedInstanceDataFn() {
  5116. // instance merge
  5117. const instanceData = isFunction(childVal)
  5118. ? childVal.call(vm, vm)
  5119. : childVal;
  5120. const defaultData = isFunction(parentVal)
  5121. ? parentVal.call(vm, vm)
  5122. : parentVal;
  5123. if (instanceData) {
  5124. return mergeData(instanceData, defaultData);
  5125. }
  5126. else {
  5127. return defaultData;
  5128. }
  5129. };
  5130. }
  5131. }
  5132. strats.data = function (parentVal, childVal, vm) {
  5133. if (!vm) {
  5134. if (childVal && typeof childVal !== 'function') {
  5135. warn$2('The "data" option should be a function ' +
  5136. 'that returns a per-instance value in component ' +
  5137. 'definitions.', vm);
  5138. return parentVal;
  5139. }
  5140. return mergeDataOrFn(parentVal, childVal);
  5141. }
  5142. return mergeDataOrFn(parentVal, childVal, vm);
  5143. };
  5144. /**
  5145. * Hooks and props are merged as arrays.
  5146. */
  5147. function mergeLifecycleHook(parentVal, childVal) {
  5148. const res = childVal
  5149. ? parentVal
  5150. ? parentVal.concat(childVal)
  5151. : isArray(childVal)
  5152. ? childVal
  5153. : [childVal]
  5154. : parentVal;
  5155. return res ? dedupeHooks(res) : res;
  5156. }
  5157. function dedupeHooks(hooks) {
  5158. const res = [];
  5159. for (let i = 0; i < hooks.length; i++) {
  5160. if (res.indexOf(hooks[i]) === -1) {
  5161. res.push(hooks[i]);
  5162. }
  5163. }
  5164. return res;
  5165. }
  5166. LIFECYCLE_HOOKS.forEach(hook => {
  5167. strats[hook] = mergeLifecycleHook;
  5168. });
  5169. /**
  5170. * Assets
  5171. *
  5172. * When a vm is present (instance creation), we need to do
  5173. * a three-way merge between constructor options, instance
  5174. * options and parent options.
  5175. */
  5176. function mergeAssets(parentVal, childVal, vm, key) {
  5177. const res = Object.create(parentVal || null);
  5178. if (childVal) {
  5179. assertObjectType(key, childVal, vm);
  5180. return extend(res, childVal);
  5181. }
  5182. else {
  5183. return res;
  5184. }
  5185. }
  5186. ASSET_TYPES.forEach(function (type) {
  5187. strats[type + 's'] = mergeAssets;
  5188. });
  5189. /**
  5190. * Watchers.
  5191. *
  5192. * Watchers hashes should not overwrite one
  5193. * another, so we merge them as arrays.
  5194. */
  5195. strats.watch = function (parentVal, childVal, vm, key) {
  5196. // work around Firefox's Object.prototype.watch...
  5197. //@ts-expect-error work around
  5198. if (parentVal === nativeWatch)
  5199. parentVal = undefined;
  5200. //@ts-expect-error work around
  5201. if (childVal === nativeWatch)
  5202. childVal = undefined;
  5203. /* istanbul ignore if */
  5204. if (!childVal)
  5205. return Object.create(parentVal || null);
  5206. {
  5207. assertObjectType(key, childVal, vm);
  5208. }
  5209. if (!parentVal)
  5210. return childVal;
  5211. const ret = {};
  5212. extend(ret, parentVal);
  5213. for (const key in childVal) {
  5214. let parent = ret[key];
  5215. const child = childVal[key];
  5216. if (parent && !isArray(parent)) {
  5217. parent = [parent];
  5218. }
  5219. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5220. }
  5221. return ret;
  5222. };
  5223. /**
  5224. * Other object hashes.
  5225. */
  5226. strats.props =
  5227. strats.methods =
  5228. strats.inject =
  5229. strats.computed =
  5230. function (parentVal, childVal, vm, key) {
  5231. if (childVal && true) {
  5232. assertObjectType(key, childVal, vm);
  5233. }
  5234. if (!parentVal)
  5235. return childVal;
  5236. const ret = Object.create(null);
  5237. extend(ret, parentVal);
  5238. if (childVal)
  5239. extend(ret, childVal);
  5240. return ret;
  5241. };
  5242. strats.provide = function (parentVal, childVal) {
  5243. if (!parentVal)
  5244. return childVal;
  5245. return function () {
  5246. const ret = Object.create(null);
  5247. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5248. if (childVal) {
  5249. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5250. );
  5251. }
  5252. return ret;
  5253. };
  5254. };
  5255. /**
  5256. * Default strategy.
  5257. */
  5258. const defaultStrat = function (parentVal, childVal) {
  5259. return childVal === undefined ? parentVal : childVal;
  5260. };
  5261. /**
  5262. * Validate component names
  5263. */
  5264. function checkComponents(options) {
  5265. for (const key in options.components) {
  5266. validateComponentName(key);
  5267. }
  5268. }
  5269. function validateComponentName(name) {
  5270. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5271. warn$2('Invalid component name: "' +
  5272. name +
  5273. '". Component names ' +
  5274. 'should conform to valid custom element name in html5 specification.');
  5275. }
  5276. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5277. warn$2('Do not use built-in or reserved HTML elements as component ' +
  5278. 'id: ' +
  5279. name);
  5280. }
  5281. }
  5282. /**
  5283. * Ensure all props option syntax are normalized into the
  5284. * Object-based format.
  5285. */
  5286. function normalizeProps(options, vm) {
  5287. const props = options.props;
  5288. if (!props)
  5289. return;
  5290. const res = {};
  5291. let i, val, name;
  5292. if (isArray(props)) {
  5293. i = props.length;
  5294. while (i--) {
  5295. val = props[i];
  5296. if (typeof val === 'string') {
  5297. name = camelize(val);
  5298. res[name] = { type: null };
  5299. }
  5300. else {
  5301. warn$2('props must be strings when using array syntax.');
  5302. }
  5303. }
  5304. }
  5305. else if (isPlainObject(props)) {
  5306. for (const key in props) {
  5307. val = props[key];
  5308. name = camelize(key);
  5309. res[name] = isPlainObject(val) ? val : { type: val };
  5310. }
  5311. }
  5312. else {
  5313. warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
  5314. `but got ${toRawType(props)}.`, vm);
  5315. }
  5316. options.props = res;
  5317. }
  5318. /**
  5319. * Normalize all injections into Object-based format
  5320. */
  5321. function normalizeInject(options, vm) {
  5322. const inject = options.inject;
  5323. if (!inject)
  5324. return;
  5325. const normalized = (options.inject = {});
  5326. if (isArray(inject)) {
  5327. for (let i = 0; i < inject.length; i++) {
  5328. normalized[inject[i]] = { from: inject[i] };
  5329. }
  5330. }
  5331. else if (isPlainObject(inject)) {
  5332. for (const key in inject) {
  5333. const val = inject[key];
  5334. normalized[key] = isPlainObject(val)
  5335. ? extend({ from: key }, val)
  5336. : { from: val };
  5337. }
  5338. }
  5339. else {
  5340. warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
  5341. `but got ${toRawType(inject)}.`, vm);
  5342. }
  5343. }
  5344. /**
  5345. * Normalize raw function directives into object format.
  5346. */
  5347. function normalizeDirectives$1(options) {
  5348. const dirs = options.directives;
  5349. if (dirs) {
  5350. for (const key in dirs) {
  5351. const def = dirs[key];
  5352. if (isFunction(def)) {
  5353. dirs[key] = { bind: def, update: def };
  5354. }
  5355. }
  5356. }
  5357. }
  5358. function assertObjectType(name, value, vm) {
  5359. if (!isPlainObject(value)) {
  5360. warn$2(`Invalid value for option "${name}": expected an Object, ` +
  5361. `but got ${toRawType(value)}.`, vm);
  5362. }
  5363. }
  5364. /**
  5365. * Merge two option objects into a new one.
  5366. * Core utility used in both instantiation and inheritance.
  5367. */
  5368. function mergeOptions(parent, child, vm) {
  5369. {
  5370. checkComponents(child);
  5371. }
  5372. if (isFunction(child)) {
  5373. // @ts-expect-error
  5374. child = child.options;
  5375. }
  5376. normalizeProps(child, vm);
  5377. normalizeInject(child, vm);
  5378. normalizeDirectives$1(child);
  5379. // Apply extends and mixins on the child options,
  5380. // but only if it is a raw options object that isn't
  5381. // the result of another mergeOptions call.
  5382. // Only merged options has the _base property.
  5383. if (!child._base) {
  5384. if (child.extends) {
  5385. parent = mergeOptions(parent, child.extends, vm);
  5386. }
  5387. if (child.mixins) {
  5388. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5389. parent = mergeOptions(parent, child.mixins[i], vm);
  5390. }
  5391. }
  5392. }
  5393. const options = {};
  5394. let key;
  5395. for (key in parent) {
  5396. mergeField(key);
  5397. }
  5398. for (key in child) {
  5399. if (!hasOwn(parent, key)) {
  5400. mergeField(key);
  5401. }
  5402. }
  5403. function mergeField(key) {
  5404. const strat = strats[key] || defaultStrat;
  5405. options[key] = strat(parent[key], child[key], vm, key);
  5406. }
  5407. return options;
  5408. }
  5409. /**
  5410. * Resolve an asset.
  5411. * This function is used because child instances need access
  5412. * to assets defined in its ancestor chain.
  5413. */
  5414. function resolveAsset(options, type, id, warnMissing) {
  5415. /* istanbul ignore if */
  5416. if (typeof id !== 'string') {
  5417. return;
  5418. }
  5419. const assets = options[type];
  5420. // check local registration variations first
  5421. if (hasOwn(assets, id))
  5422. return assets[id];
  5423. const camelizedId = camelize(id);
  5424. if (hasOwn(assets, camelizedId))
  5425. return assets[camelizedId];
  5426. const PascalCaseId = capitalize(camelizedId);
  5427. if (hasOwn(assets, PascalCaseId))
  5428. return assets[PascalCaseId];
  5429. // fallback to prototype chain
  5430. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5431. if (warnMissing && !res) {
  5432. warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5433. }
  5434. return res;
  5435. }
  5436. function validateProp(key, propOptions, propsData, vm) {
  5437. const prop = propOptions[key];
  5438. const absent = !hasOwn(propsData, key);
  5439. let value = propsData[key];
  5440. // boolean casting
  5441. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5442. if (booleanIndex > -1) {
  5443. if (absent && !hasOwn(prop, 'default')) {
  5444. value = false;
  5445. }
  5446. else if (value === '' || value === hyphenate(key)) {
  5447. // only cast empty string / same name to boolean if
  5448. // boolean has higher priority
  5449. const stringIndex = getTypeIndex(String, prop.type);
  5450. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5451. value = true;
  5452. }
  5453. }
  5454. }
  5455. // check default value
  5456. if (value === undefined) {
  5457. value = getPropDefaultValue(vm, prop, key);
  5458. // since the default value is a fresh copy,
  5459. // make sure to observe it.
  5460. const prevShouldObserve = shouldObserve;
  5461. toggleObserving(true);
  5462. observe(value);
  5463. toggleObserving(prevShouldObserve);
  5464. }
  5465. {
  5466. assertProp(prop, key, value, vm, absent);
  5467. }
  5468. return value;
  5469. }
  5470. /**
  5471. * Get the default value of a prop.
  5472. */
  5473. function getPropDefaultValue(vm, prop, key) {
  5474. // no default, return undefined
  5475. if (!hasOwn(prop, 'default')) {
  5476. return undefined;
  5477. }
  5478. const def = prop.default;
  5479. // warn against non-factory defaults for Object & Array
  5480. if (isObject(def)) {
  5481. warn$2('Invalid default value for prop "' +
  5482. key +
  5483. '": ' +
  5484. 'Props with type Object/Array must use a factory function ' +
  5485. 'to return the default value.', vm);
  5486. }
  5487. // the raw prop value was also undefined from previous render,
  5488. // return previous default value to avoid unnecessary watcher trigger
  5489. if (vm &&
  5490. vm.$options.propsData &&
  5491. vm.$options.propsData[key] === undefined &&
  5492. vm._props[key] !== undefined) {
  5493. return vm._props[key];
  5494. }
  5495. // call factory function for non-Function types
  5496. // a value is Function if its prototype is function even across different execution context
  5497. return isFunction(def) && getType(prop.type) !== 'Function'
  5498. ? def.call(vm)
  5499. : def;
  5500. }
  5501. /**
  5502. * Assert whether a prop is valid.
  5503. */
  5504. function assertProp(prop, name, value, vm, absent) {
  5505. if (prop.required && absent) {
  5506. warn$2('Missing required prop: "' + name + '"', vm);
  5507. return;
  5508. }
  5509. if (value == null && !prop.required) {
  5510. return;
  5511. }
  5512. let type = prop.type;
  5513. let valid = !type || type === true;
  5514. const expectedTypes = [];
  5515. if (type) {
  5516. if (!isArray(type)) {
  5517. type = [type];
  5518. }
  5519. for (let i = 0; i < type.length && !valid; i++) {
  5520. const assertedType = assertType(value, type[i], vm);
  5521. expectedTypes.push(assertedType.expectedType || '');
  5522. valid = assertedType.valid;
  5523. }
  5524. }
  5525. const haveExpectedTypes = expectedTypes.some(t => t);
  5526. if (!valid && haveExpectedTypes) {
  5527. warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5528. return;
  5529. }
  5530. const validator = prop.validator;
  5531. if (validator) {
  5532. if (!validator(value)) {
  5533. warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5534. }
  5535. }
  5536. }
  5537. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5538. function assertType(value, type, vm) {
  5539. let valid;
  5540. const expectedType = getType(type);
  5541. if (simpleCheckRE.test(expectedType)) {
  5542. const t = typeof value;
  5543. valid = t === expectedType.toLowerCase();
  5544. // for primitive wrapper objects
  5545. if (!valid && t === 'object') {
  5546. valid = value instanceof type;
  5547. }
  5548. }
  5549. else if (expectedType === 'Object') {
  5550. valid = isPlainObject(value);
  5551. }
  5552. else if (expectedType === 'Array') {
  5553. valid = isArray(value);
  5554. }
  5555. else {
  5556. try {
  5557. valid = value instanceof type;
  5558. }
  5559. catch (e) {
  5560. warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5561. valid = false;
  5562. }
  5563. }
  5564. return {
  5565. valid,
  5566. expectedType
  5567. };
  5568. }
  5569. const functionTypeCheckRE = /^\s*function (\w+)/;
  5570. /**
  5571. * Use function string name to check built-in types,
  5572. * because a simple equality check will fail when running
  5573. * across different vms / iframes.
  5574. */
  5575. function getType(fn) {
  5576. const match = fn && fn.toString().match(functionTypeCheckRE);
  5577. return match ? match[1] : '';
  5578. }
  5579. function isSameType(a, b) {
  5580. return getType(a) === getType(b);
  5581. }
  5582. function getTypeIndex(type, expectedTypes) {
  5583. if (!isArray(expectedTypes)) {
  5584. return isSameType(expectedTypes, type) ? 0 : -1;
  5585. }
  5586. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5587. if (isSameType(expectedTypes[i], type)) {
  5588. return i;
  5589. }
  5590. }
  5591. return -1;
  5592. }
  5593. function getInvalidTypeMessage(name, value, expectedTypes) {
  5594. let message = `Invalid prop: type check failed for prop "${name}".` +
  5595. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5596. const expectedType = expectedTypes[0];
  5597. const receivedType = toRawType(value);
  5598. // check if we need to specify expected value
  5599. if (expectedTypes.length === 1 &&
  5600. isExplicable(expectedType) &&
  5601. isExplicable(typeof value) &&
  5602. !isBoolean(expectedType, receivedType)) {
  5603. message += ` with value ${styleValue(value, expectedType)}`;
  5604. }
  5605. message += `, got ${receivedType} `;
  5606. // check if we need to specify received value
  5607. if (isExplicable(receivedType)) {
  5608. message += `with value ${styleValue(value, receivedType)}.`;
  5609. }
  5610. return message;
  5611. }
  5612. function styleValue(value, type) {
  5613. if (type === 'String') {
  5614. return `"${value}"`;
  5615. }
  5616. else if (type === 'Number') {
  5617. return `${Number(value)}`;
  5618. }
  5619. else {
  5620. return `${value}`;
  5621. }
  5622. }
  5623. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5624. function isExplicable(value) {
  5625. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5626. }
  5627. function isBoolean(...args) {
  5628. return args.some(elem => elem.toLowerCase() === 'boolean');
  5629. }
  5630. function Vue(options) {
  5631. if (!(this instanceof Vue)) {
  5632. warn$2('Vue is a constructor and should be called with the `new` keyword');
  5633. }
  5634. this._init(options);
  5635. }
  5636. //@ts-expect-error Vue has function type
  5637. initMixin$1(Vue);
  5638. //@ts-expect-error Vue has function type
  5639. stateMixin(Vue);
  5640. //@ts-expect-error Vue has function type
  5641. eventsMixin(Vue);
  5642. //@ts-expect-error Vue has function type
  5643. lifecycleMixin(Vue);
  5644. //@ts-expect-error Vue has function type
  5645. renderMixin(Vue);
  5646. function initUse(Vue) {
  5647. Vue.use = function (plugin) {
  5648. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5649. if (installedPlugins.indexOf(plugin) > -1) {
  5650. return this;
  5651. }
  5652. // additional parameters
  5653. const args = toArray(arguments, 1);
  5654. args.unshift(this);
  5655. if (isFunction(plugin.install)) {
  5656. plugin.install.apply(plugin, args);
  5657. }
  5658. else if (isFunction(plugin)) {
  5659. plugin.apply(null, args);
  5660. }
  5661. installedPlugins.push(plugin);
  5662. return this;
  5663. };
  5664. }
  5665. function initMixin(Vue) {
  5666. Vue.mixin = function (mixin) {
  5667. this.options = mergeOptions(this.options, mixin);
  5668. return this;
  5669. };
  5670. }
  5671. function initExtend(Vue) {
  5672. /**
  5673. * Each instance constructor, including Vue, has a unique
  5674. * cid. This enables us to create wrapped "child
  5675. * constructors" for prototypal inheritance and cache them.
  5676. */
  5677. Vue.cid = 0;
  5678. let cid = 1;
  5679. /**
  5680. * Class inheritance
  5681. */
  5682. Vue.extend = function (extendOptions) {
  5683. extendOptions = extendOptions || {};
  5684. const Super = this;
  5685. const SuperId = Super.cid;
  5686. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5687. if (cachedCtors[SuperId]) {
  5688. return cachedCtors[SuperId];
  5689. }
  5690. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5691. if (name) {
  5692. validateComponentName(name);
  5693. }
  5694. const Sub = function VueComponent(options) {
  5695. this._init(options);
  5696. };
  5697. Sub.prototype = Object.create(Super.prototype);
  5698. Sub.prototype.constructor = Sub;
  5699. Sub.cid = cid++;
  5700. Sub.options = mergeOptions(Super.options, extendOptions);
  5701. Sub['super'] = Super;
  5702. // For props and computed properties, we define the proxy getters on
  5703. // the Vue instances at extension time, on the extended prototype. This
  5704. // avoids Object.defineProperty calls for each instance created.
  5705. if (Sub.options.props) {
  5706. initProps(Sub);
  5707. }
  5708. if (Sub.options.computed) {
  5709. initComputed(Sub);
  5710. }
  5711. // allow further extension/mixin/plugin usage
  5712. Sub.extend = Super.extend;
  5713. Sub.mixin = Super.mixin;
  5714. Sub.use = Super.use;
  5715. // create asset registers, so extended classes
  5716. // can have their private assets too.
  5717. ASSET_TYPES.forEach(function (type) {
  5718. Sub[type] = Super[type];
  5719. });
  5720. // enable recursive self-lookup
  5721. if (name) {
  5722. Sub.options.components[name] = Sub;
  5723. }
  5724. // keep a reference to the super options at extension time.
  5725. // later at instantiation we can check if Super's options have
  5726. // been updated.
  5727. Sub.superOptions = Super.options;
  5728. Sub.extendOptions = extendOptions;
  5729. Sub.sealedOptions = extend({}, Sub.options);
  5730. // cache constructor
  5731. cachedCtors[SuperId] = Sub;
  5732. return Sub;
  5733. };
  5734. }
  5735. function initProps(Comp) {
  5736. const props = Comp.options.props;
  5737. for (const key in props) {
  5738. proxy(Comp.prototype, `_props`, key);
  5739. }
  5740. }
  5741. function initComputed(Comp) {
  5742. const computed = Comp.options.computed;
  5743. for (const key in computed) {
  5744. defineComputed(Comp.prototype, key, computed[key]);
  5745. }
  5746. }
  5747. function initAssetRegisters(Vue) {
  5748. /**
  5749. * Create asset registration methods.
  5750. */
  5751. ASSET_TYPES.forEach(type => {
  5752. // @ts-expect-error function is not exact same type
  5753. Vue[type] = function (id, definition) {
  5754. if (!definition) {
  5755. return this.options[type + 's'][id];
  5756. }
  5757. else {
  5758. /* istanbul ignore if */
  5759. if (type === 'component') {
  5760. validateComponentName(id);
  5761. }
  5762. if (type === 'component' && isPlainObject(definition)) {
  5763. // @ts-expect-error
  5764. definition.name = definition.name || id;
  5765. definition = this.options._base.extend(definition);
  5766. }
  5767. if (type === 'directive' && isFunction(definition)) {
  5768. definition = { bind: definition, update: definition };
  5769. }
  5770. this.options[type + 's'][id] = definition;
  5771. return definition;
  5772. }
  5773. };
  5774. });
  5775. }
  5776. function _getComponentName(opts) {
  5777. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5778. }
  5779. function matches(pattern, name) {
  5780. if (isArray(pattern)) {
  5781. return pattern.indexOf(name) > -1;
  5782. }
  5783. else if (typeof pattern === 'string') {
  5784. return pattern.split(',').indexOf(name) > -1;
  5785. }
  5786. else if (isRegExp(pattern)) {
  5787. return pattern.test(name);
  5788. }
  5789. /* istanbul ignore next */
  5790. return false;
  5791. }
  5792. function pruneCache(keepAliveInstance, filter) {
  5793. const { cache, keys, _vnode } = keepAliveInstance;
  5794. for (const key in cache) {
  5795. const entry = cache[key];
  5796. if (entry) {
  5797. const name = entry.name;
  5798. if (name && !filter(name)) {
  5799. pruneCacheEntry(cache, key, keys, _vnode);
  5800. }
  5801. }
  5802. }
  5803. }
  5804. function pruneCacheEntry(cache, key, keys, current) {
  5805. const entry = cache[key];
  5806. if (entry && (!current || entry.tag !== current.tag)) {
  5807. // @ts-expect-error can be undefined
  5808. entry.componentInstance.$destroy();
  5809. }
  5810. cache[key] = null;
  5811. remove$2(keys, key);
  5812. }
  5813. const patternTypes = [String, RegExp, Array];
  5814. // TODO defineComponent
  5815. var KeepAlive = {
  5816. name: 'keep-alive',
  5817. abstract: true,
  5818. props: {
  5819. include: patternTypes,
  5820. exclude: patternTypes,
  5821. max: [String, Number]
  5822. },
  5823. methods: {
  5824. cacheVNode() {
  5825. const { cache, keys, vnodeToCache, keyToCache } = this;
  5826. if (vnodeToCache) {
  5827. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5828. cache[keyToCache] = {
  5829. name: _getComponentName(componentOptions),
  5830. tag,
  5831. componentInstance
  5832. };
  5833. keys.push(keyToCache);
  5834. // prune oldest entry
  5835. if (this.max && keys.length > parseInt(this.max)) {
  5836. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5837. }
  5838. this.vnodeToCache = null;
  5839. }
  5840. }
  5841. },
  5842. created() {
  5843. this.cache = Object.create(null);
  5844. this.keys = [];
  5845. },
  5846. destroyed() {
  5847. for (const key in this.cache) {
  5848. pruneCacheEntry(this.cache, key, this.keys);
  5849. }
  5850. },
  5851. mounted() {
  5852. this.cacheVNode();
  5853. this.$watch('include', val => {
  5854. pruneCache(this, name => matches(val, name));
  5855. });
  5856. this.$watch('exclude', val => {
  5857. pruneCache(this, name => !matches(val, name));
  5858. });
  5859. },
  5860. updated() {
  5861. this.cacheVNode();
  5862. },
  5863. render() {
  5864. const slot = this.$slots.default;
  5865. const vnode = getFirstComponentChild(slot);
  5866. const componentOptions = vnode && vnode.componentOptions;
  5867. if (componentOptions) {
  5868. // check pattern
  5869. const name = _getComponentName(componentOptions);
  5870. const { include, exclude } = this;
  5871. if (
  5872. // not included
  5873. (include && (!name || !matches(include, name))) ||
  5874. // excluded
  5875. (exclude && name && matches(exclude, name))) {
  5876. return vnode;
  5877. }
  5878. const { cache, keys } = this;
  5879. const key = vnode.key == null
  5880. ? // same constructor may get registered as different local components
  5881. // so cid alone is not enough (#3269)
  5882. componentOptions.Ctor.cid +
  5883. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5884. : vnode.key;
  5885. if (cache[key]) {
  5886. vnode.componentInstance = cache[key].componentInstance;
  5887. // make current key freshest
  5888. remove$2(keys, key);
  5889. keys.push(key);
  5890. }
  5891. else {
  5892. // delay setting the cache until update
  5893. this.vnodeToCache = vnode;
  5894. this.keyToCache = key;
  5895. }
  5896. // @ts-expect-error can vnode.data can be undefined
  5897. vnode.data.keepAlive = true;
  5898. }
  5899. return vnode || (slot && slot[0]);
  5900. }
  5901. };
  5902. var builtInComponents = {
  5903. KeepAlive
  5904. };
  5905. function initGlobalAPI(Vue) {
  5906. // config
  5907. const configDef = {};
  5908. configDef.get = () => config;
  5909. {
  5910. configDef.set = () => {
  5911. warn$2('Do not replace the Vue.config object, set individual fields instead.');
  5912. };
  5913. }
  5914. Object.defineProperty(Vue, 'config', configDef);
  5915. // exposed util methods.
  5916. // NOTE: these are not considered part of the public API - avoid relying on
  5917. // them unless you are aware of the risk.
  5918. Vue.util = {
  5919. warn: warn$2,
  5920. extend,
  5921. mergeOptions,
  5922. defineReactive
  5923. };
  5924. Vue.set = set;
  5925. Vue.delete = del;
  5926. Vue.nextTick = nextTick;
  5927. // 2.6 explicit observable API
  5928. Vue.observable = (obj) => {
  5929. observe(obj);
  5930. return obj;
  5931. };
  5932. Vue.options = Object.create(null);
  5933. ASSET_TYPES.forEach(type => {
  5934. Vue.options[type + 's'] = Object.create(null);
  5935. });
  5936. // this is used to identify the "base" constructor to extend all plain-object
  5937. // components with in Weex's multi-instance scenarios.
  5938. Vue.options._base = Vue;
  5939. extend(Vue.options.components, builtInComponents);
  5940. initUse(Vue);
  5941. initMixin(Vue);
  5942. initExtend(Vue);
  5943. initAssetRegisters(Vue);
  5944. }
  5945. initGlobalAPI(Vue);
  5946. Object.defineProperty(Vue.prototype, '$isServer', {
  5947. get: isServerRendering
  5948. });
  5949. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5950. get() {
  5951. /* istanbul ignore next */
  5952. return this.$vnode && this.$vnode.ssrContext;
  5953. }
  5954. });
  5955. // expose FunctionalRenderContext for ssr runtime helper installation
  5956. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5957. value: FunctionalRenderContext
  5958. });
  5959. Vue.version = version;
  5960. // these are reserved for web because they are directly compiled away
  5961. // during template compilation
  5962. const isReservedAttr = makeMap('style,class');
  5963. // attributes that should be using props for binding
  5964. const acceptValue = makeMap('input,textarea,option,select,progress');
  5965. const mustUseProp = (tag, type, attr) => {
  5966. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5967. (attr === 'selected' && tag === 'option') ||
  5968. (attr === 'checked' && tag === 'input') ||
  5969. (attr === 'muted' && tag === 'video'));
  5970. };
  5971. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5972. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5973. const convertEnumeratedValue = (key, value) => {
  5974. return isFalsyAttrValue(value) || value === 'false'
  5975. ? 'false'
  5976. : // allow arbitrary string value for contenteditable
  5977. key === 'contenteditable' && isValidContentEditableValue(value)
  5978. ? value
  5979. : 'true';
  5980. };
  5981. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5982. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5983. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5984. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5985. 'required,reversed,scoped,seamless,selected,sortable,' +
  5986. 'truespeed,typemustmatch,visible');
  5987. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5988. const isXlink = (name) => {
  5989. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5990. };
  5991. const getXlinkProp = (name) => {
  5992. return isXlink(name) ? name.slice(6, name.length) : '';
  5993. };
  5994. const isFalsyAttrValue = (val) => {
  5995. return val == null || val === false;
  5996. };
  5997. function genClassForVnode(vnode) {
  5998. let data = vnode.data;
  5999. let parentNode = vnode;
  6000. let childNode = vnode;
  6001. while (isDef(childNode.componentInstance)) {
  6002. childNode = childNode.componentInstance._vnode;
  6003. if (childNode && childNode.data) {
  6004. data = mergeClassData(childNode.data, data);
  6005. }
  6006. }
  6007. // @ts-expect-error parentNode.parent not VNodeWithData
  6008. while (isDef((parentNode = parentNode.parent))) {
  6009. if (parentNode && parentNode.data) {
  6010. data = mergeClassData(data, parentNode.data);
  6011. }
  6012. }
  6013. return renderClass(data.staticClass, data.class);
  6014. }
  6015. function mergeClassData(child, parent) {
  6016. return {
  6017. staticClass: concat(child.staticClass, parent.staticClass),
  6018. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6019. };
  6020. }
  6021. function renderClass(staticClass, dynamicClass) {
  6022. if (isDef(staticClass) || isDef(dynamicClass)) {
  6023. return concat(staticClass, stringifyClass(dynamicClass));
  6024. }
  6025. /* istanbul ignore next */
  6026. return '';
  6027. }
  6028. function concat(a, b) {
  6029. return a ? (b ? a + ' ' + b : a) : b || '';
  6030. }
  6031. function stringifyClass(value) {
  6032. if (Array.isArray(value)) {
  6033. return stringifyArray(value);
  6034. }
  6035. if (isObject(value)) {
  6036. return stringifyObject(value);
  6037. }
  6038. if (typeof value === 'string') {
  6039. return value;
  6040. }
  6041. /* istanbul ignore next */
  6042. return '';
  6043. }
  6044. function stringifyArray(value) {
  6045. let res = '';
  6046. let stringified;
  6047. for (let i = 0, l = value.length; i < l; i++) {
  6048. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6049. if (res)
  6050. res += ' ';
  6051. res += stringified;
  6052. }
  6053. }
  6054. return res;
  6055. }
  6056. function stringifyObject(value) {
  6057. let res = '';
  6058. for (const key in value) {
  6059. if (value[key]) {
  6060. if (res)
  6061. res += ' ';
  6062. res += key;
  6063. }
  6064. }
  6065. return res;
  6066. }
  6067. const namespaceMap = {
  6068. svg: 'http://www.w3.org/2000/svg',
  6069. math: 'http://www.w3.org/1998/Math/MathML'
  6070. };
  6071. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6072. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6073. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6074. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6075. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6076. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6077. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6078. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6079. 'output,progress,select,textarea,' +
  6080. 'details,dialog,menu,menuitem,summary,' +
  6081. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6082. // this map is intentionally selective, only covering SVG elements that may
  6083. // contain child elements.
  6084. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6085. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6086. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6087. const isPreTag = (tag) => tag === 'pre';
  6088. const isReservedTag = (tag) => {
  6089. return isHTMLTag(tag) || isSVG(tag);
  6090. };
  6091. function getTagNamespace(tag) {
  6092. if (isSVG(tag)) {
  6093. return 'svg';
  6094. }
  6095. // basic support for MathML
  6096. // note it doesn't support other MathML elements being component roots
  6097. if (tag === 'math') {
  6098. return 'math';
  6099. }
  6100. }
  6101. const unknownElementCache = Object.create(null);
  6102. function isUnknownElement(tag) {
  6103. /* istanbul ignore if */
  6104. if (!inBrowser) {
  6105. return true;
  6106. }
  6107. if (isReservedTag(tag)) {
  6108. return false;
  6109. }
  6110. tag = tag.toLowerCase();
  6111. /* istanbul ignore if */
  6112. if (unknownElementCache[tag] != null) {
  6113. return unknownElementCache[tag];
  6114. }
  6115. const el = document.createElement(tag);
  6116. if (tag.indexOf('-') > -1) {
  6117. // https://stackoverflow.com/a/28210364/1070244
  6118. return (unknownElementCache[tag] =
  6119. el.constructor === window.HTMLUnknownElement ||
  6120. el.constructor === window.HTMLElement);
  6121. }
  6122. else {
  6123. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6124. }
  6125. }
  6126. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6127. /**
  6128. * Query an element selector if it's not an element already.
  6129. */
  6130. function query(el) {
  6131. if (typeof el === 'string') {
  6132. const selected = document.querySelector(el);
  6133. if (!selected) {
  6134. warn$2('Cannot find element: ' + el);
  6135. return document.createElement('div');
  6136. }
  6137. return selected;
  6138. }
  6139. else {
  6140. return el;
  6141. }
  6142. }
  6143. function createElement(tagName, vnode) {
  6144. const elm = document.createElement(tagName);
  6145. if (tagName !== 'select') {
  6146. return elm;
  6147. }
  6148. // false or null will remove the attribute but undefined will not
  6149. if (vnode.data &&
  6150. vnode.data.attrs &&
  6151. vnode.data.attrs.multiple !== undefined) {
  6152. elm.setAttribute('multiple', 'multiple');
  6153. }
  6154. return elm;
  6155. }
  6156. function createElementNS(namespace, tagName) {
  6157. return document.createElementNS(namespaceMap[namespace], tagName);
  6158. }
  6159. function createTextNode(text) {
  6160. return document.createTextNode(text);
  6161. }
  6162. function createComment(text) {
  6163. return document.createComment(text);
  6164. }
  6165. function insertBefore(parentNode, newNode, referenceNode) {
  6166. parentNode.insertBefore(newNode, referenceNode);
  6167. }
  6168. function removeChild(node, child) {
  6169. node.removeChild(child);
  6170. }
  6171. function appendChild(node, child) {
  6172. node.appendChild(child);
  6173. }
  6174. function parentNode(node) {
  6175. return node.parentNode;
  6176. }
  6177. function nextSibling(node) {
  6178. return node.nextSibling;
  6179. }
  6180. function tagName(node) {
  6181. return node.tagName;
  6182. }
  6183. function setTextContent(node, text) {
  6184. node.textContent = text;
  6185. }
  6186. function setStyleScope(node, scopeId) {
  6187. node.setAttribute(scopeId, '');
  6188. }
  6189. var nodeOps = /*#__PURE__*/Object.freeze({
  6190. __proto__: null,
  6191. createElement: createElement,
  6192. createElementNS: createElementNS,
  6193. createTextNode: createTextNode,
  6194. createComment: createComment,
  6195. insertBefore: insertBefore,
  6196. removeChild: removeChild,
  6197. appendChild: appendChild,
  6198. parentNode: parentNode,
  6199. nextSibling: nextSibling,
  6200. tagName: tagName,
  6201. setTextContent: setTextContent,
  6202. setStyleScope: setStyleScope
  6203. });
  6204. var ref = {
  6205. create(_, vnode) {
  6206. registerRef(vnode);
  6207. },
  6208. update(oldVnode, vnode) {
  6209. if (oldVnode.data.ref !== vnode.data.ref) {
  6210. registerRef(oldVnode, true);
  6211. registerRef(vnode);
  6212. }
  6213. },
  6214. destroy(vnode) {
  6215. registerRef(vnode, true);
  6216. }
  6217. };
  6218. function registerRef(vnode, isRemoval) {
  6219. const ref = vnode.data.ref;
  6220. if (!isDef(ref))
  6221. return;
  6222. const vm = vnode.context;
  6223. const refValue = vnode.componentInstance || vnode.elm;
  6224. const value = isRemoval ? null : refValue;
  6225. const $refsValue = isRemoval ? undefined : refValue;
  6226. if (isFunction(ref)) {
  6227. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6228. return;
  6229. }
  6230. const isFor = vnode.data.refInFor;
  6231. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6232. const _isRef = isRef(ref);
  6233. const refs = vm.$refs;
  6234. if (_isString || _isRef) {
  6235. if (isFor) {
  6236. const existing = _isString ? refs[ref] : ref.value;
  6237. if (isRemoval) {
  6238. isArray(existing) && remove$2(existing, refValue);
  6239. }
  6240. else {
  6241. if (!isArray(existing)) {
  6242. if (_isString) {
  6243. refs[ref] = [refValue];
  6244. setSetupRef(vm, ref, refs[ref]);
  6245. }
  6246. else {
  6247. ref.value = [refValue];
  6248. }
  6249. }
  6250. else if (!existing.includes(refValue)) {
  6251. existing.push(refValue);
  6252. }
  6253. }
  6254. }
  6255. else if (_isString) {
  6256. if (isRemoval && refs[ref] !== refValue) {
  6257. return;
  6258. }
  6259. refs[ref] = $refsValue;
  6260. setSetupRef(vm, ref, value);
  6261. }
  6262. else if (_isRef) {
  6263. if (isRemoval && ref.value !== refValue) {
  6264. return;
  6265. }
  6266. ref.value = value;
  6267. }
  6268. else {
  6269. warn$2(`Invalid template ref type: ${typeof ref}`);
  6270. }
  6271. }
  6272. }
  6273. function setSetupRef({ _setupState }, key, val) {
  6274. if (_setupState && hasOwn(_setupState, key)) {
  6275. if (isRef(_setupState[key])) {
  6276. _setupState[key].value = val;
  6277. }
  6278. else {
  6279. _setupState[key] = val;
  6280. }
  6281. }
  6282. }
  6283. /**
  6284. * Virtual DOM patching algorithm based on Snabbdom by
  6285. * Simon Friis Vindum (@paldepind)
  6286. * Licensed under the MIT License
  6287. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6288. *
  6289. * modified by Evan You (@yyx990803)
  6290. *
  6291. * Not type-checking this because this file is perf-critical and the cost
  6292. * of making flow understand it is not worth it.
  6293. */
  6294. const emptyNode = new VNode('', {}, []);
  6295. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6296. function sameVnode(a, b) {
  6297. return (a.key === b.key &&
  6298. a.asyncFactory === b.asyncFactory &&
  6299. ((a.tag === b.tag &&
  6300. a.isComment === b.isComment &&
  6301. isDef(a.data) === isDef(b.data) &&
  6302. sameInputType(a, b)) ||
  6303. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6304. }
  6305. function sameInputType(a, b) {
  6306. if (a.tag !== 'input')
  6307. return true;
  6308. let i;
  6309. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6310. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6311. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6312. }
  6313. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6314. let i, key;
  6315. const map = {};
  6316. for (i = beginIdx; i <= endIdx; ++i) {
  6317. key = children[i].key;
  6318. if (isDef(key))
  6319. map[key] = i;
  6320. }
  6321. return map;
  6322. }
  6323. function createPatchFunction(backend) {
  6324. let i, j;
  6325. const cbs = {};
  6326. const { modules, nodeOps } = backend;
  6327. for (i = 0; i < hooks.length; ++i) {
  6328. cbs[hooks[i]] = [];
  6329. for (j = 0; j < modules.length; ++j) {
  6330. if (isDef(modules[j][hooks[i]])) {
  6331. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6332. }
  6333. }
  6334. }
  6335. function emptyNodeAt(elm) {
  6336. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6337. }
  6338. function createRmCb(childElm, listeners) {
  6339. function remove() {
  6340. if (--remove.listeners === 0) {
  6341. removeNode(childElm);
  6342. }
  6343. }
  6344. remove.listeners = listeners;
  6345. return remove;
  6346. }
  6347. function removeNode(el) {
  6348. const parent = nodeOps.parentNode(el);
  6349. // element may have already been removed due to v-html / v-text
  6350. if (isDef(parent)) {
  6351. nodeOps.removeChild(parent, el);
  6352. }
  6353. }
  6354. function isUnknownElement(vnode, inVPre) {
  6355. return (!inVPre &&
  6356. !vnode.ns &&
  6357. !(config.ignoredElements.length &&
  6358. config.ignoredElements.some(ignore => {
  6359. return isRegExp(ignore)
  6360. ? ignore.test(vnode.tag)
  6361. : ignore === vnode.tag;
  6362. })) &&
  6363. config.isUnknownElement(vnode.tag));
  6364. }
  6365. let creatingElmInVPre = 0;
  6366. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6367. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6368. // This vnode was used in a previous render!
  6369. // now it's used as a new node, overwriting its elm would cause
  6370. // potential patch errors down the road when it's used as an insertion
  6371. // reference node. Instead, we clone the node on-demand before creating
  6372. // associated DOM element for it.
  6373. vnode = ownerArray[index] = cloneVNode(vnode);
  6374. }
  6375. vnode.isRootInsert = !nested; // for transition enter check
  6376. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6377. return;
  6378. }
  6379. const data = vnode.data;
  6380. const children = vnode.children;
  6381. const tag = vnode.tag;
  6382. if (isDef(tag)) {
  6383. {
  6384. if (data && data.pre) {
  6385. creatingElmInVPre++;
  6386. }
  6387. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6388. warn$2('Unknown custom element: <' +
  6389. tag +
  6390. '> - did you ' +
  6391. 'register the component correctly? For recursive components, ' +
  6392. 'make sure to provide the "name" option.', vnode.context);
  6393. }
  6394. }
  6395. vnode.elm = vnode.ns
  6396. ? nodeOps.createElementNS(vnode.ns, tag)
  6397. : nodeOps.createElement(tag, vnode);
  6398. setScope(vnode);
  6399. createChildren(vnode, children, insertedVnodeQueue);
  6400. if (isDef(data)) {
  6401. invokeCreateHooks(vnode, insertedVnodeQueue);
  6402. }
  6403. insert(parentElm, vnode.elm, refElm);
  6404. if (data && data.pre) {
  6405. creatingElmInVPre--;
  6406. }
  6407. }
  6408. else if (isTrue(vnode.isComment)) {
  6409. vnode.elm = nodeOps.createComment(vnode.text);
  6410. insert(parentElm, vnode.elm, refElm);
  6411. }
  6412. else {
  6413. vnode.elm = nodeOps.createTextNode(vnode.text);
  6414. insert(parentElm, vnode.elm, refElm);
  6415. }
  6416. }
  6417. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6418. let i = vnode.data;
  6419. if (isDef(i)) {
  6420. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6421. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6422. i(vnode, false /* hydrating */);
  6423. }
  6424. // after calling the init hook, if the vnode is a child component
  6425. // it should've created a child instance and mounted it. the child
  6426. // component also has set the placeholder vnode's elm.
  6427. // in that case we can just return the element and be done.
  6428. if (isDef(vnode.componentInstance)) {
  6429. initComponent(vnode, insertedVnodeQueue);
  6430. insert(parentElm, vnode.elm, refElm);
  6431. if (isTrue(isReactivated)) {
  6432. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6433. }
  6434. return true;
  6435. }
  6436. }
  6437. }
  6438. function initComponent(vnode, insertedVnodeQueue) {
  6439. if (isDef(vnode.data.pendingInsert)) {
  6440. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6441. vnode.data.pendingInsert = null;
  6442. }
  6443. vnode.elm = vnode.componentInstance.$el;
  6444. if (isPatchable(vnode)) {
  6445. invokeCreateHooks(vnode, insertedVnodeQueue);
  6446. setScope(vnode);
  6447. }
  6448. else {
  6449. // empty component root.
  6450. // skip all element-related modules except for ref (#3455)
  6451. registerRef(vnode);
  6452. // make sure to invoke the insert hook
  6453. insertedVnodeQueue.push(vnode);
  6454. }
  6455. }
  6456. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6457. let i;
  6458. // hack for #4339: a reactivated component with inner transition
  6459. // does not trigger because the inner node's created hooks are not called
  6460. // again. It's not ideal to involve module-specific logic in here but
  6461. // there doesn't seem to be a better way to do it.
  6462. let innerNode = vnode;
  6463. while (innerNode.componentInstance) {
  6464. innerNode = innerNode.componentInstance._vnode;
  6465. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6466. for (i = 0; i < cbs.activate.length; ++i) {
  6467. cbs.activate[i](emptyNode, innerNode);
  6468. }
  6469. insertedVnodeQueue.push(innerNode);
  6470. break;
  6471. }
  6472. }
  6473. // unlike a newly created component,
  6474. // a reactivated keep-alive component doesn't insert itself
  6475. insert(parentElm, vnode.elm, refElm);
  6476. }
  6477. function insert(parent, elm, ref) {
  6478. if (isDef(parent)) {
  6479. if (isDef(ref)) {
  6480. if (nodeOps.parentNode(ref) === parent) {
  6481. nodeOps.insertBefore(parent, elm, ref);
  6482. }
  6483. }
  6484. else {
  6485. nodeOps.appendChild(parent, elm);
  6486. }
  6487. }
  6488. }
  6489. function createChildren(vnode, children, insertedVnodeQueue) {
  6490. if (isArray(children)) {
  6491. {
  6492. checkDuplicateKeys(children);
  6493. }
  6494. for (let i = 0; i < children.length; ++i) {
  6495. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6496. }
  6497. }
  6498. else if (isPrimitive(vnode.text)) {
  6499. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6500. }
  6501. }
  6502. function isPatchable(vnode) {
  6503. while (vnode.componentInstance) {
  6504. vnode = vnode.componentInstance._vnode;
  6505. }
  6506. return isDef(vnode.tag);
  6507. }
  6508. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6509. for (let i = 0; i < cbs.create.length; ++i) {
  6510. cbs.create[i](emptyNode, vnode);
  6511. }
  6512. i = vnode.data.hook; // Reuse variable
  6513. if (isDef(i)) {
  6514. if (isDef(i.create))
  6515. i.create(emptyNode, vnode);
  6516. if (isDef(i.insert))
  6517. insertedVnodeQueue.push(vnode);
  6518. }
  6519. }
  6520. // set scope id attribute for scoped CSS.
  6521. // this is implemented as a special case to avoid the overhead
  6522. // of going through the normal attribute patching process.
  6523. function setScope(vnode) {
  6524. let i;
  6525. if (isDef((i = vnode.fnScopeId))) {
  6526. nodeOps.setStyleScope(vnode.elm, i);
  6527. }
  6528. else {
  6529. let ancestor = vnode;
  6530. while (ancestor) {
  6531. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6532. nodeOps.setStyleScope(vnode.elm, i);
  6533. }
  6534. ancestor = ancestor.parent;
  6535. }
  6536. }
  6537. // for slot content they should also get the scopeId from the host instance.
  6538. if (isDef((i = activeInstance)) &&
  6539. i !== vnode.context &&
  6540. i !== vnode.fnContext &&
  6541. isDef((i = i.$options._scopeId))) {
  6542. nodeOps.setStyleScope(vnode.elm, i);
  6543. }
  6544. }
  6545. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6546. for (; startIdx <= endIdx; ++startIdx) {
  6547. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6548. }
  6549. }
  6550. function invokeDestroyHook(vnode) {
  6551. let i, j;
  6552. const data = vnode.data;
  6553. if (isDef(data)) {
  6554. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6555. i(vnode);
  6556. for (i = 0; i < cbs.destroy.length; ++i)
  6557. cbs.destroy[i](vnode);
  6558. }
  6559. if (isDef((i = vnode.children))) {
  6560. for (j = 0; j < vnode.children.length; ++j) {
  6561. invokeDestroyHook(vnode.children[j]);
  6562. }
  6563. }
  6564. }
  6565. function removeVnodes(vnodes, startIdx, endIdx) {
  6566. for (; startIdx <= endIdx; ++startIdx) {
  6567. const ch = vnodes[startIdx];
  6568. if (isDef(ch)) {
  6569. if (isDef(ch.tag)) {
  6570. removeAndInvokeRemoveHook(ch);
  6571. invokeDestroyHook(ch);
  6572. }
  6573. else {
  6574. // Text node
  6575. removeNode(ch.elm);
  6576. }
  6577. }
  6578. }
  6579. }
  6580. function removeAndInvokeRemoveHook(vnode, rm) {
  6581. if (isDef(rm) || isDef(vnode.data)) {
  6582. let i;
  6583. const listeners = cbs.remove.length + 1;
  6584. if (isDef(rm)) {
  6585. // we have a recursively passed down rm callback
  6586. // increase the listeners count
  6587. rm.listeners += listeners;
  6588. }
  6589. else {
  6590. // directly removing
  6591. rm = createRmCb(vnode.elm, listeners);
  6592. }
  6593. // recursively invoke hooks on child component root node
  6594. if (isDef((i = vnode.componentInstance)) &&
  6595. isDef((i = i._vnode)) &&
  6596. isDef(i.data)) {
  6597. removeAndInvokeRemoveHook(i, rm);
  6598. }
  6599. for (i = 0; i < cbs.remove.length; ++i) {
  6600. cbs.remove[i](vnode, rm);
  6601. }
  6602. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6603. i(vnode, rm);
  6604. }
  6605. else {
  6606. rm();
  6607. }
  6608. }
  6609. else {
  6610. removeNode(vnode.elm);
  6611. }
  6612. }
  6613. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6614. let oldStartIdx = 0;
  6615. let newStartIdx = 0;
  6616. let oldEndIdx = oldCh.length - 1;
  6617. let oldStartVnode = oldCh[0];
  6618. let oldEndVnode = oldCh[oldEndIdx];
  6619. let newEndIdx = newCh.length - 1;
  6620. let newStartVnode = newCh[0];
  6621. let newEndVnode = newCh[newEndIdx];
  6622. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6623. // removeOnly is a special flag used only by <transition-group>
  6624. // to ensure removed elements stay in correct relative positions
  6625. // during leaving transitions
  6626. const canMove = !removeOnly;
  6627. {
  6628. checkDuplicateKeys(newCh);
  6629. }
  6630. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6631. if (isUndef(oldStartVnode)) {
  6632. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6633. }
  6634. else if (isUndef(oldEndVnode)) {
  6635. oldEndVnode = oldCh[--oldEndIdx];
  6636. }
  6637. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6638. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6639. oldStartVnode = oldCh[++oldStartIdx];
  6640. newStartVnode = newCh[++newStartIdx];
  6641. }
  6642. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6643. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6644. oldEndVnode = oldCh[--oldEndIdx];
  6645. newEndVnode = newCh[--newEndIdx];
  6646. }
  6647. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6648. // Vnode moved right
  6649. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6650. canMove &&
  6651. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6652. oldStartVnode = oldCh[++oldStartIdx];
  6653. newEndVnode = newCh[--newEndIdx];
  6654. }
  6655. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6656. // Vnode moved left
  6657. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6658. canMove &&
  6659. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6660. oldEndVnode = oldCh[--oldEndIdx];
  6661. newStartVnode = newCh[++newStartIdx];
  6662. }
  6663. else {
  6664. if (isUndef(oldKeyToIdx))
  6665. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6666. idxInOld = isDef(newStartVnode.key)
  6667. ? oldKeyToIdx[newStartVnode.key]
  6668. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6669. if (isUndef(idxInOld)) {
  6670. // New element
  6671. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6672. }
  6673. else {
  6674. vnodeToMove = oldCh[idxInOld];
  6675. if (sameVnode(vnodeToMove, newStartVnode)) {
  6676. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6677. oldCh[idxInOld] = undefined;
  6678. canMove &&
  6679. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6680. }
  6681. else {
  6682. // same key but different element. treat as new element
  6683. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6684. }
  6685. }
  6686. newStartVnode = newCh[++newStartIdx];
  6687. }
  6688. }
  6689. if (oldStartIdx > oldEndIdx) {
  6690. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6691. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6692. }
  6693. else if (newStartIdx > newEndIdx) {
  6694. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6695. }
  6696. }
  6697. function checkDuplicateKeys(children) {
  6698. const seenKeys = {};
  6699. for (let i = 0; i < children.length; i++) {
  6700. const vnode = children[i];
  6701. const key = vnode.key;
  6702. if (isDef(key)) {
  6703. if (seenKeys[key]) {
  6704. warn$2(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6705. }
  6706. else {
  6707. seenKeys[key] = true;
  6708. }
  6709. }
  6710. }
  6711. }
  6712. function findIdxInOld(node, oldCh, start, end) {
  6713. for (let i = start; i < end; i++) {
  6714. const c = oldCh[i];
  6715. if (isDef(c) && sameVnode(node, c))
  6716. return i;
  6717. }
  6718. }
  6719. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6720. if (oldVnode === vnode) {
  6721. return;
  6722. }
  6723. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6724. // clone reused vnode
  6725. vnode = ownerArray[index] = cloneVNode(vnode);
  6726. }
  6727. const elm = (vnode.elm = oldVnode.elm);
  6728. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6729. if (isDef(vnode.asyncFactory.resolved)) {
  6730. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6731. }
  6732. else {
  6733. vnode.isAsyncPlaceholder = true;
  6734. }
  6735. return;
  6736. }
  6737. // reuse element for static trees.
  6738. // note we only do this if the vnode is cloned -
  6739. // if the new node is not cloned it means the render functions have been
  6740. // reset by the hot-reload-api and we need to do a proper re-render.
  6741. if (isTrue(vnode.isStatic) &&
  6742. isTrue(oldVnode.isStatic) &&
  6743. vnode.key === oldVnode.key &&
  6744. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6745. vnode.componentInstance = oldVnode.componentInstance;
  6746. return;
  6747. }
  6748. let i;
  6749. const data = vnode.data;
  6750. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6751. i(oldVnode, vnode);
  6752. }
  6753. const oldCh = oldVnode.children;
  6754. const ch = vnode.children;
  6755. if (isDef(data) && isPatchable(vnode)) {
  6756. for (i = 0; i < cbs.update.length; ++i)
  6757. cbs.update[i](oldVnode, vnode);
  6758. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6759. i(oldVnode, vnode);
  6760. }
  6761. if (isUndef(vnode.text)) {
  6762. if (isDef(oldCh) && isDef(ch)) {
  6763. if (oldCh !== ch)
  6764. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6765. }
  6766. else if (isDef(ch)) {
  6767. {
  6768. checkDuplicateKeys(ch);
  6769. }
  6770. if (isDef(oldVnode.text))
  6771. nodeOps.setTextContent(elm, '');
  6772. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6773. }
  6774. else if (isDef(oldCh)) {
  6775. removeVnodes(oldCh, 0, oldCh.length - 1);
  6776. }
  6777. else if (isDef(oldVnode.text)) {
  6778. nodeOps.setTextContent(elm, '');
  6779. }
  6780. }
  6781. else if (oldVnode.text !== vnode.text) {
  6782. nodeOps.setTextContent(elm, vnode.text);
  6783. }
  6784. if (isDef(data)) {
  6785. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6786. i(oldVnode, vnode);
  6787. }
  6788. }
  6789. function invokeInsertHook(vnode, queue, initial) {
  6790. // delay insert hooks for component root nodes, invoke them after the
  6791. // element is really inserted
  6792. if (isTrue(initial) && isDef(vnode.parent)) {
  6793. vnode.parent.data.pendingInsert = queue;
  6794. }
  6795. else {
  6796. for (let i = 0; i < queue.length; ++i) {
  6797. queue[i].data.hook.insert(queue[i]);
  6798. }
  6799. }
  6800. }
  6801. let hydrationBailed = false;
  6802. // list of modules that can skip create hook during hydration because they
  6803. // are already rendered on the client or has no need for initialization
  6804. // Note: style is excluded because it relies on initial clone for future
  6805. // deep updates (#7063).
  6806. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6807. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6808. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6809. let i;
  6810. const { tag, data, children } = vnode;
  6811. inVPre = inVPre || (data && data.pre);
  6812. vnode.elm = elm;
  6813. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6814. vnode.isAsyncPlaceholder = true;
  6815. return true;
  6816. }
  6817. // assert node match
  6818. {
  6819. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6820. return false;
  6821. }
  6822. }
  6823. if (isDef(data)) {
  6824. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6825. i(vnode, true /* hydrating */);
  6826. if (isDef((i = vnode.componentInstance))) {
  6827. // child component. it should have hydrated its own tree.
  6828. initComponent(vnode, insertedVnodeQueue);
  6829. return true;
  6830. }
  6831. }
  6832. if (isDef(tag)) {
  6833. if (isDef(children)) {
  6834. // empty element, allow client to pick up and populate children
  6835. if (!elm.hasChildNodes()) {
  6836. createChildren(vnode, children, insertedVnodeQueue);
  6837. }
  6838. else {
  6839. // v-html and domProps: innerHTML
  6840. if (isDef((i = data)) &&
  6841. isDef((i = i.domProps)) &&
  6842. isDef((i = i.innerHTML))) {
  6843. if (i !== elm.innerHTML) {
  6844. /* istanbul ignore if */
  6845. if (typeof console !== 'undefined' &&
  6846. !hydrationBailed) {
  6847. hydrationBailed = true;
  6848. console.warn('Parent: ', elm);
  6849. console.warn('server innerHTML: ', i);
  6850. console.warn('client innerHTML: ', elm.innerHTML);
  6851. }
  6852. return false;
  6853. }
  6854. }
  6855. else {
  6856. // iterate and compare children lists
  6857. let childrenMatch = true;
  6858. let childNode = elm.firstChild;
  6859. for (let i = 0; i < children.length; i++) {
  6860. if (!childNode ||
  6861. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6862. childrenMatch = false;
  6863. break;
  6864. }
  6865. childNode = childNode.nextSibling;
  6866. }
  6867. // if childNode is not null, it means the actual childNodes list is
  6868. // longer than the virtual children list.
  6869. if (!childrenMatch || childNode) {
  6870. /* istanbul ignore if */
  6871. if (typeof console !== 'undefined' &&
  6872. !hydrationBailed) {
  6873. hydrationBailed = true;
  6874. console.warn('Parent: ', elm);
  6875. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6876. }
  6877. return false;
  6878. }
  6879. }
  6880. }
  6881. }
  6882. if (isDef(data)) {
  6883. let fullInvoke = false;
  6884. for (const key in data) {
  6885. if (!isRenderedModule(key)) {
  6886. fullInvoke = true;
  6887. invokeCreateHooks(vnode, insertedVnodeQueue);
  6888. break;
  6889. }
  6890. }
  6891. if (!fullInvoke && data['class']) {
  6892. // ensure collecting deps for deep class bindings for future updates
  6893. traverse(data['class']);
  6894. }
  6895. }
  6896. }
  6897. else if (elm.data !== vnode.text) {
  6898. elm.data = vnode.text;
  6899. }
  6900. return true;
  6901. }
  6902. function assertNodeMatch(node, vnode, inVPre) {
  6903. if (isDef(vnode.tag)) {
  6904. return (vnode.tag.indexOf('vue-component') === 0 ||
  6905. (!isUnknownElement(vnode, inVPre) &&
  6906. vnode.tag.toLowerCase() ===
  6907. (node.tagName && node.tagName.toLowerCase())));
  6908. }
  6909. else {
  6910. return node.nodeType === (vnode.isComment ? 8 : 3);
  6911. }
  6912. }
  6913. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6914. if (isUndef(vnode)) {
  6915. if (isDef(oldVnode))
  6916. invokeDestroyHook(oldVnode);
  6917. return;
  6918. }
  6919. let isInitialPatch = false;
  6920. const insertedVnodeQueue = [];
  6921. if (isUndef(oldVnode)) {
  6922. // empty mount (likely as component), create new root element
  6923. isInitialPatch = true;
  6924. createElm(vnode, insertedVnodeQueue);
  6925. }
  6926. else {
  6927. const isRealElement = isDef(oldVnode.nodeType);
  6928. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6929. // patch existing root node
  6930. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6931. }
  6932. else {
  6933. if (isRealElement) {
  6934. // mounting to a real element
  6935. // check if this is server-rendered content and if we can perform
  6936. // a successful hydration.
  6937. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6938. oldVnode.removeAttribute(SSR_ATTR);
  6939. hydrating = true;
  6940. }
  6941. if (isTrue(hydrating)) {
  6942. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6943. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6944. return oldVnode;
  6945. }
  6946. else {
  6947. warn$2('The client-side rendered virtual DOM tree is not matching ' +
  6948. 'server-rendered content. This is likely caused by incorrect ' +
  6949. 'HTML markup, for example nesting block-level elements inside ' +
  6950. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6951. 'full client-side render.');
  6952. }
  6953. }
  6954. // either not server-rendered, or hydration failed.
  6955. // create an empty node and replace it
  6956. oldVnode = emptyNodeAt(oldVnode);
  6957. }
  6958. // replacing existing element
  6959. const oldElm = oldVnode.elm;
  6960. const parentElm = nodeOps.parentNode(oldElm);
  6961. // create new node
  6962. createElm(vnode, insertedVnodeQueue,
  6963. // extremely rare edge case: do not insert if old element is in a
  6964. // leaving transition. Only happens when combining transition +
  6965. // keep-alive + HOCs. (#4590)
  6966. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6967. // update parent placeholder node element, recursively
  6968. if (isDef(vnode.parent)) {
  6969. let ancestor = vnode.parent;
  6970. const patchable = isPatchable(vnode);
  6971. while (ancestor) {
  6972. for (let i = 0; i < cbs.destroy.length; ++i) {
  6973. cbs.destroy[i](ancestor);
  6974. }
  6975. ancestor.elm = vnode.elm;
  6976. if (patchable) {
  6977. for (let i = 0; i < cbs.create.length; ++i) {
  6978. cbs.create[i](emptyNode, ancestor);
  6979. }
  6980. // #6513
  6981. // invoke insert hooks that may have been merged by create hooks.
  6982. // e.g. for directives that uses the "inserted" hook.
  6983. const insert = ancestor.data.hook.insert;
  6984. if (insert.merged) {
  6985. // start at index 1 to avoid re-invoking component mounted hook
  6986. // clone insert hooks to avoid being mutated during iteration.
  6987. // e.g. for customed directives under transition group.
  6988. const cloned = insert.fns.slice(1);
  6989. for (let i = 0; i < cloned.length; i++) {
  6990. cloned[i]();
  6991. }
  6992. }
  6993. }
  6994. else {
  6995. registerRef(ancestor);
  6996. }
  6997. ancestor = ancestor.parent;
  6998. }
  6999. }
  7000. // destroy old node
  7001. if (isDef(parentElm)) {
  7002. removeVnodes([oldVnode], 0, 0);
  7003. }
  7004. else if (isDef(oldVnode.tag)) {
  7005. invokeDestroyHook(oldVnode);
  7006. }
  7007. }
  7008. }
  7009. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  7010. return vnode.elm;
  7011. };
  7012. }
  7013. var directives$1 = {
  7014. create: updateDirectives,
  7015. update: updateDirectives,
  7016. destroy: function unbindDirectives(vnode) {
  7017. // @ts-expect-error emptyNode is not VNodeWithData
  7018. updateDirectives(vnode, emptyNode);
  7019. }
  7020. };
  7021. function updateDirectives(oldVnode, vnode) {
  7022. if (oldVnode.data.directives || vnode.data.directives) {
  7023. _update(oldVnode, vnode);
  7024. }
  7025. }
  7026. function _update(oldVnode, vnode) {
  7027. const isCreate = oldVnode === emptyNode;
  7028. const isDestroy = vnode === emptyNode;
  7029. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7030. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7031. const dirsWithInsert = [];
  7032. const dirsWithPostpatch = [];
  7033. let key, oldDir, dir;
  7034. for (key in newDirs) {
  7035. oldDir = oldDirs[key];
  7036. dir = newDirs[key];
  7037. if (!oldDir) {
  7038. // new directive, bind
  7039. callHook(dir, 'bind', vnode, oldVnode);
  7040. if (dir.def && dir.def.inserted) {
  7041. dirsWithInsert.push(dir);
  7042. }
  7043. }
  7044. else {
  7045. // existing directive, update
  7046. dir.oldValue = oldDir.value;
  7047. dir.oldArg = oldDir.arg;
  7048. callHook(dir, 'update', vnode, oldVnode);
  7049. if (dir.def && dir.def.componentUpdated) {
  7050. dirsWithPostpatch.push(dir);
  7051. }
  7052. }
  7053. }
  7054. if (dirsWithInsert.length) {
  7055. const callInsert = () => {
  7056. for (let i = 0; i < dirsWithInsert.length; i++) {
  7057. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7058. }
  7059. };
  7060. if (isCreate) {
  7061. mergeVNodeHook(vnode, 'insert', callInsert);
  7062. }
  7063. else {
  7064. callInsert();
  7065. }
  7066. }
  7067. if (dirsWithPostpatch.length) {
  7068. mergeVNodeHook(vnode, 'postpatch', () => {
  7069. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7070. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7071. }
  7072. });
  7073. }
  7074. if (!isCreate) {
  7075. for (key in oldDirs) {
  7076. if (!newDirs[key]) {
  7077. // no longer present, unbind
  7078. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7079. }
  7080. }
  7081. }
  7082. }
  7083. const emptyModifiers = Object.create(null);
  7084. function normalizeDirectives(dirs, vm) {
  7085. const res = Object.create(null);
  7086. if (!dirs) {
  7087. // $flow-disable-line
  7088. return res;
  7089. }
  7090. let i, dir;
  7091. for (i = 0; i < dirs.length; i++) {
  7092. dir = dirs[i];
  7093. if (!dir.modifiers) {
  7094. // $flow-disable-line
  7095. dir.modifiers = emptyModifiers;
  7096. }
  7097. res[getRawDirName(dir)] = dir;
  7098. if (vm._setupState && vm._setupState.__sfc) {
  7099. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7100. if (typeof setupDef === 'function') {
  7101. dir.def = {
  7102. bind: setupDef,
  7103. update: setupDef,
  7104. };
  7105. }
  7106. else {
  7107. dir.def = setupDef;
  7108. }
  7109. }
  7110. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7111. }
  7112. // $flow-disable-line
  7113. return res;
  7114. }
  7115. function getRawDirName(dir) {
  7116. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7117. }
  7118. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7119. const fn = dir.def && dir.def[hook];
  7120. if (fn) {
  7121. try {
  7122. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7123. }
  7124. catch (e) {
  7125. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7126. }
  7127. }
  7128. }
  7129. var baseModules = [ref, directives$1];
  7130. function updateAttrs(oldVnode, vnode) {
  7131. const opts = vnode.componentOptions;
  7132. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7133. return;
  7134. }
  7135. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7136. return;
  7137. }
  7138. let key, cur, old;
  7139. const elm = vnode.elm;
  7140. const oldAttrs = oldVnode.data.attrs || {};
  7141. let attrs = vnode.data.attrs || {};
  7142. // clone observed objects, as the user probably wants to mutate it
  7143. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7144. attrs = vnode.data.attrs = extend({}, attrs);
  7145. }
  7146. for (key in attrs) {
  7147. cur = attrs[key];
  7148. old = oldAttrs[key];
  7149. if (old !== cur) {
  7150. setAttr(elm, key, cur, vnode.data.pre);
  7151. }
  7152. }
  7153. // #4391: in IE9, setting type can reset value for input[type=radio]
  7154. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7155. /* istanbul ignore if */
  7156. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7157. setAttr(elm, 'value', attrs.value);
  7158. }
  7159. for (key in oldAttrs) {
  7160. if (isUndef(attrs[key])) {
  7161. if (isXlink(key)) {
  7162. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7163. }
  7164. else if (!isEnumeratedAttr(key)) {
  7165. elm.removeAttribute(key);
  7166. }
  7167. }
  7168. }
  7169. }
  7170. function setAttr(el, key, value, isInPre) {
  7171. if (isInPre || el.tagName.indexOf('-') > -1) {
  7172. baseSetAttr(el, key, value);
  7173. }
  7174. else if (isBooleanAttr(key)) {
  7175. // set attribute for blank value
  7176. // e.g. <option disabled>Select one</option>
  7177. if (isFalsyAttrValue(value)) {
  7178. el.removeAttribute(key);
  7179. }
  7180. else {
  7181. // technically allowfullscreen is a boolean attribute for <iframe>,
  7182. // but Flash expects a value of "true" when used on <embed> tag
  7183. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7184. el.setAttribute(key, value);
  7185. }
  7186. }
  7187. else if (isEnumeratedAttr(key)) {
  7188. el.setAttribute(key, convertEnumeratedValue(key, value));
  7189. }
  7190. else if (isXlink(key)) {
  7191. if (isFalsyAttrValue(value)) {
  7192. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7193. }
  7194. else {
  7195. el.setAttributeNS(xlinkNS, key, value);
  7196. }
  7197. }
  7198. else {
  7199. baseSetAttr(el, key, value);
  7200. }
  7201. }
  7202. function baseSetAttr(el, key, value) {
  7203. if (isFalsyAttrValue(value)) {
  7204. el.removeAttribute(key);
  7205. }
  7206. else {
  7207. // #7138: IE10 & 11 fires input event when setting placeholder on
  7208. // <textarea>... block the first input event and remove the blocker
  7209. // immediately.
  7210. /* istanbul ignore if */
  7211. if (isIE &&
  7212. !isIE9 &&
  7213. el.tagName === 'TEXTAREA' &&
  7214. key === 'placeholder' &&
  7215. value !== '' &&
  7216. !el.__ieph) {
  7217. const blocker = e => {
  7218. e.stopImmediatePropagation();
  7219. el.removeEventListener('input', blocker);
  7220. };
  7221. el.addEventListener('input', blocker);
  7222. // $flow-disable-line
  7223. el.__ieph = true; /* IE placeholder patched */
  7224. }
  7225. el.setAttribute(key, value);
  7226. }
  7227. }
  7228. var attrs = {
  7229. create: updateAttrs,
  7230. update: updateAttrs
  7231. };
  7232. function updateClass(oldVnode, vnode) {
  7233. const el = vnode.elm;
  7234. const data = vnode.data;
  7235. const oldData = oldVnode.data;
  7236. if (isUndef(data.staticClass) &&
  7237. isUndef(data.class) &&
  7238. (isUndef(oldData) ||
  7239. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7240. return;
  7241. }
  7242. let cls = genClassForVnode(vnode);
  7243. // handle transition classes
  7244. const transitionClass = el._transitionClasses;
  7245. if (isDef(transitionClass)) {
  7246. cls = concat(cls, stringifyClass(transitionClass));
  7247. }
  7248. // set the class
  7249. if (cls !== el._prevClass) {
  7250. el.setAttribute('class', cls);
  7251. el._prevClass = cls;
  7252. }
  7253. }
  7254. var klass$1 = {
  7255. create: updateClass,
  7256. update: updateClass
  7257. };
  7258. const validDivisionCharRE = /[\w).+\-_$\]]/;
  7259. function parseFilters(exp) {
  7260. let inSingle = false;
  7261. let inDouble = false;
  7262. let inTemplateString = false;
  7263. let inRegex = false;
  7264. let curly = 0;
  7265. let square = 0;
  7266. let paren = 0;
  7267. let lastFilterIndex = 0;
  7268. let c, prev, i, expression, filters;
  7269. for (i = 0; i < exp.length; i++) {
  7270. prev = c;
  7271. c = exp.charCodeAt(i);
  7272. if (inSingle) {
  7273. if (c === 0x27 && prev !== 0x5c)
  7274. inSingle = false;
  7275. }
  7276. else if (inDouble) {
  7277. if (c === 0x22 && prev !== 0x5c)
  7278. inDouble = false;
  7279. }
  7280. else if (inTemplateString) {
  7281. if (c === 0x60 && prev !== 0x5c)
  7282. inTemplateString = false;
  7283. }
  7284. else if (inRegex) {
  7285. if (c === 0x2f && prev !== 0x5c)
  7286. inRegex = false;
  7287. }
  7288. else if (c === 0x7c && // pipe
  7289. exp.charCodeAt(i + 1) !== 0x7c &&
  7290. exp.charCodeAt(i - 1) !== 0x7c &&
  7291. !curly &&
  7292. !square &&
  7293. !paren) {
  7294. if (expression === undefined) {
  7295. // first filter, end of expression
  7296. lastFilterIndex = i + 1;
  7297. expression = exp.slice(0, i).trim();
  7298. }
  7299. else {
  7300. pushFilter();
  7301. }
  7302. }
  7303. else {
  7304. switch (c) {
  7305. case 0x22:
  7306. inDouble = true;
  7307. break; // "
  7308. case 0x27:
  7309. inSingle = true;
  7310. break; // '
  7311. case 0x60:
  7312. inTemplateString = true;
  7313. break; // `
  7314. case 0x28:
  7315. paren++;
  7316. break; // (
  7317. case 0x29:
  7318. paren--;
  7319. break; // )
  7320. case 0x5b:
  7321. square++;
  7322. break; // [
  7323. case 0x5d:
  7324. square--;
  7325. break; // ]
  7326. case 0x7b:
  7327. curly++;
  7328. break; // {
  7329. case 0x7d:
  7330. curly--;
  7331. break; // }
  7332. }
  7333. if (c === 0x2f) {
  7334. // /
  7335. let j = i - 1;
  7336. let p;
  7337. // find first non-whitespace prev char
  7338. for (; j >= 0; j--) {
  7339. p = exp.charAt(j);
  7340. if (p !== ' ')
  7341. break;
  7342. }
  7343. if (!p || !validDivisionCharRE.test(p)) {
  7344. inRegex = true;
  7345. }
  7346. }
  7347. }
  7348. }
  7349. if (expression === undefined) {
  7350. expression = exp.slice(0, i).trim();
  7351. }
  7352. else if (lastFilterIndex !== 0) {
  7353. pushFilter();
  7354. }
  7355. function pushFilter() {
  7356. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  7357. lastFilterIndex = i + 1;
  7358. }
  7359. if (filters) {
  7360. for (i = 0; i < filters.length; i++) {
  7361. expression = wrapFilter(expression, filters[i]);
  7362. }
  7363. }
  7364. return expression;
  7365. }
  7366. function wrapFilter(exp, filter) {
  7367. const i = filter.indexOf('(');
  7368. if (i < 0) {
  7369. // _f: resolveFilter
  7370. return `_f("${filter}")(${exp})`;
  7371. }
  7372. else {
  7373. const name = filter.slice(0, i);
  7374. const args = filter.slice(i + 1);
  7375. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  7376. }
  7377. }
  7378. /* eslint-disable no-unused-vars */
  7379. function baseWarn(msg, range) {
  7380. console.error(`[Vue compiler]: ${msg}`);
  7381. }
  7382. /* eslint-enable no-unused-vars */
  7383. function pluckModuleFunction(modules, key) {
  7384. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  7385. }
  7386. function addProp(el, name, value, range, dynamic) {
  7387. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  7388. el.plain = false;
  7389. }
  7390. function addAttr(el, name, value, range, dynamic) {
  7391. const attrs = dynamic
  7392. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  7393. : el.attrs || (el.attrs = []);
  7394. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  7395. el.plain = false;
  7396. }
  7397. // add a raw attr (use this in preTransforms)
  7398. function addRawAttr(el, name, value, range) {
  7399. el.attrsMap[name] = value;
  7400. el.attrsList.push(rangeSetItem({ name, value }, range));
  7401. }
  7402. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  7403. (el.directives || (el.directives = [])).push(rangeSetItem({
  7404. name,
  7405. rawName,
  7406. value,
  7407. arg,
  7408. isDynamicArg,
  7409. modifiers
  7410. }, range));
  7411. el.plain = false;
  7412. }
  7413. function prependModifierMarker(symbol, name, dynamic) {
  7414. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  7415. }
  7416. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  7417. modifiers = modifiers || emptyObject;
  7418. // warn prevent and passive modifier
  7419. /* istanbul ignore if */
  7420. if (warn && modifiers.prevent && modifiers.passive) {
  7421. warn("passive and prevent can't be used together. " +
  7422. "Passive handler can't prevent default event.", range);
  7423. }
  7424. // normalize click.right and click.middle since they don't actually fire
  7425. // this is technically browser-specific, but at least for now browsers are
  7426. // the only target envs that have right/middle clicks.
  7427. if (modifiers.right) {
  7428. if (dynamic) {
  7429. name = `(${name})==='click'?'contextmenu':(${name})`;
  7430. }
  7431. else if (name === 'click') {
  7432. name = 'contextmenu';
  7433. delete modifiers.right;
  7434. }
  7435. }
  7436. else if (modifiers.middle) {
  7437. if (dynamic) {
  7438. name = `(${name})==='click'?'mouseup':(${name})`;
  7439. }
  7440. else if (name === 'click') {
  7441. name = 'mouseup';
  7442. }
  7443. }
  7444. // check capture modifier
  7445. if (modifiers.capture) {
  7446. delete modifiers.capture;
  7447. name = prependModifierMarker('!', name, dynamic);
  7448. }
  7449. if (modifiers.once) {
  7450. delete modifiers.once;
  7451. name = prependModifierMarker('~', name, dynamic);
  7452. }
  7453. /* istanbul ignore if */
  7454. if (modifiers.passive) {
  7455. delete modifiers.passive;
  7456. name = prependModifierMarker('&', name, dynamic);
  7457. }
  7458. let events;
  7459. if (modifiers.native) {
  7460. delete modifiers.native;
  7461. events = el.nativeEvents || (el.nativeEvents = {});
  7462. }
  7463. else {
  7464. events = el.events || (el.events = {});
  7465. }
  7466. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  7467. if (modifiers !== emptyObject) {
  7468. newHandler.modifiers = modifiers;
  7469. }
  7470. const handlers = events[name];
  7471. /* istanbul ignore if */
  7472. if (Array.isArray(handlers)) {
  7473. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  7474. }
  7475. else if (handlers) {
  7476. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  7477. }
  7478. else {
  7479. events[name] = newHandler;
  7480. }
  7481. el.plain = false;
  7482. }
  7483. function getRawBindingAttr(el, name) {
  7484. return (el.rawAttrsMap[':' + name] ||
  7485. el.rawAttrsMap['v-bind:' + name] ||
  7486. el.rawAttrsMap[name]);
  7487. }
  7488. function getBindingAttr(el, name, getStatic) {
  7489. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  7490. if (dynamicValue != null) {
  7491. return parseFilters(dynamicValue);
  7492. }
  7493. else if (getStatic !== false) {
  7494. const staticValue = getAndRemoveAttr(el, name);
  7495. if (staticValue != null) {
  7496. return JSON.stringify(staticValue);
  7497. }
  7498. }
  7499. }
  7500. // note: this only removes the attr from the Array (attrsList) so that it
  7501. // doesn't get processed by processAttrs.
  7502. // By default it does NOT remove it from the map (attrsMap) because the map is
  7503. // needed during codegen.
  7504. function getAndRemoveAttr(el, name, removeFromMap) {
  7505. let val;
  7506. if ((val = el.attrsMap[name]) != null) {
  7507. const list = el.attrsList;
  7508. for (let i = 0, l = list.length; i < l; i++) {
  7509. if (list[i].name === name) {
  7510. list.splice(i, 1);
  7511. break;
  7512. }
  7513. }
  7514. }
  7515. if (removeFromMap) {
  7516. delete el.attrsMap[name];
  7517. }
  7518. return val;
  7519. }
  7520. function getAndRemoveAttrByRegex(el, name) {
  7521. const list = el.attrsList;
  7522. for (let i = 0, l = list.length; i < l; i++) {
  7523. const attr = list[i];
  7524. if (name.test(attr.name)) {
  7525. list.splice(i, 1);
  7526. return attr;
  7527. }
  7528. }
  7529. }
  7530. function rangeSetItem(item, range) {
  7531. if (range) {
  7532. if (range.start != null) {
  7533. item.start = range.start;
  7534. }
  7535. if (range.end != null) {
  7536. item.end = range.end;
  7537. }
  7538. }
  7539. return item;
  7540. }
  7541. /**
  7542. * Cross-platform code generation for component v-model
  7543. */
  7544. function genComponentModel(el, value, modifiers) {
  7545. const { number, trim } = modifiers || {};
  7546. const baseValueExpression = '$$v';
  7547. let valueExpression = baseValueExpression;
  7548. if (trim) {
  7549. valueExpression =
  7550. `(typeof ${baseValueExpression} === 'string'` +
  7551. `? ${baseValueExpression}.trim()` +
  7552. `: ${baseValueExpression})`;
  7553. }
  7554. if (number) {
  7555. valueExpression = `_n(${valueExpression})`;
  7556. }
  7557. const assignment = genAssignmentCode(value, valueExpression);
  7558. el.model = {
  7559. value: `(${value})`,
  7560. expression: JSON.stringify(value),
  7561. callback: `function (${baseValueExpression}) {${assignment}}`
  7562. };
  7563. }
  7564. /**
  7565. * Cross-platform codegen helper for generating v-model value assignment code.
  7566. */
  7567. function genAssignmentCode(value, assignment) {
  7568. const res = parseModel(value);
  7569. if (res.key === null) {
  7570. return `${value}=${assignment}`;
  7571. }
  7572. else {
  7573. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  7574. }
  7575. }
  7576. /**
  7577. * Parse a v-model expression into a base path and a final key segment.
  7578. * Handles both dot-path and possible square brackets.
  7579. *
  7580. * Possible cases:
  7581. *
  7582. * - test
  7583. * - test[key]
  7584. * - test[test1[key]]
  7585. * - test["a"][key]
  7586. * - xxx.test[a[a].test1[key]]
  7587. * - test.xxx.a["asa"][test1[key]]
  7588. *
  7589. */
  7590. let len, str, chr, index, expressionPos, expressionEndPos;
  7591. function parseModel(val) {
  7592. // Fix https://github.com/vuejs/vue/pull/7730
  7593. // allow v-model="obj.val " (trailing whitespace)
  7594. val = val.trim();
  7595. len = val.length;
  7596. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  7597. index = val.lastIndexOf('.');
  7598. if (index > -1) {
  7599. return {
  7600. exp: val.slice(0, index),
  7601. key: '"' + val.slice(index + 1) + '"'
  7602. };
  7603. }
  7604. else {
  7605. return {
  7606. exp: val,
  7607. key: null
  7608. };
  7609. }
  7610. }
  7611. str = val;
  7612. index = expressionPos = expressionEndPos = 0;
  7613. while (!eof()) {
  7614. chr = next();
  7615. /* istanbul ignore if */
  7616. if (isStringStart(chr)) {
  7617. parseString(chr);
  7618. }
  7619. else if (chr === 0x5b) {
  7620. parseBracket(chr);
  7621. }
  7622. }
  7623. return {
  7624. exp: val.slice(0, expressionPos),
  7625. key: val.slice(expressionPos + 1, expressionEndPos)
  7626. };
  7627. }
  7628. function next() {
  7629. return str.charCodeAt(++index);
  7630. }
  7631. function eof() {
  7632. return index >= len;
  7633. }
  7634. function isStringStart(chr) {
  7635. return chr === 0x22 || chr === 0x27;
  7636. }
  7637. function parseBracket(chr) {
  7638. let inBracket = 1;
  7639. expressionPos = index;
  7640. while (!eof()) {
  7641. chr = next();
  7642. if (isStringStart(chr)) {
  7643. parseString(chr);
  7644. continue;
  7645. }
  7646. if (chr === 0x5b)
  7647. inBracket++;
  7648. if (chr === 0x5d)
  7649. inBracket--;
  7650. if (inBracket === 0) {
  7651. expressionEndPos = index;
  7652. break;
  7653. }
  7654. }
  7655. }
  7656. function parseString(chr) {
  7657. const stringQuote = chr;
  7658. while (!eof()) {
  7659. chr = next();
  7660. if (chr === stringQuote) {
  7661. break;
  7662. }
  7663. }
  7664. }
  7665. let warn$1;
  7666. // in some cases, the event used has to be determined at runtime
  7667. // so we used some reserved tokens during compile.
  7668. const RANGE_TOKEN = '__r';
  7669. const CHECKBOX_RADIO_TOKEN = '__c';
  7670. function model$1(el, dir, _warn) {
  7671. warn$1 = _warn;
  7672. const value = dir.value;
  7673. const modifiers = dir.modifiers;
  7674. const tag = el.tag;
  7675. const type = el.attrsMap.type;
  7676. {
  7677. // inputs with type="file" are read only and setting the input's
  7678. // value will throw an error.
  7679. if (tag === 'input' && type === 'file') {
  7680. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7681. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7682. }
  7683. }
  7684. if (el.component) {
  7685. genComponentModel(el, value, modifiers);
  7686. // component v-model doesn't need extra runtime
  7687. return false;
  7688. }
  7689. else if (tag === 'select') {
  7690. genSelect(el, value, modifiers);
  7691. }
  7692. else if (tag === 'input' && type === 'checkbox') {
  7693. genCheckboxModel(el, value, modifiers);
  7694. }
  7695. else if (tag === 'input' && type === 'radio') {
  7696. genRadioModel(el, value, modifiers);
  7697. }
  7698. else if (tag === 'input' || tag === 'textarea') {
  7699. genDefaultModel(el, value, modifiers);
  7700. }
  7701. else if (!config.isReservedTag(tag)) {
  7702. genComponentModel(el, value, modifiers);
  7703. // component v-model doesn't need extra runtime
  7704. return false;
  7705. }
  7706. else {
  7707. warn$1(`<${el.tag} v-model="${value}">: ` +
  7708. `v-model is not supported on this element type. ` +
  7709. "If you are working with contenteditable, it's recommended to " +
  7710. 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']);
  7711. }
  7712. // ensure runtime directive metadata
  7713. return true;
  7714. }
  7715. function genCheckboxModel(el, value, modifiers) {
  7716. const number = modifiers && modifiers.number;
  7717. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7718. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7719. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7720. addProp(el, 'checked', `Array.isArray(${value})` +
  7721. `?_i(${value},${valueBinding})>-1` +
  7722. (trueValueBinding === 'true'
  7723. ? `:(${value})`
  7724. : `:_q(${value},${trueValueBinding})`));
  7725. addHandler(el, 'change', `var $$a=${value},` +
  7726. '$$el=$event.target,' +
  7727. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7728. 'if(Array.isArray($$a)){' +
  7729. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7730. '$$i=_i($$a,$$v);' +
  7731. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7732. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7733. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7734. }
  7735. function genRadioModel(el, value, modifiers) {
  7736. const number = modifiers && modifiers.number;
  7737. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7738. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7739. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7740. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7741. }
  7742. function genSelect(el, value, modifiers) {
  7743. const number = modifiers && modifiers.number;
  7744. const selectedVal = `Array.prototype.filter` +
  7745. `.call($event.target.options,function(o){return o.selected})` +
  7746. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7747. `return ${number ? '_n(val)' : 'val'}})`;
  7748. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7749. let code = `var $$selectedVal = ${selectedVal};`;
  7750. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7751. addHandler(el, 'change', code, null, true);
  7752. }
  7753. function genDefaultModel(el, value, modifiers) {
  7754. const type = el.attrsMap.type;
  7755. // warn if v-bind:value conflicts with v-model
  7756. // except for inputs with v-bind:type
  7757. {
  7758. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7759. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7760. if (value && !typeBinding) {
  7761. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7762. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7763. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7764. }
  7765. }
  7766. const { lazy, number, trim } = modifiers || {};
  7767. const needCompositionGuard = !lazy && type !== 'range';
  7768. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7769. let valueExpression = '$event.target.value';
  7770. if (trim) {
  7771. valueExpression = `$event.target.value.trim()`;
  7772. }
  7773. if (number) {
  7774. valueExpression = `_n(${valueExpression})`;
  7775. }
  7776. let code = genAssignmentCode(value, valueExpression);
  7777. if (needCompositionGuard) {
  7778. code = `if($event.target.composing)return;${code}`;
  7779. }
  7780. addProp(el, 'value', `(${value})`);
  7781. addHandler(el, event, code, null, true);
  7782. if (trim || number) {
  7783. addHandler(el, 'blur', '$forceUpdate()');
  7784. }
  7785. }
  7786. // normalize v-model event tokens that can only be determined at runtime.
  7787. // it's important to place the event as the first in the array because
  7788. // the whole point is ensuring the v-model callback gets called before
  7789. // user-attached handlers.
  7790. function normalizeEvents(on) {
  7791. /* istanbul ignore if */
  7792. if (isDef(on[RANGE_TOKEN])) {
  7793. // IE input[type=range] only supports `change` event
  7794. const event = isIE ? 'change' : 'input';
  7795. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7796. delete on[RANGE_TOKEN];
  7797. }
  7798. // This was originally intended to fix #4521 but no longer necessary
  7799. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7800. /* istanbul ignore if */
  7801. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7802. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7803. delete on[CHECKBOX_RADIO_TOKEN];
  7804. }
  7805. }
  7806. let target;
  7807. function createOnceHandler(event, handler, capture) {
  7808. const _target = target; // save current target element in closure
  7809. return function onceHandler() {
  7810. const res = handler.apply(null, arguments);
  7811. if (res !== null) {
  7812. remove(event, onceHandler, capture, _target);
  7813. }
  7814. };
  7815. }
  7816. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7817. // implementation and does not fire microtasks in between event propagation, so
  7818. // safe to exclude.
  7819. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7820. function add(name, handler, capture, passive) {
  7821. // async edge case #6566: inner click event triggers patch, event handler
  7822. // attached to outer element during patch, and triggered again. This
  7823. // happens because browsers fire microtask ticks between event propagation.
  7824. // the solution is simple: we save the timestamp when a handler is attached,
  7825. // and the handler would only fire if the event passed to it was fired
  7826. // AFTER it was attached.
  7827. if (useMicrotaskFix) {
  7828. const attachedTimestamp = currentFlushTimestamp;
  7829. const original = handler;
  7830. //@ts-expect-error
  7831. handler = original._wrapper = function (e) {
  7832. if (
  7833. // no bubbling, should always fire.
  7834. // this is just a safety net in case event.timeStamp is unreliable in
  7835. // certain weird environments...
  7836. e.target === e.currentTarget ||
  7837. // event is fired after handler attachment
  7838. e.timeStamp >= attachedTimestamp ||
  7839. // bail for environments that have buggy event.timeStamp implementations
  7840. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7841. // #9681 QtWebEngine event.timeStamp is negative value
  7842. e.timeStamp <= 0 ||
  7843. // #9448 bail if event is fired in another document in a multi-page
  7844. // electron/nw.js app, since event.timeStamp will be using a different
  7845. // starting reference
  7846. e.target.ownerDocument !== document) {
  7847. return original.apply(this, arguments);
  7848. }
  7849. };
  7850. }
  7851. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7852. }
  7853. function remove(name, handler, capture, _target) {
  7854. (_target || target).removeEventListener(name,
  7855. //@ts-expect-error
  7856. handler._wrapper || handler, capture);
  7857. }
  7858. function updateDOMListeners(oldVnode, vnode) {
  7859. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7860. return;
  7861. }
  7862. const on = vnode.data.on || {};
  7863. const oldOn = oldVnode.data.on || {};
  7864. // vnode is empty when removing all listeners,
  7865. // and use old vnode dom element
  7866. target = vnode.elm || oldVnode.elm;
  7867. normalizeEvents(on);
  7868. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7869. target = undefined;
  7870. }
  7871. var events = {
  7872. create: updateDOMListeners,
  7873. update: updateDOMListeners,
  7874. // @ts-expect-error emptyNode has actually data
  7875. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7876. };
  7877. let svgContainer;
  7878. function updateDOMProps(oldVnode, vnode) {
  7879. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7880. return;
  7881. }
  7882. let key, cur;
  7883. const elm = vnode.elm;
  7884. const oldProps = oldVnode.data.domProps || {};
  7885. let props = vnode.data.domProps || {};
  7886. // clone observed objects, as the user probably wants to mutate it
  7887. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7888. props = vnode.data.domProps = extend({}, props);
  7889. }
  7890. for (key in oldProps) {
  7891. if (!(key in props)) {
  7892. elm[key] = '';
  7893. }
  7894. }
  7895. for (key in props) {
  7896. cur = props[key];
  7897. // ignore children if the node has textContent or innerHTML,
  7898. // as these will throw away existing DOM nodes and cause removal errors
  7899. // on subsequent patches (#3360)
  7900. if (key === 'textContent' || key === 'innerHTML') {
  7901. if (vnode.children)
  7902. vnode.children.length = 0;
  7903. if (cur === oldProps[key])
  7904. continue;
  7905. // #6601 work around Chrome version <= 55 bug where single textNode
  7906. // replaced by innerHTML/textContent retains its parentNode property
  7907. if (elm.childNodes.length === 1) {
  7908. elm.removeChild(elm.childNodes[0]);
  7909. }
  7910. }
  7911. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7912. // store value as _value as well since
  7913. // non-string values will be stringified
  7914. elm._value = cur;
  7915. // avoid resetting cursor position when value is the same
  7916. const strCur = isUndef(cur) ? '' : String(cur);
  7917. if (shouldUpdateValue(elm, strCur)) {
  7918. elm.value = strCur;
  7919. }
  7920. }
  7921. else if (key === 'innerHTML' &&
  7922. isSVG(elm.tagName) &&
  7923. isUndef(elm.innerHTML)) {
  7924. // IE doesn't support innerHTML for SVG elements
  7925. svgContainer = svgContainer || document.createElement('div');
  7926. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7927. const svg = svgContainer.firstChild;
  7928. while (elm.firstChild) {
  7929. elm.removeChild(elm.firstChild);
  7930. }
  7931. while (svg.firstChild) {
  7932. elm.appendChild(svg.firstChild);
  7933. }
  7934. }
  7935. else if (
  7936. // skip the update if old and new VDOM state is the same.
  7937. // `value` is handled separately because the DOM value may be temporarily
  7938. // out of sync with VDOM state due to focus, composition and modifiers.
  7939. // This #4521 by skipping the unnecessary `checked` update.
  7940. cur !== oldProps[key]) {
  7941. // some property updates can throw
  7942. // e.g. `value` on <progress> w/ non-finite value
  7943. try {
  7944. elm[key] = cur;
  7945. }
  7946. catch (e) { }
  7947. }
  7948. }
  7949. }
  7950. function shouldUpdateValue(elm, checkVal) {
  7951. return (
  7952. //@ts-expect-error
  7953. !elm.composing &&
  7954. (elm.tagName === 'OPTION' ||
  7955. isNotInFocusAndDirty(elm, checkVal) ||
  7956. isDirtyWithModifiers(elm, checkVal)));
  7957. }
  7958. function isNotInFocusAndDirty(elm, checkVal) {
  7959. // return true when textbox (.number and .trim) loses focus and its value is
  7960. // not equal to the updated value
  7961. let notInFocus = true;
  7962. // #6157
  7963. // work around IE bug when accessing document.activeElement in an iframe
  7964. try {
  7965. notInFocus = document.activeElement !== elm;
  7966. }
  7967. catch (e) { }
  7968. return notInFocus && elm.value !== checkVal;
  7969. }
  7970. function isDirtyWithModifiers(elm, newVal) {
  7971. const value = elm.value;
  7972. const modifiers = elm._vModifiers; // injected by v-model runtime
  7973. if (isDef(modifiers)) {
  7974. if (modifiers.number) {
  7975. return toNumber(value) !== toNumber(newVal);
  7976. }
  7977. if (modifiers.trim) {
  7978. return value.trim() !== newVal.trim();
  7979. }
  7980. }
  7981. return value !== newVal;
  7982. }
  7983. var domProps = {
  7984. create: updateDOMProps,
  7985. update: updateDOMProps
  7986. };
  7987. const parseStyleText = cached(function (cssText) {
  7988. const res = {};
  7989. const listDelimiter = /;(?![^(]*\))/g;
  7990. const propertyDelimiter = /:(.+)/;
  7991. cssText.split(listDelimiter).forEach(function (item) {
  7992. if (item) {
  7993. const tmp = item.split(propertyDelimiter);
  7994. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7995. }
  7996. });
  7997. return res;
  7998. });
  7999. // merge static and dynamic style data on the same vnode
  8000. function normalizeStyleData(data) {
  8001. const style = normalizeStyleBinding(data.style);
  8002. // static style is pre-processed into an object during compilation
  8003. // and is always a fresh object, so it's safe to merge into it
  8004. return data.staticStyle ? extend(data.staticStyle, style) : style;
  8005. }
  8006. // normalize possible array / string values into Object
  8007. function normalizeStyleBinding(bindingStyle) {
  8008. if (Array.isArray(bindingStyle)) {
  8009. return toObject(bindingStyle);
  8010. }
  8011. if (typeof bindingStyle === 'string') {
  8012. return parseStyleText(bindingStyle);
  8013. }
  8014. return bindingStyle;
  8015. }
  8016. /**
  8017. * parent component style should be after child's
  8018. * so that parent component's style could override it
  8019. */
  8020. function getStyle(vnode, checkChild) {
  8021. const res = {};
  8022. let styleData;
  8023. if (checkChild) {
  8024. let childNode = vnode;
  8025. while (childNode.componentInstance) {
  8026. childNode = childNode.componentInstance._vnode;
  8027. if (childNode &&
  8028. childNode.data &&
  8029. (styleData = normalizeStyleData(childNode.data))) {
  8030. extend(res, styleData);
  8031. }
  8032. }
  8033. }
  8034. if ((styleData = normalizeStyleData(vnode.data))) {
  8035. extend(res, styleData);
  8036. }
  8037. let parentNode = vnode;
  8038. // @ts-expect-error parentNode.parent not VNodeWithData
  8039. while ((parentNode = parentNode.parent)) {
  8040. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  8041. extend(res, styleData);
  8042. }
  8043. }
  8044. return res;
  8045. }
  8046. const cssVarRE = /^--/;
  8047. const importantRE = /\s*!important$/;
  8048. const setProp = (el, name, val) => {
  8049. /* istanbul ignore if */
  8050. if (cssVarRE.test(name)) {
  8051. el.style.setProperty(name, val);
  8052. }
  8053. else if (importantRE.test(val)) {
  8054. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  8055. }
  8056. else {
  8057. const normalizedName = normalize(name);
  8058. if (Array.isArray(val)) {
  8059. // Support values array created by autoprefixer, e.g.
  8060. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  8061. // Set them one by one, and the browser will only set those it can recognize
  8062. for (let i = 0, len = val.length; i < len; i++) {
  8063. el.style[normalizedName] = val[i];
  8064. }
  8065. }
  8066. else {
  8067. el.style[normalizedName] = val;
  8068. }
  8069. }
  8070. };
  8071. const vendorNames = ['Webkit', 'Moz', 'ms'];
  8072. let emptyStyle;
  8073. const normalize = cached(function (prop) {
  8074. emptyStyle = emptyStyle || document.createElement('div').style;
  8075. prop = camelize(prop);
  8076. if (prop !== 'filter' && prop in emptyStyle) {
  8077. return prop;
  8078. }
  8079. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  8080. for (let i = 0; i < vendorNames.length; i++) {
  8081. const name = vendorNames[i] + capName;
  8082. if (name in emptyStyle) {
  8083. return name;
  8084. }
  8085. }
  8086. });
  8087. function updateStyle(oldVnode, vnode) {
  8088. const data = vnode.data;
  8089. const oldData = oldVnode.data;
  8090. if (isUndef(data.staticStyle) &&
  8091. isUndef(data.style) &&
  8092. isUndef(oldData.staticStyle) &&
  8093. isUndef(oldData.style)) {
  8094. return;
  8095. }
  8096. let cur, name;
  8097. const el = vnode.elm;
  8098. const oldStaticStyle = oldData.staticStyle;
  8099. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  8100. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  8101. const oldStyle = oldStaticStyle || oldStyleBinding;
  8102. const style = normalizeStyleBinding(vnode.data.style) || {};
  8103. // store normalized style under a different key for next diff
  8104. // make sure to clone it if it's reactive, since the user likely wants
  8105. // to mutate it.
  8106. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  8107. const newStyle = getStyle(vnode, true);
  8108. for (name in oldStyle) {
  8109. if (isUndef(newStyle[name])) {
  8110. setProp(el, name, '');
  8111. }
  8112. }
  8113. for (name in newStyle) {
  8114. cur = newStyle[name];
  8115. if (cur !== oldStyle[name]) {
  8116. // ie9 setting to null has no effect, must use empty string
  8117. setProp(el, name, cur == null ? '' : cur);
  8118. }
  8119. }
  8120. }
  8121. var style$1 = {
  8122. create: updateStyle,
  8123. update: updateStyle
  8124. };
  8125. const whitespaceRE$1 = /\s+/;
  8126. /**
  8127. * Add class with compatibility for SVG since classList is not supported on
  8128. * SVG elements in IE
  8129. */
  8130. function addClass(el, cls) {
  8131. /* istanbul ignore if */
  8132. if (!cls || !(cls = cls.trim())) {
  8133. return;
  8134. }
  8135. /* istanbul ignore else */
  8136. if (el.classList) {
  8137. if (cls.indexOf(' ') > -1) {
  8138. cls.split(whitespaceRE$1).forEach(c => el.classList.add(c));
  8139. }
  8140. else {
  8141. el.classList.add(cls);
  8142. }
  8143. }
  8144. else {
  8145. const cur = ` ${el.getAttribute('class') || ''} `;
  8146. if (cur.indexOf(' ' + cls + ' ') < 0) {
  8147. el.setAttribute('class', (cur + cls).trim());
  8148. }
  8149. }
  8150. }
  8151. /**
  8152. * Remove class with compatibility for SVG since classList is not supported on
  8153. * SVG elements in IE
  8154. */
  8155. function removeClass(el, cls) {
  8156. /* istanbul ignore if */
  8157. if (!cls || !(cls = cls.trim())) {
  8158. return;
  8159. }
  8160. /* istanbul ignore else */
  8161. if (el.classList) {
  8162. if (cls.indexOf(' ') > -1) {
  8163. cls.split(whitespaceRE$1).forEach(c => el.classList.remove(c));
  8164. }
  8165. else {
  8166. el.classList.remove(cls);
  8167. }
  8168. if (!el.classList.length) {
  8169. el.removeAttribute('class');
  8170. }
  8171. }
  8172. else {
  8173. let cur = ` ${el.getAttribute('class') || ''} `;
  8174. const tar = ' ' + cls + ' ';
  8175. while (cur.indexOf(tar) >= 0) {
  8176. cur = cur.replace(tar, ' ');
  8177. }
  8178. cur = cur.trim();
  8179. if (cur) {
  8180. el.setAttribute('class', cur);
  8181. }
  8182. else {
  8183. el.removeAttribute('class');
  8184. }
  8185. }
  8186. }
  8187. function resolveTransition(def) {
  8188. if (!def) {
  8189. return;
  8190. }
  8191. /* istanbul ignore else */
  8192. if (typeof def === 'object') {
  8193. const res = {};
  8194. if (def.css !== false) {
  8195. extend(res, autoCssTransition(def.name || 'v'));
  8196. }
  8197. extend(res, def);
  8198. return res;
  8199. }
  8200. else if (typeof def === 'string') {
  8201. return autoCssTransition(def);
  8202. }
  8203. }
  8204. const autoCssTransition = cached(name => {
  8205. return {
  8206. enterClass: `${name}-enter`,
  8207. enterToClass: `${name}-enter-to`,
  8208. enterActiveClass: `${name}-enter-active`,
  8209. leaveClass: `${name}-leave`,
  8210. leaveToClass: `${name}-leave-to`,
  8211. leaveActiveClass: `${name}-leave-active`
  8212. };
  8213. });
  8214. const hasTransition = inBrowser && !isIE9;
  8215. const TRANSITION = 'transition';
  8216. const ANIMATION = 'animation';
  8217. // Transition property/event sniffing
  8218. let transitionProp = 'transition';
  8219. let transitionEndEvent = 'transitionend';
  8220. let animationProp = 'animation';
  8221. let animationEndEvent = 'animationend';
  8222. if (hasTransition) {
  8223. /* istanbul ignore if */
  8224. if (window.ontransitionend === undefined &&
  8225. window.onwebkittransitionend !== undefined) {
  8226. transitionProp = 'WebkitTransition';
  8227. transitionEndEvent = 'webkitTransitionEnd';
  8228. }
  8229. if (window.onanimationend === undefined &&
  8230. window.onwebkitanimationend !== undefined) {
  8231. animationProp = 'WebkitAnimation';
  8232. animationEndEvent = 'webkitAnimationEnd';
  8233. }
  8234. }
  8235. // binding to window is necessary to make hot reload work in IE in strict mode
  8236. const raf = inBrowser
  8237. ? window.requestAnimationFrame
  8238. ? window.requestAnimationFrame.bind(window)
  8239. : setTimeout
  8240. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  8241. function nextFrame(fn) {
  8242. raf(() => {
  8243. // @ts-expect-error
  8244. raf(fn);
  8245. });
  8246. }
  8247. function addTransitionClass(el, cls) {
  8248. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  8249. if (transitionClasses.indexOf(cls) < 0) {
  8250. transitionClasses.push(cls);
  8251. addClass(el, cls);
  8252. }
  8253. }
  8254. function removeTransitionClass(el, cls) {
  8255. if (el._transitionClasses) {
  8256. remove$2(el._transitionClasses, cls);
  8257. }
  8258. removeClass(el, cls);
  8259. }
  8260. function whenTransitionEnds(el, expectedType, cb) {
  8261. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8262. if (!type)
  8263. return cb();
  8264. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  8265. let ended = 0;
  8266. const end = () => {
  8267. el.removeEventListener(event, onEnd);
  8268. cb();
  8269. };
  8270. const onEnd = e => {
  8271. if (e.target === el) {
  8272. if (++ended >= propCount) {
  8273. end();
  8274. }
  8275. }
  8276. };
  8277. setTimeout(() => {
  8278. if (ended < propCount) {
  8279. end();
  8280. }
  8281. }, timeout + 1);
  8282. el.addEventListener(event, onEnd);
  8283. }
  8284. const transformRE = /\b(transform|all)(,|$)/;
  8285. function getTransitionInfo(el, expectedType) {
  8286. const styles = window.getComputedStyle(el);
  8287. // JSDOM may return undefined for transition properties
  8288. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  8289. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  8290. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8291. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  8292. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  8293. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8294. let type;
  8295. let timeout = 0;
  8296. let propCount = 0;
  8297. /* istanbul ignore if */
  8298. if (expectedType === TRANSITION) {
  8299. if (transitionTimeout > 0) {
  8300. type = TRANSITION;
  8301. timeout = transitionTimeout;
  8302. propCount = transitionDurations.length;
  8303. }
  8304. }
  8305. else if (expectedType === ANIMATION) {
  8306. if (animationTimeout > 0) {
  8307. type = ANIMATION;
  8308. timeout = animationTimeout;
  8309. propCount = animationDurations.length;
  8310. }
  8311. }
  8312. else {
  8313. timeout = Math.max(transitionTimeout, animationTimeout);
  8314. type =
  8315. timeout > 0
  8316. ? transitionTimeout > animationTimeout
  8317. ? TRANSITION
  8318. : ANIMATION
  8319. : null;
  8320. propCount = type
  8321. ? type === TRANSITION
  8322. ? transitionDurations.length
  8323. : animationDurations.length
  8324. : 0;
  8325. }
  8326. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  8327. return {
  8328. type,
  8329. timeout,
  8330. propCount,
  8331. hasTransform
  8332. };
  8333. }
  8334. function getTimeout(delays, durations) {
  8335. /* istanbul ignore next */
  8336. while (delays.length < durations.length) {
  8337. delays = delays.concat(delays);
  8338. }
  8339. return Math.max.apply(null, durations.map((d, i) => {
  8340. return toMs(d) + toMs(delays[i]);
  8341. }));
  8342. }
  8343. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  8344. // in a locale-dependent way, using a comma instead of a dot.
  8345. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  8346. // as a floor function) causing unexpected behaviors
  8347. function toMs(s) {
  8348. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8349. }
  8350. function enter(vnode, toggleDisplay) {
  8351. const el = vnode.elm;
  8352. // call leave callback now
  8353. if (isDef(el._leaveCb)) {
  8354. el._leaveCb.cancelled = true;
  8355. el._leaveCb();
  8356. }
  8357. const data = resolveTransition(vnode.data.transition);
  8358. if (isUndef(data)) {
  8359. return;
  8360. }
  8361. /* istanbul ignore if */
  8362. if (isDef(el._enterCb) || el.nodeType !== 1) {
  8363. return;
  8364. }
  8365. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  8366. // activeInstance will always be the <transition> component managing this
  8367. // transition. One edge case to check is when the <transition> is placed
  8368. // as the root node of a child component. In that case we need to check
  8369. // <transition>'s parent for appear check.
  8370. let context = activeInstance;
  8371. let transitionNode = activeInstance.$vnode;
  8372. while (transitionNode && transitionNode.parent) {
  8373. context = transitionNode.context;
  8374. transitionNode = transitionNode.parent;
  8375. }
  8376. const isAppear = !context._isMounted || !vnode.isRootInsert;
  8377. if (isAppear && !appear && appear !== '') {
  8378. return;
  8379. }
  8380. const startClass = isAppear && appearClass ? appearClass : enterClass;
  8381. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  8382. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  8383. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  8384. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  8385. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  8386. const enterCancelledHook = isAppear
  8387. ? appearCancelled || enterCancelled
  8388. : enterCancelled;
  8389. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  8390. if (explicitEnterDuration != null) {
  8391. checkDuration(explicitEnterDuration, 'enter', vnode);
  8392. }
  8393. const expectsCSS = css !== false && !isIE9;
  8394. const userWantsControl = getHookArgumentsLength(enterHook);
  8395. const cb = (el._enterCb = once(() => {
  8396. if (expectsCSS) {
  8397. removeTransitionClass(el, toClass);
  8398. removeTransitionClass(el, activeClass);
  8399. }
  8400. // @ts-expect-error
  8401. if (cb.cancelled) {
  8402. if (expectsCSS) {
  8403. removeTransitionClass(el, startClass);
  8404. }
  8405. enterCancelledHook && enterCancelledHook(el);
  8406. }
  8407. else {
  8408. afterEnterHook && afterEnterHook(el);
  8409. }
  8410. el._enterCb = null;
  8411. }));
  8412. if (!vnode.data.show) {
  8413. // remove pending leave element on enter by injecting an insert hook
  8414. mergeVNodeHook(vnode, 'insert', () => {
  8415. const parent = el.parentNode;
  8416. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  8417. if (pendingNode &&
  8418. pendingNode.tag === vnode.tag &&
  8419. pendingNode.elm._leaveCb) {
  8420. pendingNode.elm._leaveCb();
  8421. }
  8422. enterHook && enterHook(el, cb);
  8423. });
  8424. }
  8425. // start enter transition
  8426. beforeEnterHook && beforeEnterHook(el);
  8427. if (expectsCSS) {
  8428. addTransitionClass(el, startClass);
  8429. addTransitionClass(el, activeClass);
  8430. nextFrame(() => {
  8431. removeTransitionClass(el, startClass);
  8432. // @ts-expect-error
  8433. if (!cb.cancelled) {
  8434. addTransitionClass(el, toClass);
  8435. if (!userWantsControl) {
  8436. if (isValidDuration(explicitEnterDuration)) {
  8437. setTimeout(cb, explicitEnterDuration);
  8438. }
  8439. else {
  8440. whenTransitionEnds(el, type, cb);
  8441. }
  8442. }
  8443. }
  8444. });
  8445. }
  8446. if (vnode.data.show) {
  8447. toggleDisplay && toggleDisplay();
  8448. enterHook && enterHook(el, cb);
  8449. }
  8450. if (!expectsCSS && !userWantsControl) {
  8451. cb();
  8452. }
  8453. }
  8454. function leave(vnode, rm) {
  8455. const el = vnode.elm;
  8456. // call enter callback now
  8457. if (isDef(el._enterCb)) {
  8458. el._enterCb.cancelled = true;
  8459. el._enterCb();
  8460. }
  8461. const data = resolveTransition(vnode.data.transition);
  8462. if (isUndef(data) || el.nodeType !== 1) {
  8463. return rm();
  8464. }
  8465. /* istanbul ignore if */
  8466. if (isDef(el._leaveCb)) {
  8467. return;
  8468. }
  8469. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  8470. const expectsCSS = css !== false && !isIE9;
  8471. const userWantsControl = getHookArgumentsLength(leave);
  8472. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  8473. if (isDef(explicitLeaveDuration)) {
  8474. checkDuration(explicitLeaveDuration, 'leave', vnode);
  8475. }
  8476. const cb = (el._leaveCb = once(() => {
  8477. if (el.parentNode && el.parentNode._pending) {
  8478. el.parentNode._pending[vnode.key] = null;
  8479. }
  8480. if (expectsCSS) {
  8481. removeTransitionClass(el, leaveToClass);
  8482. removeTransitionClass(el, leaveActiveClass);
  8483. }
  8484. // @ts-expect-error
  8485. if (cb.cancelled) {
  8486. if (expectsCSS) {
  8487. removeTransitionClass(el, leaveClass);
  8488. }
  8489. leaveCancelled && leaveCancelled(el);
  8490. }
  8491. else {
  8492. rm();
  8493. afterLeave && afterLeave(el);
  8494. }
  8495. el._leaveCb = null;
  8496. }));
  8497. if (delayLeave) {
  8498. delayLeave(performLeave);
  8499. }
  8500. else {
  8501. performLeave();
  8502. }
  8503. function performLeave() {
  8504. // the delayed leave may have already been cancelled
  8505. // @ts-expect-error
  8506. if (cb.cancelled) {
  8507. return;
  8508. }
  8509. // record leaving element
  8510. if (!vnode.data.show && el.parentNode) {
  8511. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  8512. vnode;
  8513. }
  8514. beforeLeave && beforeLeave(el);
  8515. if (expectsCSS) {
  8516. addTransitionClass(el, leaveClass);
  8517. addTransitionClass(el, leaveActiveClass);
  8518. nextFrame(() => {
  8519. removeTransitionClass(el, leaveClass);
  8520. // @ts-expect-error
  8521. if (!cb.cancelled) {
  8522. addTransitionClass(el, leaveToClass);
  8523. if (!userWantsControl) {
  8524. if (isValidDuration(explicitLeaveDuration)) {
  8525. setTimeout(cb, explicitLeaveDuration);
  8526. }
  8527. else {
  8528. whenTransitionEnds(el, type, cb);
  8529. }
  8530. }
  8531. }
  8532. });
  8533. }
  8534. leave && leave(el, cb);
  8535. if (!expectsCSS && !userWantsControl) {
  8536. cb();
  8537. }
  8538. }
  8539. }
  8540. // only used in dev mode
  8541. function checkDuration(val, name, vnode) {
  8542. if (typeof val !== 'number') {
  8543. warn$2(`<transition> explicit ${name} duration is not a valid number - ` +
  8544. `got ${JSON.stringify(val)}.`, vnode.context);
  8545. }
  8546. else if (isNaN(val)) {
  8547. warn$2(`<transition> explicit ${name} duration is NaN - ` +
  8548. 'the duration expression might be incorrect.', vnode.context);
  8549. }
  8550. }
  8551. function isValidDuration(val) {
  8552. return typeof val === 'number' && !isNaN(val);
  8553. }
  8554. /**
  8555. * Normalize a transition hook's argument length. The hook may be:
  8556. * - a merged hook (invoker) with the original in .fns
  8557. * - a wrapped component method (check ._length)
  8558. * - a plain function (.length)
  8559. */
  8560. function getHookArgumentsLength(fn) {
  8561. if (isUndef(fn)) {
  8562. return false;
  8563. }
  8564. // @ts-expect-error
  8565. const invokerFns = fn.fns;
  8566. if (isDef(invokerFns)) {
  8567. // invoker
  8568. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8569. }
  8570. else {
  8571. // @ts-expect-error
  8572. return (fn._length || fn.length) > 1;
  8573. }
  8574. }
  8575. function _enter(_, vnode) {
  8576. if (vnode.data.show !== true) {
  8577. enter(vnode);
  8578. }
  8579. }
  8580. var transition = inBrowser
  8581. ? {
  8582. create: _enter,
  8583. activate: _enter,
  8584. remove(vnode, rm) {
  8585. /* istanbul ignore else */
  8586. if (vnode.data.show !== true) {
  8587. // @ts-expect-error
  8588. leave(vnode, rm);
  8589. }
  8590. else {
  8591. rm();
  8592. }
  8593. }
  8594. }
  8595. : {};
  8596. var platformModules = [attrs, klass$1, events, domProps, style$1, transition];
  8597. // the directive module should be applied last, after all
  8598. // built-in modules have been applied.
  8599. const modules$1 = platformModules.concat(baseModules);
  8600. const patch = createPatchFunction({ nodeOps, modules: modules$1 });
  8601. /**
  8602. * Not type checking this file because flow doesn't like attaching
  8603. * properties to Elements.
  8604. */
  8605. /* istanbul ignore if */
  8606. if (isIE9) {
  8607. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8608. document.addEventListener('selectionchange', () => {
  8609. const el = document.activeElement;
  8610. // @ts-expect-error
  8611. if (el && el.vmodel) {
  8612. trigger(el, 'input');
  8613. }
  8614. });
  8615. }
  8616. const directive = {
  8617. inserted(el, binding, vnode, oldVnode) {
  8618. if (vnode.tag === 'select') {
  8619. // #6903
  8620. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8621. mergeVNodeHook(vnode, 'postpatch', () => {
  8622. directive.componentUpdated(el, binding, vnode);
  8623. });
  8624. }
  8625. else {
  8626. setSelected(el, binding, vnode.context);
  8627. }
  8628. el._vOptions = [].map.call(el.options, getValue);
  8629. }
  8630. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8631. el._vModifiers = binding.modifiers;
  8632. if (!binding.modifiers.lazy) {
  8633. el.addEventListener('compositionstart', onCompositionStart);
  8634. el.addEventListener('compositionend', onCompositionEnd);
  8635. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8636. // switching focus before confirming composition choice
  8637. // this also fixes the issue where some browsers e.g. iOS Chrome
  8638. // fires "change" instead of "input" on autocomplete.
  8639. el.addEventListener('change', onCompositionEnd);
  8640. /* istanbul ignore if */
  8641. if (isIE9) {
  8642. el.vmodel = true;
  8643. }
  8644. }
  8645. }
  8646. },
  8647. componentUpdated(el, binding, vnode) {
  8648. if (vnode.tag === 'select') {
  8649. setSelected(el, binding, vnode.context);
  8650. // in case the options rendered by v-for have changed,
  8651. // it's possible that the value is out-of-sync with the rendered options.
  8652. // detect such cases and filter out values that no longer has a matching
  8653. // option in the DOM.
  8654. const prevOptions = el._vOptions;
  8655. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8656. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8657. // trigger change event if
  8658. // no matching option found for at least one value
  8659. const needReset = el.multiple
  8660. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8661. : binding.value !== binding.oldValue &&
  8662. hasNoMatchingOption(binding.value, curOptions);
  8663. if (needReset) {
  8664. trigger(el, 'change');
  8665. }
  8666. }
  8667. }
  8668. }
  8669. };
  8670. function setSelected(el, binding, vm) {
  8671. actuallySetSelected(el, binding, vm);
  8672. /* istanbul ignore if */
  8673. if (isIE || isEdge) {
  8674. setTimeout(() => {
  8675. actuallySetSelected(el, binding, vm);
  8676. }, 0);
  8677. }
  8678. }
  8679. function actuallySetSelected(el, binding, vm) {
  8680. const value = binding.value;
  8681. const isMultiple = el.multiple;
  8682. if (isMultiple && !Array.isArray(value)) {
  8683. warn$2(`<select multiple v-model="${binding.expression}"> ` +
  8684. `expects an Array value for its binding, but got ${Object.prototype.toString
  8685. .call(value)
  8686. .slice(8, -1)}`, vm);
  8687. return;
  8688. }
  8689. let selected, option;
  8690. for (let i = 0, l = el.options.length; i < l; i++) {
  8691. option = el.options[i];
  8692. if (isMultiple) {
  8693. selected = looseIndexOf(value, getValue(option)) > -1;
  8694. if (option.selected !== selected) {
  8695. option.selected = selected;
  8696. }
  8697. }
  8698. else {
  8699. if (looseEqual(getValue(option), value)) {
  8700. if (el.selectedIndex !== i) {
  8701. el.selectedIndex = i;
  8702. }
  8703. return;
  8704. }
  8705. }
  8706. }
  8707. if (!isMultiple) {
  8708. el.selectedIndex = -1;
  8709. }
  8710. }
  8711. function hasNoMatchingOption(value, options) {
  8712. return options.every(o => !looseEqual(o, value));
  8713. }
  8714. function getValue(option) {
  8715. return '_value' in option ? option._value : option.value;
  8716. }
  8717. function onCompositionStart(e) {
  8718. e.target.composing = true;
  8719. }
  8720. function onCompositionEnd(e) {
  8721. // prevent triggering an input event for no reason
  8722. if (!e.target.composing)
  8723. return;
  8724. e.target.composing = false;
  8725. trigger(e.target, 'input');
  8726. }
  8727. function trigger(el, type) {
  8728. const e = document.createEvent('HTMLEvents');
  8729. e.initEvent(type, true, true);
  8730. el.dispatchEvent(e);
  8731. }
  8732. // recursively search for possible transition defined inside the component root
  8733. function locateNode(vnode) {
  8734. // @ts-expect-error
  8735. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8736. ? locateNode(vnode.componentInstance._vnode)
  8737. : vnode;
  8738. }
  8739. var show = {
  8740. bind(el, { value }, vnode) {
  8741. vnode = locateNode(vnode);
  8742. const transition = vnode.data && vnode.data.transition;
  8743. const originalDisplay = (el.__vOriginalDisplay =
  8744. el.style.display === 'none' ? '' : el.style.display);
  8745. if (value && transition) {
  8746. vnode.data.show = true;
  8747. enter(vnode, () => {
  8748. el.style.display = originalDisplay;
  8749. });
  8750. }
  8751. else {
  8752. el.style.display = value ? originalDisplay : 'none';
  8753. }
  8754. },
  8755. update(el, { value, oldValue }, vnode) {
  8756. /* istanbul ignore if */
  8757. if (!value === !oldValue)
  8758. return;
  8759. vnode = locateNode(vnode);
  8760. const transition = vnode.data && vnode.data.transition;
  8761. if (transition) {
  8762. vnode.data.show = true;
  8763. if (value) {
  8764. enter(vnode, () => {
  8765. el.style.display = el.__vOriginalDisplay;
  8766. });
  8767. }
  8768. else {
  8769. leave(vnode, () => {
  8770. el.style.display = 'none';
  8771. });
  8772. }
  8773. }
  8774. else {
  8775. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8776. }
  8777. },
  8778. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8779. if (!isDestroy) {
  8780. el.style.display = el.__vOriginalDisplay;
  8781. }
  8782. }
  8783. };
  8784. var platformDirectives = {
  8785. model: directive,
  8786. show
  8787. };
  8788. // Provides transition support for a single element/component.
  8789. const transitionProps = {
  8790. name: String,
  8791. appear: Boolean,
  8792. css: Boolean,
  8793. mode: String,
  8794. type: String,
  8795. enterClass: String,
  8796. leaveClass: String,
  8797. enterToClass: String,
  8798. leaveToClass: String,
  8799. enterActiveClass: String,
  8800. leaveActiveClass: String,
  8801. appearClass: String,
  8802. appearActiveClass: String,
  8803. appearToClass: String,
  8804. duration: [Number, String, Object]
  8805. };
  8806. // in case the child is also an abstract component, e.g. <keep-alive>
  8807. // we want to recursively retrieve the real component to be rendered
  8808. function getRealChild(vnode) {
  8809. const compOptions = vnode && vnode.componentOptions;
  8810. if (compOptions && compOptions.Ctor.options.abstract) {
  8811. return getRealChild(getFirstComponentChild(compOptions.children));
  8812. }
  8813. else {
  8814. return vnode;
  8815. }
  8816. }
  8817. function extractTransitionData(comp) {
  8818. const data = {};
  8819. const options = comp.$options;
  8820. // props
  8821. for (const key in options.propsData) {
  8822. data[key] = comp[key];
  8823. }
  8824. // events.
  8825. // extract listeners and pass them directly to the transition methods
  8826. const listeners = options._parentListeners;
  8827. for (const key in listeners) {
  8828. data[camelize(key)] = listeners[key];
  8829. }
  8830. return data;
  8831. }
  8832. function placeholder(h, rawChild) {
  8833. // @ts-expect-error
  8834. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8835. return h('keep-alive', {
  8836. props: rawChild.componentOptions.propsData
  8837. });
  8838. }
  8839. }
  8840. function hasParentTransition(vnode) {
  8841. while ((vnode = vnode.parent)) {
  8842. if (vnode.data.transition) {
  8843. return true;
  8844. }
  8845. }
  8846. }
  8847. function isSameChild(child, oldChild) {
  8848. return oldChild.key === child.key && oldChild.tag === child.tag;
  8849. }
  8850. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8851. const isVShowDirective = d => d.name === 'show';
  8852. var Transition = {
  8853. name: 'transition',
  8854. props: transitionProps,
  8855. abstract: true,
  8856. render(h) {
  8857. let children = this.$slots.default;
  8858. if (!children) {
  8859. return;
  8860. }
  8861. // filter out text nodes (possible whitespaces)
  8862. children = children.filter(isNotTextNode);
  8863. /* istanbul ignore if */
  8864. if (!children.length) {
  8865. return;
  8866. }
  8867. // warn multiple elements
  8868. if (children.length > 1) {
  8869. warn$2('<transition> can only be used on a single element. Use ' +
  8870. '<transition-group> for lists.', this.$parent);
  8871. }
  8872. const mode = this.mode;
  8873. // warn invalid mode
  8874. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8875. warn$2('invalid <transition> mode: ' + mode, this.$parent);
  8876. }
  8877. const rawChild = children[0];
  8878. // if this is a component root node and the component's
  8879. // parent container node also has transition, skip.
  8880. if (hasParentTransition(this.$vnode)) {
  8881. return rawChild;
  8882. }
  8883. // apply transition data to child
  8884. // use getRealChild() to ignore abstract components e.g. keep-alive
  8885. const child = getRealChild(rawChild);
  8886. /* istanbul ignore if */
  8887. if (!child) {
  8888. return rawChild;
  8889. }
  8890. if (this._leaving) {
  8891. return placeholder(h, rawChild);
  8892. }
  8893. // ensure a key that is unique to the vnode type and to this transition
  8894. // component instance. This key will be used to remove pending leaving nodes
  8895. // during entering.
  8896. const id = `__transition-${this._uid}-`;
  8897. child.key =
  8898. child.key == null
  8899. ? child.isComment
  8900. ? id + 'comment'
  8901. : id + child.tag
  8902. : isPrimitive(child.key)
  8903. ? String(child.key).indexOf(id) === 0
  8904. ? child.key
  8905. : id + child.key
  8906. : child.key;
  8907. const data = ((child.data || (child.data = {})).transition =
  8908. extractTransitionData(this));
  8909. const oldRawChild = this._vnode;
  8910. const oldChild = getRealChild(oldRawChild);
  8911. // mark v-show
  8912. // so that the transition module can hand over the control to the directive
  8913. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8914. child.data.show = true;
  8915. }
  8916. if (oldChild &&
  8917. oldChild.data &&
  8918. !isSameChild(child, oldChild) &&
  8919. !isAsyncPlaceholder(oldChild) &&
  8920. // #6687 component root is a comment node
  8921. !(oldChild.componentInstance &&
  8922. oldChild.componentInstance._vnode.isComment)) {
  8923. // replace old child transition data with fresh one
  8924. // important for dynamic transitions!
  8925. const oldData = (oldChild.data.transition = extend({}, data));
  8926. // handle transition mode
  8927. if (mode === 'out-in') {
  8928. // return placeholder node and queue update when leave finishes
  8929. this._leaving = true;
  8930. mergeVNodeHook(oldData, 'afterLeave', () => {
  8931. this._leaving = false;
  8932. this.$forceUpdate();
  8933. });
  8934. return placeholder(h, rawChild);
  8935. }
  8936. else if (mode === 'in-out') {
  8937. if (isAsyncPlaceholder(child)) {
  8938. return oldRawChild;
  8939. }
  8940. let delayedLeave;
  8941. const performLeave = () => {
  8942. delayedLeave();
  8943. };
  8944. mergeVNodeHook(data, 'afterEnter', performLeave);
  8945. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8946. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8947. delayedLeave = leave;
  8948. });
  8949. }
  8950. }
  8951. return rawChild;
  8952. }
  8953. };
  8954. // Provides transition support for list items.
  8955. const props = extend({
  8956. tag: String,
  8957. moveClass: String
  8958. }, transitionProps);
  8959. delete props.mode;
  8960. var TransitionGroup = {
  8961. props,
  8962. beforeMount() {
  8963. const update = this._update;
  8964. this._update = (vnode, hydrating) => {
  8965. const restoreActiveInstance = setActiveInstance(this);
  8966. // force removing pass
  8967. this.__patch__(this._vnode, this.kept, false, // hydrating
  8968. true // removeOnly (!important, avoids unnecessary moves)
  8969. );
  8970. this._vnode = this.kept;
  8971. restoreActiveInstance();
  8972. update.call(this, vnode, hydrating);
  8973. };
  8974. },
  8975. render(h) {
  8976. const tag = this.tag || this.$vnode.data.tag || 'span';
  8977. const map = Object.create(null);
  8978. const prevChildren = (this.prevChildren = this.children);
  8979. const rawChildren = this.$slots.default || [];
  8980. const children = (this.children = []);
  8981. const transitionData = extractTransitionData(this);
  8982. for (let i = 0; i < rawChildren.length; i++) {
  8983. const c = rawChildren[i];
  8984. if (c.tag) {
  8985. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8986. children.push(c);
  8987. map[c.key] = c;
  8988. (c.data || (c.data = {})).transition = transitionData;
  8989. }
  8990. else {
  8991. const opts = c.componentOptions;
  8992. const name = opts
  8993. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8994. : c.tag;
  8995. warn$2(`<transition-group> children must be keyed: <${name}>`);
  8996. }
  8997. }
  8998. }
  8999. if (prevChildren) {
  9000. const kept = [];
  9001. const removed = [];
  9002. for (let i = 0; i < prevChildren.length; i++) {
  9003. const c = prevChildren[i];
  9004. c.data.transition = transitionData;
  9005. // @ts-expect-error .getBoundingClientRect is not typed in Node
  9006. c.data.pos = c.elm.getBoundingClientRect();
  9007. if (map[c.key]) {
  9008. kept.push(c);
  9009. }
  9010. else {
  9011. removed.push(c);
  9012. }
  9013. }
  9014. this.kept = h(tag, null, kept);
  9015. this.removed = removed;
  9016. }
  9017. return h(tag, null, children);
  9018. },
  9019. updated() {
  9020. const children = this.prevChildren;
  9021. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  9022. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  9023. return;
  9024. }
  9025. // we divide the work into three loops to avoid mixing DOM reads and writes
  9026. // in each iteration - which helps prevent layout thrashing.
  9027. children.forEach(callPendingCbs);
  9028. children.forEach(recordPosition);
  9029. children.forEach(applyTranslation);
  9030. // force reflow to put everything in position
  9031. // assign to this to avoid being removed in tree-shaking
  9032. // $flow-disable-line
  9033. this._reflow = document.body.offsetHeight;
  9034. children.forEach((c) => {
  9035. if (c.data.moved) {
  9036. const el = c.elm;
  9037. const s = el.style;
  9038. addTransitionClass(el, moveClass);
  9039. s.transform = s.WebkitTransform = s.transitionDuration = '';
  9040. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  9041. if (e && e.target !== el) {
  9042. return;
  9043. }
  9044. if (!e || /transform$/.test(e.propertyName)) {
  9045. el.removeEventListener(transitionEndEvent, cb);
  9046. el._moveCb = null;
  9047. removeTransitionClass(el, moveClass);
  9048. }
  9049. }));
  9050. }
  9051. });
  9052. },
  9053. methods: {
  9054. hasMove(el, moveClass) {
  9055. /* istanbul ignore if */
  9056. if (!hasTransition) {
  9057. return false;
  9058. }
  9059. /* istanbul ignore if */
  9060. if (this._hasMove) {
  9061. return this._hasMove;
  9062. }
  9063. // Detect whether an element with the move class applied has
  9064. // CSS transitions. Since the element may be inside an entering
  9065. // transition at this very moment, we make a clone of it and remove
  9066. // all other transition classes applied to ensure only the move class
  9067. // is applied.
  9068. const clone = el.cloneNode();
  9069. if (el._transitionClasses) {
  9070. el._transitionClasses.forEach((cls) => {
  9071. removeClass(clone, cls);
  9072. });
  9073. }
  9074. addClass(clone, moveClass);
  9075. clone.style.display = 'none';
  9076. this.$el.appendChild(clone);
  9077. const info = getTransitionInfo(clone);
  9078. this.$el.removeChild(clone);
  9079. return (this._hasMove = info.hasTransform);
  9080. }
  9081. }
  9082. };
  9083. function callPendingCbs(c) {
  9084. /* istanbul ignore if */
  9085. if (c.elm._moveCb) {
  9086. c.elm._moveCb();
  9087. }
  9088. /* istanbul ignore if */
  9089. if (c.elm._enterCb) {
  9090. c.elm._enterCb();
  9091. }
  9092. }
  9093. function recordPosition(c) {
  9094. c.data.newPos = c.elm.getBoundingClientRect();
  9095. }
  9096. function applyTranslation(c) {
  9097. const oldPos = c.data.pos;
  9098. const newPos = c.data.newPos;
  9099. const dx = oldPos.left - newPos.left;
  9100. const dy = oldPos.top - newPos.top;
  9101. if (dx || dy) {
  9102. c.data.moved = true;
  9103. const s = c.elm.style;
  9104. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  9105. s.transitionDuration = '0s';
  9106. }
  9107. }
  9108. var platformComponents = {
  9109. Transition,
  9110. TransitionGroup
  9111. };
  9112. // install platform specific utils
  9113. Vue.config.mustUseProp = mustUseProp;
  9114. Vue.config.isReservedTag = isReservedTag;
  9115. Vue.config.isReservedAttr = isReservedAttr;
  9116. Vue.config.getTagNamespace = getTagNamespace;
  9117. Vue.config.isUnknownElement = isUnknownElement;
  9118. // install platform runtime directives & components
  9119. extend(Vue.options.directives, platformDirectives);
  9120. extend(Vue.options.components, platformComponents);
  9121. // install platform patch function
  9122. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  9123. // public mount method
  9124. Vue.prototype.$mount = function (el, hydrating) {
  9125. el = el && inBrowser ? query(el) : undefined;
  9126. return mountComponent(this, el, hydrating);
  9127. };
  9128. // devtools global hook
  9129. /* istanbul ignore next */
  9130. if (inBrowser) {
  9131. setTimeout(() => {
  9132. if (config.devtools) {
  9133. if (devtools) {
  9134. devtools.emit('init', Vue);
  9135. }
  9136. else {
  9137. // @ts-expect-error
  9138. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  9139. 'https://github.com/vuejs/vue-devtools');
  9140. }
  9141. }
  9142. if (config.productionTip !== false &&
  9143. typeof console !== 'undefined') {
  9144. // @ts-expect-error
  9145. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  9146. `Make sure to turn on production mode when deploying for production.\n` +
  9147. `See more tips at https://vuejs.org/guide/deployment.html`);
  9148. }
  9149. }, 0);
  9150. }
  9151. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  9152. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  9153. const buildRegex = cached(delimiters => {
  9154. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  9155. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  9156. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  9157. });
  9158. function parseText(text, delimiters) {
  9159. //@ts-expect-error
  9160. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  9161. if (!tagRE.test(text)) {
  9162. return;
  9163. }
  9164. const tokens = [];
  9165. const rawTokens = [];
  9166. let lastIndex = (tagRE.lastIndex = 0);
  9167. let match, index, tokenValue;
  9168. while ((match = tagRE.exec(text))) {
  9169. index = match.index;
  9170. // push text token
  9171. if (index > lastIndex) {
  9172. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  9173. tokens.push(JSON.stringify(tokenValue));
  9174. }
  9175. // tag token
  9176. const exp = parseFilters(match[1].trim());
  9177. tokens.push(`_s(${exp})`);
  9178. rawTokens.push({ '@binding': exp });
  9179. lastIndex = index + match[0].length;
  9180. }
  9181. if (lastIndex < text.length) {
  9182. rawTokens.push((tokenValue = text.slice(lastIndex)));
  9183. tokens.push(JSON.stringify(tokenValue));
  9184. }
  9185. return {
  9186. expression: tokens.join('+'),
  9187. tokens: rawTokens
  9188. };
  9189. }
  9190. function transformNode$1(el, options) {
  9191. const warn = options.warn || baseWarn;
  9192. const staticClass = getAndRemoveAttr(el, 'class');
  9193. if (staticClass) {
  9194. const res = parseText(staticClass, options.delimiters);
  9195. if (res) {
  9196. warn(`class="${staticClass}": ` +
  9197. 'Interpolation inside attributes has been removed. ' +
  9198. 'Use v-bind or the colon shorthand instead. For example, ' +
  9199. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  9200. }
  9201. }
  9202. if (staticClass) {
  9203. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  9204. }
  9205. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  9206. if (classBinding) {
  9207. el.classBinding = classBinding;
  9208. }
  9209. }
  9210. function genData$2(el) {
  9211. let data = '';
  9212. if (el.staticClass) {
  9213. data += `staticClass:${el.staticClass},`;
  9214. }
  9215. if (el.classBinding) {
  9216. data += `class:${el.classBinding},`;
  9217. }
  9218. return data;
  9219. }
  9220. var klass = {
  9221. staticKeys: ['staticClass'],
  9222. transformNode: transformNode$1,
  9223. genData: genData$2
  9224. };
  9225. function transformNode(el, options) {
  9226. const warn = options.warn || baseWarn;
  9227. const staticStyle = getAndRemoveAttr(el, 'style');
  9228. if (staticStyle) {
  9229. /* istanbul ignore if */
  9230. {
  9231. const res = parseText(staticStyle, options.delimiters);
  9232. if (res) {
  9233. warn(`style="${staticStyle}": ` +
  9234. 'Interpolation inside attributes has been removed. ' +
  9235. 'Use v-bind or the colon shorthand instead. For example, ' +
  9236. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  9237. }
  9238. }
  9239. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  9240. }
  9241. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  9242. if (styleBinding) {
  9243. el.styleBinding = styleBinding;
  9244. }
  9245. }
  9246. function genData$1(el) {
  9247. let data = '';
  9248. if (el.staticStyle) {
  9249. data += `staticStyle:${el.staticStyle},`;
  9250. }
  9251. if (el.styleBinding) {
  9252. data += `style:(${el.styleBinding}),`;
  9253. }
  9254. return data;
  9255. }
  9256. var style = {
  9257. staticKeys: ['staticStyle'],
  9258. transformNode,
  9259. genData: genData$1
  9260. };
  9261. let decoder;
  9262. var he = {
  9263. decode(html) {
  9264. decoder = decoder || document.createElement('div');
  9265. decoder.innerHTML = html;
  9266. return decoder.textContent;
  9267. }
  9268. };
  9269. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  9270. 'link,meta,param,source,track,wbr');
  9271. // Elements that you can, intentionally, leave open
  9272. // (and which close themselves)
  9273. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  9274. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  9275. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  9276. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  9277. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  9278. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  9279. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  9280. 'title,tr,track');
  9281. /**
  9282. * Not type-checking this file because it's mostly vendor code.
  9283. */
  9284. // Regular Expressions for parsing tags and attributes
  9285. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9286. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  9287. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  9288. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  9289. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  9290. const startTagClose = /^\s*(\/?)>/;
  9291. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  9292. const doctype = /^<!DOCTYPE [^>]+>/i;
  9293. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  9294. const comment = /^<!\--/;
  9295. const conditionalComment = /^<!\[/;
  9296. // Special Elements (can contain anything)
  9297. const isPlainTextElement = makeMap('script,style,textarea', true);
  9298. const reCache = {};
  9299. const decodingMap = {
  9300. '&lt;': '<',
  9301. '&gt;': '>',
  9302. '&quot;': '"',
  9303. '&amp;': '&',
  9304. '&#10;': '\n',
  9305. '&#9;': '\t',
  9306. '&#39;': "'"
  9307. };
  9308. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  9309. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  9310. // #5992
  9311. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  9312. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  9313. function decodeAttr(value, shouldDecodeNewlines) {
  9314. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  9315. return value.replace(re, match => decodingMap[match]);
  9316. }
  9317. function parseHTML(html, options) {
  9318. const stack = [];
  9319. const expectHTML = options.expectHTML;
  9320. const isUnaryTag = options.isUnaryTag || no;
  9321. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  9322. let index = 0;
  9323. let last, lastTag;
  9324. while (html) {
  9325. last = html;
  9326. // Make sure we're not in a plaintext content element like script/style
  9327. if (!lastTag || !isPlainTextElement(lastTag)) {
  9328. let textEnd = html.indexOf('<');
  9329. if (textEnd === 0) {
  9330. // Comment:
  9331. if (comment.test(html)) {
  9332. const commentEnd = html.indexOf('-->');
  9333. if (commentEnd >= 0) {
  9334. if (options.shouldKeepComment && options.comment) {
  9335. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  9336. }
  9337. advance(commentEnd + 3);
  9338. continue;
  9339. }
  9340. }
  9341. // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  9342. if (conditionalComment.test(html)) {
  9343. const conditionalEnd = html.indexOf(']>');
  9344. if (conditionalEnd >= 0) {
  9345. advance(conditionalEnd + 2);
  9346. continue;
  9347. }
  9348. }
  9349. // Doctype:
  9350. const doctypeMatch = html.match(doctype);
  9351. if (doctypeMatch) {
  9352. advance(doctypeMatch[0].length);
  9353. continue;
  9354. }
  9355. // End tag:
  9356. const endTagMatch = html.match(endTag);
  9357. if (endTagMatch) {
  9358. const curIndex = index;
  9359. advance(endTagMatch[0].length);
  9360. parseEndTag(endTagMatch[1], curIndex, index);
  9361. continue;
  9362. }
  9363. // Start tag:
  9364. const startTagMatch = parseStartTag();
  9365. if (startTagMatch) {
  9366. handleStartTag(startTagMatch);
  9367. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  9368. advance(1);
  9369. }
  9370. continue;
  9371. }
  9372. }
  9373. let text, rest, next;
  9374. if (textEnd >= 0) {
  9375. rest = html.slice(textEnd);
  9376. while (!endTag.test(rest) &&
  9377. !startTagOpen.test(rest) &&
  9378. !comment.test(rest) &&
  9379. !conditionalComment.test(rest)) {
  9380. // < in plain text, be forgiving and treat it as text
  9381. next = rest.indexOf('<', 1);
  9382. if (next < 0)
  9383. break;
  9384. textEnd += next;
  9385. rest = html.slice(textEnd);
  9386. }
  9387. text = html.substring(0, textEnd);
  9388. }
  9389. if (textEnd < 0) {
  9390. text = html;
  9391. }
  9392. if (text) {
  9393. advance(text.length);
  9394. }
  9395. if (options.chars && text) {
  9396. options.chars(text, index - text.length, index);
  9397. }
  9398. }
  9399. else {
  9400. let endTagLength = 0;
  9401. const stackedTag = lastTag.toLowerCase();
  9402. const reStackedTag = reCache[stackedTag] ||
  9403. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  9404. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  9405. endTagLength = endTag.length;
  9406. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  9407. text = text
  9408. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  9409. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  9410. }
  9411. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  9412. text = text.slice(1);
  9413. }
  9414. if (options.chars) {
  9415. options.chars(text);
  9416. }
  9417. return '';
  9418. });
  9419. index += html.length - rest.length;
  9420. html = rest;
  9421. parseEndTag(stackedTag, index - endTagLength, index);
  9422. }
  9423. if (html === last) {
  9424. options.chars && options.chars(html);
  9425. if (!stack.length && options.warn) {
  9426. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  9427. start: index + html.length
  9428. });
  9429. }
  9430. break;
  9431. }
  9432. }
  9433. // Clean up any remaining tags
  9434. parseEndTag();
  9435. function advance(n) {
  9436. index += n;
  9437. html = html.substring(n);
  9438. }
  9439. function parseStartTag() {
  9440. const start = html.match(startTagOpen);
  9441. if (start) {
  9442. const match = {
  9443. tagName: start[1],
  9444. attrs: [],
  9445. start: index
  9446. };
  9447. advance(start[0].length);
  9448. let end, attr;
  9449. while (!(end = html.match(startTagClose)) &&
  9450. (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  9451. attr.start = index;
  9452. advance(attr[0].length);
  9453. attr.end = index;
  9454. match.attrs.push(attr);
  9455. }
  9456. if (end) {
  9457. match.unarySlash = end[1];
  9458. advance(end[0].length);
  9459. match.end = index;
  9460. return match;
  9461. }
  9462. }
  9463. }
  9464. function handleStartTag(match) {
  9465. const tagName = match.tagName;
  9466. const unarySlash = match.unarySlash;
  9467. if (expectHTML) {
  9468. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  9469. parseEndTag(lastTag);
  9470. }
  9471. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  9472. parseEndTag(tagName);
  9473. }
  9474. }
  9475. const unary = isUnaryTag(tagName) || !!unarySlash;
  9476. const l = match.attrs.length;
  9477. const attrs = new Array(l);
  9478. for (let i = 0; i < l; i++) {
  9479. const args = match.attrs[i];
  9480. const value = args[3] || args[4] || args[5] || '';
  9481. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  9482. ? options.shouldDecodeNewlinesForHref
  9483. : options.shouldDecodeNewlines;
  9484. attrs[i] = {
  9485. name: args[1],
  9486. value: decodeAttr(value, shouldDecodeNewlines)
  9487. };
  9488. if (options.outputSourceRange) {
  9489. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  9490. attrs[i].end = args.end;
  9491. }
  9492. }
  9493. if (!unary) {
  9494. stack.push({
  9495. tag: tagName,
  9496. lowerCasedTag: tagName.toLowerCase(),
  9497. attrs: attrs,
  9498. start: match.start,
  9499. end: match.end
  9500. });
  9501. lastTag = tagName;
  9502. }
  9503. if (options.start) {
  9504. options.start(tagName, attrs, unary, match.start, match.end);
  9505. }
  9506. }
  9507. function parseEndTag(tagName, start, end) {
  9508. let pos, lowerCasedTagName;
  9509. if (start == null)
  9510. start = index;
  9511. if (end == null)
  9512. end = index;
  9513. // Find the closest opened tag of the same type
  9514. if (tagName) {
  9515. lowerCasedTagName = tagName.toLowerCase();
  9516. for (pos = stack.length - 1; pos >= 0; pos--) {
  9517. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  9518. break;
  9519. }
  9520. }
  9521. }
  9522. else {
  9523. // If no tag name is provided, clean shop
  9524. pos = 0;
  9525. }
  9526. if (pos >= 0) {
  9527. // Close all the open elements, up the stack
  9528. for (let i = stack.length - 1; i >= pos; i--) {
  9529. if ((i > pos || !tagName) && options.warn) {
  9530. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  9531. start: stack[i].start,
  9532. end: stack[i].end
  9533. });
  9534. }
  9535. if (options.end) {
  9536. options.end(stack[i].tag, start, end);
  9537. }
  9538. }
  9539. // Remove the open elements from the stack
  9540. stack.length = pos;
  9541. lastTag = pos && stack[pos - 1].tag;
  9542. }
  9543. else if (lowerCasedTagName === 'br') {
  9544. if (options.start) {
  9545. options.start(tagName, [], true, start, end);
  9546. }
  9547. }
  9548. else if (lowerCasedTagName === 'p') {
  9549. if (options.start) {
  9550. options.start(tagName, [], false, start, end);
  9551. }
  9552. if (options.end) {
  9553. options.end(tagName, start, end);
  9554. }
  9555. }
  9556. }
  9557. }
  9558. const onRE = /^@|^v-on:/;
  9559. const dirRE = /^v-|^@|^:|^#/;
  9560. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9561. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  9562. const stripParensRE = /^\(|\)$/g;
  9563. const dynamicArgRE = /^\[.*\]$/;
  9564. const argRE = /:(.*)$/;
  9565. const bindRE = /^:|^\.|^v-bind:/;
  9566. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  9567. const slotRE = /^v-slot(:|$)|^#/;
  9568. const lineBreakRE = /[\r\n]/;
  9569. const whitespaceRE = /[ \f\t\r\n]+/g;
  9570. const invalidAttributeRE = /[\s"'<>\/=]/;
  9571. const decodeHTMLCached = cached(he.decode);
  9572. const emptySlotScopeToken = `_empty_`;
  9573. // configurable state
  9574. let warn;
  9575. let delimiters;
  9576. let transforms;
  9577. let preTransforms;
  9578. let postTransforms;
  9579. let platformIsPreTag;
  9580. let platformMustUseProp;
  9581. let platformGetTagNamespace;
  9582. let maybeComponent;
  9583. function createASTElement(tag, attrs, parent) {
  9584. return {
  9585. type: 1,
  9586. tag,
  9587. attrsList: attrs,
  9588. attrsMap: makeAttrsMap(attrs),
  9589. rawAttrsMap: {},
  9590. parent,
  9591. children: []
  9592. };
  9593. }
  9594. /**
  9595. * Convert HTML string to AST.
  9596. */
  9597. function parse(template, options) {
  9598. warn = options.warn || baseWarn;
  9599. platformIsPreTag = options.isPreTag || no;
  9600. platformMustUseProp = options.mustUseProp || no;
  9601. platformGetTagNamespace = options.getTagNamespace || no;
  9602. const isReservedTag = options.isReservedTag || no;
  9603. maybeComponent = (el) => !!(el.component ||
  9604. el.attrsMap[':is'] ||
  9605. el.attrsMap['v-bind:is'] ||
  9606. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  9607. transforms = pluckModuleFunction(options.modules, 'transformNode');
  9608. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  9609. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  9610. delimiters = options.delimiters;
  9611. const stack = [];
  9612. const preserveWhitespace = options.preserveWhitespace !== false;
  9613. const whitespaceOption = options.whitespace;
  9614. let root;
  9615. let currentParent;
  9616. let inVPre = false;
  9617. let inPre = false;
  9618. let warned = false;
  9619. function warnOnce(msg, range) {
  9620. if (!warned) {
  9621. warned = true;
  9622. warn(msg, range);
  9623. }
  9624. }
  9625. function closeElement(element) {
  9626. trimEndingWhitespace(element);
  9627. if (!inVPre && !element.processed) {
  9628. element = processElement(element, options);
  9629. }
  9630. // tree management
  9631. if (!stack.length && element !== root) {
  9632. // allow root elements with v-if, v-else-if and v-else
  9633. if (root.if && (element.elseif || element.else)) {
  9634. {
  9635. checkRootConstraints(element);
  9636. }
  9637. addIfCondition(root, {
  9638. exp: element.elseif,
  9639. block: element
  9640. });
  9641. }
  9642. else {
  9643. warnOnce(`Component template should contain exactly one root element. ` +
  9644. `If you are using v-if on multiple elements, ` +
  9645. `use v-else-if to chain them instead.`, { start: element.start });
  9646. }
  9647. }
  9648. if (currentParent && !element.forbidden) {
  9649. if (element.elseif || element.else) {
  9650. processIfConditions(element, currentParent);
  9651. }
  9652. else {
  9653. if (element.slotScope) {
  9654. // scoped slot
  9655. // keep it in the children list so that v-else(-if) conditions can
  9656. // find it as the prev node.
  9657. const name = element.slotTarget || '"default"';
  9658. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  9659. }
  9660. currentParent.children.push(element);
  9661. element.parent = currentParent;
  9662. }
  9663. }
  9664. // final children cleanup
  9665. // filter out scoped slots
  9666. element.children = element.children.filter(c => !c.slotScope);
  9667. // remove trailing whitespace node again
  9668. trimEndingWhitespace(element);
  9669. // check pre state
  9670. if (element.pre) {
  9671. inVPre = false;
  9672. }
  9673. if (platformIsPreTag(element.tag)) {
  9674. inPre = false;
  9675. }
  9676. // apply post-transforms
  9677. for (let i = 0; i < postTransforms.length; i++) {
  9678. postTransforms[i](element, options);
  9679. }
  9680. }
  9681. function trimEndingWhitespace(el) {
  9682. // remove trailing whitespace node
  9683. if (!inPre) {
  9684. let lastNode;
  9685. while ((lastNode = el.children[el.children.length - 1]) &&
  9686. lastNode.type === 3 &&
  9687. lastNode.text === ' ') {
  9688. el.children.pop();
  9689. }
  9690. }
  9691. }
  9692. function checkRootConstraints(el) {
  9693. if (el.tag === 'slot' || el.tag === 'template') {
  9694. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  9695. 'contain multiple nodes.', { start: el.start });
  9696. }
  9697. if (el.attrsMap.hasOwnProperty('v-for')) {
  9698. warnOnce('Cannot use v-for on stateful component root element because ' +
  9699. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  9700. }
  9701. }
  9702. parseHTML(template, {
  9703. warn,
  9704. expectHTML: options.expectHTML,
  9705. isUnaryTag: options.isUnaryTag,
  9706. canBeLeftOpenTag: options.canBeLeftOpenTag,
  9707. shouldDecodeNewlines: options.shouldDecodeNewlines,
  9708. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  9709. shouldKeepComment: options.comments,
  9710. outputSourceRange: options.outputSourceRange,
  9711. start(tag, attrs, unary, start, end) {
  9712. // check namespace.
  9713. // inherit parent ns if there is one
  9714. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  9715. // handle IE svg bug
  9716. /* istanbul ignore if */
  9717. if (isIE && ns === 'svg') {
  9718. attrs = guardIESVGBug(attrs);
  9719. }
  9720. let element = createASTElement(tag, attrs, currentParent);
  9721. if (ns) {
  9722. element.ns = ns;
  9723. }
  9724. {
  9725. if (options.outputSourceRange) {
  9726. element.start = start;
  9727. element.end = end;
  9728. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  9729. cumulated[attr.name] = attr;
  9730. return cumulated;
  9731. }, {});
  9732. }
  9733. attrs.forEach(attr => {
  9734. if (invalidAttributeRE.test(attr.name)) {
  9735. warn(`Invalid dynamic argument expression: attribute names cannot contain ` +
  9736. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  9737. ? {
  9738. start: attr.start + attr.name.indexOf(`[`),
  9739. end: attr.start + attr.name.length
  9740. }
  9741. : undefined);
  9742. }
  9743. });
  9744. }
  9745. if (isForbiddenTag(element) && !isServerRendering()) {
  9746. element.forbidden = true;
  9747. warn('Templates should only be responsible for mapping the state to the ' +
  9748. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  9749. `<${tag}>` +
  9750. ', as they will not be parsed.', { start: element.start });
  9751. }
  9752. // apply pre-transforms
  9753. for (let i = 0; i < preTransforms.length; i++) {
  9754. element = preTransforms[i](element, options) || element;
  9755. }
  9756. if (!inVPre) {
  9757. processPre(element);
  9758. if (element.pre) {
  9759. inVPre = true;
  9760. }
  9761. }
  9762. if (platformIsPreTag(element.tag)) {
  9763. inPre = true;
  9764. }
  9765. if (inVPre) {
  9766. processRawAttrs(element);
  9767. }
  9768. else if (!element.processed) {
  9769. // structural directives
  9770. processFor(element);
  9771. processIf(element);
  9772. processOnce(element);
  9773. }
  9774. if (!root) {
  9775. root = element;
  9776. {
  9777. checkRootConstraints(root);
  9778. }
  9779. }
  9780. if (!unary) {
  9781. currentParent = element;
  9782. stack.push(element);
  9783. }
  9784. else {
  9785. closeElement(element);
  9786. }
  9787. },
  9788. end(tag, start, end) {
  9789. const element = stack[stack.length - 1];
  9790. // pop stack
  9791. stack.length -= 1;
  9792. currentParent = stack[stack.length - 1];
  9793. if (options.outputSourceRange) {
  9794. element.end = end;
  9795. }
  9796. closeElement(element);
  9797. },
  9798. chars(text, start, end) {
  9799. if (!currentParent) {
  9800. {
  9801. if (text === template) {
  9802. warnOnce('Component template requires a root element, rather than just text.', { start });
  9803. }
  9804. else if ((text = text.trim())) {
  9805. warnOnce(`text "${text}" outside root element will be ignored.`, {
  9806. start
  9807. });
  9808. }
  9809. }
  9810. return;
  9811. }
  9812. // IE textarea placeholder bug
  9813. /* istanbul ignore if */
  9814. if (isIE &&
  9815. currentParent.tag === 'textarea' &&
  9816. currentParent.attrsMap.placeholder === text) {
  9817. return;
  9818. }
  9819. const children = currentParent.children;
  9820. if (inPre || text.trim()) {
  9821. text = isTextTag(currentParent)
  9822. ? text
  9823. : decodeHTMLCached(text);
  9824. }
  9825. else if (!children.length) {
  9826. // remove the whitespace-only node right after an opening tag
  9827. text = '';
  9828. }
  9829. else if (whitespaceOption) {
  9830. if (whitespaceOption === 'condense') {
  9831. // in condense mode, remove the whitespace node if it contains
  9832. // line break, otherwise condense to a single space
  9833. text = lineBreakRE.test(text) ? '' : ' ';
  9834. }
  9835. else {
  9836. text = ' ';
  9837. }
  9838. }
  9839. else {
  9840. text = preserveWhitespace ? ' ' : '';
  9841. }
  9842. if (text) {
  9843. if (!inPre && whitespaceOption === 'condense') {
  9844. // condense consecutive whitespaces into single space
  9845. text = text.replace(whitespaceRE, ' ');
  9846. }
  9847. let res;
  9848. let child;
  9849. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  9850. child = {
  9851. type: 2,
  9852. expression: res.expression,
  9853. tokens: res.tokens,
  9854. text
  9855. };
  9856. }
  9857. else if (text !== ' ' ||
  9858. !children.length ||
  9859. children[children.length - 1].text !== ' ') {
  9860. child = {
  9861. type: 3,
  9862. text
  9863. };
  9864. }
  9865. if (child) {
  9866. if (options.outputSourceRange) {
  9867. child.start = start;
  9868. child.end = end;
  9869. }
  9870. children.push(child);
  9871. }
  9872. }
  9873. },
  9874. comment(text, start, end) {
  9875. // adding anything as a sibling to the root node is forbidden
  9876. // comments should still be allowed, but ignored
  9877. if (currentParent) {
  9878. const child = {
  9879. type: 3,
  9880. text,
  9881. isComment: true
  9882. };
  9883. if (options.outputSourceRange) {
  9884. child.start = start;
  9885. child.end = end;
  9886. }
  9887. currentParent.children.push(child);
  9888. }
  9889. }
  9890. });
  9891. return root;
  9892. }
  9893. function processPre(el) {
  9894. if (getAndRemoveAttr(el, 'v-pre') != null) {
  9895. el.pre = true;
  9896. }
  9897. }
  9898. function processRawAttrs(el) {
  9899. const list = el.attrsList;
  9900. const len = list.length;
  9901. if (len) {
  9902. const attrs = (el.attrs = new Array(len));
  9903. for (let i = 0; i < len; i++) {
  9904. attrs[i] = {
  9905. name: list[i].name,
  9906. value: JSON.stringify(list[i].value)
  9907. };
  9908. if (list[i].start != null) {
  9909. attrs[i].start = list[i].start;
  9910. attrs[i].end = list[i].end;
  9911. }
  9912. }
  9913. }
  9914. else if (!el.pre) {
  9915. // non root node in pre blocks with no attributes
  9916. el.plain = true;
  9917. }
  9918. }
  9919. function processElement(element, options) {
  9920. processKey(element);
  9921. // determine whether this is a plain element after
  9922. // removing structural attributes
  9923. element.plain =
  9924. !element.key && !element.scopedSlots && !element.attrsList.length;
  9925. processRef(element);
  9926. processSlotContent(element);
  9927. processSlotOutlet(element);
  9928. processComponent(element);
  9929. for (let i = 0; i < transforms.length; i++) {
  9930. element = transforms[i](element, options) || element;
  9931. }
  9932. processAttrs(element);
  9933. return element;
  9934. }
  9935. function processKey(el) {
  9936. const exp = getBindingAttr(el, 'key');
  9937. if (exp) {
  9938. {
  9939. if (el.tag === 'template') {
  9940. warn(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  9941. }
  9942. if (el.for) {
  9943. const iterator = el.iterator2 || el.iterator1;
  9944. const parent = el.parent;
  9945. if (iterator &&
  9946. iterator === exp &&
  9947. parent &&
  9948. parent.tag === 'transition-group') {
  9949. warn(`Do not use v-for index as key on <transition-group> children, ` +
  9950. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  9951. }
  9952. }
  9953. }
  9954. el.key = exp;
  9955. }
  9956. }
  9957. function processRef(el) {
  9958. const ref = getBindingAttr(el, 'ref');
  9959. if (ref) {
  9960. el.ref = ref;
  9961. el.refInFor = checkInFor(el);
  9962. }
  9963. }
  9964. function processFor(el) {
  9965. let exp;
  9966. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9967. const res = parseFor(exp);
  9968. if (res) {
  9969. extend(el, res);
  9970. }
  9971. else {
  9972. warn(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  9973. }
  9974. }
  9975. }
  9976. function parseFor(exp) {
  9977. const inMatch = exp.match(forAliasRE);
  9978. if (!inMatch)
  9979. return;
  9980. const res = {};
  9981. res.for = inMatch[2].trim();
  9982. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9983. const iteratorMatch = alias.match(forIteratorRE);
  9984. if (iteratorMatch) {
  9985. res.alias = alias.replace(forIteratorRE, '').trim();
  9986. res.iterator1 = iteratorMatch[1].trim();
  9987. if (iteratorMatch[2]) {
  9988. res.iterator2 = iteratorMatch[2].trim();
  9989. }
  9990. }
  9991. else {
  9992. res.alias = alias;
  9993. }
  9994. return res;
  9995. }
  9996. function processIf(el) {
  9997. const exp = getAndRemoveAttr(el, 'v-if');
  9998. if (exp) {
  9999. el.if = exp;
  10000. addIfCondition(el, {
  10001. exp: exp,
  10002. block: el
  10003. });
  10004. }
  10005. else {
  10006. if (getAndRemoveAttr(el, 'v-else') != null) {
  10007. el.else = true;
  10008. }
  10009. const elseif = getAndRemoveAttr(el, 'v-else-if');
  10010. if (elseif) {
  10011. el.elseif = elseif;
  10012. }
  10013. }
  10014. }
  10015. function processIfConditions(el, parent) {
  10016. const prev = findPrevElement(parent.children);
  10017. if (prev && prev.if) {
  10018. addIfCondition(prev, {
  10019. exp: el.elseif,
  10020. block: el
  10021. });
  10022. }
  10023. else {
  10024. warn(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  10025. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  10026. }
  10027. }
  10028. function findPrevElement(children) {
  10029. let i = children.length;
  10030. while (i--) {
  10031. if (children[i].type === 1) {
  10032. return children[i];
  10033. }
  10034. else {
  10035. if (children[i].text !== ' ') {
  10036. warn(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  10037. `will be ignored.`, children[i]);
  10038. }
  10039. children.pop();
  10040. }
  10041. }
  10042. }
  10043. function addIfCondition(el, condition) {
  10044. if (!el.ifConditions) {
  10045. el.ifConditions = [];
  10046. }
  10047. el.ifConditions.push(condition);
  10048. }
  10049. function processOnce(el) {
  10050. const once = getAndRemoveAttr(el, 'v-once');
  10051. if (once != null) {
  10052. el.once = true;
  10053. }
  10054. }
  10055. // handle content being passed to a component as slot,
  10056. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  10057. function processSlotContent(el) {
  10058. let slotScope;
  10059. if (el.tag === 'template') {
  10060. slotScope = getAndRemoveAttr(el, 'scope');
  10061. /* istanbul ignore if */
  10062. if (slotScope) {
  10063. warn(`the "scope" attribute for scoped slots have been deprecated and ` +
  10064. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  10065. `can also be used on plain elements in addition to <template> to ` +
  10066. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  10067. }
  10068. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  10069. }
  10070. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  10071. /* istanbul ignore if */
  10072. if (el.attrsMap['v-for']) {
  10073. warn(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  10074. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  10075. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  10076. }
  10077. el.slotScope = slotScope;
  10078. }
  10079. // slot="xxx"
  10080. const slotTarget = getBindingAttr(el, 'slot');
  10081. if (slotTarget) {
  10082. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  10083. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  10084. // preserve slot as an attribute for native shadow DOM compat
  10085. // only for non-scoped slots.
  10086. if (el.tag !== 'template' && !el.slotScope) {
  10087. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  10088. }
  10089. }
  10090. // 2.6 v-slot syntax
  10091. {
  10092. if (el.tag === 'template') {
  10093. // v-slot on <template>
  10094. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10095. if (slotBinding) {
  10096. {
  10097. if (el.slotTarget || el.slotScope) {
  10098. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10099. }
  10100. if (el.parent && !maybeComponent(el.parent)) {
  10101. warn(`<template v-slot> can only appear at the root level inside ` +
  10102. `the receiving component`, el);
  10103. }
  10104. }
  10105. const { name, dynamic } = getSlotName(slotBinding);
  10106. el.slotTarget = name;
  10107. el.slotTargetDynamic = dynamic;
  10108. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  10109. }
  10110. }
  10111. else {
  10112. // v-slot on component, denotes default slot
  10113. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  10114. if (slotBinding) {
  10115. {
  10116. if (!maybeComponent(el)) {
  10117. warn(`v-slot can only be used on components or <template>.`, slotBinding);
  10118. }
  10119. if (el.slotScope || el.slotTarget) {
  10120. warn(`Unexpected mixed usage of different slot syntaxes.`, el);
  10121. }
  10122. if (el.scopedSlots) {
  10123. warn(`To avoid scope ambiguity, the default slot should also use ` +
  10124. `<template> syntax when there are other named slots.`, slotBinding);
  10125. }
  10126. }
  10127. // add the component's children to its default slot
  10128. const slots = el.scopedSlots || (el.scopedSlots = {});
  10129. const { name, dynamic } = getSlotName(slotBinding);
  10130. const slotContainer = (slots[name] = createASTElement('template', [], el));
  10131. slotContainer.slotTarget = name;
  10132. slotContainer.slotTargetDynamic = dynamic;
  10133. slotContainer.children = el.children.filter((c) => {
  10134. if (!c.slotScope) {
  10135. c.parent = slotContainer;
  10136. return true;
  10137. }
  10138. });
  10139. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  10140. // remove children as they are returned from scopedSlots now
  10141. el.children = [];
  10142. // mark el non-plain so data gets generated
  10143. el.plain = false;
  10144. }
  10145. }
  10146. }
  10147. }
  10148. function getSlotName(binding) {
  10149. let name = binding.name.replace(slotRE, '');
  10150. if (!name) {
  10151. if (binding.name[0] !== '#') {
  10152. name = 'default';
  10153. }
  10154. else {
  10155. warn(`v-slot shorthand syntax requires a slot name.`, binding);
  10156. }
  10157. }
  10158. return dynamicArgRE.test(name)
  10159. ? // dynamic [name]
  10160. { name: name.slice(1, -1), dynamic: true }
  10161. : // static name
  10162. { name: `"${name}"`, dynamic: false };
  10163. }
  10164. // handle <slot/> outlets
  10165. function processSlotOutlet(el) {
  10166. if (el.tag === 'slot') {
  10167. el.slotName = getBindingAttr(el, 'name');
  10168. if (el.key) {
  10169. warn(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  10170. `and can possibly expand into multiple elements. ` +
  10171. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  10172. }
  10173. }
  10174. }
  10175. function processComponent(el) {
  10176. let binding;
  10177. if ((binding = getBindingAttr(el, 'is'))) {
  10178. el.component = binding;
  10179. }
  10180. if (getAndRemoveAttr(el, 'inline-template') != null) {
  10181. el.inlineTemplate = true;
  10182. }
  10183. }
  10184. function processAttrs(el) {
  10185. const list = el.attrsList;
  10186. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  10187. for (i = 0, l = list.length; i < l; i++) {
  10188. name = rawName = list[i].name;
  10189. value = list[i].value;
  10190. if (dirRE.test(name)) {
  10191. // mark element as dynamic
  10192. el.hasBindings = true;
  10193. // modifiers
  10194. modifiers = parseModifiers(name.replace(dirRE, ''));
  10195. // support .foo shorthand syntax for the .prop modifier
  10196. if (modifiers) {
  10197. name = name.replace(modifierRE, '');
  10198. }
  10199. if (bindRE.test(name)) {
  10200. // v-bind
  10201. name = name.replace(bindRE, '');
  10202. value = parseFilters(value);
  10203. isDynamic = dynamicArgRE.test(name);
  10204. if (isDynamic) {
  10205. name = name.slice(1, -1);
  10206. }
  10207. if (value.trim().length === 0) {
  10208. warn(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  10209. }
  10210. if (modifiers) {
  10211. if (modifiers.prop && !isDynamic) {
  10212. name = camelize(name);
  10213. if (name === 'innerHtml')
  10214. name = 'innerHTML';
  10215. }
  10216. if (modifiers.camel && !isDynamic) {
  10217. name = camelize(name);
  10218. }
  10219. if (modifiers.sync) {
  10220. syncGen = genAssignmentCode(value, `$event`);
  10221. if (!isDynamic) {
  10222. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn, list[i]);
  10223. if (hyphenate(name) !== camelize(name)) {
  10224. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn, list[i]);
  10225. }
  10226. }
  10227. else {
  10228. // handler w/ dynamic event name
  10229. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn, list[i], true // dynamic
  10230. );
  10231. }
  10232. }
  10233. }
  10234. if ((modifiers && modifiers.prop) ||
  10235. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  10236. addProp(el, name, value, list[i], isDynamic);
  10237. }
  10238. else {
  10239. addAttr(el, name, value, list[i], isDynamic);
  10240. }
  10241. }
  10242. else if (onRE.test(name)) {
  10243. // v-on
  10244. name = name.replace(onRE, '');
  10245. isDynamic = dynamicArgRE.test(name);
  10246. if (isDynamic) {
  10247. name = name.slice(1, -1);
  10248. }
  10249. addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic);
  10250. }
  10251. else {
  10252. // normal directives
  10253. name = name.replace(dirRE, '');
  10254. // parse arg
  10255. const argMatch = name.match(argRE);
  10256. let arg = argMatch && argMatch[1];
  10257. isDynamic = false;
  10258. if (arg) {
  10259. name = name.slice(0, -(arg.length + 1));
  10260. if (dynamicArgRE.test(arg)) {
  10261. arg = arg.slice(1, -1);
  10262. isDynamic = true;
  10263. }
  10264. }
  10265. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  10266. if (name === 'model') {
  10267. checkForAliasModel(el, value);
  10268. }
  10269. }
  10270. }
  10271. else {
  10272. // literal attribute
  10273. {
  10274. const res = parseText(value, delimiters);
  10275. if (res) {
  10276. warn(`${name}="${value}": ` +
  10277. 'Interpolation inside attributes has been removed. ' +
  10278. 'Use v-bind or the colon shorthand instead. For example, ' +
  10279. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  10280. }
  10281. }
  10282. addAttr(el, name, JSON.stringify(value), list[i]);
  10283. // #6887 firefox doesn't update muted state if set via attribute
  10284. // even immediately after element creation
  10285. if (!el.component &&
  10286. name === 'muted' &&
  10287. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  10288. addProp(el, name, 'true', list[i]);
  10289. }
  10290. }
  10291. }
  10292. }
  10293. function checkInFor(el) {
  10294. let parent = el;
  10295. while (parent) {
  10296. if (parent.for !== undefined) {
  10297. return true;
  10298. }
  10299. parent = parent.parent;
  10300. }
  10301. return false;
  10302. }
  10303. function parseModifiers(name) {
  10304. const match = name.match(modifierRE);
  10305. if (match) {
  10306. const ret = {};
  10307. match.forEach(m => {
  10308. ret[m.slice(1)] = true;
  10309. });
  10310. return ret;
  10311. }
  10312. }
  10313. function makeAttrsMap(attrs) {
  10314. const map = {};
  10315. for (let i = 0, l = attrs.length; i < l; i++) {
  10316. if (map[attrs[i].name] && !isIE && !isEdge) {
  10317. warn('duplicate attribute: ' + attrs[i].name, attrs[i]);
  10318. }
  10319. map[attrs[i].name] = attrs[i].value;
  10320. }
  10321. return map;
  10322. }
  10323. // for script (e.g. type="x/template") or style, do not decode content
  10324. function isTextTag(el) {
  10325. return el.tag === 'script' || el.tag === 'style';
  10326. }
  10327. function isForbiddenTag(el) {
  10328. return (el.tag === 'style' ||
  10329. (el.tag === 'script' &&
  10330. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  10331. }
  10332. const ieNSBug = /^xmlns:NS\d+/;
  10333. const ieNSPrefix = /^NS\d+:/;
  10334. /* istanbul ignore next */
  10335. function guardIESVGBug(attrs) {
  10336. const res = [];
  10337. for (let i = 0; i < attrs.length; i++) {
  10338. const attr = attrs[i];
  10339. if (!ieNSBug.test(attr.name)) {
  10340. attr.name = attr.name.replace(ieNSPrefix, '');
  10341. res.push(attr);
  10342. }
  10343. }
  10344. return res;
  10345. }
  10346. function checkForAliasModel(el, value) {
  10347. let _el = el;
  10348. while (_el) {
  10349. if (_el.for && _el.alias === value) {
  10350. warn(`<${el.tag} v-model="${value}">: ` +
  10351. `You are binding v-model directly to a v-for iteration alias. ` +
  10352. `This will not be able to modify the v-for source array because ` +
  10353. `writing to the alias is like modifying a function local variable. ` +
  10354. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  10355. }
  10356. _el = _el.parent;
  10357. }
  10358. }
  10359. /**
  10360. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  10361. * Turn this:
  10362. * <input v-model="data[type]" :type="type">
  10363. * into this:
  10364. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  10365. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  10366. * <input v-else :type="type" v-model="data[type]">
  10367. */
  10368. function preTransformNode(el, options) {
  10369. if (el.tag === 'input') {
  10370. const map = el.attrsMap;
  10371. if (!map['v-model']) {
  10372. return;
  10373. }
  10374. let typeBinding;
  10375. if (map[':type'] || map['v-bind:type']) {
  10376. typeBinding = getBindingAttr(el, 'type');
  10377. }
  10378. if (!map.type && !typeBinding && map['v-bind']) {
  10379. typeBinding = `(${map['v-bind']}).type`;
  10380. }
  10381. if (typeBinding) {
  10382. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  10383. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  10384. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  10385. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  10386. // 1. checkbox
  10387. const branch0 = cloneASTElement(el);
  10388. // process for on the main node
  10389. processFor(branch0);
  10390. addRawAttr(branch0, 'type', 'checkbox');
  10391. processElement(branch0, options);
  10392. branch0.processed = true; // prevent it from double-processed
  10393. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  10394. addIfCondition(branch0, {
  10395. exp: branch0.if,
  10396. block: branch0
  10397. });
  10398. // 2. add radio else-if condition
  10399. const branch1 = cloneASTElement(el);
  10400. getAndRemoveAttr(branch1, 'v-for', true);
  10401. addRawAttr(branch1, 'type', 'radio');
  10402. processElement(branch1, options);
  10403. addIfCondition(branch0, {
  10404. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  10405. block: branch1
  10406. });
  10407. // 3. other
  10408. const branch2 = cloneASTElement(el);
  10409. getAndRemoveAttr(branch2, 'v-for', true);
  10410. addRawAttr(branch2, ':type', typeBinding);
  10411. processElement(branch2, options);
  10412. addIfCondition(branch0, {
  10413. exp: ifCondition,
  10414. block: branch2
  10415. });
  10416. if (hasElse) {
  10417. branch0.else = true;
  10418. }
  10419. else if (elseIfCondition) {
  10420. branch0.elseif = elseIfCondition;
  10421. }
  10422. return branch0;
  10423. }
  10424. }
  10425. }
  10426. function cloneASTElement(el) {
  10427. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  10428. }
  10429. var model = {
  10430. preTransformNode
  10431. };
  10432. var modules = [klass, style, model];
  10433. function text(el, dir) {
  10434. if (dir.value) {
  10435. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  10436. }
  10437. }
  10438. function html(el, dir) {
  10439. if (dir.value) {
  10440. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  10441. }
  10442. }
  10443. var directives = {
  10444. model: model$1,
  10445. text,
  10446. html
  10447. };
  10448. const baseOptions = {
  10449. expectHTML: true,
  10450. modules,
  10451. directives,
  10452. isPreTag,
  10453. isUnaryTag,
  10454. mustUseProp,
  10455. canBeLeftOpenTag,
  10456. isReservedTag,
  10457. getTagNamespace,
  10458. staticKeys: genStaticKeys$1(modules)
  10459. };
  10460. let isStaticKey;
  10461. let isPlatformReservedTag;
  10462. const genStaticKeysCached = cached(genStaticKeys);
  10463. /**
  10464. * Goal of the optimizer: walk the generated template AST tree
  10465. * and detect sub-trees that are purely static, i.e. parts of
  10466. * the DOM that never needs to change.
  10467. *
  10468. * Once we detect these sub-trees, we can:
  10469. *
  10470. * 1. Hoist them into constants, so that we no longer need to
  10471. * create fresh nodes for them on each re-render;
  10472. * 2. Completely skip them in the patching process.
  10473. */
  10474. function optimize(root, options) {
  10475. if (!root)
  10476. return;
  10477. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10478. isPlatformReservedTag = options.isReservedTag || no;
  10479. // first pass: mark all non-static nodes.
  10480. markStatic(root);
  10481. // second pass: mark static roots.
  10482. markStaticRoots(root, false);
  10483. }
  10484. function genStaticKeys(keys) {
  10485. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10486. (keys ? ',' + keys : ''));
  10487. }
  10488. function markStatic(node) {
  10489. node.static = isStatic(node);
  10490. if (node.type === 1) {
  10491. // do not make component slot content static. this avoids
  10492. // 1. components not able to mutate slot nodes
  10493. // 2. static slot content fails for hot-reloading
  10494. if (!isPlatformReservedTag(node.tag) &&
  10495. node.tag !== 'slot' &&
  10496. node.attrsMap['inline-template'] == null) {
  10497. return;
  10498. }
  10499. for (let i = 0, l = node.children.length; i < l; i++) {
  10500. const child = node.children[i];
  10501. markStatic(child);
  10502. if (!child.static) {
  10503. node.static = false;
  10504. }
  10505. }
  10506. if (node.ifConditions) {
  10507. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10508. const block = node.ifConditions[i].block;
  10509. markStatic(block);
  10510. if (!block.static) {
  10511. node.static = false;
  10512. }
  10513. }
  10514. }
  10515. }
  10516. }
  10517. function markStaticRoots(node, isInFor) {
  10518. if (node.type === 1) {
  10519. if (node.static || node.once) {
  10520. node.staticInFor = isInFor;
  10521. }
  10522. // For a node to qualify as a static root, it should have children that
  10523. // are not just static text. Otherwise the cost of hoisting out will
  10524. // outweigh the benefits and it's better off to just always render it fresh.
  10525. if (node.static &&
  10526. node.children.length &&
  10527. !(node.children.length === 1 && node.children[0].type === 3)) {
  10528. node.staticRoot = true;
  10529. return;
  10530. }
  10531. else {
  10532. node.staticRoot = false;
  10533. }
  10534. if (node.children) {
  10535. for (let i = 0, l = node.children.length; i < l; i++) {
  10536. markStaticRoots(node.children[i], isInFor || !!node.for);
  10537. }
  10538. }
  10539. if (node.ifConditions) {
  10540. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10541. markStaticRoots(node.ifConditions[i].block, isInFor);
  10542. }
  10543. }
  10544. }
  10545. }
  10546. function isStatic(node) {
  10547. if (node.type === 2) {
  10548. // expression
  10549. return false;
  10550. }
  10551. if (node.type === 3) {
  10552. // text
  10553. return true;
  10554. }
  10555. return !!(node.pre ||
  10556. (!node.hasBindings && // no dynamic bindings
  10557. !node.if &&
  10558. !node.for && // not v-if or v-for or v-else
  10559. !isBuiltInTag(node.tag) && // not a built-in
  10560. isPlatformReservedTag(node.tag) && // not a component
  10561. !isDirectChildOfTemplateFor(node) &&
  10562. Object.keys(node).every(isStaticKey)));
  10563. }
  10564. function isDirectChildOfTemplateFor(node) {
  10565. while (node.parent) {
  10566. node = node.parent;
  10567. if (node.tag !== 'template') {
  10568. return false;
  10569. }
  10570. if (node.for) {
  10571. return true;
  10572. }
  10573. }
  10574. return false;
  10575. }
  10576. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10577. const fnInvokeRE = /\([^)]*?\);*$/;
  10578. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10579. // KeyboardEvent.keyCode aliases
  10580. const keyCodes = {
  10581. esc: 27,
  10582. tab: 9,
  10583. enter: 13,
  10584. space: 32,
  10585. up: 38,
  10586. left: 37,
  10587. right: 39,
  10588. down: 40,
  10589. delete: [8, 46]
  10590. };
  10591. // KeyboardEvent.key aliases
  10592. const keyNames = {
  10593. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10594. esc: ['Esc', 'Escape'],
  10595. tab: 'Tab',
  10596. enter: 'Enter',
  10597. // #9112: IE11 uses `Spacebar` for Space key name.
  10598. space: [' ', 'Spacebar'],
  10599. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10600. up: ['Up', 'ArrowUp'],
  10601. left: ['Left', 'ArrowLeft'],
  10602. right: ['Right', 'ArrowRight'],
  10603. down: ['Down', 'ArrowDown'],
  10604. // #9112: IE11 uses `Del` for Delete key name.
  10605. delete: ['Backspace', 'Delete', 'Del']
  10606. };
  10607. // #4868: modifiers that prevent the execution of the listener
  10608. // need to explicitly return null so that we can determine whether to remove
  10609. // the listener for .once
  10610. const genGuard = condition => `if(${condition})return null;`;
  10611. const modifierCode = {
  10612. stop: '$event.stopPropagation();',
  10613. prevent: '$event.preventDefault();',
  10614. self: genGuard(`$event.target !== $event.currentTarget`),
  10615. ctrl: genGuard(`!$event.ctrlKey`),
  10616. shift: genGuard(`!$event.shiftKey`),
  10617. alt: genGuard(`!$event.altKey`),
  10618. meta: genGuard(`!$event.metaKey`),
  10619. left: genGuard(`'button' in $event && $event.button !== 0`),
  10620. middle: genGuard(`'button' in $event && $event.button !== 1`),
  10621. right: genGuard(`'button' in $event && $event.button !== 2`)
  10622. };
  10623. function genHandlers(events, isNative) {
  10624. const prefix = isNative ? 'nativeOn:' : 'on:';
  10625. let staticHandlers = ``;
  10626. let dynamicHandlers = ``;
  10627. for (const name in events) {
  10628. const handlerCode = genHandler(events[name]);
  10629. //@ts-expect-error
  10630. if (events[name] && events[name].dynamic) {
  10631. dynamicHandlers += `${name},${handlerCode},`;
  10632. }
  10633. else {
  10634. staticHandlers += `"${name}":${handlerCode},`;
  10635. }
  10636. }
  10637. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  10638. if (dynamicHandlers) {
  10639. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  10640. }
  10641. else {
  10642. return prefix + staticHandlers;
  10643. }
  10644. }
  10645. function genHandler(handler) {
  10646. if (!handler) {
  10647. return 'function(){}';
  10648. }
  10649. if (Array.isArray(handler)) {
  10650. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  10651. }
  10652. const isMethodPath = simplePathRE.test(handler.value);
  10653. const isFunctionExpression = fnExpRE.test(handler.value);
  10654. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  10655. if (!handler.modifiers) {
  10656. if (isMethodPath || isFunctionExpression) {
  10657. return handler.value;
  10658. }
  10659. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  10660. }
  10661. else {
  10662. let code = '';
  10663. let genModifierCode = '';
  10664. const keys = [];
  10665. for (const key in handler.modifiers) {
  10666. if (modifierCode[key]) {
  10667. genModifierCode += modifierCode[key];
  10668. // left/right
  10669. if (keyCodes[key]) {
  10670. keys.push(key);
  10671. }
  10672. }
  10673. else if (key === 'exact') {
  10674. const modifiers = handler.modifiers;
  10675. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  10676. .filter(keyModifier => !modifiers[keyModifier])
  10677. .map(keyModifier => `$event.${keyModifier}Key`)
  10678. .join('||'));
  10679. }
  10680. else {
  10681. keys.push(key);
  10682. }
  10683. }
  10684. if (keys.length) {
  10685. code += genKeyFilter(keys);
  10686. }
  10687. // Make sure modifiers like prevent and stop get executed after key filtering
  10688. if (genModifierCode) {
  10689. code += genModifierCode;
  10690. }
  10691. const handlerCode = isMethodPath
  10692. ? `return ${handler.value}.apply(null, arguments)`
  10693. : isFunctionExpression
  10694. ? `return (${handler.value}).apply(null, arguments)`
  10695. : isFunctionInvocation
  10696. ? `return ${handler.value}`
  10697. : handler.value;
  10698. return `function($event){${code}${handlerCode}}`;
  10699. }
  10700. }
  10701. function genKeyFilter(keys) {
  10702. return (
  10703. // make sure the key filters only apply to KeyboardEvents
  10704. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  10705. // key events that do not have keyCode property...
  10706. `if(!$event.type.indexOf('key')&&` +
  10707. `${keys.map(genFilterCode).join('&&')})return null;`);
  10708. }
  10709. function genFilterCode(key) {
  10710. const keyVal = parseInt(key, 10);
  10711. if (keyVal) {
  10712. return `$event.keyCode!==${keyVal}`;
  10713. }
  10714. const keyCode = keyCodes[key];
  10715. const keyName = keyNames[key];
  10716. return (`_k($event.keyCode,` +
  10717. `${JSON.stringify(key)},` +
  10718. `${JSON.stringify(keyCode)},` +
  10719. `$event.key,` +
  10720. `${JSON.stringify(keyName)}` +
  10721. `)`);
  10722. }
  10723. function on(el, dir) {
  10724. if (dir.modifiers) {
  10725. warn$2(`v-on without argument does not support modifiers.`);
  10726. }
  10727. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  10728. }
  10729. function bind(el, dir) {
  10730. el.wrapData = (code) => {
  10731. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  10732. };
  10733. }
  10734. var baseDirectives = {
  10735. on,
  10736. bind,
  10737. cloak: noop
  10738. };
  10739. class CodegenState {
  10740. constructor(options) {
  10741. this.options = options;
  10742. this.warn = options.warn || baseWarn;
  10743. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  10744. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  10745. this.directives = extend(extend({}, baseDirectives), options.directives);
  10746. const isReservedTag = options.isReservedTag || no;
  10747. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  10748. this.onceId = 0;
  10749. this.staticRenderFns = [];
  10750. this.pre = false;
  10751. }
  10752. }
  10753. function generate(ast, options) {
  10754. const state = new CodegenState(options);
  10755. // fix #11483, Root level <script> tags should not be rendered.
  10756. const code = ast
  10757. ? ast.tag === 'script'
  10758. ? 'null'
  10759. : genElement(ast, state)
  10760. : '_c("div")';
  10761. return {
  10762. render: `with(this){return ${code}}`,
  10763. staticRenderFns: state.staticRenderFns
  10764. };
  10765. }
  10766. function genElement(el, state) {
  10767. if (el.parent) {
  10768. el.pre = el.pre || el.parent.pre;
  10769. }
  10770. if (el.staticRoot && !el.staticProcessed) {
  10771. return genStatic(el, state);
  10772. }
  10773. else if (el.once && !el.onceProcessed) {
  10774. return genOnce(el, state);
  10775. }
  10776. else if (el.for && !el.forProcessed) {
  10777. return genFor(el, state);
  10778. }
  10779. else if (el.if && !el.ifProcessed) {
  10780. return genIf(el, state);
  10781. }
  10782. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  10783. return genChildren(el, state) || 'void 0';
  10784. }
  10785. else if (el.tag === 'slot') {
  10786. return genSlot(el, state);
  10787. }
  10788. else {
  10789. // component or element
  10790. let code;
  10791. if (el.component) {
  10792. code = genComponent(el.component, el, state);
  10793. }
  10794. else {
  10795. let data;
  10796. const maybeComponent = state.maybeComponent(el);
  10797. if (!el.plain || (el.pre && maybeComponent)) {
  10798. data = genData(el, state);
  10799. }
  10800. let tag;
  10801. // check if this is a component in <script setup>
  10802. const bindings = state.options.bindings;
  10803. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  10804. tag = checkBindingType(bindings, el.tag);
  10805. }
  10806. if (!tag)
  10807. tag = `'${el.tag}'`;
  10808. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10809. code = `_c(${tag}${data ? `,${data}` : '' // data
  10810. }${children ? `,${children}` : '' // children
  10811. })`;
  10812. }
  10813. // module transforms
  10814. for (let i = 0; i < state.transforms.length; i++) {
  10815. code = state.transforms[i](el, code);
  10816. }
  10817. return code;
  10818. }
  10819. }
  10820. function checkBindingType(bindings, key) {
  10821. const camelName = camelize(key);
  10822. const PascalName = capitalize(camelName);
  10823. const checkType = (type) => {
  10824. if (bindings[key] === type) {
  10825. return key;
  10826. }
  10827. if (bindings[camelName] === type) {
  10828. return camelName;
  10829. }
  10830. if (bindings[PascalName] === type) {
  10831. return PascalName;
  10832. }
  10833. };
  10834. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  10835. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  10836. if (fromConst) {
  10837. return fromConst;
  10838. }
  10839. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  10840. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  10841. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  10842. if (fromMaybeRef) {
  10843. return fromMaybeRef;
  10844. }
  10845. }
  10846. // hoist static sub-trees out
  10847. function genStatic(el, state) {
  10848. el.staticProcessed = true;
  10849. // Some elements (templates) need to behave differently inside of a v-pre
  10850. // node. All pre nodes are static roots, so we can use this as a location to
  10851. // wrap a state change and reset it upon exiting the pre node.
  10852. const originalPreState = state.pre;
  10853. if (el.pre) {
  10854. state.pre = el.pre;
  10855. }
  10856. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  10857. state.pre = originalPreState;
  10858. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  10859. }
  10860. // v-once
  10861. function genOnce(el, state) {
  10862. el.onceProcessed = true;
  10863. if (el.if && !el.ifProcessed) {
  10864. return genIf(el, state);
  10865. }
  10866. else if (el.staticInFor) {
  10867. let key = '';
  10868. let parent = el.parent;
  10869. while (parent) {
  10870. if (parent.for) {
  10871. key = parent.key;
  10872. break;
  10873. }
  10874. parent = parent.parent;
  10875. }
  10876. if (!key) {
  10877. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  10878. return genElement(el, state);
  10879. }
  10880. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  10881. }
  10882. else {
  10883. return genStatic(el, state);
  10884. }
  10885. }
  10886. function genIf(el, state, altGen, altEmpty) {
  10887. el.ifProcessed = true; // avoid recursion
  10888. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  10889. }
  10890. function genIfConditions(conditions, state, altGen, altEmpty) {
  10891. if (!conditions.length) {
  10892. return altEmpty || '_e()';
  10893. }
  10894. const condition = conditions.shift();
  10895. if (condition.exp) {
  10896. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  10897. }
  10898. else {
  10899. return `${genTernaryExp(condition.block)}`;
  10900. }
  10901. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10902. function genTernaryExp(el) {
  10903. return altGen
  10904. ? altGen(el, state)
  10905. : el.once
  10906. ? genOnce(el, state)
  10907. : genElement(el, state);
  10908. }
  10909. }
  10910. function genFor(el, state, altGen, altHelper) {
  10911. const exp = el.for;
  10912. const alias = el.alias;
  10913. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10914. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10915. if (state.maybeComponent(el) &&
  10916. el.tag !== 'slot' &&
  10917. el.tag !== 'template' &&
  10918. !el.key) {
  10919. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10920. `v-for should have explicit keys. ` +
  10921. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  10922. }
  10923. el.forProcessed = true; // avoid recursion
  10924. return (`${altHelper || '_l'}((${exp}),` +
  10925. `function(${alias}${iterator1}${iterator2}){` +
  10926. `return ${(altGen || genElement)(el, state)}` +
  10927. '})');
  10928. }
  10929. function genData(el, state) {
  10930. let data = '{';
  10931. // directives first.
  10932. // directives may mutate the el's other properties before they are generated.
  10933. const dirs = genDirectives(el, state);
  10934. if (dirs)
  10935. data += dirs + ',';
  10936. // key
  10937. if (el.key) {
  10938. data += `key:${el.key},`;
  10939. }
  10940. // ref
  10941. if (el.ref) {
  10942. data += `ref:${el.ref},`;
  10943. }
  10944. if (el.refInFor) {
  10945. data += `refInFor:true,`;
  10946. }
  10947. // pre
  10948. if (el.pre) {
  10949. data += `pre:true,`;
  10950. }
  10951. // record original tag name for components using "is" attribute
  10952. if (el.component) {
  10953. data += `tag:"${el.tag}",`;
  10954. }
  10955. // module data generation functions
  10956. for (let i = 0; i < state.dataGenFns.length; i++) {
  10957. data += state.dataGenFns[i](el);
  10958. }
  10959. // attributes
  10960. if (el.attrs) {
  10961. data += `attrs:${genProps(el.attrs)},`;
  10962. }
  10963. // DOM props
  10964. if (el.props) {
  10965. data += `domProps:${genProps(el.props)},`;
  10966. }
  10967. // event handlers
  10968. if (el.events) {
  10969. data += `${genHandlers(el.events, false)},`;
  10970. }
  10971. if (el.nativeEvents) {
  10972. data += `${genHandlers(el.nativeEvents, true)},`;
  10973. }
  10974. // slot target
  10975. // only for non-scoped slots
  10976. if (el.slotTarget && !el.slotScope) {
  10977. data += `slot:${el.slotTarget},`;
  10978. }
  10979. // scoped slots
  10980. if (el.scopedSlots) {
  10981. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10982. }
  10983. // component v-model
  10984. if (el.model) {
  10985. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  10986. }
  10987. // inline-template
  10988. if (el.inlineTemplate) {
  10989. const inlineTemplate = genInlineTemplate(el, state);
  10990. if (inlineTemplate) {
  10991. data += `${inlineTemplate},`;
  10992. }
  10993. }
  10994. data = data.replace(/,$/, '') + '}';
  10995. // v-bind dynamic argument wrap
  10996. // v-bind with dynamic arguments must be applied using the same v-bind object
  10997. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10998. if (el.dynamicAttrs) {
  10999. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  11000. }
  11001. // v-bind data wrap
  11002. if (el.wrapData) {
  11003. data = el.wrapData(data);
  11004. }
  11005. // v-on data wrap
  11006. if (el.wrapListeners) {
  11007. data = el.wrapListeners(data);
  11008. }
  11009. return data;
  11010. }
  11011. function genDirectives(el, state) {
  11012. const dirs = el.directives;
  11013. if (!dirs)
  11014. return;
  11015. let res = 'directives:[';
  11016. let hasRuntime = false;
  11017. let i, l, dir, needRuntime;
  11018. for (i = 0, l = dirs.length; i < l; i++) {
  11019. dir = dirs[i];
  11020. needRuntime = true;
  11021. const gen = state.directives[dir.name];
  11022. if (gen) {
  11023. // compile-time directive that manipulates AST.
  11024. // returns true if it also needs a runtime counterpart.
  11025. needRuntime = !!gen(el, dir, state.warn);
  11026. }
  11027. if (needRuntime) {
  11028. hasRuntime = true;
  11029. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11030. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11031. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11032. }
  11033. }
  11034. if (hasRuntime) {
  11035. return res.slice(0, -1) + ']';
  11036. }
  11037. }
  11038. function genInlineTemplate(el, state) {
  11039. const ast = el.children[0];
  11040. if ((el.children.length !== 1 || ast.type !== 1)) {
  11041. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11042. }
  11043. if (ast && ast.type === 1) {
  11044. const inlineRenderFns = generate(ast, state.options);
  11045. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11046. .map(code => `function(){${code}}`)
  11047. .join(',')}]}`;
  11048. }
  11049. }
  11050. function genScopedSlots(el, slots, state) {
  11051. // by default scoped slots are considered "stable", this allows child
  11052. // components with only scoped slots to skip forced updates from parent.
  11053. // but in some cases we have to bail-out of this optimization
  11054. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11055. let needsForceUpdate = el.for ||
  11056. Object.keys(slots).some(key => {
  11057. const slot = slots[key];
  11058. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11059. );
  11060. });
  11061. // #9534: if a component with scoped slots is inside a conditional branch,
  11062. // it's possible for the same component to be reused but with different
  11063. // compiled slot content. To avoid that, we generate a unique key based on
  11064. // the generated code of all the slot contents.
  11065. let needsKey = !!el.if;
  11066. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11067. // disconnected due to the intermediate scope variable)
  11068. // #9438, #9506
  11069. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11070. // and skip force updating ones that do not actually use scope variables.
  11071. if (!needsForceUpdate) {
  11072. let parent = el.parent;
  11073. while (parent) {
  11074. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11075. parent.for) {
  11076. needsForceUpdate = true;
  11077. break;
  11078. }
  11079. if (parent.if) {
  11080. needsKey = true;
  11081. }
  11082. parent = parent.parent;
  11083. }
  11084. }
  11085. const generatedSlots = Object.keys(slots)
  11086. .map(key => genScopedSlot(slots[key], state))
  11087. .join(',');
  11088. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11089. }
  11090. function hash(str) {
  11091. let hash = 5381;
  11092. let i = str.length;
  11093. while (i) {
  11094. hash = (hash * 33) ^ str.charCodeAt(--i);
  11095. }
  11096. return hash >>> 0;
  11097. }
  11098. function containsSlotChild(el) {
  11099. if (el.type === 1) {
  11100. if (el.tag === 'slot') {
  11101. return true;
  11102. }
  11103. return el.children.some(containsSlotChild);
  11104. }
  11105. return false;
  11106. }
  11107. function genScopedSlot(el, state) {
  11108. const isLegacySyntax = el.attrsMap['slot-scope'];
  11109. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11110. return genIf(el, state, genScopedSlot, `null`);
  11111. }
  11112. if (el.for && !el.forProcessed) {
  11113. return genFor(el, state, genScopedSlot);
  11114. }
  11115. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11116. const fn = `function(${slotScope}){` +
  11117. `return ${el.tag === 'template'
  11118. ? el.if && isLegacySyntax
  11119. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11120. : genChildren(el, state) || 'undefined'
  11121. : genElement(el, state)}}`;
  11122. // reverse proxy v-slot without scope on this.$slots
  11123. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11124. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11125. }
  11126. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11127. const children = el.children;
  11128. if (children.length) {
  11129. const el = children[0];
  11130. // optimize single v-for
  11131. if (children.length === 1 &&
  11132. el.for &&
  11133. el.tag !== 'template' &&
  11134. el.tag !== 'slot') {
  11135. const normalizationType = checkSkip
  11136. ? state.maybeComponent(el)
  11137. ? `,1`
  11138. : `,0`
  11139. : ``;
  11140. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11141. }
  11142. const normalizationType = checkSkip
  11143. ? getNormalizationType(children, state.maybeComponent)
  11144. : 0;
  11145. const gen = altGenNode || genNode;
  11146. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11147. }
  11148. }
  11149. // determine the normalization needed for the children array.
  11150. // 0: no normalization needed
  11151. // 1: simple normalization needed (possible 1-level deep nested array)
  11152. // 2: full normalization needed
  11153. function getNormalizationType(children, maybeComponent) {
  11154. let res = 0;
  11155. for (let i = 0; i < children.length; i++) {
  11156. const el = children[i];
  11157. if (el.type !== 1) {
  11158. continue;
  11159. }
  11160. if (needsNormalization(el) ||
  11161. (el.ifConditions &&
  11162. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11163. res = 2;
  11164. break;
  11165. }
  11166. if (maybeComponent(el) ||
  11167. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11168. res = 1;
  11169. }
  11170. }
  11171. return res;
  11172. }
  11173. function needsNormalization(el) {
  11174. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11175. }
  11176. function genNode(node, state) {
  11177. if (node.type === 1) {
  11178. return genElement(node, state);
  11179. }
  11180. else if (node.type === 3 && node.isComment) {
  11181. return genComment(node);
  11182. }
  11183. else {
  11184. return genText(node);
  11185. }
  11186. }
  11187. function genText(text) {
  11188. return `_v(${text.type === 2
  11189. ? text.expression // no need for () because already wrapped in _s()
  11190. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11191. }
  11192. function genComment(comment) {
  11193. return `_e(${JSON.stringify(comment.text)})`;
  11194. }
  11195. function genSlot(el, state) {
  11196. const slotName = el.slotName || '"default"';
  11197. const children = genChildren(el, state);
  11198. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11199. const attrs = el.attrs || el.dynamicAttrs
  11200. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11201. // slot props are camelized
  11202. name: camelize(attr.name),
  11203. value: attr.value,
  11204. dynamic: attr.dynamic
  11205. })))
  11206. : null;
  11207. const bind = el.attrsMap['v-bind'];
  11208. if ((attrs || bind) && !children) {
  11209. res += `,null`;
  11210. }
  11211. if (attrs) {
  11212. res += `,${attrs}`;
  11213. }
  11214. if (bind) {
  11215. res += `${attrs ? '' : ',null'},${bind}`;
  11216. }
  11217. return res + ')';
  11218. }
  11219. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11220. function genComponent(componentName, el, state) {
  11221. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11222. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11223. }
  11224. function genProps(props) {
  11225. let staticProps = ``;
  11226. let dynamicProps = ``;
  11227. for (let i = 0; i < props.length; i++) {
  11228. const prop = props[i];
  11229. const value = transformSpecialNewlines(prop.value);
  11230. if (prop.dynamic) {
  11231. dynamicProps += `${prop.name},${value},`;
  11232. }
  11233. else {
  11234. staticProps += `"${prop.name}":${value},`;
  11235. }
  11236. }
  11237. staticProps = `{${staticProps.slice(0, -1)}}`;
  11238. if (dynamicProps) {
  11239. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11240. }
  11241. else {
  11242. return staticProps;
  11243. }
  11244. }
  11245. // #3895, #4268
  11246. function transformSpecialNewlines(text) {
  11247. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11248. }
  11249. // these keywords should not appear inside expressions, but operators like
  11250. // typeof, instanceof and in are allowed
  11251. const prohibitedKeywordRE = new RegExp('\\b' +
  11252. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11253. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11254. 'extends,finally,continue,debugger,function,arguments')
  11255. .split(',')
  11256. .join('\\b|\\b') +
  11257. '\\b');
  11258. // these unary operators should not be used as property/method names
  11259. const unaryOperatorsRE = new RegExp('\\b' +
  11260. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11261. '\\s*\\([^\\)]*\\)');
  11262. // strip strings in expressions
  11263. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11264. // detect problematic expressions in a template
  11265. function detectErrors(ast, warn) {
  11266. if (ast) {
  11267. checkNode(ast, warn);
  11268. }
  11269. }
  11270. function checkNode(node, warn) {
  11271. if (node.type === 1) {
  11272. for (const name in node.attrsMap) {
  11273. if (dirRE.test(name)) {
  11274. const value = node.attrsMap[name];
  11275. if (value) {
  11276. const range = node.rawAttrsMap[name];
  11277. if (name === 'v-for') {
  11278. checkFor(node, `v-for="${value}"`, warn, range);
  11279. }
  11280. else if (name === 'v-slot' || name[0] === '#') {
  11281. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11282. }
  11283. else if (onRE.test(name)) {
  11284. checkEvent(value, `${name}="${value}"`, warn, range);
  11285. }
  11286. else {
  11287. checkExpression(value, `${name}="${value}"`, warn, range);
  11288. }
  11289. }
  11290. }
  11291. }
  11292. if (node.children) {
  11293. for (let i = 0; i < node.children.length; i++) {
  11294. checkNode(node.children[i], warn);
  11295. }
  11296. }
  11297. }
  11298. else if (node.type === 2) {
  11299. checkExpression(node.expression, node.text, warn, node);
  11300. }
  11301. }
  11302. function checkEvent(exp, text, warn, range) {
  11303. const stripped = exp.replace(stripStringRE, '');
  11304. const keywordMatch = stripped.match(unaryOperatorsRE);
  11305. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11306. warn(`avoid using JavaScript unary operator as property name: ` +
  11307. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11308. }
  11309. checkExpression(exp, text, warn, range);
  11310. }
  11311. function checkFor(node, text, warn, range) {
  11312. checkExpression(node.for || '', text, warn, range);
  11313. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11314. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11315. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11316. }
  11317. function checkIdentifier(ident, type, text, warn, range) {
  11318. if (typeof ident === 'string') {
  11319. try {
  11320. new Function(`var ${ident}=_`);
  11321. }
  11322. catch (e) {
  11323. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11324. }
  11325. }
  11326. }
  11327. function checkExpression(exp, text, warn, range) {
  11328. try {
  11329. new Function(`return ${exp}`);
  11330. }
  11331. catch (e) {
  11332. const keywordMatch = exp
  11333. .replace(stripStringRE, '')
  11334. .match(prohibitedKeywordRE);
  11335. if (keywordMatch) {
  11336. warn(`avoid using JavaScript keyword as property name: ` +
  11337. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11338. }
  11339. else {
  11340. warn(`invalid expression: ${e.message} in\n\n` +
  11341. ` ${exp}\n\n` +
  11342. ` Raw expression: ${text.trim()}\n`, range);
  11343. }
  11344. }
  11345. }
  11346. function checkFunctionParameterExpression(exp, text, warn, range) {
  11347. try {
  11348. new Function(exp, '');
  11349. }
  11350. catch (e) {
  11351. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11352. ` ${exp}\n\n` +
  11353. ` Raw expression: ${text.trim()}\n`, range);
  11354. }
  11355. }
  11356. const range = 2;
  11357. function generateCodeFrame(source, start = 0, end = source.length) {
  11358. const lines = source.split(/\r?\n/);
  11359. let count = 0;
  11360. const res = [];
  11361. for (let i = 0; i < lines.length; i++) {
  11362. count += lines[i].length + 1;
  11363. if (count >= start) {
  11364. for (let j = i - range; j <= i + range || end > count; j++) {
  11365. if (j < 0 || j >= lines.length)
  11366. continue;
  11367. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  11368. const lineLength = lines[j].length;
  11369. if (j === i) {
  11370. // push underline
  11371. const pad = start - (count - lineLength) + 1;
  11372. const length = end > count ? lineLength - pad : end - start;
  11373. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  11374. }
  11375. else if (j > i) {
  11376. if (end > count) {
  11377. const length = Math.min(end - count, lineLength);
  11378. res.push(` | ` + repeat(`^`, length));
  11379. }
  11380. count += lineLength + 1;
  11381. }
  11382. }
  11383. break;
  11384. }
  11385. }
  11386. return res.join('\n');
  11387. }
  11388. function repeat(str, n) {
  11389. let result = '';
  11390. if (n > 0) {
  11391. // eslint-disable-next-line no-constant-condition
  11392. while (true) {
  11393. // eslint-disable-line
  11394. if (n & 1)
  11395. result += str;
  11396. n >>>= 1;
  11397. if (n <= 0)
  11398. break;
  11399. str += str;
  11400. }
  11401. }
  11402. return result;
  11403. }
  11404. function createFunction(code, errors) {
  11405. try {
  11406. return new Function(code);
  11407. }
  11408. catch (err) {
  11409. errors.push({ err, code });
  11410. return noop;
  11411. }
  11412. }
  11413. function createCompileToFunctionFn(compile) {
  11414. const cache = Object.create(null);
  11415. return function compileToFunctions(template, options, vm) {
  11416. options = extend({}, options);
  11417. const warn = options.warn || warn$2;
  11418. delete options.warn;
  11419. /* istanbul ignore if */
  11420. {
  11421. // detect possible CSP restriction
  11422. try {
  11423. new Function('return 1');
  11424. }
  11425. catch (e) {
  11426. if (e.toString().match(/unsafe-eval|CSP/)) {
  11427. warn('It seems you are using the standalone build of Vue.js in an ' +
  11428. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11429. 'The template compiler cannot work in this environment. Consider ' +
  11430. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11431. 'templates into render functions.');
  11432. }
  11433. }
  11434. }
  11435. // check cache
  11436. const key = options.delimiters
  11437. ? String(options.delimiters) + template
  11438. : template;
  11439. if (cache[key]) {
  11440. return cache[key];
  11441. }
  11442. // compile
  11443. const compiled = compile(template, options);
  11444. // check compilation errors/tips
  11445. {
  11446. if (compiled.errors && compiled.errors.length) {
  11447. if (options.outputSourceRange) {
  11448. compiled.errors.forEach(e => {
  11449. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11450. generateCodeFrame(template, e.start, e.end), vm);
  11451. });
  11452. }
  11453. else {
  11454. warn(`Error compiling template:\n\n${template}\n\n` +
  11455. compiled.errors.map(e => `- ${e}`).join('\n') +
  11456. '\n', vm);
  11457. }
  11458. }
  11459. if (compiled.tips && compiled.tips.length) {
  11460. if (options.outputSourceRange) {
  11461. compiled.tips.forEach(e => tip(e.msg, vm));
  11462. }
  11463. else {
  11464. compiled.tips.forEach(msg => tip(msg, vm));
  11465. }
  11466. }
  11467. }
  11468. // turn code into functions
  11469. const res = {};
  11470. const fnGenErrors = [];
  11471. res.render = createFunction(compiled.render, fnGenErrors);
  11472. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11473. return createFunction(code, fnGenErrors);
  11474. });
  11475. // check function generation errors.
  11476. // this should only happen if there is a bug in the compiler itself.
  11477. // mostly for codegen development use
  11478. /* istanbul ignore if */
  11479. {
  11480. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11481. warn(`Failed to generate render function:\n\n` +
  11482. fnGenErrors
  11483. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11484. .join('\n'), vm);
  11485. }
  11486. }
  11487. return (cache[key] = res);
  11488. };
  11489. }
  11490. function createCompilerCreator(baseCompile) {
  11491. return function createCompiler(baseOptions) {
  11492. function compile(template, options) {
  11493. const finalOptions = Object.create(baseOptions);
  11494. const errors = [];
  11495. const tips = [];
  11496. let warn = (msg, range, tip) => {
  11497. (tip ? tips : errors).push(msg);
  11498. };
  11499. if (options) {
  11500. if (options.outputSourceRange) {
  11501. // $flow-disable-line
  11502. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11503. warn = (msg, range, tip) => {
  11504. const data = typeof msg === 'string' ? { msg } : msg;
  11505. if (range) {
  11506. if (range.start != null) {
  11507. data.start = range.start + leadingSpaceLength;
  11508. }
  11509. if (range.end != null) {
  11510. data.end = range.end + leadingSpaceLength;
  11511. }
  11512. }
  11513. (tip ? tips : errors).push(data);
  11514. };
  11515. }
  11516. // merge custom modules
  11517. if (options.modules) {
  11518. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11519. }
  11520. // merge custom directives
  11521. if (options.directives) {
  11522. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11523. }
  11524. // copy other options
  11525. for (const key in options) {
  11526. if (key !== 'modules' && key !== 'directives') {
  11527. finalOptions[key] = options[key];
  11528. }
  11529. }
  11530. }
  11531. finalOptions.warn = warn;
  11532. const compiled = baseCompile(template.trim(), finalOptions);
  11533. {
  11534. detectErrors(compiled.ast, warn);
  11535. }
  11536. compiled.errors = errors;
  11537. compiled.tips = tips;
  11538. return compiled;
  11539. }
  11540. return {
  11541. compile,
  11542. compileToFunctions: createCompileToFunctionFn(compile)
  11543. };
  11544. };
  11545. }
  11546. // `createCompilerCreator` allows creating compilers that use alternative
  11547. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11548. // Here we just export a default compiler using the default parts.
  11549. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  11550. const ast = parse(template.trim(), options);
  11551. if (options.optimize !== false) {
  11552. optimize(ast, options);
  11553. }
  11554. const code = generate(ast, options);
  11555. return {
  11556. ast,
  11557. render: code.render,
  11558. staticRenderFns: code.staticRenderFns
  11559. };
  11560. });
  11561. const { compile, compileToFunctions } = createCompiler(baseOptions);
  11562. // check whether current browser encodes a char inside attribute values
  11563. let div;
  11564. function getShouldDecode(href) {
  11565. div = div || document.createElement('div');
  11566. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  11567. return div.innerHTML.indexOf('&#10;') > 0;
  11568. }
  11569. // #3663: IE encodes newlines inside attribute values while other browsers don't
  11570. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  11571. // #6828: chrome encodes content in a[href]
  11572. const shouldDecodeNewlinesForHref = inBrowser
  11573. ? getShouldDecode(true)
  11574. : false;
  11575. const idToTemplate = cached(id => {
  11576. const el = query(id);
  11577. return el && el.innerHTML;
  11578. });
  11579. const mount = Vue.prototype.$mount;
  11580. Vue.prototype.$mount = function (el, hydrating) {
  11581. el = el && query(el);
  11582. /* istanbul ignore if */
  11583. if (el === document.body || el === document.documentElement) {
  11584. warn$2(`Do not mount Vue to <html> or <body> - mount to normal elements instead.`);
  11585. return this;
  11586. }
  11587. const options = this.$options;
  11588. // resolve template/el and convert to render function
  11589. if (!options.render) {
  11590. let template = options.template;
  11591. if (template) {
  11592. if (typeof template === 'string') {
  11593. if (template.charAt(0) === '#') {
  11594. template = idToTemplate(template);
  11595. /* istanbul ignore if */
  11596. if (!template) {
  11597. warn$2(`Template element not found or is empty: ${options.template}`, this);
  11598. }
  11599. }
  11600. }
  11601. else if (template.nodeType) {
  11602. template = template.innerHTML;
  11603. }
  11604. else {
  11605. {
  11606. warn$2('invalid template option:' + template, this);
  11607. }
  11608. return this;
  11609. }
  11610. }
  11611. else if (el) {
  11612. // @ts-expect-error
  11613. template = getOuterHTML(el);
  11614. }
  11615. if (template) {
  11616. /* istanbul ignore if */
  11617. if (config.performance && mark) {
  11618. mark('compile');
  11619. }
  11620. const { render, staticRenderFns } = compileToFunctions(template, {
  11621. outputSourceRange: true,
  11622. shouldDecodeNewlines,
  11623. shouldDecodeNewlinesForHref,
  11624. delimiters: options.delimiters,
  11625. comments: options.comments
  11626. }, this);
  11627. options.render = render;
  11628. options.staticRenderFns = staticRenderFns;
  11629. /* istanbul ignore if */
  11630. if (config.performance && mark) {
  11631. mark('compile end');
  11632. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  11633. }
  11634. }
  11635. }
  11636. return mount.call(this, el, hydrating);
  11637. };
  11638. /**
  11639. * Get outerHTML of elements, taking care
  11640. * of SVG elements in IE as well.
  11641. */
  11642. function getOuterHTML(el) {
  11643. if (el.outerHTML) {
  11644. return el.outerHTML;
  11645. }
  11646. else {
  11647. const container = document.createElement('div');
  11648. container.appendChild(el.cloneNode(true));
  11649. return container.innerHTML;
  11650. }
  11651. }
  11652. Vue.compile = compileToFunctions;
  11653. // export type EffectScheduler = (...args: any[]) => any
  11654. /**
  11655. * @internal since we are not exposing this in Vue 2, it's used only for
  11656. * internal testing.
  11657. */
  11658. function effect(fn, scheduler) {
  11659. const watcher = new Watcher(currentInstance, fn, noop, {
  11660. sync: true
  11661. });
  11662. if (scheduler) {
  11663. watcher.update = () => {
  11664. scheduler(() => watcher.run());
  11665. };
  11666. }
  11667. }
  11668. extend(Vue, vca);
  11669. Vue.effect = effect;
  11670. module.exports = Vue;