Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vue.esm.browser.js 272KB

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