vue.runtime.common.dev.js 283 KB

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