vue.esm.browser.js 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059
  1. /*!
  2. * Vue.js v2.6.14
  3. * (c) 2014-2021 Evan You
  4. * Released under the MIT License.
  5. */
  6. /* */
  7. const emptyObject = Object.freeze({});
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef (v) {
  11. return v === undefined || v === null
  12. }
  13. function isDef (v) {
  14. return v !== undefined && v !== null
  15. }
  16. function isTrue (v) {
  17. return v === true
  18. }
  19. function isFalse (v) {
  20. return v === false
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive (value) {
  26. return (
  27. typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean'
  32. )
  33. }
  34. /**
  35. * Quick object check - this is primarily used to tell
  36. * Objects from primitive values when we know the value
  37. * is a JSON-compliant type.
  38. */
  39. function isObject (obj) {
  40. return obj !== null && typeof obj === 'object'
  41. }
  42. /**
  43. * Get the raw type string of a value, e.g., [object Object].
  44. */
  45. const _toString = Object.prototype.toString;
  46. function toRawType (value) {
  47. return _toString.call(value).slice(8, -1)
  48. }
  49. /**
  50. * Strict object type check. Only returns true
  51. * for plain JavaScript objects.
  52. */
  53. function isPlainObject (obj) {
  54. return _toString.call(obj) === '[object Object]'
  55. }
  56. function isRegExp (v) {
  57. return _toString.call(v) === '[object RegExp]'
  58. }
  59. /**
  60. * Check if val is a valid array index.
  61. */
  62. function isValidArrayIndex (val) {
  63. const n = parseFloat(String(val));
  64. return n >= 0 && Math.floor(n) === n && isFinite(val)
  65. }
  66. function isPromise (val) {
  67. return (
  68. isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function'
  71. )
  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 (
  96. str,
  97. expectsLowerCase
  98. ) {
  99. const map = Object.create(null);
  100. const list = str.split(',');
  101. for (let i = 0; i < list.length; i++) {
  102. map[list[i]] = true;
  103. }
  104. return expectsLowerCase
  105. ? val => map[val.toLowerCase()]
  106. : val => map[val]
  107. }
  108. /**
  109. * Check if a tag is a built-in tag.
  110. */
  111. const isBuiltInTag = makeMap('slot,component', true);
  112. /**
  113. * Check if an attribute is a reserved attribute.
  114. */
  115. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  116. /**
  117. * Remove an item from an array.
  118. */
  119. function remove (arr, item) {
  120. if (arr.length) {
  121. const index = arr.indexOf(item);
  122. if (index > -1) {
  123. return arr.splice(index, 1)
  124. }
  125. }
  126. }
  127. /**
  128. * Check whether an object has the property.
  129. */
  130. const hasOwnProperty = Object.prototype.hasOwnProperty;
  131. function hasOwn (obj, key) {
  132. return hasOwnProperty.call(obj, key)
  133. }
  134. /**
  135. * Create a cached version of a pure function.
  136. */
  137. function cached (fn) {
  138. const cache = Object.create(null);
  139. return (function cachedFn (str) {
  140. const hit = cache[str];
  141. return hit || (cache[str] = fn(str))
  142. })
  143. }
  144. /**
  145. * Camelize a hyphen-delimited string.
  146. */
  147. const camelizeRE = /-(\w)/g;
  148. const camelize = cached((str) => {
  149. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
  150. });
  151. /**
  152. * Capitalize a string.
  153. */
  154. const capitalize = cached((str) => {
  155. return str.charAt(0).toUpperCase() + str.slice(1)
  156. });
  157. /**
  158. * Hyphenate a camelCase string.
  159. */
  160. const hyphenateRE = /\B([A-Z])/g;
  161. const hyphenate = cached((str) => {
  162. return str.replace(hyphenateRE, '-$1').toLowerCase()
  163. });
  164. /**
  165. * Simple bind polyfill for environments that do not support it,
  166. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  167. * since native bind is now performant enough in most browsers.
  168. * But removing it would mean breaking code that was able to run in
  169. * PhantomJS 1.x, so this must be kept for backward compatibility.
  170. */
  171. /* istanbul ignore next */
  172. function polyfillBind (fn, ctx) {
  173. function boundFn (a) {
  174. const l = arguments.length;
  175. return l
  176. ? l > 1
  177. ? fn.apply(ctx, arguments)
  178. : fn.call(ctx, a)
  179. : fn.call(ctx)
  180. }
  181. boundFn._length = fn.length;
  182. return boundFn
  183. }
  184. function nativeBind (fn, ctx) {
  185. return fn.bind(ctx)
  186. }
  187. const bind = Function.prototype.bind
  188. ? nativeBind
  189. : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray (list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend (to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject (arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop (a, b, c) {}
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys (modules) {
  243. return modules.reduce((keys, m) => {
  244. return keys.concat(m.staticKeys || [])
  245. }, []).join(',')
  246. }
  247. /**
  248. * Check if two values are loosely equal - that is,
  249. * if they are plain objects, do they have the same shape?
  250. */
  251. function looseEqual (a, b) {
  252. if (a === b) return true
  253. const isObjectA = isObject(a);
  254. const isObjectB = isObject(b);
  255. if (isObjectA && isObjectB) {
  256. try {
  257. const isArrayA = Array.isArray(a);
  258. const isArrayB = Array.isArray(b);
  259. if (isArrayA && isArrayB) {
  260. return a.length === b.length && a.every((e, i) => {
  261. return looseEqual(e, b[i])
  262. })
  263. } else if (a instanceof Date && b instanceof Date) {
  264. return a.getTime() === b.getTime()
  265. } else if (!isArrayA && !isArrayB) {
  266. const keysA = Object.keys(a);
  267. const keysB = Object.keys(b);
  268. return keysA.length === keysB.length && keysA.every(key => {
  269. return looseEqual(a[key], b[key])
  270. })
  271. } else {
  272. /* istanbul ignore next */
  273. return false
  274. }
  275. } catch (e) {
  276. /* istanbul ignore next */
  277. return false
  278. }
  279. } else if (!isObjectA && !isObjectB) {
  280. return String(a) === String(b)
  281. } else {
  282. return false
  283. }
  284. }
  285. /**
  286. * Return the first index at which a loosely equal value can be
  287. * found in the array (if value is a plain object, the array must
  288. * contain an object of the same shape), or -1 if it is not present.
  289. */
  290. function looseIndexOf (arr, val) {
  291. for (let i = 0; i < arr.length; i++) {
  292. if (looseEqual(arr[i], val)) return i
  293. }
  294. return -1
  295. }
  296. /**
  297. * Ensure a function is called only once.
  298. */
  299. function once (fn) {
  300. let called = false;
  301. return function () {
  302. if (!called) {
  303. called = true;
  304. fn.apply(this, arguments);
  305. }
  306. }
  307. }
  308. const SSR_ATTR = 'data-server-rendered';
  309. const ASSET_TYPES = [
  310. 'component',
  311. 'directive',
  312. 'filter'
  313. ];
  314. const LIFECYCLE_HOOKS = [
  315. 'beforeCreate',
  316. 'created',
  317. 'beforeMount',
  318. 'mounted',
  319. 'beforeUpdate',
  320. 'updated',
  321. 'beforeDestroy',
  322. 'destroyed',
  323. 'activated',
  324. 'deactivated',
  325. 'errorCaptured',
  326. 'serverPrefetch'
  327. ];
  328. /* */
  329. var config = ({
  330. /**
  331. * Option merge strategies (used in core/util/options)
  332. */
  333. // $flow-disable-line
  334. optionMergeStrategies: Object.create(null),
  335. /**
  336. * Whether to suppress warnings.
  337. */
  338. silent: false,
  339. /**
  340. * Show production mode tip message on boot?
  341. */
  342. productionTip: "development" !== 'production',
  343. /**
  344. * Whether to enable devtools
  345. */
  346. devtools: "development" !== 'production',
  347. /**
  348. * Whether to record perf
  349. */
  350. performance: false,
  351. /**
  352. * Error handler for watcher errors
  353. */
  354. errorHandler: null,
  355. /**
  356. * Warn handler for watcher warns
  357. */
  358. warnHandler: null,
  359. /**
  360. * Ignore certain custom elements
  361. */
  362. ignoredElements: [],
  363. /**
  364. * Custom user key aliases for v-on
  365. */
  366. // $flow-disable-line
  367. keyCodes: Object.create(null),
  368. /**
  369. * Check if a tag is reserved so that it cannot be registered as a
  370. * component. This is platform-dependent and may be overwritten.
  371. */
  372. isReservedTag: no,
  373. /**
  374. * Check if an attribute is reserved so that it cannot be used as a component
  375. * prop. This is platform-dependent and may be overwritten.
  376. */
  377. isReservedAttr: no,
  378. /**
  379. * Check if a tag is an unknown element.
  380. * Platform-dependent.
  381. */
  382. isUnknownElement: no,
  383. /**
  384. * Get the namespace of an element
  385. */
  386. getTagNamespace: noop,
  387. /**
  388. * Parse the real tag name for the specific platform.
  389. */
  390. parsePlatformTagName: identity,
  391. /**
  392. * Check if an attribute must be bound using property, e.g. value
  393. * Platform-dependent.
  394. */
  395. mustUseProp: no,
  396. /**
  397. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  398. * This will significantly reduce performance if set to false.
  399. */
  400. async: true,
  401. /**
  402. * Exposed for legacy reasons
  403. */
  404. _lifecycleHooks: LIFECYCLE_HOOKS
  405. });
  406. /* */
  407. /**
  408. * unicode letters used for parsing html tags, component names and property paths.
  409. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  410. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  411. */
  412. 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/;
  413. /**
  414. * Check if a string starts with $ or _
  415. */
  416. function isReserved (str) {
  417. const c = (str + '').charCodeAt(0);
  418. return c === 0x24 || c === 0x5F
  419. }
  420. /**
  421. * Define a property.
  422. */
  423. function def (obj, key, val, enumerable) {
  424. Object.defineProperty(obj, key, {
  425. value: val,
  426. enumerable: !!enumerable,
  427. writable: true,
  428. configurable: true
  429. });
  430. }
  431. /**
  432. * Parse simple path.
  433. */
  434. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  435. function parsePath (path) {
  436. if (bailRE.test(path)) {
  437. return
  438. }
  439. const segments = path.split('.');
  440. return function (obj) {
  441. for (let i = 0; i < segments.length; i++) {
  442. if (!obj) return
  443. obj = obj[segments[i]];
  444. }
  445. return obj
  446. }
  447. }
  448. /* */
  449. // can we use __proto__?
  450. const hasProto = '__proto__' in {};
  451. // Browser environment sniffing
  452. const inBrowser = typeof window !== 'undefined';
  453. const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  454. const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  455. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  456. const isIE = UA && /msie|trident/.test(UA);
  457. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  458. const isEdge = UA && UA.indexOf('edge/') > 0;
  459. const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  460. const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  461. const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  462. const isPhantomJS = UA && /phantomjs/.test(UA);
  463. const isFF = UA && UA.match(/firefox\/(\d+)/);
  464. // Firefox has a "watch" function on Object.prototype...
  465. const nativeWatch = ({}).watch;
  466. let supportsPassive = false;
  467. if (inBrowser) {
  468. try {
  469. const opts = {};
  470. Object.defineProperty(opts, 'passive', ({
  471. get () {
  472. /* istanbul ignore next */
  473. supportsPassive = true;
  474. }
  475. })); // https://github.com/facebook/flow/issues/285
  476. window.addEventListener('test-passive', null, opts);
  477. } catch (e) {}
  478. }
  479. // this needs to be lazy-evaled because vue may be required before
  480. // vue-server-renderer can set VUE_ENV
  481. let _isServer;
  482. const isServerRendering = () => {
  483. if (_isServer === undefined) {
  484. /* istanbul ignore if */
  485. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  486. // detect presence of vue-server-renderer and avoid
  487. // Webpack shimming the process
  488. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  489. } else {
  490. _isServer = false;
  491. }
  492. }
  493. return _isServer
  494. };
  495. // detect devtools
  496. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  497. /* istanbul ignore next */
  498. function isNative (Ctor) {
  499. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  500. }
  501. const hasSymbol =
  502. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  503. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  504. let _Set;
  505. /* istanbul ignore if */ // $flow-disable-line
  506. if (typeof Set !== 'undefined' && isNative(Set)) {
  507. // use native Set when available.
  508. _Set = Set;
  509. } else {
  510. // a non-standard Set polyfill that only works with primitive keys.
  511. _Set = class Set {
  512. constructor () {
  513. this.set = Object.create(null);
  514. }
  515. has (key) {
  516. return this.set[key] === true
  517. }
  518. add (key) {
  519. this.set[key] = true;
  520. }
  521. clear () {
  522. this.set = Object.create(null);
  523. }
  524. };
  525. }
  526. /* */
  527. let warn = noop;
  528. let tip = noop;
  529. let generateComponentTrace = (noop); // work around flow check
  530. let formatComponentName = (noop);
  531. {
  532. const hasConsole = typeof console !== 'undefined';
  533. const classifyRE = /(?:^|[-_])(\w)/g;
  534. const classify = str => str
  535. .replace(classifyRE, c => c.toUpperCase())
  536. .replace(/[-_]/g, '');
  537. warn = (msg, vm) => {
  538. const trace = vm ? generateComponentTrace(vm) : '';
  539. if (config.warnHandler) {
  540. config.warnHandler.call(null, msg, vm, trace);
  541. } else if (hasConsole && (!config.silent)) {
  542. console.error(`[Vue warn]: ${msg}${trace}`);
  543. }
  544. };
  545. tip = (msg, vm) => {
  546. if (hasConsole && (!config.silent)) {
  547. console.warn(`[Vue tip]: ${msg}` + (
  548. vm ? generateComponentTrace(vm) : ''
  549. ));
  550. }
  551. };
  552. formatComponentName = (vm, includeFile) => {
  553. if (vm.$root === vm) {
  554. return '<Root>'
  555. }
  556. const options = typeof vm === 'function' && vm.cid != null
  557. ? vm.options
  558. : vm._isVue
  559. ? vm.$options || vm.constructor.options
  560. : vm;
  561. let name = options.name || options._componentTag;
  562. const file = options.__file;
  563. if (!name && file) {
  564. const match = file.match(/([^/\\]+)\.vue$/);
  565. name = match && match[1];
  566. }
  567. return (
  568. (name ? `<${classify(name)}>` : `<Anonymous>`) +
  569. (file && includeFile !== false ? ` at ${file}` : '')
  570. )
  571. };
  572. const repeat = (str, n) => {
  573. let res = '';
  574. while (n) {
  575. if (n % 2 === 1) res += str;
  576. if (n > 1) str += str;
  577. n >>= 1;
  578. }
  579. return res
  580. };
  581. generateComponentTrace = vm => {
  582. if (vm._isVue && vm.$parent) {
  583. const tree = [];
  584. let currentRecursiveSequence = 0;
  585. while (vm) {
  586. if (tree.length > 0) {
  587. const last = tree[tree.length - 1];
  588. if (last.constructor === vm.constructor) {
  589. currentRecursiveSequence++;
  590. vm = vm.$parent;
  591. continue
  592. } else if (currentRecursiveSequence > 0) {
  593. tree[tree.length - 1] = [last, currentRecursiveSequence];
  594. currentRecursiveSequence = 0;
  595. }
  596. }
  597. tree.push(vm);
  598. vm = vm.$parent;
  599. }
  600. return '\n\nfound in\n\n' + tree
  601. .map((vm, i) => `${
  602. i === 0 ? '---> ' : repeat(' ', 5 + i * 2)
  603. }${
  604. Array.isArray(vm)
  605. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  606. : formatComponentName(vm)
  607. }`)
  608. .join('\n')
  609. } else {
  610. return `\n\n(found in ${formatComponentName(vm)})`
  611. }
  612. };
  613. }
  614. /* */
  615. let uid = 0;
  616. /**
  617. * A dep is an observable that can have multiple
  618. * directives subscribing to it.
  619. */
  620. class Dep {
  621. constructor () {
  622. this.id = uid++;
  623. this.subs = [];
  624. }
  625. addSub (sub) {
  626. this.subs.push(sub);
  627. }
  628. removeSub (sub) {
  629. remove(this.subs, sub);
  630. }
  631. depend () {
  632. if (Dep.target) {
  633. Dep.target.addDep(this);
  634. }
  635. }
  636. notify () {
  637. // stabilize the subscriber list first
  638. const subs = this.subs.slice();
  639. if (!config.async) {
  640. // subs aren't sorted in scheduler if not running async
  641. // we need to sort them now to make sure they fire in correct
  642. // order
  643. subs.sort((a, b) => a.id - b.id);
  644. }
  645. for (let i = 0, l = subs.length; i < l; i++) {
  646. subs[i].update();
  647. }
  648. }
  649. }
  650. // The current target watcher being evaluated.
  651. // This is globally unique because only one watcher
  652. // can be evaluated at a time.
  653. Dep.target = null;
  654. const targetStack = [];
  655. function pushTarget (target) {
  656. targetStack.push(target);
  657. Dep.target = target;
  658. }
  659. function popTarget () {
  660. targetStack.pop();
  661. Dep.target = targetStack[targetStack.length - 1];
  662. }
  663. /* */
  664. class VNode {
  665. // rendered in this component's scope
  666. // component instance
  667. // component placeholder node
  668. // strictly internal
  669. // contains raw HTML? (server only)
  670. // hoisted static node
  671. // necessary for enter transition check
  672. // empty comment placeholder?
  673. // is a cloned node?
  674. // is a v-once node?
  675. // async component factory function
  676. // real context vm for functional nodes
  677. // for SSR caching
  678. // used to store functional render context for devtools
  679. // functional scope id support
  680. constructor (
  681. tag,
  682. data,
  683. children,
  684. text,
  685. elm,
  686. context,
  687. componentOptions,
  688. asyncFactory
  689. ) {
  690. this.tag = tag;
  691. this.data = data;
  692. this.children = children;
  693. this.text = text;
  694. this.elm = elm;
  695. this.ns = undefined;
  696. this.context = context;
  697. this.fnContext = undefined;
  698. this.fnOptions = undefined;
  699. this.fnScopeId = undefined;
  700. this.key = data && data.key;
  701. this.componentOptions = componentOptions;
  702. this.componentInstance = undefined;
  703. this.parent = undefined;
  704. this.raw = false;
  705. this.isStatic = false;
  706. this.isRootInsert = true;
  707. this.isComment = false;
  708. this.isCloned = false;
  709. this.isOnce = false;
  710. this.asyncFactory = asyncFactory;
  711. this.asyncMeta = undefined;
  712. this.isAsyncPlaceholder = false;
  713. }
  714. // DEPRECATED: alias for componentInstance for backwards compat.
  715. /* istanbul ignore next */
  716. get child () {
  717. return this.componentInstance
  718. }
  719. }
  720. const createEmptyVNode = (text = '') => {
  721. const node = new VNode();
  722. node.text = text;
  723. node.isComment = true;
  724. return node
  725. };
  726. function createTextVNode (val) {
  727. return new VNode(undefined, undefined, undefined, String(val))
  728. }
  729. // optimized shallow clone
  730. // used for static nodes and slot nodes because they may be reused across
  731. // multiple renders, cloning them avoids errors when DOM manipulations rely
  732. // on their elm reference.
  733. function cloneVNode (vnode) {
  734. const cloned = new VNode(
  735. vnode.tag,
  736. vnode.data,
  737. // #7975
  738. // clone children array to avoid mutating original in case of cloning
  739. // a child.
  740. vnode.children && vnode.children.slice(),
  741. vnode.text,
  742. vnode.elm,
  743. vnode.context,
  744. vnode.componentOptions,
  745. vnode.asyncFactory
  746. );
  747. cloned.ns = vnode.ns;
  748. cloned.isStatic = vnode.isStatic;
  749. cloned.key = vnode.key;
  750. cloned.isComment = vnode.isComment;
  751. cloned.fnContext = vnode.fnContext;
  752. cloned.fnOptions = vnode.fnOptions;
  753. cloned.fnScopeId = vnode.fnScopeId;
  754. cloned.asyncMeta = vnode.asyncMeta;
  755. cloned.isCloned = true;
  756. return cloned
  757. }
  758. /*
  759. * not type checking this file because flow doesn't play well with
  760. * dynamically accessing methods on Array prototype
  761. */
  762. const arrayProto = Array.prototype;
  763. const arrayMethods = Object.create(arrayProto);
  764. const methodsToPatch = [
  765. 'push',
  766. 'pop',
  767. 'shift',
  768. 'unshift',
  769. 'splice',
  770. 'sort',
  771. 'reverse'
  772. ];
  773. /**
  774. * Intercept mutating methods and emit events
  775. */
  776. methodsToPatch.forEach(function (method) {
  777. // cache original method
  778. const original = arrayProto[method];
  779. def(arrayMethods, method, function mutator (...args) {
  780. const result = original.apply(this, args);
  781. const ob = this.__ob__;
  782. let inserted;
  783. switch (method) {
  784. case 'push':
  785. case 'unshift':
  786. inserted = args;
  787. break
  788. case 'splice':
  789. inserted = args.slice(2);
  790. break
  791. }
  792. if (inserted) ob.observeArray(inserted);
  793. // notify change
  794. ob.dep.notify();
  795. return result
  796. });
  797. });
  798. /* */
  799. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  800. /**
  801. * In some cases we may want to disable observation inside a component's
  802. * update computation.
  803. */
  804. let shouldObserve = true;
  805. function toggleObserving (value) {
  806. shouldObserve = value;
  807. }
  808. /**
  809. * Observer class that is attached to each observed
  810. * object. Once attached, the observer converts the target
  811. * object's property keys into getter/setters that
  812. * collect dependencies and dispatch updates.
  813. */
  814. class Observer {
  815. // number of vms that have this object as root $data
  816. constructor (value) {
  817. this.value = value;
  818. this.dep = new Dep();
  819. this.vmCount = 0;
  820. def(value, '__ob__', this);
  821. if (Array.isArray(value)) {
  822. if (hasProto) {
  823. protoAugment(value, arrayMethods);
  824. } else {
  825. copyAugment(value, arrayMethods, arrayKeys);
  826. }
  827. this.observeArray(value);
  828. } else {
  829. this.walk(value);
  830. }
  831. }
  832. /**
  833. * Walk through all properties and convert them into
  834. * getter/setters. This method should only be called when
  835. * value type is Object.
  836. */
  837. walk (obj) {
  838. const keys = Object.keys(obj);
  839. for (let i = 0; i < keys.length; i++) {
  840. defineReactive$$1(obj, keys[i]);
  841. }
  842. }
  843. /**
  844. * Observe a list of Array items.
  845. */
  846. observeArray (items) {
  847. for (let i = 0, l = items.length; i < l; i++) {
  848. observe(items[i]);
  849. }
  850. }
  851. }
  852. // helpers
  853. /**
  854. * Augment a target Object or Array by intercepting
  855. * the prototype chain using __proto__
  856. */
  857. function protoAugment (target, src) {
  858. /* eslint-disable no-proto */
  859. target.__proto__ = src;
  860. /* eslint-enable no-proto */
  861. }
  862. /**
  863. * Augment a target Object or Array by defining
  864. * hidden properties.
  865. */
  866. /* istanbul ignore next */
  867. function copyAugment (target, src, keys) {
  868. for (let i = 0, l = keys.length; i < l; i++) {
  869. const key = keys[i];
  870. def(target, key, src[key]);
  871. }
  872. }
  873. /**
  874. * Attempt to create an observer instance for a value,
  875. * returns the new observer if successfully observed,
  876. * or the existing observer if the value already has one.
  877. */
  878. function observe (value, asRootData) {
  879. if (!isObject(value) || value instanceof VNode) {
  880. return
  881. }
  882. let ob;
  883. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  884. ob = value.__ob__;
  885. } else if (
  886. shouldObserve &&
  887. !isServerRendering() &&
  888. (Array.isArray(value) || isPlainObject(value)) &&
  889. Object.isExtensible(value) &&
  890. !value._isVue
  891. ) {
  892. ob = new Observer(value);
  893. }
  894. if (asRootData && ob) {
  895. ob.vmCount++;
  896. }
  897. return ob
  898. }
  899. /**
  900. * Define a reactive property on an Object.
  901. */
  902. function defineReactive$$1 (
  903. obj,
  904. key,
  905. val,
  906. customSetter,
  907. shallow
  908. ) {
  909. const dep = new Dep();
  910. const property = Object.getOwnPropertyDescriptor(obj, key);
  911. if (property && property.configurable === false) {
  912. return
  913. }
  914. // cater for pre-defined getter/setters
  915. const getter = property && property.get;
  916. const setter = property && property.set;
  917. if ((!getter || setter) && arguments.length === 2) {
  918. val = obj[key];
  919. }
  920. let childOb = !shallow && observe(val);
  921. Object.defineProperty(obj, key, {
  922. enumerable: true,
  923. configurable: true,
  924. get: function reactiveGetter () {
  925. const value = getter ? getter.call(obj) : val;
  926. if (Dep.target) {
  927. dep.depend();
  928. if (childOb) {
  929. childOb.dep.depend();
  930. if (Array.isArray(value)) {
  931. dependArray(value);
  932. }
  933. }
  934. }
  935. return value
  936. },
  937. set: function reactiveSetter (newVal) {
  938. const value = getter ? getter.call(obj) : val;
  939. /* eslint-disable no-self-compare */
  940. if (newVal === value || (newVal !== newVal && value !== value)) {
  941. return
  942. }
  943. /* eslint-enable no-self-compare */
  944. if (customSetter) {
  945. customSetter();
  946. }
  947. // #7981: for accessor properties without setter
  948. if (getter && !setter) return
  949. if (setter) {
  950. setter.call(obj, newVal);
  951. } else {
  952. val = newVal;
  953. }
  954. childOb = !shallow && observe(newVal);
  955. dep.notify();
  956. }
  957. });
  958. }
  959. /**
  960. * Set a property on an object. Adds the new property and
  961. * triggers change notification if the property doesn't
  962. * already exist.
  963. */
  964. function set (target, key, val) {
  965. if (isUndef(target) || isPrimitive(target)
  966. ) {
  967. warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target)}`);
  968. }
  969. if (Array.isArray(target) && isValidArrayIndex(key)) {
  970. target.length = Math.max(target.length, key);
  971. target.splice(key, 1, val);
  972. return val
  973. }
  974. if (key in target && !(key in Object.prototype)) {
  975. target[key] = val;
  976. return val
  977. }
  978. const ob = (target).__ob__;
  979. if (target._isVue || (ob && ob.vmCount)) {
  980. warn(
  981. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  982. 'at runtime - declare it upfront in the data option.'
  983. );
  984. return val
  985. }
  986. if (!ob) {
  987. target[key] = val;
  988. return val
  989. }
  990. defineReactive$$1(ob.value, key, val);
  991. ob.dep.notify();
  992. return val
  993. }
  994. /**
  995. * Delete a property and trigger change if necessary.
  996. */
  997. function del (target, key) {
  998. if (isUndef(target) || isPrimitive(target)
  999. ) {
  1000. warn(`Cannot delete reactive property on undefined, null, or primitive value: ${(target)}`);
  1001. }
  1002. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1003. target.splice(key, 1);
  1004. return
  1005. }
  1006. const ob = (target).__ob__;
  1007. if (target._isVue || (ob && ob.vmCount)) {
  1008. warn(
  1009. 'Avoid deleting properties on a Vue instance or its root $data ' +
  1010. '- just set it to null.'
  1011. );
  1012. return
  1013. }
  1014. if (!hasOwn(target, key)) {
  1015. return
  1016. }
  1017. delete target[key];
  1018. if (!ob) {
  1019. return
  1020. }
  1021. ob.dep.notify();
  1022. }
  1023. /**
  1024. * Collect dependencies on array elements when the array is touched, since
  1025. * we cannot intercept array element access like property getters.
  1026. */
  1027. function dependArray (value) {
  1028. for (let e, i = 0, l = value.length; i < l; i++) {
  1029. e = value[i];
  1030. e && e.__ob__ && e.__ob__.dep.depend();
  1031. if (Array.isArray(e)) {
  1032. dependArray(e);
  1033. }
  1034. }
  1035. }
  1036. /* */
  1037. /**
  1038. * Option overwriting strategies are functions that handle
  1039. * how to merge a parent option value and a child option
  1040. * value into the final value.
  1041. */
  1042. const strats = config.optionMergeStrategies;
  1043. /**
  1044. * Options with restrictions
  1045. */
  1046. {
  1047. strats.el = strats.propsData = function (parent, child, vm, key) {
  1048. if (!vm) {
  1049. warn(
  1050. `option "${key}" can only be used during instance ` +
  1051. 'creation with the `new` keyword.'
  1052. );
  1053. }
  1054. return defaultStrat(parent, child)
  1055. };
  1056. }
  1057. /**
  1058. * Helper that recursively merges two data objects together.
  1059. */
  1060. function mergeData (to, from) {
  1061. if (!from) return to
  1062. let key, toVal, fromVal;
  1063. const keys = hasSymbol
  1064. ? Reflect.ownKeys(from)
  1065. : Object.keys(from);
  1066. for (let i = 0; i < keys.length; i++) {
  1067. key = keys[i];
  1068. // in case the object is already observed...
  1069. if (key === '__ob__') continue
  1070. toVal = to[key];
  1071. fromVal = from[key];
  1072. if (!hasOwn(to, key)) {
  1073. set(to, key, fromVal);
  1074. } else if (
  1075. toVal !== fromVal &&
  1076. isPlainObject(toVal) &&
  1077. isPlainObject(fromVal)
  1078. ) {
  1079. mergeData(toVal, fromVal);
  1080. }
  1081. }
  1082. return to
  1083. }
  1084. /**
  1085. * Data
  1086. */
  1087. function mergeDataOrFn (
  1088. parentVal,
  1089. childVal,
  1090. vm
  1091. ) {
  1092. if (!vm) {
  1093. // in a Vue.extend merge, both should be functions
  1094. if (!childVal) {
  1095. return parentVal
  1096. }
  1097. if (!parentVal) {
  1098. return childVal
  1099. }
  1100. // when parentVal & childVal are both present,
  1101. // we need to return a function that returns the
  1102. // merged result of both functions... no need to
  1103. // check if parentVal is a function here because
  1104. // it has to be a function to pass previous merges.
  1105. return function mergedDataFn () {
  1106. return mergeData(
  1107. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1108. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1109. )
  1110. }
  1111. } else {
  1112. return function mergedInstanceDataFn () {
  1113. // instance merge
  1114. const instanceData = typeof childVal === 'function'
  1115. ? childVal.call(vm, vm)
  1116. : childVal;
  1117. const defaultData = typeof parentVal === 'function'
  1118. ? parentVal.call(vm, vm)
  1119. : parentVal;
  1120. if (instanceData) {
  1121. return mergeData(instanceData, defaultData)
  1122. } else {
  1123. return defaultData
  1124. }
  1125. }
  1126. }
  1127. }
  1128. strats.data = function (
  1129. parentVal,
  1130. childVal,
  1131. vm
  1132. ) {
  1133. if (!vm) {
  1134. if (childVal && typeof childVal !== 'function') {
  1135. warn(
  1136. 'The "data" option should be a function ' +
  1137. 'that returns a per-instance value in component ' +
  1138. 'definitions.',
  1139. vm
  1140. );
  1141. return parentVal
  1142. }
  1143. return mergeDataOrFn(parentVal, childVal)
  1144. }
  1145. return mergeDataOrFn(parentVal, childVal, vm)
  1146. };
  1147. /**
  1148. * Hooks and props are merged as arrays.
  1149. */
  1150. function mergeHook (
  1151. parentVal,
  1152. childVal
  1153. ) {
  1154. const res = childVal
  1155. ? parentVal
  1156. ? parentVal.concat(childVal)
  1157. : Array.isArray(childVal)
  1158. ? childVal
  1159. : [childVal]
  1160. : parentVal;
  1161. return res
  1162. ? dedupeHooks(res)
  1163. : res
  1164. }
  1165. function dedupeHooks (hooks) {
  1166. const res = [];
  1167. for (let i = 0; i < hooks.length; i++) {
  1168. if (res.indexOf(hooks[i]) === -1) {
  1169. res.push(hooks[i]);
  1170. }
  1171. }
  1172. return res
  1173. }
  1174. LIFECYCLE_HOOKS.forEach(hook => {
  1175. strats[hook] = mergeHook;
  1176. });
  1177. /**
  1178. * Assets
  1179. *
  1180. * When a vm is present (instance creation), we need to do
  1181. * a three-way merge between constructor options, instance
  1182. * options and parent options.
  1183. */
  1184. function mergeAssets (
  1185. parentVal,
  1186. childVal,
  1187. vm,
  1188. key
  1189. ) {
  1190. const res = Object.create(parentVal || null);
  1191. if (childVal) {
  1192. assertObjectType(key, childVal, vm);
  1193. return extend(res, childVal)
  1194. } else {
  1195. return res
  1196. }
  1197. }
  1198. ASSET_TYPES.forEach(function (type) {
  1199. strats[type + 's'] = mergeAssets;
  1200. });
  1201. /**
  1202. * Watchers.
  1203. *
  1204. * Watchers hashes should not overwrite one
  1205. * another, so we merge them as arrays.
  1206. */
  1207. strats.watch = function (
  1208. parentVal,
  1209. childVal,
  1210. vm,
  1211. key
  1212. ) {
  1213. // work around Firefox's Object.prototype.watch...
  1214. if (parentVal === nativeWatch) parentVal = undefined;
  1215. if (childVal === nativeWatch) childVal = undefined;
  1216. /* istanbul ignore if */
  1217. if (!childVal) return Object.create(parentVal || null)
  1218. {
  1219. assertObjectType(key, childVal, vm);
  1220. }
  1221. if (!parentVal) return childVal
  1222. const ret = {};
  1223. extend(ret, parentVal);
  1224. for (const key in childVal) {
  1225. let parent = ret[key];
  1226. const child = childVal[key];
  1227. if (parent && !Array.isArray(parent)) {
  1228. parent = [parent];
  1229. }
  1230. ret[key] = parent
  1231. ? parent.concat(child)
  1232. : Array.isArray(child) ? child : [child];
  1233. }
  1234. return ret
  1235. };
  1236. /**
  1237. * Other object hashes.
  1238. */
  1239. strats.props =
  1240. strats.methods =
  1241. strats.inject =
  1242. strats.computed = function (
  1243. parentVal,
  1244. childVal,
  1245. vm,
  1246. key
  1247. ) {
  1248. if (childVal && "development" !== 'production') {
  1249. assertObjectType(key, childVal, vm);
  1250. }
  1251. if (!parentVal) return childVal
  1252. const ret = Object.create(null);
  1253. extend(ret, parentVal);
  1254. if (childVal) extend(ret, childVal);
  1255. return ret
  1256. };
  1257. strats.provide = mergeDataOrFn;
  1258. /**
  1259. * Default strategy.
  1260. */
  1261. const defaultStrat = function (parentVal, childVal) {
  1262. return childVal === undefined
  1263. ? parentVal
  1264. : childVal
  1265. };
  1266. /**
  1267. * Validate component names
  1268. */
  1269. function checkComponents (options) {
  1270. for (const key in options.components) {
  1271. validateComponentName(key);
  1272. }
  1273. }
  1274. function validateComponentName (name) {
  1275. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  1276. warn(
  1277. 'Invalid component name: "' + name + '". Component names ' +
  1278. 'should conform to valid custom element name in html5 specification.'
  1279. );
  1280. }
  1281. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1282. warn(
  1283. 'Do not use built-in or reserved HTML elements as component ' +
  1284. 'id: ' + name
  1285. );
  1286. }
  1287. }
  1288. /**
  1289. * Ensure all props option syntax are normalized into the
  1290. * Object-based format.
  1291. */
  1292. function normalizeProps (options, vm) {
  1293. const props = options.props;
  1294. if (!props) return
  1295. const res = {};
  1296. let i, val, name;
  1297. if (Array.isArray(props)) {
  1298. i = props.length;
  1299. while (i--) {
  1300. val = props[i];
  1301. if (typeof val === 'string') {
  1302. name = camelize(val);
  1303. res[name] = { type: null };
  1304. } else {
  1305. warn('props must be strings when using array syntax.');
  1306. }
  1307. }
  1308. } else if (isPlainObject(props)) {
  1309. for (const key in props) {
  1310. val = props[key];
  1311. name = camelize(key);
  1312. res[name] = isPlainObject(val)
  1313. ? val
  1314. : { type: val };
  1315. }
  1316. } else {
  1317. warn(
  1318. `Invalid value for option "props": expected an Array or an Object, ` +
  1319. `but got ${toRawType(props)}.`,
  1320. vm
  1321. );
  1322. }
  1323. options.props = res;
  1324. }
  1325. /**
  1326. * Normalize all injections into Object-based format
  1327. */
  1328. function normalizeInject (options, vm) {
  1329. const inject = options.inject;
  1330. if (!inject) return
  1331. const normalized = options.inject = {};
  1332. if (Array.isArray(inject)) {
  1333. for (let i = 0; i < inject.length; i++) {
  1334. normalized[inject[i]] = { from: inject[i] };
  1335. }
  1336. } else if (isPlainObject(inject)) {
  1337. for (const key in inject) {
  1338. const val = inject[key];
  1339. normalized[key] = isPlainObject(val)
  1340. ? extend({ from: key }, val)
  1341. : { from: val };
  1342. }
  1343. } else {
  1344. warn(
  1345. `Invalid value for option "inject": expected an Array or an Object, ` +
  1346. `but got ${toRawType(inject)}.`,
  1347. vm
  1348. );
  1349. }
  1350. }
  1351. /**
  1352. * Normalize raw function directives into object format.
  1353. */
  1354. function normalizeDirectives (options) {
  1355. const dirs = options.directives;
  1356. if (dirs) {
  1357. for (const key in dirs) {
  1358. const def$$1 = dirs[key];
  1359. if (typeof def$$1 === 'function') {
  1360. dirs[key] = { bind: def$$1, update: def$$1 };
  1361. }
  1362. }
  1363. }
  1364. }
  1365. function assertObjectType (name, value, vm) {
  1366. if (!isPlainObject(value)) {
  1367. warn(
  1368. `Invalid value for option "${name}": expected an Object, ` +
  1369. `but got ${toRawType(value)}.`,
  1370. vm
  1371. );
  1372. }
  1373. }
  1374. /**
  1375. * Merge two option objects into a new one.
  1376. * Core utility used in both instantiation and inheritance.
  1377. */
  1378. function mergeOptions (
  1379. parent,
  1380. child,
  1381. vm
  1382. ) {
  1383. {
  1384. checkComponents(child);
  1385. }
  1386. if (typeof child === 'function') {
  1387. child = child.options;
  1388. }
  1389. normalizeProps(child, vm);
  1390. normalizeInject(child, vm);
  1391. normalizeDirectives(child);
  1392. // Apply extends and mixins on the child options,
  1393. // but only if it is a raw options object that isn't
  1394. // the result of another mergeOptions call.
  1395. // Only merged options has the _base property.
  1396. if (!child._base) {
  1397. if (child.extends) {
  1398. parent = mergeOptions(parent, child.extends, vm);
  1399. }
  1400. if (child.mixins) {
  1401. for (let i = 0, l = child.mixins.length; i < l; i++) {
  1402. parent = mergeOptions(parent, child.mixins[i], vm);
  1403. }
  1404. }
  1405. }
  1406. const options = {};
  1407. let key;
  1408. for (key in parent) {
  1409. mergeField(key);
  1410. }
  1411. for (key in child) {
  1412. if (!hasOwn(parent, key)) {
  1413. mergeField(key);
  1414. }
  1415. }
  1416. function mergeField (key) {
  1417. const strat = strats[key] || defaultStrat;
  1418. options[key] = strat(parent[key], child[key], vm, key);
  1419. }
  1420. return options
  1421. }
  1422. /**
  1423. * Resolve an asset.
  1424. * This function is used because child instances need access
  1425. * to assets defined in its ancestor chain.
  1426. */
  1427. function resolveAsset (
  1428. options,
  1429. type,
  1430. id,
  1431. warnMissing
  1432. ) {
  1433. /* istanbul ignore if */
  1434. if (typeof id !== 'string') {
  1435. return
  1436. }
  1437. const assets = options[type];
  1438. // check local registration variations first
  1439. if (hasOwn(assets, id)) return assets[id]
  1440. const camelizedId = camelize(id);
  1441. if (hasOwn(assets, camelizedId)) return assets[camelizedId]
  1442. const PascalCaseId = capitalize(camelizedId);
  1443. if (hasOwn(assets, PascalCaseId)) return assets[PascalCaseId]
  1444. // fallback to prototype chain
  1445. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1446. if (warnMissing && !res) {
  1447. warn(
  1448. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1449. options
  1450. );
  1451. }
  1452. return res
  1453. }
  1454. /* */
  1455. function validateProp (
  1456. key,
  1457. propOptions,
  1458. propsData,
  1459. vm
  1460. ) {
  1461. const prop = propOptions[key];
  1462. const absent = !hasOwn(propsData, key);
  1463. let value = propsData[key];
  1464. // boolean casting
  1465. const booleanIndex = getTypeIndex(Boolean, prop.type);
  1466. if (booleanIndex > -1) {
  1467. if (absent && !hasOwn(prop, 'default')) {
  1468. value = false;
  1469. } else if (value === '' || value === hyphenate(key)) {
  1470. // only cast empty string / same name to boolean if
  1471. // boolean has higher priority
  1472. const stringIndex = getTypeIndex(String, prop.type);
  1473. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1474. value = true;
  1475. }
  1476. }
  1477. }
  1478. // check default value
  1479. if (value === undefined) {
  1480. value = getPropDefaultValue(vm, prop, key);
  1481. // since the default value is a fresh copy,
  1482. // make sure to observe it.
  1483. const prevShouldObserve = shouldObserve;
  1484. toggleObserving(true);
  1485. observe(value);
  1486. toggleObserving(prevShouldObserve);
  1487. }
  1488. {
  1489. assertProp(prop, key, value, vm, absent);
  1490. }
  1491. return value
  1492. }
  1493. /**
  1494. * Get the default value of a prop.
  1495. */
  1496. function getPropDefaultValue (vm, prop, key) {
  1497. // no default, return undefined
  1498. if (!hasOwn(prop, 'default')) {
  1499. return undefined
  1500. }
  1501. const def = prop.default;
  1502. // warn against non-factory defaults for Object & Array
  1503. if (isObject(def)) {
  1504. warn(
  1505. 'Invalid default value for prop "' + key + '": ' +
  1506. 'Props with type Object/Array must use a factory function ' +
  1507. 'to return the default value.',
  1508. vm
  1509. );
  1510. }
  1511. // the raw prop value was also undefined from previous render,
  1512. // return previous default value to avoid unnecessary watcher trigger
  1513. if (vm && vm.$options.propsData &&
  1514. vm.$options.propsData[key] === undefined &&
  1515. vm._props[key] !== undefined
  1516. ) {
  1517. return vm._props[key]
  1518. }
  1519. // call factory function for non-Function types
  1520. // a value is Function if its prototype is function even across different execution context
  1521. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1522. ? def.call(vm)
  1523. : def
  1524. }
  1525. /**
  1526. * Assert whether a prop is valid.
  1527. */
  1528. function assertProp (
  1529. prop,
  1530. name,
  1531. value,
  1532. vm,
  1533. absent
  1534. ) {
  1535. if (prop.required && absent) {
  1536. warn(
  1537. 'Missing required prop: "' + name + '"',
  1538. vm
  1539. );
  1540. return
  1541. }
  1542. if (value == null && !prop.required) {
  1543. return
  1544. }
  1545. let type = prop.type;
  1546. let valid = !type || type === true;
  1547. const expectedTypes = [];
  1548. if (type) {
  1549. if (!Array.isArray(type)) {
  1550. type = [type];
  1551. }
  1552. for (let i = 0; i < type.length && !valid; i++) {
  1553. const assertedType = assertType(value, type[i], vm);
  1554. expectedTypes.push(assertedType.expectedType || '');
  1555. valid = assertedType.valid;
  1556. }
  1557. }
  1558. const haveExpectedTypes = expectedTypes.some(t => t);
  1559. if (!valid && haveExpectedTypes) {
  1560. warn(
  1561. getInvalidTypeMessage(name, value, expectedTypes),
  1562. vm
  1563. );
  1564. return
  1565. }
  1566. const validator = prop.validator;
  1567. if (validator) {
  1568. if (!validator(value)) {
  1569. warn(
  1570. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1571. vm
  1572. );
  1573. }
  1574. }
  1575. }
  1576. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  1577. function assertType (value, type, vm) {
  1578. let valid;
  1579. const expectedType = getType(type);
  1580. if (simpleCheckRE.test(expectedType)) {
  1581. const t = typeof value;
  1582. valid = t === expectedType.toLowerCase();
  1583. // for primitive wrapper objects
  1584. if (!valid && t === 'object') {
  1585. valid = value instanceof type;
  1586. }
  1587. } else if (expectedType === 'Object') {
  1588. valid = isPlainObject(value);
  1589. } else if (expectedType === 'Array') {
  1590. valid = Array.isArray(value);
  1591. } else {
  1592. try {
  1593. valid = value instanceof type;
  1594. } catch (e) {
  1595. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  1596. valid = false;
  1597. }
  1598. }
  1599. return {
  1600. valid,
  1601. expectedType
  1602. }
  1603. }
  1604. const functionTypeCheckRE = /^\s*function (\w+)/;
  1605. /**
  1606. * Use function string name to check built-in types,
  1607. * because a simple equality check will fail when running
  1608. * across different vms / iframes.
  1609. */
  1610. function getType (fn) {
  1611. const match = fn && fn.toString().match(functionTypeCheckRE);
  1612. return match ? match[1] : ''
  1613. }
  1614. function isSameType (a, b) {
  1615. return getType(a) === getType(b)
  1616. }
  1617. function getTypeIndex (type, expectedTypes) {
  1618. if (!Array.isArray(expectedTypes)) {
  1619. return isSameType(expectedTypes, type) ? 0 : -1
  1620. }
  1621. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  1622. if (isSameType(expectedTypes[i], type)) {
  1623. return i
  1624. }
  1625. }
  1626. return -1
  1627. }
  1628. function getInvalidTypeMessage (name, value, expectedTypes) {
  1629. let message = `Invalid prop: type check failed for prop "${name}".` +
  1630. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  1631. const expectedType = expectedTypes[0];
  1632. const receivedType = toRawType(value);
  1633. // check if we need to specify expected value
  1634. if (
  1635. expectedTypes.length === 1 &&
  1636. isExplicable(expectedType) &&
  1637. isExplicable(typeof value) &&
  1638. !isBoolean(expectedType, receivedType)
  1639. ) {
  1640. message += ` with value ${styleValue(value, expectedType)}`;
  1641. }
  1642. message += `, got ${receivedType} `;
  1643. // check if we need to specify received value
  1644. if (isExplicable(receivedType)) {
  1645. message += `with value ${styleValue(value, receivedType)}.`;
  1646. }
  1647. return message
  1648. }
  1649. function styleValue (value, type) {
  1650. if (type === 'String') {
  1651. return `"${value}"`
  1652. } else if (type === 'Number') {
  1653. return `${Number(value)}`
  1654. } else {
  1655. return `${value}`
  1656. }
  1657. }
  1658. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  1659. function isExplicable (value) {
  1660. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem)
  1661. }
  1662. function isBoolean (...args) {
  1663. return args.some(elem => elem.toLowerCase() === 'boolean')
  1664. }
  1665. /* */
  1666. function handleError (err, vm, info) {
  1667. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1668. // See: https://github.com/vuejs/vuex/issues/1505
  1669. pushTarget();
  1670. try {
  1671. if (vm) {
  1672. let cur = vm;
  1673. while ((cur = cur.$parent)) {
  1674. const hooks = cur.$options.errorCaptured;
  1675. if (hooks) {
  1676. for (let i = 0; i < hooks.length; i++) {
  1677. try {
  1678. const capture = hooks[i].call(cur, err, vm, info) === false;
  1679. if (capture) return
  1680. } catch (e) {
  1681. globalHandleError(e, cur, 'errorCaptured hook');
  1682. }
  1683. }
  1684. }
  1685. }
  1686. }
  1687. globalHandleError(err, vm, info);
  1688. } finally {
  1689. popTarget();
  1690. }
  1691. }
  1692. function invokeWithErrorHandling (
  1693. handler,
  1694. context,
  1695. args,
  1696. vm,
  1697. info
  1698. ) {
  1699. let res;
  1700. try {
  1701. res = args ? handler.apply(context, args) : handler.call(context);
  1702. if (res && !res._isVue && isPromise(res) && !res._handled) {
  1703. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  1704. // issue #9511
  1705. // avoid catch triggering multiple times when nested calls
  1706. res._handled = true;
  1707. }
  1708. } catch (e) {
  1709. handleError(e, vm, info);
  1710. }
  1711. return res
  1712. }
  1713. function globalHandleError (err, vm, info) {
  1714. if (config.errorHandler) {
  1715. try {
  1716. return config.errorHandler.call(null, err, vm, info)
  1717. } catch (e) {
  1718. // if the user intentionally throws the original error in the handler,
  1719. // do not log it twice
  1720. if (e !== err) {
  1721. logError(e, null, 'config.errorHandler');
  1722. }
  1723. }
  1724. }
  1725. logError(err, vm, info);
  1726. }
  1727. function logError (err, vm, info) {
  1728. {
  1729. warn(`Error in ${info}: "${err.toString()}"`, vm);
  1730. }
  1731. /* istanbul ignore else */
  1732. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1733. console.error(err);
  1734. } else {
  1735. throw err
  1736. }
  1737. }
  1738. /* */
  1739. let isUsingMicroTask = false;
  1740. const callbacks = [];
  1741. let pending = false;
  1742. function flushCallbacks () {
  1743. pending = false;
  1744. const copies = callbacks.slice(0);
  1745. callbacks.length = 0;
  1746. for (let i = 0; i < copies.length; i++) {
  1747. copies[i]();
  1748. }
  1749. }
  1750. // Here we have async deferring wrappers using microtasks.
  1751. // In 2.5 we used (macro) tasks (in combination with microtasks).
  1752. // However, it has subtle problems when state is changed right before repaint
  1753. // (e.g. #6813, out-in transitions).
  1754. // Also, using (macro) tasks in event handler would cause some weird behaviors
  1755. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  1756. // So we now use microtasks everywhere, again.
  1757. // A major drawback of this tradeoff is that there are some scenarios
  1758. // where microtasks have too high a priority and fire in between supposedly
  1759. // sequential events (e.g. #4521, #6690, which have workarounds)
  1760. // or even between bubbling of the same event (#6566).
  1761. let timerFunc;
  1762. // The nextTick behavior leverages the microtask queue, which can be accessed
  1763. // via either native Promise.then or MutationObserver.
  1764. // MutationObserver has wider support, however it is seriously bugged in
  1765. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1766. // completely stops working after triggering a few times... so, if native
  1767. // Promise is available, we will use it:
  1768. /* istanbul ignore next, $flow-disable-line */
  1769. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1770. const p = Promise.resolve();
  1771. timerFunc = () => {
  1772. p.then(flushCallbacks);
  1773. // In problematic UIWebViews, Promise.then doesn't completely break, but
  1774. // it can get stuck in a weird state where callbacks are pushed into the
  1775. // microtask queue but the queue isn't being flushed, until the browser
  1776. // needs to do some other work, e.g. handle a timer. Therefore we can
  1777. // "force" the microtask queue to be flushed by adding an empty timer.
  1778. if (isIOS) setTimeout(noop);
  1779. };
  1780. isUsingMicroTask = true;
  1781. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1782. isNative(MutationObserver) ||
  1783. // PhantomJS and iOS 7.x
  1784. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1785. )) {
  1786. // Use MutationObserver where native Promise is not available,
  1787. // e.g. PhantomJS, iOS7, Android 4.4
  1788. // (#6466 MutationObserver is unreliable in IE11)
  1789. let counter = 1;
  1790. const observer = new MutationObserver(flushCallbacks);
  1791. const textNode = document.createTextNode(String(counter));
  1792. observer.observe(textNode, {
  1793. characterData: true
  1794. });
  1795. timerFunc = () => {
  1796. counter = (counter + 1) % 2;
  1797. textNode.data = String(counter);
  1798. };
  1799. isUsingMicroTask = true;
  1800. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1801. // Fallback to setImmediate.
  1802. // Technically it leverages the (macro) task queue,
  1803. // but it is still a better choice than setTimeout.
  1804. timerFunc = () => {
  1805. setImmediate(flushCallbacks);
  1806. };
  1807. } else {
  1808. // Fallback to setTimeout.
  1809. timerFunc = () => {
  1810. setTimeout(flushCallbacks, 0);
  1811. };
  1812. }
  1813. function nextTick (cb, ctx) {
  1814. let _resolve;
  1815. callbacks.push(() => {
  1816. if (cb) {
  1817. try {
  1818. cb.call(ctx);
  1819. } catch (e) {
  1820. handleError(e, ctx, 'nextTick');
  1821. }
  1822. } else if (_resolve) {
  1823. _resolve(ctx);
  1824. }
  1825. });
  1826. if (!pending) {
  1827. pending = true;
  1828. timerFunc();
  1829. }
  1830. // $flow-disable-line
  1831. if (!cb && typeof Promise !== 'undefined') {
  1832. return new Promise(resolve => {
  1833. _resolve = resolve;
  1834. })
  1835. }
  1836. }
  1837. /* */
  1838. let mark;
  1839. let measure;
  1840. {
  1841. const perf = inBrowser && window.performance;
  1842. /* istanbul ignore if */
  1843. if (
  1844. perf &&
  1845. perf.mark &&
  1846. perf.measure &&
  1847. perf.clearMarks &&
  1848. perf.clearMeasures
  1849. ) {
  1850. mark = tag => perf.mark(tag);
  1851. measure = (name, startTag, endTag) => {
  1852. perf.measure(name, startTag, endTag);
  1853. perf.clearMarks(startTag);
  1854. perf.clearMarks(endTag);
  1855. // perf.clearMeasures(name)
  1856. };
  1857. }
  1858. }
  1859. /* not type checking this file because flow doesn't play well with Proxy */
  1860. let initProxy;
  1861. {
  1862. const allowedGlobals = makeMap(
  1863. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1864. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1865. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  1866. 'require' // for Webpack/Browserify
  1867. );
  1868. const warnNonPresent = (target, key) => {
  1869. warn(
  1870. `Property or method "${key}" is not defined on the instance but ` +
  1871. 'referenced during render. Make sure that this property is reactive, ' +
  1872. 'either in the data option, or for class-based components, by ' +
  1873. 'initializing the property. ' +
  1874. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  1875. target
  1876. );
  1877. };
  1878. const warnReservedPrefix = (target, key) => {
  1879. warn(
  1880. `Property "${key}" must be accessed with "$data.${key}" because ` +
  1881. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  1882. 'prevent conflicts with Vue internals. ' +
  1883. 'See: https://vuejs.org/v2/api/#data',
  1884. target
  1885. );
  1886. };
  1887. const hasProxy =
  1888. typeof Proxy !== 'undefined' && isNative(Proxy);
  1889. if (hasProxy) {
  1890. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  1891. config.keyCodes = new Proxy(config.keyCodes, {
  1892. set (target, key, value) {
  1893. if (isBuiltInModifier(key)) {
  1894. warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  1895. return false
  1896. } else {
  1897. target[key] = value;
  1898. return true
  1899. }
  1900. }
  1901. });
  1902. }
  1903. const hasHandler = {
  1904. has (target, key) {
  1905. const has = key in target;
  1906. const isAllowed = allowedGlobals(key) ||
  1907. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  1908. if (!has && !isAllowed) {
  1909. if (key in target.$data) warnReservedPrefix(target, key);
  1910. else warnNonPresent(target, key);
  1911. }
  1912. return has || !isAllowed
  1913. }
  1914. };
  1915. const getHandler = {
  1916. get (target, key) {
  1917. if (typeof key === 'string' && !(key in target)) {
  1918. if (key in target.$data) warnReservedPrefix(target, key);
  1919. else warnNonPresent(target, key);
  1920. }
  1921. return target[key]
  1922. }
  1923. };
  1924. initProxy = function initProxy (vm) {
  1925. if (hasProxy) {
  1926. // determine which proxy handler to use
  1927. const options = vm.$options;
  1928. const handlers = options.render && options.render._withStripped
  1929. ? getHandler
  1930. : hasHandler;
  1931. vm._renderProxy = new Proxy(vm, handlers);
  1932. } else {
  1933. vm._renderProxy = vm;
  1934. }
  1935. };
  1936. }
  1937. /* */
  1938. const seenObjects = new _Set();
  1939. /**
  1940. * Recursively traverse an object to evoke all converted
  1941. * getters, so that every nested property inside the object
  1942. * is collected as a "deep" dependency.
  1943. */
  1944. function traverse (val) {
  1945. _traverse(val, seenObjects);
  1946. seenObjects.clear();
  1947. }
  1948. function _traverse (val, seen) {
  1949. let i, keys;
  1950. const isA = Array.isArray(val);
  1951. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  1952. return
  1953. }
  1954. if (val.__ob__) {
  1955. const depId = val.__ob__.dep.id;
  1956. if (seen.has(depId)) {
  1957. return
  1958. }
  1959. seen.add(depId);
  1960. }
  1961. if (isA) {
  1962. i = val.length;
  1963. while (i--) _traverse(val[i], seen);
  1964. } else {
  1965. keys = Object.keys(val);
  1966. i = keys.length;
  1967. while (i--) _traverse(val[keys[i]], seen);
  1968. }
  1969. }
  1970. /* */
  1971. const normalizeEvent = cached((name) => {
  1972. const passive = name.charAt(0) === '&';
  1973. name = passive ? name.slice(1) : name;
  1974. const once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1975. name = once$$1 ? name.slice(1) : name;
  1976. const capture = name.charAt(0) === '!';
  1977. name = capture ? name.slice(1) : name;
  1978. return {
  1979. name,
  1980. once: once$$1,
  1981. capture,
  1982. passive
  1983. }
  1984. });
  1985. function createFnInvoker (fns, vm) {
  1986. function invoker () {
  1987. const fns = invoker.fns;
  1988. if (Array.isArray(fns)) {
  1989. const cloned = fns.slice();
  1990. for (let i = 0; i < cloned.length; i++) {
  1991. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1992. }
  1993. } else {
  1994. // return handler return value for single handlers
  1995. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`)
  1996. }
  1997. }
  1998. invoker.fns = fns;
  1999. return invoker
  2000. }
  2001. function updateListeners (
  2002. on,
  2003. oldOn,
  2004. add,
  2005. remove$$1,
  2006. createOnceHandler,
  2007. vm
  2008. ) {
  2009. let name, def$$1, cur, old, event;
  2010. for (name in on) {
  2011. def$$1 = cur = on[name];
  2012. old = oldOn[name];
  2013. event = normalizeEvent(name);
  2014. if (isUndef(cur)) {
  2015. warn(
  2016. `Invalid handler for event "${event.name}": got ` + String(cur),
  2017. vm
  2018. );
  2019. } else if (isUndef(old)) {
  2020. if (isUndef(cur.fns)) {
  2021. cur = on[name] = createFnInvoker(cur, vm);
  2022. }
  2023. if (isTrue(event.once)) {
  2024. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  2025. }
  2026. add(event.name, cur, event.capture, event.passive, event.params);
  2027. } else if (cur !== old) {
  2028. old.fns = cur;
  2029. on[name] = old;
  2030. }
  2031. }
  2032. for (name in oldOn) {
  2033. if (isUndef(on[name])) {
  2034. event = normalizeEvent(name);
  2035. remove$$1(event.name, oldOn[name], event.capture);
  2036. }
  2037. }
  2038. }
  2039. /* */
  2040. function mergeVNodeHook (def, hookKey, hook) {
  2041. if (def instanceof VNode) {
  2042. def = def.data.hook || (def.data.hook = {});
  2043. }
  2044. let invoker;
  2045. const oldHook = def[hookKey];
  2046. function wrappedHook () {
  2047. hook.apply(this, arguments);
  2048. // important: remove merged hook to ensure it's called only once
  2049. // and prevent memory leak
  2050. remove(invoker.fns, wrappedHook);
  2051. }
  2052. if (isUndef(oldHook)) {
  2053. // no existing hook
  2054. invoker = createFnInvoker([wrappedHook]);
  2055. } else {
  2056. /* istanbul ignore if */
  2057. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  2058. // already a merged invoker
  2059. invoker = oldHook;
  2060. invoker.fns.push(wrappedHook);
  2061. } else {
  2062. // existing plain hook
  2063. invoker = createFnInvoker([oldHook, wrappedHook]);
  2064. }
  2065. }
  2066. invoker.merged = true;
  2067. def[hookKey] = invoker;
  2068. }
  2069. /* */
  2070. function extractPropsFromVNodeData (
  2071. data,
  2072. Ctor,
  2073. tag
  2074. ) {
  2075. // we are only extracting raw values here.
  2076. // validation and default values are handled in the child
  2077. // component itself.
  2078. const propOptions = Ctor.options.props;
  2079. if (isUndef(propOptions)) {
  2080. return
  2081. }
  2082. const res = {};
  2083. const { attrs, props } = data;
  2084. if (isDef(attrs) || isDef(props)) {
  2085. for (const key in propOptions) {
  2086. const altKey = hyphenate(key);
  2087. {
  2088. const keyInLowerCase = key.toLowerCase();
  2089. if (
  2090. key !== keyInLowerCase &&
  2091. attrs && hasOwn(attrs, keyInLowerCase)
  2092. ) {
  2093. tip(
  2094. `Prop "${keyInLowerCase}" is passed to component ` +
  2095. `${formatComponentName(tag || Ctor)}, but the declared prop name is` +
  2096. ` "${key}". ` +
  2097. `Note that HTML attributes are case-insensitive and camelCased ` +
  2098. `props need to use their kebab-case equivalents when using in-DOM ` +
  2099. `templates. You should probably use "${altKey}" instead of "${key}".`
  2100. );
  2101. }
  2102. }
  2103. checkProp(res, props, key, altKey, true) ||
  2104. checkProp(res, attrs, key, altKey, false);
  2105. }
  2106. }
  2107. return res
  2108. }
  2109. function checkProp (
  2110. res,
  2111. hash,
  2112. key,
  2113. altKey,
  2114. preserve
  2115. ) {
  2116. if (isDef(hash)) {
  2117. if (hasOwn(hash, key)) {
  2118. res[key] = hash[key];
  2119. if (!preserve) {
  2120. delete hash[key];
  2121. }
  2122. return true
  2123. } else if (hasOwn(hash, altKey)) {
  2124. res[key] = hash[altKey];
  2125. if (!preserve) {
  2126. delete hash[altKey];
  2127. }
  2128. return true
  2129. }
  2130. }
  2131. return false
  2132. }
  2133. /* */
  2134. // The template compiler attempts to minimize the need for normalization by
  2135. // statically analyzing the template at compile time.
  2136. //
  2137. // For plain HTML markup, normalization can be completely skipped because the
  2138. // generated render function is guaranteed to return Array<VNode>. There are
  2139. // two cases where extra normalization is needed:
  2140. // 1. When the children contains components - because a functional component
  2141. // may return an Array instead of a single root. In this case, just a simple
  2142. // normalization is needed - if any child is an Array, we flatten the whole
  2143. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  2144. // because functional components already normalize their own children.
  2145. function simpleNormalizeChildren (children) {
  2146. for (let i = 0; i < children.length; i++) {
  2147. if (Array.isArray(children[i])) {
  2148. return Array.prototype.concat.apply([], children)
  2149. }
  2150. }
  2151. return children
  2152. }
  2153. // 2. When the children contains constructs that always generated nested Arrays,
  2154. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  2155. // with hand-written render functions / JSX. In such cases a full normalization
  2156. // is needed to cater to all possible types of children values.
  2157. function normalizeChildren (children) {
  2158. return isPrimitive(children)
  2159. ? [createTextVNode(children)]
  2160. : Array.isArray(children)
  2161. ? normalizeArrayChildren(children)
  2162. : undefined
  2163. }
  2164. function isTextNode (node) {
  2165. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  2166. }
  2167. function normalizeArrayChildren (children, nestedIndex) {
  2168. const res = [];
  2169. let i, c, lastIndex, last;
  2170. for (i = 0; i < children.length; i++) {
  2171. c = children[i];
  2172. if (isUndef(c) || typeof c === 'boolean') continue
  2173. lastIndex = res.length - 1;
  2174. last = res[lastIndex];
  2175. // nested
  2176. if (Array.isArray(c)) {
  2177. if (c.length > 0) {
  2178. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  2179. // merge adjacent text nodes
  2180. if (isTextNode(c[0]) && isTextNode(last)) {
  2181. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  2182. c.shift();
  2183. }
  2184. res.push.apply(res, c);
  2185. }
  2186. } else if (isPrimitive(c)) {
  2187. if (isTextNode(last)) {
  2188. // merge adjacent text nodes
  2189. // this is necessary for SSR hydration because text nodes are
  2190. // essentially merged when rendered to HTML strings
  2191. res[lastIndex] = createTextVNode(last.text + c);
  2192. } else if (c !== '') {
  2193. // convert primitive to vnode
  2194. res.push(createTextVNode(c));
  2195. }
  2196. } else {
  2197. if (isTextNode(c) && isTextNode(last)) {
  2198. // merge adjacent text nodes
  2199. res[lastIndex] = createTextVNode(last.text + c.text);
  2200. } else {
  2201. // default key for nested array children (likely generated by v-for)
  2202. if (isTrue(children._isVList) &&
  2203. isDef(c.tag) &&
  2204. isUndef(c.key) &&
  2205. isDef(nestedIndex)) {
  2206. c.key = `__vlist${nestedIndex}_${i}__`;
  2207. }
  2208. res.push(c);
  2209. }
  2210. }
  2211. }
  2212. return res
  2213. }
  2214. /* */
  2215. function initProvide (vm) {
  2216. const provide = vm.$options.provide;
  2217. if (provide) {
  2218. vm._provided = typeof provide === 'function'
  2219. ? provide.call(vm)
  2220. : provide;
  2221. }
  2222. }
  2223. function initInjections (vm) {
  2224. const result = resolveInject(vm.$options.inject, vm);
  2225. if (result) {
  2226. toggleObserving(false);
  2227. Object.keys(result).forEach(key => {
  2228. /* istanbul ignore else */
  2229. {
  2230. defineReactive$$1(vm, key, result[key], () => {
  2231. warn(
  2232. `Avoid mutating an injected value directly since the changes will be ` +
  2233. `overwritten whenever the provided component re-renders. ` +
  2234. `injection being mutated: "${key}"`,
  2235. vm
  2236. );
  2237. });
  2238. }
  2239. });
  2240. toggleObserving(true);
  2241. }
  2242. }
  2243. function resolveInject (inject, vm) {
  2244. if (inject) {
  2245. // inject is :any because flow is not smart enough to figure out cached
  2246. const result = Object.create(null);
  2247. const keys = hasSymbol
  2248. ? Reflect.ownKeys(inject)
  2249. : Object.keys(inject);
  2250. for (let i = 0; i < keys.length; i++) {
  2251. const key = keys[i];
  2252. // #6574 in case the inject object is observed...
  2253. if (key === '__ob__') continue
  2254. const provideKey = inject[key].from;
  2255. let source = vm;
  2256. while (source) {
  2257. if (source._provided && hasOwn(source._provided, provideKey)) {
  2258. result[key] = source._provided[provideKey];
  2259. break
  2260. }
  2261. source = source.$parent;
  2262. }
  2263. if (!source) {
  2264. if ('default' in inject[key]) {
  2265. const provideDefault = inject[key].default;
  2266. result[key] = typeof provideDefault === 'function'
  2267. ? provideDefault.call(vm)
  2268. : provideDefault;
  2269. } else {
  2270. warn(`Injection "${key}" not found`, vm);
  2271. }
  2272. }
  2273. }
  2274. return result
  2275. }
  2276. }
  2277. /* */
  2278. /**
  2279. * Runtime helper for resolving raw children VNodes into a slot object.
  2280. */
  2281. function resolveSlots (
  2282. children,
  2283. context
  2284. ) {
  2285. if (!children || !children.length) {
  2286. return {}
  2287. }
  2288. const slots = {};
  2289. for (let i = 0, l = children.length; i < l; i++) {
  2290. const child = children[i];
  2291. const data = child.data;
  2292. // remove slot attribute if the node is resolved as a Vue slot node
  2293. if (data && data.attrs && data.attrs.slot) {
  2294. delete data.attrs.slot;
  2295. }
  2296. // named slots should only be respected if the vnode was rendered in the
  2297. // same context.
  2298. if ((child.context === context || child.fnContext === context) &&
  2299. data && data.slot != null
  2300. ) {
  2301. const name = data.slot;
  2302. const slot = (slots[name] || (slots[name] = []));
  2303. if (child.tag === 'template') {
  2304. slot.push.apply(slot, child.children || []);
  2305. } else {
  2306. slot.push(child);
  2307. }
  2308. } else {
  2309. (slots.default || (slots.default = [])).push(child);
  2310. }
  2311. }
  2312. // ignore slots that contains only whitespace
  2313. for (const name in slots) {
  2314. if (slots[name].every(isWhitespace)) {
  2315. delete slots[name];
  2316. }
  2317. }
  2318. return slots
  2319. }
  2320. function isWhitespace (node) {
  2321. return (node.isComment && !node.asyncFactory) || node.text === ' '
  2322. }
  2323. /* */
  2324. function isAsyncPlaceholder (node) {
  2325. return node.isComment && node.asyncFactory
  2326. }
  2327. /* */
  2328. function normalizeScopedSlots (
  2329. slots,
  2330. normalSlots,
  2331. prevSlots
  2332. ) {
  2333. let res;
  2334. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2335. const isStable = slots ? !!slots.$stable : !hasNormalSlots;
  2336. const key = slots && slots.$key;
  2337. if (!slots) {
  2338. res = {};
  2339. } else if (slots._normalized) {
  2340. // fast path 1: child component re-render only, parent did not change
  2341. return slots._normalized
  2342. } else if (
  2343. isStable &&
  2344. prevSlots &&
  2345. prevSlots !== emptyObject &&
  2346. key === prevSlots.$key &&
  2347. !hasNormalSlots &&
  2348. !prevSlots.$hasNormal
  2349. ) {
  2350. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2351. // only need to normalize once
  2352. return prevSlots
  2353. } else {
  2354. res = {};
  2355. for (const key in slots) {
  2356. if (slots[key] && key[0] !== '$') {
  2357. res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
  2358. }
  2359. }
  2360. }
  2361. // expose normal slots on scopedSlots
  2362. for (const key in normalSlots) {
  2363. if (!(key in res)) {
  2364. res[key] = proxyNormalSlot(normalSlots, key);
  2365. }
  2366. }
  2367. // avoriaz seems to mock a non-extensible $scopedSlots object
  2368. // and when that is passed down this would cause an error
  2369. if (slots && Object.isExtensible(slots)) {
  2370. (slots)._normalized = res;
  2371. }
  2372. def(res, '$stable', isStable);
  2373. def(res, '$key', key);
  2374. def(res, '$hasNormal', hasNormalSlots);
  2375. return res
  2376. }
  2377. function normalizeScopedSlot(normalSlots, key, fn) {
  2378. const normalized = function () {
  2379. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2380. res = res && typeof res === 'object' && !Array.isArray(res)
  2381. ? [res] // single vnode
  2382. : normalizeChildren(res);
  2383. let vnode = res && res[0];
  2384. return res && (
  2385. !vnode ||
  2386. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
  2387. ) ? undefined
  2388. : res
  2389. };
  2390. // this is a slot using the new v-slot syntax without scope. although it is
  2391. // compiled as a scoped slot, render fn users would expect it to be present
  2392. // on this.$slots because the usage is semantically a normal slot.
  2393. if (fn.proxy) {
  2394. Object.defineProperty(normalSlots, key, {
  2395. get: normalized,
  2396. enumerable: true,
  2397. configurable: true
  2398. });
  2399. }
  2400. return normalized
  2401. }
  2402. function proxyNormalSlot(slots, key) {
  2403. return () => slots[key]
  2404. }
  2405. /* */
  2406. /**
  2407. * Runtime helper for rendering v-for lists.
  2408. */
  2409. function renderList (
  2410. val,
  2411. render
  2412. ) {
  2413. let ret, i, l, keys, key;
  2414. if (Array.isArray(val) || typeof val === 'string') {
  2415. ret = new Array(val.length);
  2416. for (i = 0, l = val.length; i < l; i++) {
  2417. ret[i] = render(val[i], i);
  2418. }
  2419. } else if (typeof val === 'number') {
  2420. ret = new Array(val);
  2421. for (i = 0; i < val; i++) {
  2422. ret[i] = render(i + 1, i);
  2423. }
  2424. } else if (isObject(val)) {
  2425. if (hasSymbol && val[Symbol.iterator]) {
  2426. ret = [];
  2427. const iterator = val[Symbol.iterator]();
  2428. let result = iterator.next();
  2429. while (!result.done) {
  2430. ret.push(render(result.value, ret.length));
  2431. result = iterator.next();
  2432. }
  2433. } else {
  2434. keys = Object.keys(val);
  2435. ret = new Array(keys.length);
  2436. for (i = 0, l = keys.length; i < l; i++) {
  2437. key = keys[i];
  2438. ret[i] = render(val[key], key, i);
  2439. }
  2440. }
  2441. }
  2442. if (!isDef(ret)) {
  2443. ret = [];
  2444. }
  2445. (ret)._isVList = true;
  2446. return ret
  2447. }
  2448. /* */
  2449. /**
  2450. * Runtime helper for rendering <slot>
  2451. */
  2452. function renderSlot (
  2453. name,
  2454. fallbackRender,
  2455. props,
  2456. bindObject
  2457. ) {
  2458. const scopedSlotFn = this.$scopedSlots[name];
  2459. let nodes;
  2460. if (scopedSlotFn) {
  2461. // scoped slot
  2462. props = props || {};
  2463. if (bindObject) {
  2464. if (!isObject(bindObject)) {
  2465. warn('slot v-bind without argument expects an Object', this);
  2466. }
  2467. props = extend(extend({}, bindObject), props);
  2468. }
  2469. nodes =
  2470. scopedSlotFn(props) ||
  2471. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2472. } else {
  2473. nodes =
  2474. this.$slots[name] ||
  2475. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2476. }
  2477. const target = props && props.slot;
  2478. if (target) {
  2479. return this.$createElement('template', { slot: target }, nodes)
  2480. } else {
  2481. return nodes
  2482. }
  2483. }
  2484. /* */
  2485. /**
  2486. * Runtime helper for resolving filters
  2487. */
  2488. function resolveFilter (id) {
  2489. return resolveAsset(this.$options, 'filters', id, true) || identity
  2490. }
  2491. /* */
  2492. function isKeyNotMatch (expect, actual) {
  2493. if (Array.isArray(expect)) {
  2494. return expect.indexOf(actual) === -1
  2495. } else {
  2496. return expect !== actual
  2497. }
  2498. }
  2499. /**
  2500. * Runtime helper for checking keyCodes from config.
  2501. * exposed as Vue.prototype._k
  2502. * passing in eventKeyName as last argument separately for backwards compat
  2503. */
  2504. function checkKeyCodes (
  2505. eventKeyCode,
  2506. key,
  2507. builtInKeyCode,
  2508. eventKeyName,
  2509. builtInKeyName
  2510. ) {
  2511. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2512. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2513. return isKeyNotMatch(builtInKeyName, eventKeyName)
  2514. } else if (mappedKeyCode) {
  2515. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  2516. } else if (eventKeyName) {
  2517. return hyphenate(eventKeyName) !== key
  2518. }
  2519. return eventKeyCode === undefined
  2520. }
  2521. /* */
  2522. /**
  2523. * Runtime helper for merging v-bind="object" into a VNode's data.
  2524. */
  2525. function bindObjectProps (
  2526. data,
  2527. tag,
  2528. value,
  2529. asProp,
  2530. isSync
  2531. ) {
  2532. if (value) {
  2533. if (!isObject(value)) {
  2534. warn(
  2535. 'v-bind without argument expects an Object or Array value',
  2536. this
  2537. );
  2538. } else {
  2539. if (Array.isArray(value)) {
  2540. value = toObject(value);
  2541. }
  2542. let hash;
  2543. for (const key in value) {
  2544. if (
  2545. key === 'class' ||
  2546. key === 'style' ||
  2547. isReservedAttribute(key)
  2548. ) {
  2549. hash = data;
  2550. } else {
  2551. const type = data.attrs && data.attrs.type;
  2552. hash = asProp || config.mustUseProp(tag, type, key)
  2553. ? data.domProps || (data.domProps = {})
  2554. : data.attrs || (data.attrs = {});
  2555. }
  2556. const camelizedKey = camelize(key);
  2557. const hyphenatedKey = hyphenate(key);
  2558. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2559. hash[key] = value[key];
  2560. if (isSync) {
  2561. const on = data.on || (data.on = {});
  2562. on[`update:${key}`] = function ($event) {
  2563. value[key] = $event;
  2564. };
  2565. }
  2566. }
  2567. }
  2568. }
  2569. }
  2570. return data
  2571. }
  2572. /* */
  2573. /**
  2574. * Runtime helper for rendering static trees.
  2575. */
  2576. function renderStatic (
  2577. index,
  2578. isInFor
  2579. ) {
  2580. const cached = this._staticTrees || (this._staticTrees = []);
  2581. let tree = cached[index];
  2582. // if has already-rendered static tree and not inside v-for,
  2583. // we can reuse the same tree.
  2584. if (tree && !isInFor) {
  2585. return tree
  2586. }
  2587. // otherwise, render a fresh tree.
  2588. tree = cached[index] = this.$options.staticRenderFns[index].call(
  2589. this._renderProxy,
  2590. null,
  2591. this // for render fns generated for functional component templates
  2592. );
  2593. markStatic(tree, `__static__${index}`, false);
  2594. return tree
  2595. }
  2596. /**
  2597. * Runtime helper for v-once.
  2598. * Effectively it means marking the node as static with a unique key.
  2599. */
  2600. function markOnce (
  2601. tree,
  2602. index,
  2603. key
  2604. ) {
  2605. markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  2606. return tree
  2607. }
  2608. function markStatic (
  2609. tree,
  2610. key,
  2611. isOnce
  2612. ) {
  2613. if (Array.isArray(tree)) {
  2614. for (let i = 0; i < tree.length; i++) {
  2615. if (tree[i] && typeof tree[i] !== 'string') {
  2616. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  2617. }
  2618. }
  2619. } else {
  2620. markStaticNode(tree, key, isOnce);
  2621. }
  2622. }
  2623. function markStaticNode (node, key, isOnce) {
  2624. node.isStatic = true;
  2625. node.key = key;
  2626. node.isOnce = isOnce;
  2627. }
  2628. /* */
  2629. function bindObjectListeners (data, value) {
  2630. if (value) {
  2631. if (!isPlainObject(value)) {
  2632. warn(
  2633. 'v-on without argument expects an Object value',
  2634. this
  2635. );
  2636. } else {
  2637. const on = data.on = data.on ? extend({}, data.on) : {};
  2638. for (const key in value) {
  2639. const existing = on[key];
  2640. const ours = value[key];
  2641. on[key] = existing ? [].concat(existing, ours) : ours;
  2642. }
  2643. }
  2644. }
  2645. return data
  2646. }
  2647. /* */
  2648. function resolveScopedSlots (
  2649. fns, // see flow/vnode
  2650. res,
  2651. // the following are added in 2.6
  2652. hasDynamicKeys,
  2653. contentHashKey
  2654. ) {
  2655. res = res || { $stable: !hasDynamicKeys };
  2656. for (let i = 0; i < fns.length; i++) {
  2657. const slot = fns[i];
  2658. if (Array.isArray(slot)) {
  2659. resolveScopedSlots(slot, res, hasDynamicKeys);
  2660. } else if (slot) {
  2661. // marker for reverse proxying v-slot without scope on this.$slots
  2662. if (slot.proxy) {
  2663. slot.fn.proxy = true;
  2664. }
  2665. res[slot.key] = slot.fn;
  2666. }
  2667. }
  2668. if (contentHashKey) {
  2669. (res).$key = contentHashKey;
  2670. }
  2671. return res
  2672. }
  2673. /* */
  2674. function bindDynamicKeys (baseObj, values) {
  2675. for (let i = 0; i < values.length; i += 2) {
  2676. const key = values[i];
  2677. if (typeof key === 'string' && key) {
  2678. baseObj[values[i]] = values[i + 1];
  2679. } else if (key !== '' && key !== null) {
  2680. // null is a special value for explicitly removing a binding
  2681. warn(
  2682. `Invalid value for dynamic directive argument (expected string or null): ${key}`,
  2683. this
  2684. );
  2685. }
  2686. }
  2687. return baseObj
  2688. }
  2689. // helper to dynamically append modifier runtime markers to event names.
  2690. // ensure only append when value is already string, otherwise it will be cast
  2691. // to string and cause the type check to miss.
  2692. function prependModifier (value, symbol) {
  2693. return typeof value === 'string' ? symbol + value : value
  2694. }
  2695. /* */
  2696. function installRenderHelpers (target) {
  2697. target._o = markOnce;
  2698. target._n = toNumber;
  2699. target._s = toString;
  2700. target._l = renderList;
  2701. target._t = renderSlot;
  2702. target._q = looseEqual;
  2703. target._i = looseIndexOf;
  2704. target._m = renderStatic;
  2705. target._f = resolveFilter;
  2706. target._k = checkKeyCodes;
  2707. target._b = bindObjectProps;
  2708. target._v = createTextVNode;
  2709. target._e = createEmptyVNode;
  2710. target._u = resolveScopedSlots;
  2711. target._g = bindObjectListeners;
  2712. target._d = bindDynamicKeys;
  2713. target._p = prependModifier;
  2714. }
  2715. /* */
  2716. function FunctionalRenderContext (
  2717. data,
  2718. props,
  2719. children,
  2720. parent,
  2721. Ctor
  2722. ) {
  2723. const options = Ctor.options;
  2724. // ensure the createElement function in functional components
  2725. // gets a unique context - this is necessary for correct named slot check
  2726. let contextVm;
  2727. if (hasOwn(parent, '_uid')) {
  2728. contextVm = Object.create(parent);
  2729. // $flow-disable-line
  2730. contextVm._original = parent;
  2731. } else {
  2732. // the context vm passed in is a functional context as well.
  2733. // in this case we want to make sure we are able to get a hold to the
  2734. // real context instance.
  2735. contextVm = parent;
  2736. // $flow-disable-line
  2737. parent = parent._original;
  2738. }
  2739. const isCompiled = isTrue(options._compiled);
  2740. const needNormalization = !isCompiled;
  2741. this.data = data;
  2742. this.props = props;
  2743. this.children = children;
  2744. this.parent = parent;
  2745. this.listeners = data.on || emptyObject;
  2746. this.injections = resolveInject(options.inject, parent);
  2747. this.slots = () => {
  2748. if (!this.$slots) {
  2749. normalizeScopedSlots(
  2750. data.scopedSlots,
  2751. this.$slots = resolveSlots(children, parent)
  2752. );
  2753. }
  2754. return this.$slots
  2755. };
  2756. Object.defineProperty(this, 'scopedSlots', ({
  2757. enumerable: true,
  2758. get () {
  2759. return normalizeScopedSlots(data.scopedSlots, this.slots())
  2760. }
  2761. }));
  2762. // support for compiled functional template
  2763. if (isCompiled) {
  2764. // exposing $options for renderStatic()
  2765. this.$options = options;
  2766. // pre-resolve slots for renderSlot()
  2767. this.$slots = this.slots();
  2768. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  2769. }
  2770. if (options._scopeId) {
  2771. this._c = (a, b, c, d) => {
  2772. const vnode = createElement(contextVm, a, b, c, d, needNormalization);
  2773. if (vnode && !Array.isArray(vnode)) {
  2774. vnode.fnScopeId = options._scopeId;
  2775. vnode.fnContext = parent;
  2776. }
  2777. return vnode
  2778. };
  2779. } else {
  2780. this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
  2781. }
  2782. }
  2783. installRenderHelpers(FunctionalRenderContext.prototype);
  2784. function createFunctionalComponent (
  2785. Ctor,
  2786. propsData,
  2787. data,
  2788. contextVm,
  2789. children
  2790. ) {
  2791. const options = Ctor.options;
  2792. const props = {};
  2793. const propOptions = options.props;
  2794. if (isDef(propOptions)) {
  2795. for (const key in propOptions) {
  2796. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  2797. }
  2798. } else {
  2799. if (isDef(data.attrs)) mergeProps(props, data.attrs);
  2800. if (isDef(data.props)) mergeProps(props, data.props);
  2801. }
  2802. const renderContext = new FunctionalRenderContext(
  2803. data,
  2804. props,
  2805. children,
  2806. contextVm,
  2807. Ctor
  2808. );
  2809. const vnode = options.render.call(null, renderContext._c, renderContext);
  2810. if (vnode instanceof VNode) {
  2811. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  2812. } else if (Array.isArray(vnode)) {
  2813. const vnodes = normalizeChildren(vnode) || [];
  2814. const res = new Array(vnodes.length);
  2815. for (let i = 0; i < vnodes.length; i++) {
  2816. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  2817. }
  2818. return res
  2819. }
  2820. }
  2821. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  2822. // #7817 clone node before setting fnContext, otherwise if the node is reused
  2823. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  2824. // that should not be matched to match.
  2825. const clone = cloneVNode(vnode);
  2826. clone.fnContext = contextVm;
  2827. clone.fnOptions = options;
  2828. {
  2829. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  2830. }
  2831. if (data.slot) {
  2832. (clone.data || (clone.data = {})).slot = data.slot;
  2833. }
  2834. return clone
  2835. }
  2836. function mergeProps (to, from) {
  2837. for (const key in from) {
  2838. to[camelize(key)] = from[key];
  2839. }
  2840. }
  2841. /* */
  2842. /* */
  2843. /* */
  2844. /* */
  2845. // inline hooks to be invoked on component VNodes during patch
  2846. const componentVNodeHooks = {
  2847. init (vnode, hydrating) {
  2848. if (
  2849. vnode.componentInstance &&
  2850. !vnode.componentInstance._isDestroyed &&
  2851. vnode.data.keepAlive
  2852. ) {
  2853. // kept-alive components, treat as a patch
  2854. const mountedNode = vnode; // work around flow
  2855. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  2856. } else {
  2857. const child = vnode.componentInstance = createComponentInstanceForVnode(
  2858. vnode,
  2859. activeInstance
  2860. );
  2861. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  2862. }
  2863. },
  2864. prepatch (oldVnode, vnode) {
  2865. const options = vnode.componentOptions;
  2866. const child = vnode.componentInstance = oldVnode.componentInstance;
  2867. updateChildComponent(
  2868. child,
  2869. options.propsData, // updated props
  2870. options.listeners, // updated listeners
  2871. vnode, // new parent vnode
  2872. options.children // new children
  2873. );
  2874. },
  2875. insert (vnode) {
  2876. const { context, componentInstance } = vnode;
  2877. if (!componentInstance._isMounted) {
  2878. componentInstance._isMounted = true;
  2879. callHook(componentInstance, 'mounted');
  2880. }
  2881. if (vnode.data.keepAlive) {
  2882. if (context._isMounted) {
  2883. // vue-router#1212
  2884. // During updates, a kept-alive component's child components may
  2885. // change, so directly walking the tree here may call activated hooks
  2886. // on incorrect children. Instead we push them into a queue which will
  2887. // be processed after the whole patch process ended.
  2888. queueActivatedComponent(componentInstance);
  2889. } else {
  2890. activateChildComponent(componentInstance, true /* direct */);
  2891. }
  2892. }
  2893. },
  2894. destroy (vnode) {
  2895. const { componentInstance } = vnode;
  2896. if (!componentInstance._isDestroyed) {
  2897. if (!vnode.data.keepAlive) {
  2898. componentInstance.$destroy();
  2899. } else {
  2900. deactivateChildComponent(componentInstance, true /* direct */);
  2901. }
  2902. }
  2903. }
  2904. };
  2905. const hooksToMerge = Object.keys(componentVNodeHooks);
  2906. function createComponent (
  2907. Ctor,
  2908. data,
  2909. context,
  2910. children,
  2911. tag
  2912. ) {
  2913. if (isUndef(Ctor)) {
  2914. return
  2915. }
  2916. const baseCtor = context.$options._base;
  2917. // plain options object: turn it into a constructor
  2918. if (isObject(Ctor)) {
  2919. Ctor = baseCtor.extend(Ctor);
  2920. }
  2921. // if at this stage it's not a constructor or an async component factory,
  2922. // reject.
  2923. if (typeof Ctor !== 'function') {
  2924. {
  2925. warn(`Invalid Component definition: ${String(Ctor)}`, context);
  2926. }
  2927. return
  2928. }
  2929. // async component
  2930. let asyncFactory;
  2931. if (isUndef(Ctor.cid)) {
  2932. asyncFactory = Ctor;
  2933. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  2934. if (Ctor === undefined) {
  2935. // return a placeholder node for async component, which is rendered
  2936. // as a comment node but preserves all the raw information for the node.
  2937. // the information will be used for async server-rendering and hydration.
  2938. return createAsyncPlaceholder(
  2939. asyncFactory,
  2940. data,
  2941. context,
  2942. children,
  2943. tag
  2944. )
  2945. }
  2946. }
  2947. data = data || {};
  2948. // resolve constructor options in case global mixins are applied after
  2949. // component constructor creation
  2950. resolveConstructorOptions(Ctor);
  2951. // transform component v-model data into props & events
  2952. if (isDef(data.model)) {
  2953. transformModel(Ctor.options, data);
  2954. }
  2955. // extract props
  2956. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  2957. // functional component
  2958. if (isTrue(Ctor.options.functional)) {
  2959. return createFunctionalComponent(Ctor, propsData, data, context, children)
  2960. }
  2961. // extract listeners, since these needs to be treated as
  2962. // child component listeners instead of DOM listeners
  2963. const listeners = data.on;
  2964. // replace with listeners with .native modifier
  2965. // so it gets processed during parent component patch.
  2966. data.on = data.nativeOn;
  2967. if (isTrue(Ctor.options.abstract)) {
  2968. // abstract components do not keep anything
  2969. // other than props & listeners & slot
  2970. // work around flow
  2971. const slot = data.slot;
  2972. data = {};
  2973. if (slot) {
  2974. data.slot = slot;
  2975. }
  2976. }
  2977. // install component management hooks onto the placeholder node
  2978. installComponentHooks(data);
  2979. // return a placeholder vnode
  2980. const name = Ctor.options.name || tag;
  2981. const vnode = new VNode(
  2982. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`,
  2983. data, undefined, undefined, undefined, context,
  2984. { Ctor, propsData, listeners, tag, children },
  2985. asyncFactory
  2986. );
  2987. return vnode
  2988. }
  2989. function createComponentInstanceForVnode (
  2990. // we know it's MountedComponentVNode but flow doesn't
  2991. vnode,
  2992. // activeInstance in lifecycle state
  2993. parent
  2994. ) {
  2995. const options = {
  2996. _isComponent: true,
  2997. _parentVnode: vnode,
  2998. parent
  2999. };
  3000. // check inline-template render functions
  3001. const inlineTemplate = vnode.data.inlineTemplate;
  3002. if (isDef(inlineTemplate)) {
  3003. options.render = inlineTemplate.render;
  3004. options.staticRenderFns = inlineTemplate.staticRenderFns;
  3005. }
  3006. return new vnode.componentOptions.Ctor(options)
  3007. }
  3008. function installComponentHooks (data) {
  3009. const hooks = data.hook || (data.hook = {});
  3010. for (let i = 0; i < hooksToMerge.length; i++) {
  3011. const key = hooksToMerge[i];
  3012. const existing = hooks[key];
  3013. const toMerge = componentVNodeHooks[key];
  3014. if (existing !== toMerge && !(existing && existing._merged)) {
  3015. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  3016. }
  3017. }
  3018. }
  3019. function mergeHook$1 (f1, f2) {
  3020. const merged = (a, b) => {
  3021. // flow complains about extra args which is why we use any
  3022. f1(a, b);
  3023. f2(a, b);
  3024. };
  3025. merged._merged = true;
  3026. return merged
  3027. }
  3028. // transform component v-model info (value and callback) into
  3029. // prop and event handler respectively.
  3030. function transformModel (options, data) {
  3031. const prop = (options.model && options.model.prop) || 'value';
  3032. const event = (options.model && options.model.event) || 'input'
  3033. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  3034. const on = data.on || (data.on = {});
  3035. const existing = on[event];
  3036. const callback = data.model.callback;
  3037. if (isDef(existing)) {
  3038. if (
  3039. Array.isArray(existing)
  3040. ? existing.indexOf(callback) === -1
  3041. : existing !== callback
  3042. ) {
  3043. on[event] = [callback].concat(existing);
  3044. }
  3045. } else {
  3046. on[event] = callback;
  3047. }
  3048. }
  3049. /* */
  3050. const SIMPLE_NORMALIZE = 1;
  3051. const ALWAYS_NORMALIZE = 2;
  3052. // wrapper function for providing a more flexible interface
  3053. // without getting yelled at by flow
  3054. function createElement (
  3055. context,
  3056. tag,
  3057. data,
  3058. children,
  3059. normalizationType,
  3060. alwaysNormalize
  3061. ) {
  3062. if (Array.isArray(data) || isPrimitive(data)) {
  3063. normalizationType = children;
  3064. children = data;
  3065. data = undefined;
  3066. }
  3067. if (isTrue(alwaysNormalize)) {
  3068. normalizationType = ALWAYS_NORMALIZE;
  3069. }
  3070. return _createElement(context, tag, data, children, normalizationType)
  3071. }
  3072. function _createElement (
  3073. context,
  3074. tag,
  3075. data,
  3076. children,
  3077. normalizationType
  3078. ) {
  3079. if (isDef(data) && isDef((data).__ob__)) {
  3080. warn(
  3081. `Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` +
  3082. 'Always create fresh vnode data objects in each render!',
  3083. context
  3084. );
  3085. return createEmptyVNode()
  3086. }
  3087. // object syntax in v-bind
  3088. if (isDef(data) && isDef(data.is)) {
  3089. tag = data.is;
  3090. }
  3091. if (!tag) {
  3092. // in case of component :is set to falsy value
  3093. return createEmptyVNode()
  3094. }
  3095. // warn against non-primitive key
  3096. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  3097. ) {
  3098. {
  3099. warn(
  3100. 'Avoid using non-primitive value as key, ' +
  3101. 'use string/number value instead.',
  3102. context
  3103. );
  3104. }
  3105. }
  3106. // support single function children as default scoped slot
  3107. if (Array.isArray(children) &&
  3108. typeof children[0] === 'function'
  3109. ) {
  3110. data = data || {};
  3111. data.scopedSlots = { default: children[0] };
  3112. children.length = 0;
  3113. }
  3114. if (normalizationType === ALWAYS_NORMALIZE) {
  3115. children = normalizeChildren(children);
  3116. } else if (normalizationType === SIMPLE_NORMALIZE) {
  3117. children = simpleNormalizeChildren(children);
  3118. }
  3119. let vnode, ns;
  3120. if (typeof tag === 'string') {
  3121. let Ctor;
  3122. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3123. if (config.isReservedTag(tag)) {
  3124. // platform built-in elements
  3125. if (isDef(data) && isDef(data.nativeOn) && data.tag !== 'component') {
  3126. warn(
  3127. `The .native modifier for v-on is only valid on components but it was used on <${tag}>.`,
  3128. context
  3129. );
  3130. }
  3131. vnode = new VNode(
  3132. config.parsePlatformTagName(tag), data, children,
  3133. undefined, undefined, context
  3134. );
  3135. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  3136. // component
  3137. vnode = createComponent(Ctor, data, context, children, tag);
  3138. } else {
  3139. // unknown or unlisted namespaced elements
  3140. // check at runtime because it may get assigned a namespace when its
  3141. // parent normalizes children
  3142. vnode = new VNode(
  3143. tag, data, children,
  3144. undefined, undefined, context
  3145. );
  3146. }
  3147. } else {
  3148. // direct component options / constructor
  3149. vnode = createComponent(tag, data, context, children);
  3150. }
  3151. if (Array.isArray(vnode)) {
  3152. return vnode
  3153. } else if (isDef(vnode)) {
  3154. if (isDef(ns)) applyNS(vnode, ns);
  3155. if (isDef(data)) registerDeepBindings(data);
  3156. return vnode
  3157. } else {
  3158. return createEmptyVNode()
  3159. }
  3160. }
  3161. function applyNS (vnode, ns, force) {
  3162. vnode.ns = ns;
  3163. if (vnode.tag === 'foreignObject') {
  3164. // use default namespace inside foreignObject
  3165. ns = undefined;
  3166. force = true;
  3167. }
  3168. if (isDef(vnode.children)) {
  3169. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3170. const child = vnode.children[i];
  3171. if (isDef(child.tag) && (
  3172. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3173. applyNS(child, ns, force);
  3174. }
  3175. }
  3176. }
  3177. }
  3178. // ref #5318
  3179. // necessary to ensure parent re-render when deep bindings like :style and
  3180. // :class are used on slot nodes
  3181. function registerDeepBindings (data) {
  3182. if (isObject(data.style)) {
  3183. traverse(data.style);
  3184. }
  3185. if (isObject(data.class)) {
  3186. traverse(data.class);
  3187. }
  3188. }
  3189. /* */
  3190. function initRender (vm) {
  3191. vm._vnode = null; // the root of the child tree
  3192. vm._staticTrees = null; // v-once cached trees
  3193. const options = vm.$options;
  3194. const parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  3195. const renderContext = parentVnode && parentVnode.context;
  3196. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  3197. vm.$scopedSlots = emptyObject;
  3198. // bind the createElement fn to this instance
  3199. // so that we get proper render context inside it.
  3200. // args order: tag, data, children, normalizationType, alwaysNormalize
  3201. // internal version is used by render functions compiled from templates
  3202. vm._c = (a, b, c, d) => createElement(vm, a, b, c, d, false);
  3203. // normalization is always applied for the public version, used in
  3204. // user-written render functions.
  3205. vm.$createElement = (a, b, c, d) => createElement(vm, a, b, c, d, true);
  3206. // $attrs & $listeners are exposed for easier HOC creation.
  3207. // they need to be reactive so that HOCs using them are always updated
  3208. const parentData = parentVnode && parentVnode.data;
  3209. /* istanbul ignore else */
  3210. {
  3211. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
  3212. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  3213. }, true);
  3214. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, () => {
  3215. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  3216. }, true);
  3217. }
  3218. }
  3219. let currentRenderingInstance = null;
  3220. function renderMixin (Vue) {
  3221. // install runtime convenience helpers
  3222. installRenderHelpers(Vue.prototype);
  3223. Vue.prototype.$nextTick = function (fn) {
  3224. return nextTick(fn, this)
  3225. };
  3226. Vue.prototype._render = function () {
  3227. const vm = this;
  3228. const { render, _parentVnode } = vm.$options;
  3229. if (_parentVnode) {
  3230. vm.$scopedSlots = normalizeScopedSlots(
  3231. _parentVnode.data.scopedSlots,
  3232. vm.$slots,
  3233. vm.$scopedSlots
  3234. );
  3235. }
  3236. // set parent vnode. this allows render functions to have access
  3237. // to the data on the placeholder node.
  3238. vm.$vnode = _parentVnode;
  3239. // render self
  3240. let vnode;
  3241. try {
  3242. // There's no need to maintain a stack because all render fns are called
  3243. // separately from one another. Nested component's render fns are called
  3244. // when parent component is patched.
  3245. currentRenderingInstance = vm;
  3246. vnode = render.call(vm._renderProxy, vm.$createElement);
  3247. } catch (e) {
  3248. handleError(e, vm, `render`);
  3249. // return error render result,
  3250. // or previous vnode to prevent render error causing blank component
  3251. /* istanbul ignore else */
  3252. if (vm.$options.renderError) {
  3253. try {
  3254. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  3255. } catch (e) {
  3256. handleError(e, vm, `renderError`);
  3257. vnode = vm._vnode;
  3258. }
  3259. } else {
  3260. vnode = vm._vnode;
  3261. }
  3262. } finally {
  3263. currentRenderingInstance = null;
  3264. }
  3265. // if the returned array contains only a single node, allow it
  3266. if (Array.isArray(vnode) && vnode.length === 1) {
  3267. vnode = vnode[0];
  3268. }
  3269. // return empty vnode in case the render function errored out
  3270. if (!(vnode instanceof VNode)) {
  3271. if (Array.isArray(vnode)) {
  3272. warn(
  3273. 'Multiple root nodes returned from render function. Render function ' +
  3274. 'should return a single root node.',
  3275. vm
  3276. );
  3277. }
  3278. vnode = createEmptyVNode();
  3279. }
  3280. // set parent
  3281. vnode.parent = _parentVnode;
  3282. return vnode
  3283. };
  3284. }
  3285. /* */
  3286. function ensureCtor (comp, base) {
  3287. if (
  3288. comp.__esModule ||
  3289. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  3290. ) {
  3291. comp = comp.default;
  3292. }
  3293. return isObject(comp)
  3294. ? base.extend(comp)
  3295. : comp
  3296. }
  3297. function createAsyncPlaceholder (
  3298. factory,
  3299. data,
  3300. context,
  3301. children,
  3302. tag
  3303. ) {
  3304. const node = createEmptyVNode();
  3305. node.asyncFactory = factory;
  3306. node.asyncMeta = { data, context, children, tag };
  3307. return node
  3308. }
  3309. function resolveAsyncComponent (
  3310. factory,
  3311. baseCtor
  3312. ) {
  3313. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  3314. return factory.errorComp
  3315. }
  3316. if (isDef(factory.resolved)) {
  3317. return factory.resolved
  3318. }
  3319. const owner = currentRenderingInstance;
  3320. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  3321. // already pending
  3322. factory.owners.push(owner);
  3323. }
  3324. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  3325. return factory.loadingComp
  3326. }
  3327. if (owner && !isDef(factory.owners)) {
  3328. const owners = factory.owners = [owner];
  3329. let sync = true;
  3330. let timerLoading = null;
  3331. let timerTimeout = null
  3332. ;(owner).$on('hook:destroyed', () => remove(owners, owner));
  3333. const forceRender = (renderCompleted) => {
  3334. for (let i = 0, l = owners.length; i < l; i++) {
  3335. (owners[i]).$forceUpdate();
  3336. }
  3337. if (renderCompleted) {
  3338. owners.length = 0;
  3339. if (timerLoading !== null) {
  3340. clearTimeout(timerLoading);
  3341. timerLoading = null;
  3342. }
  3343. if (timerTimeout !== null) {
  3344. clearTimeout(timerTimeout);
  3345. timerTimeout = null;
  3346. }
  3347. }
  3348. };
  3349. const resolve = once((res) => {
  3350. // cache resolved
  3351. factory.resolved = ensureCtor(res, baseCtor);
  3352. // invoke callbacks only if this is not a synchronous resolve
  3353. // (async resolves are shimmed as synchronous during SSR)
  3354. if (!sync) {
  3355. forceRender(true);
  3356. } else {
  3357. owners.length = 0;
  3358. }
  3359. });
  3360. const reject = once(reason => {
  3361. warn(
  3362. `Failed to resolve async component: ${String(factory)}` +
  3363. (reason ? `\nReason: ${reason}` : '')
  3364. );
  3365. if (isDef(factory.errorComp)) {
  3366. factory.error = true;
  3367. forceRender(true);
  3368. }
  3369. });
  3370. const res = factory(resolve, reject);
  3371. if (isObject(res)) {
  3372. if (isPromise(res)) {
  3373. // () => Promise
  3374. if (isUndef(factory.resolved)) {
  3375. res.then(resolve, reject);
  3376. }
  3377. } else if (isPromise(res.component)) {
  3378. res.component.then(resolve, reject);
  3379. if (isDef(res.error)) {
  3380. factory.errorComp = ensureCtor(res.error, baseCtor);
  3381. }
  3382. if (isDef(res.loading)) {
  3383. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  3384. if (res.delay === 0) {
  3385. factory.loading = true;
  3386. } else {
  3387. timerLoading = setTimeout(() => {
  3388. timerLoading = null;
  3389. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  3390. factory.loading = true;
  3391. forceRender(false);
  3392. }
  3393. }, res.delay || 200);
  3394. }
  3395. }
  3396. if (isDef(res.timeout)) {
  3397. timerTimeout = setTimeout(() => {
  3398. timerTimeout = null;
  3399. if (isUndef(factory.resolved)) {
  3400. reject(
  3401. `timeout (${res.timeout}ms)`
  3402. );
  3403. }
  3404. }, res.timeout);
  3405. }
  3406. }
  3407. }
  3408. sync = false;
  3409. // return in case resolved synchronously
  3410. return factory.loading
  3411. ? factory.loadingComp
  3412. : factory.resolved
  3413. }
  3414. }
  3415. /* */
  3416. function getFirstComponentChild (children) {
  3417. if (Array.isArray(children)) {
  3418. for (let i = 0; i < children.length; i++) {
  3419. const c = children[i];
  3420. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  3421. return c
  3422. }
  3423. }
  3424. }
  3425. }
  3426. /* */
  3427. /* */
  3428. function initEvents (vm) {
  3429. vm._events = Object.create(null);
  3430. vm._hasHookEvent = false;
  3431. // init parent attached events
  3432. const listeners = vm.$options._parentListeners;
  3433. if (listeners) {
  3434. updateComponentListeners(vm, listeners);
  3435. }
  3436. }
  3437. let target;
  3438. function add (event, fn) {
  3439. target.$on(event, fn);
  3440. }
  3441. function remove$1 (event, fn) {
  3442. target.$off(event, fn);
  3443. }
  3444. function createOnceHandler (event, fn) {
  3445. const _target = target;
  3446. return function onceHandler () {
  3447. const res = fn.apply(null, arguments);
  3448. if (res !== null) {
  3449. _target.$off(event, onceHandler);
  3450. }
  3451. }
  3452. }
  3453. function updateComponentListeners (
  3454. vm,
  3455. listeners,
  3456. oldListeners
  3457. ) {
  3458. target = vm;
  3459. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  3460. target = undefined;
  3461. }
  3462. function eventsMixin (Vue) {
  3463. const hookRE = /^hook:/;
  3464. Vue.prototype.$on = function (event, fn) {
  3465. const vm = this;
  3466. if (Array.isArray(event)) {
  3467. for (let i = 0, l = event.length; i < l; i++) {
  3468. vm.$on(event[i], fn);
  3469. }
  3470. } else {
  3471. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3472. // optimize hook:event cost by using a boolean flag marked at registration
  3473. // instead of a hash lookup
  3474. if (hookRE.test(event)) {
  3475. vm._hasHookEvent = true;
  3476. }
  3477. }
  3478. return vm
  3479. };
  3480. Vue.prototype.$once = function (event, fn) {
  3481. const vm = this;
  3482. function on () {
  3483. vm.$off(event, on);
  3484. fn.apply(vm, arguments);
  3485. }
  3486. on.fn = fn;
  3487. vm.$on(event, on);
  3488. return vm
  3489. };
  3490. Vue.prototype.$off = function (event, fn) {
  3491. const vm = this;
  3492. // all
  3493. if (!arguments.length) {
  3494. vm._events = Object.create(null);
  3495. return vm
  3496. }
  3497. // array of events
  3498. if (Array.isArray(event)) {
  3499. for (let i = 0, l = event.length; i < l; i++) {
  3500. vm.$off(event[i], fn);
  3501. }
  3502. return vm
  3503. }
  3504. // specific event
  3505. const cbs = vm._events[event];
  3506. if (!cbs) {
  3507. return vm
  3508. }
  3509. if (!fn) {
  3510. vm._events[event] = null;
  3511. return vm
  3512. }
  3513. // specific handler
  3514. let cb;
  3515. let i = cbs.length;
  3516. while (i--) {
  3517. cb = cbs[i];
  3518. if (cb === fn || cb.fn === fn) {
  3519. cbs.splice(i, 1);
  3520. break
  3521. }
  3522. }
  3523. return vm
  3524. };
  3525. Vue.prototype.$emit = function (event) {
  3526. const vm = this;
  3527. {
  3528. const lowerCaseEvent = event.toLowerCase();
  3529. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3530. tip(
  3531. `Event "${lowerCaseEvent}" is emitted in component ` +
  3532. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3533. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3534. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3535. `You should probably use "${hyphenate(event)}" instead of "${event}".`
  3536. );
  3537. }
  3538. }
  3539. let cbs = vm._events[event];
  3540. if (cbs) {
  3541. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3542. const args = toArray(arguments, 1);
  3543. const info = `event handler for "${event}"`;
  3544. for (let i = 0, l = cbs.length; i < l; i++) {
  3545. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3546. }
  3547. }
  3548. return vm
  3549. };
  3550. }
  3551. /* */
  3552. let activeInstance = null;
  3553. let isUpdatingChildComponent = false;
  3554. function setActiveInstance(vm) {
  3555. const prevActiveInstance = activeInstance;
  3556. activeInstance = vm;
  3557. return () => {
  3558. activeInstance = prevActiveInstance;
  3559. }
  3560. }
  3561. function initLifecycle (vm) {
  3562. const options = vm.$options;
  3563. // locate first non-abstract parent
  3564. let parent = options.parent;
  3565. if (parent && !options.abstract) {
  3566. while (parent.$options.abstract && parent.$parent) {
  3567. parent = parent.$parent;
  3568. }
  3569. parent.$children.push(vm);
  3570. }
  3571. vm.$parent = parent;
  3572. vm.$root = parent ? parent.$root : vm;
  3573. vm.$children = [];
  3574. vm.$refs = {};
  3575. vm._watcher = null;
  3576. vm._inactive = null;
  3577. vm._directInactive = false;
  3578. vm._isMounted = false;
  3579. vm._isDestroyed = false;
  3580. vm._isBeingDestroyed = false;
  3581. }
  3582. function lifecycleMixin (Vue) {
  3583. Vue.prototype._update = function (vnode, hydrating) {
  3584. const vm = this;
  3585. const prevEl = vm.$el;
  3586. const prevVnode = vm._vnode;
  3587. const restoreActiveInstance = setActiveInstance(vm);
  3588. vm._vnode = vnode;
  3589. // Vue.prototype.__patch__ is injected in entry points
  3590. // based on the rendering backend used.
  3591. if (!prevVnode) {
  3592. // initial render
  3593. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3594. } else {
  3595. // updates
  3596. vm.$el = vm.__patch__(prevVnode, vnode);
  3597. }
  3598. restoreActiveInstance();
  3599. // update __vue__ reference
  3600. if (prevEl) {
  3601. prevEl.__vue__ = null;
  3602. }
  3603. if (vm.$el) {
  3604. vm.$el.__vue__ = vm;
  3605. }
  3606. // if parent is an HOC, update its $el as well
  3607. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  3608. vm.$parent.$el = vm.$el;
  3609. }
  3610. // updated hook is called by the scheduler to ensure that children are
  3611. // updated in a parent's updated hook.
  3612. };
  3613. Vue.prototype.$forceUpdate = function () {
  3614. const vm = this;
  3615. if (vm._watcher) {
  3616. vm._watcher.update();
  3617. }
  3618. };
  3619. Vue.prototype.$destroy = function () {
  3620. const vm = this;
  3621. if (vm._isBeingDestroyed) {
  3622. return
  3623. }
  3624. callHook(vm, 'beforeDestroy');
  3625. vm._isBeingDestroyed = true;
  3626. // remove self from parent
  3627. const parent = vm.$parent;
  3628. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3629. remove(parent.$children, vm);
  3630. }
  3631. // teardown watchers
  3632. if (vm._watcher) {
  3633. vm._watcher.teardown();
  3634. }
  3635. let i = vm._watchers.length;
  3636. while (i--) {
  3637. vm._watchers[i].teardown();
  3638. }
  3639. // remove reference from data ob
  3640. // frozen object may not have observer.
  3641. if (vm._data.__ob__) {
  3642. vm._data.__ob__.vmCount--;
  3643. }
  3644. // call the last hook...
  3645. vm._isDestroyed = true;
  3646. // invoke destroy hooks on current rendered tree
  3647. vm.__patch__(vm._vnode, null);
  3648. // fire destroyed hook
  3649. callHook(vm, 'destroyed');
  3650. // turn off all instance listeners.
  3651. vm.$off();
  3652. // remove __vue__ reference
  3653. if (vm.$el) {
  3654. vm.$el.__vue__ = null;
  3655. }
  3656. // release circular reference (#6759)
  3657. if (vm.$vnode) {
  3658. vm.$vnode.parent = null;
  3659. }
  3660. };
  3661. }
  3662. function mountComponent (
  3663. vm,
  3664. el,
  3665. hydrating
  3666. ) {
  3667. vm.$el = el;
  3668. if (!vm.$options.render) {
  3669. vm.$options.render = createEmptyVNode;
  3670. {
  3671. /* istanbul ignore if */
  3672. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3673. vm.$options.el || el) {
  3674. warn(
  3675. 'You are using the runtime-only build of Vue where the template ' +
  3676. 'compiler is not available. Either pre-compile the templates into ' +
  3677. 'render functions, or use the compiler-included build.',
  3678. vm
  3679. );
  3680. } else {
  3681. warn(
  3682. 'Failed to mount component: template or render function not defined.',
  3683. vm
  3684. );
  3685. }
  3686. }
  3687. }
  3688. callHook(vm, 'beforeMount');
  3689. let updateComponent;
  3690. /* istanbul ignore if */
  3691. if (config.performance && mark) {
  3692. updateComponent = () => {
  3693. const name = vm._name;
  3694. const id = vm._uid;
  3695. const startTag = `vue-perf-start:${id}`;
  3696. const endTag = `vue-perf-end:${id}`;
  3697. mark(startTag);
  3698. const vnode = vm._render();
  3699. mark(endTag);
  3700. measure(`vue ${name} render`, startTag, endTag);
  3701. mark(startTag);
  3702. vm._update(vnode, hydrating);
  3703. mark(endTag);
  3704. measure(`vue ${name} patch`, startTag, endTag);
  3705. };
  3706. } else {
  3707. updateComponent = () => {
  3708. vm._update(vm._render(), hydrating);
  3709. };
  3710. }
  3711. // we set this to vm._watcher inside the watcher's constructor
  3712. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3713. // component's mounted hook), which relies on vm._watcher being already defined
  3714. new Watcher(vm, updateComponent, noop, {
  3715. before () {
  3716. if (vm._isMounted && !vm._isDestroyed) {
  3717. callHook(vm, 'beforeUpdate');
  3718. }
  3719. }
  3720. }, true /* isRenderWatcher */);
  3721. hydrating = false;
  3722. // manually mounted instance, call mounted on self
  3723. // mounted is called for render-created child components in its inserted hook
  3724. if (vm.$vnode == null) {
  3725. vm._isMounted = true;
  3726. callHook(vm, 'mounted');
  3727. }
  3728. return vm
  3729. }
  3730. function updateChildComponent (
  3731. vm,
  3732. propsData,
  3733. listeners,
  3734. parentVnode,
  3735. renderChildren
  3736. ) {
  3737. {
  3738. isUpdatingChildComponent = true;
  3739. }
  3740. // determine whether component has slot children
  3741. // we need to do this before overwriting $options._renderChildren.
  3742. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3743. // dynamic slot names). Static scoped slots compiled from template has the
  3744. // "$stable" marker.
  3745. const newScopedSlots = parentVnode.data.scopedSlots;
  3746. const oldScopedSlots = vm.$scopedSlots;
  3747. const hasDynamicScopedSlot = !!(
  3748. (newScopedSlots && !newScopedSlots.$stable) ||
  3749. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3750. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3751. (!newScopedSlots && vm.$scopedSlots.$key)
  3752. );
  3753. // Any static slot children from the parent may have changed during parent's
  3754. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3755. // update is necessary to ensure correctness.
  3756. const needsForceUpdate = !!(
  3757. renderChildren || // has new static slots
  3758. vm.$options._renderChildren || // has old static slots
  3759. hasDynamicScopedSlot
  3760. );
  3761. vm.$options._parentVnode = parentVnode;
  3762. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3763. if (vm._vnode) { // update child tree's parent
  3764. vm._vnode.parent = parentVnode;
  3765. }
  3766. vm.$options._renderChildren = renderChildren;
  3767. // update $attrs and $listeners hash
  3768. // these are also reactive so they may trigger child update if the child
  3769. // used them during render
  3770. vm.$attrs = parentVnode.data.attrs || emptyObject;
  3771. vm.$listeners = listeners || emptyObject;
  3772. // update props
  3773. if (propsData && vm.$options.props) {
  3774. toggleObserving(false);
  3775. const props = vm._props;
  3776. const propKeys = vm.$options._propKeys || [];
  3777. for (let i = 0; i < propKeys.length; i++) {
  3778. const key = propKeys[i];
  3779. const propOptions = vm.$options.props; // wtf flow?
  3780. props[key] = validateProp(key, propOptions, propsData, vm);
  3781. }
  3782. toggleObserving(true);
  3783. // keep a copy of raw propsData
  3784. vm.$options.propsData = propsData;
  3785. }
  3786. // update listeners
  3787. listeners = listeners || emptyObject;
  3788. const oldListeners = vm.$options._parentListeners;
  3789. vm.$options._parentListeners = listeners;
  3790. updateComponentListeners(vm, listeners, oldListeners);
  3791. // resolve slots + force update if has children
  3792. if (needsForceUpdate) {
  3793. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3794. vm.$forceUpdate();
  3795. }
  3796. {
  3797. isUpdatingChildComponent = false;
  3798. }
  3799. }
  3800. function isInInactiveTree (vm) {
  3801. while (vm && (vm = vm.$parent)) {
  3802. if (vm._inactive) return true
  3803. }
  3804. return false
  3805. }
  3806. function activateChildComponent (vm, direct) {
  3807. if (direct) {
  3808. vm._directInactive = false;
  3809. if (isInInactiveTree(vm)) {
  3810. return
  3811. }
  3812. } else if (vm._directInactive) {
  3813. return
  3814. }
  3815. if (vm._inactive || vm._inactive === null) {
  3816. vm._inactive = false;
  3817. for (let i = 0; i < vm.$children.length; i++) {
  3818. activateChildComponent(vm.$children[i]);
  3819. }
  3820. callHook(vm, 'activated');
  3821. }
  3822. }
  3823. function deactivateChildComponent (vm, direct) {
  3824. if (direct) {
  3825. vm._directInactive = true;
  3826. if (isInInactiveTree(vm)) {
  3827. return
  3828. }
  3829. }
  3830. if (!vm._inactive) {
  3831. vm._inactive = true;
  3832. for (let i = 0; i < vm.$children.length; i++) {
  3833. deactivateChildComponent(vm.$children[i]);
  3834. }
  3835. callHook(vm, 'deactivated');
  3836. }
  3837. }
  3838. function callHook (vm, hook) {
  3839. // #7573 disable dep collection when invoking lifecycle hooks
  3840. pushTarget();
  3841. const handlers = vm.$options[hook];
  3842. const info = `${hook} hook`;
  3843. if (handlers) {
  3844. for (let i = 0, j = handlers.length; i < j; i++) {
  3845. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  3846. }
  3847. }
  3848. if (vm._hasHookEvent) {
  3849. vm.$emit('hook:' + hook);
  3850. }
  3851. popTarget();
  3852. }
  3853. /* */
  3854. const MAX_UPDATE_COUNT = 100;
  3855. const queue = [];
  3856. const activatedChildren = [];
  3857. let has = {};
  3858. let circular = {};
  3859. let waiting = false;
  3860. let flushing = false;
  3861. let index = 0;
  3862. /**
  3863. * Reset the scheduler's state.
  3864. */
  3865. function resetSchedulerState () {
  3866. index = queue.length = activatedChildren.length = 0;
  3867. has = {};
  3868. {
  3869. circular = {};
  3870. }
  3871. waiting = flushing = false;
  3872. }
  3873. // Async edge case #6566 requires saving the timestamp when event listeners are
  3874. // attached. However, calling performance.now() has a perf overhead especially
  3875. // if the page has thousands of event listeners. Instead, we take a timestamp
  3876. // every time the scheduler flushes and use that for all event listeners
  3877. // attached during that flush.
  3878. let currentFlushTimestamp = 0;
  3879. // Async edge case fix requires storing an event listener's attach timestamp.
  3880. let getNow = Date.now;
  3881. // Determine what event timestamp the browser is using. Annoyingly, the
  3882. // timestamp can either be hi-res (relative to page load) or low-res
  3883. // (relative to UNIX epoch), so in order to compare time we have to use the
  3884. // same timestamp type when saving the flush timestamp.
  3885. // All IE versions use low-res event timestamps, and have problematic clock
  3886. // implementations (#9632)
  3887. if (inBrowser && !isIE) {
  3888. const performance = window.performance;
  3889. if (
  3890. performance &&
  3891. typeof performance.now === 'function' &&
  3892. getNow() > document.createEvent('Event').timeStamp
  3893. ) {
  3894. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3895. // smaller than it, it means the event is using a hi-res timestamp,
  3896. // and we need to use the hi-res version for event listener timestamps as
  3897. // well.
  3898. getNow = () => performance.now();
  3899. }
  3900. }
  3901. /**
  3902. * Flush both queues and run the watchers.
  3903. */
  3904. function flushSchedulerQueue () {
  3905. currentFlushTimestamp = getNow();
  3906. flushing = true;
  3907. let watcher, id;
  3908. // Sort queue before flush.
  3909. // This ensures that:
  3910. // 1. Components are updated from parent to child. (because parent is always
  3911. // created before the child)
  3912. // 2. A component's user watchers are run before its render watcher (because
  3913. // user watchers are created before the render watcher)
  3914. // 3. If a component is destroyed during a parent component's watcher run,
  3915. // its watchers can be skipped.
  3916. queue.sort((a, b) => a.id - b.id);
  3917. // do not cache length because more watchers might be pushed
  3918. // as we run existing watchers
  3919. for (index = 0; index < queue.length; index++) {
  3920. watcher = queue[index];
  3921. if (watcher.before) {
  3922. watcher.before();
  3923. }
  3924. id = watcher.id;
  3925. has[id] = null;
  3926. watcher.run();
  3927. // in dev build, check and stop circular updates.
  3928. if (has[id] != null) {
  3929. circular[id] = (circular[id] || 0) + 1;
  3930. if (circular[id] > MAX_UPDATE_COUNT) {
  3931. warn(
  3932. 'You may have an infinite update loop ' + (
  3933. watcher.user
  3934. ? `in watcher with expression "${watcher.expression}"`
  3935. : `in a component render function.`
  3936. ),
  3937. watcher.vm
  3938. );
  3939. break
  3940. }
  3941. }
  3942. }
  3943. // keep copies of post queues before resetting state
  3944. const activatedQueue = activatedChildren.slice();
  3945. const updatedQueue = queue.slice();
  3946. resetSchedulerState();
  3947. // call component updated and activated hooks
  3948. callActivatedHooks(activatedQueue);
  3949. callUpdatedHooks(updatedQueue);
  3950. // devtool hook
  3951. /* istanbul ignore if */
  3952. if (devtools && config.devtools) {
  3953. devtools.emit('flush');
  3954. }
  3955. }
  3956. function callUpdatedHooks (queue) {
  3957. let i = queue.length;
  3958. while (i--) {
  3959. const watcher = queue[i];
  3960. const vm = watcher.vm;
  3961. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3962. callHook(vm, 'updated');
  3963. }
  3964. }
  3965. }
  3966. /**
  3967. * Queue a kept-alive component that was activated during patch.
  3968. * The queue will be processed after the entire tree has been patched.
  3969. */
  3970. function queueActivatedComponent (vm) {
  3971. // setting _inactive to false here so that a render function can
  3972. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3973. vm._inactive = false;
  3974. activatedChildren.push(vm);
  3975. }
  3976. function callActivatedHooks (queue) {
  3977. for (let i = 0; i < queue.length; i++) {
  3978. queue[i]._inactive = true;
  3979. activateChildComponent(queue[i], true /* true */);
  3980. }
  3981. }
  3982. /**
  3983. * Push a watcher into the watcher queue.
  3984. * Jobs with duplicate IDs will be skipped unless it's
  3985. * pushed when the queue is being flushed.
  3986. */
  3987. function queueWatcher (watcher) {
  3988. const id = watcher.id;
  3989. if (has[id] == null) {
  3990. has[id] = true;
  3991. if (!flushing) {
  3992. queue.push(watcher);
  3993. } else {
  3994. // if already flushing, splice the watcher based on its id
  3995. // if already past its id, it will be run next immediately.
  3996. let i = queue.length - 1;
  3997. while (i > index && queue[i].id > watcher.id) {
  3998. i--;
  3999. }
  4000. queue.splice(i + 1, 0, watcher);
  4001. }
  4002. // queue the flush
  4003. if (!waiting) {
  4004. waiting = true;
  4005. if (!config.async) {
  4006. flushSchedulerQueue();
  4007. return
  4008. }
  4009. nextTick(flushSchedulerQueue);
  4010. }
  4011. }
  4012. }
  4013. /* */
  4014. let uid$2 = 0;
  4015. /**
  4016. * A watcher parses an expression, collects dependencies,
  4017. * and fires callback when the expression value changes.
  4018. * This is used for both the $watch() api and directives.
  4019. */
  4020. class Watcher {
  4021. constructor (
  4022. vm,
  4023. expOrFn,
  4024. cb,
  4025. options,
  4026. isRenderWatcher
  4027. ) {
  4028. this.vm = vm;
  4029. if (isRenderWatcher) {
  4030. vm._watcher = this;
  4031. }
  4032. vm._watchers.push(this);
  4033. // options
  4034. if (options) {
  4035. this.deep = !!options.deep;
  4036. this.user = !!options.user;
  4037. this.lazy = !!options.lazy;
  4038. this.sync = !!options.sync;
  4039. this.before = options.before;
  4040. } else {
  4041. this.deep = this.user = this.lazy = this.sync = false;
  4042. }
  4043. this.cb = cb;
  4044. this.id = ++uid$2; // uid for batching
  4045. this.active = true;
  4046. this.dirty = this.lazy; // for lazy watchers
  4047. this.deps = [];
  4048. this.newDeps = [];
  4049. this.depIds = new _Set();
  4050. this.newDepIds = new _Set();
  4051. this.expression = expOrFn.toString();
  4052. // parse expression for getter
  4053. if (typeof expOrFn === 'function') {
  4054. this.getter = expOrFn;
  4055. } else {
  4056. this.getter = parsePath(expOrFn);
  4057. if (!this.getter) {
  4058. this.getter = noop;
  4059. warn(
  4060. `Failed watching path: "${expOrFn}" ` +
  4061. 'Watcher only accepts simple dot-delimited paths. ' +
  4062. 'For full control, use a function instead.',
  4063. vm
  4064. );
  4065. }
  4066. }
  4067. this.value = this.lazy
  4068. ? undefined
  4069. : this.get();
  4070. }
  4071. /**
  4072. * Evaluate the getter, and re-collect dependencies.
  4073. */
  4074. get () {
  4075. pushTarget(this);
  4076. let value;
  4077. const vm = this.vm;
  4078. try {
  4079. value = this.getter.call(vm, vm);
  4080. } catch (e) {
  4081. if (this.user) {
  4082. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4083. } else {
  4084. throw e
  4085. }
  4086. } finally {
  4087. // "touch" every property so they are all tracked as
  4088. // dependencies for deep watching
  4089. if (this.deep) {
  4090. traverse(value);
  4091. }
  4092. popTarget();
  4093. this.cleanupDeps();
  4094. }
  4095. return value
  4096. }
  4097. /**
  4098. * Add a dependency to this directive.
  4099. */
  4100. addDep (dep) {
  4101. const id = dep.id;
  4102. if (!this.newDepIds.has(id)) {
  4103. this.newDepIds.add(id);
  4104. this.newDeps.push(dep);
  4105. if (!this.depIds.has(id)) {
  4106. dep.addSub(this);
  4107. }
  4108. }
  4109. }
  4110. /**
  4111. * Clean up for dependency collection.
  4112. */
  4113. cleanupDeps () {
  4114. let i = this.deps.length;
  4115. while (i--) {
  4116. const dep = this.deps[i];
  4117. if (!this.newDepIds.has(dep.id)) {
  4118. dep.removeSub(this);
  4119. }
  4120. }
  4121. let tmp = this.depIds;
  4122. this.depIds = this.newDepIds;
  4123. this.newDepIds = tmp;
  4124. this.newDepIds.clear();
  4125. tmp = this.deps;
  4126. this.deps = this.newDeps;
  4127. this.newDeps = tmp;
  4128. this.newDeps.length = 0;
  4129. }
  4130. /**
  4131. * Subscriber interface.
  4132. * Will be called when a dependency changes.
  4133. */
  4134. update () {
  4135. /* istanbul ignore else */
  4136. if (this.lazy) {
  4137. this.dirty = true;
  4138. } else if (this.sync) {
  4139. this.run();
  4140. } else {
  4141. queueWatcher(this);
  4142. }
  4143. }
  4144. /**
  4145. * Scheduler job interface.
  4146. * Will be called by the scheduler.
  4147. */
  4148. run () {
  4149. if (this.active) {
  4150. const value = this.get();
  4151. if (
  4152. value !== this.value ||
  4153. // Deep watchers and watchers on Object/Arrays should fire even
  4154. // when the value is the same, because the value may
  4155. // have mutated.
  4156. isObject(value) ||
  4157. this.deep
  4158. ) {
  4159. // set new value
  4160. const oldValue = this.value;
  4161. this.value = value;
  4162. if (this.user) {
  4163. const info = `callback for watcher "${this.expression}"`;
  4164. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4165. } else {
  4166. this.cb.call(this.vm, value, oldValue);
  4167. }
  4168. }
  4169. }
  4170. }
  4171. /**
  4172. * Evaluate the value of the watcher.
  4173. * This only gets called for lazy watchers.
  4174. */
  4175. evaluate () {
  4176. this.value = this.get();
  4177. this.dirty = false;
  4178. }
  4179. /**
  4180. * Depend on all deps collected by this watcher.
  4181. */
  4182. depend () {
  4183. let i = this.deps.length;
  4184. while (i--) {
  4185. this.deps[i].depend();
  4186. }
  4187. }
  4188. /**
  4189. * Remove self from all dependencies' subscriber list.
  4190. */
  4191. teardown () {
  4192. if (this.active) {
  4193. // remove self from vm's watcher list
  4194. // this is a somewhat expensive operation so we skip it
  4195. // if the vm is being destroyed.
  4196. if (!this.vm._isBeingDestroyed) {
  4197. remove(this.vm._watchers, this);
  4198. }
  4199. let i = this.deps.length;
  4200. while (i--) {
  4201. this.deps[i].removeSub(this);
  4202. }
  4203. this.active = false;
  4204. }
  4205. }
  4206. }
  4207. /* */
  4208. const sharedPropertyDefinition = {
  4209. enumerable: true,
  4210. configurable: true,
  4211. get: noop,
  4212. set: noop
  4213. };
  4214. function proxy (target, sourceKey, key) {
  4215. sharedPropertyDefinition.get = function proxyGetter () {
  4216. return this[sourceKey][key]
  4217. };
  4218. sharedPropertyDefinition.set = function proxySetter (val) {
  4219. this[sourceKey][key] = val;
  4220. };
  4221. Object.defineProperty(target, key, sharedPropertyDefinition);
  4222. }
  4223. function initState (vm) {
  4224. vm._watchers = [];
  4225. const opts = vm.$options;
  4226. if (opts.props) initProps(vm, opts.props);
  4227. if (opts.methods) initMethods(vm, opts.methods);
  4228. if (opts.data) {
  4229. initData(vm);
  4230. } else {
  4231. observe(vm._data = {}, true /* asRootData */);
  4232. }
  4233. if (opts.computed) initComputed(vm, opts.computed);
  4234. if (opts.watch && opts.watch !== nativeWatch) {
  4235. initWatch(vm, opts.watch);
  4236. }
  4237. }
  4238. function initProps (vm, propsOptions) {
  4239. const propsData = vm.$options.propsData || {};
  4240. const props = vm._props = {};
  4241. // cache prop keys so that future props updates can iterate using Array
  4242. // instead of dynamic object key enumeration.
  4243. const keys = vm.$options._propKeys = [];
  4244. const isRoot = !vm.$parent;
  4245. // root instance props should be converted
  4246. if (!isRoot) {
  4247. toggleObserving(false);
  4248. }
  4249. for (const key in propsOptions) {
  4250. keys.push(key);
  4251. const value = validateProp(key, propsOptions, propsData, vm);
  4252. /* istanbul ignore else */
  4253. {
  4254. const hyphenatedKey = hyphenate(key);
  4255. if (isReservedAttribute(hyphenatedKey) ||
  4256. config.isReservedAttr(hyphenatedKey)) {
  4257. warn(
  4258. `"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`,
  4259. vm
  4260. );
  4261. }
  4262. defineReactive$$1(props, key, value, () => {
  4263. if (!isRoot && !isUpdatingChildComponent) {
  4264. warn(
  4265. `Avoid mutating a prop directly since the value will be ` +
  4266. `overwritten whenever the parent component re-renders. ` +
  4267. `Instead, use a data or computed property based on the prop's ` +
  4268. `value. Prop being mutated: "${key}"`,
  4269. vm
  4270. );
  4271. }
  4272. });
  4273. }
  4274. // static props are already proxied on the component's prototype
  4275. // during Vue.extend(). We only need to proxy props defined at
  4276. // instantiation here.
  4277. if (!(key in vm)) {
  4278. proxy(vm, `_props`, key);
  4279. }
  4280. }
  4281. toggleObserving(true);
  4282. }
  4283. function initData (vm) {
  4284. let data = vm.$options.data;
  4285. data = vm._data = typeof data === 'function'
  4286. ? getData(data, vm)
  4287. : data || {};
  4288. if (!isPlainObject(data)) {
  4289. data = {};
  4290. warn(
  4291. 'data functions should return an object:\n' +
  4292. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  4293. vm
  4294. );
  4295. }
  4296. // proxy data on instance
  4297. const keys = Object.keys(data);
  4298. const props = vm.$options.props;
  4299. const methods = vm.$options.methods;
  4300. let i = keys.length;
  4301. while (i--) {
  4302. const key = keys[i];
  4303. {
  4304. if (methods && hasOwn(methods, key)) {
  4305. warn(
  4306. `Method "${key}" has already been defined as a data property.`,
  4307. vm
  4308. );
  4309. }
  4310. }
  4311. if (props && hasOwn(props, key)) {
  4312. warn(
  4313. `The data property "${key}" is already declared as a prop. ` +
  4314. `Use prop default value instead.`,
  4315. vm
  4316. );
  4317. } else if (!isReserved(key)) {
  4318. proxy(vm, `_data`, key);
  4319. }
  4320. }
  4321. // observe data
  4322. observe(data, true /* asRootData */);
  4323. }
  4324. function getData (data, vm) {
  4325. // #7573 disable dep collection when invoking data getters
  4326. pushTarget();
  4327. try {
  4328. return data.call(vm, vm)
  4329. } catch (e) {
  4330. handleError(e, vm, `data()`);
  4331. return {}
  4332. } finally {
  4333. popTarget();
  4334. }
  4335. }
  4336. const computedWatcherOptions = { lazy: true };
  4337. function initComputed (vm, computed) {
  4338. // $flow-disable-line
  4339. const watchers = vm._computedWatchers = Object.create(null);
  4340. // computed properties are just getters during SSR
  4341. const isSSR = isServerRendering();
  4342. for (const key in computed) {
  4343. const userDef = computed[key];
  4344. const getter = typeof userDef === 'function' ? userDef : userDef.get;
  4345. if (getter == null) {
  4346. warn(
  4347. `Getter is missing for computed property "${key}".`,
  4348. vm
  4349. );
  4350. }
  4351. if (!isSSR) {
  4352. // create internal watcher for the computed property.
  4353. watchers[key] = new Watcher(
  4354. vm,
  4355. getter || noop,
  4356. noop,
  4357. computedWatcherOptions
  4358. );
  4359. }
  4360. // component-defined computed properties are already defined on the
  4361. // component prototype. We only need to define computed properties defined
  4362. // at instantiation here.
  4363. if (!(key in vm)) {
  4364. defineComputed(vm, key, userDef);
  4365. } else {
  4366. if (key in vm.$data) {
  4367. warn(`The computed property "${key}" is already defined in data.`, vm);
  4368. } else if (vm.$options.props && key in vm.$options.props) {
  4369. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  4370. } else if (vm.$options.methods && key in vm.$options.methods) {
  4371. warn(`The computed property "${key}" is already defined as a method.`, vm);
  4372. }
  4373. }
  4374. }
  4375. }
  4376. function defineComputed (
  4377. target,
  4378. key,
  4379. userDef
  4380. ) {
  4381. const shouldCache = !isServerRendering();
  4382. if (typeof userDef === 'function') {
  4383. sharedPropertyDefinition.get = shouldCache
  4384. ? createComputedGetter(key)
  4385. : createGetterInvoker(userDef);
  4386. sharedPropertyDefinition.set = noop;
  4387. } else {
  4388. sharedPropertyDefinition.get = userDef.get
  4389. ? shouldCache && userDef.cache !== false
  4390. ? createComputedGetter(key)
  4391. : createGetterInvoker(userDef.get)
  4392. : noop;
  4393. sharedPropertyDefinition.set = userDef.set || noop;
  4394. }
  4395. if (sharedPropertyDefinition.set === noop) {
  4396. sharedPropertyDefinition.set = function () {
  4397. warn(
  4398. `Computed property "${key}" was assigned to but it has no setter.`,
  4399. this
  4400. );
  4401. };
  4402. }
  4403. Object.defineProperty(target, key, sharedPropertyDefinition);
  4404. }
  4405. function createComputedGetter (key) {
  4406. return function computedGetter () {
  4407. const watcher = this._computedWatchers && this._computedWatchers[key];
  4408. if (watcher) {
  4409. if (watcher.dirty) {
  4410. watcher.evaluate();
  4411. }
  4412. if (Dep.target) {
  4413. watcher.depend();
  4414. }
  4415. return watcher.value
  4416. }
  4417. }
  4418. }
  4419. function createGetterInvoker(fn) {
  4420. return function computedGetter () {
  4421. return fn.call(this, this)
  4422. }
  4423. }
  4424. function initMethods (vm, methods) {
  4425. const props = vm.$options.props;
  4426. for (const key in methods) {
  4427. {
  4428. if (typeof methods[key] !== 'function') {
  4429. warn(
  4430. `Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4431. `Did you reference the function correctly?`,
  4432. vm
  4433. );
  4434. }
  4435. if (props && hasOwn(props, key)) {
  4436. warn(
  4437. `Method "${key}" has already been defined as a prop.`,
  4438. vm
  4439. );
  4440. }
  4441. if ((key in vm) && isReserved(key)) {
  4442. warn(
  4443. `Method "${key}" conflicts with an existing Vue instance method. ` +
  4444. `Avoid defining component methods that start with _ or $.`
  4445. );
  4446. }
  4447. }
  4448. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  4449. }
  4450. }
  4451. function initWatch (vm, watch) {
  4452. for (const key in watch) {
  4453. const handler = watch[key];
  4454. if (Array.isArray(handler)) {
  4455. for (let i = 0; i < handler.length; i++) {
  4456. createWatcher(vm, key, handler[i]);
  4457. }
  4458. } else {
  4459. createWatcher(vm, key, handler);
  4460. }
  4461. }
  4462. }
  4463. function createWatcher (
  4464. vm,
  4465. expOrFn,
  4466. handler,
  4467. options
  4468. ) {
  4469. if (isPlainObject(handler)) {
  4470. options = handler;
  4471. handler = handler.handler;
  4472. }
  4473. if (typeof handler === 'string') {
  4474. handler = vm[handler];
  4475. }
  4476. return vm.$watch(expOrFn, handler, options)
  4477. }
  4478. function stateMixin (Vue) {
  4479. // flow somehow has problems with directly declared definition object
  4480. // when using Object.defineProperty, so we have to procedurally build up
  4481. // the object here.
  4482. const dataDef = {};
  4483. dataDef.get = function () { return this._data };
  4484. const propsDef = {};
  4485. propsDef.get = function () { return this._props };
  4486. {
  4487. dataDef.set = function () {
  4488. warn(
  4489. 'Avoid replacing instance root $data. ' +
  4490. 'Use nested data properties instead.',
  4491. this
  4492. );
  4493. };
  4494. propsDef.set = function () {
  4495. warn(`$props is readonly.`, this);
  4496. };
  4497. }
  4498. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4499. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4500. Vue.prototype.$set = set;
  4501. Vue.prototype.$delete = del;
  4502. Vue.prototype.$watch = function (
  4503. expOrFn,
  4504. cb,
  4505. options
  4506. ) {
  4507. const vm = this;
  4508. if (isPlainObject(cb)) {
  4509. return createWatcher(vm, expOrFn, cb, options)
  4510. }
  4511. options = options || {};
  4512. options.user = true;
  4513. const watcher = new Watcher(vm, expOrFn, cb, options);
  4514. if (options.immediate) {
  4515. const info = `callback for immediate watcher "${watcher.expression}"`;
  4516. pushTarget();
  4517. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4518. popTarget();
  4519. }
  4520. return function unwatchFn () {
  4521. watcher.teardown();
  4522. }
  4523. };
  4524. }
  4525. /* */
  4526. let uid$3 = 0;
  4527. function initMixin (Vue) {
  4528. Vue.prototype._init = function (options) {
  4529. const vm = this;
  4530. // a uid
  4531. vm._uid = uid$3++;
  4532. let startTag, endTag;
  4533. /* istanbul ignore if */
  4534. if (config.performance && mark) {
  4535. startTag = `vue-perf-start:${vm._uid}`;
  4536. endTag = `vue-perf-end:${vm._uid}`;
  4537. mark(startTag);
  4538. }
  4539. // a flag to avoid this being observed
  4540. vm._isVue = true;
  4541. // merge options
  4542. if (options && options._isComponent) {
  4543. // optimize internal component instantiation
  4544. // since dynamic options merging is pretty slow, and none of the
  4545. // internal component options needs special treatment.
  4546. initInternalComponent(vm, options);
  4547. } else {
  4548. vm.$options = mergeOptions(
  4549. resolveConstructorOptions(vm.constructor),
  4550. options || {},
  4551. vm
  4552. );
  4553. }
  4554. /* istanbul ignore else */
  4555. {
  4556. initProxy(vm);
  4557. }
  4558. // expose real self
  4559. vm._self = vm;
  4560. initLifecycle(vm);
  4561. initEvents(vm);
  4562. initRender(vm);
  4563. callHook(vm, 'beforeCreate');
  4564. initInjections(vm); // resolve injections before data/props
  4565. initState(vm);
  4566. initProvide(vm); // resolve provide after data/props
  4567. callHook(vm, 'created');
  4568. /* istanbul ignore if */
  4569. if (config.performance && mark) {
  4570. vm._name = formatComponentName(vm, false);
  4571. mark(endTag);
  4572. measure(`vue ${vm._name} init`, startTag, endTag);
  4573. }
  4574. if (vm.$options.el) {
  4575. vm.$mount(vm.$options.el);
  4576. }
  4577. };
  4578. }
  4579. function initInternalComponent (vm, options) {
  4580. const opts = vm.$options = Object.create(vm.constructor.options);
  4581. // doing this because it's faster than dynamic enumeration.
  4582. const parentVnode = options._parentVnode;
  4583. opts.parent = options.parent;
  4584. opts._parentVnode = parentVnode;
  4585. const vnodeComponentOptions = parentVnode.componentOptions;
  4586. opts.propsData = vnodeComponentOptions.propsData;
  4587. opts._parentListeners = vnodeComponentOptions.listeners;
  4588. opts._renderChildren = vnodeComponentOptions.children;
  4589. opts._componentTag = vnodeComponentOptions.tag;
  4590. if (options.render) {
  4591. opts.render = options.render;
  4592. opts.staticRenderFns = options.staticRenderFns;
  4593. }
  4594. }
  4595. function resolveConstructorOptions (Ctor) {
  4596. let options = Ctor.options;
  4597. if (Ctor.super) {
  4598. const superOptions = resolveConstructorOptions(Ctor.super);
  4599. const cachedSuperOptions = Ctor.superOptions;
  4600. if (superOptions !== cachedSuperOptions) {
  4601. // super option changed,
  4602. // need to resolve new options.
  4603. Ctor.superOptions = superOptions;
  4604. // check if there are any late-modified/attached options (#4976)
  4605. const modifiedOptions = resolveModifiedOptions(Ctor);
  4606. // update base extend options
  4607. if (modifiedOptions) {
  4608. extend(Ctor.extendOptions, modifiedOptions);
  4609. }
  4610. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4611. if (options.name) {
  4612. options.components[options.name] = Ctor;
  4613. }
  4614. }
  4615. }
  4616. return options
  4617. }
  4618. function resolveModifiedOptions (Ctor) {
  4619. let modified;
  4620. const latest = Ctor.options;
  4621. const sealed = Ctor.sealedOptions;
  4622. for (const key in latest) {
  4623. if (latest[key] !== sealed[key]) {
  4624. if (!modified) modified = {};
  4625. modified[key] = latest[key];
  4626. }
  4627. }
  4628. return modified
  4629. }
  4630. function Vue (options) {
  4631. if (!(this instanceof Vue)
  4632. ) {
  4633. warn('Vue is a constructor and should be called with the `new` keyword');
  4634. }
  4635. this._init(options);
  4636. }
  4637. initMixin(Vue);
  4638. stateMixin(Vue);
  4639. eventsMixin(Vue);
  4640. lifecycleMixin(Vue);
  4641. renderMixin(Vue);
  4642. /* */
  4643. function initUse (Vue) {
  4644. Vue.use = function (plugin) {
  4645. const installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4646. if (installedPlugins.indexOf(plugin) > -1) {
  4647. return this
  4648. }
  4649. // additional parameters
  4650. const args = toArray(arguments, 1);
  4651. args.unshift(this);
  4652. if (typeof plugin.install === 'function') {
  4653. plugin.install.apply(plugin, args);
  4654. } else if (typeof plugin === 'function') {
  4655. plugin.apply(null, args);
  4656. }
  4657. installedPlugins.push(plugin);
  4658. return this
  4659. };
  4660. }
  4661. /* */
  4662. function initMixin$1 (Vue) {
  4663. Vue.mixin = function (mixin) {
  4664. this.options = mergeOptions(this.options, mixin);
  4665. return this
  4666. };
  4667. }
  4668. /* */
  4669. function initExtend (Vue) {
  4670. /**
  4671. * Each instance constructor, including Vue, has a unique
  4672. * cid. This enables us to create wrapped "child
  4673. * constructors" for prototypal inheritance and cache them.
  4674. */
  4675. Vue.cid = 0;
  4676. let cid = 1;
  4677. /**
  4678. * Class inheritance
  4679. */
  4680. Vue.extend = function (extendOptions) {
  4681. extendOptions = extendOptions || {};
  4682. const Super = this;
  4683. const SuperId = Super.cid;
  4684. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4685. if (cachedCtors[SuperId]) {
  4686. return cachedCtors[SuperId]
  4687. }
  4688. const name = extendOptions.name || Super.options.name;
  4689. if (name) {
  4690. validateComponentName(name);
  4691. }
  4692. const Sub = function VueComponent (options) {
  4693. this._init(options);
  4694. };
  4695. Sub.prototype = Object.create(Super.prototype);
  4696. Sub.prototype.constructor = Sub;
  4697. Sub.cid = cid++;
  4698. Sub.options = mergeOptions(
  4699. Super.options,
  4700. extendOptions
  4701. );
  4702. Sub['super'] = Super;
  4703. // For props and computed properties, we define the proxy getters on
  4704. // the Vue instances at extension time, on the extended prototype. This
  4705. // avoids Object.defineProperty calls for each instance created.
  4706. if (Sub.options.props) {
  4707. initProps$1(Sub);
  4708. }
  4709. if (Sub.options.computed) {
  4710. initComputed$1(Sub);
  4711. }
  4712. // allow further extension/mixin/plugin usage
  4713. Sub.extend = Super.extend;
  4714. Sub.mixin = Super.mixin;
  4715. Sub.use = Super.use;
  4716. // create asset registers, so extended classes
  4717. // can have their private assets too.
  4718. ASSET_TYPES.forEach(function (type) {
  4719. Sub[type] = Super[type];
  4720. });
  4721. // enable recursive self-lookup
  4722. if (name) {
  4723. Sub.options.components[name] = Sub;
  4724. }
  4725. // keep a reference to the super options at extension time.
  4726. // later at instantiation we can check if Super's options have
  4727. // been updated.
  4728. Sub.superOptions = Super.options;
  4729. Sub.extendOptions = extendOptions;
  4730. Sub.sealedOptions = extend({}, Sub.options);
  4731. // cache constructor
  4732. cachedCtors[SuperId] = Sub;
  4733. return Sub
  4734. };
  4735. }
  4736. function initProps$1 (Comp) {
  4737. const props = Comp.options.props;
  4738. for (const key in props) {
  4739. proxy(Comp.prototype, `_props`, key);
  4740. }
  4741. }
  4742. function initComputed$1 (Comp) {
  4743. const computed = Comp.options.computed;
  4744. for (const key in computed) {
  4745. defineComputed(Comp.prototype, key, computed[key]);
  4746. }
  4747. }
  4748. /* */
  4749. function initAssetRegisters (Vue) {
  4750. /**
  4751. * Create asset registration methods.
  4752. */
  4753. ASSET_TYPES.forEach(type => {
  4754. Vue[type] = function (
  4755. id,
  4756. definition
  4757. ) {
  4758. if (!definition) {
  4759. return this.options[type + 's'][id]
  4760. } else {
  4761. /* istanbul ignore if */
  4762. if (type === 'component') {
  4763. validateComponentName(id);
  4764. }
  4765. if (type === 'component' && isPlainObject(definition)) {
  4766. definition.name = definition.name || id;
  4767. definition = this.options._base.extend(definition);
  4768. }
  4769. if (type === 'directive' && typeof definition === 'function') {
  4770. definition = { bind: definition, update: definition };
  4771. }
  4772. this.options[type + 's'][id] = definition;
  4773. return definition
  4774. }
  4775. };
  4776. });
  4777. }
  4778. /* */
  4779. function getComponentName (opts) {
  4780. return opts && (opts.Ctor.options.name || opts.tag)
  4781. }
  4782. function matches (pattern, name) {
  4783. if (Array.isArray(pattern)) {
  4784. return pattern.indexOf(name) > -1
  4785. } else if (typeof pattern === 'string') {
  4786. return pattern.split(',').indexOf(name) > -1
  4787. } else if (isRegExp(pattern)) {
  4788. return pattern.test(name)
  4789. }
  4790. /* istanbul ignore next */
  4791. return false
  4792. }
  4793. function pruneCache (keepAliveInstance, filter) {
  4794. const { cache, keys, _vnode } = keepAliveInstance;
  4795. for (const key in cache) {
  4796. const entry = cache[key];
  4797. if (entry) {
  4798. const name = entry.name;
  4799. if (name && !filter(name)) {
  4800. pruneCacheEntry(cache, key, keys, _vnode);
  4801. }
  4802. }
  4803. }
  4804. }
  4805. function pruneCacheEntry (
  4806. cache,
  4807. key,
  4808. keys,
  4809. current
  4810. ) {
  4811. const entry = cache[key];
  4812. if (entry && (!current || entry.tag !== current.tag)) {
  4813. entry.componentInstance.$destroy();
  4814. }
  4815. cache[key] = null;
  4816. remove(keys, key);
  4817. }
  4818. const patternTypes = [String, RegExp, Array];
  4819. var KeepAlive = {
  4820. name: 'keep-alive',
  4821. abstract: true,
  4822. props: {
  4823. include: patternTypes,
  4824. exclude: patternTypes,
  4825. max: [String, Number]
  4826. },
  4827. methods: {
  4828. cacheVNode() {
  4829. const { cache, keys, vnodeToCache, keyToCache } = this;
  4830. if (vnodeToCache) {
  4831. const { tag, componentInstance, componentOptions } = vnodeToCache;
  4832. cache[keyToCache] = {
  4833. name: getComponentName(componentOptions),
  4834. tag,
  4835. componentInstance,
  4836. };
  4837. keys.push(keyToCache);
  4838. // prune oldest entry
  4839. if (this.max && keys.length > parseInt(this.max)) {
  4840. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4841. }
  4842. this.vnodeToCache = null;
  4843. }
  4844. }
  4845. },
  4846. created () {
  4847. this.cache = Object.create(null);
  4848. this.keys = [];
  4849. },
  4850. destroyed () {
  4851. for (const key in this.cache) {
  4852. pruneCacheEntry(this.cache, key, this.keys);
  4853. }
  4854. },
  4855. mounted () {
  4856. this.cacheVNode();
  4857. this.$watch('include', val => {
  4858. pruneCache(this, name => matches(val, name));
  4859. });
  4860. this.$watch('exclude', val => {
  4861. pruneCache(this, name => !matches(val, name));
  4862. });
  4863. },
  4864. updated () {
  4865. this.cacheVNode();
  4866. },
  4867. render () {
  4868. const slot = this.$slots.default;
  4869. const vnode = getFirstComponentChild(slot);
  4870. const componentOptions = vnode && vnode.componentOptions;
  4871. if (componentOptions) {
  4872. // check pattern
  4873. const name = getComponentName(componentOptions);
  4874. const { include, exclude } = this;
  4875. if (
  4876. // not included
  4877. (include && (!name || !matches(include, name))) ||
  4878. // excluded
  4879. (exclude && name && matches(exclude, name))
  4880. ) {
  4881. return vnode
  4882. }
  4883. const { cache, keys } = this;
  4884. const key = vnode.key == null
  4885. // same constructor may get registered as different local components
  4886. // so cid alone is not enough (#3269)
  4887. ? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
  4888. : vnode.key;
  4889. if (cache[key]) {
  4890. vnode.componentInstance = cache[key].componentInstance;
  4891. // make current key freshest
  4892. remove(keys, key);
  4893. keys.push(key);
  4894. } else {
  4895. // delay setting the cache until update
  4896. this.vnodeToCache = vnode;
  4897. this.keyToCache = key;
  4898. }
  4899. vnode.data.keepAlive = true;
  4900. }
  4901. return vnode || (slot && slot[0])
  4902. }
  4903. };
  4904. var builtInComponents = {
  4905. KeepAlive
  4906. };
  4907. /* */
  4908. function initGlobalAPI (Vue) {
  4909. // config
  4910. const configDef = {};
  4911. configDef.get = () => config;
  4912. {
  4913. configDef.set = () => {
  4914. warn(
  4915. 'Do not replace the Vue.config object, set individual fields instead.'
  4916. );
  4917. };
  4918. }
  4919. Object.defineProperty(Vue, 'config', configDef);
  4920. // exposed util methods.
  4921. // NOTE: these are not considered part of the public API - avoid relying on
  4922. // them unless you are aware of the risk.
  4923. Vue.util = {
  4924. warn,
  4925. extend,
  4926. mergeOptions,
  4927. defineReactive: defineReactive$$1
  4928. };
  4929. Vue.set = set;
  4930. Vue.delete = del;
  4931. Vue.nextTick = nextTick;
  4932. // 2.6 explicit observable API
  4933. Vue.observable = (obj) => {
  4934. observe(obj);
  4935. return obj
  4936. };
  4937. Vue.options = Object.create(null);
  4938. ASSET_TYPES.forEach(type => {
  4939. Vue.options[type + 's'] = Object.create(null);
  4940. });
  4941. // this is used to identify the "base" constructor to extend all plain-object
  4942. // components with in Weex's multi-instance scenarios.
  4943. Vue.options._base = Vue;
  4944. extend(Vue.options.components, builtInComponents);
  4945. initUse(Vue);
  4946. initMixin$1(Vue);
  4947. initExtend(Vue);
  4948. initAssetRegisters(Vue);
  4949. }
  4950. initGlobalAPI(Vue);
  4951. Object.defineProperty(Vue.prototype, '$isServer', {
  4952. get: isServerRendering
  4953. });
  4954. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4955. get () {
  4956. /* istanbul ignore next */
  4957. return this.$vnode && this.$vnode.ssrContext
  4958. }
  4959. });
  4960. // expose FunctionalRenderContext for ssr runtime helper installation
  4961. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4962. value: FunctionalRenderContext
  4963. });
  4964. Vue.version = '2.6.14';
  4965. /* */
  4966. // these are reserved for web because they are directly compiled away
  4967. // during template compilation
  4968. const isReservedAttr = makeMap('style,class');
  4969. // attributes that should be using props for binding
  4970. const acceptValue = makeMap('input,textarea,option,select,progress');
  4971. const mustUseProp = (tag, type, attr) => {
  4972. return (
  4973. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4974. (attr === 'selected' && tag === 'option') ||
  4975. (attr === 'checked' && tag === 'input') ||
  4976. (attr === 'muted' && tag === 'video')
  4977. )
  4978. };
  4979. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4980. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  4981. const convertEnumeratedValue = (key, value) => {
  4982. return isFalsyAttrValue(value) || value === 'false'
  4983. ? 'false'
  4984. // allow arbitrary string value for contenteditable
  4985. : key === 'contenteditable' && isValidContentEditableValue(value)
  4986. ? value
  4987. : 'true'
  4988. };
  4989. const isBooleanAttr = makeMap(
  4990. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  4991. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  4992. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  4993. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  4994. 'required,reversed,scoped,seamless,selected,sortable,' +
  4995. 'truespeed,typemustmatch,visible'
  4996. );
  4997. const xlinkNS = 'http://www.w3.org/1999/xlink';
  4998. const isXlink = (name) => {
  4999. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  5000. };
  5001. const getXlinkProp = (name) => {
  5002. return isXlink(name) ? name.slice(6, name.length) : ''
  5003. };
  5004. const isFalsyAttrValue = (val) => {
  5005. return val == null || val === false
  5006. };
  5007. /* */
  5008. function genClassForVnode (vnode) {
  5009. let data = vnode.data;
  5010. let parentNode = vnode;
  5011. let childNode = vnode;
  5012. while (isDef(childNode.componentInstance)) {
  5013. childNode = childNode.componentInstance._vnode;
  5014. if (childNode && childNode.data) {
  5015. data = mergeClassData(childNode.data, data);
  5016. }
  5017. }
  5018. while (isDef(parentNode = parentNode.parent)) {
  5019. if (parentNode && parentNode.data) {
  5020. data = mergeClassData(data, parentNode.data);
  5021. }
  5022. }
  5023. return renderClass(data.staticClass, data.class)
  5024. }
  5025. function mergeClassData (child, parent) {
  5026. return {
  5027. staticClass: concat(child.staticClass, parent.staticClass),
  5028. class: isDef(child.class)
  5029. ? [child.class, parent.class]
  5030. : parent.class
  5031. }
  5032. }
  5033. function renderClass (
  5034. staticClass,
  5035. dynamicClass
  5036. ) {
  5037. if (isDef(staticClass) || isDef(dynamicClass)) {
  5038. return concat(staticClass, stringifyClass(dynamicClass))
  5039. }
  5040. /* istanbul ignore next */
  5041. return ''
  5042. }
  5043. function concat (a, b) {
  5044. return a ? b ? (a + ' ' + b) : a : (b || '')
  5045. }
  5046. function stringifyClass (value) {
  5047. if (Array.isArray(value)) {
  5048. return stringifyArray(value)
  5049. }
  5050. if (isObject(value)) {
  5051. return stringifyObject(value)
  5052. }
  5053. if (typeof value === 'string') {
  5054. return value
  5055. }
  5056. /* istanbul ignore next */
  5057. return ''
  5058. }
  5059. function stringifyArray (value) {
  5060. let res = '';
  5061. let stringified;
  5062. for (let i = 0, l = value.length; i < l; i++) {
  5063. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  5064. if (res) res += ' ';
  5065. res += stringified;
  5066. }
  5067. }
  5068. return res
  5069. }
  5070. function stringifyObject (value) {
  5071. let res = '';
  5072. for (const key in value) {
  5073. if (value[key]) {
  5074. if (res) res += ' ';
  5075. res += key;
  5076. }
  5077. }
  5078. return res
  5079. }
  5080. /* */
  5081. const namespaceMap = {
  5082. svg: 'http://www.w3.org/2000/svg',
  5083. math: 'http://www.w3.org/1998/Math/MathML'
  5084. };
  5085. const isHTMLTag = makeMap(
  5086. 'html,body,base,head,link,meta,style,title,' +
  5087. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5088. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5089. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5090. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5091. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5092. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5093. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5094. 'output,progress,select,textarea,' +
  5095. 'details,dialog,menu,menuitem,summary,' +
  5096. 'content,element,shadow,template,blockquote,iframe,tfoot'
  5097. );
  5098. // this map is intentionally selective, only covering SVG elements that may
  5099. // contain child elements.
  5100. const isSVG = makeMap(
  5101. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5102. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5103. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  5104. true
  5105. );
  5106. const isPreTag = (tag) => tag === 'pre';
  5107. const isReservedTag = (tag) => {
  5108. return isHTMLTag(tag) || isSVG(tag)
  5109. };
  5110. function getTagNamespace (tag) {
  5111. if (isSVG(tag)) {
  5112. return 'svg'
  5113. }
  5114. // basic support for MathML
  5115. // note it doesn't support other MathML elements being component roots
  5116. if (tag === 'math') {
  5117. return 'math'
  5118. }
  5119. }
  5120. const unknownElementCache = Object.create(null);
  5121. function isUnknownElement (tag) {
  5122. /* istanbul ignore if */
  5123. if (!inBrowser) {
  5124. return true
  5125. }
  5126. if (isReservedTag(tag)) {
  5127. return false
  5128. }
  5129. tag = tag.toLowerCase();
  5130. /* istanbul ignore if */
  5131. if (unknownElementCache[tag] != null) {
  5132. return unknownElementCache[tag]
  5133. }
  5134. const el = document.createElement(tag);
  5135. if (tag.indexOf('-') > -1) {
  5136. // http://stackoverflow.com/a/28210364/1070244
  5137. return (unknownElementCache[tag] = (
  5138. el.constructor === window.HTMLUnknownElement ||
  5139. el.constructor === window.HTMLElement
  5140. ))
  5141. } else {
  5142. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  5143. }
  5144. }
  5145. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  5146. /* */
  5147. /**
  5148. * Query an element selector if it's not an element already.
  5149. */
  5150. function query (el) {
  5151. if (typeof el === 'string') {
  5152. const selected = document.querySelector(el);
  5153. if (!selected) {
  5154. warn(
  5155. 'Cannot find element: ' + el
  5156. );
  5157. return document.createElement('div')
  5158. }
  5159. return selected
  5160. } else {
  5161. return el
  5162. }
  5163. }
  5164. /* */
  5165. function createElement$1 (tagName, vnode) {
  5166. const elm = document.createElement(tagName);
  5167. if (tagName !== 'select') {
  5168. return elm
  5169. }
  5170. // false or null will remove the attribute but undefined will not
  5171. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  5172. elm.setAttribute('multiple', 'multiple');
  5173. }
  5174. return elm
  5175. }
  5176. function createElementNS (namespace, tagName) {
  5177. return document.createElementNS(namespaceMap[namespace], tagName)
  5178. }
  5179. function createTextNode (text) {
  5180. return document.createTextNode(text)
  5181. }
  5182. function createComment (text) {
  5183. return document.createComment(text)
  5184. }
  5185. function insertBefore (parentNode, newNode, referenceNode) {
  5186. parentNode.insertBefore(newNode, referenceNode);
  5187. }
  5188. function removeChild (node, child) {
  5189. node.removeChild(child);
  5190. }
  5191. function appendChild (node, child) {
  5192. node.appendChild(child);
  5193. }
  5194. function parentNode (node) {
  5195. return node.parentNode
  5196. }
  5197. function nextSibling (node) {
  5198. return node.nextSibling
  5199. }
  5200. function tagName (node) {
  5201. return node.tagName
  5202. }
  5203. function setTextContent (node, text) {
  5204. node.textContent = text;
  5205. }
  5206. function setStyleScope (node, scopeId) {
  5207. node.setAttribute(scopeId, '');
  5208. }
  5209. var nodeOps = /*#__PURE__*/Object.freeze({
  5210. createElement: createElement$1,
  5211. createElementNS: createElementNS,
  5212. createTextNode: createTextNode,
  5213. createComment: createComment,
  5214. insertBefore: insertBefore,
  5215. removeChild: removeChild,
  5216. appendChild: appendChild,
  5217. parentNode: parentNode,
  5218. nextSibling: nextSibling,
  5219. tagName: tagName,
  5220. setTextContent: setTextContent,
  5221. setStyleScope: setStyleScope
  5222. });
  5223. /* */
  5224. var ref = {
  5225. create (_, vnode) {
  5226. registerRef(vnode);
  5227. },
  5228. update (oldVnode, vnode) {
  5229. if (oldVnode.data.ref !== vnode.data.ref) {
  5230. registerRef(oldVnode, true);
  5231. registerRef(vnode);
  5232. }
  5233. },
  5234. destroy (vnode) {
  5235. registerRef(vnode, true);
  5236. }
  5237. };
  5238. function registerRef (vnode, isRemoval) {
  5239. const key = vnode.data.ref;
  5240. if (!isDef(key)) return
  5241. const vm = vnode.context;
  5242. const ref = vnode.componentInstance || vnode.elm;
  5243. const refs = vm.$refs;
  5244. if (isRemoval) {
  5245. if (Array.isArray(refs[key])) {
  5246. remove(refs[key], ref);
  5247. } else if (refs[key] === ref) {
  5248. refs[key] = undefined;
  5249. }
  5250. } else {
  5251. if (vnode.data.refInFor) {
  5252. if (!Array.isArray(refs[key])) {
  5253. refs[key] = [ref];
  5254. } else if (refs[key].indexOf(ref) < 0) {
  5255. // $flow-disable-line
  5256. refs[key].push(ref);
  5257. }
  5258. } else {
  5259. refs[key] = ref;
  5260. }
  5261. }
  5262. }
  5263. /**
  5264. * Virtual DOM patching algorithm based on Snabbdom by
  5265. * Simon Friis Vindum (@paldepind)
  5266. * Licensed under the MIT License
  5267. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  5268. *
  5269. * modified by Evan You (@yyx990803)
  5270. *
  5271. * Not type-checking this because this file is perf-critical and the cost
  5272. * of making flow understand it is not worth it.
  5273. */
  5274. const emptyNode = new VNode('', {}, []);
  5275. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  5276. function sameVnode (a, b) {
  5277. return (
  5278. a.key === b.key &&
  5279. a.asyncFactory === b.asyncFactory && (
  5280. (
  5281. a.tag === b.tag &&
  5282. a.isComment === b.isComment &&
  5283. isDef(a.data) === isDef(b.data) &&
  5284. sameInputType(a, b)
  5285. ) || (
  5286. isTrue(a.isAsyncPlaceholder) &&
  5287. isUndef(b.asyncFactory.error)
  5288. )
  5289. )
  5290. )
  5291. }
  5292. function sameInputType (a, b) {
  5293. if (a.tag !== 'input') return true
  5294. let i;
  5295. const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5296. const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5297. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5298. }
  5299. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5300. let i, key;
  5301. const map = {};
  5302. for (i = beginIdx; i <= endIdx; ++i) {
  5303. key = children[i].key;
  5304. if (isDef(key)) map[key] = i;
  5305. }
  5306. return map
  5307. }
  5308. function createPatchFunction (backend) {
  5309. let i, j;
  5310. const cbs = {};
  5311. const { modules, nodeOps } = backend;
  5312. for (i = 0; i < hooks.length; ++i) {
  5313. cbs[hooks[i]] = [];
  5314. for (j = 0; j < modules.length; ++j) {
  5315. if (isDef(modules[j][hooks[i]])) {
  5316. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5317. }
  5318. }
  5319. }
  5320. function emptyNodeAt (elm) {
  5321. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5322. }
  5323. function createRmCb (childElm, listeners) {
  5324. function remove$$1 () {
  5325. if (--remove$$1.listeners === 0) {
  5326. removeNode(childElm);
  5327. }
  5328. }
  5329. remove$$1.listeners = listeners;
  5330. return remove$$1
  5331. }
  5332. function removeNode (el) {
  5333. const parent = nodeOps.parentNode(el);
  5334. // element may have already been removed due to v-html / v-text
  5335. if (isDef(parent)) {
  5336. nodeOps.removeChild(parent, el);
  5337. }
  5338. }
  5339. function isUnknownElement$$1 (vnode, inVPre) {
  5340. return (
  5341. !inVPre &&
  5342. !vnode.ns &&
  5343. !(
  5344. config.ignoredElements.length &&
  5345. config.ignoredElements.some(ignore => {
  5346. return isRegExp(ignore)
  5347. ? ignore.test(vnode.tag)
  5348. : ignore === vnode.tag
  5349. })
  5350. ) &&
  5351. config.isUnknownElement(vnode.tag)
  5352. )
  5353. }
  5354. let creatingElmInVPre = 0;
  5355. function createElm (
  5356. vnode,
  5357. insertedVnodeQueue,
  5358. parentElm,
  5359. refElm,
  5360. nested,
  5361. ownerArray,
  5362. index
  5363. ) {
  5364. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5365. // This vnode was used in a previous render!
  5366. // now it's used as a new node, overwriting its elm would cause
  5367. // potential patch errors down the road when it's used as an insertion
  5368. // reference node. Instead, we clone the node on-demand before creating
  5369. // associated DOM element for it.
  5370. vnode = ownerArray[index] = cloneVNode(vnode);
  5371. }
  5372. vnode.isRootInsert = !nested; // for transition enter check
  5373. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5374. return
  5375. }
  5376. const data = vnode.data;
  5377. const children = vnode.children;
  5378. const tag = vnode.tag;
  5379. if (isDef(tag)) {
  5380. {
  5381. if (data && data.pre) {
  5382. creatingElmInVPre++;
  5383. }
  5384. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5385. warn(
  5386. 'Unknown custom element: <' + tag + '> - did you ' +
  5387. 'register the component correctly? For recursive components, ' +
  5388. 'make sure to provide the "name" option.',
  5389. vnode.context
  5390. );
  5391. }
  5392. }
  5393. vnode.elm = vnode.ns
  5394. ? nodeOps.createElementNS(vnode.ns, tag)
  5395. : nodeOps.createElement(tag, vnode);
  5396. setScope(vnode);
  5397. /* istanbul ignore if */
  5398. {
  5399. createChildren(vnode, children, insertedVnodeQueue);
  5400. if (isDef(data)) {
  5401. invokeCreateHooks(vnode, insertedVnodeQueue);
  5402. }
  5403. insert(parentElm, vnode.elm, refElm);
  5404. }
  5405. if (data && data.pre) {
  5406. creatingElmInVPre--;
  5407. }
  5408. } else if (isTrue(vnode.isComment)) {
  5409. vnode.elm = nodeOps.createComment(vnode.text);
  5410. insert(parentElm, vnode.elm, refElm);
  5411. } else {
  5412. vnode.elm = nodeOps.createTextNode(vnode.text);
  5413. insert(parentElm, vnode.elm, refElm);
  5414. }
  5415. }
  5416. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5417. let i = vnode.data;
  5418. if (isDef(i)) {
  5419. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5420. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5421. i(vnode, false /* hydrating */);
  5422. }
  5423. // after calling the init hook, if the vnode is a child component
  5424. // it should've created a child instance and mounted it. the child
  5425. // component also has set the placeholder vnode's elm.
  5426. // in that case we can just return the element and be done.
  5427. if (isDef(vnode.componentInstance)) {
  5428. initComponent(vnode, insertedVnodeQueue);
  5429. insert(parentElm, vnode.elm, refElm);
  5430. if (isTrue(isReactivated)) {
  5431. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5432. }
  5433. return true
  5434. }
  5435. }
  5436. }
  5437. function initComponent (vnode, insertedVnodeQueue) {
  5438. if (isDef(vnode.data.pendingInsert)) {
  5439. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5440. vnode.data.pendingInsert = null;
  5441. }
  5442. vnode.elm = vnode.componentInstance.$el;
  5443. if (isPatchable(vnode)) {
  5444. invokeCreateHooks(vnode, insertedVnodeQueue);
  5445. setScope(vnode);
  5446. } else {
  5447. // empty component root.
  5448. // skip all element-related modules except for ref (#3455)
  5449. registerRef(vnode);
  5450. // make sure to invoke the insert hook
  5451. insertedVnodeQueue.push(vnode);
  5452. }
  5453. }
  5454. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5455. let i;
  5456. // hack for #4339: a reactivated component with inner transition
  5457. // does not trigger because the inner node's created hooks are not called
  5458. // again. It's not ideal to involve module-specific logic in here but
  5459. // there doesn't seem to be a better way to do it.
  5460. let innerNode = vnode;
  5461. while (innerNode.componentInstance) {
  5462. innerNode = innerNode.componentInstance._vnode;
  5463. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5464. for (i = 0; i < cbs.activate.length; ++i) {
  5465. cbs.activate[i](emptyNode, innerNode);
  5466. }
  5467. insertedVnodeQueue.push(innerNode);
  5468. break
  5469. }
  5470. }
  5471. // unlike a newly created component,
  5472. // a reactivated keep-alive component doesn't insert itself
  5473. insert(parentElm, vnode.elm, refElm);
  5474. }
  5475. function insert (parent, elm, ref$$1) {
  5476. if (isDef(parent)) {
  5477. if (isDef(ref$$1)) {
  5478. if (nodeOps.parentNode(ref$$1) === parent) {
  5479. nodeOps.insertBefore(parent, elm, ref$$1);
  5480. }
  5481. } else {
  5482. nodeOps.appendChild(parent, elm);
  5483. }
  5484. }
  5485. }
  5486. function createChildren (vnode, children, insertedVnodeQueue) {
  5487. if (Array.isArray(children)) {
  5488. {
  5489. checkDuplicateKeys(children);
  5490. }
  5491. for (let i = 0; i < children.length; ++i) {
  5492. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5493. }
  5494. } else if (isPrimitive(vnode.text)) {
  5495. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5496. }
  5497. }
  5498. function isPatchable (vnode) {
  5499. while (vnode.componentInstance) {
  5500. vnode = vnode.componentInstance._vnode;
  5501. }
  5502. return isDef(vnode.tag)
  5503. }
  5504. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5505. for (let i = 0; i < cbs.create.length; ++i) {
  5506. cbs.create[i](emptyNode, vnode);
  5507. }
  5508. i = vnode.data.hook; // Reuse variable
  5509. if (isDef(i)) {
  5510. if (isDef(i.create)) i.create(emptyNode, vnode);
  5511. if (isDef(i.insert)) insertedVnodeQueue.push(vnode);
  5512. }
  5513. }
  5514. // set scope id attribute for scoped CSS.
  5515. // this is implemented as a special case to avoid the overhead
  5516. // of going through the normal attribute patching process.
  5517. function setScope (vnode) {
  5518. let i;
  5519. if (isDef(i = vnode.fnScopeId)) {
  5520. nodeOps.setStyleScope(vnode.elm, i);
  5521. } else {
  5522. let ancestor = vnode;
  5523. while (ancestor) {
  5524. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5525. nodeOps.setStyleScope(vnode.elm, i);
  5526. }
  5527. ancestor = ancestor.parent;
  5528. }
  5529. }
  5530. // for slot content they should also get the scopeId from the host instance.
  5531. if (isDef(i = activeInstance) &&
  5532. i !== vnode.context &&
  5533. i !== vnode.fnContext &&
  5534. isDef(i = i.$options._scopeId)
  5535. ) {
  5536. nodeOps.setStyleScope(vnode.elm, i);
  5537. }
  5538. }
  5539. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5540. for (; startIdx <= endIdx; ++startIdx) {
  5541. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5542. }
  5543. }
  5544. function invokeDestroyHook (vnode) {
  5545. let i, j;
  5546. const data = vnode.data;
  5547. if (isDef(data)) {
  5548. if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
  5549. for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);
  5550. }
  5551. if (isDef(i = vnode.children)) {
  5552. for (j = 0; j < vnode.children.length; ++j) {
  5553. invokeDestroyHook(vnode.children[j]);
  5554. }
  5555. }
  5556. }
  5557. function removeVnodes (vnodes, startIdx, endIdx) {
  5558. for (; startIdx <= endIdx; ++startIdx) {
  5559. const ch = vnodes[startIdx];
  5560. if (isDef(ch)) {
  5561. if (isDef(ch.tag)) {
  5562. removeAndInvokeRemoveHook(ch);
  5563. invokeDestroyHook(ch);
  5564. } else { // Text node
  5565. removeNode(ch.elm);
  5566. }
  5567. }
  5568. }
  5569. }
  5570. function removeAndInvokeRemoveHook (vnode, rm) {
  5571. if (isDef(rm) || isDef(vnode.data)) {
  5572. let i;
  5573. const listeners = cbs.remove.length + 1;
  5574. if (isDef(rm)) {
  5575. // we have a recursively passed down rm callback
  5576. // increase the listeners count
  5577. rm.listeners += listeners;
  5578. } else {
  5579. // directly removing
  5580. rm = createRmCb(vnode.elm, listeners);
  5581. }
  5582. // recursively invoke hooks on child component root node
  5583. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5584. removeAndInvokeRemoveHook(i, rm);
  5585. }
  5586. for (i = 0; i < cbs.remove.length; ++i) {
  5587. cbs.remove[i](vnode, rm);
  5588. }
  5589. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5590. i(vnode, rm);
  5591. } else {
  5592. rm();
  5593. }
  5594. } else {
  5595. removeNode(vnode.elm);
  5596. }
  5597. }
  5598. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5599. let oldStartIdx = 0;
  5600. let newStartIdx = 0;
  5601. let oldEndIdx = oldCh.length - 1;
  5602. let oldStartVnode = oldCh[0];
  5603. let oldEndVnode = oldCh[oldEndIdx];
  5604. let newEndIdx = newCh.length - 1;
  5605. let newStartVnode = newCh[0];
  5606. let newEndVnode = newCh[newEndIdx];
  5607. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5608. // removeOnly is a special flag used only by <transition-group>
  5609. // to ensure removed elements stay in correct relative positions
  5610. // during leaving transitions
  5611. const canMove = !removeOnly;
  5612. {
  5613. checkDuplicateKeys(newCh);
  5614. }
  5615. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5616. if (isUndef(oldStartVnode)) {
  5617. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5618. } else if (isUndef(oldEndVnode)) {
  5619. oldEndVnode = oldCh[--oldEndIdx];
  5620. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5621. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5622. oldStartVnode = oldCh[++oldStartIdx];
  5623. newStartVnode = newCh[++newStartIdx];
  5624. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5625. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5626. oldEndVnode = oldCh[--oldEndIdx];
  5627. newEndVnode = newCh[--newEndIdx];
  5628. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5629. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5630. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5631. oldStartVnode = oldCh[++oldStartIdx];
  5632. newEndVnode = newCh[--newEndIdx];
  5633. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5634. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5635. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5636. oldEndVnode = oldCh[--oldEndIdx];
  5637. newStartVnode = newCh[++newStartIdx];
  5638. } else {
  5639. if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  5640. idxInOld = isDef(newStartVnode.key)
  5641. ? oldKeyToIdx[newStartVnode.key]
  5642. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5643. if (isUndef(idxInOld)) { // New element
  5644. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5645. } else {
  5646. vnodeToMove = oldCh[idxInOld];
  5647. if (sameVnode(vnodeToMove, newStartVnode)) {
  5648. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5649. oldCh[idxInOld] = undefined;
  5650. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5651. } else {
  5652. // same key but different element. treat as new element
  5653. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5654. }
  5655. }
  5656. newStartVnode = newCh[++newStartIdx];
  5657. }
  5658. }
  5659. if (oldStartIdx > oldEndIdx) {
  5660. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5661. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5662. } else if (newStartIdx > newEndIdx) {
  5663. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  5664. }
  5665. }
  5666. function checkDuplicateKeys (children) {
  5667. const seenKeys = {};
  5668. for (let i = 0; i < children.length; i++) {
  5669. const vnode = children[i];
  5670. const key = vnode.key;
  5671. if (isDef(key)) {
  5672. if (seenKeys[key]) {
  5673. warn(
  5674. `Duplicate keys detected: '${key}'. This may cause an update error.`,
  5675. vnode.context
  5676. );
  5677. } else {
  5678. seenKeys[key] = true;
  5679. }
  5680. }
  5681. }
  5682. }
  5683. function findIdxInOld (node, oldCh, start, end) {
  5684. for (let i = start; i < end; i++) {
  5685. const c = oldCh[i];
  5686. if (isDef(c) && sameVnode(node, c)) return i
  5687. }
  5688. }
  5689. function patchVnode (
  5690. oldVnode,
  5691. vnode,
  5692. insertedVnodeQueue,
  5693. ownerArray,
  5694. index,
  5695. removeOnly
  5696. ) {
  5697. if (oldVnode === vnode) {
  5698. return
  5699. }
  5700. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5701. // clone reused vnode
  5702. vnode = ownerArray[index] = cloneVNode(vnode);
  5703. }
  5704. const elm = vnode.elm = oldVnode.elm;
  5705. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5706. if (isDef(vnode.asyncFactory.resolved)) {
  5707. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5708. } else {
  5709. vnode.isAsyncPlaceholder = true;
  5710. }
  5711. return
  5712. }
  5713. // reuse element for static trees.
  5714. // note we only do this if the vnode is cloned -
  5715. // if the new node is not cloned it means the render functions have been
  5716. // reset by the hot-reload-api and we need to do a proper re-render.
  5717. if (isTrue(vnode.isStatic) &&
  5718. isTrue(oldVnode.isStatic) &&
  5719. vnode.key === oldVnode.key &&
  5720. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5721. ) {
  5722. vnode.componentInstance = oldVnode.componentInstance;
  5723. return
  5724. }
  5725. let i;
  5726. const data = vnode.data;
  5727. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5728. i(oldVnode, vnode);
  5729. }
  5730. const oldCh = oldVnode.children;
  5731. const ch = vnode.children;
  5732. if (isDef(data) && isPatchable(vnode)) {
  5733. for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode);
  5734. if (isDef(i = data.hook) && isDef(i = i.update)) i(oldVnode, vnode);
  5735. }
  5736. if (isUndef(vnode.text)) {
  5737. if (isDef(oldCh) && isDef(ch)) {
  5738. if (oldCh !== ch) updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  5739. } else if (isDef(ch)) {
  5740. {
  5741. checkDuplicateKeys(ch);
  5742. }
  5743. if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '');
  5744. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5745. } else if (isDef(oldCh)) {
  5746. removeVnodes(oldCh, 0, oldCh.length - 1);
  5747. } else if (isDef(oldVnode.text)) {
  5748. nodeOps.setTextContent(elm, '');
  5749. }
  5750. } else if (oldVnode.text !== vnode.text) {
  5751. nodeOps.setTextContent(elm, vnode.text);
  5752. }
  5753. if (isDef(data)) {
  5754. if (isDef(i = data.hook) && isDef(i = i.postpatch)) i(oldVnode, vnode);
  5755. }
  5756. }
  5757. function invokeInsertHook (vnode, queue, initial) {
  5758. // delay insert hooks for component root nodes, invoke them after the
  5759. // element is really inserted
  5760. if (isTrue(initial) && isDef(vnode.parent)) {
  5761. vnode.parent.data.pendingInsert = queue;
  5762. } else {
  5763. for (let i = 0; i < queue.length; ++i) {
  5764. queue[i].data.hook.insert(queue[i]);
  5765. }
  5766. }
  5767. }
  5768. let hydrationBailed = false;
  5769. // list of modules that can skip create hook during hydration because they
  5770. // are already rendered on the client or has no need for initialization
  5771. // Note: style is excluded because it relies on initial clone for future
  5772. // deep updates (#7063).
  5773. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5774. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5775. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5776. let i;
  5777. const { tag, data, children } = vnode;
  5778. inVPre = inVPre || (data && data.pre);
  5779. vnode.elm = elm;
  5780. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5781. vnode.isAsyncPlaceholder = true;
  5782. return true
  5783. }
  5784. // assert node match
  5785. {
  5786. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5787. return false
  5788. }
  5789. }
  5790. if (isDef(data)) {
  5791. if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */);
  5792. if (isDef(i = vnode.componentInstance)) {
  5793. // child component. it should have hydrated its own tree.
  5794. initComponent(vnode, insertedVnodeQueue);
  5795. return true
  5796. }
  5797. }
  5798. if (isDef(tag)) {
  5799. if (isDef(children)) {
  5800. // empty element, allow client to pick up and populate children
  5801. if (!elm.hasChildNodes()) {
  5802. createChildren(vnode, children, insertedVnodeQueue);
  5803. } else {
  5804. // v-html and domProps: innerHTML
  5805. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5806. if (i !== elm.innerHTML) {
  5807. /* istanbul ignore if */
  5808. if (typeof console !== 'undefined' &&
  5809. !hydrationBailed
  5810. ) {
  5811. hydrationBailed = true;
  5812. console.warn('Parent: ', elm);
  5813. console.warn('server innerHTML: ', i);
  5814. console.warn('client innerHTML: ', elm.innerHTML);
  5815. }
  5816. return false
  5817. }
  5818. } else {
  5819. // iterate and compare children lists
  5820. let childrenMatch = true;
  5821. let childNode = elm.firstChild;
  5822. for (let i = 0; i < children.length; i++) {
  5823. if (!childNode || !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  5824. childrenMatch = false;
  5825. break
  5826. }
  5827. childNode = childNode.nextSibling;
  5828. }
  5829. // if childNode is not null, it means the actual childNodes list is
  5830. // longer than the virtual children list.
  5831. if (!childrenMatch || childNode) {
  5832. /* istanbul ignore if */
  5833. if (typeof console !== 'undefined' &&
  5834. !hydrationBailed
  5835. ) {
  5836. hydrationBailed = true;
  5837. console.warn('Parent: ', elm);
  5838. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5839. }
  5840. return false
  5841. }
  5842. }
  5843. }
  5844. }
  5845. if (isDef(data)) {
  5846. let fullInvoke = false;
  5847. for (const key in data) {
  5848. if (!isRenderedModule(key)) {
  5849. fullInvoke = true;
  5850. invokeCreateHooks(vnode, insertedVnodeQueue);
  5851. break
  5852. }
  5853. }
  5854. if (!fullInvoke && data['class']) {
  5855. // ensure collecting deps for deep class bindings for future updates
  5856. traverse(data['class']);
  5857. }
  5858. }
  5859. } else if (elm.data !== vnode.text) {
  5860. elm.data = vnode.text;
  5861. }
  5862. return true
  5863. }
  5864. function assertNodeMatch (node, vnode, inVPre) {
  5865. if (isDef(vnode.tag)) {
  5866. return vnode.tag.indexOf('vue-component') === 0 || (
  5867. !isUnknownElement$$1(vnode, inVPre) &&
  5868. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5869. )
  5870. } else {
  5871. return node.nodeType === (vnode.isComment ? 8 : 3)
  5872. }
  5873. }
  5874. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5875. if (isUndef(vnode)) {
  5876. if (isDef(oldVnode)) invokeDestroyHook(oldVnode);
  5877. return
  5878. }
  5879. let isInitialPatch = false;
  5880. const insertedVnodeQueue = [];
  5881. if (isUndef(oldVnode)) {
  5882. // empty mount (likely as component), create new root element
  5883. isInitialPatch = true;
  5884. createElm(vnode, insertedVnodeQueue);
  5885. } else {
  5886. const isRealElement = isDef(oldVnode.nodeType);
  5887. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5888. // patch existing root node
  5889. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5890. } else {
  5891. if (isRealElement) {
  5892. // mounting to a real element
  5893. // check if this is server-rendered content and if we can perform
  5894. // a successful hydration.
  5895. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5896. oldVnode.removeAttribute(SSR_ATTR);
  5897. hydrating = true;
  5898. }
  5899. if (isTrue(hydrating)) {
  5900. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5901. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5902. return oldVnode
  5903. } else {
  5904. warn(
  5905. 'The client-side rendered virtual DOM tree is not matching ' +
  5906. 'server-rendered content. This is likely caused by incorrect ' +
  5907. 'HTML markup, for example nesting block-level elements inside ' +
  5908. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5909. 'full client-side render.'
  5910. );
  5911. }
  5912. }
  5913. // either not server-rendered, or hydration failed.
  5914. // create an empty node and replace it
  5915. oldVnode = emptyNodeAt(oldVnode);
  5916. }
  5917. // replacing existing element
  5918. const oldElm = oldVnode.elm;
  5919. const parentElm = nodeOps.parentNode(oldElm);
  5920. // create new node
  5921. createElm(
  5922. vnode,
  5923. insertedVnodeQueue,
  5924. // extremely rare edge case: do not insert if old element is in a
  5925. // leaving transition. Only happens when combining transition +
  5926. // keep-alive + HOCs. (#4590)
  5927. oldElm._leaveCb ? null : parentElm,
  5928. nodeOps.nextSibling(oldElm)
  5929. );
  5930. // update parent placeholder node element, recursively
  5931. if (isDef(vnode.parent)) {
  5932. let ancestor = vnode.parent;
  5933. const patchable = isPatchable(vnode);
  5934. while (ancestor) {
  5935. for (let i = 0; i < cbs.destroy.length; ++i) {
  5936. cbs.destroy[i](ancestor);
  5937. }
  5938. ancestor.elm = vnode.elm;
  5939. if (patchable) {
  5940. for (let i = 0; i < cbs.create.length; ++i) {
  5941. cbs.create[i](emptyNode, ancestor);
  5942. }
  5943. // #6513
  5944. // invoke insert hooks that may have been merged by create hooks.
  5945. // e.g. for directives that uses the "inserted" hook.
  5946. const insert = ancestor.data.hook.insert;
  5947. if (insert.merged) {
  5948. // start at index 1 to avoid re-invoking component mounted hook
  5949. for (let i = 1; i < insert.fns.length; i++) {
  5950. insert.fns[i]();
  5951. }
  5952. }
  5953. } else {
  5954. registerRef(ancestor);
  5955. }
  5956. ancestor = ancestor.parent;
  5957. }
  5958. }
  5959. // destroy old node
  5960. if (isDef(parentElm)) {
  5961. removeVnodes([oldVnode], 0, 0);
  5962. } else if (isDef(oldVnode.tag)) {
  5963. invokeDestroyHook(oldVnode);
  5964. }
  5965. }
  5966. }
  5967. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5968. return vnode.elm
  5969. }
  5970. }
  5971. /* */
  5972. var directives = {
  5973. create: updateDirectives,
  5974. update: updateDirectives,
  5975. destroy: function unbindDirectives (vnode) {
  5976. updateDirectives(vnode, emptyNode);
  5977. }
  5978. };
  5979. function updateDirectives (oldVnode, vnode) {
  5980. if (oldVnode.data.directives || vnode.data.directives) {
  5981. _update(oldVnode, vnode);
  5982. }
  5983. }
  5984. function _update (oldVnode, vnode) {
  5985. const isCreate = oldVnode === emptyNode;
  5986. const isDestroy = vnode === emptyNode;
  5987. const oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  5988. const newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  5989. const dirsWithInsert = [];
  5990. const dirsWithPostpatch = [];
  5991. let key, oldDir, dir;
  5992. for (key in newDirs) {
  5993. oldDir = oldDirs[key];
  5994. dir = newDirs[key];
  5995. if (!oldDir) {
  5996. // new directive, bind
  5997. callHook$1(dir, 'bind', vnode, oldVnode);
  5998. if (dir.def && dir.def.inserted) {
  5999. dirsWithInsert.push(dir);
  6000. }
  6001. } else {
  6002. // existing directive, update
  6003. dir.oldValue = oldDir.value;
  6004. dir.oldArg = oldDir.arg;
  6005. callHook$1(dir, 'update', vnode, oldVnode);
  6006. if (dir.def && dir.def.componentUpdated) {
  6007. dirsWithPostpatch.push(dir);
  6008. }
  6009. }
  6010. }
  6011. if (dirsWithInsert.length) {
  6012. const callInsert = () => {
  6013. for (let i = 0; i < dirsWithInsert.length; i++) {
  6014. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  6015. }
  6016. };
  6017. if (isCreate) {
  6018. mergeVNodeHook(vnode, 'insert', callInsert);
  6019. } else {
  6020. callInsert();
  6021. }
  6022. }
  6023. if (dirsWithPostpatch.length) {
  6024. mergeVNodeHook(vnode, 'postpatch', () => {
  6025. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  6026. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  6027. }
  6028. });
  6029. }
  6030. if (!isCreate) {
  6031. for (key in oldDirs) {
  6032. if (!newDirs[key]) {
  6033. // no longer present, unbind
  6034. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  6035. }
  6036. }
  6037. }
  6038. }
  6039. const emptyModifiers = Object.create(null);
  6040. function normalizeDirectives$1 (
  6041. dirs,
  6042. vm
  6043. ) {
  6044. const res = Object.create(null);
  6045. if (!dirs) {
  6046. // $flow-disable-line
  6047. return res
  6048. }
  6049. let i, dir;
  6050. for (i = 0; i < dirs.length; i++) {
  6051. dir = dirs[i];
  6052. if (!dir.modifiers) {
  6053. // $flow-disable-line
  6054. dir.modifiers = emptyModifiers;
  6055. }
  6056. res[getRawDirName(dir)] = dir;
  6057. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  6058. }
  6059. // $flow-disable-line
  6060. return res
  6061. }
  6062. function getRawDirName (dir) {
  6063. return dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`
  6064. }
  6065. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  6066. const fn = dir.def && dir.def[hook];
  6067. if (fn) {
  6068. try {
  6069. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  6070. } catch (e) {
  6071. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  6072. }
  6073. }
  6074. }
  6075. var baseModules = [
  6076. ref,
  6077. directives
  6078. ];
  6079. /* */
  6080. function updateAttrs (oldVnode, vnode) {
  6081. const opts = vnode.componentOptions;
  6082. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  6083. return
  6084. }
  6085. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  6086. return
  6087. }
  6088. let key, cur, old;
  6089. const elm = vnode.elm;
  6090. const oldAttrs = oldVnode.data.attrs || {};
  6091. let attrs = vnode.data.attrs || {};
  6092. // clone observed objects, as the user probably wants to mutate it
  6093. if (isDef(attrs.__ob__)) {
  6094. attrs = vnode.data.attrs = extend({}, attrs);
  6095. }
  6096. for (key in attrs) {
  6097. cur = attrs[key];
  6098. old = oldAttrs[key];
  6099. if (old !== cur) {
  6100. setAttr(elm, key, cur, vnode.data.pre);
  6101. }
  6102. }
  6103. // #4391: in IE9, setting type can reset value for input[type=radio]
  6104. // #6666: IE/Edge forces progress value down to 1 before setting a max
  6105. /* istanbul ignore if */
  6106. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  6107. setAttr(elm, 'value', attrs.value);
  6108. }
  6109. for (key in oldAttrs) {
  6110. if (isUndef(attrs[key])) {
  6111. if (isXlink(key)) {
  6112. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6113. } else if (!isEnumeratedAttr(key)) {
  6114. elm.removeAttribute(key);
  6115. }
  6116. }
  6117. }
  6118. }
  6119. function setAttr (el, key, value, isInPre) {
  6120. if (isInPre || el.tagName.indexOf('-') > -1) {
  6121. baseSetAttr(el, key, value);
  6122. } else if (isBooleanAttr(key)) {
  6123. // set attribute for blank value
  6124. // e.g. <option disabled>Select one</option>
  6125. if (isFalsyAttrValue(value)) {
  6126. el.removeAttribute(key);
  6127. } else {
  6128. // technically allowfullscreen is a boolean attribute for <iframe>,
  6129. // but Flash expects a value of "true" when used on <embed> tag
  6130. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  6131. ? 'true'
  6132. : key;
  6133. el.setAttribute(key, value);
  6134. }
  6135. } else if (isEnumeratedAttr(key)) {
  6136. el.setAttribute(key, convertEnumeratedValue(key, value));
  6137. } else if (isXlink(key)) {
  6138. if (isFalsyAttrValue(value)) {
  6139. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6140. } else {
  6141. el.setAttributeNS(xlinkNS, key, value);
  6142. }
  6143. } else {
  6144. baseSetAttr(el, key, value);
  6145. }
  6146. }
  6147. function baseSetAttr (el, key, value) {
  6148. if (isFalsyAttrValue(value)) {
  6149. el.removeAttribute(key);
  6150. } else {
  6151. // #7138: IE10 & 11 fires input event when setting placeholder on
  6152. // <textarea>... block the first input event and remove the blocker
  6153. // immediately.
  6154. /* istanbul ignore if */
  6155. if (
  6156. isIE && !isIE9 &&
  6157. el.tagName === 'TEXTAREA' &&
  6158. key === 'placeholder' && value !== '' && !el.__ieph
  6159. ) {
  6160. const blocker = e => {
  6161. e.stopImmediatePropagation();
  6162. el.removeEventListener('input', blocker);
  6163. };
  6164. el.addEventListener('input', blocker);
  6165. // $flow-disable-line
  6166. el.__ieph = true; /* IE placeholder patched */
  6167. }
  6168. el.setAttribute(key, value);
  6169. }
  6170. }
  6171. var attrs = {
  6172. create: updateAttrs,
  6173. update: updateAttrs
  6174. };
  6175. /* */
  6176. function updateClass (oldVnode, vnode) {
  6177. const el = vnode.elm;
  6178. const data = vnode.data;
  6179. const oldData = oldVnode.data;
  6180. if (
  6181. isUndef(data.staticClass) &&
  6182. isUndef(data.class) && (
  6183. isUndef(oldData) || (
  6184. isUndef(oldData.staticClass) &&
  6185. isUndef(oldData.class)
  6186. )
  6187. )
  6188. ) {
  6189. return
  6190. }
  6191. let cls = genClassForVnode(vnode);
  6192. // handle transition classes
  6193. const transitionClass = el._transitionClasses;
  6194. if (isDef(transitionClass)) {
  6195. cls = concat(cls, stringifyClass(transitionClass));
  6196. }
  6197. // set the class
  6198. if (cls !== el._prevClass) {
  6199. el.setAttribute('class', cls);
  6200. el._prevClass = cls;
  6201. }
  6202. }
  6203. var klass = {
  6204. create: updateClass,
  6205. update: updateClass
  6206. };
  6207. /* */
  6208. const validDivisionCharRE = /[\w).+\-_$\]]/;
  6209. function parseFilters (exp) {
  6210. let inSingle = false;
  6211. let inDouble = false;
  6212. let inTemplateString = false;
  6213. let inRegex = false;
  6214. let curly = 0;
  6215. let square = 0;
  6216. let paren = 0;
  6217. let lastFilterIndex = 0;
  6218. let c, prev, i, expression, filters;
  6219. for (i = 0; i < exp.length; i++) {
  6220. prev = c;
  6221. c = exp.charCodeAt(i);
  6222. if (inSingle) {
  6223. if (c === 0x27 && prev !== 0x5C) inSingle = false;
  6224. } else if (inDouble) {
  6225. if (c === 0x22 && prev !== 0x5C) inDouble = false;
  6226. } else if (inTemplateString) {
  6227. if (c === 0x60 && prev !== 0x5C) inTemplateString = false;
  6228. } else if (inRegex) {
  6229. if (c === 0x2f && prev !== 0x5C) inRegex = false;
  6230. } else if (
  6231. c === 0x7C && // pipe
  6232. exp.charCodeAt(i + 1) !== 0x7C &&
  6233. exp.charCodeAt(i - 1) !== 0x7C &&
  6234. !curly && !square && !paren
  6235. ) {
  6236. if (expression === undefined) {
  6237. // first filter, end of expression
  6238. lastFilterIndex = i + 1;
  6239. expression = exp.slice(0, i).trim();
  6240. } else {
  6241. pushFilter();
  6242. }
  6243. } else {
  6244. switch (c) {
  6245. case 0x22: inDouble = true; break // "
  6246. case 0x27: inSingle = true; break // '
  6247. case 0x60: inTemplateString = true; break // `
  6248. case 0x28: paren++; break // (
  6249. case 0x29: paren--; break // )
  6250. case 0x5B: square++; break // [
  6251. case 0x5D: square--; break // ]
  6252. case 0x7B: curly++; break // {
  6253. case 0x7D: curly--; break // }
  6254. }
  6255. if (c === 0x2f) { // /
  6256. let j = i - 1;
  6257. let p;
  6258. // find first non-whitespace prev char
  6259. for (; j >= 0; j--) {
  6260. p = exp.charAt(j);
  6261. if (p !== ' ') break
  6262. }
  6263. if (!p || !validDivisionCharRE.test(p)) {
  6264. inRegex = true;
  6265. }
  6266. }
  6267. }
  6268. }
  6269. if (expression === undefined) {
  6270. expression = exp.slice(0, i).trim();
  6271. } else if (lastFilterIndex !== 0) {
  6272. pushFilter();
  6273. }
  6274. function pushFilter () {
  6275. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  6276. lastFilterIndex = i + 1;
  6277. }
  6278. if (filters) {
  6279. for (i = 0; i < filters.length; i++) {
  6280. expression = wrapFilter(expression, filters[i]);
  6281. }
  6282. }
  6283. return expression
  6284. }
  6285. function wrapFilter (exp, filter) {
  6286. const i = filter.indexOf('(');
  6287. if (i < 0) {
  6288. // _f: resolveFilter
  6289. return `_f("${filter}")(${exp})`
  6290. } else {
  6291. const name = filter.slice(0, i);
  6292. const args = filter.slice(i + 1);
  6293. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`
  6294. }
  6295. }
  6296. /* */
  6297. /* eslint-disable no-unused-vars */
  6298. function baseWarn (msg, range) {
  6299. console.error(`[Vue compiler]: ${msg}`);
  6300. }
  6301. /* eslint-enable no-unused-vars */
  6302. function pluckModuleFunction (
  6303. modules,
  6304. key
  6305. ) {
  6306. return modules
  6307. ? modules.map(m => m[key]).filter(_ => _)
  6308. : []
  6309. }
  6310. function addProp (el, name, value, range, dynamic) {
  6311. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  6312. el.plain = false;
  6313. }
  6314. function addAttr (el, name, value, range, dynamic) {
  6315. const attrs = dynamic
  6316. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  6317. : (el.attrs || (el.attrs = []));
  6318. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  6319. el.plain = false;
  6320. }
  6321. // add a raw attr (use this in preTransforms)
  6322. function addRawAttr (el, name, value, range) {
  6323. el.attrsMap[name] = value;
  6324. el.attrsList.push(rangeSetItem({ name, value }, range));
  6325. }
  6326. function addDirective (
  6327. el,
  6328. name,
  6329. rawName,
  6330. value,
  6331. arg,
  6332. isDynamicArg,
  6333. modifiers,
  6334. range
  6335. ) {
  6336. (el.directives || (el.directives = [])).push(rangeSetItem({
  6337. name,
  6338. rawName,
  6339. value,
  6340. arg,
  6341. isDynamicArg,
  6342. modifiers
  6343. }, range));
  6344. el.plain = false;
  6345. }
  6346. function prependModifierMarker (symbol, name, dynamic) {
  6347. return dynamic
  6348. ? `_p(${name},"${symbol}")`
  6349. : symbol + name // mark the event as captured
  6350. }
  6351. function addHandler (
  6352. el,
  6353. name,
  6354. value,
  6355. modifiers,
  6356. important,
  6357. warn,
  6358. range,
  6359. dynamic
  6360. ) {
  6361. modifiers = modifiers || emptyObject;
  6362. // warn prevent and passive modifier
  6363. /* istanbul ignore if */
  6364. if (
  6365. warn &&
  6366. modifiers.prevent && modifiers.passive
  6367. ) {
  6368. warn(
  6369. 'passive and prevent can\'t be used together. ' +
  6370. 'Passive handler can\'t prevent default event.',
  6371. range
  6372. );
  6373. }
  6374. // normalize click.right and click.middle since they don't actually fire
  6375. // this is technically browser-specific, but at least for now browsers are
  6376. // the only target envs that have right/middle clicks.
  6377. if (modifiers.right) {
  6378. if (dynamic) {
  6379. name = `(${name})==='click'?'contextmenu':(${name})`;
  6380. } else if (name === 'click') {
  6381. name = 'contextmenu';
  6382. delete modifiers.right;
  6383. }
  6384. } else if (modifiers.middle) {
  6385. if (dynamic) {
  6386. name = `(${name})==='click'?'mouseup':(${name})`;
  6387. } else if (name === 'click') {
  6388. name = 'mouseup';
  6389. }
  6390. }
  6391. // check capture modifier
  6392. if (modifiers.capture) {
  6393. delete modifiers.capture;
  6394. name = prependModifierMarker('!', name, dynamic);
  6395. }
  6396. if (modifiers.once) {
  6397. delete modifiers.once;
  6398. name = prependModifierMarker('~', name, dynamic);
  6399. }
  6400. /* istanbul ignore if */
  6401. if (modifiers.passive) {
  6402. delete modifiers.passive;
  6403. name = prependModifierMarker('&', name, dynamic);
  6404. }
  6405. let events;
  6406. if (modifiers.native) {
  6407. delete modifiers.native;
  6408. events = el.nativeEvents || (el.nativeEvents = {});
  6409. } else {
  6410. events = el.events || (el.events = {});
  6411. }
  6412. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  6413. if (modifiers !== emptyObject) {
  6414. newHandler.modifiers = modifiers;
  6415. }
  6416. const handlers = events[name];
  6417. /* istanbul ignore if */
  6418. if (Array.isArray(handlers)) {
  6419. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  6420. } else if (handlers) {
  6421. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  6422. } else {
  6423. events[name] = newHandler;
  6424. }
  6425. el.plain = false;
  6426. }
  6427. function getRawBindingAttr (
  6428. el,
  6429. name
  6430. ) {
  6431. return el.rawAttrsMap[':' + name] ||
  6432. el.rawAttrsMap['v-bind:' + name] ||
  6433. el.rawAttrsMap[name]
  6434. }
  6435. function getBindingAttr (
  6436. el,
  6437. name,
  6438. getStatic
  6439. ) {
  6440. const dynamicValue =
  6441. getAndRemoveAttr(el, ':' + name) ||
  6442. getAndRemoveAttr(el, 'v-bind:' + name);
  6443. if (dynamicValue != null) {
  6444. return parseFilters(dynamicValue)
  6445. } else if (getStatic !== false) {
  6446. const staticValue = getAndRemoveAttr(el, name);
  6447. if (staticValue != null) {
  6448. return JSON.stringify(staticValue)
  6449. }
  6450. }
  6451. }
  6452. // note: this only removes the attr from the Array (attrsList) so that it
  6453. // doesn't get processed by processAttrs.
  6454. // By default it does NOT remove it from the map (attrsMap) because the map is
  6455. // needed during codegen.
  6456. function getAndRemoveAttr (
  6457. el,
  6458. name,
  6459. removeFromMap
  6460. ) {
  6461. let val;
  6462. if ((val = el.attrsMap[name]) != null) {
  6463. const list = el.attrsList;
  6464. for (let i = 0, l = list.length; i < l; i++) {
  6465. if (list[i].name === name) {
  6466. list.splice(i, 1);
  6467. break
  6468. }
  6469. }
  6470. }
  6471. if (removeFromMap) {
  6472. delete el.attrsMap[name];
  6473. }
  6474. return val
  6475. }
  6476. function getAndRemoveAttrByRegex (
  6477. el,
  6478. name
  6479. ) {
  6480. const list = el.attrsList;
  6481. for (let i = 0, l = list.length; i < l; i++) {
  6482. const attr = list[i];
  6483. if (name.test(attr.name)) {
  6484. list.splice(i, 1);
  6485. return attr
  6486. }
  6487. }
  6488. }
  6489. function rangeSetItem (
  6490. item,
  6491. range
  6492. ) {
  6493. if (range) {
  6494. if (range.start != null) {
  6495. item.start = range.start;
  6496. }
  6497. if (range.end != null) {
  6498. item.end = range.end;
  6499. }
  6500. }
  6501. return item
  6502. }
  6503. /* */
  6504. /**
  6505. * Cross-platform code generation for component v-model
  6506. */
  6507. function genComponentModel (
  6508. el,
  6509. value,
  6510. modifiers
  6511. ) {
  6512. const { number, trim } = modifiers || {};
  6513. const baseValueExpression = '$$v';
  6514. let valueExpression = baseValueExpression;
  6515. if (trim) {
  6516. valueExpression =
  6517. `(typeof ${baseValueExpression} === 'string'` +
  6518. `? ${baseValueExpression}.trim()` +
  6519. `: ${baseValueExpression})`;
  6520. }
  6521. if (number) {
  6522. valueExpression = `_n(${valueExpression})`;
  6523. }
  6524. const assignment = genAssignmentCode(value, valueExpression);
  6525. el.model = {
  6526. value: `(${value})`,
  6527. expression: JSON.stringify(value),
  6528. callback: `function (${baseValueExpression}) {${assignment}}`
  6529. };
  6530. }
  6531. /**
  6532. * Cross-platform codegen helper for generating v-model value assignment code.
  6533. */
  6534. function genAssignmentCode (
  6535. value,
  6536. assignment
  6537. ) {
  6538. const res = parseModel(value);
  6539. if (res.key === null) {
  6540. return `${value}=${assignment}`
  6541. } else {
  6542. return `$set(${res.exp}, ${res.key}, ${assignment})`
  6543. }
  6544. }
  6545. /**
  6546. * Parse a v-model expression into a base path and a final key segment.
  6547. * Handles both dot-path and possible square brackets.
  6548. *
  6549. * Possible cases:
  6550. *
  6551. * - test
  6552. * - test[key]
  6553. * - test[test1[key]]
  6554. * - test["a"][key]
  6555. * - xxx.test[a[a].test1[key]]
  6556. * - test.xxx.a["asa"][test1[key]]
  6557. *
  6558. */
  6559. let len, str, chr, index$1, expressionPos, expressionEndPos;
  6560. function parseModel (val) {
  6561. // Fix https://github.com/vuejs/vue/pull/7730
  6562. // allow v-model="obj.val " (trailing whitespace)
  6563. val = val.trim();
  6564. len = val.length;
  6565. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6566. index$1 = val.lastIndexOf('.');
  6567. if (index$1 > -1) {
  6568. return {
  6569. exp: val.slice(0, index$1),
  6570. key: '"' + val.slice(index$1 + 1) + '"'
  6571. }
  6572. } else {
  6573. return {
  6574. exp: val,
  6575. key: null
  6576. }
  6577. }
  6578. }
  6579. str = val;
  6580. index$1 = expressionPos = expressionEndPos = 0;
  6581. while (!eof()) {
  6582. chr = next();
  6583. /* istanbul ignore if */
  6584. if (isStringStart(chr)) {
  6585. parseString(chr);
  6586. } else if (chr === 0x5B) {
  6587. parseBracket(chr);
  6588. }
  6589. }
  6590. return {
  6591. exp: val.slice(0, expressionPos),
  6592. key: val.slice(expressionPos + 1, expressionEndPos)
  6593. }
  6594. }
  6595. function next () {
  6596. return str.charCodeAt(++index$1)
  6597. }
  6598. function eof () {
  6599. return index$1 >= len
  6600. }
  6601. function isStringStart (chr) {
  6602. return chr === 0x22 || chr === 0x27
  6603. }
  6604. function parseBracket (chr) {
  6605. let inBracket = 1;
  6606. expressionPos = index$1;
  6607. while (!eof()) {
  6608. chr = next();
  6609. if (isStringStart(chr)) {
  6610. parseString(chr);
  6611. continue
  6612. }
  6613. if (chr === 0x5B) inBracket++;
  6614. if (chr === 0x5D) inBracket--;
  6615. if (inBracket === 0) {
  6616. expressionEndPos = index$1;
  6617. break
  6618. }
  6619. }
  6620. }
  6621. function parseString (chr) {
  6622. const stringQuote = chr;
  6623. while (!eof()) {
  6624. chr = next();
  6625. if (chr === stringQuote) {
  6626. break
  6627. }
  6628. }
  6629. }
  6630. /* */
  6631. let warn$1;
  6632. // in some cases, the event used has to be determined at runtime
  6633. // so we used some reserved tokens during compile.
  6634. const RANGE_TOKEN = '__r';
  6635. const CHECKBOX_RADIO_TOKEN = '__c';
  6636. function model (
  6637. el,
  6638. dir,
  6639. _warn
  6640. ) {
  6641. warn$1 = _warn;
  6642. const value = dir.value;
  6643. const modifiers = dir.modifiers;
  6644. const tag = el.tag;
  6645. const type = el.attrsMap.type;
  6646. {
  6647. // inputs with type="file" are read only and setting the input's
  6648. // value will throw an error.
  6649. if (tag === 'input' && type === 'file') {
  6650. warn$1(
  6651. `<${el.tag} v-model="${value}" type="file">:\n` +
  6652. `File inputs are read only. Use a v-on:change listener instead.`,
  6653. el.rawAttrsMap['v-model']
  6654. );
  6655. }
  6656. }
  6657. if (el.component) {
  6658. genComponentModel(el, value, modifiers);
  6659. // component v-model doesn't need extra runtime
  6660. return false
  6661. } else if (tag === 'select') {
  6662. genSelect(el, value, modifiers);
  6663. } else if (tag === 'input' && type === 'checkbox') {
  6664. genCheckboxModel(el, value, modifiers);
  6665. } else if (tag === 'input' && type === 'radio') {
  6666. genRadioModel(el, value, modifiers);
  6667. } else if (tag === 'input' || tag === 'textarea') {
  6668. genDefaultModel(el, value, modifiers);
  6669. } else if (!config.isReservedTag(tag)) {
  6670. genComponentModel(el, value, modifiers);
  6671. // component v-model doesn't need extra runtime
  6672. return false
  6673. } else {
  6674. warn$1(
  6675. `<${el.tag} v-model="${value}">: ` +
  6676. `v-model is not supported on this element type. ` +
  6677. 'If you are working with contenteditable, it\'s recommended to ' +
  6678. 'wrap a library dedicated for that purpose inside a custom component.',
  6679. el.rawAttrsMap['v-model']
  6680. );
  6681. }
  6682. // ensure runtime directive metadata
  6683. return true
  6684. }
  6685. function genCheckboxModel (
  6686. el,
  6687. value,
  6688. modifiers
  6689. ) {
  6690. const number = modifiers && modifiers.number;
  6691. const valueBinding = getBindingAttr(el, 'value') || 'null';
  6692. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  6693. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  6694. addProp(el, 'checked',
  6695. `Array.isArray(${value})` +
  6696. `?_i(${value},${valueBinding})>-1` + (
  6697. trueValueBinding === 'true'
  6698. ? `:(${value})`
  6699. : `:_q(${value},${trueValueBinding})`
  6700. )
  6701. );
  6702. addHandler(el, 'change',
  6703. `var $$a=${value},` +
  6704. '$$el=$event.target,' +
  6705. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  6706. 'if(Array.isArray($$a)){' +
  6707. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  6708. '$$i=_i($$a,$$v);' +
  6709. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  6710. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  6711. `}else{${genAssignmentCode(value, '$$c')}}`,
  6712. null, true
  6713. );
  6714. }
  6715. function genRadioModel (
  6716. el,
  6717. value,
  6718. modifiers
  6719. ) {
  6720. const number = modifiers && modifiers.number;
  6721. let valueBinding = getBindingAttr(el, 'value') || 'null';
  6722. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  6723. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  6724. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  6725. }
  6726. function genSelect (
  6727. el,
  6728. value,
  6729. modifiers
  6730. ) {
  6731. const number = modifiers && modifiers.number;
  6732. const selectedVal = `Array.prototype.filter` +
  6733. `.call($event.target.options,function(o){return o.selected})` +
  6734. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  6735. `return ${number ? '_n(val)' : 'val'}})`;
  6736. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  6737. let code = `var $$selectedVal = ${selectedVal};`;
  6738. code = `${code} ${genAssignmentCode(value, assignment)}`;
  6739. addHandler(el, 'change', code, null, true);
  6740. }
  6741. function genDefaultModel (
  6742. el,
  6743. value,
  6744. modifiers
  6745. ) {
  6746. const type = el.attrsMap.type;
  6747. // warn if v-bind:value conflicts with v-model
  6748. // except for inputs with v-bind:type
  6749. {
  6750. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  6751. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  6752. if (value && !typeBinding) {
  6753. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  6754. warn$1(
  6755. `${binding}="${value}" conflicts with v-model on the same element ` +
  6756. 'because the latter already expands to a value binding internally',
  6757. el.rawAttrsMap[binding]
  6758. );
  6759. }
  6760. }
  6761. const { lazy, number, trim } = modifiers || {};
  6762. const needCompositionGuard = !lazy && type !== 'range';
  6763. const event = lazy
  6764. ? 'change'
  6765. : type === 'range'
  6766. ? RANGE_TOKEN
  6767. : 'input';
  6768. let valueExpression = '$event.target.value';
  6769. if (trim) {
  6770. valueExpression = `$event.target.value.trim()`;
  6771. }
  6772. if (number) {
  6773. valueExpression = `_n(${valueExpression})`;
  6774. }
  6775. let code = genAssignmentCode(value, valueExpression);
  6776. if (needCompositionGuard) {
  6777. code = `if($event.target.composing)return;${code}`;
  6778. }
  6779. addProp(el, 'value', `(${value})`);
  6780. addHandler(el, event, code, null, true);
  6781. if (trim || number) {
  6782. addHandler(el, 'blur', '$forceUpdate()');
  6783. }
  6784. }
  6785. /* */
  6786. // normalize v-model event tokens that can only be determined at runtime.
  6787. // it's important to place the event as the first in the array because
  6788. // the whole point is ensuring the v-model callback gets called before
  6789. // user-attached handlers.
  6790. function normalizeEvents (on) {
  6791. /* istanbul ignore if */
  6792. if (isDef(on[RANGE_TOKEN])) {
  6793. // IE input[type=range] only supports `change` event
  6794. const event = isIE ? 'change' : 'input';
  6795. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6796. delete on[RANGE_TOKEN];
  6797. }
  6798. // This was originally intended to fix #4521 but no longer necessary
  6799. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6800. /* istanbul ignore if */
  6801. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6802. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6803. delete on[CHECKBOX_RADIO_TOKEN];
  6804. }
  6805. }
  6806. let target$1;
  6807. function createOnceHandler$1 (event, handler, capture) {
  6808. const _target = target$1; // save current target element in closure
  6809. return function onceHandler () {
  6810. const res = handler.apply(null, arguments);
  6811. if (res !== null) {
  6812. remove$2(event, onceHandler, capture, _target);
  6813. }
  6814. }
  6815. }
  6816. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  6817. // implementation and does not fire microtasks in between event propagation, so
  6818. // safe to exclude.
  6819. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  6820. function add$1 (
  6821. name,
  6822. handler,
  6823. capture,
  6824. passive
  6825. ) {
  6826. // async edge case #6566: inner click event triggers patch, event handler
  6827. // attached to outer element during patch, and triggered again. This
  6828. // happens because browsers fire microtask ticks between event propagation.
  6829. // the solution is simple: we save the timestamp when a handler is attached,
  6830. // and the handler would only fire if the event passed to it was fired
  6831. // AFTER it was attached.
  6832. if (useMicrotaskFix) {
  6833. const attachedTimestamp = currentFlushTimestamp;
  6834. const original = handler;
  6835. handler = original._wrapper = function (e) {
  6836. if (
  6837. // no bubbling, should always fire.
  6838. // this is just a safety net in case event.timeStamp is unreliable in
  6839. // certain weird environments...
  6840. e.target === e.currentTarget ||
  6841. // event is fired after handler attachment
  6842. e.timeStamp >= attachedTimestamp ||
  6843. // bail for environments that have buggy event.timeStamp implementations
  6844. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  6845. // #9681 QtWebEngine event.timeStamp is negative value
  6846. e.timeStamp <= 0 ||
  6847. // #9448 bail if event is fired in another document in a multi-page
  6848. // electron/nw.js app, since event.timeStamp will be using a different
  6849. // starting reference
  6850. e.target.ownerDocument !== document
  6851. ) {
  6852. return original.apply(this, arguments)
  6853. }
  6854. };
  6855. }
  6856. target$1.addEventListener(
  6857. name,
  6858. handler,
  6859. supportsPassive
  6860. ? { capture, passive }
  6861. : capture
  6862. );
  6863. }
  6864. function remove$2 (
  6865. name,
  6866. handler,
  6867. capture,
  6868. _target
  6869. ) {
  6870. (_target || target$1).removeEventListener(
  6871. name,
  6872. handler._wrapper || handler,
  6873. capture
  6874. );
  6875. }
  6876. function updateDOMListeners (oldVnode, vnode) {
  6877. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6878. return
  6879. }
  6880. const on = vnode.data.on || {};
  6881. const oldOn = oldVnode.data.on || {};
  6882. target$1 = vnode.elm;
  6883. normalizeEvents(on);
  6884. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6885. target$1 = undefined;
  6886. }
  6887. var events = {
  6888. create: updateDOMListeners,
  6889. update: updateDOMListeners
  6890. };
  6891. /* */
  6892. let svgContainer;
  6893. function updateDOMProps (oldVnode, vnode) {
  6894. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6895. return
  6896. }
  6897. let key, cur;
  6898. const elm = vnode.elm;
  6899. const oldProps = oldVnode.data.domProps || {};
  6900. let props = vnode.data.domProps || {};
  6901. // clone observed objects, as the user probably wants to mutate it
  6902. if (isDef(props.__ob__)) {
  6903. props = vnode.data.domProps = extend({}, props);
  6904. }
  6905. for (key in oldProps) {
  6906. if (!(key in props)) {
  6907. elm[key] = '';
  6908. }
  6909. }
  6910. for (key in props) {
  6911. cur = props[key];
  6912. // ignore children if the node has textContent or innerHTML,
  6913. // as these will throw away existing DOM nodes and cause removal errors
  6914. // on subsequent patches (#3360)
  6915. if (key === 'textContent' || key === 'innerHTML') {
  6916. if (vnode.children) vnode.children.length = 0;
  6917. if (cur === oldProps[key]) continue
  6918. // #6601 work around Chrome version <= 55 bug where single textNode
  6919. // replaced by innerHTML/textContent retains its parentNode property
  6920. if (elm.childNodes.length === 1) {
  6921. elm.removeChild(elm.childNodes[0]);
  6922. }
  6923. }
  6924. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  6925. // store value as _value as well since
  6926. // non-string values will be stringified
  6927. elm._value = cur;
  6928. // avoid resetting cursor position when value is the same
  6929. const strCur = isUndef(cur) ? '' : String(cur);
  6930. if (shouldUpdateValue(elm, strCur)) {
  6931. elm.value = strCur;
  6932. }
  6933. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  6934. // IE doesn't support innerHTML for SVG elements
  6935. svgContainer = svgContainer || document.createElement('div');
  6936. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  6937. const svg = svgContainer.firstChild;
  6938. while (elm.firstChild) {
  6939. elm.removeChild(elm.firstChild);
  6940. }
  6941. while (svg.firstChild) {
  6942. elm.appendChild(svg.firstChild);
  6943. }
  6944. } else if (
  6945. // skip the update if old and new VDOM state is the same.
  6946. // `value` is handled separately because the DOM value may be temporarily
  6947. // out of sync with VDOM state due to focus, composition and modifiers.
  6948. // This #4521 by skipping the unnecessary `checked` update.
  6949. cur !== oldProps[key]
  6950. ) {
  6951. // some property updates can throw
  6952. // e.g. `value` on <progress> w/ non-finite value
  6953. try {
  6954. elm[key] = cur;
  6955. } catch (e) {}
  6956. }
  6957. }
  6958. }
  6959. // check platforms/web/util/attrs.js acceptValue
  6960. function shouldUpdateValue (elm, checkVal) {
  6961. return (!elm.composing && (
  6962. elm.tagName === 'OPTION' ||
  6963. isNotInFocusAndDirty(elm, checkVal) ||
  6964. isDirtyWithModifiers(elm, checkVal)
  6965. ))
  6966. }
  6967. function isNotInFocusAndDirty (elm, checkVal) {
  6968. // return true when textbox (.number and .trim) loses focus and its value is
  6969. // not equal to the updated value
  6970. let notInFocus = true;
  6971. // #6157
  6972. // work around IE bug when accessing document.activeElement in an iframe
  6973. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6974. return notInFocus && elm.value !== checkVal
  6975. }
  6976. function isDirtyWithModifiers (elm, newVal) {
  6977. const value = elm.value;
  6978. const modifiers = elm._vModifiers; // injected by v-model runtime
  6979. if (isDef(modifiers)) {
  6980. if (modifiers.number) {
  6981. return toNumber(value) !== toNumber(newVal)
  6982. }
  6983. if (modifiers.trim) {
  6984. return value.trim() !== newVal.trim()
  6985. }
  6986. }
  6987. return value !== newVal
  6988. }
  6989. var domProps = {
  6990. create: updateDOMProps,
  6991. update: updateDOMProps
  6992. };
  6993. /* */
  6994. const parseStyleText = cached(function (cssText) {
  6995. const res = {};
  6996. const listDelimiter = /;(?![^(]*\))/g;
  6997. const propertyDelimiter = /:(.+)/;
  6998. cssText.split(listDelimiter).forEach(function (item) {
  6999. if (item) {
  7000. const tmp = item.split(propertyDelimiter);
  7001. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7002. }
  7003. });
  7004. return res
  7005. });
  7006. // merge static and dynamic style data on the same vnode
  7007. function normalizeStyleData (data) {
  7008. const style = normalizeStyleBinding(data.style);
  7009. // static style is pre-processed into an object during compilation
  7010. // and is always a fresh object, so it's safe to merge into it
  7011. return data.staticStyle
  7012. ? extend(data.staticStyle, style)
  7013. : style
  7014. }
  7015. // normalize possible array / string values into Object
  7016. function normalizeStyleBinding (bindingStyle) {
  7017. if (Array.isArray(bindingStyle)) {
  7018. return toObject(bindingStyle)
  7019. }
  7020. if (typeof bindingStyle === 'string') {
  7021. return parseStyleText(bindingStyle)
  7022. }
  7023. return bindingStyle
  7024. }
  7025. /**
  7026. * parent component style should be after child's
  7027. * so that parent component's style could override it
  7028. */
  7029. function getStyle (vnode, checkChild) {
  7030. const res = {};
  7031. let styleData;
  7032. if (checkChild) {
  7033. let childNode = vnode;
  7034. while (childNode.componentInstance) {
  7035. childNode = childNode.componentInstance._vnode;
  7036. if (
  7037. childNode && childNode.data &&
  7038. (styleData = normalizeStyleData(childNode.data))
  7039. ) {
  7040. extend(res, styleData);
  7041. }
  7042. }
  7043. }
  7044. if ((styleData = normalizeStyleData(vnode.data))) {
  7045. extend(res, styleData);
  7046. }
  7047. let parentNode = vnode;
  7048. while ((parentNode = parentNode.parent)) {
  7049. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7050. extend(res, styleData);
  7051. }
  7052. }
  7053. return res
  7054. }
  7055. /* */
  7056. const cssVarRE = /^--/;
  7057. const importantRE = /\s*!important$/;
  7058. const setProp = (el, name, val) => {
  7059. /* istanbul ignore if */
  7060. if (cssVarRE.test(name)) {
  7061. el.style.setProperty(name, val);
  7062. } else if (importantRE.test(val)) {
  7063. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7064. } else {
  7065. const normalizedName = normalize(name);
  7066. if (Array.isArray(val)) {
  7067. // Support values array created by autoprefixer, e.g.
  7068. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7069. // Set them one by one, and the browser will only set those it can recognize
  7070. for (let i = 0, len = val.length; i < len; i++) {
  7071. el.style[normalizedName] = val[i];
  7072. }
  7073. } else {
  7074. el.style[normalizedName] = val;
  7075. }
  7076. }
  7077. };
  7078. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7079. let emptyStyle;
  7080. const normalize = cached(function (prop) {
  7081. emptyStyle = emptyStyle || document.createElement('div').style;
  7082. prop = camelize(prop);
  7083. if (prop !== 'filter' && (prop in emptyStyle)) {
  7084. return prop
  7085. }
  7086. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7087. for (let i = 0; i < vendorNames.length; i++) {
  7088. const name = vendorNames[i] + capName;
  7089. if (name in emptyStyle) {
  7090. return name
  7091. }
  7092. }
  7093. });
  7094. function updateStyle (oldVnode, vnode) {
  7095. const data = vnode.data;
  7096. const oldData = oldVnode.data;
  7097. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  7098. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  7099. ) {
  7100. return
  7101. }
  7102. let cur, name;
  7103. const el = vnode.elm;
  7104. const oldStaticStyle = oldData.staticStyle;
  7105. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7106. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7107. const oldStyle = oldStaticStyle || oldStyleBinding;
  7108. const style = normalizeStyleBinding(vnode.data.style) || {};
  7109. // store normalized style under a different key for next diff
  7110. // make sure to clone it if it's reactive, since the user likely wants
  7111. // to mutate it.
  7112. vnode.data.normalizedStyle = isDef(style.__ob__)
  7113. ? extend({}, style)
  7114. : style;
  7115. const newStyle = getStyle(vnode, true);
  7116. for (name in oldStyle) {
  7117. if (isUndef(newStyle[name])) {
  7118. setProp(el, name, '');
  7119. }
  7120. }
  7121. for (name in newStyle) {
  7122. cur = newStyle[name];
  7123. if (cur !== oldStyle[name]) {
  7124. // ie9 setting to null has no effect, must use empty string
  7125. setProp(el, name, cur == null ? '' : cur);
  7126. }
  7127. }
  7128. }
  7129. var style = {
  7130. create: updateStyle,
  7131. update: updateStyle
  7132. };
  7133. /* */
  7134. const whitespaceRE = /\s+/;
  7135. /**
  7136. * Add class with compatibility for SVG since classList is not supported on
  7137. * SVG elements in IE
  7138. */
  7139. function addClass (el, cls) {
  7140. /* istanbul ignore if */
  7141. if (!cls || !(cls = cls.trim())) {
  7142. return
  7143. }
  7144. /* istanbul ignore else */
  7145. if (el.classList) {
  7146. if (cls.indexOf(' ') > -1) {
  7147. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7148. } else {
  7149. el.classList.add(cls);
  7150. }
  7151. } else {
  7152. const cur = ` ${el.getAttribute('class') || ''} `;
  7153. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7154. el.setAttribute('class', (cur + cls).trim());
  7155. }
  7156. }
  7157. }
  7158. /**
  7159. * Remove class with compatibility for SVG since classList is not supported on
  7160. * SVG elements in IE
  7161. */
  7162. function removeClass (el, cls) {
  7163. /* istanbul ignore if */
  7164. if (!cls || !(cls = cls.trim())) {
  7165. return
  7166. }
  7167. /* istanbul ignore else */
  7168. if (el.classList) {
  7169. if (cls.indexOf(' ') > -1) {
  7170. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7171. } else {
  7172. el.classList.remove(cls);
  7173. }
  7174. if (!el.classList.length) {
  7175. el.removeAttribute('class');
  7176. }
  7177. } else {
  7178. let cur = ` ${el.getAttribute('class') || ''} `;
  7179. const tar = ' ' + cls + ' ';
  7180. while (cur.indexOf(tar) >= 0) {
  7181. cur = cur.replace(tar, ' ');
  7182. }
  7183. cur = cur.trim();
  7184. if (cur) {
  7185. el.setAttribute('class', cur);
  7186. } else {
  7187. el.removeAttribute('class');
  7188. }
  7189. }
  7190. }
  7191. /* */
  7192. function resolveTransition (def$$1) {
  7193. if (!def$$1) {
  7194. return
  7195. }
  7196. /* istanbul ignore else */
  7197. if (typeof def$$1 === 'object') {
  7198. const res = {};
  7199. if (def$$1.css !== false) {
  7200. extend(res, autoCssTransition(def$$1.name || 'v'));
  7201. }
  7202. extend(res, def$$1);
  7203. return res
  7204. } else if (typeof def$$1 === 'string') {
  7205. return autoCssTransition(def$$1)
  7206. }
  7207. }
  7208. const autoCssTransition = cached(name => {
  7209. return {
  7210. enterClass: `${name}-enter`,
  7211. enterToClass: `${name}-enter-to`,
  7212. enterActiveClass: `${name}-enter-active`,
  7213. leaveClass: `${name}-leave`,
  7214. leaveToClass: `${name}-leave-to`,
  7215. leaveActiveClass: `${name}-leave-active`
  7216. }
  7217. });
  7218. const hasTransition = inBrowser && !isIE9;
  7219. const TRANSITION = 'transition';
  7220. const ANIMATION = 'animation';
  7221. // Transition property/event sniffing
  7222. let transitionProp = 'transition';
  7223. let transitionEndEvent = 'transitionend';
  7224. let animationProp = 'animation';
  7225. let animationEndEvent = 'animationend';
  7226. if (hasTransition) {
  7227. /* istanbul ignore if */
  7228. if (window.ontransitionend === undefined &&
  7229. window.onwebkittransitionend !== undefined
  7230. ) {
  7231. transitionProp = 'WebkitTransition';
  7232. transitionEndEvent = 'webkitTransitionEnd';
  7233. }
  7234. if (window.onanimationend === undefined &&
  7235. window.onwebkitanimationend !== undefined
  7236. ) {
  7237. animationProp = 'WebkitAnimation';
  7238. animationEndEvent = 'webkitAnimationEnd';
  7239. }
  7240. }
  7241. // binding to window is necessary to make hot reload work in IE in strict mode
  7242. const raf = inBrowser
  7243. ? window.requestAnimationFrame
  7244. ? window.requestAnimationFrame.bind(window)
  7245. : setTimeout
  7246. : /* istanbul ignore next */ fn => fn();
  7247. function nextFrame (fn) {
  7248. raf(() => {
  7249. raf(fn);
  7250. });
  7251. }
  7252. function addTransitionClass (el, cls) {
  7253. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7254. if (transitionClasses.indexOf(cls) < 0) {
  7255. transitionClasses.push(cls);
  7256. addClass(el, cls);
  7257. }
  7258. }
  7259. function removeTransitionClass (el, cls) {
  7260. if (el._transitionClasses) {
  7261. remove(el._transitionClasses, cls);
  7262. }
  7263. removeClass(el, cls);
  7264. }
  7265. function whenTransitionEnds (
  7266. el,
  7267. expectedType,
  7268. cb
  7269. ) {
  7270. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7271. if (!type) return cb()
  7272. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7273. let ended = 0;
  7274. const end = () => {
  7275. el.removeEventListener(event, onEnd);
  7276. cb();
  7277. };
  7278. const onEnd = e => {
  7279. if (e.target === el) {
  7280. if (++ended >= propCount) {
  7281. end();
  7282. }
  7283. }
  7284. };
  7285. setTimeout(() => {
  7286. if (ended < propCount) {
  7287. end();
  7288. }
  7289. }, timeout + 1);
  7290. el.addEventListener(event, onEnd);
  7291. }
  7292. const transformRE = /\b(transform|all)(,|$)/;
  7293. function getTransitionInfo (el, expectedType) {
  7294. const styles = window.getComputedStyle(el);
  7295. // JSDOM may return undefined for transition properties
  7296. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7297. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7298. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7299. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7300. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7301. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7302. let type;
  7303. let timeout = 0;
  7304. let propCount = 0;
  7305. /* istanbul ignore if */
  7306. if (expectedType === TRANSITION) {
  7307. if (transitionTimeout > 0) {
  7308. type = TRANSITION;
  7309. timeout = transitionTimeout;
  7310. propCount = transitionDurations.length;
  7311. }
  7312. } else if (expectedType === ANIMATION) {
  7313. if (animationTimeout > 0) {
  7314. type = ANIMATION;
  7315. timeout = animationTimeout;
  7316. propCount = animationDurations.length;
  7317. }
  7318. } else {
  7319. timeout = Math.max(transitionTimeout, animationTimeout);
  7320. type = timeout > 0
  7321. ? transitionTimeout > animationTimeout
  7322. ? TRANSITION
  7323. : ANIMATION
  7324. : null;
  7325. propCount = type
  7326. ? type === TRANSITION
  7327. ? transitionDurations.length
  7328. : animationDurations.length
  7329. : 0;
  7330. }
  7331. const hasTransform =
  7332. type === TRANSITION &&
  7333. transformRE.test(styles[transitionProp + 'Property']);
  7334. return {
  7335. type,
  7336. timeout,
  7337. propCount,
  7338. hasTransform
  7339. }
  7340. }
  7341. function getTimeout (delays, durations) {
  7342. /* istanbul ignore next */
  7343. while (delays.length < durations.length) {
  7344. delays = delays.concat(delays);
  7345. }
  7346. return Math.max.apply(null, durations.map((d, i) => {
  7347. return toMs(d) + toMs(delays[i])
  7348. }))
  7349. }
  7350. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7351. // in a locale-dependent way, using a comma instead of a dot.
  7352. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7353. // as a floor function) causing unexpected behaviors
  7354. function toMs (s) {
  7355. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  7356. }
  7357. /* */
  7358. function enter (vnode, toggleDisplay) {
  7359. const el = vnode.elm;
  7360. // call leave callback now
  7361. if (isDef(el._leaveCb)) {
  7362. el._leaveCb.cancelled = true;
  7363. el._leaveCb();
  7364. }
  7365. const data = resolveTransition(vnode.data.transition);
  7366. if (isUndef(data)) {
  7367. return
  7368. }
  7369. /* istanbul ignore if */
  7370. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7371. return
  7372. }
  7373. const {
  7374. css,
  7375. type,
  7376. enterClass,
  7377. enterToClass,
  7378. enterActiveClass,
  7379. appearClass,
  7380. appearToClass,
  7381. appearActiveClass,
  7382. beforeEnter,
  7383. enter,
  7384. afterEnter,
  7385. enterCancelled,
  7386. beforeAppear,
  7387. appear,
  7388. afterAppear,
  7389. appearCancelled,
  7390. duration
  7391. } = data;
  7392. // activeInstance will always be the <transition> component managing this
  7393. // transition. One edge case to check is when the <transition> is placed
  7394. // as the root node of a child component. In that case we need to check
  7395. // <transition>'s parent for appear check.
  7396. let context = activeInstance;
  7397. let transitionNode = activeInstance.$vnode;
  7398. while (transitionNode && transitionNode.parent) {
  7399. context = transitionNode.context;
  7400. transitionNode = transitionNode.parent;
  7401. }
  7402. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7403. if (isAppear && !appear && appear !== '') {
  7404. return
  7405. }
  7406. const startClass = isAppear && appearClass
  7407. ? appearClass
  7408. : enterClass;
  7409. const activeClass = isAppear && appearActiveClass
  7410. ? appearActiveClass
  7411. : enterActiveClass;
  7412. const toClass = isAppear && appearToClass
  7413. ? appearToClass
  7414. : enterToClass;
  7415. const beforeEnterHook = isAppear
  7416. ? (beforeAppear || beforeEnter)
  7417. : beforeEnter;
  7418. const enterHook = isAppear
  7419. ? (typeof appear === 'function' ? appear : enter)
  7420. : enter;
  7421. const afterEnterHook = isAppear
  7422. ? (afterAppear || afterEnter)
  7423. : afterEnter;
  7424. const enterCancelledHook = isAppear
  7425. ? (appearCancelled || enterCancelled)
  7426. : enterCancelled;
  7427. const explicitEnterDuration = toNumber(
  7428. isObject(duration)
  7429. ? duration.enter
  7430. : duration
  7431. );
  7432. if (explicitEnterDuration != null) {
  7433. checkDuration(explicitEnterDuration, 'enter', vnode);
  7434. }
  7435. const expectsCSS = css !== false && !isIE9;
  7436. const userWantsControl = getHookArgumentsLength(enterHook);
  7437. const cb = el._enterCb = once(() => {
  7438. if (expectsCSS) {
  7439. removeTransitionClass(el, toClass);
  7440. removeTransitionClass(el, activeClass);
  7441. }
  7442. if (cb.cancelled) {
  7443. if (expectsCSS) {
  7444. removeTransitionClass(el, startClass);
  7445. }
  7446. enterCancelledHook && enterCancelledHook(el);
  7447. } else {
  7448. afterEnterHook && afterEnterHook(el);
  7449. }
  7450. el._enterCb = null;
  7451. });
  7452. if (!vnode.data.show) {
  7453. // remove pending leave element on enter by injecting an insert hook
  7454. mergeVNodeHook(vnode, 'insert', () => {
  7455. const parent = el.parentNode;
  7456. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7457. if (pendingNode &&
  7458. pendingNode.tag === vnode.tag &&
  7459. pendingNode.elm._leaveCb
  7460. ) {
  7461. pendingNode.elm._leaveCb();
  7462. }
  7463. enterHook && enterHook(el, cb);
  7464. });
  7465. }
  7466. // start enter transition
  7467. beforeEnterHook && beforeEnterHook(el);
  7468. if (expectsCSS) {
  7469. addTransitionClass(el, startClass);
  7470. addTransitionClass(el, activeClass);
  7471. nextFrame(() => {
  7472. removeTransitionClass(el, startClass);
  7473. if (!cb.cancelled) {
  7474. addTransitionClass(el, toClass);
  7475. if (!userWantsControl) {
  7476. if (isValidDuration(explicitEnterDuration)) {
  7477. setTimeout(cb, explicitEnterDuration);
  7478. } else {
  7479. whenTransitionEnds(el, type, cb);
  7480. }
  7481. }
  7482. }
  7483. });
  7484. }
  7485. if (vnode.data.show) {
  7486. toggleDisplay && toggleDisplay();
  7487. enterHook && enterHook(el, cb);
  7488. }
  7489. if (!expectsCSS && !userWantsControl) {
  7490. cb();
  7491. }
  7492. }
  7493. function leave (vnode, rm) {
  7494. const el = vnode.elm;
  7495. // call enter callback now
  7496. if (isDef(el._enterCb)) {
  7497. el._enterCb.cancelled = true;
  7498. el._enterCb();
  7499. }
  7500. const data = resolveTransition(vnode.data.transition);
  7501. if (isUndef(data) || el.nodeType !== 1) {
  7502. return rm()
  7503. }
  7504. /* istanbul ignore if */
  7505. if (isDef(el._leaveCb)) {
  7506. return
  7507. }
  7508. const {
  7509. css,
  7510. type,
  7511. leaveClass,
  7512. leaveToClass,
  7513. leaveActiveClass,
  7514. beforeLeave,
  7515. leave,
  7516. afterLeave,
  7517. leaveCancelled,
  7518. delayLeave,
  7519. duration
  7520. } = data;
  7521. const expectsCSS = css !== false && !isIE9;
  7522. const userWantsControl = getHookArgumentsLength(leave);
  7523. const explicitLeaveDuration = toNumber(
  7524. isObject(duration)
  7525. ? duration.leave
  7526. : duration
  7527. );
  7528. if (isDef(explicitLeaveDuration)) {
  7529. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7530. }
  7531. const cb = el._leaveCb = once(() => {
  7532. if (el.parentNode && el.parentNode._pending) {
  7533. el.parentNode._pending[vnode.key] = null;
  7534. }
  7535. if (expectsCSS) {
  7536. removeTransitionClass(el, leaveToClass);
  7537. removeTransitionClass(el, leaveActiveClass);
  7538. }
  7539. if (cb.cancelled) {
  7540. if (expectsCSS) {
  7541. removeTransitionClass(el, leaveClass);
  7542. }
  7543. leaveCancelled && leaveCancelled(el);
  7544. } else {
  7545. rm();
  7546. afterLeave && afterLeave(el);
  7547. }
  7548. el._leaveCb = null;
  7549. });
  7550. if (delayLeave) {
  7551. delayLeave(performLeave);
  7552. } else {
  7553. performLeave();
  7554. }
  7555. function performLeave () {
  7556. // the delayed leave may have already been cancelled
  7557. if (cb.cancelled) {
  7558. return
  7559. }
  7560. // record leaving element
  7561. if (!vnode.data.show && el.parentNode) {
  7562. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7563. }
  7564. beforeLeave && beforeLeave(el);
  7565. if (expectsCSS) {
  7566. addTransitionClass(el, leaveClass);
  7567. addTransitionClass(el, leaveActiveClass);
  7568. nextFrame(() => {
  7569. removeTransitionClass(el, leaveClass);
  7570. if (!cb.cancelled) {
  7571. addTransitionClass(el, leaveToClass);
  7572. if (!userWantsControl) {
  7573. if (isValidDuration(explicitLeaveDuration)) {
  7574. setTimeout(cb, explicitLeaveDuration);
  7575. } else {
  7576. whenTransitionEnds(el, type, cb);
  7577. }
  7578. }
  7579. }
  7580. });
  7581. }
  7582. leave && leave(el, cb);
  7583. if (!expectsCSS && !userWantsControl) {
  7584. cb();
  7585. }
  7586. }
  7587. }
  7588. // only used in dev mode
  7589. function checkDuration (val, name, vnode) {
  7590. if (typeof val !== 'number') {
  7591. warn(
  7592. `<transition> explicit ${name} duration is not a valid number - ` +
  7593. `got ${JSON.stringify(val)}.`,
  7594. vnode.context
  7595. );
  7596. } else if (isNaN(val)) {
  7597. warn(
  7598. `<transition> explicit ${name} duration is NaN - ` +
  7599. 'the duration expression might be incorrect.',
  7600. vnode.context
  7601. );
  7602. }
  7603. }
  7604. function isValidDuration (val) {
  7605. return typeof val === 'number' && !isNaN(val)
  7606. }
  7607. /**
  7608. * Normalize a transition hook's argument length. The hook may be:
  7609. * - a merged hook (invoker) with the original in .fns
  7610. * - a wrapped component method (check ._length)
  7611. * - a plain function (.length)
  7612. */
  7613. function getHookArgumentsLength (fn) {
  7614. if (isUndef(fn)) {
  7615. return false
  7616. }
  7617. const invokerFns = fn.fns;
  7618. if (isDef(invokerFns)) {
  7619. // invoker
  7620. return getHookArgumentsLength(
  7621. Array.isArray(invokerFns)
  7622. ? invokerFns[0]
  7623. : invokerFns
  7624. )
  7625. } else {
  7626. return (fn._length || fn.length) > 1
  7627. }
  7628. }
  7629. function _enter (_, vnode) {
  7630. if (vnode.data.show !== true) {
  7631. enter(vnode);
  7632. }
  7633. }
  7634. var transition = inBrowser ? {
  7635. create: _enter,
  7636. activate: _enter,
  7637. remove (vnode, rm) {
  7638. /* istanbul ignore else */
  7639. if (vnode.data.show !== true) {
  7640. leave(vnode, rm);
  7641. } else {
  7642. rm();
  7643. }
  7644. }
  7645. } : {};
  7646. var platformModules = [
  7647. attrs,
  7648. klass,
  7649. events,
  7650. domProps,
  7651. style,
  7652. transition
  7653. ];
  7654. /* */
  7655. // the directive module should be applied last, after all
  7656. // built-in modules have been applied.
  7657. const modules = platformModules.concat(baseModules);
  7658. const patch = createPatchFunction({ nodeOps, modules });
  7659. /**
  7660. * Not type checking this file because flow doesn't like attaching
  7661. * properties to Elements.
  7662. */
  7663. /* istanbul ignore if */
  7664. if (isIE9) {
  7665. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7666. document.addEventListener('selectionchange', () => {
  7667. const el = document.activeElement;
  7668. if (el && el.vmodel) {
  7669. trigger(el, 'input');
  7670. }
  7671. });
  7672. }
  7673. const directive = {
  7674. inserted (el, binding, vnode, oldVnode) {
  7675. if (vnode.tag === 'select') {
  7676. // #6903
  7677. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7678. mergeVNodeHook(vnode, 'postpatch', () => {
  7679. directive.componentUpdated(el, binding, vnode);
  7680. });
  7681. } else {
  7682. setSelected(el, binding, vnode.context);
  7683. }
  7684. el._vOptions = [].map.call(el.options, getValue);
  7685. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7686. el._vModifiers = binding.modifiers;
  7687. if (!binding.modifiers.lazy) {
  7688. el.addEventListener('compositionstart', onCompositionStart);
  7689. el.addEventListener('compositionend', onCompositionEnd);
  7690. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7691. // switching focus before confirming composition choice
  7692. // this also fixes the issue where some browsers e.g. iOS Chrome
  7693. // fires "change" instead of "input" on autocomplete.
  7694. el.addEventListener('change', onCompositionEnd);
  7695. /* istanbul ignore if */
  7696. if (isIE9) {
  7697. el.vmodel = true;
  7698. }
  7699. }
  7700. }
  7701. },
  7702. componentUpdated (el, binding, vnode) {
  7703. if (vnode.tag === 'select') {
  7704. setSelected(el, binding, vnode.context);
  7705. // in case the options rendered by v-for have changed,
  7706. // it's possible that the value is out-of-sync with the rendered options.
  7707. // detect such cases and filter out values that no longer has a matching
  7708. // option in the DOM.
  7709. const prevOptions = el._vOptions;
  7710. const curOptions = el._vOptions = [].map.call(el.options, getValue);
  7711. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  7712. // trigger change event if
  7713. // no matching option found for at least one value
  7714. const needReset = el.multiple
  7715. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  7716. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7717. if (needReset) {
  7718. trigger(el, 'change');
  7719. }
  7720. }
  7721. }
  7722. }
  7723. };
  7724. function setSelected (el, binding, vm) {
  7725. actuallySetSelected(el, binding, vm);
  7726. /* istanbul ignore if */
  7727. if (isIE || isEdge) {
  7728. setTimeout(() => {
  7729. actuallySetSelected(el, binding, vm);
  7730. }, 0);
  7731. }
  7732. }
  7733. function actuallySetSelected (el, binding, vm) {
  7734. const value = binding.value;
  7735. const isMultiple = el.multiple;
  7736. if (isMultiple && !Array.isArray(value)) {
  7737. warn(
  7738. `<select multiple v-model="${binding.expression}"> ` +
  7739. `expects an Array value for its binding, but got ${
  7740. Object.prototype.toString.call(value).slice(8, -1)
  7741. }`,
  7742. vm
  7743. );
  7744. return
  7745. }
  7746. let selected, option;
  7747. for (let i = 0, l = el.options.length; i < l; i++) {
  7748. option = el.options[i];
  7749. if (isMultiple) {
  7750. selected = looseIndexOf(value, getValue(option)) > -1;
  7751. if (option.selected !== selected) {
  7752. option.selected = selected;
  7753. }
  7754. } else {
  7755. if (looseEqual(getValue(option), value)) {
  7756. if (el.selectedIndex !== i) {
  7757. el.selectedIndex = i;
  7758. }
  7759. return
  7760. }
  7761. }
  7762. }
  7763. if (!isMultiple) {
  7764. el.selectedIndex = -1;
  7765. }
  7766. }
  7767. function hasNoMatchingOption (value, options) {
  7768. return options.every(o => !looseEqual(o, value))
  7769. }
  7770. function getValue (option) {
  7771. return '_value' in option
  7772. ? option._value
  7773. : option.value
  7774. }
  7775. function onCompositionStart (e) {
  7776. e.target.composing = true;
  7777. }
  7778. function onCompositionEnd (e) {
  7779. // prevent triggering an input event for no reason
  7780. if (!e.target.composing) return
  7781. e.target.composing = false;
  7782. trigger(e.target, 'input');
  7783. }
  7784. function trigger (el, type) {
  7785. const e = document.createEvent('HTMLEvents');
  7786. e.initEvent(type, true, true);
  7787. el.dispatchEvent(e);
  7788. }
  7789. /* */
  7790. // recursively search for possible transition defined inside the component root
  7791. function locateNode (vnode) {
  7792. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7793. ? locateNode(vnode.componentInstance._vnode)
  7794. : vnode
  7795. }
  7796. var show = {
  7797. bind (el, { value }, vnode) {
  7798. vnode = locateNode(vnode);
  7799. const transition$$1 = vnode.data && vnode.data.transition;
  7800. const originalDisplay = el.__vOriginalDisplay =
  7801. el.style.display === 'none' ? '' : el.style.display;
  7802. if (value && transition$$1) {
  7803. vnode.data.show = true;
  7804. enter(vnode, () => {
  7805. el.style.display = originalDisplay;
  7806. });
  7807. } else {
  7808. el.style.display = value ? originalDisplay : 'none';
  7809. }
  7810. },
  7811. update (el, { value, oldValue }, vnode) {
  7812. /* istanbul ignore if */
  7813. if (!value === !oldValue) return
  7814. vnode = locateNode(vnode);
  7815. const transition$$1 = vnode.data && vnode.data.transition;
  7816. if (transition$$1) {
  7817. vnode.data.show = true;
  7818. if (value) {
  7819. enter(vnode, () => {
  7820. el.style.display = el.__vOriginalDisplay;
  7821. });
  7822. } else {
  7823. leave(vnode, () => {
  7824. el.style.display = 'none';
  7825. });
  7826. }
  7827. } else {
  7828. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7829. }
  7830. },
  7831. unbind (
  7832. el,
  7833. binding,
  7834. vnode,
  7835. oldVnode,
  7836. isDestroy
  7837. ) {
  7838. if (!isDestroy) {
  7839. el.style.display = el.__vOriginalDisplay;
  7840. }
  7841. }
  7842. };
  7843. var platformDirectives = {
  7844. model: directive,
  7845. show
  7846. };
  7847. /* */
  7848. const transitionProps = {
  7849. name: String,
  7850. appear: Boolean,
  7851. css: Boolean,
  7852. mode: String,
  7853. type: String,
  7854. enterClass: String,
  7855. leaveClass: String,
  7856. enterToClass: String,
  7857. leaveToClass: String,
  7858. enterActiveClass: String,
  7859. leaveActiveClass: String,
  7860. appearClass: String,
  7861. appearActiveClass: String,
  7862. appearToClass: String,
  7863. duration: [Number, String, Object]
  7864. };
  7865. // in case the child is also an abstract component, e.g. <keep-alive>
  7866. // we want to recursively retrieve the real component to be rendered
  7867. function getRealChild (vnode) {
  7868. const compOptions = vnode && vnode.componentOptions;
  7869. if (compOptions && compOptions.Ctor.options.abstract) {
  7870. return getRealChild(getFirstComponentChild(compOptions.children))
  7871. } else {
  7872. return vnode
  7873. }
  7874. }
  7875. function extractTransitionData (comp) {
  7876. const data = {};
  7877. const options = comp.$options;
  7878. // props
  7879. for (const key in options.propsData) {
  7880. data[key] = comp[key];
  7881. }
  7882. // events.
  7883. // extract listeners and pass them directly to the transition methods
  7884. const listeners = options._parentListeners;
  7885. for (const key in listeners) {
  7886. data[camelize(key)] = listeners[key];
  7887. }
  7888. return data
  7889. }
  7890. function placeholder (h, rawChild) {
  7891. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7892. return h('keep-alive', {
  7893. props: rawChild.componentOptions.propsData
  7894. })
  7895. }
  7896. }
  7897. function hasParentTransition (vnode) {
  7898. while ((vnode = vnode.parent)) {
  7899. if (vnode.data.transition) {
  7900. return true
  7901. }
  7902. }
  7903. }
  7904. function isSameChild (child, oldChild) {
  7905. return oldChild.key === child.key && oldChild.tag === child.tag
  7906. }
  7907. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  7908. const isVShowDirective = d => d.name === 'show';
  7909. var Transition = {
  7910. name: 'transition',
  7911. props: transitionProps,
  7912. abstract: true,
  7913. render (h) {
  7914. let children = this.$slots.default;
  7915. if (!children) {
  7916. return
  7917. }
  7918. // filter out text nodes (possible whitespaces)
  7919. children = children.filter(isNotTextNode);
  7920. /* istanbul ignore if */
  7921. if (!children.length) {
  7922. return
  7923. }
  7924. // warn multiple elements
  7925. if (children.length > 1) {
  7926. warn(
  7927. '<transition> can only be used on a single element. Use ' +
  7928. '<transition-group> for lists.',
  7929. this.$parent
  7930. );
  7931. }
  7932. const mode = this.mode;
  7933. // warn invalid mode
  7934. if (mode && mode !== 'in-out' && mode !== 'out-in'
  7935. ) {
  7936. warn(
  7937. 'invalid <transition> mode: ' + mode,
  7938. this.$parent
  7939. );
  7940. }
  7941. const rawChild = children[0];
  7942. // if this is a component root node and the component's
  7943. // parent container node also has transition, skip.
  7944. if (hasParentTransition(this.$vnode)) {
  7945. return rawChild
  7946. }
  7947. // apply transition data to child
  7948. // use getRealChild() to ignore abstract components e.g. keep-alive
  7949. const child = getRealChild(rawChild);
  7950. /* istanbul ignore if */
  7951. if (!child) {
  7952. return rawChild
  7953. }
  7954. if (this._leaving) {
  7955. return placeholder(h, rawChild)
  7956. }
  7957. // ensure a key that is unique to the vnode type and to this transition
  7958. // component instance. This key will be used to remove pending leaving nodes
  7959. // during entering.
  7960. const id = `__transition-${this._uid}-`;
  7961. child.key = child.key == null
  7962. ? child.isComment
  7963. ? id + 'comment'
  7964. : id + child.tag
  7965. : isPrimitive(child.key)
  7966. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7967. : child.key;
  7968. const data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7969. const oldRawChild = this._vnode;
  7970. const oldChild = getRealChild(oldRawChild);
  7971. // mark v-show
  7972. // so that the transition module can hand over the control to the directive
  7973. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7974. child.data.show = true;
  7975. }
  7976. if (
  7977. oldChild &&
  7978. oldChild.data &&
  7979. !isSameChild(child, oldChild) &&
  7980. !isAsyncPlaceholder(oldChild) &&
  7981. // #6687 component root is a comment node
  7982. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7983. ) {
  7984. // replace old child transition data with fresh one
  7985. // important for dynamic transitions!
  7986. const oldData = oldChild.data.transition = extend({}, data);
  7987. // handle transition mode
  7988. if (mode === 'out-in') {
  7989. // return placeholder node and queue update when leave finishes
  7990. this._leaving = true;
  7991. mergeVNodeHook(oldData, 'afterLeave', () => {
  7992. this._leaving = false;
  7993. this.$forceUpdate();
  7994. });
  7995. return placeholder(h, rawChild)
  7996. } else if (mode === 'in-out') {
  7997. if (isAsyncPlaceholder(child)) {
  7998. return oldRawChild
  7999. }
  8000. let delayedLeave;
  8001. const performLeave = () => { delayedLeave(); };
  8002. mergeVNodeHook(data, 'afterEnter', performLeave);
  8003. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8004. mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave; });
  8005. }
  8006. }
  8007. return rawChild
  8008. }
  8009. };
  8010. /* */
  8011. const props = extend({
  8012. tag: String,
  8013. moveClass: String
  8014. }, transitionProps);
  8015. delete props.mode;
  8016. var TransitionGroup = {
  8017. props,
  8018. beforeMount () {
  8019. const update = this._update;
  8020. this._update = (vnode, hydrating) => {
  8021. const restoreActiveInstance = setActiveInstance(this);
  8022. // force removing pass
  8023. this.__patch__(
  8024. this._vnode,
  8025. this.kept,
  8026. false, // hydrating
  8027. true // removeOnly (!important, avoids unnecessary moves)
  8028. );
  8029. this._vnode = this.kept;
  8030. restoreActiveInstance();
  8031. update.call(this, vnode, hydrating);
  8032. };
  8033. },
  8034. render (h) {
  8035. const tag = this.tag || this.$vnode.data.tag || 'span';
  8036. const map = Object.create(null);
  8037. const prevChildren = this.prevChildren = this.children;
  8038. const rawChildren = this.$slots.default || [];
  8039. const children = this.children = [];
  8040. const transitionData = extractTransitionData(this);
  8041. for (let i = 0; i < rawChildren.length; i++) {
  8042. const c = rawChildren[i];
  8043. if (c.tag) {
  8044. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8045. children.push(c);
  8046. map[c.key] = c
  8047. ;(c.data || (c.data = {})).transition = transitionData;
  8048. } else {
  8049. const opts = c.componentOptions;
  8050. const name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  8051. warn(`<transition-group> children must be keyed: <${name}>`);
  8052. }
  8053. }
  8054. }
  8055. if (prevChildren) {
  8056. const kept = [];
  8057. const removed = [];
  8058. for (let i = 0; i < prevChildren.length; i++) {
  8059. const c = prevChildren[i];
  8060. c.data.transition = transitionData;
  8061. c.data.pos = c.elm.getBoundingClientRect();
  8062. if (map[c.key]) {
  8063. kept.push(c);
  8064. } else {
  8065. removed.push(c);
  8066. }
  8067. }
  8068. this.kept = h(tag, null, kept);
  8069. this.removed = removed;
  8070. }
  8071. return h(tag, null, children)
  8072. },
  8073. updated () {
  8074. const children = this.prevChildren;
  8075. const moveClass = this.moveClass || ((this.name || 'v') + '-move');
  8076. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8077. return
  8078. }
  8079. // we divide the work into three loops to avoid mixing DOM reads and writes
  8080. // in each iteration - which helps prevent layout thrashing.
  8081. children.forEach(callPendingCbs);
  8082. children.forEach(recordPosition);
  8083. children.forEach(applyTranslation);
  8084. // force reflow to put everything in position
  8085. // assign to this to avoid being removed in tree-shaking
  8086. // $flow-disable-line
  8087. this._reflow = document.body.offsetHeight;
  8088. children.forEach((c) => {
  8089. if (c.data.moved) {
  8090. const el = c.elm;
  8091. const s = el.style;
  8092. addTransitionClass(el, moveClass);
  8093. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8094. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  8095. if (e && e.target !== el) {
  8096. return
  8097. }
  8098. if (!e || /transform$/.test(e.propertyName)) {
  8099. el.removeEventListener(transitionEndEvent, cb);
  8100. el._moveCb = null;
  8101. removeTransitionClass(el, moveClass);
  8102. }
  8103. });
  8104. }
  8105. });
  8106. },
  8107. methods: {
  8108. hasMove (el, moveClass) {
  8109. /* istanbul ignore if */
  8110. if (!hasTransition) {
  8111. return false
  8112. }
  8113. /* istanbul ignore if */
  8114. if (this._hasMove) {
  8115. return this._hasMove
  8116. }
  8117. // Detect whether an element with the move class applied has
  8118. // CSS transitions. Since the element may be inside an entering
  8119. // transition at this very moment, we make a clone of it and remove
  8120. // all other transition classes applied to ensure only the move class
  8121. // is applied.
  8122. const clone = el.cloneNode();
  8123. if (el._transitionClasses) {
  8124. el._transitionClasses.forEach((cls) => { removeClass(clone, cls); });
  8125. }
  8126. addClass(clone, moveClass);
  8127. clone.style.display = 'none';
  8128. this.$el.appendChild(clone);
  8129. const info = getTransitionInfo(clone);
  8130. this.$el.removeChild(clone);
  8131. return (this._hasMove = info.hasTransform)
  8132. }
  8133. }
  8134. };
  8135. function callPendingCbs (c) {
  8136. /* istanbul ignore if */
  8137. if (c.elm._moveCb) {
  8138. c.elm._moveCb();
  8139. }
  8140. /* istanbul ignore if */
  8141. if (c.elm._enterCb) {
  8142. c.elm._enterCb();
  8143. }
  8144. }
  8145. function recordPosition (c) {
  8146. c.data.newPos = c.elm.getBoundingClientRect();
  8147. }
  8148. function applyTranslation (c) {
  8149. const oldPos = c.data.pos;
  8150. const newPos = c.data.newPos;
  8151. const dx = oldPos.left - newPos.left;
  8152. const dy = oldPos.top - newPos.top;
  8153. if (dx || dy) {
  8154. c.data.moved = true;
  8155. const s = c.elm.style;
  8156. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8157. s.transitionDuration = '0s';
  8158. }
  8159. }
  8160. var platformComponents = {
  8161. Transition,
  8162. TransitionGroup
  8163. };
  8164. /* */
  8165. // install platform specific utils
  8166. Vue.config.mustUseProp = mustUseProp;
  8167. Vue.config.isReservedTag = isReservedTag;
  8168. Vue.config.isReservedAttr = isReservedAttr;
  8169. Vue.config.getTagNamespace = getTagNamespace;
  8170. Vue.config.isUnknownElement = isUnknownElement;
  8171. // install platform runtime directives & components
  8172. extend(Vue.options.directives, platformDirectives);
  8173. extend(Vue.options.components, platformComponents);
  8174. // install platform patch function
  8175. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8176. // public mount method
  8177. Vue.prototype.$mount = function (
  8178. el,
  8179. hydrating
  8180. ) {
  8181. el = el && inBrowser ? query(el) : undefined;
  8182. return mountComponent(this, el, hydrating)
  8183. };
  8184. // devtools global hook
  8185. /* istanbul ignore next */
  8186. if (inBrowser) {
  8187. setTimeout(() => {
  8188. if (config.devtools) {
  8189. if (devtools) {
  8190. devtools.emit('init', Vue);
  8191. } else {
  8192. console[console.info ? 'info' : 'log'](
  8193. 'Download the Vue Devtools extension for a better development experience:\n' +
  8194. 'https://github.com/vuejs/vue-devtools'
  8195. );
  8196. }
  8197. }
  8198. if (config.productionTip !== false &&
  8199. typeof console !== 'undefined'
  8200. ) {
  8201. console[console.info ? 'info' : 'log'](
  8202. `You are running Vue in development mode.\n` +
  8203. `Make sure to turn on production mode when deploying for production.\n` +
  8204. `See more tips at https://vuejs.org/guide/deployment.html`
  8205. );
  8206. }
  8207. }, 0);
  8208. }
  8209. /* */
  8210. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  8211. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  8212. const buildRegex = cached(delimiters => {
  8213. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  8214. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  8215. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  8216. });
  8217. function parseText (
  8218. text,
  8219. delimiters
  8220. ) {
  8221. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  8222. if (!tagRE.test(text)) {
  8223. return
  8224. }
  8225. const tokens = [];
  8226. const rawTokens = [];
  8227. let lastIndex = tagRE.lastIndex = 0;
  8228. let match, index, tokenValue;
  8229. while ((match = tagRE.exec(text))) {
  8230. index = match.index;
  8231. // push text token
  8232. if (index > lastIndex) {
  8233. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  8234. tokens.push(JSON.stringify(tokenValue));
  8235. }
  8236. // tag token
  8237. const exp = parseFilters(match[1].trim());
  8238. tokens.push(`_s(${exp})`);
  8239. rawTokens.push({ '@binding': exp });
  8240. lastIndex = index + match[0].length;
  8241. }
  8242. if (lastIndex < text.length) {
  8243. rawTokens.push(tokenValue = text.slice(lastIndex));
  8244. tokens.push(JSON.stringify(tokenValue));
  8245. }
  8246. return {
  8247. expression: tokens.join('+'),
  8248. tokens: rawTokens
  8249. }
  8250. }
  8251. /* */
  8252. function transformNode (el, options) {
  8253. const warn = options.warn || baseWarn;
  8254. const staticClass = getAndRemoveAttr(el, 'class');
  8255. if (staticClass) {
  8256. const res = parseText(staticClass, options.delimiters);
  8257. if (res) {
  8258. warn(
  8259. `class="${staticClass}": ` +
  8260. 'Interpolation inside attributes has been removed. ' +
  8261. 'Use v-bind or the colon shorthand instead. For example, ' +
  8262. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  8263. el.rawAttrsMap['class']
  8264. );
  8265. }
  8266. }
  8267. if (staticClass) {
  8268. el.staticClass = JSON.stringify(staticClass);
  8269. }
  8270. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  8271. if (classBinding) {
  8272. el.classBinding = classBinding;
  8273. }
  8274. }
  8275. function genData (el) {
  8276. let data = '';
  8277. if (el.staticClass) {
  8278. data += `staticClass:${el.staticClass},`;
  8279. }
  8280. if (el.classBinding) {
  8281. data += `class:${el.classBinding},`;
  8282. }
  8283. return data
  8284. }
  8285. var klass$1 = {
  8286. staticKeys: ['staticClass'],
  8287. transformNode,
  8288. genData
  8289. };
  8290. /* */
  8291. function transformNode$1 (el, options) {
  8292. const warn = options.warn || baseWarn;
  8293. const staticStyle = getAndRemoveAttr(el, 'style');
  8294. if (staticStyle) {
  8295. /* istanbul ignore if */
  8296. {
  8297. const res = parseText(staticStyle, options.delimiters);
  8298. if (res) {
  8299. warn(
  8300. `style="${staticStyle}": ` +
  8301. 'Interpolation inside attributes has been removed. ' +
  8302. 'Use v-bind or the colon shorthand instead. For example, ' +
  8303. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  8304. el.rawAttrsMap['style']
  8305. );
  8306. }
  8307. }
  8308. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  8309. }
  8310. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  8311. if (styleBinding) {
  8312. el.styleBinding = styleBinding;
  8313. }
  8314. }
  8315. function genData$1 (el) {
  8316. let data = '';
  8317. if (el.staticStyle) {
  8318. data += `staticStyle:${el.staticStyle},`;
  8319. }
  8320. if (el.styleBinding) {
  8321. data += `style:(${el.styleBinding}),`;
  8322. }
  8323. return data
  8324. }
  8325. var style$1 = {
  8326. staticKeys: ['staticStyle'],
  8327. transformNode: transformNode$1,
  8328. genData: genData$1
  8329. };
  8330. /* */
  8331. let decoder;
  8332. var he = {
  8333. decode (html) {
  8334. decoder = decoder || document.createElement('div');
  8335. decoder.innerHTML = html;
  8336. return decoder.textContent
  8337. }
  8338. };
  8339. /* */
  8340. const isUnaryTag = makeMap(
  8341. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  8342. 'link,meta,param,source,track,wbr'
  8343. );
  8344. // Elements that you can, intentionally, leave open
  8345. // (and which close themselves)
  8346. const canBeLeftOpenTag = makeMap(
  8347. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  8348. );
  8349. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  8350. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  8351. const isNonPhrasingTag = makeMap(
  8352. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  8353. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  8354. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  8355. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  8356. 'title,tr,track'
  8357. );
  8358. /**
  8359. * Not type-checking this file because it's mostly vendor code.
  8360. */
  8361. // Regular Expressions for parsing tags and attributes
  8362. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8363. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8364. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  8365. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  8366. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  8367. const startTagClose = /^\s*(\/?)>/;
  8368. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  8369. const doctype = /^<!DOCTYPE [^>]+>/i;
  8370. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  8371. const comment = /^<!\--/;
  8372. const conditionalComment = /^<!\[/;
  8373. // Special Elements (can contain anything)
  8374. const isPlainTextElement = makeMap('script,style,textarea', true);
  8375. const reCache = {};
  8376. const decodingMap = {
  8377. '&lt;': '<',
  8378. '&gt;': '>',
  8379. '&quot;': '"',
  8380. '&amp;': '&',
  8381. '&#10;': '\n',
  8382. '&#9;': '\t',
  8383. '&#39;': "'"
  8384. };
  8385. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  8386. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  8387. // #5992
  8388. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  8389. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  8390. function decodeAttr (value, shouldDecodeNewlines) {
  8391. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  8392. return value.replace(re, match => decodingMap[match])
  8393. }
  8394. function parseHTML (html, options) {
  8395. const stack = [];
  8396. const expectHTML = options.expectHTML;
  8397. const isUnaryTag$$1 = options.isUnaryTag || no;
  8398. const canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  8399. let index = 0;
  8400. let last, lastTag;
  8401. while (html) {
  8402. last = html;
  8403. // Make sure we're not in a plaintext content element like script/style
  8404. if (!lastTag || !isPlainTextElement(lastTag)) {
  8405. let textEnd = html.indexOf('<');
  8406. if (textEnd === 0) {
  8407. // Comment:
  8408. if (comment.test(html)) {
  8409. const commentEnd = html.indexOf('-->');
  8410. if (commentEnd >= 0) {
  8411. if (options.shouldKeepComment) {
  8412. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  8413. }
  8414. advance(commentEnd + 3);
  8415. continue
  8416. }
  8417. }
  8418. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  8419. if (conditionalComment.test(html)) {
  8420. const conditionalEnd = html.indexOf(']>');
  8421. if (conditionalEnd >= 0) {
  8422. advance(conditionalEnd + 2);
  8423. continue
  8424. }
  8425. }
  8426. // Doctype:
  8427. const doctypeMatch = html.match(doctype);
  8428. if (doctypeMatch) {
  8429. advance(doctypeMatch[0].length);
  8430. continue
  8431. }
  8432. // End tag:
  8433. const endTagMatch = html.match(endTag);
  8434. if (endTagMatch) {
  8435. const curIndex = index;
  8436. advance(endTagMatch[0].length);
  8437. parseEndTag(endTagMatch[1], curIndex, index);
  8438. continue
  8439. }
  8440. // Start tag:
  8441. const startTagMatch = parseStartTag();
  8442. if (startTagMatch) {
  8443. handleStartTag(startTagMatch);
  8444. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  8445. advance(1);
  8446. }
  8447. continue
  8448. }
  8449. }
  8450. let text, rest, next;
  8451. if (textEnd >= 0) {
  8452. rest = html.slice(textEnd);
  8453. while (
  8454. !endTag.test(rest) &&
  8455. !startTagOpen.test(rest) &&
  8456. !comment.test(rest) &&
  8457. !conditionalComment.test(rest)
  8458. ) {
  8459. // < in plain text, be forgiving and treat it as text
  8460. next = rest.indexOf('<', 1);
  8461. if (next < 0) break
  8462. textEnd += next;
  8463. rest = html.slice(textEnd);
  8464. }
  8465. text = html.substring(0, textEnd);
  8466. }
  8467. if (textEnd < 0) {
  8468. text = html;
  8469. }
  8470. if (text) {
  8471. advance(text.length);
  8472. }
  8473. if (options.chars && text) {
  8474. options.chars(text, index - text.length, index);
  8475. }
  8476. } else {
  8477. let endTagLength = 0;
  8478. const stackedTag = lastTag.toLowerCase();
  8479. const reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  8480. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  8481. endTagLength = endTag.length;
  8482. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  8483. text = text
  8484. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  8485. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  8486. }
  8487. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  8488. text = text.slice(1);
  8489. }
  8490. if (options.chars) {
  8491. options.chars(text);
  8492. }
  8493. return ''
  8494. });
  8495. index += html.length - rest.length;
  8496. html = rest;
  8497. parseEndTag(stackedTag, index - endTagLength, index);
  8498. }
  8499. if (html === last) {
  8500. options.chars && options.chars(html);
  8501. if (!stack.length && options.warn) {
  8502. options.warn(`Mal-formatted tag at end of template: "${html}"`, { start: index + html.length });
  8503. }
  8504. break
  8505. }
  8506. }
  8507. // Clean up any remaining tags
  8508. parseEndTag();
  8509. function advance (n) {
  8510. index += n;
  8511. html = html.substring(n);
  8512. }
  8513. function parseStartTag () {
  8514. const start = html.match(startTagOpen);
  8515. if (start) {
  8516. const match = {
  8517. tagName: start[1],
  8518. attrs: [],
  8519. start: index
  8520. };
  8521. advance(start[0].length);
  8522. let end, attr;
  8523. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  8524. attr.start = index;
  8525. advance(attr[0].length);
  8526. attr.end = index;
  8527. match.attrs.push(attr);
  8528. }
  8529. if (end) {
  8530. match.unarySlash = end[1];
  8531. advance(end[0].length);
  8532. match.end = index;
  8533. return match
  8534. }
  8535. }
  8536. }
  8537. function handleStartTag (match) {
  8538. const tagName = match.tagName;
  8539. const unarySlash = match.unarySlash;
  8540. if (expectHTML) {
  8541. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  8542. parseEndTag(lastTag);
  8543. }
  8544. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  8545. parseEndTag(tagName);
  8546. }
  8547. }
  8548. const unary = isUnaryTag$$1(tagName) || !!unarySlash;
  8549. const l = match.attrs.length;
  8550. const attrs = new Array(l);
  8551. for (let i = 0; i < l; i++) {
  8552. const args = match.attrs[i];
  8553. const value = args[3] || args[4] || args[5] || '';
  8554. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  8555. ? options.shouldDecodeNewlinesForHref
  8556. : options.shouldDecodeNewlines;
  8557. attrs[i] = {
  8558. name: args[1],
  8559. value: decodeAttr(value, shouldDecodeNewlines)
  8560. };
  8561. if (options.outputSourceRange) {
  8562. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  8563. attrs[i].end = args.end;
  8564. }
  8565. }
  8566. if (!unary) {
  8567. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  8568. lastTag = tagName;
  8569. }
  8570. if (options.start) {
  8571. options.start(tagName, attrs, unary, match.start, match.end);
  8572. }
  8573. }
  8574. function parseEndTag (tagName, start, end) {
  8575. let pos, lowerCasedTagName;
  8576. if (start == null) start = index;
  8577. if (end == null) end = index;
  8578. // Find the closest opened tag of the same type
  8579. if (tagName) {
  8580. lowerCasedTagName = tagName.toLowerCase();
  8581. for (pos = stack.length - 1; pos >= 0; pos--) {
  8582. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  8583. break
  8584. }
  8585. }
  8586. } else {
  8587. // If no tag name is provided, clean shop
  8588. pos = 0;
  8589. }
  8590. if (pos >= 0) {
  8591. // Close all the open elements, up the stack
  8592. for (let i = stack.length - 1; i >= pos; i--) {
  8593. if (i > pos || !tagName &&
  8594. options.warn
  8595. ) {
  8596. options.warn(
  8597. `tag <${stack[i].tag}> has no matching end tag.`,
  8598. { start: stack[i].start, end: stack[i].end }
  8599. );
  8600. }
  8601. if (options.end) {
  8602. options.end(stack[i].tag, start, end);
  8603. }
  8604. }
  8605. // Remove the open elements from the stack
  8606. stack.length = pos;
  8607. lastTag = pos && stack[pos - 1].tag;
  8608. } else if (lowerCasedTagName === 'br') {
  8609. if (options.start) {
  8610. options.start(tagName, [], true, start, end);
  8611. }
  8612. } else if (lowerCasedTagName === 'p') {
  8613. if (options.start) {
  8614. options.start(tagName, [], false, start, end);
  8615. }
  8616. if (options.end) {
  8617. options.end(tagName, start, end);
  8618. }
  8619. }
  8620. }
  8621. }
  8622. /* */
  8623. const onRE = /^@|^v-on:/;
  8624. const dirRE = /^v-|^@|^:|^#/;
  8625. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8626. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8627. const stripParensRE = /^\(|\)$/g;
  8628. const dynamicArgRE = /^\[.*\]$/;
  8629. const argRE = /:(.*)$/;
  8630. const bindRE = /^:|^\.|^v-bind:/;
  8631. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  8632. const slotRE = /^v-slot(:|$)|^#/;
  8633. const lineBreakRE = /[\r\n]/;
  8634. const whitespaceRE$1 = /[ \f\t\r\n]+/g;
  8635. const invalidAttributeRE = /[\s"'<>\/=]/;
  8636. const decodeHTMLCached = cached(he.decode);
  8637. const emptySlotScopeToken = `_empty_`;
  8638. // configurable state
  8639. let warn$2;
  8640. let delimiters;
  8641. let transforms;
  8642. let preTransforms;
  8643. let postTransforms;
  8644. let platformIsPreTag;
  8645. let platformMustUseProp;
  8646. let platformGetTagNamespace;
  8647. let maybeComponent;
  8648. function createASTElement (
  8649. tag,
  8650. attrs,
  8651. parent
  8652. ) {
  8653. return {
  8654. type: 1,
  8655. tag,
  8656. attrsList: attrs,
  8657. attrsMap: makeAttrsMap(attrs),
  8658. rawAttrsMap: {},
  8659. parent,
  8660. children: []
  8661. }
  8662. }
  8663. /**
  8664. * Convert HTML string to AST.
  8665. */
  8666. function parse (
  8667. template,
  8668. options
  8669. ) {
  8670. warn$2 = options.warn || baseWarn;
  8671. platformIsPreTag = options.isPreTag || no;
  8672. platformMustUseProp = options.mustUseProp || no;
  8673. platformGetTagNamespace = options.getTagNamespace || no;
  8674. const isReservedTag = options.isReservedTag || no;
  8675. maybeComponent = (el) => !!(
  8676. el.component ||
  8677. el.attrsMap[':is'] ||
  8678. el.attrsMap['v-bind:is'] ||
  8679. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag))
  8680. );
  8681. transforms = pluckModuleFunction(options.modules, 'transformNode');
  8682. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  8683. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  8684. delimiters = options.delimiters;
  8685. const stack = [];
  8686. const preserveWhitespace = options.preserveWhitespace !== false;
  8687. const whitespaceOption = options.whitespace;
  8688. let root;
  8689. let currentParent;
  8690. let inVPre = false;
  8691. let inPre = false;
  8692. let warned = false;
  8693. function warnOnce (msg, range) {
  8694. if (!warned) {
  8695. warned = true;
  8696. warn$2(msg, range);
  8697. }
  8698. }
  8699. function closeElement (element) {
  8700. trimEndingWhitespace(element);
  8701. if (!inVPre && !element.processed) {
  8702. element = processElement(element, options);
  8703. }
  8704. // tree management
  8705. if (!stack.length && element !== root) {
  8706. // allow root elements with v-if, v-else-if and v-else
  8707. if (root.if && (element.elseif || element.else)) {
  8708. {
  8709. checkRootConstraints(element);
  8710. }
  8711. addIfCondition(root, {
  8712. exp: element.elseif,
  8713. block: element
  8714. });
  8715. } else {
  8716. warnOnce(
  8717. `Component template should contain exactly one root element. ` +
  8718. `If you are using v-if on multiple elements, ` +
  8719. `use v-else-if to chain them instead.`,
  8720. { start: element.start }
  8721. );
  8722. }
  8723. }
  8724. if (currentParent && !element.forbidden) {
  8725. if (element.elseif || element.else) {
  8726. processIfConditions(element, currentParent);
  8727. } else {
  8728. if (element.slotScope) {
  8729. // scoped slot
  8730. // keep it in the children list so that v-else(-if) conditions can
  8731. // find it as the prev node.
  8732. const name = element.slotTarget || '"default"'
  8733. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  8734. }
  8735. currentParent.children.push(element);
  8736. element.parent = currentParent;
  8737. }
  8738. }
  8739. // final children cleanup
  8740. // filter out scoped slots
  8741. element.children = element.children.filter(c => !(c).slotScope);
  8742. // remove trailing whitespace node again
  8743. trimEndingWhitespace(element);
  8744. // check pre state
  8745. if (element.pre) {
  8746. inVPre = false;
  8747. }
  8748. if (platformIsPreTag(element.tag)) {
  8749. inPre = false;
  8750. }
  8751. // apply post-transforms
  8752. for (let i = 0; i < postTransforms.length; i++) {
  8753. postTransforms[i](element, options);
  8754. }
  8755. }
  8756. function trimEndingWhitespace (el) {
  8757. // remove trailing whitespace node
  8758. if (!inPre) {
  8759. let lastNode;
  8760. while (
  8761. (lastNode = el.children[el.children.length - 1]) &&
  8762. lastNode.type === 3 &&
  8763. lastNode.text === ' '
  8764. ) {
  8765. el.children.pop();
  8766. }
  8767. }
  8768. }
  8769. function checkRootConstraints (el) {
  8770. if (el.tag === 'slot' || el.tag === 'template') {
  8771. warnOnce(
  8772. `Cannot use <${el.tag}> as component root element because it may ` +
  8773. 'contain multiple nodes.',
  8774. { start: el.start }
  8775. );
  8776. }
  8777. if (el.attrsMap.hasOwnProperty('v-for')) {
  8778. warnOnce(
  8779. 'Cannot use v-for on stateful component root element because ' +
  8780. 'it renders multiple elements.',
  8781. el.rawAttrsMap['v-for']
  8782. );
  8783. }
  8784. }
  8785. parseHTML(template, {
  8786. warn: warn$2,
  8787. expectHTML: options.expectHTML,
  8788. isUnaryTag: options.isUnaryTag,
  8789. canBeLeftOpenTag: options.canBeLeftOpenTag,
  8790. shouldDecodeNewlines: options.shouldDecodeNewlines,
  8791. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  8792. shouldKeepComment: options.comments,
  8793. outputSourceRange: options.outputSourceRange,
  8794. start (tag, attrs, unary, start, end) {
  8795. // check namespace.
  8796. // inherit parent ns if there is one
  8797. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  8798. // handle IE svg bug
  8799. /* istanbul ignore if */
  8800. if (isIE && ns === 'svg') {
  8801. attrs = guardIESVGBug(attrs);
  8802. }
  8803. let element = createASTElement(tag, attrs, currentParent);
  8804. if (ns) {
  8805. element.ns = ns;
  8806. }
  8807. {
  8808. if (options.outputSourceRange) {
  8809. element.start = start;
  8810. element.end = end;
  8811. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  8812. cumulated[attr.name] = attr;
  8813. return cumulated
  8814. }, {});
  8815. }
  8816. attrs.forEach(attr => {
  8817. if (invalidAttributeRE.test(attr.name)) {
  8818. warn$2(
  8819. `Invalid dynamic argument expression: attribute names cannot contain ` +
  8820. `spaces, quotes, <, >, / or =.`,
  8821. {
  8822. start: attr.start + attr.name.indexOf(`[`),
  8823. end: attr.start + attr.name.length
  8824. }
  8825. );
  8826. }
  8827. });
  8828. }
  8829. if (isForbiddenTag(element) && !isServerRendering()) {
  8830. element.forbidden = true;
  8831. warn$2(
  8832. 'Templates should only be responsible for mapping the state to the ' +
  8833. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  8834. `<${tag}>` + ', as they will not be parsed.',
  8835. { start: element.start }
  8836. );
  8837. }
  8838. // apply pre-transforms
  8839. for (let i = 0; i < preTransforms.length; i++) {
  8840. element = preTransforms[i](element, options) || element;
  8841. }
  8842. if (!inVPre) {
  8843. processPre(element);
  8844. if (element.pre) {
  8845. inVPre = true;
  8846. }
  8847. }
  8848. if (platformIsPreTag(element.tag)) {
  8849. inPre = true;
  8850. }
  8851. if (inVPre) {
  8852. processRawAttrs(element);
  8853. } else if (!element.processed) {
  8854. // structural directives
  8855. processFor(element);
  8856. processIf(element);
  8857. processOnce(element);
  8858. }
  8859. if (!root) {
  8860. root = element;
  8861. {
  8862. checkRootConstraints(root);
  8863. }
  8864. }
  8865. if (!unary) {
  8866. currentParent = element;
  8867. stack.push(element);
  8868. } else {
  8869. closeElement(element);
  8870. }
  8871. },
  8872. end (tag, start, end) {
  8873. const element = stack[stack.length - 1];
  8874. // pop stack
  8875. stack.length -= 1;
  8876. currentParent = stack[stack.length - 1];
  8877. if (options.outputSourceRange) {
  8878. element.end = end;
  8879. }
  8880. closeElement(element);
  8881. },
  8882. chars (text, start, end) {
  8883. if (!currentParent) {
  8884. {
  8885. if (text === template) {
  8886. warnOnce(
  8887. 'Component template requires a root element, rather than just text.',
  8888. { start }
  8889. );
  8890. } else if ((text = text.trim())) {
  8891. warnOnce(
  8892. `text "${text}" outside root element will be ignored.`,
  8893. { start }
  8894. );
  8895. }
  8896. }
  8897. return
  8898. }
  8899. // IE textarea placeholder bug
  8900. /* istanbul ignore if */
  8901. if (isIE &&
  8902. currentParent.tag === 'textarea' &&
  8903. currentParent.attrsMap.placeholder === text
  8904. ) {
  8905. return
  8906. }
  8907. const children = currentParent.children;
  8908. if (inPre || text.trim()) {
  8909. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  8910. } else if (!children.length) {
  8911. // remove the whitespace-only node right after an opening tag
  8912. text = '';
  8913. } else if (whitespaceOption) {
  8914. if (whitespaceOption === 'condense') {
  8915. // in condense mode, remove the whitespace node if it contains
  8916. // line break, otherwise condense to a single space
  8917. text = lineBreakRE.test(text) ? '' : ' ';
  8918. } else {
  8919. text = ' ';
  8920. }
  8921. } else {
  8922. text = preserveWhitespace ? ' ' : '';
  8923. }
  8924. if (text) {
  8925. if (!inPre && whitespaceOption === 'condense') {
  8926. // condense consecutive whitespaces into single space
  8927. text = text.replace(whitespaceRE$1, ' ');
  8928. }
  8929. let res;
  8930. let child;
  8931. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  8932. child = {
  8933. type: 2,
  8934. expression: res.expression,
  8935. tokens: res.tokens,
  8936. text
  8937. };
  8938. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  8939. child = {
  8940. type: 3,
  8941. text
  8942. };
  8943. }
  8944. if (child) {
  8945. if (options.outputSourceRange) {
  8946. child.start = start;
  8947. child.end = end;
  8948. }
  8949. children.push(child);
  8950. }
  8951. }
  8952. },
  8953. comment (text, start, end) {
  8954. // adding anything as a sibling to the root node is forbidden
  8955. // comments should still be allowed, but ignored
  8956. if (currentParent) {
  8957. const child = {
  8958. type: 3,
  8959. text,
  8960. isComment: true
  8961. };
  8962. if (options.outputSourceRange) {
  8963. child.start = start;
  8964. child.end = end;
  8965. }
  8966. currentParent.children.push(child);
  8967. }
  8968. }
  8969. });
  8970. return root
  8971. }
  8972. function processPre (el) {
  8973. if (getAndRemoveAttr(el, 'v-pre') != null) {
  8974. el.pre = true;
  8975. }
  8976. }
  8977. function processRawAttrs (el) {
  8978. const list = el.attrsList;
  8979. const len = list.length;
  8980. if (len) {
  8981. const attrs = el.attrs = new Array(len);
  8982. for (let i = 0; i < len; i++) {
  8983. attrs[i] = {
  8984. name: list[i].name,
  8985. value: JSON.stringify(list[i].value)
  8986. };
  8987. if (list[i].start != null) {
  8988. attrs[i].start = list[i].start;
  8989. attrs[i].end = list[i].end;
  8990. }
  8991. }
  8992. } else if (!el.pre) {
  8993. // non root node in pre blocks with no attributes
  8994. el.plain = true;
  8995. }
  8996. }
  8997. function processElement (
  8998. element,
  8999. options
  9000. ) {
  9001. processKey(element);
  9002. // determine whether this is a plain element after
  9003. // removing structural attributes
  9004. element.plain = (
  9005. !element.key &&
  9006. !element.scopedSlots &&
  9007. !element.attrsList.length
  9008. );
  9009. processRef(element);
  9010. processSlotContent(element);
  9011. processSlotOutlet(element);
  9012. processComponent(element);
  9013. for (let i = 0; i < transforms.length; i++) {
  9014. element = transforms[i](element, options) || element;
  9015. }
  9016. processAttrs(element);
  9017. return element
  9018. }
  9019. function processKey (el) {
  9020. const exp = getBindingAttr(el, 'key');
  9021. if (exp) {
  9022. {
  9023. if (el.tag === 'template') {
  9024. warn$2(
  9025. `<template> cannot be keyed. Place the key on real elements instead.`,
  9026. getRawBindingAttr(el, 'key')
  9027. );
  9028. }
  9029. if (el.for) {
  9030. const iterator = el.iterator2 || el.iterator1;
  9031. const parent = el.parent;
  9032. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  9033. warn$2(
  9034. `Do not use v-for index as key on <transition-group> children, ` +
  9035. `this is the same as not using keys.`,
  9036. getRawBindingAttr(el, 'key'),
  9037. true /* tip */
  9038. );
  9039. }
  9040. }
  9041. }
  9042. el.key = exp;
  9043. }
  9044. }
  9045. function processRef (el) {
  9046. const ref = getBindingAttr(el, 'ref');
  9047. if (ref) {
  9048. el.ref = ref;
  9049. el.refInFor = checkInFor(el);
  9050. }
  9051. }
  9052. function processFor (el) {
  9053. let exp;
  9054. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9055. const res = parseFor(exp);
  9056. if (res) {
  9057. extend(el, res);
  9058. } else {
  9059. warn$2(
  9060. `Invalid v-for expression: ${exp}`,
  9061. el.rawAttrsMap['v-for']
  9062. );
  9063. }
  9064. }
  9065. }
  9066. function parseFor (exp) {
  9067. const inMatch = exp.match(forAliasRE);
  9068. if (!inMatch) return
  9069. const res = {};
  9070. res.for = inMatch[2].trim();
  9071. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9072. const iteratorMatch = alias.match(forIteratorRE);
  9073. if (iteratorMatch) {
  9074. res.alias = alias.replace(forIteratorRE, '').trim();
  9075. res.iterator1 = iteratorMatch[1].trim();
  9076. if (iteratorMatch[2]) {
  9077. res.iterator2 = iteratorMatch[2].trim();
  9078. }
  9079. } else {
  9080. res.alias = alias;
  9081. }
  9082. return res
  9083. }
  9084. function processIf (el) {
  9085. const exp = getAndRemoveAttr(el, 'v-if');
  9086. if (exp) {
  9087. el.if = exp;
  9088. addIfCondition(el, {
  9089. exp: exp,
  9090. block: el
  9091. });
  9092. } else {
  9093. if (getAndRemoveAttr(el, 'v-else') != null) {
  9094. el.else = true;
  9095. }
  9096. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9097. if (elseif) {
  9098. el.elseif = elseif;
  9099. }
  9100. }
  9101. }
  9102. function processIfConditions (el, parent) {
  9103. const prev = findPrevElement(parent.children);
  9104. if (prev && prev.if) {
  9105. addIfCondition(prev, {
  9106. exp: el.elseif,
  9107. block: el
  9108. });
  9109. } else {
  9110. warn$2(
  9111. `v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} ` +
  9112. `used on element <${el.tag}> without corresponding v-if.`,
  9113. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  9114. );
  9115. }
  9116. }
  9117. function findPrevElement (children) {
  9118. let i = children.length;
  9119. while (i--) {
  9120. if (children[i].type === 1) {
  9121. return children[i]
  9122. } else {
  9123. if (children[i].text !== ' ') {
  9124. warn$2(
  9125. `text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9126. `will be ignored.`,
  9127. children[i]
  9128. );
  9129. }
  9130. children.pop();
  9131. }
  9132. }
  9133. }
  9134. function addIfCondition (el, condition) {
  9135. if (!el.ifConditions) {
  9136. el.ifConditions = [];
  9137. }
  9138. el.ifConditions.push(condition);
  9139. }
  9140. function processOnce (el) {
  9141. const once$$1 = getAndRemoveAttr(el, 'v-once');
  9142. if (once$$1 != null) {
  9143. el.once = true;
  9144. }
  9145. }
  9146. // handle content being passed to a component as slot,
  9147. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9148. function processSlotContent (el) {
  9149. let slotScope;
  9150. if (el.tag === 'template') {
  9151. slotScope = getAndRemoveAttr(el, 'scope');
  9152. /* istanbul ignore if */
  9153. if (slotScope) {
  9154. warn$2(
  9155. `the "scope" attribute for scoped slots have been deprecated and ` +
  9156. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  9157. `can also be used on plain elements in addition to <template> to ` +
  9158. `denote scoped slots.`,
  9159. el.rawAttrsMap['scope'],
  9160. true
  9161. );
  9162. }
  9163. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9164. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  9165. /* istanbul ignore if */
  9166. if (el.attrsMap['v-for']) {
  9167. warn$2(
  9168. `Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  9169. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  9170. `scoped slot to make it clearer.`,
  9171. el.rawAttrsMap['slot-scope'],
  9172. true
  9173. );
  9174. }
  9175. el.slotScope = slotScope;
  9176. }
  9177. // slot="xxx"
  9178. const slotTarget = getBindingAttr(el, 'slot');
  9179. if (slotTarget) {
  9180. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  9181. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  9182. // preserve slot as an attribute for native shadow DOM compat
  9183. // only for non-scoped slots.
  9184. if (el.tag !== 'template' && !el.slotScope) {
  9185. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  9186. }
  9187. }
  9188. // 2.6 v-slot syntax
  9189. {
  9190. if (el.tag === 'template') {
  9191. // v-slot on <template>
  9192. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9193. if (slotBinding) {
  9194. {
  9195. if (el.slotTarget || el.slotScope) {
  9196. warn$2(
  9197. `Unexpected mixed usage of different slot syntaxes.`,
  9198. el
  9199. );
  9200. }
  9201. if (el.parent && !maybeComponent(el.parent)) {
  9202. warn$2(
  9203. `<template v-slot> can only appear at the root level inside ` +
  9204. `the receiving component`,
  9205. el
  9206. );
  9207. }
  9208. }
  9209. const { name, dynamic } = getSlotName(slotBinding);
  9210. el.slotTarget = name;
  9211. el.slotTargetDynamic = dynamic;
  9212. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  9213. }
  9214. } else {
  9215. // v-slot on component, denotes default slot
  9216. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9217. if (slotBinding) {
  9218. {
  9219. if (!maybeComponent(el)) {
  9220. warn$2(
  9221. `v-slot can only be used on components or <template>.`,
  9222. slotBinding
  9223. );
  9224. }
  9225. if (el.slotScope || el.slotTarget) {
  9226. warn$2(
  9227. `Unexpected mixed usage of different slot syntaxes.`,
  9228. el
  9229. );
  9230. }
  9231. if (el.scopedSlots) {
  9232. warn$2(
  9233. `To avoid scope ambiguity, the default slot should also use ` +
  9234. `<template> syntax when there are other named slots.`,
  9235. slotBinding
  9236. );
  9237. }
  9238. }
  9239. // add the component's children to its default slot
  9240. const slots = el.scopedSlots || (el.scopedSlots = {});
  9241. const { name, dynamic } = getSlotName(slotBinding);
  9242. const slotContainer = slots[name] = createASTElement('template', [], el);
  9243. slotContainer.slotTarget = name;
  9244. slotContainer.slotTargetDynamic = dynamic;
  9245. slotContainer.children = el.children.filter((c) => {
  9246. if (!c.slotScope) {
  9247. c.parent = slotContainer;
  9248. return true
  9249. }
  9250. });
  9251. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  9252. // remove children as they are returned from scopedSlots now
  9253. el.children = [];
  9254. // mark el non-plain so data gets generated
  9255. el.plain = false;
  9256. }
  9257. }
  9258. }
  9259. }
  9260. function getSlotName (binding) {
  9261. let name = binding.name.replace(slotRE, '');
  9262. if (!name) {
  9263. if (binding.name[0] !== '#') {
  9264. name = 'default';
  9265. } else {
  9266. warn$2(
  9267. `v-slot shorthand syntax requires a slot name.`,
  9268. binding
  9269. );
  9270. }
  9271. }
  9272. return dynamicArgRE.test(name)
  9273. // dynamic [name]
  9274. ? { name: name.slice(1, -1), dynamic: true }
  9275. // static name
  9276. : { name: `"${name}"`, dynamic: false }
  9277. }
  9278. // handle <slot/> outlets
  9279. function processSlotOutlet (el) {
  9280. if (el.tag === 'slot') {
  9281. el.slotName = getBindingAttr(el, 'name');
  9282. if (el.key) {
  9283. warn$2(
  9284. `\`key\` does not work on <slot> because slots are abstract outlets ` +
  9285. `and can possibly expand into multiple elements. ` +
  9286. `Use the key on a wrapping element instead.`,
  9287. getRawBindingAttr(el, 'key')
  9288. );
  9289. }
  9290. }
  9291. }
  9292. function processComponent (el) {
  9293. let binding;
  9294. if ((binding = getBindingAttr(el, 'is'))) {
  9295. el.component = binding;
  9296. }
  9297. if (getAndRemoveAttr(el, 'inline-template') != null) {
  9298. el.inlineTemplate = true;
  9299. }
  9300. }
  9301. function processAttrs (el) {
  9302. const list = el.attrsList;
  9303. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  9304. for (i = 0, l = list.length; i < l; i++) {
  9305. name = rawName = list[i].name;
  9306. value = list[i].value;
  9307. if (dirRE.test(name)) {
  9308. // mark element as dynamic
  9309. el.hasBindings = true;
  9310. // modifiers
  9311. modifiers = parseModifiers(name.replace(dirRE, ''));
  9312. // support .foo shorthand syntax for the .prop modifier
  9313. if (modifiers) {
  9314. name = name.replace(modifierRE, '');
  9315. }
  9316. if (bindRE.test(name)) { // v-bind
  9317. name = name.replace(bindRE, '');
  9318. value = parseFilters(value);
  9319. isDynamic = dynamicArgRE.test(name);
  9320. if (isDynamic) {
  9321. name = name.slice(1, -1);
  9322. }
  9323. if (
  9324. value.trim().length === 0
  9325. ) {
  9326. warn$2(
  9327. `The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`
  9328. );
  9329. }
  9330. if (modifiers) {
  9331. if (modifiers.prop && !isDynamic) {
  9332. name = camelize(name);
  9333. if (name === 'innerHtml') name = 'innerHTML';
  9334. }
  9335. if (modifiers.camel && !isDynamic) {
  9336. name = camelize(name);
  9337. }
  9338. if (modifiers.sync) {
  9339. syncGen = genAssignmentCode(value, `$event`);
  9340. if (!isDynamic) {
  9341. addHandler(
  9342. el,
  9343. `update:${camelize(name)}`,
  9344. syncGen,
  9345. null,
  9346. false,
  9347. warn$2,
  9348. list[i]
  9349. );
  9350. if (hyphenate(name) !== camelize(name)) {
  9351. addHandler(
  9352. el,
  9353. `update:${hyphenate(name)}`,
  9354. syncGen,
  9355. null,
  9356. false,
  9357. warn$2,
  9358. list[i]
  9359. );
  9360. }
  9361. } else {
  9362. // handler w/ dynamic event name
  9363. addHandler(
  9364. el,
  9365. `"update:"+(${name})`,
  9366. syncGen,
  9367. null,
  9368. false,
  9369. warn$2,
  9370. list[i],
  9371. true // dynamic
  9372. );
  9373. }
  9374. }
  9375. }
  9376. if ((modifiers && modifiers.prop) || (
  9377. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  9378. )) {
  9379. addProp(el, name, value, list[i], isDynamic);
  9380. } else {
  9381. addAttr(el, name, value, list[i], isDynamic);
  9382. }
  9383. } else if (onRE.test(name)) { // v-on
  9384. name = name.replace(onRE, '');
  9385. isDynamic = dynamicArgRE.test(name);
  9386. if (isDynamic) {
  9387. name = name.slice(1, -1);
  9388. }
  9389. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  9390. } else { // normal directives
  9391. name = name.replace(dirRE, '');
  9392. // parse arg
  9393. const argMatch = name.match(argRE);
  9394. let arg = argMatch && argMatch[1];
  9395. isDynamic = false;
  9396. if (arg) {
  9397. name = name.slice(0, -(arg.length + 1));
  9398. if (dynamicArgRE.test(arg)) {
  9399. arg = arg.slice(1, -1);
  9400. isDynamic = true;
  9401. }
  9402. }
  9403. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  9404. if (name === 'model') {
  9405. checkForAliasModel(el, value);
  9406. }
  9407. }
  9408. } else {
  9409. // literal attribute
  9410. {
  9411. const res = parseText(value, delimiters);
  9412. if (res) {
  9413. warn$2(
  9414. `${name}="${value}": ` +
  9415. 'Interpolation inside attributes has been removed. ' +
  9416. 'Use v-bind or the colon shorthand instead. For example, ' +
  9417. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  9418. list[i]
  9419. );
  9420. }
  9421. }
  9422. addAttr(el, name, JSON.stringify(value), list[i]);
  9423. // #6887 firefox doesn't update muted state if set via attribute
  9424. // even immediately after element creation
  9425. if (!el.component &&
  9426. name === 'muted' &&
  9427. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  9428. addProp(el, name, 'true', list[i]);
  9429. }
  9430. }
  9431. }
  9432. }
  9433. function checkInFor (el) {
  9434. let parent = el;
  9435. while (parent) {
  9436. if (parent.for !== undefined) {
  9437. return true
  9438. }
  9439. parent = parent.parent;
  9440. }
  9441. return false
  9442. }
  9443. function parseModifiers (name) {
  9444. const match = name.match(modifierRE);
  9445. if (match) {
  9446. const ret = {};
  9447. match.forEach(m => { ret[m.slice(1)] = true; });
  9448. return ret
  9449. }
  9450. }
  9451. function makeAttrsMap (attrs) {
  9452. const map = {};
  9453. for (let i = 0, l = attrs.length; i < l; i++) {
  9454. if (
  9455. map[attrs[i].name] && !isIE && !isEdge
  9456. ) {
  9457. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  9458. }
  9459. map[attrs[i].name] = attrs[i].value;
  9460. }
  9461. return map
  9462. }
  9463. // for script (e.g. type="x/template") or style, do not decode content
  9464. function isTextTag (el) {
  9465. return el.tag === 'script' || el.tag === 'style'
  9466. }
  9467. function isForbiddenTag (el) {
  9468. return (
  9469. el.tag === 'style' ||
  9470. (el.tag === 'script' && (
  9471. !el.attrsMap.type ||
  9472. el.attrsMap.type === 'text/javascript'
  9473. ))
  9474. )
  9475. }
  9476. const ieNSBug = /^xmlns:NS\d+/;
  9477. const ieNSPrefix = /^NS\d+:/;
  9478. /* istanbul ignore next */
  9479. function guardIESVGBug (attrs) {
  9480. const res = [];
  9481. for (let i = 0; i < attrs.length; i++) {
  9482. const attr = attrs[i];
  9483. if (!ieNSBug.test(attr.name)) {
  9484. attr.name = attr.name.replace(ieNSPrefix, '');
  9485. res.push(attr);
  9486. }
  9487. }
  9488. return res
  9489. }
  9490. function checkForAliasModel (el, value) {
  9491. let _el = el;
  9492. while (_el) {
  9493. if (_el.for && _el.alias === value) {
  9494. warn$2(
  9495. `<${el.tag} v-model="${value}">: ` +
  9496. `You are binding v-model directly to a v-for iteration alias. ` +
  9497. `This will not be able to modify the v-for source array because ` +
  9498. `writing to the alias is like modifying a function local variable. ` +
  9499. `Consider using an array of objects and use v-model on an object property instead.`,
  9500. el.rawAttrsMap['v-model']
  9501. );
  9502. }
  9503. _el = _el.parent;
  9504. }
  9505. }
  9506. /* */
  9507. function preTransformNode (el, options) {
  9508. if (el.tag === 'input') {
  9509. const map = el.attrsMap;
  9510. if (!map['v-model']) {
  9511. return
  9512. }
  9513. let typeBinding;
  9514. if (map[':type'] || map['v-bind:type']) {
  9515. typeBinding = getBindingAttr(el, 'type');
  9516. }
  9517. if (!map.type && !typeBinding && map['v-bind']) {
  9518. typeBinding = `(${map['v-bind']}).type`;
  9519. }
  9520. if (typeBinding) {
  9521. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  9522. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  9523. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  9524. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  9525. // 1. checkbox
  9526. const branch0 = cloneASTElement(el);
  9527. // process for on the main node
  9528. processFor(branch0);
  9529. addRawAttr(branch0, 'type', 'checkbox');
  9530. processElement(branch0, options);
  9531. branch0.processed = true; // prevent it from double-processed
  9532. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  9533. addIfCondition(branch0, {
  9534. exp: branch0.if,
  9535. block: branch0
  9536. });
  9537. // 2. add radio else-if condition
  9538. const branch1 = cloneASTElement(el);
  9539. getAndRemoveAttr(branch1, 'v-for', true);
  9540. addRawAttr(branch1, 'type', 'radio');
  9541. processElement(branch1, options);
  9542. addIfCondition(branch0, {
  9543. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  9544. block: branch1
  9545. });
  9546. // 3. other
  9547. const branch2 = cloneASTElement(el);
  9548. getAndRemoveAttr(branch2, 'v-for', true);
  9549. addRawAttr(branch2, ':type', typeBinding);
  9550. processElement(branch2, options);
  9551. addIfCondition(branch0, {
  9552. exp: ifCondition,
  9553. block: branch2
  9554. });
  9555. if (hasElse) {
  9556. branch0.else = true;
  9557. } else if (elseIfCondition) {
  9558. branch0.elseif = elseIfCondition;
  9559. }
  9560. return branch0
  9561. }
  9562. }
  9563. }
  9564. function cloneASTElement (el) {
  9565. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  9566. }
  9567. var model$1 = {
  9568. preTransformNode
  9569. };
  9570. var modules$1 = [
  9571. klass$1,
  9572. style$1,
  9573. model$1
  9574. ];
  9575. /* */
  9576. function text (el, dir) {
  9577. if (dir.value) {
  9578. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  9579. }
  9580. }
  9581. /* */
  9582. function html (el, dir) {
  9583. if (dir.value) {
  9584. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  9585. }
  9586. }
  9587. var directives$1 = {
  9588. model,
  9589. text,
  9590. html
  9591. };
  9592. /* */
  9593. const baseOptions = {
  9594. expectHTML: true,
  9595. modules: modules$1,
  9596. directives: directives$1,
  9597. isPreTag,
  9598. isUnaryTag,
  9599. mustUseProp,
  9600. canBeLeftOpenTag,
  9601. isReservedTag,
  9602. getTagNamespace,
  9603. staticKeys: genStaticKeys(modules$1)
  9604. };
  9605. /* */
  9606. let isStaticKey;
  9607. let isPlatformReservedTag;
  9608. const genStaticKeysCached = cached(genStaticKeys$1);
  9609. /**
  9610. * Goal of the optimizer: walk the generated template AST tree
  9611. * and detect sub-trees that are purely static, i.e. parts of
  9612. * the DOM that never needs to change.
  9613. *
  9614. * Once we detect these sub-trees, we can:
  9615. *
  9616. * 1. Hoist them into constants, so that we no longer need to
  9617. * create fresh nodes for them on each re-render;
  9618. * 2. Completely skip them in the patching process.
  9619. */
  9620. function optimize (root, options) {
  9621. if (!root) return
  9622. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  9623. isPlatformReservedTag = options.isReservedTag || no;
  9624. // first pass: mark all non-static nodes.
  9625. markStatic$1(root);
  9626. // second pass: mark static roots.
  9627. markStaticRoots(root, false);
  9628. }
  9629. function genStaticKeys$1 (keys) {
  9630. return makeMap(
  9631. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  9632. (keys ? ',' + keys : '')
  9633. )
  9634. }
  9635. function markStatic$1 (node) {
  9636. node.static = isStatic(node);
  9637. if (node.type === 1) {
  9638. // do not make component slot content static. this avoids
  9639. // 1. components not able to mutate slot nodes
  9640. // 2. static slot content fails for hot-reloading
  9641. if (
  9642. !isPlatformReservedTag(node.tag) &&
  9643. node.tag !== 'slot' &&
  9644. node.attrsMap['inline-template'] == null
  9645. ) {
  9646. return
  9647. }
  9648. for (let i = 0, l = node.children.length; i < l; i++) {
  9649. const child = node.children[i];
  9650. markStatic$1(child);
  9651. if (!child.static) {
  9652. node.static = false;
  9653. }
  9654. }
  9655. if (node.ifConditions) {
  9656. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9657. const block = node.ifConditions[i].block;
  9658. markStatic$1(block);
  9659. if (!block.static) {
  9660. node.static = false;
  9661. }
  9662. }
  9663. }
  9664. }
  9665. }
  9666. function markStaticRoots (node, isInFor) {
  9667. if (node.type === 1) {
  9668. if (node.static || node.once) {
  9669. node.staticInFor = isInFor;
  9670. }
  9671. // For a node to qualify as a static root, it should have children that
  9672. // are not just static text. Otherwise the cost of hoisting out will
  9673. // outweigh the benefits and it's better off to just always render it fresh.
  9674. if (node.static && node.children.length && !(
  9675. node.children.length === 1 &&
  9676. node.children[0].type === 3
  9677. )) {
  9678. node.staticRoot = true;
  9679. return
  9680. } else {
  9681. node.staticRoot = false;
  9682. }
  9683. if (node.children) {
  9684. for (let i = 0, l = node.children.length; i < l; i++) {
  9685. markStaticRoots(node.children[i], isInFor || !!node.for);
  9686. }
  9687. }
  9688. if (node.ifConditions) {
  9689. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9690. markStaticRoots(node.ifConditions[i].block, isInFor);
  9691. }
  9692. }
  9693. }
  9694. }
  9695. function isStatic (node) {
  9696. if (node.type === 2) { // expression
  9697. return false
  9698. }
  9699. if (node.type === 3) { // text
  9700. return true
  9701. }
  9702. return !!(node.pre || (
  9703. !node.hasBindings && // no dynamic bindings
  9704. !node.if && !node.for && // not v-if or v-for or v-else
  9705. !isBuiltInTag(node.tag) && // not a built-in
  9706. isPlatformReservedTag(node.tag) && // not a component
  9707. !isDirectChildOfTemplateFor(node) &&
  9708. Object.keys(node).every(isStaticKey)
  9709. ))
  9710. }
  9711. function isDirectChildOfTemplateFor (node) {
  9712. while (node.parent) {
  9713. node = node.parent;
  9714. if (node.tag !== 'template') {
  9715. return false
  9716. }
  9717. if (node.for) {
  9718. return true
  9719. }
  9720. }
  9721. return false
  9722. }
  9723. /* */
  9724. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  9725. const fnInvokeRE = /\([^)]*?\);*$/;
  9726. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  9727. // KeyboardEvent.keyCode aliases
  9728. const keyCodes = {
  9729. esc: 27,
  9730. tab: 9,
  9731. enter: 13,
  9732. space: 32,
  9733. up: 38,
  9734. left: 37,
  9735. right: 39,
  9736. down: 40,
  9737. 'delete': [8, 46]
  9738. };
  9739. // KeyboardEvent.key aliases
  9740. const keyNames = {
  9741. // #7880: IE11 and Edge use `Esc` for Escape key name.
  9742. esc: ['Esc', 'Escape'],
  9743. tab: 'Tab',
  9744. enter: 'Enter',
  9745. // #9112: IE11 uses `Spacebar` for Space key name.
  9746. space: [' ', 'Spacebar'],
  9747. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  9748. up: ['Up', 'ArrowUp'],
  9749. left: ['Left', 'ArrowLeft'],
  9750. right: ['Right', 'ArrowRight'],
  9751. down: ['Down', 'ArrowDown'],
  9752. // #9112: IE11 uses `Del` for Delete key name.
  9753. 'delete': ['Backspace', 'Delete', 'Del']
  9754. };
  9755. // #4868: modifiers that prevent the execution of the listener
  9756. // need to explicitly return null so that we can determine whether to remove
  9757. // the listener for .once
  9758. const genGuard = condition => `if(${condition})return null;`;
  9759. const modifierCode = {
  9760. stop: '$event.stopPropagation();',
  9761. prevent: '$event.preventDefault();',
  9762. self: genGuard(`$event.target !== $event.currentTarget`),
  9763. ctrl: genGuard(`!$event.ctrlKey`),
  9764. shift: genGuard(`!$event.shiftKey`),
  9765. alt: genGuard(`!$event.altKey`),
  9766. meta: genGuard(`!$event.metaKey`),
  9767. left: genGuard(`'button' in $event && $event.button !== 0`),
  9768. middle: genGuard(`'button' in $event && $event.button !== 1`),
  9769. right: genGuard(`'button' in $event && $event.button !== 2`)
  9770. };
  9771. function genHandlers (
  9772. events,
  9773. isNative
  9774. ) {
  9775. const prefix = isNative ? 'nativeOn:' : 'on:';
  9776. let staticHandlers = ``;
  9777. let dynamicHandlers = ``;
  9778. for (const name in events) {
  9779. const handlerCode = genHandler(events[name]);
  9780. if (events[name] && events[name].dynamic) {
  9781. dynamicHandlers += `${name},${handlerCode},`;
  9782. } else {
  9783. staticHandlers += `"${name}":${handlerCode},`;
  9784. }
  9785. }
  9786. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  9787. if (dynamicHandlers) {
  9788. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`
  9789. } else {
  9790. return prefix + staticHandlers
  9791. }
  9792. }
  9793. function genHandler (handler) {
  9794. if (!handler) {
  9795. return 'function(){}'
  9796. }
  9797. if (Array.isArray(handler)) {
  9798. return `[${handler.map(handler => genHandler(handler)).join(',')}]`
  9799. }
  9800. const isMethodPath = simplePathRE.test(handler.value);
  9801. const isFunctionExpression = fnExpRE.test(handler.value);
  9802. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  9803. if (!handler.modifiers) {
  9804. if (isMethodPath || isFunctionExpression) {
  9805. return handler.value
  9806. }
  9807. return `function($event){${
  9808. isFunctionInvocation ? `return ${handler.value}` : handler.value
  9809. }}` // inline statement
  9810. } else {
  9811. let code = '';
  9812. let genModifierCode = '';
  9813. const keys = [];
  9814. for (const key in handler.modifiers) {
  9815. if (modifierCode[key]) {
  9816. genModifierCode += modifierCode[key];
  9817. // left/right
  9818. if (keyCodes[key]) {
  9819. keys.push(key);
  9820. }
  9821. } else if (key === 'exact') {
  9822. const modifiers = (handler.modifiers);
  9823. genModifierCode += genGuard(
  9824. ['ctrl', 'shift', 'alt', 'meta']
  9825. .filter(keyModifier => !modifiers[keyModifier])
  9826. .map(keyModifier => `$event.${keyModifier}Key`)
  9827. .join('||')
  9828. );
  9829. } else {
  9830. keys.push(key);
  9831. }
  9832. }
  9833. if (keys.length) {
  9834. code += genKeyFilter(keys);
  9835. }
  9836. // Make sure modifiers like prevent and stop get executed after key filtering
  9837. if (genModifierCode) {
  9838. code += genModifierCode;
  9839. }
  9840. const handlerCode = isMethodPath
  9841. ? `return ${handler.value}.apply(null, arguments)`
  9842. : isFunctionExpression
  9843. ? `return (${handler.value}).apply(null, arguments)`
  9844. : isFunctionInvocation
  9845. ? `return ${handler.value}`
  9846. : handler.value;
  9847. return `function($event){${code}${handlerCode}}`
  9848. }
  9849. }
  9850. function genKeyFilter (keys) {
  9851. return (
  9852. // make sure the key filters only apply to KeyboardEvents
  9853. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  9854. // key events that do not have keyCode property...
  9855. `if(!$event.type.indexOf('key')&&` +
  9856. `${keys.map(genFilterCode).join('&&')})return null;`
  9857. )
  9858. }
  9859. function genFilterCode (key) {
  9860. const keyVal = parseInt(key, 10);
  9861. if (keyVal) {
  9862. return `$event.keyCode!==${keyVal}`
  9863. }
  9864. const keyCode = keyCodes[key];
  9865. const keyName = keyNames[key];
  9866. return (
  9867. `_k($event.keyCode,` +
  9868. `${JSON.stringify(key)},` +
  9869. `${JSON.stringify(keyCode)},` +
  9870. `$event.key,` +
  9871. `${JSON.stringify(keyName)}` +
  9872. `)`
  9873. )
  9874. }
  9875. /* */
  9876. function on (el, dir) {
  9877. if (dir.modifiers) {
  9878. warn(`v-on without argument does not support modifiers.`);
  9879. }
  9880. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  9881. }
  9882. /* */
  9883. function bind$1 (el, dir) {
  9884. el.wrapData = (code) => {
  9885. return `_b(${code},'${el.tag}',${dir.value},${
  9886. dir.modifiers && dir.modifiers.prop ? 'true' : 'false'
  9887. }${
  9888. dir.modifiers && dir.modifiers.sync ? ',true' : ''
  9889. })`
  9890. };
  9891. }
  9892. /* */
  9893. var baseDirectives = {
  9894. on,
  9895. bind: bind$1,
  9896. cloak: noop
  9897. };
  9898. /* */
  9899. class CodegenState {
  9900. constructor (options) {
  9901. this.options = options;
  9902. this.warn = options.warn || baseWarn;
  9903. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  9904. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  9905. this.directives = extend(extend({}, baseDirectives), options.directives);
  9906. const isReservedTag = options.isReservedTag || no;
  9907. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  9908. this.onceId = 0;
  9909. this.staticRenderFns = [];
  9910. this.pre = false;
  9911. }
  9912. }
  9913. function generate (
  9914. ast,
  9915. options
  9916. ) {
  9917. const state = new CodegenState(options);
  9918. // fix #11483, Root level <script> tags should not be rendered.
  9919. const code = ast ? (ast.tag === 'script' ? 'null' : genElement(ast, state)) : '_c("div")';
  9920. return {
  9921. render: `with(this){return ${code}}`,
  9922. staticRenderFns: state.staticRenderFns
  9923. }
  9924. }
  9925. function genElement (el, state) {
  9926. if (el.parent) {
  9927. el.pre = el.pre || el.parent.pre;
  9928. }
  9929. if (el.staticRoot && !el.staticProcessed) {
  9930. return genStatic(el, state)
  9931. } else if (el.once && !el.onceProcessed) {
  9932. return genOnce(el, state)
  9933. } else if (el.for && !el.forProcessed) {
  9934. return genFor(el, state)
  9935. } else if (el.if && !el.ifProcessed) {
  9936. return genIf(el, state)
  9937. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  9938. return genChildren(el, state) || 'void 0'
  9939. } else if (el.tag === 'slot') {
  9940. return genSlot(el, state)
  9941. } else {
  9942. // component or element
  9943. let code;
  9944. if (el.component) {
  9945. code = genComponent(el.component, el, state);
  9946. } else {
  9947. let data;
  9948. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  9949. data = genData$2(el, state);
  9950. }
  9951. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  9952. code = `_c('${el.tag}'${
  9953. data ? `,${data}` : '' // data
  9954. }${
  9955. children ? `,${children}` : '' // children
  9956. })`;
  9957. }
  9958. // module transforms
  9959. for (let i = 0; i < state.transforms.length; i++) {
  9960. code = state.transforms[i](el, code);
  9961. }
  9962. return code
  9963. }
  9964. }
  9965. // hoist static sub-trees out
  9966. function genStatic (el, state) {
  9967. el.staticProcessed = true;
  9968. // Some elements (templates) need to behave differently inside of a v-pre
  9969. // node. All pre nodes are static roots, so we can use this as a location to
  9970. // wrap a state change and reset it upon exiting the pre node.
  9971. const originalPreState = state.pre;
  9972. if (el.pre) {
  9973. state.pre = el.pre;
  9974. }
  9975. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  9976. state.pre = originalPreState;
  9977. return `_m(${
  9978. state.staticRenderFns.length - 1
  9979. }${
  9980. el.staticInFor ? ',true' : ''
  9981. })`
  9982. }
  9983. // v-once
  9984. function genOnce (el, state) {
  9985. el.onceProcessed = true;
  9986. if (el.if && !el.ifProcessed) {
  9987. return genIf(el, state)
  9988. } else if (el.staticInFor) {
  9989. let key = '';
  9990. let parent = el.parent;
  9991. while (parent) {
  9992. if (parent.for) {
  9993. key = parent.key;
  9994. break
  9995. }
  9996. parent = parent.parent;
  9997. }
  9998. if (!key) {
  9999. state.warn(
  10000. `v-once can only be used inside v-for that is keyed. `,
  10001. el.rawAttrsMap['v-once']
  10002. );
  10003. return genElement(el, state)
  10004. }
  10005. return `_o(${genElement(el, state)},${state.onceId++},${key})`
  10006. } else {
  10007. return genStatic(el, state)
  10008. }
  10009. }
  10010. function genIf (
  10011. el,
  10012. state,
  10013. altGen,
  10014. altEmpty
  10015. ) {
  10016. el.ifProcessed = true; // avoid recursion
  10017. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  10018. }
  10019. function genIfConditions (
  10020. conditions,
  10021. state,
  10022. altGen,
  10023. altEmpty
  10024. ) {
  10025. if (!conditions.length) {
  10026. return altEmpty || '_e()'
  10027. }
  10028. const condition = conditions.shift();
  10029. if (condition.exp) {
  10030. return `(${condition.exp})?${
  10031. genTernaryExp(condition.block)
  10032. }:${
  10033. genIfConditions(conditions, state, altGen, altEmpty)
  10034. }`
  10035. } else {
  10036. return `${genTernaryExp(condition.block)}`
  10037. }
  10038. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10039. function genTernaryExp (el) {
  10040. return altGen
  10041. ? altGen(el, state)
  10042. : el.once
  10043. ? genOnce(el, state)
  10044. : genElement(el, state)
  10045. }
  10046. }
  10047. function genFor (
  10048. el,
  10049. state,
  10050. altGen,
  10051. altHelper
  10052. ) {
  10053. const exp = el.for;
  10054. const alias = el.alias;
  10055. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10056. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10057. if (state.maybeComponent(el) &&
  10058. el.tag !== 'slot' &&
  10059. el.tag !== 'template' &&
  10060. !el.key
  10061. ) {
  10062. state.warn(
  10063. `<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10064. `v-for should have explicit keys. ` +
  10065. `See https://vuejs.org/guide/list.html#key for more info.`,
  10066. el.rawAttrsMap['v-for'],
  10067. true /* tip */
  10068. );
  10069. }
  10070. el.forProcessed = true; // avoid recursion
  10071. return `${altHelper || '_l'}((${exp}),` +
  10072. `function(${alias}${iterator1}${iterator2}){` +
  10073. `return ${(altGen || genElement)(el, state)}` +
  10074. '})'
  10075. }
  10076. function genData$2 (el, state) {
  10077. let data = '{';
  10078. // directives first.
  10079. // directives may mutate the el's other properties before they are generated.
  10080. const dirs = genDirectives(el, state);
  10081. if (dirs) data += dirs + ',';
  10082. // key
  10083. if (el.key) {
  10084. data += `key:${el.key},`;
  10085. }
  10086. // ref
  10087. if (el.ref) {
  10088. data += `ref:${el.ref},`;
  10089. }
  10090. if (el.refInFor) {
  10091. data += `refInFor:true,`;
  10092. }
  10093. // pre
  10094. if (el.pre) {
  10095. data += `pre:true,`;
  10096. }
  10097. // record original tag name for components using "is" attribute
  10098. if (el.component) {
  10099. data += `tag:"${el.tag}",`;
  10100. }
  10101. // module data generation functions
  10102. for (let i = 0; i < state.dataGenFns.length; i++) {
  10103. data += state.dataGenFns[i](el);
  10104. }
  10105. // attributes
  10106. if (el.attrs) {
  10107. data += `attrs:${genProps(el.attrs)},`;
  10108. }
  10109. // DOM props
  10110. if (el.props) {
  10111. data += `domProps:${genProps(el.props)},`;
  10112. }
  10113. // event handlers
  10114. if (el.events) {
  10115. data += `${genHandlers(el.events, false)},`;
  10116. }
  10117. if (el.nativeEvents) {
  10118. data += `${genHandlers(el.nativeEvents, true)},`;
  10119. }
  10120. // slot target
  10121. // only for non-scoped slots
  10122. if (el.slotTarget && !el.slotScope) {
  10123. data += `slot:${el.slotTarget},`;
  10124. }
  10125. // scoped slots
  10126. if (el.scopedSlots) {
  10127. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10128. }
  10129. // component v-model
  10130. if (el.model) {
  10131. data += `model:{value:${
  10132. el.model.value
  10133. },callback:${
  10134. el.model.callback
  10135. },expression:${
  10136. el.model.expression
  10137. }},`;
  10138. }
  10139. // inline-template
  10140. if (el.inlineTemplate) {
  10141. const inlineTemplate = genInlineTemplate(el, state);
  10142. if (inlineTemplate) {
  10143. data += `${inlineTemplate},`;
  10144. }
  10145. }
  10146. data = data.replace(/,$/, '') + '}';
  10147. // v-bind dynamic argument wrap
  10148. // v-bind with dynamic arguments must be applied using the same v-bind object
  10149. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10150. if (el.dynamicAttrs) {
  10151. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10152. }
  10153. // v-bind data wrap
  10154. if (el.wrapData) {
  10155. data = el.wrapData(data);
  10156. }
  10157. // v-on data wrap
  10158. if (el.wrapListeners) {
  10159. data = el.wrapListeners(data);
  10160. }
  10161. return data
  10162. }
  10163. function genDirectives (el, state) {
  10164. const dirs = el.directives;
  10165. if (!dirs) return
  10166. let res = 'directives:[';
  10167. let hasRuntime = false;
  10168. let i, l, dir, needRuntime;
  10169. for (i = 0, l = dirs.length; i < l; i++) {
  10170. dir = dirs[i];
  10171. needRuntime = true;
  10172. const gen = state.directives[dir.name];
  10173. if (gen) {
  10174. // compile-time directive that manipulates AST.
  10175. // returns true if it also needs a runtime counterpart.
  10176. needRuntime = !!gen(el, dir, state.warn);
  10177. }
  10178. if (needRuntime) {
  10179. hasRuntime = true;
  10180. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${
  10181. dir.value ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}` : ''
  10182. }${
  10183. dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''
  10184. }${
  10185. dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''
  10186. }},`;
  10187. }
  10188. }
  10189. if (hasRuntime) {
  10190. return res.slice(0, -1) + ']'
  10191. }
  10192. }
  10193. function genInlineTemplate (el, state) {
  10194. const ast = el.children[0];
  10195. if (el.children.length !== 1 || ast.type !== 1) {
  10196. state.warn(
  10197. 'Inline-template components must have exactly one child element.',
  10198. { start: el.start }
  10199. );
  10200. }
  10201. if (ast && ast.type === 1) {
  10202. const inlineRenderFns = generate(ast, state.options);
  10203. return `inlineTemplate:{render:function(){${
  10204. inlineRenderFns.render
  10205. }},staticRenderFns:[${
  10206. inlineRenderFns.staticRenderFns.map(code => `function(){${code}}`).join(',')
  10207. }]}`
  10208. }
  10209. }
  10210. function genScopedSlots (
  10211. el,
  10212. slots,
  10213. state
  10214. ) {
  10215. // by default scoped slots are considered "stable", this allows child
  10216. // components with only scoped slots to skip forced updates from parent.
  10217. // but in some cases we have to bail-out of this optimization
  10218. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10219. let needsForceUpdate = el.for || Object.keys(slots).some(key => {
  10220. const slot = slots[key];
  10221. return (
  10222. slot.slotTargetDynamic ||
  10223. slot.if ||
  10224. slot.for ||
  10225. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10226. )
  10227. });
  10228. // #9534: if a component with scoped slots is inside a conditional branch,
  10229. // it's possible for the same component to be reused but with different
  10230. // compiled slot content. To avoid that, we generate a unique key based on
  10231. // the generated code of all the slot contents.
  10232. let needsKey = !!el.if;
  10233. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10234. // disconnected due to the intermediate scope variable)
  10235. // #9438, #9506
  10236. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10237. // and skip force updating ones that do not actually use scope variables.
  10238. if (!needsForceUpdate) {
  10239. let parent = el.parent;
  10240. while (parent) {
  10241. if (
  10242. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  10243. parent.for
  10244. ) {
  10245. needsForceUpdate = true;
  10246. break
  10247. }
  10248. if (parent.if) {
  10249. needsKey = true;
  10250. }
  10251. parent = parent.parent;
  10252. }
  10253. }
  10254. const generatedSlots = Object.keys(slots)
  10255. .map(key => genScopedSlot(slots[key], state))
  10256. .join(',');
  10257. return `scopedSlots:_u([${generatedSlots}]${
  10258. needsForceUpdate ? `,null,true` : ``
  10259. }${
  10260. !needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``
  10261. })`
  10262. }
  10263. function hash(str) {
  10264. let hash = 5381;
  10265. let i = str.length;
  10266. while(i) {
  10267. hash = (hash * 33) ^ str.charCodeAt(--i);
  10268. }
  10269. return hash >>> 0
  10270. }
  10271. function containsSlotChild (el) {
  10272. if (el.type === 1) {
  10273. if (el.tag === 'slot') {
  10274. return true
  10275. }
  10276. return el.children.some(containsSlotChild)
  10277. }
  10278. return false
  10279. }
  10280. function genScopedSlot (
  10281. el,
  10282. state
  10283. ) {
  10284. const isLegacySyntax = el.attrsMap['slot-scope'];
  10285. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  10286. return genIf(el, state, genScopedSlot, `null`)
  10287. }
  10288. if (el.for && !el.forProcessed) {
  10289. return genFor(el, state, genScopedSlot)
  10290. }
  10291. const slotScope = el.slotScope === emptySlotScopeToken
  10292. ? ``
  10293. : String(el.slotScope);
  10294. const fn = `function(${slotScope}){` +
  10295. `return ${el.tag === 'template'
  10296. ? el.if && isLegacySyntax
  10297. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  10298. : genChildren(el, state) || 'undefined'
  10299. : genElement(el, state)
  10300. }}`;
  10301. // reverse proxy v-slot without scope on this.$slots
  10302. const reverseProxy = slotScope ? `` : `,proxy:true`;
  10303. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`
  10304. }
  10305. function genChildren (
  10306. el,
  10307. state,
  10308. checkSkip,
  10309. altGenElement,
  10310. altGenNode
  10311. ) {
  10312. const children = el.children;
  10313. if (children.length) {
  10314. const el = children[0];
  10315. // optimize single v-for
  10316. if (children.length === 1 &&
  10317. el.for &&
  10318. el.tag !== 'template' &&
  10319. el.tag !== 'slot'
  10320. ) {
  10321. const normalizationType = checkSkip
  10322. ? state.maybeComponent(el) ? `,1` : `,0`
  10323. : ``;
  10324. return `${(altGenElement || genElement)(el, state)}${normalizationType}`
  10325. }
  10326. const normalizationType = checkSkip
  10327. ? getNormalizationType(children, state.maybeComponent)
  10328. : 0;
  10329. const gen = altGenNode || genNode;
  10330. return `[${children.map(c => gen(c, state)).join(',')}]${
  10331. normalizationType ? `,${normalizationType}` : ''
  10332. }`
  10333. }
  10334. }
  10335. // determine the normalization needed for the children array.
  10336. // 0: no normalization needed
  10337. // 1: simple normalization needed (possible 1-level deep nested array)
  10338. // 2: full normalization needed
  10339. function getNormalizationType (
  10340. children,
  10341. maybeComponent
  10342. ) {
  10343. let res = 0;
  10344. for (let i = 0; i < children.length; i++) {
  10345. const el = children[i];
  10346. if (el.type !== 1) {
  10347. continue
  10348. }
  10349. if (needsNormalization(el) ||
  10350. (el.ifConditions && el.ifConditions.some(c => needsNormalization(c.block)))) {
  10351. res = 2;
  10352. break
  10353. }
  10354. if (maybeComponent(el) ||
  10355. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  10356. res = 1;
  10357. }
  10358. }
  10359. return res
  10360. }
  10361. function needsNormalization (el) {
  10362. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  10363. }
  10364. function genNode (node, state) {
  10365. if (node.type === 1) {
  10366. return genElement(node, state)
  10367. } else if (node.type === 3 && node.isComment) {
  10368. return genComment(node)
  10369. } else {
  10370. return genText(node)
  10371. }
  10372. }
  10373. function genText (text) {
  10374. return `_v(${text.type === 2
  10375. ? text.expression // no need for () because already wrapped in _s()
  10376. : transformSpecialNewlines(JSON.stringify(text.text))
  10377. })`
  10378. }
  10379. function genComment (comment) {
  10380. return `_e(${JSON.stringify(comment.text)})`
  10381. }
  10382. function genSlot (el, state) {
  10383. const slotName = el.slotName || '"default"';
  10384. const children = genChildren(el, state);
  10385. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  10386. const attrs = el.attrs || el.dynamicAttrs
  10387. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  10388. // slot props are camelized
  10389. name: camelize(attr.name),
  10390. value: attr.value,
  10391. dynamic: attr.dynamic
  10392. })))
  10393. : null;
  10394. const bind$$1 = el.attrsMap['v-bind'];
  10395. if ((attrs || bind$$1) && !children) {
  10396. res += `,null`;
  10397. }
  10398. if (attrs) {
  10399. res += `,${attrs}`;
  10400. }
  10401. if (bind$$1) {
  10402. res += `${attrs ? '' : ',null'},${bind$$1}`;
  10403. }
  10404. return res + ')'
  10405. }
  10406. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  10407. function genComponent (
  10408. componentName,
  10409. el,
  10410. state
  10411. ) {
  10412. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10413. return `_c(${componentName},${genData$2(el, state)}${
  10414. children ? `,${children}` : ''
  10415. })`
  10416. }
  10417. function genProps (props) {
  10418. let staticProps = ``;
  10419. let dynamicProps = ``;
  10420. for (let i = 0; i < props.length; i++) {
  10421. const prop = props[i];
  10422. const value = transformSpecialNewlines(prop.value);
  10423. if (prop.dynamic) {
  10424. dynamicProps += `${prop.name},${value},`;
  10425. } else {
  10426. staticProps += `"${prop.name}":${value},`;
  10427. }
  10428. }
  10429. staticProps = `{${staticProps.slice(0, -1)}}`;
  10430. if (dynamicProps) {
  10431. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`
  10432. } else {
  10433. return staticProps
  10434. }
  10435. }
  10436. // #3895, #4268
  10437. function transformSpecialNewlines (text) {
  10438. return text
  10439. .replace(/\u2028/g, '\\u2028')
  10440. .replace(/\u2029/g, '\\u2029')
  10441. }
  10442. /* */
  10443. // these keywords should not appear inside expressions, but operators like
  10444. // typeof, instanceof and in are allowed
  10445. const prohibitedKeywordRE = new RegExp('\\b' + (
  10446. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  10447. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  10448. 'extends,finally,continue,debugger,function,arguments'
  10449. ).split(',').join('\\b|\\b') + '\\b');
  10450. // these unary operators should not be used as property/method names
  10451. const unaryOperatorsRE = new RegExp('\\b' + (
  10452. 'delete,typeof,void'
  10453. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  10454. // strip strings in expressions
  10455. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  10456. // detect problematic expressions in a template
  10457. function detectErrors (ast, warn) {
  10458. if (ast) {
  10459. checkNode(ast, warn);
  10460. }
  10461. }
  10462. function checkNode (node, warn) {
  10463. if (node.type === 1) {
  10464. for (const name in node.attrsMap) {
  10465. if (dirRE.test(name)) {
  10466. const value = node.attrsMap[name];
  10467. if (value) {
  10468. const range = node.rawAttrsMap[name];
  10469. if (name === 'v-for') {
  10470. checkFor(node, `v-for="${value}"`, warn, range);
  10471. } else if (name === 'v-slot' || name[0] === '#') {
  10472. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  10473. } else if (onRE.test(name)) {
  10474. checkEvent(value, `${name}="${value}"`, warn, range);
  10475. } else {
  10476. checkExpression(value, `${name}="${value}"`, warn, range);
  10477. }
  10478. }
  10479. }
  10480. }
  10481. if (node.children) {
  10482. for (let i = 0; i < node.children.length; i++) {
  10483. checkNode(node.children[i], warn);
  10484. }
  10485. }
  10486. } else if (node.type === 2) {
  10487. checkExpression(node.expression, node.text, warn, node);
  10488. }
  10489. }
  10490. function checkEvent (exp, text, warn, range) {
  10491. const stripped = exp.replace(stripStringRE, '');
  10492. const keywordMatch = stripped.match(unaryOperatorsRE);
  10493. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  10494. warn(
  10495. `avoid using JavaScript unary operator as property name: ` +
  10496. `"${keywordMatch[0]}" in expression ${text.trim()}`,
  10497. range
  10498. );
  10499. }
  10500. checkExpression(exp, text, warn, range);
  10501. }
  10502. function checkFor (node, text, warn, range) {
  10503. checkExpression(node.for || '', text, warn, range);
  10504. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  10505. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  10506. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  10507. }
  10508. function checkIdentifier (
  10509. ident,
  10510. type,
  10511. text,
  10512. warn,
  10513. range
  10514. ) {
  10515. if (typeof ident === 'string') {
  10516. try {
  10517. new Function(`var ${ident}=_`);
  10518. } catch (e) {
  10519. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  10520. }
  10521. }
  10522. }
  10523. function checkExpression (exp, text, warn, range) {
  10524. try {
  10525. new Function(`return ${exp}`);
  10526. } catch (e) {
  10527. const keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  10528. if (keywordMatch) {
  10529. warn(
  10530. `avoid using JavaScript keyword as property name: ` +
  10531. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`,
  10532. range
  10533. );
  10534. } else {
  10535. warn(
  10536. `invalid expression: ${e.message} in\n\n` +
  10537. ` ${exp}\n\n` +
  10538. ` Raw expression: ${text.trim()}\n`,
  10539. range
  10540. );
  10541. }
  10542. }
  10543. }
  10544. function checkFunctionParameterExpression (exp, text, warn, range) {
  10545. try {
  10546. new Function(exp, '');
  10547. } catch (e) {
  10548. warn(
  10549. `invalid function parameter expression: ${e.message} in\n\n` +
  10550. ` ${exp}\n\n` +
  10551. ` Raw expression: ${text.trim()}\n`,
  10552. range
  10553. );
  10554. }
  10555. }
  10556. /* */
  10557. const range = 2;
  10558. function generateCodeFrame (
  10559. source,
  10560. start = 0,
  10561. end = source.length
  10562. ) {
  10563. const lines = source.split(/\r?\n/);
  10564. let count = 0;
  10565. const res = [];
  10566. for (let i = 0; i < lines.length; i++) {
  10567. count += lines[i].length + 1;
  10568. if (count >= start) {
  10569. for (let j = i - range; j <= i + range || end > count; j++) {
  10570. if (j < 0 || j >= lines.length) continue
  10571. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  10572. const lineLength = lines[j].length;
  10573. if (j === i) {
  10574. // push underline
  10575. const pad = start - (count - lineLength) + 1;
  10576. const length = end > count ? lineLength - pad : end - start;
  10577. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  10578. } else if (j > i) {
  10579. if (end > count) {
  10580. const length = Math.min(end - count, lineLength);
  10581. res.push(` | ` + repeat(`^`, length));
  10582. }
  10583. count += lineLength + 1;
  10584. }
  10585. }
  10586. break
  10587. }
  10588. }
  10589. return res.join('\n')
  10590. }
  10591. function repeat (str, n) {
  10592. let result = '';
  10593. if (n > 0) {
  10594. while (true) { // eslint-disable-line
  10595. if (n & 1) result += str;
  10596. n >>>= 1;
  10597. if (n <= 0) break
  10598. str += str;
  10599. }
  10600. }
  10601. return result
  10602. }
  10603. /* */
  10604. function createFunction (code, errors) {
  10605. try {
  10606. return new Function(code)
  10607. } catch (err) {
  10608. errors.push({ err, code });
  10609. return noop
  10610. }
  10611. }
  10612. function createCompileToFunctionFn (compile) {
  10613. const cache = Object.create(null);
  10614. return function compileToFunctions (
  10615. template,
  10616. options,
  10617. vm
  10618. ) {
  10619. options = extend({}, options);
  10620. const warn$$1 = options.warn || warn;
  10621. delete options.warn;
  10622. /* istanbul ignore if */
  10623. {
  10624. // detect possible CSP restriction
  10625. try {
  10626. new Function('return 1');
  10627. } catch (e) {
  10628. if (e.toString().match(/unsafe-eval|CSP/)) {
  10629. warn$$1(
  10630. 'It seems you are using the standalone build of Vue.js in an ' +
  10631. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  10632. 'The template compiler cannot work in this environment. Consider ' +
  10633. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  10634. 'templates into render functions.'
  10635. );
  10636. }
  10637. }
  10638. }
  10639. // check cache
  10640. const key = options.delimiters
  10641. ? String(options.delimiters) + template
  10642. : template;
  10643. if (cache[key]) {
  10644. return cache[key]
  10645. }
  10646. // compile
  10647. const compiled = compile(template, options);
  10648. // check compilation errors/tips
  10649. {
  10650. if (compiled.errors && compiled.errors.length) {
  10651. if (options.outputSourceRange) {
  10652. compiled.errors.forEach(e => {
  10653. warn$$1(
  10654. `Error compiling template:\n\n${e.msg}\n\n` +
  10655. generateCodeFrame(template, e.start, e.end),
  10656. vm
  10657. );
  10658. });
  10659. } else {
  10660. warn$$1(
  10661. `Error compiling template:\n\n${template}\n\n` +
  10662. compiled.errors.map(e => `- ${e}`).join('\n') + '\n',
  10663. vm
  10664. );
  10665. }
  10666. }
  10667. if (compiled.tips && compiled.tips.length) {
  10668. if (options.outputSourceRange) {
  10669. compiled.tips.forEach(e => tip(e.msg, vm));
  10670. } else {
  10671. compiled.tips.forEach(msg => tip(msg, vm));
  10672. }
  10673. }
  10674. }
  10675. // turn code into functions
  10676. const res = {};
  10677. const fnGenErrors = [];
  10678. res.render = createFunction(compiled.render, fnGenErrors);
  10679. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  10680. return createFunction(code, fnGenErrors)
  10681. });
  10682. // check function generation errors.
  10683. // this should only happen if there is a bug in the compiler itself.
  10684. // mostly for codegen development use
  10685. /* istanbul ignore if */
  10686. {
  10687. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  10688. warn$$1(
  10689. `Failed to generate render function:\n\n` +
  10690. fnGenErrors.map(({ err, code }) => `${err.toString()} in\n\n${code}\n`).join('\n'),
  10691. vm
  10692. );
  10693. }
  10694. }
  10695. return (cache[key] = res)
  10696. }
  10697. }
  10698. /* */
  10699. function createCompilerCreator (baseCompile) {
  10700. return function createCompiler (baseOptions) {
  10701. function compile (
  10702. template,
  10703. options
  10704. ) {
  10705. const finalOptions = Object.create(baseOptions);
  10706. const errors = [];
  10707. const tips = [];
  10708. let warn = (msg, range, tip) => {
  10709. (tip ? tips : errors).push(msg);
  10710. };
  10711. if (options) {
  10712. if (options.outputSourceRange) {
  10713. // $flow-disable-line
  10714. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  10715. warn = (msg, range, tip) => {
  10716. const data = { msg };
  10717. if (range) {
  10718. if (range.start != null) {
  10719. data.start = range.start + leadingSpaceLength;
  10720. }
  10721. if (range.end != null) {
  10722. data.end = range.end + leadingSpaceLength;
  10723. }
  10724. }
  10725. (tip ? tips : errors).push(data);
  10726. };
  10727. }
  10728. // merge custom modules
  10729. if (options.modules) {
  10730. finalOptions.modules =
  10731. (baseOptions.modules || []).concat(options.modules);
  10732. }
  10733. // merge custom directives
  10734. if (options.directives) {
  10735. finalOptions.directives = extend(
  10736. Object.create(baseOptions.directives || null),
  10737. options.directives
  10738. );
  10739. }
  10740. // copy other options
  10741. for (const key in options) {
  10742. if (key !== 'modules' && key !== 'directives') {
  10743. finalOptions[key] = options[key];
  10744. }
  10745. }
  10746. }
  10747. finalOptions.warn = warn;
  10748. const compiled = baseCompile(template.trim(), finalOptions);
  10749. {
  10750. detectErrors(compiled.ast, warn);
  10751. }
  10752. compiled.errors = errors;
  10753. compiled.tips = tips;
  10754. return compiled
  10755. }
  10756. return {
  10757. compile,
  10758. compileToFunctions: createCompileToFunctionFn(compile)
  10759. }
  10760. }
  10761. }
  10762. /* */
  10763. // `createCompilerCreator` allows creating compilers that use alternative
  10764. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  10765. // Here we just export a default compiler using the default parts.
  10766. const createCompiler = createCompilerCreator(function baseCompile (
  10767. template,
  10768. options
  10769. ) {
  10770. const ast = parse(template.trim(), options);
  10771. if (options.optimize !== false) {
  10772. optimize(ast, options);
  10773. }
  10774. const code = generate(ast, options);
  10775. return {
  10776. ast,
  10777. render: code.render,
  10778. staticRenderFns: code.staticRenderFns
  10779. }
  10780. });
  10781. /* */
  10782. const { compile, compileToFunctions } = createCompiler(baseOptions);
  10783. /* */
  10784. // check whether current browser encodes a char inside attribute values
  10785. let div;
  10786. function getShouldDecode (href) {
  10787. div = div || document.createElement('div');
  10788. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  10789. return div.innerHTML.indexOf('&#10;') > 0
  10790. }
  10791. // #3663: IE encodes newlines inside attribute values while other browsers don't
  10792. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  10793. // #6828: chrome encodes content in a[href]
  10794. const shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  10795. /* */
  10796. const idToTemplate = cached(id => {
  10797. const el = query(id);
  10798. return el && el.innerHTML
  10799. });
  10800. const mount = Vue.prototype.$mount;
  10801. Vue.prototype.$mount = function (
  10802. el,
  10803. hydrating
  10804. ) {
  10805. el = el && query(el);
  10806. /* istanbul ignore if */
  10807. if (el === document.body || el === document.documentElement) {
  10808. warn(
  10809. `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
  10810. );
  10811. return this
  10812. }
  10813. const options = this.$options;
  10814. // resolve template/el and convert to render function
  10815. if (!options.render) {
  10816. let template = options.template;
  10817. if (template) {
  10818. if (typeof template === 'string') {
  10819. if (template.charAt(0) === '#') {
  10820. template = idToTemplate(template);
  10821. /* istanbul ignore if */
  10822. if (!template) {
  10823. warn(
  10824. `Template element not found or is empty: ${options.template}`,
  10825. this
  10826. );
  10827. }
  10828. }
  10829. } else if (template.nodeType) {
  10830. template = template.innerHTML;
  10831. } else {
  10832. {
  10833. warn('invalid template option:' + template, this);
  10834. }
  10835. return this
  10836. }
  10837. } else if (el) {
  10838. template = getOuterHTML(el);
  10839. }
  10840. if (template) {
  10841. /* istanbul ignore if */
  10842. if (config.performance && mark) {
  10843. mark('compile');
  10844. }
  10845. const { render, staticRenderFns } = compileToFunctions(template, {
  10846. outputSourceRange: "development" !== 'production',
  10847. shouldDecodeNewlines,
  10848. shouldDecodeNewlinesForHref,
  10849. delimiters: options.delimiters,
  10850. comments: options.comments
  10851. }, this);
  10852. options.render = render;
  10853. options.staticRenderFns = staticRenderFns;
  10854. /* istanbul ignore if */
  10855. if (config.performance && mark) {
  10856. mark('compile end');
  10857. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  10858. }
  10859. }
  10860. }
  10861. return mount.call(this, el, hydrating)
  10862. };
  10863. /**
  10864. * Get outerHTML of elements, taking care
  10865. * of SVG elements in IE as well.
  10866. */
  10867. function getOuterHTML (el) {
  10868. if (el.outerHTML) {
  10869. return el.outerHTML
  10870. } else {
  10871. const container = document.createElement('div');
  10872. container.appendChild(el.cloneNode(true));
  10873. return container.innerHTML
  10874. }
  10875. }
  10876. Vue.compile = compileToFunctions;
  10877. export default Vue;