vue.runtime.common.dev.js 283 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698
  1. /*!
  2. * Vue.js v2.7.12
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind = 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. * Check if two values are loosely equal - that is,
  241. * if they are plain objects, do they have the same shape?
  242. */
  243. function looseEqual(a, b) {
  244. if (a === b)
  245. return true;
  246. const isObjectA = isObject(a);
  247. const isObjectB = isObject(b);
  248. if (isObjectA && isObjectB) {
  249. try {
  250. const isArrayA = Array.isArray(a);
  251. const isArrayB = Array.isArray(b);
  252. if (isArrayA && isArrayB) {
  253. return (a.length === b.length &&
  254. a.every((e, i) => {
  255. return looseEqual(e, b[i]);
  256. }));
  257. }
  258. else if (a instanceof Date && b instanceof Date) {
  259. return a.getTime() === b.getTime();
  260. }
  261. else if (!isArrayA && !isArrayB) {
  262. const keysA = Object.keys(a);
  263. const keysB = Object.keys(b);
  264. return (keysA.length === keysB.length &&
  265. keysA.every(key => {
  266. return looseEqual(a[key], b[key]);
  267. }));
  268. }
  269. else {
  270. /* istanbul ignore next */
  271. return false;
  272. }
  273. }
  274. catch (e) {
  275. /* istanbul ignore next */
  276. return false;
  277. }
  278. }
  279. else if (!isObjectA && !isObjectB) {
  280. return String(a) === String(b);
  281. }
  282. else {
  283. return false;
  284. }
  285. }
  286. /**
  287. * Return the first index at which a loosely equal value can be
  288. * found in the array (if value is a plain object, the array must
  289. * contain an object of the same shape), or -1 if it is not present.
  290. */
  291. function looseIndexOf(arr, val) {
  292. for (let i = 0; i < arr.length; i++) {
  293. if (looseEqual(arr[i], val))
  294. return i;
  295. }
  296. return -1;
  297. }
  298. /**
  299. * Ensure a function is called only once.
  300. */
  301. function once(fn) {
  302. let called = false;
  303. return function () {
  304. if (!called) {
  305. called = true;
  306. fn.apply(this, arguments);
  307. }
  308. };
  309. }
  310. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  311. function hasChanged(x, y) {
  312. if (x === y) {
  313. return x === 0 && 1 / x !== 1 / y;
  314. }
  315. else {
  316. return x === x || y === y;
  317. }
  318. }
  319. const SSR_ATTR = 'data-server-rendered';
  320. const ASSET_TYPES = ['component', 'directive', 'filter'];
  321. const LIFECYCLE_HOOKS = [
  322. 'beforeCreate',
  323. 'created',
  324. 'beforeMount',
  325. 'mounted',
  326. 'beforeUpdate',
  327. 'updated',
  328. 'beforeDestroy',
  329. 'destroyed',
  330. 'activated',
  331. 'deactivated',
  332. 'errorCaptured',
  333. 'serverPrefetch',
  334. 'renderTracked',
  335. 'renderTriggered'
  336. ];
  337. var config = {
  338. /**
  339. * Option merge strategies (used in core/util/options)
  340. */
  341. // $flow-disable-line
  342. optionMergeStrategies: Object.create(null),
  343. /**
  344. * Whether to suppress warnings.
  345. */
  346. silent: false,
  347. /**
  348. * Show production mode tip message on boot?
  349. */
  350. productionTip: true,
  351. /**
  352. * Whether to enable devtools
  353. */
  354. devtools: true,
  355. /**
  356. * Whether to record perf
  357. */
  358. performance: false,
  359. /**
  360. * Error handler for watcher errors
  361. */
  362. errorHandler: null,
  363. /**
  364. * Warn handler for watcher warns
  365. */
  366. warnHandler: null,
  367. /**
  368. * Ignore certain custom elements
  369. */
  370. ignoredElements: [],
  371. /**
  372. * Custom user key aliases for v-on
  373. */
  374. // $flow-disable-line
  375. keyCodes: Object.create(null),
  376. /**
  377. * Check if a tag is reserved so that it cannot be registered as a
  378. * component. This is platform-dependent and may be overwritten.
  379. */
  380. isReservedTag: no,
  381. /**
  382. * Check if an attribute is reserved so that it cannot be used as a component
  383. * prop. This is platform-dependent and may be overwritten.
  384. */
  385. isReservedAttr: no,
  386. /**
  387. * Check if a tag is an unknown element.
  388. * Platform-dependent.
  389. */
  390. isUnknownElement: no,
  391. /**
  392. * Get the namespace of an element
  393. */
  394. getTagNamespace: noop,
  395. /**
  396. * Parse the real tag name for the specific platform.
  397. */
  398. parsePlatformTagName: identity,
  399. /**
  400. * Check if an attribute must be bound using property, e.g. value
  401. * Platform-dependent.
  402. */
  403. mustUseProp: no,
  404. /**
  405. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  406. * This will significantly reduce performance if set to false.
  407. */
  408. async: true,
  409. /**
  410. * Exposed for legacy reasons
  411. */
  412. _lifecycleHooks: LIFECYCLE_HOOKS
  413. };
  414. /**
  415. * unicode letters used for parsing html tags, component names and property paths.
  416. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  417. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  418. */
  419. 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/;
  420. /**
  421. * Check if a string starts with $ or _
  422. */
  423. function isReserved(str) {
  424. const c = (str + '').charCodeAt(0);
  425. return c === 0x24 || c === 0x5f;
  426. }
  427. /**
  428. * Define a property.
  429. */
  430. function def(obj, key, val, enumerable) {
  431. Object.defineProperty(obj, key, {
  432. value: val,
  433. enumerable: !!enumerable,
  434. writable: true,
  435. configurable: true
  436. });
  437. }
  438. /**
  439. * Parse simple path.
  440. */
  441. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  442. function parsePath(path) {
  443. if (bailRE.test(path)) {
  444. return;
  445. }
  446. const segments = path.split('.');
  447. return function (obj) {
  448. for (let i = 0; i < segments.length; i++) {
  449. if (!obj)
  450. return;
  451. obj = obj[segments[i]];
  452. }
  453. return obj;
  454. };
  455. }
  456. // can we use __proto__?
  457. const hasProto = '__proto__' in {};
  458. // Browser environment sniffing
  459. const inBrowser = typeof window !== 'undefined';
  460. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  461. const isIE = UA && /msie|trident/.test(UA);
  462. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  463. const isEdge = UA && UA.indexOf('edge/') > 0;
  464. UA && UA.indexOf('android') > 0;
  465. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  466. UA && /chrome\/\d+/.test(UA) && !isEdge;
  467. UA && /phantomjs/.test(UA);
  468. const isFF = UA && UA.match(/firefox\/(\d+)/);
  469. // Firefox has a "watch" function on Object.prototype...
  470. // @ts-expect-error firebox support
  471. const nativeWatch = {}.watch;
  472. let supportsPassive = false;
  473. if (inBrowser) {
  474. try {
  475. const opts = {};
  476. Object.defineProperty(opts, 'passive', {
  477. get() {
  478. /* istanbul ignore next */
  479. supportsPassive = true;
  480. }
  481. }); // https://github.com/facebook/flow/issues/285
  482. window.addEventListener('test-passive', null, opts);
  483. }
  484. catch (e) { }
  485. }
  486. // this needs to be lazy-evaled because vue may be required before
  487. // vue-server-renderer can set VUE_ENV
  488. let _isServer;
  489. const isServerRendering = () => {
  490. if (_isServer === undefined) {
  491. /* istanbul ignore if */
  492. if (!inBrowser && typeof global !== 'undefined') {
  493. // detect presence of vue-server-renderer and avoid
  494. // Webpack shimming the process
  495. _isServer =
  496. global['process'] && global['process'].env.VUE_ENV === 'server';
  497. }
  498. else {
  499. _isServer = false;
  500. }
  501. }
  502. return _isServer;
  503. };
  504. // detect devtools
  505. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  506. /* istanbul ignore next */
  507. function isNative(Ctor) {
  508. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  509. }
  510. const hasSymbol = typeof Symbol !== 'undefined' &&
  511. isNative(Symbol) &&
  512. typeof Reflect !== 'undefined' &&
  513. isNative(Reflect.ownKeys);
  514. let _Set; // $flow-disable-line
  515. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  516. // use native Set when available.
  517. _Set = Set;
  518. }
  519. else {
  520. // a non-standard Set polyfill that only works with primitive keys.
  521. _Set = class Set {
  522. constructor() {
  523. this.set = Object.create(null);
  524. }
  525. has(key) {
  526. return this.set[key] === true;
  527. }
  528. add(key) {
  529. this.set[key] = true;
  530. }
  531. clear() {
  532. this.set = Object.create(null);
  533. }
  534. };
  535. }
  536. let currentInstance = null;
  537. /**
  538. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  539. * relies on it). Do not use this internally, just use `currentInstance`.
  540. *
  541. * @internal this function needs manual type declaration because it relies
  542. * on previously manually authored types from Vue 2
  543. */
  544. function getCurrentInstance() {
  545. return currentInstance && { proxy: currentInstance };
  546. }
  547. /**
  548. * @internal
  549. */
  550. function setCurrentInstance(vm = null) {
  551. if (!vm)
  552. currentInstance && currentInstance._scope.off();
  553. currentInstance = vm;
  554. vm && vm._scope.on();
  555. }
  556. /**
  557. * @internal
  558. */
  559. class VNode {
  560. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  561. this.tag = tag;
  562. this.data = data;
  563. this.children = children;
  564. this.text = text;
  565. this.elm = elm;
  566. this.ns = undefined;
  567. this.context = context;
  568. this.fnContext = undefined;
  569. this.fnOptions = undefined;
  570. this.fnScopeId = undefined;
  571. this.key = data && data.key;
  572. this.componentOptions = componentOptions;
  573. this.componentInstance = undefined;
  574. this.parent = undefined;
  575. this.raw = false;
  576. this.isStatic = false;
  577. this.isRootInsert = true;
  578. this.isComment = false;
  579. this.isCloned = false;
  580. this.isOnce = false;
  581. this.asyncFactory = asyncFactory;
  582. this.asyncMeta = undefined;
  583. this.isAsyncPlaceholder = false;
  584. }
  585. // DEPRECATED: alias for componentInstance for backwards compat.
  586. /* istanbul ignore next */
  587. get child() {
  588. return this.componentInstance;
  589. }
  590. }
  591. const createEmptyVNode = (text = '') => {
  592. const node = new VNode();
  593. node.text = text;
  594. node.isComment = true;
  595. return node;
  596. };
  597. function createTextVNode(val) {
  598. return new VNode(undefined, undefined, undefined, String(val));
  599. }
  600. // optimized shallow clone
  601. // used for static nodes and slot nodes because they may be reused across
  602. // multiple renders, cloning them avoids errors when DOM manipulations rely
  603. // on their elm reference.
  604. function cloneVNode(vnode) {
  605. const cloned = new VNode(vnode.tag, vnode.data,
  606. // #7975
  607. // clone children array to avoid mutating original in case of cloning
  608. // a child.
  609. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  610. cloned.ns = vnode.ns;
  611. cloned.isStatic = vnode.isStatic;
  612. cloned.key = vnode.key;
  613. cloned.isComment = vnode.isComment;
  614. cloned.fnContext = vnode.fnContext;
  615. cloned.fnOptions = vnode.fnOptions;
  616. cloned.fnScopeId = vnode.fnScopeId;
  617. cloned.asyncMeta = vnode.asyncMeta;
  618. cloned.isCloned = true;
  619. return cloned;
  620. }
  621. let uid$2 = 0;
  622. const pendingCleanupDeps = [];
  623. const cleanupDeps = () => {
  624. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  625. const dep = pendingCleanupDeps[i];
  626. dep.subs = dep.subs.filter(s => s);
  627. dep._pending = false;
  628. }
  629. pendingCleanupDeps.length = 0;
  630. };
  631. /**
  632. * A dep is an observable that can have multiple
  633. * directives subscribing to it.
  634. * @internal
  635. */
  636. class Dep {
  637. constructor() {
  638. // pending subs cleanup
  639. this._pending = false;
  640. this.id = uid$2++;
  641. this.subs = [];
  642. }
  643. addSub(sub) {
  644. this.subs.push(sub);
  645. }
  646. removeSub(sub) {
  647. // #12696 deps with massive amount of subscribers are extremely slow to
  648. // clean up in Chromium
  649. // to workaround this, we unset the sub for now, and clear them on
  650. // next scheduler flush.
  651. this.subs[this.subs.indexOf(sub)] = null;
  652. if (!this._pending) {
  653. this._pending = true;
  654. pendingCleanupDeps.push(this);
  655. }
  656. }
  657. depend(info) {
  658. if (Dep.target) {
  659. Dep.target.addDep(this);
  660. if (info && Dep.target.onTrack) {
  661. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  662. }
  663. }
  664. }
  665. notify(info) {
  666. // stabilize the subscriber list first
  667. const subs = this.subs.filter(s => s);
  668. if (!config.async) {
  669. // subs aren't sorted in scheduler if not running async
  670. // we need to sort them now to make sure they fire in correct
  671. // order
  672. subs.sort((a, b) => a.id - b.id);
  673. }
  674. for (let i = 0, l = subs.length; i < l; i++) {
  675. const sub = subs[i];
  676. if (info) {
  677. sub.onTrigger &&
  678. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  679. }
  680. sub.update();
  681. }
  682. }
  683. }
  684. // The current target watcher being evaluated.
  685. // This is globally unique because only one watcher
  686. // can be evaluated at a time.
  687. Dep.target = null;
  688. const targetStack = [];
  689. function pushTarget(target) {
  690. targetStack.push(target);
  691. Dep.target = target;
  692. }
  693. function popTarget() {
  694. targetStack.pop();
  695. Dep.target = targetStack[targetStack.length - 1];
  696. }
  697. /*
  698. * not type checking this file because flow doesn't play well with
  699. * dynamically accessing methods on Array prototype
  700. */
  701. const arrayProto = Array.prototype;
  702. const arrayMethods = Object.create(arrayProto);
  703. const methodsToPatch = [
  704. 'push',
  705. 'pop',
  706. 'shift',
  707. 'unshift',
  708. 'splice',
  709. 'sort',
  710. 'reverse'
  711. ];
  712. /**
  713. * Intercept mutating methods and emit events
  714. */
  715. methodsToPatch.forEach(function (method) {
  716. // cache original method
  717. const original = arrayProto[method];
  718. def(arrayMethods, method, function mutator(...args) {
  719. const result = original.apply(this, args);
  720. const ob = this.__ob__;
  721. let inserted;
  722. switch (method) {
  723. case 'push':
  724. case 'unshift':
  725. inserted = args;
  726. break;
  727. case 'splice':
  728. inserted = args.slice(2);
  729. break;
  730. }
  731. if (inserted)
  732. ob.observeArray(inserted);
  733. // notify change
  734. {
  735. ob.dep.notify({
  736. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  737. target: this,
  738. key: method
  739. });
  740. }
  741. return result;
  742. });
  743. });
  744. const rawMap = new WeakMap();
  745. function reactive(target) {
  746. makeReactive(target, false);
  747. return target;
  748. }
  749. /**
  750. * Return a shallowly-reactive copy of the original object, where only the root
  751. * level properties are reactive. It also does not auto-unwrap refs (even at the
  752. * root level).
  753. */
  754. function shallowReactive(target) {
  755. makeReactive(target, true);
  756. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  757. return target;
  758. }
  759. function makeReactive(target, shallow) {
  760. // if trying to observe a readonly proxy, return the readonly version.
  761. if (!isReadonly(target)) {
  762. {
  763. if (isArray(target)) {
  764. warn(`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.`);
  765. }
  766. const existingOb = target && target.__ob__;
  767. if (existingOb && existingOb.shallow !== shallow) {
  768. warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  769. }
  770. }
  771. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  772. if (!ob) {
  773. if (target == null || isPrimitive(target)) {
  774. warn(`value cannot be made reactive: ${String(target)}`);
  775. }
  776. if (isCollectionType(target)) {
  777. warn(`Vue 2 does not support reactive collection types such as Map or Set.`);
  778. }
  779. }
  780. }
  781. }
  782. function isReactive(value) {
  783. if (isReadonly(value)) {
  784. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  785. }
  786. return !!(value && value.__ob__);
  787. }
  788. function isShallow(value) {
  789. return !!(value && value.__v_isShallow);
  790. }
  791. function isReadonly(value) {
  792. return !!(value && value.__v_isReadonly);
  793. }
  794. function isProxy(value) {
  795. return isReactive(value) || isReadonly(value);
  796. }
  797. function toRaw(observed) {
  798. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  799. return raw ? toRaw(raw) : observed;
  800. }
  801. function markRaw(value) {
  802. if (isObject(value)) {
  803. rawMap.set(value, true);
  804. }
  805. return value;
  806. }
  807. /**
  808. * @internal
  809. */
  810. function isCollectionType(value) {
  811. const type = toRawType(value);
  812. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  813. }
  814. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  815. const NO_INIITIAL_VALUE = {};
  816. /**
  817. * In some cases we may want to disable observation inside a component's
  818. * update computation.
  819. */
  820. let shouldObserve = true;
  821. function toggleObserving(value) {
  822. shouldObserve = value;
  823. }
  824. // ssr mock dep
  825. const mockDep = {
  826. notify: noop,
  827. depend: noop,
  828. addSub: noop,
  829. removeSub: noop
  830. };
  831. /**
  832. * Observer class that is attached to each observed
  833. * object. Once attached, the observer converts the target
  834. * object's property keys into getter/setters that
  835. * collect dependencies and dispatch updates.
  836. */
  837. class Observer {
  838. constructor(value, shallow = false, mock = false) {
  839. this.value = value;
  840. this.shallow = shallow;
  841. this.mock = mock;
  842. // this.value = value
  843. this.dep = mock ? mockDep : new Dep();
  844. this.vmCount = 0;
  845. def(value, '__ob__', this);
  846. if (isArray(value)) {
  847. if (!mock) {
  848. if (hasProto) {
  849. value.__proto__ = arrayMethods;
  850. /* eslint-enable no-proto */
  851. }
  852. else {
  853. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  854. const key = arrayKeys[i];
  855. def(value, key, arrayMethods[key]);
  856. }
  857. }
  858. }
  859. if (!shallow) {
  860. this.observeArray(value);
  861. }
  862. }
  863. else {
  864. /**
  865. * Walk through all properties and convert them into
  866. * getter/setters. This method should only be called when
  867. * value type is Object.
  868. */
  869. const keys = Object.keys(value);
  870. for (let i = 0; i < keys.length; i++) {
  871. const key = keys[i];
  872. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  873. }
  874. }
  875. }
  876. /**
  877. * Observe a list of Array items.
  878. */
  879. observeArray(value) {
  880. for (let i = 0, l = value.length; i < l; i++) {
  881. observe(value[i], false, this.mock);
  882. }
  883. }
  884. }
  885. // helpers
  886. /**
  887. * Attempt to create an observer instance for a value,
  888. * returns the new observer if successfully observed,
  889. * or the existing observer if the value already has one.
  890. */
  891. function observe(value, shallow, ssrMockReactivity) {
  892. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  893. return value.__ob__;
  894. }
  895. if (shouldObserve &&
  896. (ssrMockReactivity || !isServerRendering()) &&
  897. (isArray(value) || isPlainObject(value)) &&
  898. Object.isExtensible(value) &&
  899. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  900. !rawMap.has(value) &&
  901. !isRef(value) &&
  902. !(value instanceof VNode)) {
  903. return new Observer(value, shallow, ssrMockReactivity);
  904. }
  905. }
  906. /**
  907. * Define a reactive property on an Object.
  908. */
  909. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  910. const dep = new Dep();
  911. const property = Object.getOwnPropertyDescriptor(obj, key);
  912. if (property && property.configurable === false) {
  913. return;
  914. }
  915. // cater for pre-defined getter/setters
  916. const getter = property && property.get;
  917. const setter = property && property.set;
  918. if ((!getter || setter) &&
  919. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  920. val = obj[key];
  921. }
  922. let childOb = !shallow && observe(val, false, mock);
  923. Object.defineProperty(obj, key, {
  924. enumerable: true,
  925. configurable: true,
  926. get: function reactiveGetter() {
  927. const value = getter ? getter.call(obj) : val;
  928. if (Dep.target) {
  929. {
  930. dep.depend({
  931. target: obj,
  932. type: "get" /* TrackOpTypes.GET */,
  933. key
  934. });
  935. }
  936. if (childOb) {
  937. childOb.dep.depend();
  938. if (isArray(value)) {
  939. dependArray(value);
  940. }
  941. }
  942. }
  943. return isRef(value) && !shallow ? value.value : value;
  944. },
  945. set: function reactiveSetter(newVal) {
  946. const value = getter ? getter.call(obj) : val;
  947. if (!hasChanged(value, newVal)) {
  948. return;
  949. }
  950. if (customSetter) {
  951. customSetter();
  952. }
  953. if (setter) {
  954. setter.call(obj, newVal);
  955. }
  956. else if (getter) {
  957. // #7981: for accessor properties without setter
  958. return;
  959. }
  960. else if (!shallow && isRef(value) && !isRef(newVal)) {
  961. value.value = newVal;
  962. return;
  963. }
  964. else {
  965. val = newVal;
  966. }
  967. childOb = !shallow && observe(newVal, false, mock);
  968. {
  969. dep.notify({
  970. type: "set" /* TriggerOpTypes.SET */,
  971. target: obj,
  972. key,
  973. newValue: newVal,
  974. oldValue: value
  975. });
  976. }
  977. }
  978. });
  979. return dep;
  980. }
  981. function set(target, key, val) {
  982. if ((isUndef(target) || isPrimitive(target))) {
  983. warn(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  984. }
  985. if (isReadonly(target)) {
  986. warn(`Set operation on key "${key}" failed: target is readonly.`);
  987. return;
  988. }
  989. const ob = target.__ob__;
  990. if (isArray(target) && isValidArrayIndex(key)) {
  991. target.length = Math.max(target.length, key);
  992. target.splice(key, 1, val);
  993. // when mocking for SSR, array methods are not hijacked
  994. if (ob && !ob.shallow && ob.mock) {
  995. observe(val, false, true);
  996. }
  997. return val;
  998. }
  999. if (key in target && !(key in Object.prototype)) {
  1000. target[key] = val;
  1001. return val;
  1002. }
  1003. if (target._isVue || (ob && ob.vmCount)) {
  1004. warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
  1005. 'at runtime - declare it upfront in the data option.');
  1006. return val;
  1007. }
  1008. if (!ob) {
  1009. target[key] = val;
  1010. return val;
  1011. }
  1012. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  1013. {
  1014. ob.dep.notify({
  1015. type: "add" /* TriggerOpTypes.ADD */,
  1016. target: target,
  1017. key,
  1018. newValue: val,
  1019. oldValue: undefined
  1020. });
  1021. }
  1022. return val;
  1023. }
  1024. function del(target, key) {
  1025. if ((isUndef(target) || isPrimitive(target))) {
  1026. warn(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  1027. }
  1028. if (isArray(target) && isValidArrayIndex(key)) {
  1029. target.splice(key, 1);
  1030. return;
  1031. }
  1032. const ob = target.__ob__;
  1033. if (target._isVue || (ob && ob.vmCount)) {
  1034. warn('Avoid deleting properties on a Vue instance or its root $data ' +
  1035. '- just set it to null.');
  1036. return;
  1037. }
  1038. if (isReadonly(target)) {
  1039. warn(`Delete operation on key "${key}" failed: target is readonly.`);
  1040. return;
  1041. }
  1042. if (!hasOwn(target, key)) {
  1043. return;
  1044. }
  1045. delete target[key];
  1046. if (!ob) {
  1047. return;
  1048. }
  1049. {
  1050. ob.dep.notify({
  1051. type: "delete" /* TriggerOpTypes.DELETE */,
  1052. target: target,
  1053. key
  1054. });
  1055. }
  1056. }
  1057. /**
  1058. * Collect dependencies on array elements when the array is touched, since
  1059. * we cannot intercept array element access like property getters.
  1060. */
  1061. function dependArray(value) {
  1062. for (let e, i = 0, l = value.length; i < l; i++) {
  1063. e = value[i];
  1064. if (e && e.__ob__) {
  1065. e.__ob__.dep.depend();
  1066. }
  1067. if (isArray(e)) {
  1068. dependArray(e);
  1069. }
  1070. }
  1071. }
  1072. /**
  1073. * @internal
  1074. */
  1075. const RefFlag = `__v_isRef`;
  1076. function isRef(r) {
  1077. return !!(r && r.__v_isRef === true);
  1078. }
  1079. function ref$1(value) {
  1080. return createRef(value, false);
  1081. }
  1082. function shallowRef(value) {
  1083. return createRef(value, true);
  1084. }
  1085. function createRef(rawValue, shallow) {
  1086. if (isRef(rawValue)) {
  1087. return rawValue;
  1088. }
  1089. const ref = {};
  1090. def(ref, RefFlag, true);
  1091. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1092. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1093. return ref;
  1094. }
  1095. function triggerRef(ref) {
  1096. if (!ref.dep) {
  1097. warn(`received object is not a triggerable ref.`);
  1098. }
  1099. {
  1100. ref.dep &&
  1101. ref.dep.notify({
  1102. type: "set" /* TriggerOpTypes.SET */,
  1103. target: ref,
  1104. key: 'value'
  1105. });
  1106. }
  1107. }
  1108. function unref(ref) {
  1109. return isRef(ref) ? ref.value : ref;
  1110. }
  1111. function proxyRefs(objectWithRefs) {
  1112. if (isReactive(objectWithRefs)) {
  1113. return objectWithRefs;
  1114. }
  1115. const proxy = {};
  1116. const keys = Object.keys(objectWithRefs);
  1117. for (let i = 0; i < keys.length; i++) {
  1118. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1119. }
  1120. return proxy;
  1121. }
  1122. function proxyWithRefUnwrap(target, source, key) {
  1123. Object.defineProperty(target, key, {
  1124. enumerable: true,
  1125. configurable: true,
  1126. get: () => {
  1127. const val = source[key];
  1128. if (isRef(val)) {
  1129. return val.value;
  1130. }
  1131. else {
  1132. const ob = val && val.__ob__;
  1133. if (ob)
  1134. ob.dep.depend();
  1135. return val;
  1136. }
  1137. },
  1138. set: value => {
  1139. const oldValue = source[key];
  1140. if (isRef(oldValue) && !isRef(value)) {
  1141. oldValue.value = value;
  1142. }
  1143. else {
  1144. source[key] = value;
  1145. }
  1146. }
  1147. });
  1148. }
  1149. function customRef(factory) {
  1150. const dep = new Dep();
  1151. const { get, set } = factory(() => {
  1152. {
  1153. dep.depend({
  1154. target: ref,
  1155. type: "get" /* TrackOpTypes.GET */,
  1156. key: 'value'
  1157. });
  1158. }
  1159. }, () => {
  1160. {
  1161. dep.notify({
  1162. target: ref,
  1163. type: "set" /* TriggerOpTypes.SET */,
  1164. key: 'value'
  1165. });
  1166. }
  1167. });
  1168. const ref = {
  1169. get value() {
  1170. return get();
  1171. },
  1172. set value(newVal) {
  1173. set(newVal);
  1174. }
  1175. };
  1176. def(ref, RefFlag, true);
  1177. return ref;
  1178. }
  1179. function toRefs(object) {
  1180. if (!isReactive(object)) {
  1181. warn(`toRefs() expects a reactive object but received a plain one.`);
  1182. }
  1183. const ret = isArray(object) ? new Array(object.length) : {};
  1184. for (const key in object) {
  1185. ret[key] = toRef(object, key);
  1186. }
  1187. return ret;
  1188. }
  1189. function toRef(object, key, defaultValue) {
  1190. const val = object[key];
  1191. if (isRef(val)) {
  1192. return val;
  1193. }
  1194. const ref = {
  1195. get value() {
  1196. const val = object[key];
  1197. return val === undefined ? defaultValue : val;
  1198. },
  1199. set value(newVal) {
  1200. object[key] = newVal;
  1201. }
  1202. };
  1203. def(ref, RefFlag, true);
  1204. return ref;
  1205. }
  1206. const rawToReadonlyMap = new WeakMap();
  1207. const rawToShallowReadonlyMap = new WeakMap();
  1208. function readonly(target) {
  1209. return createReadonly(target, false);
  1210. }
  1211. function createReadonly(target, shallow) {
  1212. if (!isPlainObject(target)) {
  1213. {
  1214. if (isArray(target)) {
  1215. warn(`Vue 2 does not support readonly arrays.`);
  1216. }
  1217. else if (isCollectionType(target)) {
  1218. warn(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1219. }
  1220. else {
  1221. warn(`value cannot be made readonly: ${typeof target}`);
  1222. }
  1223. }
  1224. return target;
  1225. }
  1226. // already a readonly object
  1227. if (isReadonly(target)) {
  1228. return target;
  1229. }
  1230. // already has a readonly proxy
  1231. const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap;
  1232. const existingProxy = map.get(target);
  1233. if (existingProxy) {
  1234. return existingProxy;
  1235. }
  1236. const proxy = Object.create(Object.getPrototypeOf(target));
  1237. map.set(target, proxy);
  1238. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1239. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1240. if (isRef(target)) {
  1241. def(proxy, RefFlag, true);
  1242. }
  1243. if (shallow || isShallow(target)) {
  1244. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1245. }
  1246. const keys = Object.keys(target);
  1247. for (let i = 0; i < keys.length; i++) {
  1248. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1249. }
  1250. return proxy;
  1251. }
  1252. function defineReadonlyProperty(proxy, target, key, shallow) {
  1253. Object.defineProperty(proxy, key, {
  1254. enumerable: true,
  1255. configurable: true,
  1256. get() {
  1257. const val = target[key];
  1258. return shallow || !isPlainObject(val) ? val : readonly(val);
  1259. },
  1260. set() {
  1261. warn(`Set operation on key "${key}" failed: target is readonly.`);
  1262. }
  1263. });
  1264. }
  1265. /**
  1266. * Returns a reactive-copy of the original object, where only the root level
  1267. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1268. * returned properties.
  1269. * This is used for creating the props proxy object for stateful components.
  1270. */
  1271. function shallowReadonly(target) {
  1272. return createReadonly(target, true);
  1273. }
  1274. function computed(getterOrOptions, debugOptions) {
  1275. let getter;
  1276. let setter;
  1277. const onlyGetter = isFunction(getterOrOptions);
  1278. if (onlyGetter) {
  1279. getter = getterOrOptions;
  1280. setter = () => {
  1281. warn('Write operation failed: computed value is readonly');
  1282. }
  1283. ;
  1284. }
  1285. else {
  1286. getter = getterOrOptions.get;
  1287. setter = getterOrOptions.set;
  1288. }
  1289. const watcher = isServerRendering()
  1290. ? null
  1291. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1292. if (watcher && debugOptions) {
  1293. watcher.onTrack = debugOptions.onTrack;
  1294. watcher.onTrigger = debugOptions.onTrigger;
  1295. }
  1296. const ref = {
  1297. // some libs rely on the presence effect for checking computed refs
  1298. // from normal refs, but the implementation doesn't matter
  1299. effect: watcher,
  1300. get value() {
  1301. if (watcher) {
  1302. if (watcher.dirty) {
  1303. watcher.evaluate();
  1304. }
  1305. if (Dep.target) {
  1306. if (Dep.target.onTrack) {
  1307. Dep.target.onTrack({
  1308. effect: Dep.target,
  1309. target: ref,
  1310. type: "get" /* TrackOpTypes.GET */,
  1311. key: 'value'
  1312. });
  1313. }
  1314. watcher.depend();
  1315. }
  1316. return watcher.value;
  1317. }
  1318. else {
  1319. return getter();
  1320. }
  1321. },
  1322. set value(newVal) {
  1323. setter(newVal);
  1324. }
  1325. };
  1326. def(ref, RefFlag, true);
  1327. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1328. return ref;
  1329. }
  1330. const WATCHER = `watcher`;
  1331. const WATCHER_CB = `${WATCHER} callback`;
  1332. const WATCHER_GETTER = `${WATCHER} getter`;
  1333. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  1334. // Simple effect.
  1335. function watchEffect(effect, options) {
  1336. return doWatch(effect, null, options);
  1337. }
  1338. function watchPostEffect(effect, options) {
  1339. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  1340. }
  1341. function watchSyncEffect(effect, options) {
  1342. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  1343. }
  1344. // initial value for watchers to trigger on undefined initial values
  1345. const INITIAL_WATCHER_VALUE = {};
  1346. // implementation
  1347. function watch(source, cb, options) {
  1348. if (typeof cb !== 'function') {
  1349. warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  1350. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  1351. `supports \`watch(source, cb, options?) signature.`);
  1352. }
  1353. return doWatch(source, cb, options);
  1354. }
  1355. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  1356. if (!cb) {
  1357. if (immediate !== undefined) {
  1358. warn(`watch() "immediate" option is only respected when using the ` +
  1359. `watch(source, callback, options?) signature.`);
  1360. }
  1361. if (deep !== undefined) {
  1362. warn(`watch() "deep" option is only respected when using the ` +
  1363. `watch(source, callback, options?) signature.`);
  1364. }
  1365. }
  1366. const warnInvalidSource = (s) => {
  1367. warn(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  1368. `function, a ref, a reactive object, or an array of these types.`);
  1369. };
  1370. const instance = currentInstance;
  1371. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  1372. let getter;
  1373. let forceTrigger = false;
  1374. let isMultiSource = false;
  1375. if (isRef(source)) {
  1376. getter = () => source.value;
  1377. forceTrigger = isShallow(source);
  1378. }
  1379. else if (isReactive(source)) {
  1380. getter = () => {
  1381. source.__ob__.dep.depend();
  1382. return source;
  1383. };
  1384. deep = true;
  1385. }
  1386. else if (isArray(source)) {
  1387. isMultiSource = true;
  1388. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  1389. getter = () => source.map(s => {
  1390. if (isRef(s)) {
  1391. return s.value;
  1392. }
  1393. else if (isReactive(s)) {
  1394. return traverse(s);
  1395. }
  1396. else if (isFunction(s)) {
  1397. return call(s, WATCHER_GETTER);
  1398. }
  1399. else {
  1400. warnInvalidSource(s);
  1401. }
  1402. });
  1403. }
  1404. else if (isFunction(source)) {
  1405. if (cb) {
  1406. // getter with cb
  1407. getter = () => call(source, WATCHER_GETTER);
  1408. }
  1409. else {
  1410. // no cb -> simple effect
  1411. getter = () => {
  1412. if (instance && instance._isDestroyed) {
  1413. return;
  1414. }
  1415. if (cleanup) {
  1416. cleanup();
  1417. }
  1418. return call(source, WATCHER, [onCleanup]);
  1419. };
  1420. }
  1421. }
  1422. else {
  1423. getter = noop;
  1424. warnInvalidSource(source);
  1425. }
  1426. if (cb && deep) {
  1427. const baseGetter = getter;
  1428. getter = () => traverse(baseGetter());
  1429. }
  1430. let cleanup;
  1431. let onCleanup = (fn) => {
  1432. cleanup = watcher.onStop = () => {
  1433. call(fn, WATCHER_CLEANUP);
  1434. };
  1435. };
  1436. // in SSR there is no need to setup an actual effect, and it should be noop
  1437. // unless it's eager
  1438. if (isServerRendering()) {
  1439. // we will also not call the invalidate callback (+ runner is not set up)
  1440. onCleanup = noop;
  1441. if (!cb) {
  1442. getter();
  1443. }
  1444. else if (immediate) {
  1445. call(cb, WATCHER_CB, [
  1446. getter(),
  1447. isMultiSource ? [] : undefined,
  1448. onCleanup
  1449. ]);
  1450. }
  1451. return noop;
  1452. }
  1453. const watcher = new Watcher(currentInstance, getter, noop, {
  1454. lazy: true
  1455. });
  1456. watcher.noRecurse = !cb;
  1457. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  1458. // overwrite default run
  1459. watcher.run = () => {
  1460. if (!watcher.active) {
  1461. return;
  1462. }
  1463. if (cb) {
  1464. // watch(source, cb)
  1465. const newValue = watcher.get();
  1466. if (deep ||
  1467. forceTrigger ||
  1468. (isMultiSource
  1469. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  1470. : hasChanged(newValue, oldValue))) {
  1471. // cleanup before running cb again
  1472. if (cleanup) {
  1473. cleanup();
  1474. }
  1475. call(cb, WATCHER_CB, [
  1476. newValue,
  1477. // pass undefined as the old value when it's changed for the first time
  1478. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  1479. onCleanup
  1480. ]);
  1481. oldValue = newValue;
  1482. }
  1483. }
  1484. else {
  1485. // watchEffect
  1486. watcher.get();
  1487. }
  1488. };
  1489. if (flush === 'sync') {
  1490. watcher.update = watcher.run;
  1491. }
  1492. else if (flush === 'post') {
  1493. watcher.post = true;
  1494. watcher.update = () => queueWatcher(watcher);
  1495. }
  1496. else {
  1497. // pre
  1498. watcher.update = () => {
  1499. if (instance && instance === currentInstance && !instance._isMounted) {
  1500. // pre-watcher triggered before
  1501. const buffer = instance._preWatchers || (instance._preWatchers = []);
  1502. if (buffer.indexOf(watcher) < 0)
  1503. buffer.push(watcher);
  1504. }
  1505. else {
  1506. queueWatcher(watcher);
  1507. }
  1508. };
  1509. }
  1510. {
  1511. watcher.onTrack = onTrack;
  1512. watcher.onTrigger = onTrigger;
  1513. }
  1514. // initial run
  1515. if (cb) {
  1516. if (immediate) {
  1517. watcher.run();
  1518. }
  1519. else {
  1520. oldValue = watcher.get();
  1521. }
  1522. }
  1523. else if (flush === 'post' && instance) {
  1524. instance.$once('hook:mounted', () => watcher.get());
  1525. }
  1526. else {
  1527. watcher.get();
  1528. }
  1529. return () => {
  1530. watcher.teardown();
  1531. };
  1532. }
  1533. let activeEffectScope;
  1534. class EffectScope {
  1535. constructor(detached = false) {
  1536. /**
  1537. * @internal
  1538. */
  1539. this.active = true;
  1540. /**
  1541. * @internal
  1542. */
  1543. this.effects = [];
  1544. /**
  1545. * @internal
  1546. */
  1547. this.cleanups = [];
  1548. if (!detached && activeEffectScope) {
  1549. this.parent = activeEffectScope;
  1550. this.index =
  1551. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  1552. }
  1553. }
  1554. run(fn) {
  1555. if (this.active) {
  1556. const currentEffectScope = activeEffectScope;
  1557. try {
  1558. activeEffectScope = this;
  1559. return fn();
  1560. }
  1561. finally {
  1562. activeEffectScope = currentEffectScope;
  1563. }
  1564. }
  1565. else {
  1566. warn(`cannot run an inactive effect scope.`);
  1567. }
  1568. }
  1569. /**
  1570. * This should only be called on non-detached scopes
  1571. * @internal
  1572. */
  1573. on() {
  1574. activeEffectScope = this;
  1575. }
  1576. /**
  1577. * This should only be called on non-detached scopes
  1578. * @internal
  1579. */
  1580. off() {
  1581. activeEffectScope = this.parent;
  1582. }
  1583. stop(fromParent) {
  1584. if (this.active) {
  1585. let i, l;
  1586. for (i = 0, l = this.effects.length; i < l; i++) {
  1587. this.effects[i].teardown();
  1588. }
  1589. for (i = 0, l = this.cleanups.length; i < l; i++) {
  1590. this.cleanups[i]();
  1591. }
  1592. if (this.scopes) {
  1593. for (i = 0, l = this.scopes.length; i < l; i++) {
  1594. this.scopes[i].stop(true);
  1595. }
  1596. }
  1597. // nested scope, dereference from parent to avoid memory leaks
  1598. if (this.parent && !fromParent) {
  1599. // optimized O(1) removal
  1600. const last = this.parent.scopes.pop();
  1601. if (last && last !== this) {
  1602. this.parent.scopes[this.index] = last;
  1603. last.index = this.index;
  1604. }
  1605. }
  1606. this.active = false;
  1607. }
  1608. }
  1609. }
  1610. function effectScope(detached) {
  1611. return new EffectScope(detached);
  1612. }
  1613. /**
  1614. * @internal
  1615. */
  1616. function recordEffectScope(effect, scope = activeEffectScope) {
  1617. if (scope && scope.active) {
  1618. scope.effects.push(effect);
  1619. }
  1620. }
  1621. function getCurrentScope() {
  1622. return activeEffectScope;
  1623. }
  1624. function onScopeDispose(fn) {
  1625. if (activeEffectScope) {
  1626. activeEffectScope.cleanups.push(fn);
  1627. }
  1628. else {
  1629. warn(`onScopeDispose() is called when there is no active effect scope` +
  1630. ` to be associated with.`);
  1631. }
  1632. }
  1633. function provide(key, value) {
  1634. if (!currentInstance) {
  1635. {
  1636. warn(`provide() can only be used inside setup().`);
  1637. }
  1638. }
  1639. else {
  1640. // TS doesn't allow symbol as index type
  1641. resolveProvided(currentInstance)[key] = value;
  1642. }
  1643. }
  1644. function resolveProvided(vm) {
  1645. // by default an instance inherits its parent's provides object
  1646. // but when it needs to provide values of its own, it creates its
  1647. // own provides object using parent provides object as prototype.
  1648. // this way in `inject` we can simply look up injections from direct
  1649. // parent and let the prototype chain do the work.
  1650. const existing = vm._provided;
  1651. const parentProvides = vm.$parent && vm.$parent._provided;
  1652. if (parentProvides === existing) {
  1653. return (vm._provided = Object.create(parentProvides));
  1654. }
  1655. else {
  1656. return existing;
  1657. }
  1658. }
  1659. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  1660. // fallback to `currentRenderingInstance` so that this can be called in
  1661. // a functional component
  1662. const instance = currentInstance;
  1663. if (instance) {
  1664. // #2400
  1665. // to support `app.use` plugins,
  1666. // fallback to appContext's `provides` if the instance is at root
  1667. const provides = instance.$parent && instance.$parent._provided;
  1668. if (provides && key in provides) {
  1669. // TS doesn't allow symbol as index type
  1670. return provides[key];
  1671. }
  1672. else if (arguments.length > 1) {
  1673. return treatDefaultAsFactory && isFunction(defaultValue)
  1674. ? defaultValue.call(instance)
  1675. : defaultValue;
  1676. }
  1677. else {
  1678. warn(`injection "${String(key)}" not found.`);
  1679. }
  1680. }
  1681. else {
  1682. warn(`inject() can only be used inside setup() or functional components.`);
  1683. }
  1684. }
  1685. const normalizeEvent = cached((name) => {
  1686. const passive = name.charAt(0) === '&';
  1687. name = passive ? name.slice(1) : name;
  1688. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1689. name = once ? name.slice(1) : name;
  1690. const capture = name.charAt(0) === '!';
  1691. name = capture ? name.slice(1) : name;
  1692. return {
  1693. name,
  1694. once,
  1695. capture,
  1696. passive
  1697. };
  1698. });
  1699. function createFnInvoker(fns, vm) {
  1700. function invoker() {
  1701. const fns = invoker.fns;
  1702. if (isArray(fns)) {
  1703. const cloned = fns.slice();
  1704. for (let i = 0; i < cloned.length; i++) {
  1705. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1706. }
  1707. }
  1708. else {
  1709. // return handler return value for single handlers
  1710. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1711. }
  1712. }
  1713. invoker.fns = fns;
  1714. return invoker;
  1715. }
  1716. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1717. let name, cur, old, event;
  1718. for (name in on) {
  1719. cur = on[name];
  1720. old = oldOn[name];
  1721. event = normalizeEvent(name);
  1722. if (isUndef(cur)) {
  1723. warn(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1724. }
  1725. else if (isUndef(old)) {
  1726. if (isUndef(cur.fns)) {
  1727. cur = on[name] = createFnInvoker(cur, vm);
  1728. }
  1729. if (isTrue(event.once)) {
  1730. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1731. }
  1732. add(event.name, cur, event.capture, event.passive, event.params);
  1733. }
  1734. else if (cur !== old) {
  1735. old.fns = cur;
  1736. on[name] = old;
  1737. }
  1738. }
  1739. for (name in oldOn) {
  1740. if (isUndef(on[name])) {
  1741. event = normalizeEvent(name);
  1742. remove(event.name, oldOn[name], event.capture);
  1743. }
  1744. }
  1745. }
  1746. function mergeVNodeHook(def, hookKey, hook) {
  1747. if (def instanceof VNode) {
  1748. def = def.data.hook || (def.data.hook = {});
  1749. }
  1750. let invoker;
  1751. const oldHook = def[hookKey];
  1752. function wrappedHook() {
  1753. hook.apply(this, arguments);
  1754. // important: remove merged hook to ensure it's called only once
  1755. // and prevent memory leak
  1756. remove$2(invoker.fns, wrappedHook);
  1757. }
  1758. if (isUndef(oldHook)) {
  1759. // no existing hook
  1760. invoker = createFnInvoker([wrappedHook]);
  1761. }
  1762. else {
  1763. /* istanbul ignore if */
  1764. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1765. // already a merged invoker
  1766. invoker = oldHook;
  1767. invoker.fns.push(wrappedHook);
  1768. }
  1769. else {
  1770. // existing plain hook
  1771. invoker = createFnInvoker([oldHook, wrappedHook]);
  1772. }
  1773. }
  1774. invoker.merged = true;
  1775. def[hookKey] = invoker;
  1776. }
  1777. function extractPropsFromVNodeData(data, Ctor, tag) {
  1778. // we are only extracting raw values here.
  1779. // validation and default values are handled in the child
  1780. // component itself.
  1781. const propOptions = Ctor.options.props;
  1782. if (isUndef(propOptions)) {
  1783. return;
  1784. }
  1785. const res = {};
  1786. const { attrs, props } = data;
  1787. if (isDef(attrs) || isDef(props)) {
  1788. for (const key in propOptions) {
  1789. const altKey = hyphenate(key);
  1790. {
  1791. const keyInLowerCase = key.toLowerCase();
  1792. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1793. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1794. `${formatComponentName(
  1795. // @ts-expect-error tag is string
  1796. tag || Ctor)}, but the declared prop name is` +
  1797. ` "${key}". ` +
  1798. `Note that HTML attributes are case-insensitive and camelCased ` +
  1799. `props need to use their kebab-case equivalents when using in-DOM ` +
  1800. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1801. }
  1802. }
  1803. checkProp(res, props, key, altKey, true) ||
  1804. checkProp(res, attrs, key, altKey, false);
  1805. }
  1806. }
  1807. return res;
  1808. }
  1809. function checkProp(res, hash, key, altKey, preserve) {
  1810. if (isDef(hash)) {
  1811. if (hasOwn(hash, key)) {
  1812. res[key] = hash[key];
  1813. if (!preserve) {
  1814. delete hash[key];
  1815. }
  1816. return true;
  1817. }
  1818. else if (hasOwn(hash, altKey)) {
  1819. res[key] = hash[altKey];
  1820. if (!preserve) {
  1821. delete hash[altKey];
  1822. }
  1823. return true;
  1824. }
  1825. }
  1826. return false;
  1827. }
  1828. // The template compiler attempts to minimize the need for normalization by
  1829. // statically analyzing the template at compile time.
  1830. //
  1831. // For plain HTML markup, normalization can be completely skipped because the
  1832. // generated render function is guaranteed to return Array<VNode>. There are
  1833. // two cases where extra normalization is needed:
  1834. // 1. When the children contains components - because a functional component
  1835. // may return an Array instead of a single root. In this case, just a simple
  1836. // normalization is needed - if any child is an Array, we flatten the whole
  1837. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1838. // because functional components already normalize their own children.
  1839. function simpleNormalizeChildren(children) {
  1840. for (let i = 0; i < children.length; i++) {
  1841. if (isArray(children[i])) {
  1842. return Array.prototype.concat.apply([], children);
  1843. }
  1844. }
  1845. return children;
  1846. }
  1847. // 2. When the children contains constructs that always generated nested Arrays,
  1848. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1849. // with hand-written render functions / JSX. In such cases a full normalization
  1850. // is needed to cater to all possible types of children values.
  1851. function normalizeChildren(children) {
  1852. return isPrimitive(children)
  1853. ? [createTextVNode(children)]
  1854. : isArray(children)
  1855. ? normalizeArrayChildren(children)
  1856. : undefined;
  1857. }
  1858. function isTextNode(node) {
  1859. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1860. }
  1861. function normalizeArrayChildren(children, nestedIndex) {
  1862. const res = [];
  1863. let i, c, lastIndex, last;
  1864. for (i = 0; i < children.length; i++) {
  1865. c = children[i];
  1866. if (isUndef(c) || typeof c === 'boolean')
  1867. continue;
  1868. lastIndex = res.length - 1;
  1869. last = res[lastIndex];
  1870. // nested
  1871. if (isArray(c)) {
  1872. if (c.length > 0) {
  1873. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1874. // merge adjacent text nodes
  1875. if (isTextNode(c[0]) && isTextNode(last)) {
  1876. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1877. c.shift();
  1878. }
  1879. res.push.apply(res, c);
  1880. }
  1881. }
  1882. else if (isPrimitive(c)) {
  1883. if (isTextNode(last)) {
  1884. // merge adjacent text nodes
  1885. // this is necessary for SSR hydration because text nodes are
  1886. // essentially merged when rendered to HTML strings
  1887. res[lastIndex] = createTextVNode(last.text + c);
  1888. }
  1889. else if (c !== '') {
  1890. // convert primitive to vnode
  1891. res.push(createTextVNode(c));
  1892. }
  1893. }
  1894. else {
  1895. if (isTextNode(c) && isTextNode(last)) {
  1896. // merge adjacent text nodes
  1897. res[lastIndex] = createTextVNode(last.text + c.text);
  1898. }
  1899. else {
  1900. // default key for nested array children (likely generated by v-for)
  1901. if (isTrue(children._isVList) &&
  1902. isDef(c.tag) &&
  1903. isUndef(c.key) &&
  1904. isDef(nestedIndex)) {
  1905. c.key = `__vlist${nestedIndex}_${i}__`;
  1906. }
  1907. res.push(c);
  1908. }
  1909. }
  1910. }
  1911. return res;
  1912. }
  1913. /**
  1914. * Runtime helper for rendering v-for lists.
  1915. */
  1916. function renderList(val, render) {
  1917. let ret = null, i, l, keys, key;
  1918. if (isArray(val) || typeof val === 'string') {
  1919. ret = new Array(val.length);
  1920. for (i = 0, l = val.length; i < l; i++) {
  1921. ret[i] = render(val[i], i);
  1922. }
  1923. }
  1924. else if (typeof val === 'number') {
  1925. ret = new Array(val);
  1926. for (i = 0; i < val; i++) {
  1927. ret[i] = render(i + 1, i);
  1928. }
  1929. }
  1930. else if (isObject(val)) {
  1931. if (hasSymbol && val[Symbol.iterator]) {
  1932. ret = [];
  1933. const iterator = val[Symbol.iterator]();
  1934. let result = iterator.next();
  1935. while (!result.done) {
  1936. ret.push(render(result.value, ret.length));
  1937. result = iterator.next();
  1938. }
  1939. }
  1940. else {
  1941. keys = Object.keys(val);
  1942. ret = new Array(keys.length);
  1943. for (i = 0, l = keys.length; i < l; i++) {
  1944. key = keys[i];
  1945. ret[i] = render(val[key], key, i);
  1946. }
  1947. }
  1948. }
  1949. if (!isDef(ret)) {
  1950. ret = [];
  1951. }
  1952. ret._isVList = true;
  1953. return ret;
  1954. }
  1955. /**
  1956. * Runtime helper for rendering <slot>
  1957. */
  1958. function renderSlot(name, fallbackRender, props, bindObject) {
  1959. const scopedSlotFn = this.$scopedSlots[name];
  1960. let nodes;
  1961. if (scopedSlotFn) {
  1962. // scoped slot
  1963. props = props || {};
  1964. if (bindObject) {
  1965. if (!isObject(bindObject)) {
  1966. warn('slot v-bind without argument expects an Object', this);
  1967. }
  1968. props = extend(extend({}, bindObject), props);
  1969. }
  1970. nodes =
  1971. scopedSlotFn(props) ||
  1972. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1973. }
  1974. else {
  1975. nodes =
  1976. this.$slots[name] ||
  1977. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1978. }
  1979. const target = props && props.slot;
  1980. if (target) {
  1981. return this.$createElement('template', { slot: target }, nodes);
  1982. }
  1983. else {
  1984. return nodes;
  1985. }
  1986. }
  1987. /**
  1988. * Runtime helper for resolving filters
  1989. */
  1990. function resolveFilter(id) {
  1991. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1992. }
  1993. function isKeyNotMatch(expect, actual) {
  1994. if (isArray(expect)) {
  1995. return expect.indexOf(actual) === -1;
  1996. }
  1997. else {
  1998. return expect !== actual;
  1999. }
  2000. }
  2001. /**
  2002. * Runtime helper for checking keyCodes from config.
  2003. * exposed as Vue.prototype._k
  2004. * passing in eventKeyName as last argument separately for backwards compat
  2005. */
  2006. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  2007. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2008. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2009. return isKeyNotMatch(builtInKeyName, eventKeyName);
  2010. }
  2011. else if (mappedKeyCode) {
  2012. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  2013. }
  2014. else if (eventKeyName) {
  2015. return hyphenate(eventKeyName) !== key;
  2016. }
  2017. return eventKeyCode === undefined;
  2018. }
  2019. /**
  2020. * Runtime helper for merging v-bind="object" into a VNode's data.
  2021. */
  2022. function bindObjectProps(data, tag, value, asProp, isSync) {
  2023. if (value) {
  2024. if (!isObject(value)) {
  2025. warn('v-bind without argument expects an Object or Array value', this);
  2026. }
  2027. else {
  2028. if (isArray(value)) {
  2029. value = toObject(value);
  2030. }
  2031. let hash;
  2032. for (const key in value) {
  2033. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  2034. hash = data;
  2035. }
  2036. else {
  2037. const type = data.attrs && data.attrs.type;
  2038. hash =
  2039. asProp || config.mustUseProp(tag, type, key)
  2040. ? data.domProps || (data.domProps = {})
  2041. : data.attrs || (data.attrs = {});
  2042. }
  2043. const camelizedKey = camelize(key);
  2044. const hyphenatedKey = hyphenate(key);
  2045. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2046. hash[key] = value[key];
  2047. if (isSync) {
  2048. const on = data.on || (data.on = {});
  2049. on[`update:${key}`] = function ($event) {
  2050. value[key] = $event;
  2051. };
  2052. }
  2053. }
  2054. }
  2055. }
  2056. }
  2057. return data;
  2058. }
  2059. /**
  2060. * Runtime helper for rendering static trees.
  2061. */
  2062. function renderStatic(index, isInFor) {
  2063. const cached = this._staticTrees || (this._staticTrees = []);
  2064. let tree = cached[index];
  2065. // if has already-rendered static tree and not inside v-for,
  2066. // we can reuse the same tree.
  2067. if (tree && !isInFor) {
  2068. return tree;
  2069. }
  2070. // otherwise, render a fresh tree.
  2071. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  2072. );
  2073. markStatic(tree, `__static__${index}`, false);
  2074. return tree;
  2075. }
  2076. /**
  2077. * Runtime helper for v-once.
  2078. * Effectively it means marking the node as static with a unique key.
  2079. */
  2080. function markOnce(tree, index, key) {
  2081. markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  2082. return tree;
  2083. }
  2084. function markStatic(tree, key, isOnce) {
  2085. if (isArray(tree)) {
  2086. for (let i = 0; i < tree.length; i++) {
  2087. if (tree[i] && typeof tree[i] !== 'string') {
  2088. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  2089. }
  2090. }
  2091. }
  2092. else {
  2093. markStaticNode(tree, key, isOnce);
  2094. }
  2095. }
  2096. function markStaticNode(node, key, isOnce) {
  2097. node.isStatic = true;
  2098. node.key = key;
  2099. node.isOnce = isOnce;
  2100. }
  2101. function bindObjectListeners(data, value) {
  2102. if (value) {
  2103. if (!isPlainObject(value)) {
  2104. warn('v-on without argument expects an Object value', this);
  2105. }
  2106. else {
  2107. const on = (data.on = data.on ? extend({}, data.on) : {});
  2108. for (const key in value) {
  2109. const existing = on[key];
  2110. const ours = value[key];
  2111. on[key] = existing ? [].concat(existing, ours) : ours;
  2112. }
  2113. }
  2114. }
  2115. return data;
  2116. }
  2117. function resolveScopedSlots(fns, res,
  2118. // the following are added in 2.6
  2119. hasDynamicKeys, contentHashKey) {
  2120. res = res || { $stable: !hasDynamicKeys };
  2121. for (let i = 0; i < fns.length; i++) {
  2122. const slot = fns[i];
  2123. if (isArray(slot)) {
  2124. resolveScopedSlots(slot, res, hasDynamicKeys);
  2125. }
  2126. else if (slot) {
  2127. // marker for reverse proxying v-slot without scope on this.$slots
  2128. // @ts-expect-error
  2129. if (slot.proxy) {
  2130. // @ts-expect-error
  2131. slot.fn.proxy = true;
  2132. }
  2133. res[slot.key] = slot.fn;
  2134. }
  2135. }
  2136. if (contentHashKey) {
  2137. res.$key = contentHashKey;
  2138. }
  2139. return res;
  2140. }
  2141. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2142. function bindDynamicKeys(baseObj, values) {
  2143. for (let i = 0; i < values.length; i += 2) {
  2144. const key = values[i];
  2145. if (typeof key === 'string' && key) {
  2146. baseObj[values[i]] = values[i + 1];
  2147. }
  2148. else if (key !== '' && key !== null) {
  2149. // null is a special value for explicitly removing a binding
  2150. warn(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2151. }
  2152. }
  2153. return baseObj;
  2154. }
  2155. // helper to dynamically append modifier runtime markers to event names.
  2156. // ensure only append when value is already string, otherwise it will be cast
  2157. // to string and cause the type check to miss.
  2158. function prependModifier(value, symbol) {
  2159. return typeof value === 'string' ? symbol + value : value;
  2160. }
  2161. function installRenderHelpers(target) {
  2162. target._o = markOnce;
  2163. target._n = toNumber;
  2164. target._s = toString;
  2165. target._l = renderList;
  2166. target._t = renderSlot;
  2167. target._q = looseEqual;
  2168. target._i = looseIndexOf;
  2169. target._m = renderStatic;
  2170. target._f = resolveFilter;
  2171. target._k = checkKeyCodes;
  2172. target._b = bindObjectProps;
  2173. target._v = createTextVNode;
  2174. target._e = createEmptyVNode;
  2175. target._u = resolveScopedSlots;
  2176. target._g = bindObjectListeners;
  2177. target._d = bindDynamicKeys;
  2178. target._p = prependModifier;
  2179. }
  2180. /**
  2181. * Runtime helper for resolving raw children VNodes into a slot object.
  2182. */
  2183. function resolveSlots(children, context) {
  2184. if (!children || !children.length) {
  2185. return {};
  2186. }
  2187. const slots = {};
  2188. for (let i = 0, l = children.length; i < l; i++) {
  2189. const child = children[i];
  2190. const data = child.data;
  2191. // remove slot attribute if the node is resolved as a Vue slot node
  2192. if (data && data.attrs && data.attrs.slot) {
  2193. delete data.attrs.slot;
  2194. }
  2195. // named slots should only be respected if the vnode was rendered in the
  2196. // same context.
  2197. if ((child.context === context || child.fnContext === context) &&
  2198. data &&
  2199. data.slot != null) {
  2200. const name = data.slot;
  2201. const slot = slots[name] || (slots[name] = []);
  2202. if (child.tag === 'template') {
  2203. slot.push.apply(slot, child.children || []);
  2204. }
  2205. else {
  2206. slot.push(child);
  2207. }
  2208. }
  2209. else {
  2210. (slots.default || (slots.default = [])).push(child);
  2211. }
  2212. }
  2213. // ignore slots that contains only whitespace
  2214. for (const name in slots) {
  2215. if (slots[name].every(isWhitespace)) {
  2216. delete slots[name];
  2217. }
  2218. }
  2219. return slots;
  2220. }
  2221. function isWhitespace(node) {
  2222. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2223. }
  2224. function isAsyncPlaceholder(node) {
  2225. // @ts-expect-error not really boolean type
  2226. return node.isComment && node.asyncFactory;
  2227. }
  2228. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2229. let res;
  2230. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2231. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2232. const key = scopedSlots && scopedSlots.$key;
  2233. if (!scopedSlots) {
  2234. res = {};
  2235. }
  2236. else if (scopedSlots._normalized) {
  2237. // fast path 1: child component re-render only, parent did not change
  2238. return scopedSlots._normalized;
  2239. }
  2240. else if (isStable &&
  2241. prevScopedSlots &&
  2242. prevScopedSlots !== emptyObject &&
  2243. key === prevScopedSlots.$key &&
  2244. !hasNormalSlots &&
  2245. !prevScopedSlots.$hasNormal) {
  2246. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2247. // only need to normalize once
  2248. return prevScopedSlots;
  2249. }
  2250. else {
  2251. res = {};
  2252. for (const key in scopedSlots) {
  2253. if (scopedSlots[key] && key[0] !== '$') {
  2254. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2255. }
  2256. }
  2257. }
  2258. // expose normal slots on scopedSlots
  2259. for (const key in normalSlots) {
  2260. if (!(key in res)) {
  2261. res[key] = proxyNormalSlot(normalSlots, key);
  2262. }
  2263. }
  2264. // avoriaz seems to mock a non-extensible $scopedSlots object
  2265. // and when that is passed down this would cause an error
  2266. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2267. scopedSlots._normalized = res;
  2268. }
  2269. def(res, '$stable', isStable);
  2270. def(res, '$key', key);
  2271. def(res, '$hasNormal', hasNormalSlots);
  2272. return res;
  2273. }
  2274. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2275. const normalized = function () {
  2276. const cur = currentInstance;
  2277. setCurrentInstance(vm);
  2278. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2279. res =
  2280. res && typeof res === 'object' && !isArray(res)
  2281. ? [res] // single vnode
  2282. : normalizeChildren(res);
  2283. const vnode = res && res[0];
  2284. setCurrentInstance(cur);
  2285. return res &&
  2286. (!vnode ||
  2287. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2288. ? undefined
  2289. : res;
  2290. };
  2291. // this is a slot using the new v-slot syntax without scope. although it is
  2292. // compiled as a scoped slot, render fn users would expect it to be present
  2293. // on this.$slots because the usage is semantically a normal slot.
  2294. if (fn.proxy) {
  2295. Object.defineProperty(normalSlots, key, {
  2296. get: normalized,
  2297. enumerable: true,
  2298. configurable: true
  2299. });
  2300. }
  2301. return normalized;
  2302. }
  2303. function proxyNormalSlot(slots, key) {
  2304. return () => slots[key];
  2305. }
  2306. function initSetup(vm) {
  2307. const options = vm.$options;
  2308. const setup = options.setup;
  2309. if (setup) {
  2310. const ctx = (vm._setupContext = createSetupContext(vm));
  2311. setCurrentInstance(vm);
  2312. pushTarget();
  2313. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2314. popTarget();
  2315. setCurrentInstance();
  2316. if (isFunction(setupResult)) {
  2317. // render function
  2318. // @ts-ignore
  2319. options.render = setupResult;
  2320. }
  2321. else if (isObject(setupResult)) {
  2322. // bindings
  2323. if (setupResult instanceof VNode) {
  2324. warn(`setup() should not return VNodes directly - ` +
  2325. `return a render function instead.`);
  2326. }
  2327. vm._setupState = setupResult;
  2328. // __sfc indicates compiled bindings from <script setup>
  2329. if (!setupResult.__sfc) {
  2330. for (const key in setupResult) {
  2331. if (!isReserved(key)) {
  2332. proxyWithRefUnwrap(vm, setupResult, key);
  2333. }
  2334. else {
  2335. warn(`Avoid using variables that start with _ or $ in setup().`);
  2336. }
  2337. }
  2338. }
  2339. else {
  2340. // exposed for compiled render fn
  2341. const proxy = (vm._setupProxy = {});
  2342. for (const key in setupResult) {
  2343. if (key !== '__sfc') {
  2344. proxyWithRefUnwrap(proxy, setupResult, key);
  2345. }
  2346. }
  2347. }
  2348. }
  2349. else if (setupResult !== undefined) {
  2350. warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2351. }
  2352. }
  2353. }
  2354. function createSetupContext(vm) {
  2355. let exposeCalled = false;
  2356. return {
  2357. get attrs() {
  2358. if (!vm._attrsProxy) {
  2359. const proxy = (vm._attrsProxy = {});
  2360. def(proxy, '_v_attr_proxy', true);
  2361. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2362. }
  2363. return vm._attrsProxy;
  2364. },
  2365. get listeners() {
  2366. if (!vm._listenersProxy) {
  2367. const proxy = (vm._listenersProxy = {});
  2368. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2369. }
  2370. return vm._listenersProxy;
  2371. },
  2372. get slots() {
  2373. return initSlotsProxy(vm);
  2374. },
  2375. emit: bind(vm.$emit, vm),
  2376. expose(exposed) {
  2377. {
  2378. if (exposeCalled) {
  2379. warn(`expose() should be called only once per setup().`, vm);
  2380. }
  2381. exposeCalled = true;
  2382. }
  2383. if (exposed) {
  2384. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2385. }
  2386. }
  2387. };
  2388. }
  2389. function syncSetupProxy(to, from, prev, instance, type) {
  2390. let changed = false;
  2391. for (const key in from) {
  2392. if (!(key in to)) {
  2393. changed = true;
  2394. defineProxyAttr(to, key, instance, type);
  2395. }
  2396. else if (from[key] !== prev[key]) {
  2397. changed = true;
  2398. }
  2399. }
  2400. for (const key in to) {
  2401. if (!(key in from)) {
  2402. changed = true;
  2403. delete to[key];
  2404. }
  2405. }
  2406. return changed;
  2407. }
  2408. function defineProxyAttr(proxy, key, instance, type) {
  2409. Object.defineProperty(proxy, key, {
  2410. enumerable: true,
  2411. configurable: true,
  2412. get() {
  2413. return instance[type][key];
  2414. }
  2415. });
  2416. }
  2417. function initSlotsProxy(vm) {
  2418. if (!vm._slotsProxy) {
  2419. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2420. }
  2421. return vm._slotsProxy;
  2422. }
  2423. function syncSetupSlots(to, from) {
  2424. for (const key in from) {
  2425. to[key] = from[key];
  2426. }
  2427. for (const key in to) {
  2428. if (!(key in from)) {
  2429. delete to[key];
  2430. }
  2431. }
  2432. }
  2433. /**
  2434. * @internal use manual type def because public setup context type relies on
  2435. * legacy VNode types
  2436. */
  2437. function useSlots() {
  2438. return getContext().slots;
  2439. }
  2440. /**
  2441. * @internal use manual type def because public setup context type relies on
  2442. * legacy VNode types
  2443. */
  2444. function useAttrs() {
  2445. return getContext().attrs;
  2446. }
  2447. /**
  2448. * Vue 2 only
  2449. * @internal use manual type def because public setup context type relies on
  2450. * legacy VNode types
  2451. */
  2452. function useListeners() {
  2453. return getContext().listeners;
  2454. }
  2455. function getContext() {
  2456. if (!currentInstance) {
  2457. warn(`useContext() called without active instance.`);
  2458. }
  2459. const vm = currentInstance;
  2460. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2461. }
  2462. /**
  2463. * Runtime helper for merging default declarations. Imported by compiled code
  2464. * only.
  2465. * @internal
  2466. */
  2467. function mergeDefaults(raw, defaults) {
  2468. const props = isArray(raw)
  2469. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2470. : raw;
  2471. for (const key in defaults) {
  2472. const opt = props[key];
  2473. if (opt) {
  2474. if (isArray(opt) || isFunction(opt)) {
  2475. props[key] = { type: opt, default: defaults[key] };
  2476. }
  2477. else {
  2478. opt.default = defaults[key];
  2479. }
  2480. }
  2481. else if (opt === null) {
  2482. props[key] = { default: defaults[key] };
  2483. }
  2484. else {
  2485. warn(`props default key "${key}" has no corresponding declaration.`);
  2486. }
  2487. }
  2488. return props;
  2489. }
  2490. function initRender(vm) {
  2491. vm._vnode = null; // the root of the child tree
  2492. vm._staticTrees = null; // v-once cached trees
  2493. const options = vm.$options;
  2494. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2495. const renderContext = parentVnode && parentVnode.context;
  2496. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2497. vm.$scopedSlots = parentVnode
  2498. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2499. : emptyObject;
  2500. // bind the createElement fn to this instance
  2501. // so that we get proper render context inside it.
  2502. // args order: tag, data, children, normalizationType, alwaysNormalize
  2503. // internal version is used by render functions compiled from templates
  2504. // @ts-expect-error
  2505. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2506. // normalization is always applied for the public version, used in
  2507. // user-written render functions.
  2508. // @ts-expect-error
  2509. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2510. // $attrs & $listeners are exposed for easier HOC creation.
  2511. // they need to be reactive so that HOCs using them are always updated
  2512. const parentData = parentVnode && parentVnode.data;
  2513. /* istanbul ignore else */
  2514. {
  2515. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2516. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  2517. }, true);
  2518. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2519. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  2520. }, true);
  2521. }
  2522. }
  2523. let currentRenderingInstance = null;
  2524. function renderMixin(Vue) {
  2525. // install runtime convenience helpers
  2526. installRenderHelpers(Vue.prototype);
  2527. Vue.prototype.$nextTick = function (fn) {
  2528. return nextTick(fn, this);
  2529. };
  2530. Vue.prototype._render = function () {
  2531. const vm = this;
  2532. const { render, _parentVnode } = vm.$options;
  2533. if (_parentVnode && vm._isMounted) {
  2534. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2535. if (vm._slotsProxy) {
  2536. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2537. }
  2538. }
  2539. // set parent vnode. this allows render functions to have access
  2540. // to the data on the placeholder node.
  2541. vm.$vnode = _parentVnode;
  2542. // render self
  2543. let vnode;
  2544. try {
  2545. // There's no need to maintain a stack because all render fns are called
  2546. // separately from one another. Nested component's render fns are called
  2547. // when parent component is patched.
  2548. setCurrentInstance(vm);
  2549. currentRenderingInstance = vm;
  2550. vnode = render.call(vm._renderProxy, vm.$createElement);
  2551. }
  2552. catch (e) {
  2553. handleError(e, vm, `render`);
  2554. // return error render result,
  2555. // or previous vnode to prevent render error causing blank component
  2556. /* istanbul ignore else */
  2557. if (vm.$options.renderError) {
  2558. try {
  2559. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2560. }
  2561. catch (e) {
  2562. handleError(e, vm, `renderError`);
  2563. vnode = vm._vnode;
  2564. }
  2565. }
  2566. else {
  2567. vnode = vm._vnode;
  2568. }
  2569. }
  2570. finally {
  2571. currentRenderingInstance = null;
  2572. setCurrentInstance();
  2573. }
  2574. // if the returned array contains only a single node, allow it
  2575. if (isArray(vnode) && vnode.length === 1) {
  2576. vnode = vnode[0];
  2577. }
  2578. // return empty vnode in case the render function errored out
  2579. if (!(vnode instanceof VNode)) {
  2580. if (isArray(vnode)) {
  2581. warn('Multiple root nodes returned from render function. Render function ' +
  2582. 'should return a single root node.', vm);
  2583. }
  2584. vnode = createEmptyVNode();
  2585. }
  2586. // set parent
  2587. vnode.parent = _parentVnode;
  2588. return vnode;
  2589. };
  2590. }
  2591. function ensureCtor(comp, base) {
  2592. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2593. comp = comp.default;
  2594. }
  2595. return isObject(comp) ? base.extend(comp) : comp;
  2596. }
  2597. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2598. const node = createEmptyVNode();
  2599. node.asyncFactory = factory;
  2600. node.asyncMeta = { data, context, children, tag };
  2601. return node;
  2602. }
  2603. function resolveAsyncComponent(factory, baseCtor) {
  2604. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2605. return factory.errorComp;
  2606. }
  2607. if (isDef(factory.resolved)) {
  2608. return factory.resolved;
  2609. }
  2610. const owner = currentRenderingInstance;
  2611. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2612. // already pending
  2613. factory.owners.push(owner);
  2614. }
  2615. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2616. return factory.loadingComp;
  2617. }
  2618. if (owner && !isDef(factory.owners)) {
  2619. const owners = (factory.owners = [owner]);
  2620. let sync = true;
  2621. let timerLoading = null;
  2622. let timerTimeout = null;
  2623. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2624. const forceRender = (renderCompleted) => {
  2625. for (let i = 0, l = owners.length; i < l; i++) {
  2626. owners[i].$forceUpdate();
  2627. }
  2628. if (renderCompleted) {
  2629. owners.length = 0;
  2630. if (timerLoading !== null) {
  2631. clearTimeout(timerLoading);
  2632. timerLoading = null;
  2633. }
  2634. if (timerTimeout !== null) {
  2635. clearTimeout(timerTimeout);
  2636. timerTimeout = null;
  2637. }
  2638. }
  2639. };
  2640. const resolve = once((res) => {
  2641. // cache resolved
  2642. factory.resolved = ensureCtor(res, baseCtor);
  2643. // invoke callbacks only if this is not a synchronous resolve
  2644. // (async resolves are shimmed as synchronous during SSR)
  2645. if (!sync) {
  2646. forceRender(true);
  2647. }
  2648. else {
  2649. owners.length = 0;
  2650. }
  2651. });
  2652. const reject = once(reason => {
  2653. warn(`Failed to resolve async component: ${String(factory)}` +
  2654. (reason ? `\nReason: ${reason}` : ''));
  2655. if (isDef(factory.errorComp)) {
  2656. factory.error = true;
  2657. forceRender(true);
  2658. }
  2659. });
  2660. const res = factory(resolve, reject);
  2661. if (isObject(res)) {
  2662. if (isPromise(res)) {
  2663. // () => Promise
  2664. if (isUndef(factory.resolved)) {
  2665. res.then(resolve, reject);
  2666. }
  2667. }
  2668. else if (isPromise(res.component)) {
  2669. res.component.then(resolve, reject);
  2670. if (isDef(res.error)) {
  2671. factory.errorComp = ensureCtor(res.error, baseCtor);
  2672. }
  2673. if (isDef(res.loading)) {
  2674. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2675. if (res.delay === 0) {
  2676. factory.loading = true;
  2677. }
  2678. else {
  2679. // @ts-expect-error NodeJS timeout type
  2680. timerLoading = setTimeout(() => {
  2681. timerLoading = null;
  2682. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2683. factory.loading = true;
  2684. forceRender(false);
  2685. }
  2686. }, res.delay || 200);
  2687. }
  2688. }
  2689. if (isDef(res.timeout)) {
  2690. // @ts-expect-error NodeJS timeout type
  2691. timerTimeout = setTimeout(() => {
  2692. timerTimeout = null;
  2693. if (isUndef(factory.resolved)) {
  2694. reject(`timeout (${res.timeout}ms)` );
  2695. }
  2696. }, res.timeout);
  2697. }
  2698. }
  2699. }
  2700. sync = false;
  2701. // return in case resolved synchronously
  2702. return factory.loading ? factory.loadingComp : factory.resolved;
  2703. }
  2704. }
  2705. function getFirstComponentChild(children) {
  2706. if (isArray(children)) {
  2707. for (let i = 0; i < children.length; i++) {
  2708. const c = children[i];
  2709. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2710. return c;
  2711. }
  2712. }
  2713. }
  2714. }
  2715. const SIMPLE_NORMALIZE = 1;
  2716. const ALWAYS_NORMALIZE = 2;
  2717. // wrapper function for providing a more flexible interface
  2718. // without getting yelled at by flow
  2719. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  2720. if (isArray(data) || isPrimitive(data)) {
  2721. normalizationType = children;
  2722. children = data;
  2723. data = undefined;
  2724. }
  2725. if (isTrue(alwaysNormalize)) {
  2726. normalizationType = ALWAYS_NORMALIZE;
  2727. }
  2728. return _createElement(context, tag, data, children, normalizationType);
  2729. }
  2730. function _createElement(context, tag, data, children, normalizationType) {
  2731. if (isDef(data) && isDef(data.__ob__)) {
  2732. warn(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  2733. return createEmptyVNode();
  2734. }
  2735. // object syntax in v-bind
  2736. if (isDef(data) && isDef(data.is)) {
  2737. tag = data.is;
  2738. }
  2739. if (!tag) {
  2740. // in case of component :is set to falsy value
  2741. return createEmptyVNode();
  2742. }
  2743. // warn against non-primitive key
  2744. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  2745. warn('Avoid using non-primitive value as key, ' +
  2746. 'use string/number value instead.', context);
  2747. }
  2748. // support single function children as default scoped slot
  2749. if (isArray(children) && isFunction(children[0])) {
  2750. data = data || {};
  2751. data.scopedSlots = { default: children[0] };
  2752. children.length = 0;
  2753. }
  2754. if (normalizationType === ALWAYS_NORMALIZE) {
  2755. children = normalizeChildren(children);
  2756. }
  2757. else if (normalizationType === SIMPLE_NORMALIZE) {
  2758. children = simpleNormalizeChildren(children);
  2759. }
  2760. let vnode, ns;
  2761. if (typeof tag === 'string') {
  2762. let Ctor;
  2763. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  2764. if (config.isReservedTag(tag)) {
  2765. // platform built-in elements
  2766. if (isDef(data) &&
  2767. isDef(data.nativeOn) &&
  2768. data.tag !== 'component') {
  2769. warn(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  2770. }
  2771. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  2772. }
  2773. else if ((!data || !data.pre) &&
  2774. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  2775. // component
  2776. vnode = createComponent(Ctor, data, context, children, tag);
  2777. }
  2778. else {
  2779. // unknown or unlisted namespaced elements
  2780. // check at runtime because it may get assigned a namespace when its
  2781. // parent normalizes children
  2782. vnode = new VNode(tag, data, children, undefined, undefined, context);
  2783. }
  2784. }
  2785. else {
  2786. // direct component options / constructor
  2787. vnode = createComponent(tag, data, context, children);
  2788. }
  2789. if (isArray(vnode)) {
  2790. return vnode;
  2791. }
  2792. else if (isDef(vnode)) {
  2793. if (isDef(ns))
  2794. applyNS(vnode, ns);
  2795. if (isDef(data))
  2796. registerDeepBindings(data);
  2797. return vnode;
  2798. }
  2799. else {
  2800. return createEmptyVNode();
  2801. }
  2802. }
  2803. function applyNS(vnode, ns, force) {
  2804. vnode.ns = ns;
  2805. if (vnode.tag === 'foreignObject') {
  2806. // use default namespace inside foreignObject
  2807. ns = undefined;
  2808. force = true;
  2809. }
  2810. if (isDef(vnode.children)) {
  2811. for (let i = 0, l = vnode.children.length; i < l; i++) {
  2812. const child = vnode.children[i];
  2813. if (isDef(child.tag) &&
  2814. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  2815. applyNS(child, ns, force);
  2816. }
  2817. }
  2818. }
  2819. }
  2820. // ref #5318
  2821. // necessary to ensure parent re-render when deep bindings like :style and
  2822. // :class are used on slot nodes
  2823. function registerDeepBindings(data) {
  2824. if (isObject(data.style)) {
  2825. traverse(data.style);
  2826. }
  2827. if (isObject(data.class)) {
  2828. traverse(data.class);
  2829. }
  2830. }
  2831. /**
  2832. * @internal this function needs manual public type declaration because it relies
  2833. * on previously manually authored types from Vue 2
  2834. */
  2835. function h(type, props, children) {
  2836. if (!currentInstance) {
  2837. warn(`globally imported h() can only be invoked when there is an active ` +
  2838. `component instance, e.g. synchronously in a component's render or setup function.`);
  2839. }
  2840. return createElement$1(currentInstance, type, props, children, 2, true);
  2841. }
  2842. function handleError(err, vm, info) {
  2843. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  2844. // See: https://github.com/vuejs/vuex/issues/1505
  2845. pushTarget();
  2846. try {
  2847. if (vm) {
  2848. let cur = vm;
  2849. while ((cur = cur.$parent)) {
  2850. const hooks = cur.$options.errorCaptured;
  2851. if (hooks) {
  2852. for (let i = 0; i < hooks.length; i++) {
  2853. try {
  2854. const capture = hooks[i].call(cur, err, vm, info) === false;
  2855. if (capture)
  2856. return;
  2857. }
  2858. catch (e) {
  2859. globalHandleError(e, cur, 'errorCaptured hook');
  2860. }
  2861. }
  2862. }
  2863. }
  2864. }
  2865. globalHandleError(err, vm, info);
  2866. }
  2867. finally {
  2868. popTarget();
  2869. }
  2870. }
  2871. function invokeWithErrorHandling(handler, context, args, vm, info) {
  2872. let res;
  2873. try {
  2874. res = args ? handler.apply(context, args) : handler.call(context);
  2875. if (res && !res._isVue && isPromise(res) && !res._handled) {
  2876. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  2877. res._handled = true;
  2878. }
  2879. }
  2880. catch (e) {
  2881. handleError(e, vm, info);
  2882. }
  2883. return res;
  2884. }
  2885. function globalHandleError(err, vm, info) {
  2886. if (config.errorHandler) {
  2887. try {
  2888. return config.errorHandler.call(null, err, vm, info);
  2889. }
  2890. catch (e) {
  2891. // if the user intentionally throws the original error in the handler,
  2892. // do not log it twice
  2893. if (e !== err) {
  2894. logError(e, null, 'config.errorHandler');
  2895. }
  2896. }
  2897. }
  2898. logError(err, vm, info);
  2899. }
  2900. function logError(err, vm, info) {
  2901. {
  2902. warn(`Error in ${info}: "${err.toString()}"`, vm);
  2903. }
  2904. /* istanbul ignore else */
  2905. if (inBrowser && typeof console !== 'undefined') {
  2906. console.error(err);
  2907. }
  2908. else {
  2909. throw err;
  2910. }
  2911. }
  2912. /* globals MutationObserver */
  2913. let isUsingMicroTask = false;
  2914. const callbacks = [];
  2915. let pending = false;
  2916. function flushCallbacks() {
  2917. pending = false;
  2918. const copies = callbacks.slice(0);
  2919. callbacks.length = 0;
  2920. for (let i = 0; i < copies.length; i++) {
  2921. copies[i]();
  2922. }
  2923. }
  2924. // Here we have async deferring wrappers using microtasks.
  2925. // In 2.5 we used (macro) tasks (in combination with microtasks).
  2926. // However, it has subtle problems when state is changed right before repaint
  2927. // (e.g. #6813, out-in transitions).
  2928. // Also, using (macro) tasks in event handler would cause some weird behaviors
  2929. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  2930. // So we now use microtasks everywhere, again.
  2931. // A major drawback of this tradeoff is that there are some scenarios
  2932. // where microtasks have too high a priority and fire in between supposedly
  2933. // sequential events (e.g. #4521, #6690, which have workarounds)
  2934. // or even between bubbling of the same event (#6566).
  2935. let timerFunc;
  2936. // The nextTick behavior leverages the microtask queue, which can be accessed
  2937. // via either native Promise.then or MutationObserver.
  2938. // MutationObserver has wider support, however it is seriously bugged in
  2939. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  2940. // completely stops working after triggering a few times... so, if native
  2941. // Promise is available, we will use it:
  2942. /* istanbul ignore next, $flow-disable-line */
  2943. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  2944. const p = Promise.resolve();
  2945. timerFunc = () => {
  2946. p.then(flushCallbacks);
  2947. // In problematic UIWebViews, Promise.then doesn't completely break, but
  2948. // it can get stuck in a weird state where callbacks are pushed into the
  2949. // microtask queue but the queue isn't being flushed, until the browser
  2950. // needs to do some other work, e.g. handle a timer. Therefore we can
  2951. // "force" the microtask queue to be flushed by adding an empty timer.
  2952. if (isIOS)
  2953. setTimeout(noop);
  2954. };
  2955. isUsingMicroTask = true;
  2956. }
  2957. else if (!isIE &&
  2958. typeof MutationObserver !== 'undefined' &&
  2959. (isNative(MutationObserver) ||
  2960. // PhantomJS and iOS 7.x
  2961. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  2962. // Use MutationObserver where native Promise is not available,
  2963. // e.g. PhantomJS, iOS7, Android 4.4
  2964. // (#6466 MutationObserver is unreliable in IE11)
  2965. let counter = 1;
  2966. const observer = new MutationObserver(flushCallbacks);
  2967. const textNode = document.createTextNode(String(counter));
  2968. observer.observe(textNode, {
  2969. characterData: true
  2970. });
  2971. timerFunc = () => {
  2972. counter = (counter + 1) % 2;
  2973. textNode.data = String(counter);
  2974. };
  2975. isUsingMicroTask = true;
  2976. }
  2977. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  2978. // Fallback to setImmediate.
  2979. // Technically it leverages the (macro) task queue,
  2980. // but it is still a better choice than setTimeout.
  2981. timerFunc = () => {
  2982. setImmediate(flushCallbacks);
  2983. };
  2984. }
  2985. else {
  2986. // Fallback to setTimeout.
  2987. timerFunc = () => {
  2988. setTimeout(flushCallbacks, 0);
  2989. };
  2990. }
  2991. /**
  2992. * @internal
  2993. */
  2994. function nextTick(cb, ctx) {
  2995. let _resolve;
  2996. callbacks.push(() => {
  2997. if (cb) {
  2998. try {
  2999. cb.call(ctx);
  3000. }
  3001. catch (e) {
  3002. handleError(e, ctx, 'nextTick');
  3003. }
  3004. }
  3005. else if (_resolve) {
  3006. _resolve(ctx);
  3007. }
  3008. });
  3009. if (!pending) {
  3010. pending = true;
  3011. timerFunc();
  3012. }
  3013. // $flow-disable-line
  3014. if (!cb && typeof Promise !== 'undefined') {
  3015. return new Promise(resolve => {
  3016. _resolve = resolve;
  3017. });
  3018. }
  3019. }
  3020. function useCssModule(name = '$style') {
  3021. /* istanbul ignore else */
  3022. {
  3023. if (!currentInstance) {
  3024. warn(`useCssModule must be called inside setup()`);
  3025. return emptyObject;
  3026. }
  3027. const mod = currentInstance[name];
  3028. if (!mod) {
  3029. warn(`Current instance does not have CSS module named "${name}".`);
  3030. return emptyObject;
  3031. }
  3032. return mod;
  3033. }
  3034. }
  3035. /**
  3036. * Runtime helper for SFC's CSS variable injection feature.
  3037. * @private
  3038. */
  3039. function useCssVars(getter) {
  3040. if (!inBrowser && !false)
  3041. return;
  3042. const instance = currentInstance;
  3043. if (!instance) {
  3044. warn(`useCssVars is called without current active component instance.`);
  3045. return;
  3046. }
  3047. watchPostEffect(() => {
  3048. const el = instance.$el;
  3049. const vars = getter(instance, instance._setupProxy);
  3050. if (el && el.nodeType === 1) {
  3051. const style = el.style;
  3052. for (const key in vars) {
  3053. style.setProperty(`--${key}`, vars[key]);
  3054. }
  3055. }
  3056. });
  3057. }
  3058. /**
  3059. * v3-compatible async component API.
  3060. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3061. * because it relies on existing manual types
  3062. */
  3063. function defineAsyncComponent(source) {
  3064. if (isFunction(source)) {
  3065. source = { loader: source };
  3066. }
  3067. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3068. suspensible = false, // in Vue 3 default is true
  3069. onError: userOnError } = source;
  3070. if (suspensible) {
  3071. warn(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3072. }
  3073. let pendingRequest = null;
  3074. let retries = 0;
  3075. const retry = () => {
  3076. retries++;
  3077. pendingRequest = null;
  3078. return load();
  3079. };
  3080. const load = () => {
  3081. let thisRequest;
  3082. return (pendingRequest ||
  3083. (thisRequest = pendingRequest =
  3084. loader()
  3085. .catch(err => {
  3086. err = err instanceof Error ? err : new Error(String(err));
  3087. if (userOnError) {
  3088. return new Promise((resolve, reject) => {
  3089. const userRetry = () => resolve(retry());
  3090. const userFail = () => reject(err);
  3091. userOnError(err, userRetry, userFail, retries + 1);
  3092. });
  3093. }
  3094. else {
  3095. throw err;
  3096. }
  3097. })
  3098. .then((comp) => {
  3099. if (thisRequest !== pendingRequest && pendingRequest) {
  3100. return pendingRequest;
  3101. }
  3102. if (!comp) {
  3103. warn(`Async component loader resolved to undefined. ` +
  3104. `If you are using retry(), make sure to return its return value.`);
  3105. }
  3106. // interop module default
  3107. if (comp &&
  3108. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3109. comp = comp.default;
  3110. }
  3111. if (comp && !isObject(comp) && !isFunction(comp)) {
  3112. throw new Error(`Invalid async component load result: ${comp}`);
  3113. }
  3114. return comp;
  3115. })));
  3116. };
  3117. return () => {
  3118. const component = load();
  3119. return {
  3120. component,
  3121. delay,
  3122. timeout,
  3123. error: errorComponent,
  3124. loading: loadingComponent
  3125. };
  3126. };
  3127. }
  3128. function createLifeCycle(hookName) {
  3129. return (fn, target = currentInstance) => {
  3130. if (!target) {
  3131. warn(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3132. `associated with. ` +
  3133. `Lifecycle injection APIs can only be used during execution of setup().`);
  3134. return;
  3135. }
  3136. return injectHook(target, hookName, fn);
  3137. };
  3138. }
  3139. function formatName(name) {
  3140. if (name === 'beforeDestroy') {
  3141. name = 'beforeUnmount';
  3142. }
  3143. else if (name === 'destroyed') {
  3144. name = 'unmounted';
  3145. }
  3146. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3147. }
  3148. function injectHook(instance, hookName, fn) {
  3149. const options = instance.$options;
  3150. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3151. }
  3152. const onBeforeMount = createLifeCycle('beforeMount');
  3153. const onMounted = createLifeCycle('mounted');
  3154. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3155. const onUpdated = createLifeCycle('updated');
  3156. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3157. const onUnmounted = createLifeCycle('destroyed');
  3158. const onActivated = createLifeCycle('activated');
  3159. const onDeactivated = createLifeCycle('deactivated');
  3160. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3161. const onRenderTracked = createLifeCycle('renderTracked');
  3162. const onRenderTriggered = createLifeCycle('renderTriggered');
  3163. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3164. function onErrorCaptured(hook, target = currentInstance) {
  3165. injectErrorCapturedHook(hook, target);
  3166. }
  3167. /**
  3168. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3169. */
  3170. const version = '2.7.12';
  3171. /**
  3172. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3173. */
  3174. function defineComponent(options) {
  3175. return options;
  3176. }
  3177. var vca = /*#__PURE__*/Object.freeze({
  3178. __proto__: null,
  3179. version: version,
  3180. defineComponent: defineComponent,
  3181. ref: ref$1,
  3182. shallowRef: shallowRef,
  3183. isRef: isRef,
  3184. toRef: toRef,
  3185. toRefs: toRefs,
  3186. unref: unref,
  3187. proxyRefs: proxyRefs,
  3188. customRef: customRef,
  3189. triggerRef: triggerRef,
  3190. reactive: reactive,
  3191. isReactive: isReactive,
  3192. isReadonly: isReadonly,
  3193. isShallow: isShallow,
  3194. isProxy: isProxy,
  3195. shallowReactive: shallowReactive,
  3196. markRaw: markRaw,
  3197. toRaw: toRaw,
  3198. readonly: readonly,
  3199. shallowReadonly: shallowReadonly,
  3200. computed: computed,
  3201. watch: watch,
  3202. watchEffect: watchEffect,
  3203. watchPostEffect: watchPostEffect,
  3204. watchSyncEffect: watchSyncEffect,
  3205. EffectScope: EffectScope,
  3206. effectScope: effectScope,
  3207. onScopeDispose: onScopeDispose,
  3208. getCurrentScope: getCurrentScope,
  3209. provide: provide,
  3210. inject: inject,
  3211. h: h,
  3212. getCurrentInstance: getCurrentInstance,
  3213. useSlots: useSlots,
  3214. useAttrs: useAttrs,
  3215. useListeners: useListeners,
  3216. mergeDefaults: mergeDefaults,
  3217. nextTick: nextTick,
  3218. set: set,
  3219. del: del,
  3220. useCssModule: useCssModule,
  3221. useCssVars: useCssVars,
  3222. defineAsyncComponent: defineAsyncComponent,
  3223. onBeforeMount: onBeforeMount,
  3224. onMounted: onMounted,
  3225. onBeforeUpdate: onBeforeUpdate,
  3226. onUpdated: onUpdated,
  3227. onBeforeUnmount: onBeforeUnmount,
  3228. onUnmounted: onUnmounted,
  3229. onActivated: onActivated,
  3230. onDeactivated: onDeactivated,
  3231. onServerPrefetch: onServerPrefetch,
  3232. onRenderTracked: onRenderTracked,
  3233. onRenderTriggered: onRenderTriggered,
  3234. onErrorCaptured: onErrorCaptured
  3235. });
  3236. const seenObjects = new _Set();
  3237. /**
  3238. * Recursively traverse an object to evoke all converted
  3239. * getters, so that every nested property inside the object
  3240. * is collected as a "deep" dependency.
  3241. */
  3242. function traverse(val) {
  3243. _traverse(val, seenObjects);
  3244. seenObjects.clear();
  3245. return val;
  3246. }
  3247. function _traverse(val, seen) {
  3248. let i, keys;
  3249. const isA = isArray(val);
  3250. if ((!isA && !isObject(val)) ||
  3251. Object.isFrozen(val) ||
  3252. val instanceof VNode) {
  3253. return;
  3254. }
  3255. if (val.__ob__) {
  3256. const depId = val.__ob__.dep.id;
  3257. if (seen.has(depId)) {
  3258. return;
  3259. }
  3260. seen.add(depId);
  3261. }
  3262. if (isA) {
  3263. i = val.length;
  3264. while (i--)
  3265. _traverse(val[i], seen);
  3266. }
  3267. else if (isRef(val)) {
  3268. _traverse(val.value, seen);
  3269. }
  3270. else {
  3271. keys = Object.keys(val);
  3272. i = keys.length;
  3273. while (i--)
  3274. _traverse(val[keys[i]], seen);
  3275. }
  3276. }
  3277. let uid$1 = 0;
  3278. /**
  3279. * A watcher parses an expression, collects dependencies,
  3280. * and fires callback when the expression value changes.
  3281. * This is used for both the $watch() api and directives.
  3282. * @internal
  3283. */
  3284. class Watcher {
  3285. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3286. recordEffectScope(this,
  3287. // if the active effect scope is manually created (not a component scope),
  3288. // prioritize it
  3289. activeEffectScope && !activeEffectScope._vm
  3290. ? activeEffectScope
  3291. : vm
  3292. ? vm._scope
  3293. : undefined);
  3294. if ((this.vm = vm) && isRenderWatcher) {
  3295. vm._watcher = this;
  3296. }
  3297. // options
  3298. if (options) {
  3299. this.deep = !!options.deep;
  3300. this.user = !!options.user;
  3301. this.lazy = !!options.lazy;
  3302. this.sync = !!options.sync;
  3303. this.before = options.before;
  3304. {
  3305. this.onTrack = options.onTrack;
  3306. this.onTrigger = options.onTrigger;
  3307. }
  3308. }
  3309. else {
  3310. this.deep = this.user = this.lazy = this.sync = false;
  3311. }
  3312. this.cb = cb;
  3313. this.id = ++uid$1; // uid for batching
  3314. this.active = true;
  3315. this.post = false;
  3316. this.dirty = this.lazy; // for lazy watchers
  3317. this.deps = [];
  3318. this.newDeps = [];
  3319. this.depIds = new _Set();
  3320. this.newDepIds = new _Set();
  3321. this.expression = expOrFn.toString() ;
  3322. // parse expression for getter
  3323. if (isFunction(expOrFn)) {
  3324. this.getter = expOrFn;
  3325. }
  3326. else {
  3327. this.getter = parsePath(expOrFn);
  3328. if (!this.getter) {
  3329. this.getter = noop;
  3330. warn(`Failed watching path: "${expOrFn}" ` +
  3331. 'Watcher only accepts simple dot-delimited paths. ' +
  3332. 'For full control, use a function instead.', vm);
  3333. }
  3334. }
  3335. this.value = this.lazy ? undefined : this.get();
  3336. }
  3337. /**
  3338. * Evaluate the getter, and re-collect dependencies.
  3339. */
  3340. get() {
  3341. pushTarget(this);
  3342. let value;
  3343. const vm = this.vm;
  3344. try {
  3345. value = this.getter.call(vm, vm);
  3346. }
  3347. catch (e) {
  3348. if (this.user) {
  3349. handleError(e, vm, `getter for watcher "${this.expression}"`);
  3350. }
  3351. else {
  3352. throw e;
  3353. }
  3354. }
  3355. finally {
  3356. // "touch" every property so they are all tracked as
  3357. // dependencies for deep watching
  3358. if (this.deep) {
  3359. traverse(value);
  3360. }
  3361. popTarget();
  3362. this.cleanupDeps();
  3363. }
  3364. return value;
  3365. }
  3366. /**
  3367. * Add a dependency to this directive.
  3368. */
  3369. addDep(dep) {
  3370. const id = dep.id;
  3371. if (!this.newDepIds.has(id)) {
  3372. this.newDepIds.add(id);
  3373. this.newDeps.push(dep);
  3374. if (!this.depIds.has(id)) {
  3375. dep.addSub(this);
  3376. }
  3377. }
  3378. }
  3379. /**
  3380. * Clean up for dependency collection.
  3381. */
  3382. cleanupDeps() {
  3383. let i = this.deps.length;
  3384. while (i--) {
  3385. const dep = this.deps[i];
  3386. if (!this.newDepIds.has(dep.id)) {
  3387. dep.removeSub(this);
  3388. }
  3389. }
  3390. let tmp = this.depIds;
  3391. this.depIds = this.newDepIds;
  3392. this.newDepIds = tmp;
  3393. this.newDepIds.clear();
  3394. tmp = this.deps;
  3395. this.deps = this.newDeps;
  3396. this.newDeps = tmp;
  3397. this.newDeps.length = 0;
  3398. }
  3399. /**
  3400. * Subscriber interface.
  3401. * Will be called when a dependency changes.
  3402. */
  3403. update() {
  3404. /* istanbul ignore else */
  3405. if (this.lazy) {
  3406. this.dirty = true;
  3407. }
  3408. else if (this.sync) {
  3409. this.run();
  3410. }
  3411. else {
  3412. queueWatcher(this);
  3413. }
  3414. }
  3415. /**
  3416. * Scheduler job interface.
  3417. * Will be called by the scheduler.
  3418. */
  3419. run() {
  3420. if (this.active) {
  3421. const value = this.get();
  3422. if (value !== this.value ||
  3423. // Deep watchers and watchers on Object/Arrays should fire even
  3424. // when the value is the same, because the value may
  3425. // have mutated.
  3426. isObject(value) ||
  3427. this.deep) {
  3428. // set new value
  3429. const oldValue = this.value;
  3430. this.value = value;
  3431. if (this.user) {
  3432. const info = `callback for watcher "${this.expression}"`;
  3433. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  3434. }
  3435. else {
  3436. this.cb.call(this.vm, value, oldValue);
  3437. }
  3438. }
  3439. }
  3440. }
  3441. /**
  3442. * Evaluate the value of the watcher.
  3443. * This only gets called for lazy watchers.
  3444. */
  3445. evaluate() {
  3446. this.value = this.get();
  3447. this.dirty = false;
  3448. }
  3449. /**
  3450. * Depend on all deps collected by this watcher.
  3451. */
  3452. depend() {
  3453. let i = this.deps.length;
  3454. while (i--) {
  3455. this.deps[i].depend();
  3456. }
  3457. }
  3458. /**
  3459. * Remove self from all dependencies' subscriber list.
  3460. */
  3461. teardown() {
  3462. if (this.vm && !this.vm._isBeingDestroyed) {
  3463. remove$2(this.vm._scope.effects, this);
  3464. }
  3465. if (this.active) {
  3466. let i = this.deps.length;
  3467. while (i--) {
  3468. this.deps[i].removeSub(this);
  3469. }
  3470. this.active = false;
  3471. if (this.onStop) {
  3472. this.onStop();
  3473. }
  3474. }
  3475. }
  3476. }
  3477. let mark;
  3478. let measure;
  3479. {
  3480. const perf = inBrowser && window.performance;
  3481. /* istanbul ignore if */
  3482. if (perf &&
  3483. // @ts-ignore
  3484. perf.mark &&
  3485. // @ts-ignore
  3486. perf.measure &&
  3487. // @ts-ignore
  3488. perf.clearMarks &&
  3489. // @ts-ignore
  3490. perf.clearMeasures) {
  3491. mark = tag => perf.mark(tag);
  3492. measure = (name, startTag, endTag) => {
  3493. perf.measure(name, startTag, endTag);
  3494. perf.clearMarks(startTag);
  3495. perf.clearMarks(endTag);
  3496. // perf.clearMeasures(name)
  3497. };
  3498. }
  3499. }
  3500. function initEvents(vm) {
  3501. vm._events = Object.create(null);
  3502. vm._hasHookEvent = false;
  3503. // init parent attached events
  3504. const listeners = vm.$options._parentListeners;
  3505. if (listeners) {
  3506. updateComponentListeners(vm, listeners);
  3507. }
  3508. }
  3509. let target$1;
  3510. function add$1(event, fn) {
  3511. target$1.$on(event, fn);
  3512. }
  3513. function remove$1(event, fn) {
  3514. target$1.$off(event, fn);
  3515. }
  3516. function createOnceHandler$1(event, fn) {
  3517. const _target = target$1;
  3518. return function onceHandler() {
  3519. const res = fn.apply(null, arguments);
  3520. if (res !== null) {
  3521. _target.$off(event, onceHandler);
  3522. }
  3523. };
  3524. }
  3525. function updateComponentListeners(vm, listeners, oldListeners) {
  3526. target$1 = vm;
  3527. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  3528. target$1 = undefined;
  3529. }
  3530. function eventsMixin(Vue) {
  3531. const hookRE = /^hook:/;
  3532. Vue.prototype.$on = function (event, fn) {
  3533. const vm = this;
  3534. if (isArray(event)) {
  3535. for (let i = 0, l = event.length; i < l; i++) {
  3536. vm.$on(event[i], fn);
  3537. }
  3538. }
  3539. else {
  3540. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3541. // optimize hook:event cost by using a boolean flag marked at registration
  3542. // instead of a hash lookup
  3543. if (hookRE.test(event)) {
  3544. vm._hasHookEvent = true;
  3545. }
  3546. }
  3547. return vm;
  3548. };
  3549. Vue.prototype.$once = function (event, fn) {
  3550. const vm = this;
  3551. function on() {
  3552. vm.$off(event, on);
  3553. fn.apply(vm, arguments);
  3554. }
  3555. on.fn = fn;
  3556. vm.$on(event, on);
  3557. return vm;
  3558. };
  3559. Vue.prototype.$off = function (event, fn) {
  3560. const vm = this;
  3561. // all
  3562. if (!arguments.length) {
  3563. vm._events = Object.create(null);
  3564. return vm;
  3565. }
  3566. // array of events
  3567. if (isArray(event)) {
  3568. for (let i = 0, l = event.length; i < l; i++) {
  3569. vm.$off(event[i], fn);
  3570. }
  3571. return vm;
  3572. }
  3573. // specific event
  3574. const cbs = vm._events[event];
  3575. if (!cbs) {
  3576. return vm;
  3577. }
  3578. if (!fn) {
  3579. vm._events[event] = null;
  3580. return vm;
  3581. }
  3582. // specific handler
  3583. let cb;
  3584. let i = cbs.length;
  3585. while (i--) {
  3586. cb = cbs[i];
  3587. if (cb === fn || cb.fn === fn) {
  3588. cbs.splice(i, 1);
  3589. break;
  3590. }
  3591. }
  3592. return vm;
  3593. };
  3594. Vue.prototype.$emit = function (event) {
  3595. const vm = this;
  3596. {
  3597. const lowerCaseEvent = event.toLowerCase();
  3598. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3599. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  3600. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3601. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3602. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3603. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  3604. }
  3605. }
  3606. let cbs = vm._events[event];
  3607. if (cbs) {
  3608. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3609. const args = toArray(arguments, 1);
  3610. const info = `event handler for "${event}"`;
  3611. for (let i = 0, l = cbs.length; i < l; i++) {
  3612. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3613. }
  3614. }
  3615. return vm;
  3616. };
  3617. }
  3618. let activeInstance = null;
  3619. let isUpdatingChildComponent = false;
  3620. function setActiveInstance(vm) {
  3621. const prevActiveInstance = activeInstance;
  3622. activeInstance = vm;
  3623. return () => {
  3624. activeInstance = prevActiveInstance;
  3625. };
  3626. }
  3627. function initLifecycle(vm) {
  3628. const options = vm.$options;
  3629. // locate first non-abstract parent
  3630. let parent = options.parent;
  3631. if (parent && !options.abstract) {
  3632. while (parent.$options.abstract && parent.$parent) {
  3633. parent = parent.$parent;
  3634. }
  3635. parent.$children.push(vm);
  3636. }
  3637. vm.$parent = parent;
  3638. vm.$root = parent ? parent.$root : vm;
  3639. vm.$children = [];
  3640. vm.$refs = {};
  3641. vm._provided = parent ? parent._provided : Object.create(null);
  3642. vm._watcher = null;
  3643. vm._inactive = null;
  3644. vm._directInactive = false;
  3645. vm._isMounted = false;
  3646. vm._isDestroyed = false;
  3647. vm._isBeingDestroyed = false;
  3648. }
  3649. function lifecycleMixin(Vue) {
  3650. Vue.prototype._update = function (vnode, hydrating) {
  3651. const vm = this;
  3652. const prevEl = vm.$el;
  3653. const prevVnode = vm._vnode;
  3654. const restoreActiveInstance = setActiveInstance(vm);
  3655. vm._vnode = vnode;
  3656. // Vue.prototype.__patch__ is injected in entry points
  3657. // based on the rendering backend used.
  3658. if (!prevVnode) {
  3659. // initial render
  3660. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3661. }
  3662. else {
  3663. // updates
  3664. vm.$el = vm.__patch__(prevVnode, vnode);
  3665. }
  3666. restoreActiveInstance();
  3667. // update __vue__ reference
  3668. if (prevEl) {
  3669. prevEl.__vue__ = null;
  3670. }
  3671. if (vm.$el) {
  3672. vm.$el.__vue__ = vm;
  3673. }
  3674. // if parent is an HOC, update its $el as well
  3675. let wrapper = vm;
  3676. while (wrapper &&
  3677. wrapper.$vnode &&
  3678. wrapper.$parent &&
  3679. wrapper.$vnode === wrapper.$parent._vnode) {
  3680. wrapper.$parent.$el = wrapper.$el;
  3681. wrapper = wrapper.$parent;
  3682. }
  3683. // updated hook is called by the scheduler to ensure that children are
  3684. // updated in a parent's updated hook.
  3685. };
  3686. Vue.prototype.$forceUpdate = function () {
  3687. const vm = this;
  3688. if (vm._watcher) {
  3689. vm._watcher.update();
  3690. }
  3691. };
  3692. Vue.prototype.$destroy = function () {
  3693. const vm = this;
  3694. if (vm._isBeingDestroyed) {
  3695. return;
  3696. }
  3697. callHook$1(vm, 'beforeDestroy');
  3698. vm._isBeingDestroyed = true;
  3699. // remove self from parent
  3700. const parent = vm.$parent;
  3701. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3702. remove$2(parent.$children, vm);
  3703. }
  3704. // teardown scope. this includes both the render watcher and other
  3705. // watchers created
  3706. vm._scope.stop();
  3707. // remove reference from data ob
  3708. // frozen object may not have observer.
  3709. if (vm._data.__ob__) {
  3710. vm._data.__ob__.vmCount--;
  3711. }
  3712. // call the last hook...
  3713. vm._isDestroyed = true;
  3714. // invoke destroy hooks on current rendered tree
  3715. vm.__patch__(vm._vnode, null);
  3716. // fire destroyed hook
  3717. callHook$1(vm, 'destroyed');
  3718. // turn off all instance listeners.
  3719. vm.$off();
  3720. // remove __vue__ reference
  3721. if (vm.$el) {
  3722. vm.$el.__vue__ = null;
  3723. }
  3724. // release circular reference (#6759)
  3725. if (vm.$vnode) {
  3726. vm.$vnode.parent = null;
  3727. }
  3728. };
  3729. }
  3730. function mountComponent(vm, el, hydrating) {
  3731. vm.$el = el;
  3732. if (!vm.$options.render) {
  3733. // @ts-expect-error invalid type
  3734. vm.$options.render = createEmptyVNode;
  3735. {
  3736. /* istanbul ignore if */
  3737. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3738. vm.$options.el ||
  3739. el) {
  3740. warn('You are using the runtime-only build of Vue where the template ' +
  3741. 'compiler is not available. Either pre-compile the templates into ' +
  3742. 'render functions, or use the compiler-included build.', vm);
  3743. }
  3744. else {
  3745. warn('Failed to mount component: template or render function not defined.', vm);
  3746. }
  3747. }
  3748. }
  3749. callHook$1(vm, 'beforeMount');
  3750. let updateComponent;
  3751. /* istanbul ignore if */
  3752. if (config.performance && mark) {
  3753. updateComponent = () => {
  3754. const name = vm._name;
  3755. const id = vm._uid;
  3756. const startTag = `vue-perf-start:${id}`;
  3757. const endTag = `vue-perf-end:${id}`;
  3758. mark(startTag);
  3759. const vnode = vm._render();
  3760. mark(endTag);
  3761. measure(`vue ${name} render`, startTag, endTag);
  3762. mark(startTag);
  3763. vm._update(vnode, hydrating);
  3764. mark(endTag);
  3765. measure(`vue ${name} patch`, startTag, endTag);
  3766. };
  3767. }
  3768. else {
  3769. updateComponent = () => {
  3770. vm._update(vm._render(), hydrating);
  3771. };
  3772. }
  3773. const watcherOptions = {
  3774. before() {
  3775. if (vm._isMounted && !vm._isDestroyed) {
  3776. callHook$1(vm, 'beforeUpdate');
  3777. }
  3778. }
  3779. };
  3780. {
  3781. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  3782. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  3783. }
  3784. // we set this to vm._watcher inside the watcher's constructor
  3785. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3786. // component's mounted hook), which relies on vm._watcher being already defined
  3787. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  3788. hydrating = false;
  3789. // flush buffer for flush: "pre" watchers queued in setup()
  3790. const preWatchers = vm._preWatchers;
  3791. if (preWatchers) {
  3792. for (let i = 0; i < preWatchers.length; i++) {
  3793. preWatchers[i].run();
  3794. }
  3795. }
  3796. // manually mounted instance, call mounted on self
  3797. // mounted is called for render-created child components in its inserted hook
  3798. if (vm.$vnode == null) {
  3799. vm._isMounted = true;
  3800. callHook$1(vm, 'mounted');
  3801. }
  3802. return vm;
  3803. }
  3804. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  3805. {
  3806. isUpdatingChildComponent = true;
  3807. }
  3808. // determine whether component has slot children
  3809. // we need to do this before overwriting $options._renderChildren.
  3810. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3811. // dynamic slot names). Static scoped slots compiled from template has the
  3812. // "$stable" marker.
  3813. const newScopedSlots = parentVnode.data.scopedSlots;
  3814. const oldScopedSlots = vm.$scopedSlots;
  3815. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3816. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3817. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3818. (!newScopedSlots && vm.$scopedSlots.$key));
  3819. // Any static slot children from the parent may have changed during parent's
  3820. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3821. // update is necessary to ensure correctness.
  3822. let needsForceUpdate = !!(renderChildren || // has new static slots
  3823. vm.$options._renderChildren || // has old static slots
  3824. hasDynamicScopedSlot);
  3825. const prevVNode = vm.$vnode;
  3826. vm.$options._parentVnode = parentVnode;
  3827. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3828. if (vm._vnode) {
  3829. // update child tree's parent
  3830. vm._vnode.parent = parentVnode;
  3831. }
  3832. vm.$options._renderChildren = renderChildren;
  3833. // update $attrs and $listeners hash
  3834. // these are also reactive so they may trigger child update if the child
  3835. // used them during render
  3836. const attrs = parentVnode.data.attrs || emptyObject;
  3837. if (vm._attrsProxy) {
  3838. // force update if attrs are accessed and has changed since it may be
  3839. // passed to a child component.
  3840. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3841. needsForceUpdate = true;
  3842. }
  3843. }
  3844. vm.$attrs = attrs;
  3845. // update listeners
  3846. listeners = listeners || emptyObject;
  3847. const prevListeners = vm.$options._parentListeners;
  3848. if (vm._listenersProxy) {
  3849. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3850. }
  3851. vm.$listeners = vm.$options._parentListeners = listeners;
  3852. updateComponentListeners(vm, listeners, prevListeners);
  3853. // update props
  3854. if (propsData && vm.$options.props) {
  3855. toggleObserving(false);
  3856. const props = vm._props;
  3857. const propKeys = vm.$options._propKeys || [];
  3858. for (let i = 0; i < propKeys.length; i++) {
  3859. const key = propKeys[i];
  3860. const propOptions = vm.$options.props; // wtf flow?
  3861. props[key] = validateProp(key, propOptions, propsData, vm);
  3862. }
  3863. toggleObserving(true);
  3864. // keep a copy of raw propsData
  3865. vm.$options.propsData = propsData;
  3866. }
  3867. // resolve slots + force update if has children
  3868. if (needsForceUpdate) {
  3869. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3870. vm.$forceUpdate();
  3871. }
  3872. {
  3873. isUpdatingChildComponent = false;
  3874. }
  3875. }
  3876. function isInInactiveTree(vm) {
  3877. while (vm && (vm = vm.$parent)) {
  3878. if (vm._inactive)
  3879. return true;
  3880. }
  3881. return false;
  3882. }
  3883. function activateChildComponent(vm, direct) {
  3884. if (direct) {
  3885. vm._directInactive = false;
  3886. if (isInInactiveTree(vm)) {
  3887. return;
  3888. }
  3889. }
  3890. else if (vm._directInactive) {
  3891. return;
  3892. }
  3893. if (vm._inactive || vm._inactive === null) {
  3894. vm._inactive = false;
  3895. for (let i = 0; i < vm.$children.length; i++) {
  3896. activateChildComponent(vm.$children[i]);
  3897. }
  3898. callHook$1(vm, 'activated');
  3899. }
  3900. }
  3901. function deactivateChildComponent(vm, direct) {
  3902. if (direct) {
  3903. vm._directInactive = true;
  3904. if (isInInactiveTree(vm)) {
  3905. return;
  3906. }
  3907. }
  3908. if (!vm._inactive) {
  3909. vm._inactive = true;
  3910. for (let i = 0; i < vm.$children.length; i++) {
  3911. deactivateChildComponent(vm.$children[i]);
  3912. }
  3913. callHook$1(vm, 'deactivated');
  3914. }
  3915. }
  3916. function callHook$1(vm, hook, args, setContext = true) {
  3917. // #7573 disable dep collection when invoking lifecycle hooks
  3918. pushTarget();
  3919. const prev = currentInstance;
  3920. setContext && setCurrentInstance(vm);
  3921. const handlers = vm.$options[hook];
  3922. const info = `${hook} hook`;
  3923. if (handlers) {
  3924. for (let i = 0, j = handlers.length; i < j; i++) {
  3925. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3926. }
  3927. }
  3928. if (vm._hasHookEvent) {
  3929. vm.$emit('hook:' + hook);
  3930. }
  3931. setContext && setCurrentInstance(prev);
  3932. popTarget();
  3933. }
  3934. const MAX_UPDATE_COUNT = 100;
  3935. const queue = [];
  3936. const activatedChildren = [];
  3937. let has = {};
  3938. let circular = {};
  3939. let waiting = false;
  3940. let flushing = false;
  3941. let index = 0;
  3942. /**
  3943. * Reset the scheduler's state.
  3944. */
  3945. function resetSchedulerState() {
  3946. index = queue.length = activatedChildren.length = 0;
  3947. has = {};
  3948. {
  3949. circular = {};
  3950. }
  3951. waiting = flushing = false;
  3952. }
  3953. // Async edge case #6566 requires saving the timestamp when event listeners are
  3954. // attached. However, calling performance.now() has a perf overhead especially
  3955. // if the page has thousands of event listeners. Instead, we take a timestamp
  3956. // every time the scheduler flushes and use that for all event listeners
  3957. // attached during that flush.
  3958. let currentFlushTimestamp = 0;
  3959. // Async edge case fix requires storing an event listener's attach timestamp.
  3960. let getNow = Date.now;
  3961. // Determine what event timestamp the browser is using. Annoyingly, the
  3962. // timestamp can either be hi-res (relative to page load) or low-res
  3963. // (relative to UNIX epoch), so in order to compare time we have to use the
  3964. // same timestamp type when saving the flush timestamp.
  3965. // All IE versions use low-res event timestamps, and have problematic clock
  3966. // implementations (#9632)
  3967. if (inBrowser && !isIE) {
  3968. const performance = window.performance;
  3969. if (performance &&
  3970. typeof performance.now === 'function' &&
  3971. getNow() > document.createEvent('Event').timeStamp) {
  3972. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3973. // smaller than it, it means the event is using a hi-res timestamp,
  3974. // and we need to use the hi-res version for event listener timestamps as
  3975. // well.
  3976. getNow = () => performance.now();
  3977. }
  3978. }
  3979. const sortCompareFn = (a, b) => {
  3980. if (a.post) {
  3981. if (!b.post)
  3982. return 1;
  3983. }
  3984. else if (b.post) {
  3985. return -1;
  3986. }
  3987. return a.id - b.id;
  3988. };
  3989. /**
  3990. * Flush both queues and run the watchers.
  3991. */
  3992. function flushSchedulerQueue() {
  3993. currentFlushTimestamp = getNow();
  3994. flushing = true;
  3995. let watcher, id;
  3996. // Sort queue before flush.
  3997. // This ensures that:
  3998. // 1. Components are updated from parent to child. (because parent is always
  3999. // created before the child)
  4000. // 2. A component's user watchers are run before its render watcher (because
  4001. // user watchers are created before the render watcher)
  4002. // 3. If a component is destroyed during a parent component's watcher run,
  4003. // its watchers can be skipped.
  4004. queue.sort(sortCompareFn);
  4005. // do not cache length because more watchers might be pushed
  4006. // as we run existing watchers
  4007. for (index = 0; index < queue.length; index++) {
  4008. watcher = queue[index];
  4009. if (watcher.before) {
  4010. watcher.before();
  4011. }
  4012. id = watcher.id;
  4013. has[id] = null;
  4014. watcher.run();
  4015. // in dev build, check and stop circular updates.
  4016. if (has[id] != null) {
  4017. circular[id] = (circular[id] || 0) + 1;
  4018. if (circular[id] > MAX_UPDATE_COUNT) {
  4019. warn('You may have an infinite update loop ' +
  4020. (watcher.user
  4021. ? `in watcher with expression "${watcher.expression}"`
  4022. : `in a component render function.`), watcher.vm);
  4023. break;
  4024. }
  4025. }
  4026. }
  4027. // keep copies of post queues before resetting state
  4028. const activatedQueue = activatedChildren.slice();
  4029. const updatedQueue = queue.slice();
  4030. resetSchedulerState();
  4031. // call component updated and activated hooks
  4032. callActivatedHooks(activatedQueue);
  4033. callUpdatedHooks(updatedQueue);
  4034. cleanupDeps();
  4035. // devtool hook
  4036. /* istanbul ignore if */
  4037. if (devtools && config.devtools) {
  4038. devtools.emit('flush');
  4039. }
  4040. }
  4041. function callUpdatedHooks(queue) {
  4042. let i = queue.length;
  4043. while (i--) {
  4044. const watcher = queue[i];
  4045. const vm = watcher.vm;
  4046. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  4047. callHook$1(vm, 'updated');
  4048. }
  4049. }
  4050. }
  4051. /**
  4052. * Queue a kept-alive component that was activated during patch.
  4053. * The queue will be processed after the entire tree has been patched.
  4054. */
  4055. function queueActivatedComponent(vm) {
  4056. // setting _inactive to false here so that a render function can
  4057. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4058. vm._inactive = false;
  4059. activatedChildren.push(vm);
  4060. }
  4061. function callActivatedHooks(queue) {
  4062. for (let i = 0; i < queue.length; i++) {
  4063. queue[i]._inactive = true;
  4064. activateChildComponent(queue[i], true /* true */);
  4065. }
  4066. }
  4067. /**
  4068. * Push a watcher into the watcher queue.
  4069. * Jobs with duplicate IDs will be skipped unless it's
  4070. * pushed when the queue is being flushed.
  4071. */
  4072. function queueWatcher(watcher) {
  4073. const id = watcher.id;
  4074. if (has[id] != null) {
  4075. return;
  4076. }
  4077. if (watcher === Dep.target && watcher.noRecurse) {
  4078. return;
  4079. }
  4080. has[id] = true;
  4081. if (!flushing) {
  4082. queue.push(watcher);
  4083. }
  4084. else {
  4085. // if already flushing, splice the watcher based on its id
  4086. // if already past its id, it will be run next immediately.
  4087. let i = queue.length - 1;
  4088. while (i > index && queue[i].id > watcher.id) {
  4089. i--;
  4090. }
  4091. queue.splice(i + 1, 0, watcher);
  4092. }
  4093. // queue the flush
  4094. if (!waiting) {
  4095. waiting = true;
  4096. if (!config.async) {
  4097. flushSchedulerQueue();
  4098. return;
  4099. }
  4100. nextTick(flushSchedulerQueue);
  4101. }
  4102. }
  4103. function initProvide(vm) {
  4104. const provideOption = vm.$options.provide;
  4105. if (provideOption) {
  4106. const provided = isFunction(provideOption)
  4107. ? provideOption.call(vm)
  4108. : provideOption;
  4109. if (!isObject(provided)) {
  4110. return;
  4111. }
  4112. const source = resolveProvided(vm);
  4113. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4114. // iterate the keys ourselves.
  4115. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4116. for (let i = 0; i < keys.length; i++) {
  4117. const key = keys[i];
  4118. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4119. }
  4120. }
  4121. }
  4122. function initInjections(vm) {
  4123. const result = resolveInject(vm.$options.inject, vm);
  4124. if (result) {
  4125. toggleObserving(false);
  4126. Object.keys(result).forEach(key => {
  4127. /* istanbul ignore else */
  4128. {
  4129. defineReactive(vm, key, result[key], () => {
  4130. warn(`Avoid mutating an injected value directly since the changes will be ` +
  4131. `overwritten whenever the provided component re-renders. ` +
  4132. `injection being mutated: "${key}"`, vm);
  4133. });
  4134. }
  4135. });
  4136. toggleObserving(true);
  4137. }
  4138. }
  4139. function resolveInject(inject, vm) {
  4140. if (inject) {
  4141. // inject is :any because flow is not smart enough to figure out cached
  4142. const result = Object.create(null);
  4143. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4144. for (let i = 0; i < keys.length; i++) {
  4145. const key = keys[i];
  4146. // #6574 in case the inject object is observed...
  4147. if (key === '__ob__')
  4148. continue;
  4149. const provideKey = inject[key].from;
  4150. if (provideKey in vm._provided) {
  4151. result[key] = vm._provided[provideKey];
  4152. }
  4153. else if ('default' in inject[key]) {
  4154. const provideDefault = inject[key].default;
  4155. result[key] = isFunction(provideDefault)
  4156. ? provideDefault.call(vm)
  4157. : provideDefault;
  4158. }
  4159. else {
  4160. warn(`Injection "${key}" not found`, vm);
  4161. }
  4162. }
  4163. return result;
  4164. }
  4165. }
  4166. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4167. const options = Ctor.options;
  4168. // ensure the createElement function in functional components
  4169. // gets a unique context - this is necessary for correct named slot check
  4170. let contextVm;
  4171. if (hasOwn(parent, '_uid')) {
  4172. contextVm = Object.create(parent);
  4173. contextVm._original = parent;
  4174. }
  4175. else {
  4176. // the context vm passed in is a functional context as well.
  4177. // in this case we want to make sure we are able to get a hold to the
  4178. // real context instance.
  4179. contextVm = parent;
  4180. // @ts-ignore
  4181. parent = parent._original;
  4182. }
  4183. const isCompiled = isTrue(options._compiled);
  4184. const needNormalization = !isCompiled;
  4185. this.data = data;
  4186. this.props = props;
  4187. this.children = children;
  4188. this.parent = parent;
  4189. this.listeners = data.on || emptyObject;
  4190. this.injections = resolveInject(options.inject, parent);
  4191. this.slots = () => {
  4192. if (!this.$slots) {
  4193. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4194. }
  4195. return this.$slots;
  4196. };
  4197. Object.defineProperty(this, 'scopedSlots', {
  4198. enumerable: true,
  4199. get() {
  4200. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4201. }
  4202. });
  4203. // support for compiled functional template
  4204. if (isCompiled) {
  4205. // exposing $options for renderStatic()
  4206. this.$options = options;
  4207. // pre-resolve slots for renderSlot()
  4208. this.$slots = this.slots();
  4209. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4210. }
  4211. if (options._scopeId) {
  4212. this._c = (a, b, c, d) => {
  4213. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4214. if (vnode && !isArray(vnode)) {
  4215. vnode.fnScopeId = options._scopeId;
  4216. vnode.fnContext = parent;
  4217. }
  4218. return vnode;
  4219. };
  4220. }
  4221. else {
  4222. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4223. }
  4224. }
  4225. installRenderHelpers(FunctionalRenderContext.prototype);
  4226. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4227. const options = Ctor.options;
  4228. const props = {};
  4229. const propOptions = options.props;
  4230. if (isDef(propOptions)) {
  4231. for (const key in propOptions) {
  4232. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4233. }
  4234. }
  4235. else {
  4236. if (isDef(data.attrs))
  4237. mergeProps(props, data.attrs);
  4238. if (isDef(data.props))
  4239. mergeProps(props, data.props);
  4240. }
  4241. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4242. const vnode = options.render.call(null, renderContext._c, renderContext);
  4243. if (vnode instanceof VNode) {
  4244. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4245. }
  4246. else if (isArray(vnode)) {
  4247. const vnodes = normalizeChildren(vnode) || [];
  4248. const res = new Array(vnodes.length);
  4249. for (let i = 0; i < vnodes.length; i++) {
  4250. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4251. }
  4252. return res;
  4253. }
  4254. }
  4255. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4256. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4257. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4258. // that should not be matched to match.
  4259. const clone = cloneVNode(vnode);
  4260. clone.fnContext = contextVm;
  4261. clone.fnOptions = options;
  4262. {
  4263. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4264. renderContext;
  4265. }
  4266. if (data.slot) {
  4267. (clone.data || (clone.data = {})).slot = data.slot;
  4268. }
  4269. return clone;
  4270. }
  4271. function mergeProps(to, from) {
  4272. for (const key in from) {
  4273. to[camelize(key)] = from[key];
  4274. }
  4275. }
  4276. function getComponentName(options) {
  4277. return options.name || options.__name || options._componentTag;
  4278. }
  4279. // inline hooks to be invoked on component VNodes during patch
  4280. const componentVNodeHooks = {
  4281. init(vnode, hydrating) {
  4282. if (vnode.componentInstance &&
  4283. !vnode.componentInstance._isDestroyed &&
  4284. vnode.data.keepAlive) {
  4285. // kept-alive components, treat as a patch
  4286. const mountedNode = vnode; // work around flow
  4287. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4288. }
  4289. else {
  4290. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4291. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4292. }
  4293. },
  4294. prepatch(oldVnode, vnode) {
  4295. const options = vnode.componentOptions;
  4296. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4297. updateChildComponent(child, options.propsData, // updated props
  4298. options.listeners, // updated listeners
  4299. vnode, // new parent vnode
  4300. options.children // new children
  4301. );
  4302. },
  4303. insert(vnode) {
  4304. const { context, componentInstance } = vnode;
  4305. if (!componentInstance._isMounted) {
  4306. componentInstance._isMounted = true;
  4307. callHook$1(componentInstance, 'mounted');
  4308. }
  4309. if (vnode.data.keepAlive) {
  4310. if (context._isMounted) {
  4311. // vue-router#1212
  4312. // During updates, a kept-alive component's child components may
  4313. // change, so directly walking the tree here may call activated hooks
  4314. // on incorrect children. Instead we push them into a queue which will
  4315. // be processed after the whole patch process ended.
  4316. queueActivatedComponent(componentInstance);
  4317. }
  4318. else {
  4319. activateChildComponent(componentInstance, true /* direct */);
  4320. }
  4321. }
  4322. },
  4323. destroy(vnode) {
  4324. const { componentInstance } = vnode;
  4325. if (!componentInstance._isDestroyed) {
  4326. if (!vnode.data.keepAlive) {
  4327. componentInstance.$destroy();
  4328. }
  4329. else {
  4330. deactivateChildComponent(componentInstance, true /* direct */);
  4331. }
  4332. }
  4333. }
  4334. };
  4335. const hooksToMerge = Object.keys(componentVNodeHooks);
  4336. function createComponent(Ctor, data, context, children, tag) {
  4337. if (isUndef(Ctor)) {
  4338. return;
  4339. }
  4340. const baseCtor = context.$options._base;
  4341. // plain options object: turn it into a constructor
  4342. if (isObject(Ctor)) {
  4343. Ctor = baseCtor.extend(Ctor);
  4344. }
  4345. // if at this stage it's not a constructor or an async component factory,
  4346. // reject.
  4347. if (typeof Ctor !== 'function') {
  4348. {
  4349. warn(`Invalid Component definition: ${String(Ctor)}`, context);
  4350. }
  4351. return;
  4352. }
  4353. // async component
  4354. let asyncFactory;
  4355. // @ts-expect-error
  4356. if (isUndef(Ctor.cid)) {
  4357. asyncFactory = Ctor;
  4358. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4359. if (Ctor === undefined) {
  4360. // return a placeholder node for async component, which is rendered
  4361. // as a comment node but preserves all the raw information for the node.
  4362. // the information will be used for async server-rendering and hydration.
  4363. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4364. }
  4365. }
  4366. data = data || {};
  4367. // resolve constructor options in case global mixins are applied after
  4368. // component constructor creation
  4369. resolveConstructorOptions(Ctor);
  4370. // transform component v-model data into props & events
  4371. if (isDef(data.model)) {
  4372. // @ts-expect-error
  4373. transformModel(Ctor.options, data);
  4374. }
  4375. // extract props
  4376. // @ts-expect-error
  4377. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4378. // functional component
  4379. // @ts-expect-error
  4380. if (isTrue(Ctor.options.functional)) {
  4381. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4382. }
  4383. // extract listeners, since these needs to be treated as
  4384. // child component listeners instead of DOM listeners
  4385. const listeners = data.on;
  4386. // replace with listeners with .native modifier
  4387. // so it gets processed during parent component patch.
  4388. data.on = data.nativeOn;
  4389. // @ts-expect-error
  4390. if (isTrue(Ctor.options.abstract)) {
  4391. // abstract components do not keep anything
  4392. // other than props & listeners & slot
  4393. // work around flow
  4394. const slot = data.slot;
  4395. data = {};
  4396. if (slot) {
  4397. data.slot = slot;
  4398. }
  4399. }
  4400. // install component management hooks onto the placeholder node
  4401. installComponentHooks(data);
  4402. // return a placeholder vnode
  4403. // @ts-expect-error
  4404. const name = getComponentName(Ctor.options) || tag;
  4405. const vnode = new VNode(
  4406. // @ts-expect-error
  4407. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4408. // @ts-expect-error
  4409. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4410. return vnode;
  4411. }
  4412. function createComponentInstanceForVnode(
  4413. // we know it's MountedComponentVNode but flow doesn't
  4414. vnode,
  4415. // activeInstance in lifecycle state
  4416. parent) {
  4417. const options = {
  4418. _isComponent: true,
  4419. _parentVnode: vnode,
  4420. parent
  4421. };
  4422. // check inline-template render functions
  4423. const inlineTemplate = vnode.data.inlineTemplate;
  4424. if (isDef(inlineTemplate)) {
  4425. options.render = inlineTemplate.render;
  4426. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4427. }
  4428. return new vnode.componentOptions.Ctor(options);
  4429. }
  4430. function installComponentHooks(data) {
  4431. const hooks = data.hook || (data.hook = {});
  4432. for (let i = 0; i < hooksToMerge.length; i++) {
  4433. const key = hooksToMerge[i];
  4434. const existing = hooks[key];
  4435. const toMerge = componentVNodeHooks[key];
  4436. // @ts-expect-error
  4437. if (existing !== toMerge && !(existing && existing._merged)) {
  4438. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4439. }
  4440. }
  4441. }
  4442. function mergeHook(f1, f2) {
  4443. const merged = (a, b) => {
  4444. // flow complains about extra args which is why we use any
  4445. f1(a, b);
  4446. f2(a, b);
  4447. };
  4448. merged._merged = true;
  4449. return merged;
  4450. }
  4451. // transform component v-model info (value and callback) into
  4452. // prop and event handler respectively.
  4453. function transformModel(options, data) {
  4454. const prop = (options.model && options.model.prop) || 'value';
  4455. const event = (options.model && options.model.event) || 'input';
  4456. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4457. const on = data.on || (data.on = {});
  4458. const existing = on[event];
  4459. const callback = data.model.callback;
  4460. if (isDef(existing)) {
  4461. if (isArray(existing)
  4462. ? existing.indexOf(callback) === -1
  4463. : existing !== callback) {
  4464. on[event] = [callback].concat(existing);
  4465. }
  4466. }
  4467. else {
  4468. on[event] = callback;
  4469. }
  4470. }
  4471. let warn = noop;
  4472. let tip = noop;
  4473. let generateComponentTrace; // work around flow check
  4474. let formatComponentName;
  4475. {
  4476. const hasConsole = typeof console !== 'undefined';
  4477. const classifyRE = /(?:^|[-_])(\w)/g;
  4478. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4479. warn = (msg, vm = currentInstance) => {
  4480. const trace = vm ? generateComponentTrace(vm) : '';
  4481. if (config.warnHandler) {
  4482. config.warnHandler.call(null, msg, vm, trace);
  4483. }
  4484. else if (hasConsole && !config.silent) {
  4485. console.error(`[Vue warn]: ${msg}${trace}`);
  4486. }
  4487. };
  4488. tip = (msg, vm) => {
  4489. if (hasConsole && !config.silent) {
  4490. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4491. }
  4492. };
  4493. formatComponentName = (vm, includeFile) => {
  4494. if (vm.$root === vm) {
  4495. return '<Root>';
  4496. }
  4497. const options = isFunction(vm) && vm.cid != null
  4498. ? vm.options
  4499. : vm._isVue
  4500. ? vm.$options || vm.constructor.options
  4501. : vm;
  4502. let name = getComponentName(options);
  4503. const file = options.__file;
  4504. if (!name && file) {
  4505. const match = file.match(/([^/\\]+)\.vue$/);
  4506. name = match && match[1];
  4507. }
  4508. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4509. (file && includeFile !== false ? ` at ${file}` : ''));
  4510. };
  4511. const repeat = (str, n) => {
  4512. let res = '';
  4513. while (n) {
  4514. if (n % 2 === 1)
  4515. res += str;
  4516. if (n > 1)
  4517. str += str;
  4518. n >>= 1;
  4519. }
  4520. return res;
  4521. };
  4522. generateComponentTrace = (vm) => {
  4523. if (vm._isVue && vm.$parent) {
  4524. const tree = [];
  4525. let currentRecursiveSequence = 0;
  4526. while (vm) {
  4527. if (tree.length > 0) {
  4528. const last = tree[tree.length - 1];
  4529. if (last.constructor === vm.constructor) {
  4530. currentRecursiveSequence++;
  4531. vm = vm.$parent;
  4532. continue;
  4533. }
  4534. else if (currentRecursiveSequence > 0) {
  4535. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4536. currentRecursiveSequence = 0;
  4537. }
  4538. }
  4539. tree.push(vm);
  4540. vm = vm.$parent;
  4541. }
  4542. return ('\n\nfound in\n\n' +
  4543. tree
  4544. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4545. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4546. : formatComponentName(vm)}`)
  4547. .join('\n'));
  4548. }
  4549. else {
  4550. return `\n\n(found in ${formatComponentName(vm)})`;
  4551. }
  4552. };
  4553. }
  4554. /**
  4555. * Option overwriting strategies are functions that handle
  4556. * how to merge a parent option value and a child option
  4557. * value into the final value.
  4558. */
  4559. const strats = config.optionMergeStrategies;
  4560. /**
  4561. * Options with restrictions
  4562. */
  4563. {
  4564. strats.el = strats.propsData = function (parent, child, vm, key) {
  4565. if (!vm) {
  4566. warn(`option "${key}" can only be used during instance ` +
  4567. 'creation with the `new` keyword.');
  4568. }
  4569. return defaultStrat(parent, child);
  4570. };
  4571. }
  4572. /**
  4573. * Helper that recursively merges two data objects together.
  4574. */
  4575. function mergeData(to, from) {
  4576. if (!from)
  4577. return to;
  4578. let key, toVal, fromVal;
  4579. const keys = hasSymbol
  4580. ? Reflect.ownKeys(from)
  4581. : Object.keys(from);
  4582. for (let i = 0; i < keys.length; i++) {
  4583. key = keys[i];
  4584. // in case the object is already observed...
  4585. if (key === '__ob__')
  4586. continue;
  4587. toVal = to[key];
  4588. fromVal = from[key];
  4589. if (!hasOwn(to, key)) {
  4590. set(to, key, fromVal);
  4591. }
  4592. else if (toVal !== fromVal &&
  4593. isPlainObject(toVal) &&
  4594. isPlainObject(fromVal)) {
  4595. mergeData(toVal, fromVal);
  4596. }
  4597. }
  4598. return to;
  4599. }
  4600. /**
  4601. * Data
  4602. */
  4603. function mergeDataOrFn(parentVal, childVal, vm) {
  4604. if (!vm) {
  4605. // in a Vue.extend merge, both should be functions
  4606. if (!childVal) {
  4607. return parentVal;
  4608. }
  4609. if (!parentVal) {
  4610. return childVal;
  4611. }
  4612. // when parentVal & childVal are both present,
  4613. // we need to return a function that returns the
  4614. // merged result of both functions... no need to
  4615. // check if parentVal is a function here because
  4616. // it has to be a function to pass previous merges.
  4617. return function mergedDataFn() {
  4618. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  4619. };
  4620. }
  4621. else {
  4622. return function mergedInstanceDataFn() {
  4623. // instance merge
  4624. const instanceData = isFunction(childVal)
  4625. ? childVal.call(vm, vm)
  4626. : childVal;
  4627. const defaultData = isFunction(parentVal)
  4628. ? parentVal.call(vm, vm)
  4629. : parentVal;
  4630. if (instanceData) {
  4631. return mergeData(instanceData, defaultData);
  4632. }
  4633. else {
  4634. return defaultData;
  4635. }
  4636. };
  4637. }
  4638. }
  4639. strats.data = function (parentVal, childVal, vm) {
  4640. if (!vm) {
  4641. if (childVal && typeof childVal !== 'function') {
  4642. warn('The "data" option should be a function ' +
  4643. 'that returns a per-instance value in component ' +
  4644. 'definitions.', vm);
  4645. return parentVal;
  4646. }
  4647. return mergeDataOrFn(parentVal, childVal);
  4648. }
  4649. return mergeDataOrFn(parentVal, childVal, vm);
  4650. };
  4651. /**
  4652. * Hooks and props are merged as arrays.
  4653. */
  4654. function mergeLifecycleHook(parentVal, childVal) {
  4655. const res = childVal
  4656. ? parentVal
  4657. ? parentVal.concat(childVal)
  4658. : isArray(childVal)
  4659. ? childVal
  4660. : [childVal]
  4661. : parentVal;
  4662. return res ? dedupeHooks(res) : res;
  4663. }
  4664. function dedupeHooks(hooks) {
  4665. const res = [];
  4666. for (let i = 0; i < hooks.length; i++) {
  4667. if (res.indexOf(hooks[i]) === -1) {
  4668. res.push(hooks[i]);
  4669. }
  4670. }
  4671. return res;
  4672. }
  4673. LIFECYCLE_HOOKS.forEach(hook => {
  4674. strats[hook] = mergeLifecycleHook;
  4675. });
  4676. /**
  4677. * Assets
  4678. *
  4679. * When a vm is present (instance creation), we need to do
  4680. * a three-way merge between constructor options, instance
  4681. * options and parent options.
  4682. */
  4683. function mergeAssets(parentVal, childVal, vm, key) {
  4684. const res = Object.create(parentVal || null);
  4685. if (childVal) {
  4686. assertObjectType(key, childVal, vm);
  4687. return extend(res, childVal);
  4688. }
  4689. else {
  4690. return res;
  4691. }
  4692. }
  4693. ASSET_TYPES.forEach(function (type) {
  4694. strats[type + 's'] = mergeAssets;
  4695. });
  4696. /**
  4697. * Watchers.
  4698. *
  4699. * Watchers hashes should not overwrite one
  4700. * another, so we merge them as arrays.
  4701. */
  4702. strats.watch = function (parentVal, childVal, vm, key) {
  4703. // work around Firefox's Object.prototype.watch...
  4704. //@ts-expect-error work around
  4705. if (parentVal === nativeWatch)
  4706. parentVal = undefined;
  4707. //@ts-expect-error work around
  4708. if (childVal === nativeWatch)
  4709. childVal = undefined;
  4710. /* istanbul ignore if */
  4711. if (!childVal)
  4712. return Object.create(parentVal || null);
  4713. {
  4714. assertObjectType(key, childVal, vm);
  4715. }
  4716. if (!parentVal)
  4717. return childVal;
  4718. const ret = {};
  4719. extend(ret, parentVal);
  4720. for (const key in childVal) {
  4721. let parent = ret[key];
  4722. const child = childVal[key];
  4723. if (parent && !isArray(parent)) {
  4724. parent = [parent];
  4725. }
  4726. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  4727. }
  4728. return ret;
  4729. };
  4730. /**
  4731. * Other object hashes.
  4732. */
  4733. strats.props =
  4734. strats.methods =
  4735. strats.inject =
  4736. strats.computed =
  4737. function (parentVal, childVal, vm, key) {
  4738. if (childVal && true) {
  4739. assertObjectType(key, childVal, vm);
  4740. }
  4741. if (!parentVal)
  4742. return childVal;
  4743. const ret = Object.create(null);
  4744. extend(ret, parentVal);
  4745. if (childVal)
  4746. extend(ret, childVal);
  4747. return ret;
  4748. };
  4749. strats.provide = mergeDataOrFn;
  4750. /**
  4751. * Default strategy.
  4752. */
  4753. const defaultStrat = function (parentVal, childVal) {
  4754. return childVal === undefined ? parentVal : childVal;
  4755. };
  4756. /**
  4757. * Validate component names
  4758. */
  4759. function checkComponents(options) {
  4760. for (const key in options.components) {
  4761. validateComponentName(key);
  4762. }
  4763. }
  4764. function validateComponentName(name) {
  4765. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  4766. warn('Invalid component name: "' +
  4767. name +
  4768. '". Component names ' +
  4769. 'should conform to valid custom element name in html5 specification.');
  4770. }
  4771. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  4772. warn('Do not use built-in or reserved HTML elements as component ' +
  4773. 'id: ' +
  4774. name);
  4775. }
  4776. }
  4777. /**
  4778. * Ensure all props option syntax are normalized into the
  4779. * Object-based format.
  4780. */
  4781. function normalizeProps(options, vm) {
  4782. const props = options.props;
  4783. if (!props)
  4784. return;
  4785. const res = {};
  4786. let i, val, name;
  4787. if (isArray(props)) {
  4788. i = props.length;
  4789. while (i--) {
  4790. val = props[i];
  4791. if (typeof val === 'string') {
  4792. name = camelize(val);
  4793. res[name] = { type: null };
  4794. }
  4795. else {
  4796. warn('props must be strings when using array syntax.');
  4797. }
  4798. }
  4799. }
  4800. else if (isPlainObject(props)) {
  4801. for (const key in props) {
  4802. val = props[key];
  4803. name = camelize(key);
  4804. res[name] = isPlainObject(val) ? val : { type: val };
  4805. }
  4806. }
  4807. else {
  4808. warn(`Invalid value for option "props": expected an Array or an Object, ` +
  4809. `but got ${toRawType(props)}.`, vm);
  4810. }
  4811. options.props = res;
  4812. }
  4813. /**
  4814. * Normalize all injections into Object-based format
  4815. */
  4816. function normalizeInject(options, vm) {
  4817. const inject = options.inject;
  4818. if (!inject)
  4819. return;
  4820. const normalized = (options.inject = {});
  4821. if (isArray(inject)) {
  4822. for (let i = 0; i < inject.length; i++) {
  4823. normalized[inject[i]] = { from: inject[i] };
  4824. }
  4825. }
  4826. else if (isPlainObject(inject)) {
  4827. for (const key in inject) {
  4828. const val = inject[key];
  4829. normalized[key] = isPlainObject(val)
  4830. ? extend({ from: key }, val)
  4831. : { from: val };
  4832. }
  4833. }
  4834. else {
  4835. warn(`Invalid value for option "inject": expected an Array or an Object, ` +
  4836. `but got ${toRawType(inject)}.`, vm);
  4837. }
  4838. }
  4839. /**
  4840. * Normalize raw function directives into object format.
  4841. */
  4842. function normalizeDirectives$1(options) {
  4843. const dirs = options.directives;
  4844. if (dirs) {
  4845. for (const key in dirs) {
  4846. const def = dirs[key];
  4847. if (isFunction(def)) {
  4848. dirs[key] = { bind: def, update: def };
  4849. }
  4850. }
  4851. }
  4852. }
  4853. function assertObjectType(name, value, vm) {
  4854. if (!isPlainObject(value)) {
  4855. warn(`Invalid value for option "${name}": expected an Object, ` +
  4856. `but got ${toRawType(value)}.`, vm);
  4857. }
  4858. }
  4859. /**
  4860. * Merge two option objects into a new one.
  4861. * Core utility used in both instantiation and inheritance.
  4862. */
  4863. function mergeOptions(parent, child, vm) {
  4864. {
  4865. checkComponents(child);
  4866. }
  4867. if (isFunction(child)) {
  4868. // @ts-expect-error
  4869. child = child.options;
  4870. }
  4871. normalizeProps(child, vm);
  4872. normalizeInject(child, vm);
  4873. normalizeDirectives$1(child);
  4874. // Apply extends and mixins on the child options,
  4875. // but only if it is a raw options object that isn't
  4876. // the result of another mergeOptions call.
  4877. // Only merged options has the _base property.
  4878. if (!child._base) {
  4879. if (child.extends) {
  4880. parent = mergeOptions(parent, child.extends, vm);
  4881. }
  4882. if (child.mixins) {
  4883. for (let i = 0, l = child.mixins.length; i < l; i++) {
  4884. parent = mergeOptions(parent, child.mixins[i], vm);
  4885. }
  4886. }
  4887. }
  4888. const options = {};
  4889. let key;
  4890. for (key in parent) {
  4891. mergeField(key);
  4892. }
  4893. for (key in child) {
  4894. if (!hasOwn(parent, key)) {
  4895. mergeField(key);
  4896. }
  4897. }
  4898. function mergeField(key) {
  4899. const strat = strats[key] || defaultStrat;
  4900. options[key] = strat(parent[key], child[key], vm, key);
  4901. }
  4902. return options;
  4903. }
  4904. /**
  4905. * Resolve an asset.
  4906. * This function is used because child instances need access
  4907. * to assets defined in its ancestor chain.
  4908. */
  4909. function resolveAsset(options, type, id, warnMissing) {
  4910. /* istanbul ignore if */
  4911. if (typeof id !== 'string') {
  4912. return;
  4913. }
  4914. const assets = options[type];
  4915. // check local registration variations first
  4916. if (hasOwn(assets, id))
  4917. return assets[id];
  4918. const camelizedId = camelize(id);
  4919. if (hasOwn(assets, camelizedId))
  4920. return assets[camelizedId];
  4921. const PascalCaseId = capitalize(camelizedId);
  4922. if (hasOwn(assets, PascalCaseId))
  4923. return assets[PascalCaseId];
  4924. // fallback to prototype chain
  4925. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  4926. if (warnMissing && !res) {
  4927. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  4928. }
  4929. return res;
  4930. }
  4931. function validateProp(key, propOptions, propsData, vm) {
  4932. const prop = propOptions[key];
  4933. const absent = !hasOwn(propsData, key);
  4934. let value = propsData[key];
  4935. // boolean casting
  4936. const booleanIndex = getTypeIndex(Boolean, prop.type);
  4937. if (booleanIndex > -1) {
  4938. if (absent && !hasOwn(prop, 'default')) {
  4939. value = false;
  4940. }
  4941. else if (value === '' || value === hyphenate(key)) {
  4942. // only cast empty string / same name to boolean if
  4943. // boolean has higher priority
  4944. const stringIndex = getTypeIndex(String, prop.type);
  4945. if (stringIndex < 0 || booleanIndex < stringIndex) {
  4946. value = true;
  4947. }
  4948. }
  4949. }
  4950. // check default value
  4951. if (value === undefined) {
  4952. value = getPropDefaultValue(vm, prop, key);
  4953. // since the default value is a fresh copy,
  4954. // make sure to observe it.
  4955. const prevShouldObserve = shouldObserve;
  4956. toggleObserving(true);
  4957. observe(value);
  4958. toggleObserving(prevShouldObserve);
  4959. }
  4960. {
  4961. assertProp(prop, key, value, vm, absent);
  4962. }
  4963. return value;
  4964. }
  4965. /**
  4966. * Get the default value of a prop.
  4967. */
  4968. function getPropDefaultValue(vm, prop, key) {
  4969. // no default, return undefined
  4970. if (!hasOwn(prop, 'default')) {
  4971. return undefined;
  4972. }
  4973. const def = prop.default;
  4974. // warn against non-factory defaults for Object & Array
  4975. if (isObject(def)) {
  4976. warn('Invalid default value for prop "' +
  4977. key +
  4978. '": ' +
  4979. 'Props with type Object/Array must use a factory function ' +
  4980. 'to return the default value.', vm);
  4981. }
  4982. // the raw prop value was also undefined from previous render,
  4983. // return previous default value to avoid unnecessary watcher trigger
  4984. if (vm &&
  4985. vm.$options.propsData &&
  4986. vm.$options.propsData[key] === undefined &&
  4987. vm._props[key] !== undefined) {
  4988. return vm._props[key];
  4989. }
  4990. // call factory function for non-Function types
  4991. // a value is Function if its prototype is function even across different execution context
  4992. return isFunction(def) && getType(prop.type) !== 'Function'
  4993. ? def.call(vm)
  4994. : def;
  4995. }
  4996. /**
  4997. * Assert whether a prop is valid.
  4998. */
  4999. function assertProp(prop, name, value, vm, absent) {
  5000. if (prop.required && absent) {
  5001. warn('Missing required prop: "' + name + '"', vm);
  5002. return;
  5003. }
  5004. if (value == null && !prop.required) {
  5005. return;
  5006. }
  5007. let type = prop.type;
  5008. let valid = !type || type === true;
  5009. const expectedTypes = [];
  5010. if (type) {
  5011. if (!isArray(type)) {
  5012. type = [type];
  5013. }
  5014. for (let i = 0; i < type.length && !valid; i++) {
  5015. const assertedType = assertType(value, type[i], vm);
  5016. expectedTypes.push(assertedType.expectedType || '');
  5017. valid = assertedType.valid;
  5018. }
  5019. }
  5020. const haveExpectedTypes = expectedTypes.some(t => t);
  5021. if (!valid && haveExpectedTypes) {
  5022. warn(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5023. return;
  5024. }
  5025. const validator = prop.validator;
  5026. if (validator) {
  5027. if (!validator(value)) {
  5028. warn('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5029. }
  5030. }
  5031. }
  5032. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5033. function assertType(value, type, vm) {
  5034. let valid;
  5035. const expectedType = getType(type);
  5036. if (simpleCheckRE.test(expectedType)) {
  5037. const t = typeof value;
  5038. valid = t === expectedType.toLowerCase();
  5039. // for primitive wrapper objects
  5040. if (!valid && t === 'object') {
  5041. valid = value instanceof type;
  5042. }
  5043. }
  5044. else if (expectedType === 'Object') {
  5045. valid = isPlainObject(value);
  5046. }
  5047. else if (expectedType === 'Array') {
  5048. valid = isArray(value);
  5049. }
  5050. else {
  5051. try {
  5052. valid = value instanceof type;
  5053. }
  5054. catch (e) {
  5055. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5056. valid = false;
  5057. }
  5058. }
  5059. return {
  5060. valid,
  5061. expectedType
  5062. };
  5063. }
  5064. const functionTypeCheckRE = /^\s*function (\w+)/;
  5065. /**
  5066. * Use function string name to check built-in types,
  5067. * because a simple equality check will fail when running
  5068. * across different vms / iframes.
  5069. */
  5070. function getType(fn) {
  5071. const match = fn && fn.toString().match(functionTypeCheckRE);
  5072. return match ? match[1] : '';
  5073. }
  5074. function isSameType(a, b) {
  5075. return getType(a) === getType(b);
  5076. }
  5077. function getTypeIndex(type, expectedTypes) {
  5078. if (!isArray(expectedTypes)) {
  5079. return isSameType(expectedTypes, type) ? 0 : -1;
  5080. }
  5081. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5082. if (isSameType(expectedTypes[i], type)) {
  5083. return i;
  5084. }
  5085. }
  5086. return -1;
  5087. }
  5088. function getInvalidTypeMessage(name, value, expectedTypes) {
  5089. let message = `Invalid prop: type check failed for prop "${name}".` +
  5090. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5091. const expectedType = expectedTypes[0];
  5092. const receivedType = toRawType(value);
  5093. // check if we need to specify expected value
  5094. if (expectedTypes.length === 1 &&
  5095. isExplicable(expectedType) &&
  5096. isExplicable(typeof value) &&
  5097. !isBoolean(expectedType, receivedType)) {
  5098. message += ` with value ${styleValue(value, expectedType)}`;
  5099. }
  5100. message += `, got ${receivedType} `;
  5101. // check if we need to specify received value
  5102. if (isExplicable(receivedType)) {
  5103. message += `with value ${styleValue(value, receivedType)}.`;
  5104. }
  5105. return message;
  5106. }
  5107. function styleValue(value, type) {
  5108. if (type === 'String') {
  5109. return `"${value}"`;
  5110. }
  5111. else if (type === 'Number') {
  5112. return `${Number(value)}`;
  5113. }
  5114. else {
  5115. return `${value}`;
  5116. }
  5117. }
  5118. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5119. function isExplicable(value) {
  5120. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5121. }
  5122. function isBoolean(...args) {
  5123. return args.some(elem => elem.toLowerCase() === 'boolean');
  5124. }
  5125. /* not type checking this file because flow doesn't play well with Proxy */
  5126. let initProxy;
  5127. {
  5128. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  5129. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5130. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  5131. 'require' // for Webpack/Browserify
  5132. );
  5133. const warnNonPresent = (target, key) => {
  5134. warn(`Property or method "${key}" is not defined on the instance but ` +
  5135. 'referenced during render. Make sure that this property is reactive, ' +
  5136. 'either in the data option, or for class-based components, by ' +
  5137. 'initializing the property. ' +
  5138. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  5139. };
  5140. const warnReservedPrefix = (target, key) => {
  5141. warn(`Property "${key}" must be accessed with "$data.${key}" because ` +
  5142. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  5143. 'prevent conflicts with Vue internals. ' +
  5144. 'See: https://v2.vuejs.org/v2/api/#data', target);
  5145. };
  5146. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  5147. if (hasProxy) {
  5148. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5149. config.keyCodes = new Proxy(config.keyCodes, {
  5150. set(target, key, value) {
  5151. if (isBuiltInModifier(key)) {
  5152. warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  5153. return false;
  5154. }
  5155. else {
  5156. target[key] = value;
  5157. return true;
  5158. }
  5159. }
  5160. });
  5161. }
  5162. const hasHandler = {
  5163. has(target, key) {
  5164. const has = key in target;
  5165. const isAllowed = allowedGlobals(key) ||
  5166. (typeof key === 'string' &&
  5167. key.charAt(0) === '_' &&
  5168. !(key in target.$data));
  5169. if (!has && !isAllowed) {
  5170. if (key in target.$data)
  5171. warnReservedPrefix(target, key);
  5172. else
  5173. warnNonPresent(target, key);
  5174. }
  5175. return has || !isAllowed;
  5176. }
  5177. };
  5178. const getHandler = {
  5179. get(target, key) {
  5180. if (typeof key === 'string' && !(key in target)) {
  5181. if (key in target.$data)
  5182. warnReservedPrefix(target, key);
  5183. else
  5184. warnNonPresent(target, key);
  5185. }
  5186. return target[key];
  5187. }
  5188. };
  5189. initProxy = function initProxy(vm) {
  5190. if (hasProxy) {
  5191. // determine which proxy handler to use
  5192. const options = vm.$options;
  5193. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  5194. vm._renderProxy = new Proxy(vm, handlers);
  5195. }
  5196. else {
  5197. vm._renderProxy = vm;
  5198. }
  5199. };
  5200. }
  5201. const sharedPropertyDefinition = {
  5202. enumerable: true,
  5203. configurable: true,
  5204. get: noop,
  5205. set: noop
  5206. };
  5207. function proxy(target, sourceKey, key) {
  5208. sharedPropertyDefinition.get = function proxyGetter() {
  5209. return this[sourceKey][key];
  5210. };
  5211. sharedPropertyDefinition.set = function proxySetter(val) {
  5212. this[sourceKey][key] = val;
  5213. };
  5214. Object.defineProperty(target, key, sharedPropertyDefinition);
  5215. }
  5216. function initState(vm) {
  5217. const opts = vm.$options;
  5218. if (opts.props)
  5219. initProps$1(vm, opts.props);
  5220. // Composition API
  5221. initSetup(vm);
  5222. if (opts.methods)
  5223. initMethods(vm, opts.methods);
  5224. if (opts.data) {
  5225. initData(vm);
  5226. }
  5227. else {
  5228. const ob = observe((vm._data = {}));
  5229. ob && ob.vmCount++;
  5230. }
  5231. if (opts.computed)
  5232. initComputed$1(vm, opts.computed);
  5233. if (opts.watch && opts.watch !== nativeWatch) {
  5234. initWatch(vm, opts.watch);
  5235. }
  5236. }
  5237. function initProps$1(vm, propsOptions) {
  5238. const propsData = vm.$options.propsData || {};
  5239. const props = (vm._props = shallowReactive({}));
  5240. // cache prop keys so that future props updates can iterate using Array
  5241. // instead of dynamic object key enumeration.
  5242. const keys = (vm.$options._propKeys = []);
  5243. const isRoot = !vm.$parent;
  5244. // root instance props should be converted
  5245. if (!isRoot) {
  5246. toggleObserving(false);
  5247. }
  5248. for (const key in propsOptions) {
  5249. keys.push(key);
  5250. const value = validateProp(key, propsOptions, propsData, vm);
  5251. /* istanbul ignore else */
  5252. {
  5253. const hyphenatedKey = hyphenate(key);
  5254. if (isReservedAttribute(hyphenatedKey) ||
  5255. config.isReservedAttr(hyphenatedKey)) {
  5256. warn(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  5257. }
  5258. defineReactive(props, key, value, () => {
  5259. if (!isRoot && !isUpdatingChildComponent) {
  5260. warn(`Avoid mutating a prop directly since the value will be ` +
  5261. `overwritten whenever the parent component re-renders. ` +
  5262. `Instead, use a data or computed property based on the prop's ` +
  5263. `value. Prop being mutated: "${key}"`, vm);
  5264. }
  5265. });
  5266. }
  5267. // static props are already proxied on the component's prototype
  5268. // during Vue.extend(). We only need to proxy props defined at
  5269. // instantiation here.
  5270. if (!(key in vm)) {
  5271. proxy(vm, `_props`, key);
  5272. }
  5273. }
  5274. toggleObserving(true);
  5275. }
  5276. function initData(vm) {
  5277. let data = vm.$options.data;
  5278. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  5279. if (!isPlainObject(data)) {
  5280. data = {};
  5281. warn('data functions should return an object:\n' +
  5282. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  5283. }
  5284. // proxy data on instance
  5285. const keys = Object.keys(data);
  5286. const props = vm.$options.props;
  5287. const methods = vm.$options.methods;
  5288. let i = keys.length;
  5289. while (i--) {
  5290. const key = keys[i];
  5291. {
  5292. if (methods && hasOwn(methods, key)) {
  5293. warn(`Method "${key}" has already been defined as a data property.`, vm);
  5294. }
  5295. }
  5296. if (props && hasOwn(props, key)) {
  5297. warn(`The data property "${key}" is already declared as a prop. ` +
  5298. `Use prop default value instead.`, vm);
  5299. }
  5300. else if (!isReserved(key)) {
  5301. proxy(vm, `_data`, key);
  5302. }
  5303. }
  5304. // observe data
  5305. const ob = observe(data);
  5306. ob && ob.vmCount++;
  5307. }
  5308. function getData(data, vm) {
  5309. // #7573 disable dep collection when invoking data getters
  5310. pushTarget();
  5311. try {
  5312. return data.call(vm, vm);
  5313. }
  5314. catch (e) {
  5315. handleError(e, vm, `data()`);
  5316. return {};
  5317. }
  5318. finally {
  5319. popTarget();
  5320. }
  5321. }
  5322. const computedWatcherOptions = { lazy: true };
  5323. function initComputed$1(vm, computed) {
  5324. // $flow-disable-line
  5325. const watchers = (vm._computedWatchers = Object.create(null));
  5326. // computed properties are just getters during SSR
  5327. const isSSR = isServerRendering();
  5328. for (const key in computed) {
  5329. const userDef = computed[key];
  5330. const getter = isFunction(userDef) ? userDef : userDef.get;
  5331. if (getter == null) {
  5332. warn(`Getter is missing for computed property "${key}".`, vm);
  5333. }
  5334. if (!isSSR) {
  5335. // create internal watcher for the computed property.
  5336. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  5337. }
  5338. // component-defined computed properties are already defined on the
  5339. // component prototype. We only need to define computed properties defined
  5340. // at instantiation here.
  5341. if (!(key in vm)) {
  5342. defineComputed(vm, key, userDef);
  5343. }
  5344. else {
  5345. if (key in vm.$data) {
  5346. warn(`The computed property "${key}" is already defined in data.`, vm);
  5347. }
  5348. else if (vm.$options.props && key in vm.$options.props) {
  5349. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  5350. }
  5351. else if (vm.$options.methods && key in vm.$options.methods) {
  5352. warn(`The computed property "${key}" is already defined as a method.`, vm);
  5353. }
  5354. }
  5355. }
  5356. }
  5357. function defineComputed(target, key, userDef) {
  5358. const shouldCache = !isServerRendering();
  5359. if (isFunction(userDef)) {
  5360. sharedPropertyDefinition.get = shouldCache
  5361. ? createComputedGetter(key)
  5362. : createGetterInvoker(userDef);
  5363. sharedPropertyDefinition.set = noop;
  5364. }
  5365. else {
  5366. sharedPropertyDefinition.get = userDef.get
  5367. ? shouldCache && userDef.cache !== false
  5368. ? createComputedGetter(key)
  5369. : createGetterInvoker(userDef.get)
  5370. : noop;
  5371. sharedPropertyDefinition.set = userDef.set || noop;
  5372. }
  5373. if (sharedPropertyDefinition.set === noop) {
  5374. sharedPropertyDefinition.set = function () {
  5375. warn(`Computed property "${key}" was assigned to but it has no setter.`, this);
  5376. };
  5377. }
  5378. Object.defineProperty(target, key, sharedPropertyDefinition);
  5379. }
  5380. function createComputedGetter(key) {
  5381. return function computedGetter() {
  5382. const watcher = this._computedWatchers && this._computedWatchers[key];
  5383. if (watcher) {
  5384. if (watcher.dirty) {
  5385. watcher.evaluate();
  5386. }
  5387. if (Dep.target) {
  5388. if (Dep.target.onTrack) {
  5389. Dep.target.onTrack({
  5390. effect: Dep.target,
  5391. target: this,
  5392. type: "get" /* TrackOpTypes.GET */,
  5393. key
  5394. });
  5395. }
  5396. watcher.depend();
  5397. }
  5398. return watcher.value;
  5399. }
  5400. };
  5401. }
  5402. function createGetterInvoker(fn) {
  5403. return function computedGetter() {
  5404. return fn.call(this, this);
  5405. };
  5406. }
  5407. function initMethods(vm, methods) {
  5408. const props = vm.$options.props;
  5409. for (const key in methods) {
  5410. {
  5411. if (typeof methods[key] !== 'function') {
  5412. warn(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  5413. `Did you reference the function correctly?`, vm);
  5414. }
  5415. if (props && hasOwn(props, key)) {
  5416. warn(`Method "${key}" has already been defined as a prop.`, vm);
  5417. }
  5418. if (key in vm && isReserved(key)) {
  5419. warn(`Method "${key}" conflicts with an existing Vue instance method. ` +
  5420. `Avoid defining component methods that start with _ or $.`);
  5421. }
  5422. }
  5423. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  5424. }
  5425. }
  5426. function initWatch(vm, watch) {
  5427. for (const key in watch) {
  5428. const handler = watch[key];
  5429. if (isArray(handler)) {
  5430. for (let i = 0; i < handler.length; i++) {
  5431. createWatcher(vm, key, handler[i]);
  5432. }
  5433. }
  5434. else {
  5435. createWatcher(vm, key, handler);
  5436. }
  5437. }
  5438. }
  5439. function createWatcher(vm, expOrFn, handler, options) {
  5440. if (isPlainObject(handler)) {
  5441. options = handler;
  5442. handler = handler.handler;
  5443. }
  5444. if (typeof handler === 'string') {
  5445. handler = vm[handler];
  5446. }
  5447. return vm.$watch(expOrFn, handler, options);
  5448. }
  5449. function stateMixin(Vue) {
  5450. // flow somehow has problems with directly declared definition object
  5451. // when using Object.defineProperty, so we have to procedurally build up
  5452. // the object here.
  5453. const dataDef = {};
  5454. dataDef.get = function () {
  5455. return this._data;
  5456. };
  5457. const propsDef = {};
  5458. propsDef.get = function () {
  5459. return this._props;
  5460. };
  5461. {
  5462. dataDef.set = function () {
  5463. warn('Avoid replacing instance root $data. ' +
  5464. 'Use nested data properties instead.', this);
  5465. };
  5466. propsDef.set = function () {
  5467. warn(`$props is readonly.`, this);
  5468. };
  5469. }
  5470. Object.defineProperty(Vue.prototype, '$data', dataDef);
  5471. Object.defineProperty(Vue.prototype, '$props', propsDef);
  5472. Vue.prototype.$set = set;
  5473. Vue.prototype.$delete = del;
  5474. Vue.prototype.$watch = function (expOrFn, cb, options) {
  5475. const vm = this;
  5476. if (isPlainObject(cb)) {
  5477. return createWatcher(vm, expOrFn, cb, options);
  5478. }
  5479. options = options || {};
  5480. options.user = true;
  5481. const watcher = new Watcher(vm, expOrFn, cb, options);
  5482. if (options.immediate) {
  5483. const info = `callback for immediate watcher "${watcher.expression}"`;
  5484. pushTarget();
  5485. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  5486. popTarget();
  5487. }
  5488. return function unwatchFn() {
  5489. watcher.teardown();
  5490. };
  5491. };
  5492. }
  5493. let uid = 0;
  5494. function initMixin$1(Vue) {
  5495. Vue.prototype._init = function (options) {
  5496. const vm = this;
  5497. // a uid
  5498. vm._uid = uid++;
  5499. let startTag, endTag;
  5500. /* istanbul ignore if */
  5501. if (config.performance && mark) {
  5502. startTag = `vue-perf-start:${vm._uid}`;
  5503. endTag = `vue-perf-end:${vm._uid}`;
  5504. mark(startTag);
  5505. }
  5506. // a flag to mark this as a Vue instance without having to do instanceof
  5507. // check
  5508. vm._isVue = true;
  5509. // avoid instances from being observed
  5510. vm.__v_skip = true;
  5511. // effect scope
  5512. vm._scope = new EffectScope(true /* detached */);
  5513. vm._scope._vm = true;
  5514. // merge options
  5515. if (options && options._isComponent) {
  5516. // optimize internal component instantiation
  5517. // since dynamic options merging is pretty slow, and none of the
  5518. // internal component options needs special treatment.
  5519. initInternalComponent(vm, options);
  5520. }
  5521. else {
  5522. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  5523. }
  5524. /* istanbul ignore else */
  5525. {
  5526. initProxy(vm);
  5527. }
  5528. // expose real self
  5529. vm._self = vm;
  5530. initLifecycle(vm);
  5531. initEvents(vm);
  5532. initRender(vm);
  5533. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  5534. initInjections(vm); // resolve injections before data/props
  5535. initState(vm);
  5536. initProvide(vm); // resolve provide after data/props
  5537. callHook$1(vm, 'created');
  5538. /* istanbul ignore if */
  5539. if (config.performance && mark) {
  5540. vm._name = formatComponentName(vm, false);
  5541. mark(endTag);
  5542. measure(`vue ${vm._name} init`, startTag, endTag);
  5543. }
  5544. if (vm.$options.el) {
  5545. vm.$mount(vm.$options.el);
  5546. }
  5547. };
  5548. }
  5549. function initInternalComponent(vm, options) {
  5550. const opts = (vm.$options = Object.create(vm.constructor.options));
  5551. // doing this because it's faster than dynamic enumeration.
  5552. const parentVnode = options._parentVnode;
  5553. opts.parent = options.parent;
  5554. opts._parentVnode = parentVnode;
  5555. const vnodeComponentOptions = parentVnode.componentOptions;
  5556. opts.propsData = vnodeComponentOptions.propsData;
  5557. opts._parentListeners = vnodeComponentOptions.listeners;
  5558. opts._renderChildren = vnodeComponentOptions.children;
  5559. opts._componentTag = vnodeComponentOptions.tag;
  5560. if (options.render) {
  5561. opts.render = options.render;
  5562. opts.staticRenderFns = options.staticRenderFns;
  5563. }
  5564. }
  5565. function resolveConstructorOptions(Ctor) {
  5566. let options = Ctor.options;
  5567. if (Ctor.super) {
  5568. const superOptions = resolveConstructorOptions(Ctor.super);
  5569. const cachedSuperOptions = Ctor.superOptions;
  5570. if (superOptions !== cachedSuperOptions) {
  5571. // super option changed,
  5572. // need to resolve new options.
  5573. Ctor.superOptions = superOptions;
  5574. // check if there are any late-modified/attached options (#4976)
  5575. const modifiedOptions = resolveModifiedOptions(Ctor);
  5576. // update base extend options
  5577. if (modifiedOptions) {
  5578. extend(Ctor.extendOptions, modifiedOptions);
  5579. }
  5580. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  5581. if (options.name) {
  5582. options.components[options.name] = Ctor;
  5583. }
  5584. }
  5585. }
  5586. return options;
  5587. }
  5588. function resolveModifiedOptions(Ctor) {
  5589. let modified;
  5590. const latest = Ctor.options;
  5591. const sealed = Ctor.sealedOptions;
  5592. for (const key in latest) {
  5593. if (latest[key] !== sealed[key]) {
  5594. if (!modified)
  5595. modified = {};
  5596. modified[key] = latest[key];
  5597. }
  5598. }
  5599. return modified;
  5600. }
  5601. function Vue(options) {
  5602. if (!(this instanceof Vue)) {
  5603. warn('Vue is a constructor and should be called with the `new` keyword');
  5604. }
  5605. this._init(options);
  5606. }
  5607. //@ts-expect-error Vue has function type
  5608. initMixin$1(Vue);
  5609. //@ts-expect-error Vue has function type
  5610. stateMixin(Vue);
  5611. //@ts-expect-error Vue has function type
  5612. eventsMixin(Vue);
  5613. //@ts-expect-error Vue has function type
  5614. lifecycleMixin(Vue);
  5615. //@ts-expect-error Vue has function type
  5616. renderMixin(Vue);
  5617. function initUse(Vue) {
  5618. Vue.use = function (plugin) {
  5619. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5620. if (installedPlugins.indexOf(plugin) > -1) {
  5621. return this;
  5622. }
  5623. // additional parameters
  5624. const args = toArray(arguments, 1);
  5625. args.unshift(this);
  5626. if (isFunction(plugin.install)) {
  5627. plugin.install.apply(plugin, args);
  5628. }
  5629. else if (isFunction(plugin)) {
  5630. plugin.apply(null, args);
  5631. }
  5632. installedPlugins.push(plugin);
  5633. return this;
  5634. };
  5635. }
  5636. function initMixin(Vue) {
  5637. Vue.mixin = function (mixin) {
  5638. this.options = mergeOptions(this.options, mixin);
  5639. return this;
  5640. };
  5641. }
  5642. function initExtend(Vue) {
  5643. /**
  5644. * Each instance constructor, including Vue, has a unique
  5645. * cid. This enables us to create wrapped "child
  5646. * constructors" for prototypal inheritance and cache them.
  5647. */
  5648. Vue.cid = 0;
  5649. let cid = 1;
  5650. /**
  5651. * Class inheritance
  5652. */
  5653. Vue.extend = function (extendOptions) {
  5654. extendOptions = extendOptions || {};
  5655. const Super = this;
  5656. const SuperId = Super.cid;
  5657. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5658. if (cachedCtors[SuperId]) {
  5659. return cachedCtors[SuperId];
  5660. }
  5661. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5662. if (name) {
  5663. validateComponentName(name);
  5664. }
  5665. const Sub = function VueComponent(options) {
  5666. this._init(options);
  5667. };
  5668. Sub.prototype = Object.create(Super.prototype);
  5669. Sub.prototype.constructor = Sub;
  5670. Sub.cid = cid++;
  5671. Sub.options = mergeOptions(Super.options, extendOptions);
  5672. Sub['super'] = Super;
  5673. // For props and computed properties, we define the proxy getters on
  5674. // the Vue instances at extension time, on the extended prototype. This
  5675. // avoids Object.defineProperty calls for each instance created.
  5676. if (Sub.options.props) {
  5677. initProps(Sub);
  5678. }
  5679. if (Sub.options.computed) {
  5680. initComputed(Sub);
  5681. }
  5682. // allow further extension/mixin/plugin usage
  5683. Sub.extend = Super.extend;
  5684. Sub.mixin = Super.mixin;
  5685. Sub.use = Super.use;
  5686. // create asset registers, so extended classes
  5687. // can have their private assets too.
  5688. ASSET_TYPES.forEach(function (type) {
  5689. Sub[type] = Super[type];
  5690. });
  5691. // enable recursive self-lookup
  5692. if (name) {
  5693. Sub.options.components[name] = Sub;
  5694. }
  5695. // keep a reference to the super options at extension time.
  5696. // later at instantiation we can check if Super's options have
  5697. // been updated.
  5698. Sub.superOptions = Super.options;
  5699. Sub.extendOptions = extendOptions;
  5700. Sub.sealedOptions = extend({}, Sub.options);
  5701. // cache constructor
  5702. cachedCtors[SuperId] = Sub;
  5703. return Sub;
  5704. };
  5705. }
  5706. function initProps(Comp) {
  5707. const props = Comp.options.props;
  5708. for (const key in props) {
  5709. proxy(Comp.prototype, `_props`, key);
  5710. }
  5711. }
  5712. function initComputed(Comp) {
  5713. const computed = Comp.options.computed;
  5714. for (const key in computed) {
  5715. defineComputed(Comp.prototype, key, computed[key]);
  5716. }
  5717. }
  5718. function initAssetRegisters(Vue) {
  5719. /**
  5720. * Create asset registration methods.
  5721. */
  5722. ASSET_TYPES.forEach(type => {
  5723. // @ts-expect-error function is not exact same type
  5724. Vue[type] = function (id, definition) {
  5725. if (!definition) {
  5726. return this.options[type + 's'][id];
  5727. }
  5728. else {
  5729. /* istanbul ignore if */
  5730. if (type === 'component') {
  5731. validateComponentName(id);
  5732. }
  5733. if (type === 'component' && isPlainObject(definition)) {
  5734. // @ts-expect-error
  5735. definition.name = definition.name || id;
  5736. definition = this.options._base.extend(definition);
  5737. }
  5738. if (type === 'directive' && isFunction(definition)) {
  5739. definition = { bind: definition, update: definition };
  5740. }
  5741. this.options[type + 's'][id] = definition;
  5742. return definition;
  5743. }
  5744. };
  5745. });
  5746. }
  5747. function _getComponentName(opts) {
  5748. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5749. }
  5750. function matches(pattern, name) {
  5751. if (isArray(pattern)) {
  5752. return pattern.indexOf(name) > -1;
  5753. }
  5754. else if (typeof pattern === 'string') {
  5755. return pattern.split(',').indexOf(name) > -1;
  5756. }
  5757. else if (isRegExp(pattern)) {
  5758. return pattern.test(name);
  5759. }
  5760. /* istanbul ignore next */
  5761. return false;
  5762. }
  5763. function pruneCache(keepAliveInstance, filter) {
  5764. const { cache, keys, _vnode } = keepAliveInstance;
  5765. for (const key in cache) {
  5766. const entry = cache[key];
  5767. if (entry) {
  5768. const name = entry.name;
  5769. if (name && !filter(name)) {
  5770. pruneCacheEntry(cache, key, keys, _vnode);
  5771. }
  5772. }
  5773. }
  5774. }
  5775. function pruneCacheEntry(cache, key, keys, current) {
  5776. const entry = cache[key];
  5777. if (entry && (!current || entry.tag !== current.tag)) {
  5778. // @ts-expect-error can be undefined
  5779. entry.componentInstance.$destroy();
  5780. }
  5781. cache[key] = null;
  5782. remove$2(keys, key);
  5783. }
  5784. const patternTypes = [String, RegExp, Array];
  5785. // TODO defineComponent
  5786. var KeepAlive = {
  5787. name: 'keep-alive',
  5788. abstract: true,
  5789. props: {
  5790. include: patternTypes,
  5791. exclude: patternTypes,
  5792. max: [String, Number]
  5793. },
  5794. methods: {
  5795. cacheVNode() {
  5796. const { cache, keys, vnodeToCache, keyToCache } = this;
  5797. if (vnodeToCache) {
  5798. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5799. cache[keyToCache] = {
  5800. name: _getComponentName(componentOptions),
  5801. tag,
  5802. componentInstance
  5803. };
  5804. keys.push(keyToCache);
  5805. // prune oldest entry
  5806. if (this.max && keys.length > parseInt(this.max)) {
  5807. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5808. }
  5809. this.vnodeToCache = null;
  5810. }
  5811. }
  5812. },
  5813. created() {
  5814. this.cache = Object.create(null);
  5815. this.keys = [];
  5816. },
  5817. destroyed() {
  5818. for (const key in this.cache) {
  5819. pruneCacheEntry(this.cache, key, this.keys);
  5820. }
  5821. },
  5822. mounted() {
  5823. this.cacheVNode();
  5824. this.$watch('include', val => {
  5825. pruneCache(this, name => matches(val, name));
  5826. });
  5827. this.$watch('exclude', val => {
  5828. pruneCache(this, name => !matches(val, name));
  5829. });
  5830. },
  5831. updated() {
  5832. this.cacheVNode();
  5833. },
  5834. render() {
  5835. const slot = this.$slots.default;
  5836. const vnode = getFirstComponentChild(slot);
  5837. const componentOptions = vnode && vnode.componentOptions;
  5838. if (componentOptions) {
  5839. // check pattern
  5840. const name = _getComponentName(componentOptions);
  5841. const { include, exclude } = this;
  5842. if (
  5843. // not included
  5844. (include && (!name || !matches(include, name))) ||
  5845. // excluded
  5846. (exclude && name && matches(exclude, name))) {
  5847. return vnode;
  5848. }
  5849. const { cache, keys } = this;
  5850. const key = vnode.key == null
  5851. ? // same constructor may get registered as different local components
  5852. // so cid alone is not enough (#3269)
  5853. componentOptions.Ctor.cid +
  5854. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5855. : vnode.key;
  5856. if (cache[key]) {
  5857. vnode.componentInstance = cache[key].componentInstance;
  5858. // make current key freshest
  5859. remove$2(keys, key);
  5860. keys.push(key);
  5861. }
  5862. else {
  5863. // delay setting the cache until update
  5864. this.vnodeToCache = vnode;
  5865. this.keyToCache = key;
  5866. }
  5867. // @ts-expect-error can vnode.data can be undefined
  5868. vnode.data.keepAlive = true;
  5869. }
  5870. return vnode || (slot && slot[0]);
  5871. }
  5872. };
  5873. var builtInComponents = {
  5874. KeepAlive
  5875. };
  5876. function initGlobalAPI(Vue) {
  5877. // config
  5878. const configDef = {};
  5879. configDef.get = () => config;
  5880. {
  5881. configDef.set = () => {
  5882. warn('Do not replace the Vue.config object, set individual fields instead.');
  5883. };
  5884. }
  5885. Object.defineProperty(Vue, 'config', configDef);
  5886. // exposed util methods.
  5887. // NOTE: these are not considered part of the public API - avoid relying on
  5888. // them unless you are aware of the risk.
  5889. Vue.util = {
  5890. warn,
  5891. extend,
  5892. mergeOptions,
  5893. defineReactive
  5894. };
  5895. Vue.set = set;
  5896. Vue.delete = del;
  5897. Vue.nextTick = nextTick;
  5898. // 2.6 explicit observable API
  5899. Vue.observable = (obj) => {
  5900. observe(obj);
  5901. return obj;
  5902. };
  5903. Vue.options = Object.create(null);
  5904. ASSET_TYPES.forEach(type => {
  5905. Vue.options[type + 's'] = Object.create(null);
  5906. });
  5907. // this is used to identify the "base" constructor to extend all plain-object
  5908. // components with in Weex's multi-instance scenarios.
  5909. Vue.options._base = Vue;
  5910. extend(Vue.options.components, builtInComponents);
  5911. initUse(Vue);
  5912. initMixin(Vue);
  5913. initExtend(Vue);
  5914. initAssetRegisters(Vue);
  5915. }
  5916. initGlobalAPI(Vue);
  5917. Object.defineProperty(Vue.prototype, '$isServer', {
  5918. get: isServerRendering
  5919. });
  5920. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5921. get() {
  5922. /* istanbul ignore next */
  5923. return this.$vnode && this.$vnode.ssrContext;
  5924. }
  5925. });
  5926. // expose FunctionalRenderContext for ssr runtime helper installation
  5927. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5928. value: FunctionalRenderContext
  5929. });
  5930. Vue.version = version;
  5931. // these are reserved for web because they are directly compiled away
  5932. // during template compilation
  5933. const isReservedAttr = makeMap('style,class');
  5934. // attributes that should be using props for binding
  5935. const acceptValue = makeMap('input,textarea,option,select,progress');
  5936. const mustUseProp = (tag, type, attr) => {
  5937. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5938. (attr === 'selected' && tag === 'option') ||
  5939. (attr === 'checked' && tag === 'input') ||
  5940. (attr === 'muted' && tag === 'video'));
  5941. };
  5942. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5943. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5944. const convertEnumeratedValue = (key, value) => {
  5945. return isFalsyAttrValue(value) || value === 'false'
  5946. ? 'false'
  5947. : // allow arbitrary string value for contenteditable
  5948. key === 'contenteditable' && isValidContentEditableValue(value)
  5949. ? value
  5950. : 'true';
  5951. };
  5952. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5953. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5954. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5955. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5956. 'required,reversed,scoped,seamless,selected,sortable,' +
  5957. 'truespeed,typemustmatch,visible');
  5958. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5959. const isXlink = (name) => {
  5960. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5961. };
  5962. const getXlinkProp = (name) => {
  5963. return isXlink(name) ? name.slice(6, name.length) : '';
  5964. };
  5965. const isFalsyAttrValue = (val) => {
  5966. return val == null || val === false;
  5967. };
  5968. function genClassForVnode(vnode) {
  5969. let data = vnode.data;
  5970. let parentNode = vnode;
  5971. let childNode = vnode;
  5972. while (isDef(childNode.componentInstance)) {
  5973. childNode = childNode.componentInstance._vnode;
  5974. if (childNode && childNode.data) {
  5975. data = mergeClassData(childNode.data, data);
  5976. }
  5977. }
  5978. // @ts-expect-error parentNode.parent not VNodeWithData
  5979. while (isDef((parentNode = parentNode.parent))) {
  5980. if (parentNode && parentNode.data) {
  5981. data = mergeClassData(data, parentNode.data);
  5982. }
  5983. }
  5984. return renderClass(data.staticClass, data.class);
  5985. }
  5986. function mergeClassData(child, parent) {
  5987. return {
  5988. staticClass: concat(child.staticClass, parent.staticClass),
  5989. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  5990. };
  5991. }
  5992. function renderClass(staticClass, dynamicClass) {
  5993. if (isDef(staticClass) || isDef(dynamicClass)) {
  5994. return concat(staticClass, stringifyClass(dynamicClass));
  5995. }
  5996. /* istanbul ignore next */
  5997. return '';
  5998. }
  5999. function concat(a, b) {
  6000. return a ? (b ? a + ' ' + b : a) : b || '';
  6001. }
  6002. function stringifyClass(value) {
  6003. if (Array.isArray(value)) {
  6004. return stringifyArray(value);
  6005. }
  6006. if (isObject(value)) {
  6007. return stringifyObject(value);
  6008. }
  6009. if (typeof value === 'string') {
  6010. return value;
  6011. }
  6012. /* istanbul ignore next */
  6013. return '';
  6014. }
  6015. function stringifyArray(value) {
  6016. let res = '';
  6017. let stringified;
  6018. for (let i = 0, l = value.length; i < l; i++) {
  6019. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6020. if (res)
  6021. res += ' ';
  6022. res += stringified;
  6023. }
  6024. }
  6025. return res;
  6026. }
  6027. function stringifyObject(value) {
  6028. let res = '';
  6029. for (const key in value) {
  6030. if (value[key]) {
  6031. if (res)
  6032. res += ' ';
  6033. res += key;
  6034. }
  6035. }
  6036. return res;
  6037. }
  6038. const namespaceMap = {
  6039. svg: 'http://www.w3.org/2000/svg',
  6040. math: 'http://www.w3.org/1998/Math/MathML'
  6041. };
  6042. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6043. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6044. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6045. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6046. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6047. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6048. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6049. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6050. 'output,progress,select,textarea,' +
  6051. 'details,dialog,menu,menuitem,summary,' +
  6052. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6053. // this map is intentionally selective, only covering SVG elements that may
  6054. // contain child elements.
  6055. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6056. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6057. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6058. const isReservedTag = (tag) => {
  6059. return isHTMLTag(tag) || isSVG(tag);
  6060. };
  6061. function getTagNamespace(tag) {
  6062. if (isSVG(tag)) {
  6063. return 'svg';
  6064. }
  6065. // basic support for MathML
  6066. // note it doesn't support other MathML elements being component roots
  6067. if (tag === 'math') {
  6068. return 'math';
  6069. }
  6070. }
  6071. const unknownElementCache = Object.create(null);
  6072. function isUnknownElement(tag) {
  6073. /* istanbul ignore if */
  6074. if (!inBrowser) {
  6075. return true;
  6076. }
  6077. if (isReservedTag(tag)) {
  6078. return false;
  6079. }
  6080. tag = tag.toLowerCase();
  6081. /* istanbul ignore if */
  6082. if (unknownElementCache[tag] != null) {
  6083. return unknownElementCache[tag];
  6084. }
  6085. const el = document.createElement(tag);
  6086. if (tag.indexOf('-') > -1) {
  6087. // http://stackoverflow.com/a/28210364/1070244
  6088. return (unknownElementCache[tag] =
  6089. el.constructor === window.HTMLUnknownElement ||
  6090. el.constructor === window.HTMLElement);
  6091. }
  6092. else {
  6093. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6094. }
  6095. }
  6096. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6097. /**
  6098. * Query an element selector if it's not an element already.
  6099. */
  6100. function query(el) {
  6101. if (typeof el === 'string') {
  6102. const selected = document.querySelector(el);
  6103. if (!selected) {
  6104. warn('Cannot find element: ' + el);
  6105. return document.createElement('div');
  6106. }
  6107. return selected;
  6108. }
  6109. else {
  6110. return el;
  6111. }
  6112. }
  6113. function createElement(tagName, vnode) {
  6114. const elm = document.createElement(tagName);
  6115. if (tagName !== 'select') {
  6116. return elm;
  6117. }
  6118. // false or null will remove the attribute but undefined will not
  6119. if (vnode.data &&
  6120. vnode.data.attrs &&
  6121. vnode.data.attrs.multiple !== undefined) {
  6122. elm.setAttribute('multiple', 'multiple');
  6123. }
  6124. return elm;
  6125. }
  6126. function createElementNS(namespace, tagName) {
  6127. return document.createElementNS(namespaceMap[namespace], tagName);
  6128. }
  6129. function createTextNode(text) {
  6130. return document.createTextNode(text);
  6131. }
  6132. function createComment(text) {
  6133. return document.createComment(text);
  6134. }
  6135. function insertBefore(parentNode, newNode, referenceNode) {
  6136. parentNode.insertBefore(newNode, referenceNode);
  6137. }
  6138. function removeChild(node, child) {
  6139. node.removeChild(child);
  6140. }
  6141. function appendChild(node, child) {
  6142. node.appendChild(child);
  6143. }
  6144. function parentNode(node) {
  6145. return node.parentNode;
  6146. }
  6147. function nextSibling(node) {
  6148. return node.nextSibling;
  6149. }
  6150. function tagName(node) {
  6151. return node.tagName;
  6152. }
  6153. function setTextContent(node, text) {
  6154. node.textContent = text;
  6155. }
  6156. function setStyleScope(node, scopeId) {
  6157. node.setAttribute(scopeId, '');
  6158. }
  6159. var nodeOps = /*#__PURE__*/Object.freeze({
  6160. __proto__: null,
  6161. createElement: createElement,
  6162. createElementNS: createElementNS,
  6163. createTextNode: createTextNode,
  6164. createComment: createComment,
  6165. insertBefore: insertBefore,
  6166. removeChild: removeChild,
  6167. appendChild: appendChild,
  6168. parentNode: parentNode,
  6169. nextSibling: nextSibling,
  6170. tagName: tagName,
  6171. setTextContent: setTextContent,
  6172. setStyleScope: setStyleScope
  6173. });
  6174. var ref = {
  6175. create(_, vnode) {
  6176. registerRef(vnode);
  6177. },
  6178. update(oldVnode, vnode) {
  6179. if (oldVnode.data.ref !== vnode.data.ref) {
  6180. registerRef(oldVnode, true);
  6181. registerRef(vnode);
  6182. }
  6183. },
  6184. destroy(vnode) {
  6185. registerRef(vnode, true);
  6186. }
  6187. };
  6188. function registerRef(vnode, isRemoval) {
  6189. const ref = vnode.data.ref;
  6190. if (!isDef(ref))
  6191. return;
  6192. const vm = vnode.context;
  6193. const refValue = vnode.componentInstance || vnode.elm;
  6194. const value = isRemoval ? null : refValue;
  6195. const $refsValue = isRemoval ? undefined : refValue;
  6196. if (isFunction(ref)) {
  6197. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6198. return;
  6199. }
  6200. const isFor = vnode.data.refInFor;
  6201. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6202. const _isRef = isRef(ref);
  6203. const refs = vm.$refs;
  6204. if (_isString || _isRef) {
  6205. if (isFor) {
  6206. const existing = _isString ? refs[ref] : ref.value;
  6207. if (isRemoval) {
  6208. isArray(existing) && remove$2(existing, refValue);
  6209. }
  6210. else {
  6211. if (!isArray(existing)) {
  6212. if (_isString) {
  6213. refs[ref] = [refValue];
  6214. setSetupRef(vm, ref, refs[ref]);
  6215. }
  6216. else {
  6217. ref.value = [refValue];
  6218. }
  6219. }
  6220. else if (!existing.includes(refValue)) {
  6221. existing.push(refValue);
  6222. }
  6223. }
  6224. }
  6225. else if (_isString) {
  6226. if (isRemoval && refs[ref] !== refValue) {
  6227. return;
  6228. }
  6229. refs[ref] = $refsValue;
  6230. setSetupRef(vm, ref, value);
  6231. }
  6232. else if (_isRef) {
  6233. if (isRemoval && ref.value !== refValue) {
  6234. return;
  6235. }
  6236. ref.value = value;
  6237. }
  6238. else {
  6239. warn(`Invalid template ref type: ${typeof ref}`);
  6240. }
  6241. }
  6242. }
  6243. function setSetupRef({ _setupState }, key, val) {
  6244. if (_setupState && hasOwn(_setupState, key)) {
  6245. if (isRef(_setupState[key])) {
  6246. _setupState[key].value = val;
  6247. }
  6248. else {
  6249. _setupState[key] = val;
  6250. }
  6251. }
  6252. }
  6253. /**
  6254. * Virtual DOM patching algorithm based on Snabbdom by
  6255. * Simon Friis Vindum (@paldepind)
  6256. * Licensed under the MIT License
  6257. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6258. *
  6259. * modified by Evan You (@yyx990803)
  6260. *
  6261. * Not type-checking this because this file is perf-critical and the cost
  6262. * of making flow understand it is not worth it.
  6263. */
  6264. const emptyNode = new VNode('', {}, []);
  6265. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6266. function sameVnode(a, b) {
  6267. return (a.key === b.key &&
  6268. a.asyncFactory === b.asyncFactory &&
  6269. ((a.tag === b.tag &&
  6270. a.isComment === b.isComment &&
  6271. isDef(a.data) === isDef(b.data) &&
  6272. sameInputType(a, b)) ||
  6273. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6274. }
  6275. function sameInputType(a, b) {
  6276. if (a.tag !== 'input')
  6277. return true;
  6278. let i;
  6279. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6280. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6281. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6282. }
  6283. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6284. let i, key;
  6285. const map = {};
  6286. for (i = beginIdx; i <= endIdx; ++i) {
  6287. key = children[i].key;
  6288. if (isDef(key))
  6289. map[key] = i;
  6290. }
  6291. return map;
  6292. }
  6293. function createPatchFunction(backend) {
  6294. let i, j;
  6295. const cbs = {};
  6296. const { modules, nodeOps } = backend;
  6297. for (i = 0; i < hooks.length; ++i) {
  6298. cbs[hooks[i]] = [];
  6299. for (j = 0; j < modules.length; ++j) {
  6300. if (isDef(modules[j][hooks[i]])) {
  6301. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6302. }
  6303. }
  6304. }
  6305. function emptyNodeAt(elm) {
  6306. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6307. }
  6308. function createRmCb(childElm, listeners) {
  6309. function remove() {
  6310. if (--remove.listeners === 0) {
  6311. removeNode(childElm);
  6312. }
  6313. }
  6314. remove.listeners = listeners;
  6315. return remove;
  6316. }
  6317. function removeNode(el) {
  6318. const parent = nodeOps.parentNode(el);
  6319. // element may have already been removed due to v-html / v-text
  6320. if (isDef(parent)) {
  6321. nodeOps.removeChild(parent, el);
  6322. }
  6323. }
  6324. function isUnknownElement(vnode, inVPre) {
  6325. return (!inVPre &&
  6326. !vnode.ns &&
  6327. !(config.ignoredElements.length &&
  6328. config.ignoredElements.some(ignore => {
  6329. return isRegExp(ignore)
  6330. ? ignore.test(vnode.tag)
  6331. : ignore === vnode.tag;
  6332. })) &&
  6333. config.isUnknownElement(vnode.tag));
  6334. }
  6335. let creatingElmInVPre = 0;
  6336. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6337. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6338. // This vnode was used in a previous render!
  6339. // now it's used as a new node, overwriting its elm would cause
  6340. // potential patch errors down the road when it's used as an insertion
  6341. // reference node. Instead, we clone the node on-demand before creating
  6342. // associated DOM element for it.
  6343. vnode = ownerArray[index] = cloneVNode(vnode);
  6344. }
  6345. vnode.isRootInsert = !nested; // for transition enter check
  6346. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6347. return;
  6348. }
  6349. const data = vnode.data;
  6350. const children = vnode.children;
  6351. const tag = vnode.tag;
  6352. if (isDef(tag)) {
  6353. {
  6354. if (data && data.pre) {
  6355. creatingElmInVPre++;
  6356. }
  6357. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6358. warn('Unknown custom element: <' +
  6359. tag +
  6360. '> - did you ' +
  6361. 'register the component correctly? For recursive components, ' +
  6362. 'make sure to provide the "name" option.', vnode.context);
  6363. }
  6364. }
  6365. vnode.elm = vnode.ns
  6366. ? nodeOps.createElementNS(vnode.ns, tag)
  6367. : nodeOps.createElement(tag, vnode);
  6368. setScope(vnode);
  6369. createChildren(vnode, children, insertedVnodeQueue);
  6370. if (isDef(data)) {
  6371. invokeCreateHooks(vnode, insertedVnodeQueue);
  6372. }
  6373. insert(parentElm, vnode.elm, refElm);
  6374. if (data && data.pre) {
  6375. creatingElmInVPre--;
  6376. }
  6377. }
  6378. else if (isTrue(vnode.isComment)) {
  6379. vnode.elm = nodeOps.createComment(vnode.text);
  6380. insert(parentElm, vnode.elm, refElm);
  6381. }
  6382. else {
  6383. vnode.elm = nodeOps.createTextNode(vnode.text);
  6384. insert(parentElm, vnode.elm, refElm);
  6385. }
  6386. }
  6387. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6388. let i = vnode.data;
  6389. if (isDef(i)) {
  6390. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6391. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6392. i(vnode, false /* hydrating */);
  6393. }
  6394. // after calling the init hook, if the vnode is a child component
  6395. // it should've created a child instance and mounted it. the child
  6396. // component also has set the placeholder vnode's elm.
  6397. // in that case we can just return the element and be done.
  6398. if (isDef(vnode.componentInstance)) {
  6399. initComponent(vnode, insertedVnodeQueue);
  6400. insert(parentElm, vnode.elm, refElm);
  6401. if (isTrue(isReactivated)) {
  6402. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6403. }
  6404. return true;
  6405. }
  6406. }
  6407. }
  6408. function initComponent(vnode, insertedVnodeQueue) {
  6409. if (isDef(vnode.data.pendingInsert)) {
  6410. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6411. vnode.data.pendingInsert = null;
  6412. }
  6413. vnode.elm = vnode.componentInstance.$el;
  6414. if (isPatchable(vnode)) {
  6415. invokeCreateHooks(vnode, insertedVnodeQueue);
  6416. setScope(vnode);
  6417. }
  6418. else {
  6419. // empty component root.
  6420. // skip all element-related modules except for ref (#3455)
  6421. registerRef(vnode);
  6422. // make sure to invoke the insert hook
  6423. insertedVnodeQueue.push(vnode);
  6424. }
  6425. }
  6426. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6427. let i;
  6428. // hack for #4339: a reactivated component with inner transition
  6429. // does not trigger because the inner node's created hooks are not called
  6430. // again. It's not ideal to involve module-specific logic in here but
  6431. // there doesn't seem to be a better way to do it.
  6432. let innerNode = vnode;
  6433. while (innerNode.componentInstance) {
  6434. innerNode = innerNode.componentInstance._vnode;
  6435. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6436. for (i = 0; i < cbs.activate.length; ++i) {
  6437. cbs.activate[i](emptyNode, innerNode);
  6438. }
  6439. insertedVnodeQueue.push(innerNode);
  6440. break;
  6441. }
  6442. }
  6443. // unlike a newly created component,
  6444. // a reactivated keep-alive component doesn't insert itself
  6445. insert(parentElm, vnode.elm, refElm);
  6446. }
  6447. function insert(parent, elm, ref) {
  6448. if (isDef(parent)) {
  6449. if (isDef(ref)) {
  6450. if (nodeOps.parentNode(ref) === parent) {
  6451. nodeOps.insertBefore(parent, elm, ref);
  6452. }
  6453. }
  6454. else {
  6455. nodeOps.appendChild(parent, elm);
  6456. }
  6457. }
  6458. }
  6459. function createChildren(vnode, children, insertedVnodeQueue) {
  6460. if (isArray(children)) {
  6461. {
  6462. checkDuplicateKeys(children);
  6463. }
  6464. for (let i = 0; i < children.length; ++i) {
  6465. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6466. }
  6467. }
  6468. else if (isPrimitive(vnode.text)) {
  6469. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6470. }
  6471. }
  6472. function isPatchable(vnode) {
  6473. while (vnode.componentInstance) {
  6474. vnode = vnode.componentInstance._vnode;
  6475. }
  6476. return isDef(vnode.tag);
  6477. }
  6478. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6479. for (let i = 0; i < cbs.create.length; ++i) {
  6480. cbs.create[i](emptyNode, vnode);
  6481. }
  6482. i = vnode.data.hook; // Reuse variable
  6483. if (isDef(i)) {
  6484. if (isDef(i.create))
  6485. i.create(emptyNode, vnode);
  6486. if (isDef(i.insert))
  6487. insertedVnodeQueue.push(vnode);
  6488. }
  6489. }
  6490. // set scope id attribute for scoped CSS.
  6491. // this is implemented as a special case to avoid the overhead
  6492. // of going through the normal attribute patching process.
  6493. function setScope(vnode) {
  6494. let i;
  6495. if (isDef((i = vnode.fnScopeId))) {
  6496. nodeOps.setStyleScope(vnode.elm, i);
  6497. }
  6498. else {
  6499. let ancestor = vnode;
  6500. while (ancestor) {
  6501. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6502. nodeOps.setStyleScope(vnode.elm, i);
  6503. }
  6504. ancestor = ancestor.parent;
  6505. }
  6506. }
  6507. // for slot content they should also get the scopeId from the host instance.
  6508. if (isDef((i = activeInstance)) &&
  6509. i !== vnode.context &&
  6510. i !== vnode.fnContext &&
  6511. isDef((i = i.$options._scopeId))) {
  6512. nodeOps.setStyleScope(vnode.elm, i);
  6513. }
  6514. }
  6515. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6516. for (; startIdx <= endIdx; ++startIdx) {
  6517. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6518. }
  6519. }
  6520. function invokeDestroyHook(vnode) {
  6521. let i, j;
  6522. const data = vnode.data;
  6523. if (isDef(data)) {
  6524. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6525. i(vnode);
  6526. for (i = 0; i < cbs.destroy.length; ++i)
  6527. cbs.destroy[i](vnode);
  6528. }
  6529. if (isDef((i = vnode.children))) {
  6530. for (j = 0; j < vnode.children.length; ++j) {
  6531. invokeDestroyHook(vnode.children[j]);
  6532. }
  6533. }
  6534. }
  6535. function removeVnodes(vnodes, startIdx, endIdx) {
  6536. for (; startIdx <= endIdx; ++startIdx) {
  6537. const ch = vnodes[startIdx];
  6538. if (isDef(ch)) {
  6539. if (isDef(ch.tag)) {
  6540. removeAndInvokeRemoveHook(ch);
  6541. invokeDestroyHook(ch);
  6542. }
  6543. else {
  6544. // Text node
  6545. removeNode(ch.elm);
  6546. }
  6547. }
  6548. }
  6549. }
  6550. function removeAndInvokeRemoveHook(vnode, rm) {
  6551. if (isDef(rm) || isDef(vnode.data)) {
  6552. let i;
  6553. const listeners = cbs.remove.length + 1;
  6554. if (isDef(rm)) {
  6555. // we have a recursively passed down rm callback
  6556. // increase the listeners count
  6557. rm.listeners += listeners;
  6558. }
  6559. else {
  6560. // directly removing
  6561. rm = createRmCb(vnode.elm, listeners);
  6562. }
  6563. // recursively invoke hooks on child component root node
  6564. if (isDef((i = vnode.componentInstance)) &&
  6565. isDef((i = i._vnode)) &&
  6566. isDef(i.data)) {
  6567. removeAndInvokeRemoveHook(i, rm);
  6568. }
  6569. for (i = 0; i < cbs.remove.length; ++i) {
  6570. cbs.remove[i](vnode, rm);
  6571. }
  6572. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6573. i(vnode, rm);
  6574. }
  6575. else {
  6576. rm();
  6577. }
  6578. }
  6579. else {
  6580. removeNode(vnode.elm);
  6581. }
  6582. }
  6583. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6584. let oldStartIdx = 0;
  6585. let newStartIdx = 0;
  6586. let oldEndIdx = oldCh.length - 1;
  6587. let oldStartVnode = oldCh[0];
  6588. let oldEndVnode = oldCh[oldEndIdx];
  6589. let newEndIdx = newCh.length - 1;
  6590. let newStartVnode = newCh[0];
  6591. let newEndVnode = newCh[newEndIdx];
  6592. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6593. // removeOnly is a special flag used only by <transition-group>
  6594. // to ensure removed elements stay in correct relative positions
  6595. // during leaving transitions
  6596. const canMove = !removeOnly;
  6597. {
  6598. checkDuplicateKeys(newCh);
  6599. }
  6600. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6601. if (isUndef(oldStartVnode)) {
  6602. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6603. }
  6604. else if (isUndef(oldEndVnode)) {
  6605. oldEndVnode = oldCh[--oldEndIdx];
  6606. }
  6607. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6608. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6609. oldStartVnode = oldCh[++oldStartIdx];
  6610. newStartVnode = newCh[++newStartIdx];
  6611. }
  6612. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6613. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6614. oldEndVnode = oldCh[--oldEndIdx];
  6615. newEndVnode = newCh[--newEndIdx];
  6616. }
  6617. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6618. // Vnode moved right
  6619. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6620. canMove &&
  6621. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6622. oldStartVnode = oldCh[++oldStartIdx];
  6623. newEndVnode = newCh[--newEndIdx];
  6624. }
  6625. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6626. // Vnode moved left
  6627. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6628. canMove &&
  6629. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6630. oldEndVnode = oldCh[--oldEndIdx];
  6631. newStartVnode = newCh[++newStartIdx];
  6632. }
  6633. else {
  6634. if (isUndef(oldKeyToIdx))
  6635. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6636. idxInOld = isDef(newStartVnode.key)
  6637. ? oldKeyToIdx[newStartVnode.key]
  6638. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6639. if (isUndef(idxInOld)) {
  6640. // New element
  6641. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6642. }
  6643. else {
  6644. vnodeToMove = oldCh[idxInOld];
  6645. if (sameVnode(vnodeToMove, newStartVnode)) {
  6646. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6647. oldCh[idxInOld] = undefined;
  6648. canMove &&
  6649. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6650. }
  6651. else {
  6652. // same key but different element. treat as new element
  6653. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6654. }
  6655. }
  6656. newStartVnode = newCh[++newStartIdx];
  6657. }
  6658. }
  6659. if (oldStartIdx > oldEndIdx) {
  6660. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6661. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6662. }
  6663. else if (newStartIdx > newEndIdx) {
  6664. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6665. }
  6666. }
  6667. function checkDuplicateKeys(children) {
  6668. const seenKeys = {};
  6669. for (let i = 0; i < children.length; i++) {
  6670. const vnode = children[i];
  6671. const key = vnode.key;
  6672. if (isDef(key)) {
  6673. if (seenKeys[key]) {
  6674. warn(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6675. }
  6676. else {
  6677. seenKeys[key] = true;
  6678. }
  6679. }
  6680. }
  6681. }
  6682. function findIdxInOld(node, oldCh, start, end) {
  6683. for (let i = start; i < end; i++) {
  6684. const c = oldCh[i];
  6685. if (isDef(c) && sameVnode(node, c))
  6686. return i;
  6687. }
  6688. }
  6689. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6690. if (oldVnode === vnode) {
  6691. return;
  6692. }
  6693. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6694. // clone reused vnode
  6695. vnode = ownerArray[index] = cloneVNode(vnode);
  6696. }
  6697. const elm = (vnode.elm = oldVnode.elm);
  6698. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6699. if (isDef(vnode.asyncFactory.resolved)) {
  6700. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6701. }
  6702. else {
  6703. vnode.isAsyncPlaceholder = true;
  6704. }
  6705. return;
  6706. }
  6707. // reuse element for static trees.
  6708. // note we only do this if the vnode is cloned -
  6709. // if the new node is not cloned it means the render functions have been
  6710. // reset by the hot-reload-api and we need to do a proper re-render.
  6711. if (isTrue(vnode.isStatic) &&
  6712. isTrue(oldVnode.isStatic) &&
  6713. vnode.key === oldVnode.key &&
  6714. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6715. vnode.componentInstance = oldVnode.componentInstance;
  6716. return;
  6717. }
  6718. let i;
  6719. const data = vnode.data;
  6720. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6721. i(oldVnode, vnode);
  6722. }
  6723. const oldCh = oldVnode.children;
  6724. const ch = vnode.children;
  6725. if (isDef(data) && isPatchable(vnode)) {
  6726. for (i = 0; i < cbs.update.length; ++i)
  6727. cbs.update[i](oldVnode, vnode);
  6728. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6729. i(oldVnode, vnode);
  6730. }
  6731. if (isUndef(vnode.text)) {
  6732. if (isDef(oldCh) && isDef(ch)) {
  6733. if (oldCh !== ch)
  6734. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6735. }
  6736. else if (isDef(ch)) {
  6737. {
  6738. checkDuplicateKeys(ch);
  6739. }
  6740. if (isDef(oldVnode.text))
  6741. nodeOps.setTextContent(elm, '');
  6742. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6743. }
  6744. else if (isDef(oldCh)) {
  6745. removeVnodes(oldCh, 0, oldCh.length - 1);
  6746. }
  6747. else if (isDef(oldVnode.text)) {
  6748. nodeOps.setTextContent(elm, '');
  6749. }
  6750. }
  6751. else if (oldVnode.text !== vnode.text) {
  6752. nodeOps.setTextContent(elm, vnode.text);
  6753. }
  6754. if (isDef(data)) {
  6755. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6756. i(oldVnode, vnode);
  6757. }
  6758. }
  6759. function invokeInsertHook(vnode, queue, initial) {
  6760. // delay insert hooks for component root nodes, invoke them after the
  6761. // element is really inserted
  6762. if (isTrue(initial) && isDef(vnode.parent)) {
  6763. vnode.parent.data.pendingInsert = queue;
  6764. }
  6765. else {
  6766. for (let i = 0; i < queue.length; ++i) {
  6767. queue[i].data.hook.insert(queue[i]);
  6768. }
  6769. }
  6770. }
  6771. let hydrationBailed = false;
  6772. // list of modules that can skip create hook during hydration because they
  6773. // are already rendered on the client or has no need for initialization
  6774. // Note: style is excluded because it relies on initial clone for future
  6775. // deep updates (#7063).
  6776. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6777. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6778. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6779. let i;
  6780. const { tag, data, children } = vnode;
  6781. inVPre = inVPre || (data && data.pre);
  6782. vnode.elm = elm;
  6783. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6784. vnode.isAsyncPlaceholder = true;
  6785. return true;
  6786. }
  6787. // assert node match
  6788. {
  6789. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6790. return false;
  6791. }
  6792. }
  6793. if (isDef(data)) {
  6794. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6795. i(vnode, true /* hydrating */);
  6796. if (isDef((i = vnode.componentInstance))) {
  6797. // child component. it should have hydrated its own tree.
  6798. initComponent(vnode, insertedVnodeQueue);
  6799. return true;
  6800. }
  6801. }
  6802. if (isDef(tag)) {
  6803. if (isDef(children)) {
  6804. // empty element, allow client to pick up and populate children
  6805. if (!elm.hasChildNodes()) {
  6806. createChildren(vnode, children, insertedVnodeQueue);
  6807. }
  6808. else {
  6809. // v-html and domProps: innerHTML
  6810. if (isDef((i = data)) &&
  6811. isDef((i = i.domProps)) &&
  6812. isDef((i = i.innerHTML))) {
  6813. if (i !== elm.innerHTML) {
  6814. /* istanbul ignore if */
  6815. if (typeof console !== 'undefined' &&
  6816. !hydrationBailed) {
  6817. hydrationBailed = true;
  6818. console.warn('Parent: ', elm);
  6819. console.warn('server innerHTML: ', i);
  6820. console.warn('client innerHTML: ', elm.innerHTML);
  6821. }
  6822. return false;
  6823. }
  6824. }
  6825. else {
  6826. // iterate and compare children lists
  6827. let childrenMatch = true;
  6828. let childNode = elm.firstChild;
  6829. for (let i = 0; i < children.length; i++) {
  6830. if (!childNode ||
  6831. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6832. childrenMatch = false;
  6833. break;
  6834. }
  6835. childNode = childNode.nextSibling;
  6836. }
  6837. // if childNode is not null, it means the actual childNodes list is
  6838. // longer than the virtual children list.
  6839. if (!childrenMatch || childNode) {
  6840. /* istanbul ignore if */
  6841. if (typeof console !== 'undefined' &&
  6842. !hydrationBailed) {
  6843. hydrationBailed = true;
  6844. console.warn('Parent: ', elm);
  6845. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6846. }
  6847. return false;
  6848. }
  6849. }
  6850. }
  6851. }
  6852. if (isDef(data)) {
  6853. let fullInvoke = false;
  6854. for (const key in data) {
  6855. if (!isRenderedModule(key)) {
  6856. fullInvoke = true;
  6857. invokeCreateHooks(vnode, insertedVnodeQueue);
  6858. break;
  6859. }
  6860. }
  6861. if (!fullInvoke && data['class']) {
  6862. // ensure collecting deps for deep class bindings for future updates
  6863. traverse(data['class']);
  6864. }
  6865. }
  6866. }
  6867. else if (elm.data !== vnode.text) {
  6868. elm.data = vnode.text;
  6869. }
  6870. return true;
  6871. }
  6872. function assertNodeMatch(node, vnode, inVPre) {
  6873. if (isDef(vnode.tag)) {
  6874. return (vnode.tag.indexOf('vue-component') === 0 ||
  6875. (!isUnknownElement(vnode, inVPre) &&
  6876. vnode.tag.toLowerCase() ===
  6877. (node.tagName && node.tagName.toLowerCase())));
  6878. }
  6879. else {
  6880. return node.nodeType === (vnode.isComment ? 8 : 3);
  6881. }
  6882. }
  6883. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6884. if (isUndef(vnode)) {
  6885. if (isDef(oldVnode))
  6886. invokeDestroyHook(oldVnode);
  6887. return;
  6888. }
  6889. let isInitialPatch = false;
  6890. const insertedVnodeQueue = [];
  6891. if (isUndef(oldVnode)) {
  6892. // empty mount (likely as component), create new root element
  6893. isInitialPatch = true;
  6894. createElm(vnode, insertedVnodeQueue);
  6895. }
  6896. else {
  6897. const isRealElement = isDef(oldVnode.nodeType);
  6898. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6899. // patch existing root node
  6900. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6901. }
  6902. else {
  6903. if (isRealElement) {
  6904. // mounting to a real element
  6905. // check if this is server-rendered content and if we can perform
  6906. // a successful hydration.
  6907. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6908. oldVnode.removeAttribute(SSR_ATTR);
  6909. hydrating = true;
  6910. }
  6911. if (isTrue(hydrating)) {
  6912. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6913. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6914. return oldVnode;
  6915. }
  6916. else {
  6917. warn('The client-side rendered virtual DOM tree is not matching ' +
  6918. 'server-rendered content. This is likely caused by incorrect ' +
  6919. 'HTML markup, for example nesting block-level elements inside ' +
  6920. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6921. 'full client-side render.');
  6922. }
  6923. }
  6924. // either not server-rendered, or hydration failed.
  6925. // create an empty node and replace it
  6926. oldVnode = emptyNodeAt(oldVnode);
  6927. }
  6928. // replacing existing element
  6929. const oldElm = oldVnode.elm;
  6930. const parentElm = nodeOps.parentNode(oldElm);
  6931. // create new node
  6932. createElm(vnode, insertedVnodeQueue,
  6933. // extremely rare edge case: do not insert if old element is in a
  6934. // leaving transition. Only happens when combining transition +
  6935. // keep-alive + HOCs. (#4590)
  6936. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6937. // update parent placeholder node element, recursively
  6938. if (isDef(vnode.parent)) {
  6939. let ancestor = vnode.parent;
  6940. const patchable = isPatchable(vnode);
  6941. while (ancestor) {
  6942. for (let i = 0; i < cbs.destroy.length; ++i) {
  6943. cbs.destroy[i](ancestor);
  6944. }
  6945. ancestor.elm = vnode.elm;
  6946. if (patchable) {
  6947. for (let i = 0; i < cbs.create.length; ++i) {
  6948. cbs.create[i](emptyNode, ancestor);
  6949. }
  6950. // #6513
  6951. // invoke insert hooks that may have been merged by create hooks.
  6952. // e.g. for directives that uses the "inserted" hook.
  6953. const insert = ancestor.data.hook.insert;
  6954. if (insert.merged) {
  6955. // start at index 1 to avoid re-invoking component mounted hook
  6956. for (let i = 1; i < insert.fns.length; i++) {
  6957. insert.fns[i]();
  6958. }
  6959. }
  6960. }
  6961. else {
  6962. registerRef(ancestor);
  6963. }
  6964. ancestor = ancestor.parent;
  6965. }
  6966. }
  6967. // destroy old node
  6968. if (isDef(parentElm)) {
  6969. removeVnodes([oldVnode], 0, 0);
  6970. }
  6971. else if (isDef(oldVnode.tag)) {
  6972. invokeDestroyHook(oldVnode);
  6973. }
  6974. }
  6975. }
  6976. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6977. return vnode.elm;
  6978. };
  6979. }
  6980. var directives = {
  6981. create: updateDirectives,
  6982. update: updateDirectives,
  6983. destroy: function unbindDirectives(vnode) {
  6984. // @ts-expect-error emptyNode is not VNodeWithData
  6985. updateDirectives(vnode, emptyNode);
  6986. }
  6987. };
  6988. function updateDirectives(oldVnode, vnode) {
  6989. if (oldVnode.data.directives || vnode.data.directives) {
  6990. _update(oldVnode, vnode);
  6991. }
  6992. }
  6993. function _update(oldVnode, vnode) {
  6994. const isCreate = oldVnode === emptyNode;
  6995. const isDestroy = vnode === emptyNode;
  6996. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  6997. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  6998. const dirsWithInsert = [];
  6999. const dirsWithPostpatch = [];
  7000. let key, oldDir, dir;
  7001. for (key in newDirs) {
  7002. oldDir = oldDirs[key];
  7003. dir = newDirs[key];
  7004. if (!oldDir) {
  7005. // new directive, bind
  7006. callHook(dir, 'bind', vnode, oldVnode);
  7007. if (dir.def && dir.def.inserted) {
  7008. dirsWithInsert.push(dir);
  7009. }
  7010. }
  7011. else {
  7012. // existing directive, update
  7013. dir.oldValue = oldDir.value;
  7014. dir.oldArg = oldDir.arg;
  7015. callHook(dir, 'update', vnode, oldVnode);
  7016. if (dir.def && dir.def.componentUpdated) {
  7017. dirsWithPostpatch.push(dir);
  7018. }
  7019. }
  7020. }
  7021. if (dirsWithInsert.length) {
  7022. const callInsert = () => {
  7023. for (let i = 0; i < dirsWithInsert.length; i++) {
  7024. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7025. }
  7026. };
  7027. if (isCreate) {
  7028. mergeVNodeHook(vnode, 'insert', callInsert);
  7029. }
  7030. else {
  7031. callInsert();
  7032. }
  7033. }
  7034. if (dirsWithPostpatch.length) {
  7035. mergeVNodeHook(vnode, 'postpatch', () => {
  7036. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7037. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7038. }
  7039. });
  7040. }
  7041. if (!isCreate) {
  7042. for (key in oldDirs) {
  7043. if (!newDirs[key]) {
  7044. // no longer present, unbind
  7045. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7046. }
  7047. }
  7048. }
  7049. }
  7050. const emptyModifiers = Object.create(null);
  7051. function normalizeDirectives(dirs, vm) {
  7052. const res = Object.create(null);
  7053. if (!dirs) {
  7054. // $flow-disable-line
  7055. return res;
  7056. }
  7057. let i, dir;
  7058. for (i = 0; i < dirs.length; i++) {
  7059. dir = dirs[i];
  7060. if (!dir.modifiers) {
  7061. // $flow-disable-line
  7062. dir.modifiers = emptyModifiers;
  7063. }
  7064. res[getRawDirName(dir)] = dir;
  7065. if (vm._setupState && vm._setupState.__sfc) {
  7066. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7067. if (typeof setupDef === 'function') {
  7068. dir.def = {
  7069. bind: setupDef,
  7070. update: setupDef,
  7071. };
  7072. }
  7073. else {
  7074. dir.def = setupDef;
  7075. }
  7076. }
  7077. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7078. }
  7079. // $flow-disable-line
  7080. return res;
  7081. }
  7082. function getRawDirName(dir) {
  7083. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7084. }
  7085. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7086. const fn = dir.def && dir.def[hook];
  7087. if (fn) {
  7088. try {
  7089. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7090. }
  7091. catch (e) {
  7092. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7093. }
  7094. }
  7095. }
  7096. var baseModules = [ref, directives];
  7097. function updateAttrs(oldVnode, vnode) {
  7098. const opts = vnode.componentOptions;
  7099. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7100. return;
  7101. }
  7102. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7103. return;
  7104. }
  7105. let key, cur, old;
  7106. const elm = vnode.elm;
  7107. const oldAttrs = oldVnode.data.attrs || {};
  7108. let attrs = vnode.data.attrs || {};
  7109. // clone observed objects, as the user probably wants to mutate it
  7110. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7111. attrs = vnode.data.attrs = extend({}, attrs);
  7112. }
  7113. for (key in attrs) {
  7114. cur = attrs[key];
  7115. old = oldAttrs[key];
  7116. if (old !== cur) {
  7117. setAttr(elm, key, cur, vnode.data.pre);
  7118. }
  7119. }
  7120. // #4391: in IE9, setting type can reset value for input[type=radio]
  7121. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7122. /* istanbul ignore if */
  7123. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7124. setAttr(elm, 'value', attrs.value);
  7125. }
  7126. for (key in oldAttrs) {
  7127. if (isUndef(attrs[key])) {
  7128. if (isXlink(key)) {
  7129. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7130. }
  7131. else if (!isEnumeratedAttr(key)) {
  7132. elm.removeAttribute(key);
  7133. }
  7134. }
  7135. }
  7136. }
  7137. function setAttr(el, key, value, isInPre) {
  7138. if (isInPre || el.tagName.indexOf('-') > -1) {
  7139. baseSetAttr(el, key, value);
  7140. }
  7141. else if (isBooleanAttr(key)) {
  7142. // set attribute for blank value
  7143. // e.g. <option disabled>Select one</option>
  7144. if (isFalsyAttrValue(value)) {
  7145. el.removeAttribute(key);
  7146. }
  7147. else {
  7148. // technically allowfullscreen is a boolean attribute for <iframe>,
  7149. // but Flash expects a value of "true" when used on <embed> tag
  7150. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7151. el.setAttribute(key, value);
  7152. }
  7153. }
  7154. else if (isEnumeratedAttr(key)) {
  7155. el.setAttribute(key, convertEnumeratedValue(key, value));
  7156. }
  7157. else if (isXlink(key)) {
  7158. if (isFalsyAttrValue(value)) {
  7159. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7160. }
  7161. else {
  7162. el.setAttributeNS(xlinkNS, key, value);
  7163. }
  7164. }
  7165. else {
  7166. baseSetAttr(el, key, value);
  7167. }
  7168. }
  7169. function baseSetAttr(el, key, value) {
  7170. if (isFalsyAttrValue(value)) {
  7171. el.removeAttribute(key);
  7172. }
  7173. else {
  7174. // #7138: IE10 & 11 fires input event when setting placeholder on
  7175. // <textarea>... block the first input event and remove the blocker
  7176. // immediately.
  7177. /* istanbul ignore if */
  7178. if (isIE &&
  7179. !isIE9 &&
  7180. el.tagName === 'TEXTAREA' &&
  7181. key === 'placeholder' &&
  7182. value !== '' &&
  7183. !el.__ieph) {
  7184. const blocker = e => {
  7185. e.stopImmediatePropagation();
  7186. el.removeEventListener('input', blocker);
  7187. };
  7188. el.addEventListener('input', blocker);
  7189. // $flow-disable-line
  7190. el.__ieph = true; /* IE placeholder patched */
  7191. }
  7192. el.setAttribute(key, value);
  7193. }
  7194. }
  7195. var attrs = {
  7196. create: updateAttrs,
  7197. update: updateAttrs
  7198. };
  7199. function updateClass(oldVnode, vnode) {
  7200. const el = vnode.elm;
  7201. const data = vnode.data;
  7202. const oldData = oldVnode.data;
  7203. if (isUndef(data.staticClass) &&
  7204. isUndef(data.class) &&
  7205. (isUndef(oldData) ||
  7206. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7207. return;
  7208. }
  7209. let cls = genClassForVnode(vnode);
  7210. // handle transition classes
  7211. const transitionClass = el._transitionClasses;
  7212. if (isDef(transitionClass)) {
  7213. cls = concat(cls, stringifyClass(transitionClass));
  7214. }
  7215. // set the class
  7216. if (cls !== el._prevClass) {
  7217. el.setAttribute('class', cls);
  7218. el._prevClass = cls;
  7219. }
  7220. }
  7221. var klass = {
  7222. create: updateClass,
  7223. update: updateClass
  7224. };
  7225. // in some cases, the event used has to be determined at runtime
  7226. // so we used some reserved tokens during compile.
  7227. const RANGE_TOKEN = '__r';
  7228. const CHECKBOX_RADIO_TOKEN = '__c';
  7229. // normalize v-model event tokens that can only be determined at runtime.
  7230. // it's important to place the event as the first in the array because
  7231. // the whole point is ensuring the v-model callback gets called before
  7232. // user-attached handlers.
  7233. function normalizeEvents(on) {
  7234. /* istanbul ignore if */
  7235. if (isDef(on[RANGE_TOKEN])) {
  7236. // IE input[type=range] only supports `change` event
  7237. const event = isIE ? 'change' : 'input';
  7238. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7239. delete on[RANGE_TOKEN];
  7240. }
  7241. // This was originally intended to fix #4521 but no longer necessary
  7242. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7243. /* istanbul ignore if */
  7244. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7245. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7246. delete on[CHECKBOX_RADIO_TOKEN];
  7247. }
  7248. }
  7249. let target;
  7250. function createOnceHandler(event, handler, capture) {
  7251. const _target = target; // save current target element in closure
  7252. return function onceHandler() {
  7253. const res = handler.apply(null, arguments);
  7254. if (res !== null) {
  7255. remove(event, onceHandler, capture, _target);
  7256. }
  7257. };
  7258. }
  7259. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7260. // implementation and does not fire microtasks in between event propagation, so
  7261. // safe to exclude.
  7262. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7263. function add(name, handler, capture, passive) {
  7264. // async edge case #6566: inner click event triggers patch, event handler
  7265. // attached to outer element during patch, and triggered again. This
  7266. // happens because browsers fire microtask ticks between event propagation.
  7267. // the solution is simple: we save the timestamp when a handler is attached,
  7268. // and the handler would only fire if the event passed to it was fired
  7269. // AFTER it was attached.
  7270. if (useMicrotaskFix) {
  7271. const attachedTimestamp = currentFlushTimestamp;
  7272. const original = handler;
  7273. //@ts-expect-error
  7274. handler = original._wrapper = function (e) {
  7275. if (
  7276. // no bubbling, should always fire.
  7277. // this is just a safety net in case event.timeStamp is unreliable in
  7278. // certain weird environments...
  7279. e.target === e.currentTarget ||
  7280. // event is fired after handler attachment
  7281. e.timeStamp >= attachedTimestamp ||
  7282. // bail for environments that have buggy event.timeStamp implementations
  7283. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7284. // #9681 QtWebEngine event.timeStamp is negative value
  7285. e.timeStamp <= 0 ||
  7286. // #9448 bail if event is fired in another document in a multi-page
  7287. // electron/nw.js app, since event.timeStamp will be using a different
  7288. // starting reference
  7289. e.target.ownerDocument !== document) {
  7290. return original.apply(this, arguments);
  7291. }
  7292. };
  7293. }
  7294. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7295. }
  7296. function remove(name, handler, capture, _target) {
  7297. (_target || target).removeEventListener(name,
  7298. //@ts-expect-error
  7299. handler._wrapper || handler, capture);
  7300. }
  7301. function updateDOMListeners(oldVnode, vnode) {
  7302. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7303. return;
  7304. }
  7305. const on = vnode.data.on || {};
  7306. const oldOn = oldVnode.data.on || {};
  7307. // vnode is empty when removing all listeners,
  7308. // and use old vnode dom element
  7309. target = vnode.elm || oldVnode.elm;
  7310. normalizeEvents(on);
  7311. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7312. target = undefined;
  7313. }
  7314. var events = {
  7315. create: updateDOMListeners,
  7316. update: updateDOMListeners,
  7317. // @ts-expect-error emptyNode has actually data
  7318. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7319. };
  7320. let svgContainer;
  7321. function updateDOMProps(oldVnode, vnode) {
  7322. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7323. return;
  7324. }
  7325. let key, cur;
  7326. const elm = vnode.elm;
  7327. const oldProps = oldVnode.data.domProps || {};
  7328. let props = vnode.data.domProps || {};
  7329. // clone observed objects, as the user probably wants to mutate it
  7330. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7331. props = vnode.data.domProps = extend({}, props);
  7332. }
  7333. for (key in oldProps) {
  7334. if (!(key in props)) {
  7335. elm[key] = '';
  7336. }
  7337. }
  7338. for (key in props) {
  7339. cur = props[key];
  7340. // ignore children if the node has textContent or innerHTML,
  7341. // as these will throw away existing DOM nodes and cause removal errors
  7342. // on subsequent patches (#3360)
  7343. if (key === 'textContent' || key === 'innerHTML') {
  7344. if (vnode.children)
  7345. vnode.children.length = 0;
  7346. if (cur === oldProps[key])
  7347. continue;
  7348. // #6601 work around Chrome version <= 55 bug where single textNode
  7349. // replaced by innerHTML/textContent retains its parentNode property
  7350. if (elm.childNodes.length === 1) {
  7351. elm.removeChild(elm.childNodes[0]);
  7352. }
  7353. }
  7354. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7355. // store value as _value as well since
  7356. // non-string values will be stringified
  7357. elm._value = cur;
  7358. // avoid resetting cursor position when value is the same
  7359. const strCur = isUndef(cur) ? '' : String(cur);
  7360. if (shouldUpdateValue(elm, strCur)) {
  7361. elm.value = strCur;
  7362. }
  7363. }
  7364. else if (key === 'innerHTML' &&
  7365. isSVG(elm.tagName) &&
  7366. isUndef(elm.innerHTML)) {
  7367. // IE doesn't support innerHTML for SVG elements
  7368. svgContainer = svgContainer || document.createElement('div');
  7369. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7370. const svg = svgContainer.firstChild;
  7371. while (elm.firstChild) {
  7372. elm.removeChild(elm.firstChild);
  7373. }
  7374. while (svg.firstChild) {
  7375. elm.appendChild(svg.firstChild);
  7376. }
  7377. }
  7378. else if (
  7379. // skip the update if old and new VDOM state is the same.
  7380. // `value` is handled separately because the DOM value may be temporarily
  7381. // out of sync with VDOM state due to focus, composition and modifiers.
  7382. // This #4521 by skipping the unnecessary `checked` update.
  7383. cur !== oldProps[key]) {
  7384. // some property updates can throw
  7385. // e.g. `value` on <progress> w/ non-finite value
  7386. try {
  7387. elm[key] = cur;
  7388. }
  7389. catch (e) { }
  7390. }
  7391. }
  7392. }
  7393. function shouldUpdateValue(elm, checkVal) {
  7394. return (
  7395. //@ts-expect-error
  7396. !elm.composing &&
  7397. (elm.tagName === 'OPTION' ||
  7398. isNotInFocusAndDirty(elm, checkVal) ||
  7399. isDirtyWithModifiers(elm, checkVal)));
  7400. }
  7401. function isNotInFocusAndDirty(elm, checkVal) {
  7402. // return true when textbox (.number and .trim) loses focus and its value is
  7403. // not equal to the updated value
  7404. let notInFocus = true;
  7405. // #6157
  7406. // work around IE bug when accessing document.activeElement in an iframe
  7407. try {
  7408. notInFocus = document.activeElement !== elm;
  7409. }
  7410. catch (e) { }
  7411. return notInFocus && elm.value !== checkVal;
  7412. }
  7413. function isDirtyWithModifiers(elm, newVal) {
  7414. const value = elm.value;
  7415. const modifiers = elm._vModifiers; // injected by v-model runtime
  7416. if (isDef(modifiers)) {
  7417. if (modifiers.number) {
  7418. return toNumber(value) !== toNumber(newVal);
  7419. }
  7420. if (modifiers.trim) {
  7421. return value.trim() !== newVal.trim();
  7422. }
  7423. }
  7424. return value !== newVal;
  7425. }
  7426. var domProps = {
  7427. create: updateDOMProps,
  7428. update: updateDOMProps
  7429. };
  7430. const parseStyleText = cached(function (cssText) {
  7431. const res = {};
  7432. const listDelimiter = /;(?![^(]*\))/g;
  7433. const propertyDelimiter = /:(.+)/;
  7434. cssText.split(listDelimiter).forEach(function (item) {
  7435. if (item) {
  7436. const tmp = item.split(propertyDelimiter);
  7437. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7438. }
  7439. });
  7440. return res;
  7441. });
  7442. // merge static and dynamic style data on the same vnode
  7443. function normalizeStyleData(data) {
  7444. const style = normalizeStyleBinding(data.style);
  7445. // static style is pre-processed into an object during compilation
  7446. // and is always a fresh object, so it's safe to merge into it
  7447. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7448. }
  7449. // normalize possible array / string values into Object
  7450. function normalizeStyleBinding(bindingStyle) {
  7451. if (Array.isArray(bindingStyle)) {
  7452. return toObject(bindingStyle);
  7453. }
  7454. if (typeof bindingStyle === 'string') {
  7455. return parseStyleText(bindingStyle);
  7456. }
  7457. return bindingStyle;
  7458. }
  7459. /**
  7460. * parent component style should be after child's
  7461. * so that parent component's style could override it
  7462. */
  7463. function getStyle(vnode, checkChild) {
  7464. const res = {};
  7465. let styleData;
  7466. if (checkChild) {
  7467. let childNode = vnode;
  7468. while (childNode.componentInstance) {
  7469. childNode = childNode.componentInstance._vnode;
  7470. if (childNode &&
  7471. childNode.data &&
  7472. (styleData = normalizeStyleData(childNode.data))) {
  7473. extend(res, styleData);
  7474. }
  7475. }
  7476. }
  7477. if ((styleData = normalizeStyleData(vnode.data))) {
  7478. extend(res, styleData);
  7479. }
  7480. let parentNode = vnode;
  7481. // @ts-expect-error parentNode.parent not VNodeWithData
  7482. while ((parentNode = parentNode.parent)) {
  7483. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7484. extend(res, styleData);
  7485. }
  7486. }
  7487. return res;
  7488. }
  7489. const cssVarRE = /^--/;
  7490. const importantRE = /\s*!important$/;
  7491. const setProp = (el, name, val) => {
  7492. /* istanbul ignore if */
  7493. if (cssVarRE.test(name)) {
  7494. el.style.setProperty(name, val);
  7495. }
  7496. else if (importantRE.test(val)) {
  7497. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7498. }
  7499. else {
  7500. const normalizedName = normalize(name);
  7501. if (Array.isArray(val)) {
  7502. // Support values array created by autoprefixer, e.g.
  7503. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7504. // Set them one by one, and the browser will only set those it can recognize
  7505. for (let i = 0, len = val.length; i < len; i++) {
  7506. el.style[normalizedName] = val[i];
  7507. }
  7508. }
  7509. else {
  7510. el.style[normalizedName] = val;
  7511. }
  7512. }
  7513. };
  7514. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7515. let emptyStyle;
  7516. const normalize = cached(function (prop) {
  7517. emptyStyle = emptyStyle || document.createElement('div').style;
  7518. prop = camelize(prop);
  7519. if (prop !== 'filter' && prop in emptyStyle) {
  7520. return prop;
  7521. }
  7522. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7523. for (let i = 0; i < vendorNames.length; i++) {
  7524. const name = vendorNames[i] + capName;
  7525. if (name in emptyStyle) {
  7526. return name;
  7527. }
  7528. }
  7529. });
  7530. function updateStyle(oldVnode, vnode) {
  7531. const data = vnode.data;
  7532. const oldData = oldVnode.data;
  7533. if (isUndef(data.staticStyle) &&
  7534. isUndef(data.style) &&
  7535. isUndef(oldData.staticStyle) &&
  7536. isUndef(oldData.style)) {
  7537. return;
  7538. }
  7539. let cur, name;
  7540. const el = vnode.elm;
  7541. const oldStaticStyle = oldData.staticStyle;
  7542. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7543. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7544. const oldStyle = oldStaticStyle || oldStyleBinding;
  7545. const style = normalizeStyleBinding(vnode.data.style) || {};
  7546. // store normalized style under a different key for next diff
  7547. // make sure to clone it if it's reactive, since the user likely wants
  7548. // to mutate it.
  7549. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  7550. const newStyle = getStyle(vnode, true);
  7551. for (name in oldStyle) {
  7552. if (isUndef(newStyle[name])) {
  7553. setProp(el, name, '');
  7554. }
  7555. }
  7556. for (name in newStyle) {
  7557. cur = newStyle[name];
  7558. if (cur !== oldStyle[name]) {
  7559. // ie9 setting to null has no effect, must use empty string
  7560. setProp(el, name, cur == null ? '' : cur);
  7561. }
  7562. }
  7563. }
  7564. var style = {
  7565. create: updateStyle,
  7566. update: updateStyle
  7567. };
  7568. const whitespaceRE = /\s+/;
  7569. /**
  7570. * Add class with compatibility for SVG since classList is not supported on
  7571. * SVG elements in IE
  7572. */
  7573. function addClass(el, cls) {
  7574. /* istanbul ignore if */
  7575. if (!cls || !(cls = cls.trim())) {
  7576. return;
  7577. }
  7578. /* istanbul ignore else */
  7579. if (el.classList) {
  7580. if (cls.indexOf(' ') > -1) {
  7581. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7582. }
  7583. else {
  7584. el.classList.add(cls);
  7585. }
  7586. }
  7587. else {
  7588. const cur = ` ${el.getAttribute('class') || ''} `;
  7589. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7590. el.setAttribute('class', (cur + cls).trim());
  7591. }
  7592. }
  7593. }
  7594. /**
  7595. * Remove class with compatibility for SVG since classList is not supported on
  7596. * SVG elements in IE
  7597. */
  7598. function removeClass(el, cls) {
  7599. /* istanbul ignore if */
  7600. if (!cls || !(cls = cls.trim())) {
  7601. return;
  7602. }
  7603. /* istanbul ignore else */
  7604. if (el.classList) {
  7605. if (cls.indexOf(' ') > -1) {
  7606. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7607. }
  7608. else {
  7609. el.classList.remove(cls);
  7610. }
  7611. if (!el.classList.length) {
  7612. el.removeAttribute('class');
  7613. }
  7614. }
  7615. else {
  7616. let cur = ` ${el.getAttribute('class') || ''} `;
  7617. const tar = ' ' + cls + ' ';
  7618. while (cur.indexOf(tar) >= 0) {
  7619. cur = cur.replace(tar, ' ');
  7620. }
  7621. cur = cur.trim();
  7622. if (cur) {
  7623. el.setAttribute('class', cur);
  7624. }
  7625. else {
  7626. el.removeAttribute('class');
  7627. }
  7628. }
  7629. }
  7630. function resolveTransition(def) {
  7631. if (!def) {
  7632. return;
  7633. }
  7634. /* istanbul ignore else */
  7635. if (typeof def === 'object') {
  7636. const res = {};
  7637. if (def.css !== false) {
  7638. extend(res, autoCssTransition(def.name || 'v'));
  7639. }
  7640. extend(res, def);
  7641. return res;
  7642. }
  7643. else if (typeof def === 'string') {
  7644. return autoCssTransition(def);
  7645. }
  7646. }
  7647. const autoCssTransition = cached(name => {
  7648. return {
  7649. enterClass: `${name}-enter`,
  7650. enterToClass: `${name}-enter-to`,
  7651. enterActiveClass: `${name}-enter-active`,
  7652. leaveClass: `${name}-leave`,
  7653. leaveToClass: `${name}-leave-to`,
  7654. leaveActiveClass: `${name}-leave-active`
  7655. };
  7656. });
  7657. const hasTransition = inBrowser && !isIE9;
  7658. const TRANSITION = 'transition';
  7659. const ANIMATION = 'animation';
  7660. // Transition property/event sniffing
  7661. let transitionProp = 'transition';
  7662. let transitionEndEvent = 'transitionend';
  7663. let animationProp = 'animation';
  7664. let animationEndEvent = 'animationend';
  7665. if (hasTransition) {
  7666. /* istanbul ignore if */
  7667. if (window.ontransitionend === undefined &&
  7668. window.onwebkittransitionend !== undefined) {
  7669. transitionProp = 'WebkitTransition';
  7670. transitionEndEvent = 'webkitTransitionEnd';
  7671. }
  7672. if (window.onanimationend === undefined &&
  7673. window.onwebkitanimationend !== undefined) {
  7674. animationProp = 'WebkitAnimation';
  7675. animationEndEvent = 'webkitAnimationEnd';
  7676. }
  7677. }
  7678. // binding to window is necessary to make hot reload work in IE in strict mode
  7679. const raf = inBrowser
  7680. ? window.requestAnimationFrame
  7681. ? window.requestAnimationFrame.bind(window)
  7682. : setTimeout
  7683. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  7684. function nextFrame(fn) {
  7685. raf(() => {
  7686. // @ts-expect-error
  7687. raf(fn);
  7688. });
  7689. }
  7690. function addTransitionClass(el, cls) {
  7691. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7692. if (transitionClasses.indexOf(cls) < 0) {
  7693. transitionClasses.push(cls);
  7694. addClass(el, cls);
  7695. }
  7696. }
  7697. function removeTransitionClass(el, cls) {
  7698. if (el._transitionClasses) {
  7699. remove$2(el._transitionClasses, cls);
  7700. }
  7701. removeClass(el, cls);
  7702. }
  7703. function whenTransitionEnds(el, expectedType, cb) {
  7704. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7705. if (!type)
  7706. return cb();
  7707. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7708. let ended = 0;
  7709. const end = () => {
  7710. el.removeEventListener(event, onEnd);
  7711. cb();
  7712. };
  7713. const onEnd = e => {
  7714. if (e.target === el) {
  7715. if (++ended >= propCount) {
  7716. end();
  7717. }
  7718. }
  7719. };
  7720. setTimeout(() => {
  7721. if (ended < propCount) {
  7722. end();
  7723. }
  7724. }, timeout + 1);
  7725. el.addEventListener(event, onEnd);
  7726. }
  7727. const transformRE = /\b(transform|all)(,|$)/;
  7728. function getTransitionInfo(el, expectedType) {
  7729. const styles = window.getComputedStyle(el);
  7730. // JSDOM may return undefined for transition properties
  7731. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7732. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7733. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7734. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7735. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7736. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7737. let type;
  7738. let timeout = 0;
  7739. let propCount = 0;
  7740. /* istanbul ignore if */
  7741. if (expectedType === TRANSITION) {
  7742. if (transitionTimeout > 0) {
  7743. type = TRANSITION;
  7744. timeout = transitionTimeout;
  7745. propCount = transitionDurations.length;
  7746. }
  7747. }
  7748. else if (expectedType === ANIMATION) {
  7749. if (animationTimeout > 0) {
  7750. type = ANIMATION;
  7751. timeout = animationTimeout;
  7752. propCount = animationDurations.length;
  7753. }
  7754. }
  7755. else {
  7756. timeout = Math.max(transitionTimeout, animationTimeout);
  7757. type =
  7758. timeout > 0
  7759. ? transitionTimeout > animationTimeout
  7760. ? TRANSITION
  7761. : ANIMATION
  7762. : null;
  7763. propCount = type
  7764. ? type === TRANSITION
  7765. ? transitionDurations.length
  7766. : animationDurations.length
  7767. : 0;
  7768. }
  7769. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  7770. return {
  7771. type,
  7772. timeout,
  7773. propCount,
  7774. hasTransform
  7775. };
  7776. }
  7777. function getTimeout(delays, durations) {
  7778. /* istanbul ignore next */
  7779. while (delays.length < durations.length) {
  7780. delays = delays.concat(delays);
  7781. }
  7782. return Math.max.apply(null, durations.map((d, i) => {
  7783. return toMs(d) + toMs(delays[i]);
  7784. }));
  7785. }
  7786. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7787. // in a locale-dependent way, using a comma instead of a dot.
  7788. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7789. // as a floor function) causing unexpected behaviors
  7790. function toMs(s) {
  7791. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  7792. }
  7793. function enter(vnode, toggleDisplay) {
  7794. const el = vnode.elm;
  7795. // call leave callback now
  7796. if (isDef(el._leaveCb)) {
  7797. el._leaveCb.cancelled = true;
  7798. el._leaveCb();
  7799. }
  7800. const data = resolveTransition(vnode.data.transition);
  7801. if (isUndef(data)) {
  7802. return;
  7803. }
  7804. /* istanbul ignore if */
  7805. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7806. return;
  7807. }
  7808. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  7809. // activeInstance will always be the <transition> component managing this
  7810. // transition. One edge case to check is when the <transition> is placed
  7811. // as the root node of a child component. In that case we need to check
  7812. // <transition>'s parent for appear check.
  7813. let context = activeInstance;
  7814. let transitionNode = activeInstance.$vnode;
  7815. while (transitionNode && transitionNode.parent) {
  7816. context = transitionNode.context;
  7817. transitionNode = transitionNode.parent;
  7818. }
  7819. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7820. if (isAppear && !appear && appear !== '') {
  7821. return;
  7822. }
  7823. const startClass = isAppear && appearClass ? appearClass : enterClass;
  7824. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  7825. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  7826. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  7827. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  7828. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  7829. const enterCancelledHook = isAppear
  7830. ? appearCancelled || enterCancelled
  7831. : enterCancelled;
  7832. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  7833. if (explicitEnterDuration != null) {
  7834. checkDuration(explicitEnterDuration, 'enter', vnode);
  7835. }
  7836. const expectsCSS = css !== false && !isIE9;
  7837. const userWantsControl = getHookArgumentsLength(enterHook);
  7838. const cb = (el._enterCb = once(() => {
  7839. if (expectsCSS) {
  7840. removeTransitionClass(el, toClass);
  7841. removeTransitionClass(el, activeClass);
  7842. }
  7843. // @ts-expect-error
  7844. if (cb.cancelled) {
  7845. if (expectsCSS) {
  7846. removeTransitionClass(el, startClass);
  7847. }
  7848. enterCancelledHook && enterCancelledHook(el);
  7849. }
  7850. else {
  7851. afterEnterHook && afterEnterHook(el);
  7852. }
  7853. el._enterCb = null;
  7854. }));
  7855. if (!vnode.data.show) {
  7856. // remove pending leave element on enter by injecting an insert hook
  7857. mergeVNodeHook(vnode, 'insert', () => {
  7858. const parent = el.parentNode;
  7859. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7860. if (pendingNode &&
  7861. pendingNode.tag === vnode.tag &&
  7862. pendingNode.elm._leaveCb) {
  7863. pendingNode.elm._leaveCb();
  7864. }
  7865. enterHook && enterHook(el, cb);
  7866. });
  7867. }
  7868. // start enter transition
  7869. beforeEnterHook && beforeEnterHook(el);
  7870. if (expectsCSS) {
  7871. addTransitionClass(el, startClass);
  7872. addTransitionClass(el, activeClass);
  7873. nextFrame(() => {
  7874. removeTransitionClass(el, startClass);
  7875. // @ts-expect-error
  7876. if (!cb.cancelled) {
  7877. addTransitionClass(el, toClass);
  7878. if (!userWantsControl) {
  7879. if (isValidDuration(explicitEnterDuration)) {
  7880. setTimeout(cb, explicitEnterDuration);
  7881. }
  7882. else {
  7883. whenTransitionEnds(el, type, cb);
  7884. }
  7885. }
  7886. }
  7887. });
  7888. }
  7889. if (vnode.data.show) {
  7890. toggleDisplay && toggleDisplay();
  7891. enterHook && enterHook(el, cb);
  7892. }
  7893. if (!expectsCSS && !userWantsControl) {
  7894. cb();
  7895. }
  7896. }
  7897. function leave(vnode, rm) {
  7898. const el = vnode.elm;
  7899. // call enter callback now
  7900. if (isDef(el._enterCb)) {
  7901. el._enterCb.cancelled = true;
  7902. el._enterCb();
  7903. }
  7904. const data = resolveTransition(vnode.data.transition);
  7905. if (isUndef(data) || el.nodeType !== 1) {
  7906. return rm();
  7907. }
  7908. /* istanbul ignore if */
  7909. if (isDef(el._leaveCb)) {
  7910. return;
  7911. }
  7912. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  7913. const expectsCSS = css !== false && !isIE9;
  7914. const userWantsControl = getHookArgumentsLength(leave);
  7915. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  7916. if (isDef(explicitLeaveDuration)) {
  7917. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7918. }
  7919. const cb = (el._leaveCb = once(() => {
  7920. if (el.parentNode && el.parentNode._pending) {
  7921. el.parentNode._pending[vnode.key] = null;
  7922. }
  7923. if (expectsCSS) {
  7924. removeTransitionClass(el, leaveToClass);
  7925. removeTransitionClass(el, leaveActiveClass);
  7926. }
  7927. // @ts-expect-error
  7928. if (cb.cancelled) {
  7929. if (expectsCSS) {
  7930. removeTransitionClass(el, leaveClass);
  7931. }
  7932. leaveCancelled && leaveCancelled(el);
  7933. }
  7934. else {
  7935. rm();
  7936. afterLeave && afterLeave(el);
  7937. }
  7938. el._leaveCb = null;
  7939. }));
  7940. if (delayLeave) {
  7941. delayLeave(performLeave);
  7942. }
  7943. else {
  7944. performLeave();
  7945. }
  7946. function performLeave() {
  7947. // the delayed leave may have already been cancelled
  7948. // @ts-expect-error
  7949. if (cb.cancelled) {
  7950. return;
  7951. }
  7952. // record leaving element
  7953. if (!vnode.data.show && el.parentNode) {
  7954. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  7955. vnode;
  7956. }
  7957. beforeLeave && beforeLeave(el);
  7958. if (expectsCSS) {
  7959. addTransitionClass(el, leaveClass);
  7960. addTransitionClass(el, leaveActiveClass);
  7961. nextFrame(() => {
  7962. removeTransitionClass(el, leaveClass);
  7963. // @ts-expect-error
  7964. if (!cb.cancelled) {
  7965. addTransitionClass(el, leaveToClass);
  7966. if (!userWantsControl) {
  7967. if (isValidDuration(explicitLeaveDuration)) {
  7968. setTimeout(cb, explicitLeaveDuration);
  7969. }
  7970. else {
  7971. whenTransitionEnds(el, type, cb);
  7972. }
  7973. }
  7974. }
  7975. });
  7976. }
  7977. leave && leave(el, cb);
  7978. if (!expectsCSS && !userWantsControl) {
  7979. cb();
  7980. }
  7981. }
  7982. }
  7983. // only used in dev mode
  7984. function checkDuration(val, name, vnode) {
  7985. if (typeof val !== 'number') {
  7986. warn(`<transition> explicit ${name} duration is not a valid number - ` +
  7987. `got ${JSON.stringify(val)}.`, vnode.context);
  7988. }
  7989. else if (isNaN(val)) {
  7990. warn(`<transition> explicit ${name} duration is NaN - ` +
  7991. 'the duration expression might be incorrect.', vnode.context);
  7992. }
  7993. }
  7994. function isValidDuration(val) {
  7995. return typeof val === 'number' && !isNaN(val);
  7996. }
  7997. /**
  7998. * Normalize a transition hook's argument length. The hook may be:
  7999. * - a merged hook (invoker) with the original in .fns
  8000. * - a wrapped component method (check ._length)
  8001. * - a plain function (.length)
  8002. */
  8003. function getHookArgumentsLength(fn) {
  8004. if (isUndef(fn)) {
  8005. return false;
  8006. }
  8007. // @ts-expect-error
  8008. const invokerFns = fn.fns;
  8009. if (isDef(invokerFns)) {
  8010. // invoker
  8011. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8012. }
  8013. else {
  8014. // @ts-expect-error
  8015. return (fn._length || fn.length) > 1;
  8016. }
  8017. }
  8018. function _enter(_, vnode) {
  8019. if (vnode.data.show !== true) {
  8020. enter(vnode);
  8021. }
  8022. }
  8023. var transition = inBrowser
  8024. ? {
  8025. create: _enter,
  8026. activate: _enter,
  8027. remove(vnode, rm) {
  8028. /* istanbul ignore else */
  8029. if (vnode.data.show !== true) {
  8030. // @ts-expect-error
  8031. leave(vnode, rm);
  8032. }
  8033. else {
  8034. rm();
  8035. }
  8036. }
  8037. }
  8038. : {};
  8039. var platformModules = [attrs, klass, events, domProps, style, transition];
  8040. // the directive module should be applied last, after all
  8041. // built-in modules have been applied.
  8042. const modules = platformModules.concat(baseModules);
  8043. const patch = createPatchFunction({ nodeOps, modules });
  8044. /**
  8045. * Not type checking this file because flow doesn't like attaching
  8046. * properties to Elements.
  8047. */
  8048. /* istanbul ignore if */
  8049. if (isIE9) {
  8050. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8051. document.addEventListener('selectionchange', () => {
  8052. const el = document.activeElement;
  8053. // @ts-expect-error
  8054. if (el && el.vmodel) {
  8055. trigger(el, 'input');
  8056. }
  8057. });
  8058. }
  8059. const directive = {
  8060. inserted(el, binding, vnode, oldVnode) {
  8061. if (vnode.tag === 'select') {
  8062. // #6903
  8063. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8064. mergeVNodeHook(vnode, 'postpatch', () => {
  8065. directive.componentUpdated(el, binding, vnode);
  8066. });
  8067. }
  8068. else {
  8069. setSelected(el, binding, vnode.context);
  8070. }
  8071. el._vOptions = [].map.call(el.options, getValue);
  8072. }
  8073. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8074. el._vModifiers = binding.modifiers;
  8075. if (!binding.modifiers.lazy) {
  8076. el.addEventListener('compositionstart', onCompositionStart);
  8077. el.addEventListener('compositionend', onCompositionEnd);
  8078. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8079. // switching focus before confirming composition choice
  8080. // this also fixes the issue where some browsers e.g. iOS Chrome
  8081. // fires "change" instead of "input" on autocomplete.
  8082. el.addEventListener('change', onCompositionEnd);
  8083. /* istanbul ignore if */
  8084. if (isIE9) {
  8085. el.vmodel = true;
  8086. }
  8087. }
  8088. }
  8089. },
  8090. componentUpdated(el, binding, vnode) {
  8091. if (vnode.tag === 'select') {
  8092. setSelected(el, binding, vnode.context);
  8093. // in case the options rendered by v-for have changed,
  8094. // it's possible that the value is out-of-sync with the rendered options.
  8095. // detect such cases and filter out values that no longer has a matching
  8096. // option in the DOM.
  8097. const prevOptions = el._vOptions;
  8098. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8099. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8100. // trigger change event if
  8101. // no matching option found for at least one value
  8102. const needReset = el.multiple
  8103. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8104. : binding.value !== binding.oldValue &&
  8105. hasNoMatchingOption(binding.value, curOptions);
  8106. if (needReset) {
  8107. trigger(el, 'change');
  8108. }
  8109. }
  8110. }
  8111. }
  8112. };
  8113. function setSelected(el, binding, vm) {
  8114. actuallySetSelected(el, binding, vm);
  8115. /* istanbul ignore if */
  8116. if (isIE || isEdge) {
  8117. setTimeout(() => {
  8118. actuallySetSelected(el, binding, vm);
  8119. }, 0);
  8120. }
  8121. }
  8122. function actuallySetSelected(el, binding, vm) {
  8123. const value = binding.value;
  8124. const isMultiple = el.multiple;
  8125. if (isMultiple && !Array.isArray(value)) {
  8126. warn(`<select multiple v-model="${binding.expression}"> ` +
  8127. `expects an Array value for its binding, but got ${Object.prototype.toString
  8128. .call(value)
  8129. .slice(8, -1)}`, vm);
  8130. return;
  8131. }
  8132. let selected, option;
  8133. for (let i = 0, l = el.options.length; i < l; i++) {
  8134. option = el.options[i];
  8135. if (isMultiple) {
  8136. selected = looseIndexOf(value, getValue(option)) > -1;
  8137. if (option.selected !== selected) {
  8138. option.selected = selected;
  8139. }
  8140. }
  8141. else {
  8142. if (looseEqual(getValue(option), value)) {
  8143. if (el.selectedIndex !== i) {
  8144. el.selectedIndex = i;
  8145. }
  8146. return;
  8147. }
  8148. }
  8149. }
  8150. if (!isMultiple) {
  8151. el.selectedIndex = -1;
  8152. }
  8153. }
  8154. function hasNoMatchingOption(value, options) {
  8155. return options.every(o => !looseEqual(o, value));
  8156. }
  8157. function getValue(option) {
  8158. return '_value' in option ? option._value : option.value;
  8159. }
  8160. function onCompositionStart(e) {
  8161. e.target.composing = true;
  8162. }
  8163. function onCompositionEnd(e) {
  8164. // prevent triggering an input event for no reason
  8165. if (!e.target.composing)
  8166. return;
  8167. e.target.composing = false;
  8168. trigger(e.target, 'input');
  8169. }
  8170. function trigger(el, type) {
  8171. const e = document.createEvent('HTMLEvents');
  8172. e.initEvent(type, true, true);
  8173. el.dispatchEvent(e);
  8174. }
  8175. // recursively search for possible transition defined inside the component root
  8176. function locateNode(vnode) {
  8177. // @ts-expect-error
  8178. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8179. ? locateNode(vnode.componentInstance._vnode)
  8180. : vnode;
  8181. }
  8182. var show = {
  8183. bind(el, { value }, vnode) {
  8184. vnode = locateNode(vnode);
  8185. const transition = vnode.data && vnode.data.transition;
  8186. const originalDisplay = (el.__vOriginalDisplay =
  8187. el.style.display === 'none' ? '' : el.style.display);
  8188. if (value && transition) {
  8189. vnode.data.show = true;
  8190. enter(vnode, () => {
  8191. el.style.display = originalDisplay;
  8192. });
  8193. }
  8194. else {
  8195. el.style.display = value ? originalDisplay : 'none';
  8196. }
  8197. },
  8198. update(el, { value, oldValue }, vnode) {
  8199. /* istanbul ignore if */
  8200. if (!value === !oldValue)
  8201. return;
  8202. vnode = locateNode(vnode);
  8203. const transition = vnode.data && vnode.data.transition;
  8204. if (transition) {
  8205. vnode.data.show = true;
  8206. if (value) {
  8207. enter(vnode, () => {
  8208. el.style.display = el.__vOriginalDisplay;
  8209. });
  8210. }
  8211. else {
  8212. leave(vnode, () => {
  8213. el.style.display = 'none';
  8214. });
  8215. }
  8216. }
  8217. else {
  8218. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8219. }
  8220. },
  8221. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8222. if (!isDestroy) {
  8223. el.style.display = el.__vOriginalDisplay;
  8224. }
  8225. }
  8226. };
  8227. var platformDirectives = {
  8228. model: directive,
  8229. show
  8230. };
  8231. // Provides transition support for a single element/component.
  8232. const transitionProps = {
  8233. name: String,
  8234. appear: Boolean,
  8235. css: Boolean,
  8236. mode: String,
  8237. type: String,
  8238. enterClass: String,
  8239. leaveClass: String,
  8240. enterToClass: String,
  8241. leaveToClass: String,
  8242. enterActiveClass: String,
  8243. leaveActiveClass: String,
  8244. appearClass: String,
  8245. appearActiveClass: String,
  8246. appearToClass: String,
  8247. duration: [Number, String, Object]
  8248. };
  8249. // in case the child is also an abstract component, e.g. <keep-alive>
  8250. // we want to recursively retrieve the real component to be rendered
  8251. function getRealChild(vnode) {
  8252. const compOptions = vnode && vnode.componentOptions;
  8253. if (compOptions && compOptions.Ctor.options.abstract) {
  8254. return getRealChild(getFirstComponentChild(compOptions.children));
  8255. }
  8256. else {
  8257. return vnode;
  8258. }
  8259. }
  8260. function extractTransitionData(comp) {
  8261. const data = {};
  8262. const options = comp.$options;
  8263. // props
  8264. for (const key in options.propsData) {
  8265. data[key] = comp[key];
  8266. }
  8267. // events.
  8268. // extract listeners and pass them directly to the transition methods
  8269. const listeners = options._parentListeners;
  8270. for (const key in listeners) {
  8271. data[camelize(key)] = listeners[key];
  8272. }
  8273. return data;
  8274. }
  8275. function placeholder(h, rawChild) {
  8276. // @ts-expect-error
  8277. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8278. return h('keep-alive', {
  8279. props: rawChild.componentOptions.propsData
  8280. });
  8281. }
  8282. }
  8283. function hasParentTransition(vnode) {
  8284. while ((vnode = vnode.parent)) {
  8285. if (vnode.data.transition) {
  8286. return true;
  8287. }
  8288. }
  8289. }
  8290. function isSameChild(child, oldChild) {
  8291. return oldChild.key === child.key && oldChild.tag === child.tag;
  8292. }
  8293. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8294. const isVShowDirective = d => d.name === 'show';
  8295. var Transition = {
  8296. name: 'transition',
  8297. props: transitionProps,
  8298. abstract: true,
  8299. render(h) {
  8300. let children = this.$slots.default;
  8301. if (!children) {
  8302. return;
  8303. }
  8304. // filter out text nodes (possible whitespaces)
  8305. children = children.filter(isNotTextNode);
  8306. /* istanbul ignore if */
  8307. if (!children.length) {
  8308. return;
  8309. }
  8310. // warn multiple elements
  8311. if (children.length > 1) {
  8312. warn('<transition> can only be used on a single element. Use ' +
  8313. '<transition-group> for lists.', this.$parent);
  8314. }
  8315. const mode = this.mode;
  8316. // warn invalid mode
  8317. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8318. warn('invalid <transition> mode: ' + mode, this.$parent);
  8319. }
  8320. const rawChild = children[0];
  8321. // if this is a component root node and the component's
  8322. // parent container node also has transition, skip.
  8323. if (hasParentTransition(this.$vnode)) {
  8324. return rawChild;
  8325. }
  8326. // apply transition data to child
  8327. // use getRealChild() to ignore abstract components e.g. keep-alive
  8328. const child = getRealChild(rawChild);
  8329. /* istanbul ignore if */
  8330. if (!child) {
  8331. return rawChild;
  8332. }
  8333. if (this._leaving) {
  8334. return placeholder(h, rawChild);
  8335. }
  8336. // ensure a key that is unique to the vnode type and to this transition
  8337. // component instance. This key will be used to remove pending leaving nodes
  8338. // during entering.
  8339. const id = `__transition-${this._uid}-`;
  8340. child.key =
  8341. child.key == null
  8342. ? child.isComment
  8343. ? id + 'comment'
  8344. : id + child.tag
  8345. : isPrimitive(child.key)
  8346. ? String(child.key).indexOf(id) === 0
  8347. ? child.key
  8348. : id + child.key
  8349. : child.key;
  8350. const data = ((child.data || (child.data = {})).transition =
  8351. extractTransitionData(this));
  8352. const oldRawChild = this._vnode;
  8353. const oldChild = getRealChild(oldRawChild);
  8354. // mark v-show
  8355. // so that the transition module can hand over the control to the directive
  8356. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8357. child.data.show = true;
  8358. }
  8359. if (oldChild &&
  8360. oldChild.data &&
  8361. !isSameChild(child, oldChild) &&
  8362. !isAsyncPlaceholder(oldChild) &&
  8363. // #6687 component root is a comment node
  8364. !(oldChild.componentInstance &&
  8365. oldChild.componentInstance._vnode.isComment)) {
  8366. // replace old child transition data with fresh one
  8367. // important for dynamic transitions!
  8368. const oldData = (oldChild.data.transition = extend({}, data));
  8369. // handle transition mode
  8370. if (mode === 'out-in') {
  8371. // return placeholder node and queue update when leave finishes
  8372. this._leaving = true;
  8373. mergeVNodeHook(oldData, 'afterLeave', () => {
  8374. this._leaving = false;
  8375. this.$forceUpdate();
  8376. });
  8377. return placeholder(h, rawChild);
  8378. }
  8379. else if (mode === 'in-out') {
  8380. if (isAsyncPlaceholder(child)) {
  8381. return oldRawChild;
  8382. }
  8383. let delayedLeave;
  8384. const performLeave = () => {
  8385. delayedLeave();
  8386. };
  8387. mergeVNodeHook(data, 'afterEnter', performLeave);
  8388. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8389. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8390. delayedLeave = leave;
  8391. });
  8392. }
  8393. }
  8394. return rawChild;
  8395. }
  8396. };
  8397. // Provides transition support for list items.
  8398. const props = extend({
  8399. tag: String,
  8400. moveClass: String
  8401. }, transitionProps);
  8402. delete props.mode;
  8403. var TransitionGroup = {
  8404. props,
  8405. beforeMount() {
  8406. const update = this._update;
  8407. this._update = (vnode, hydrating) => {
  8408. const restoreActiveInstance = setActiveInstance(this);
  8409. // force removing pass
  8410. this.__patch__(this._vnode, this.kept, false, // hydrating
  8411. true // removeOnly (!important, avoids unnecessary moves)
  8412. );
  8413. this._vnode = this.kept;
  8414. restoreActiveInstance();
  8415. update.call(this, vnode, hydrating);
  8416. };
  8417. },
  8418. render(h) {
  8419. const tag = this.tag || this.$vnode.data.tag || 'span';
  8420. const map = Object.create(null);
  8421. const prevChildren = (this.prevChildren = this.children);
  8422. const rawChildren = this.$slots.default || [];
  8423. const children = (this.children = []);
  8424. const transitionData = extractTransitionData(this);
  8425. for (let i = 0; i < rawChildren.length; i++) {
  8426. const c = rawChildren[i];
  8427. if (c.tag) {
  8428. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8429. children.push(c);
  8430. map[c.key] = c;
  8431. (c.data || (c.data = {})).transition = transitionData;
  8432. }
  8433. else {
  8434. const opts = c.componentOptions;
  8435. const name = opts
  8436. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8437. : c.tag;
  8438. warn(`<transition-group> children must be keyed: <${name}>`);
  8439. }
  8440. }
  8441. }
  8442. if (prevChildren) {
  8443. const kept = [];
  8444. const removed = [];
  8445. for (let i = 0; i < prevChildren.length; i++) {
  8446. const c = prevChildren[i];
  8447. c.data.transition = transitionData;
  8448. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8449. c.data.pos = c.elm.getBoundingClientRect();
  8450. if (map[c.key]) {
  8451. kept.push(c);
  8452. }
  8453. else {
  8454. removed.push(c);
  8455. }
  8456. }
  8457. this.kept = h(tag, null, kept);
  8458. this.removed = removed;
  8459. }
  8460. return h(tag, null, children);
  8461. },
  8462. updated() {
  8463. const children = this.prevChildren;
  8464. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8465. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8466. return;
  8467. }
  8468. // we divide the work into three loops to avoid mixing DOM reads and writes
  8469. // in each iteration - which helps prevent layout thrashing.
  8470. children.forEach(callPendingCbs);
  8471. children.forEach(recordPosition);
  8472. children.forEach(applyTranslation);
  8473. // force reflow to put everything in position
  8474. // assign to this to avoid being removed in tree-shaking
  8475. // $flow-disable-line
  8476. this._reflow = document.body.offsetHeight;
  8477. children.forEach((c) => {
  8478. if (c.data.moved) {
  8479. const el = c.elm;
  8480. const s = el.style;
  8481. addTransitionClass(el, moveClass);
  8482. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8483. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8484. if (e && e.target !== el) {
  8485. return;
  8486. }
  8487. if (!e || /transform$/.test(e.propertyName)) {
  8488. el.removeEventListener(transitionEndEvent, cb);
  8489. el._moveCb = null;
  8490. removeTransitionClass(el, moveClass);
  8491. }
  8492. }));
  8493. }
  8494. });
  8495. },
  8496. methods: {
  8497. hasMove(el, moveClass) {
  8498. /* istanbul ignore if */
  8499. if (!hasTransition) {
  8500. return false;
  8501. }
  8502. /* istanbul ignore if */
  8503. if (this._hasMove) {
  8504. return this._hasMove;
  8505. }
  8506. // Detect whether an element with the move class applied has
  8507. // CSS transitions. Since the element may be inside an entering
  8508. // transition at this very moment, we make a clone of it and remove
  8509. // all other transition classes applied to ensure only the move class
  8510. // is applied.
  8511. const clone = el.cloneNode();
  8512. if (el._transitionClasses) {
  8513. el._transitionClasses.forEach((cls) => {
  8514. removeClass(clone, cls);
  8515. });
  8516. }
  8517. addClass(clone, moveClass);
  8518. clone.style.display = 'none';
  8519. this.$el.appendChild(clone);
  8520. const info = getTransitionInfo(clone);
  8521. this.$el.removeChild(clone);
  8522. return (this._hasMove = info.hasTransform);
  8523. }
  8524. }
  8525. };
  8526. function callPendingCbs(c) {
  8527. /* istanbul ignore if */
  8528. if (c.elm._moveCb) {
  8529. c.elm._moveCb();
  8530. }
  8531. /* istanbul ignore if */
  8532. if (c.elm._enterCb) {
  8533. c.elm._enterCb();
  8534. }
  8535. }
  8536. function recordPosition(c) {
  8537. c.data.newPos = c.elm.getBoundingClientRect();
  8538. }
  8539. function applyTranslation(c) {
  8540. const oldPos = c.data.pos;
  8541. const newPos = c.data.newPos;
  8542. const dx = oldPos.left - newPos.left;
  8543. const dy = oldPos.top - newPos.top;
  8544. if (dx || dy) {
  8545. c.data.moved = true;
  8546. const s = c.elm.style;
  8547. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8548. s.transitionDuration = '0s';
  8549. }
  8550. }
  8551. var platformComponents = {
  8552. Transition,
  8553. TransitionGroup
  8554. };
  8555. // install platform specific utils
  8556. Vue.config.mustUseProp = mustUseProp;
  8557. Vue.config.isReservedTag = isReservedTag;
  8558. Vue.config.isReservedAttr = isReservedAttr;
  8559. Vue.config.getTagNamespace = getTagNamespace;
  8560. Vue.config.isUnknownElement = isUnknownElement;
  8561. // install platform runtime directives & components
  8562. extend(Vue.options.directives, platformDirectives);
  8563. extend(Vue.options.components, platformComponents);
  8564. // install platform patch function
  8565. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8566. // public mount method
  8567. Vue.prototype.$mount = function (el, hydrating) {
  8568. el = el && inBrowser ? query(el) : undefined;
  8569. return mountComponent(this, el, hydrating);
  8570. };
  8571. // devtools global hook
  8572. /* istanbul ignore next */
  8573. if (inBrowser) {
  8574. setTimeout(() => {
  8575. if (config.devtools) {
  8576. if (devtools) {
  8577. devtools.emit('init', Vue);
  8578. }
  8579. else {
  8580. // @ts-expect-error
  8581. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  8582. 'https://github.com/vuejs/vue-devtools');
  8583. }
  8584. }
  8585. if (config.productionTip !== false &&
  8586. typeof console !== 'undefined') {
  8587. // @ts-expect-error
  8588. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  8589. `Make sure to turn on production mode when deploying for production.\n` +
  8590. `See more tips at https://vuejs.org/guide/deployment.html`);
  8591. }
  8592. }, 0);
  8593. }
  8594. extend(Vue, vca);
  8595. module.exports = Vue;