vue.runtime.common.js 170 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723
  1. /*!
  2. * Vue.js v2.2.2
  3. * (c) 2014-2017 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. /* */
  8. /**
  9. * Convert a value to a string that is actually rendered.
  10. */
  11. function _toString (val) {
  12. return val == null
  13. ? ''
  14. : typeof val === 'object'
  15. ? JSON.stringify(val, null, 2)
  16. : String(val)
  17. }
  18. /**
  19. * Convert a input value to a number for persistence.
  20. * If the conversion fails, return original string.
  21. */
  22. function toNumber (val) {
  23. var n = parseFloat(val);
  24. return isNaN(n) ? val : n
  25. }
  26. /**
  27. * Make a map and return a function for checking if a key
  28. * is in that map.
  29. */
  30. function makeMap (
  31. str,
  32. expectsLowerCase
  33. ) {
  34. var map = Object.create(null);
  35. var list = str.split(',');
  36. for (var i = 0; i < list.length; i++) {
  37. map[list[i]] = true;
  38. }
  39. return expectsLowerCase
  40. ? function (val) { return map[val.toLowerCase()]; }
  41. : function (val) { return map[val]; }
  42. }
  43. /**
  44. * Check if a tag is a built-in tag.
  45. */
  46. var isBuiltInTag = makeMap('slot,component', true);
  47. /**
  48. * Remove an item from an array
  49. */
  50. function remove (arr, item) {
  51. if (arr.length) {
  52. var index = arr.indexOf(item);
  53. if (index > -1) {
  54. return arr.splice(index, 1)
  55. }
  56. }
  57. }
  58. /**
  59. * Check whether the object has the property.
  60. */
  61. var hasOwnProperty = Object.prototype.hasOwnProperty;
  62. function hasOwn (obj, key) {
  63. return hasOwnProperty.call(obj, key)
  64. }
  65. /**
  66. * Check if value is primitive
  67. */
  68. function isPrimitive (value) {
  69. return typeof value === 'string' || typeof value === 'number'
  70. }
  71. /**
  72. * Create a cached version of a pure function.
  73. */
  74. function cached (fn) {
  75. var cache = Object.create(null);
  76. return (function cachedFn (str) {
  77. var hit = cache[str];
  78. return hit || (cache[str] = fn(str))
  79. })
  80. }
  81. /**
  82. * Camelize a hyphen-delimited string.
  83. */
  84. var camelizeRE = /-(\w)/g;
  85. var camelize = cached(function (str) {
  86. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  87. });
  88. /**
  89. * Capitalize a string.
  90. */
  91. var capitalize = cached(function (str) {
  92. return str.charAt(0).toUpperCase() + str.slice(1)
  93. });
  94. /**
  95. * Hyphenate a camelCase string.
  96. */
  97. var hyphenateRE = /([^-])([A-Z])/g;
  98. var hyphenate = cached(function (str) {
  99. return str
  100. .replace(hyphenateRE, '$1-$2')
  101. .replace(hyphenateRE, '$1-$2')
  102. .toLowerCase()
  103. });
  104. /**
  105. * Simple bind, faster than native
  106. */
  107. function bind (fn, ctx) {
  108. function boundFn (a) {
  109. var l = arguments.length;
  110. return l
  111. ? l > 1
  112. ? fn.apply(ctx, arguments)
  113. : fn.call(ctx, a)
  114. : fn.call(ctx)
  115. }
  116. // record original fn length
  117. boundFn._length = fn.length;
  118. return boundFn
  119. }
  120. /**
  121. * Convert an Array-like object to a real Array.
  122. */
  123. function toArray (list, start) {
  124. start = start || 0;
  125. var i = list.length - start;
  126. var ret = new Array(i);
  127. while (i--) {
  128. ret[i] = list[i + start];
  129. }
  130. return ret
  131. }
  132. /**
  133. * Mix properties into target object.
  134. */
  135. function extend (to, _from) {
  136. for (var key in _from) {
  137. to[key] = _from[key];
  138. }
  139. return to
  140. }
  141. /**
  142. * Quick object check - this is primarily used to tell
  143. * Objects from primitive values when we know the value
  144. * is a JSON-compliant type.
  145. */
  146. function isObject (obj) {
  147. return obj !== null && typeof obj === 'object'
  148. }
  149. /**
  150. * Strict object type check. Only returns true
  151. * for plain JavaScript objects.
  152. */
  153. var toString = Object.prototype.toString;
  154. var OBJECT_STRING = '[object Object]';
  155. function isPlainObject (obj) {
  156. return toString.call(obj) === OBJECT_STRING
  157. }
  158. /**
  159. * Merge an Array of Objects into a single Object.
  160. */
  161. function toObject (arr) {
  162. var res = {};
  163. for (var i = 0; i < arr.length; i++) {
  164. if (arr[i]) {
  165. extend(res, arr[i]);
  166. }
  167. }
  168. return res
  169. }
  170. /**
  171. * Perform no operation.
  172. */
  173. function noop () {}
  174. /**
  175. * Always return false.
  176. */
  177. var no = function () { return false; };
  178. /**
  179. * Return same value
  180. */
  181. var identity = function (_) { return _; };
  182. /**
  183. * Generate a static keys string from compiler modules.
  184. */
  185. /**
  186. * Check if two values are loosely equal - that is,
  187. * if they are plain objects, do they have the same shape?
  188. */
  189. function looseEqual (a, b) {
  190. var isObjectA = isObject(a);
  191. var isObjectB = isObject(b);
  192. if (isObjectA && isObjectB) {
  193. try {
  194. return JSON.stringify(a) === JSON.stringify(b)
  195. } catch (e) {
  196. // possible circular reference
  197. return a === b
  198. }
  199. } else if (!isObjectA && !isObjectB) {
  200. return String(a) === String(b)
  201. } else {
  202. return false
  203. }
  204. }
  205. function looseIndexOf (arr, val) {
  206. for (var i = 0; i < arr.length; i++) {
  207. if (looseEqual(arr[i], val)) { return i }
  208. }
  209. return -1
  210. }
  211. /**
  212. * Ensure a function is called only once.
  213. */
  214. function once (fn) {
  215. var called = false;
  216. return function () {
  217. if (!called) {
  218. called = true;
  219. fn();
  220. }
  221. }
  222. }
  223. /* */
  224. var config = {
  225. /**
  226. * Option merge strategies (used in core/util/options)
  227. */
  228. optionMergeStrategies: Object.create(null),
  229. /**
  230. * Whether to suppress warnings.
  231. */
  232. silent: false,
  233. /**
  234. * Show production mode tip message on boot?
  235. */
  236. productionTip: process.env.NODE_ENV !== 'production',
  237. /**
  238. * Whether to enable devtools
  239. */
  240. devtools: process.env.NODE_ENV !== 'production',
  241. /**
  242. * Whether to record perf
  243. */
  244. performance: process.env.NODE_ENV !== 'production',
  245. /**
  246. * Error handler for watcher errors
  247. */
  248. errorHandler: null,
  249. /**
  250. * Ignore certain custom elements
  251. */
  252. ignoredElements: [],
  253. /**
  254. * Custom user key aliases for v-on
  255. */
  256. keyCodes: Object.create(null),
  257. /**
  258. * Check if a tag is reserved so that it cannot be registered as a
  259. * component. This is platform-dependent and may be overwritten.
  260. */
  261. isReservedTag: no,
  262. /**
  263. * Check if a tag is an unknown element.
  264. * Platform-dependent.
  265. */
  266. isUnknownElement: no,
  267. /**
  268. * Get the namespace of an element
  269. */
  270. getTagNamespace: noop,
  271. /**
  272. * Parse the real tag name for the specific platform.
  273. */
  274. parsePlatformTagName: identity,
  275. /**
  276. * Check if an attribute must be bound using property, e.g. value
  277. * Platform-dependent.
  278. */
  279. mustUseProp: no,
  280. /**
  281. * List of asset types that a component can own.
  282. */
  283. _assetTypes: [
  284. 'component',
  285. 'directive',
  286. 'filter'
  287. ],
  288. /**
  289. * List of lifecycle hooks.
  290. */
  291. _lifecycleHooks: [
  292. 'beforeCreate',
  293. 'created',
  294. 'beforeMount',
  295. 'mounted',
  296. 'beforeUpdate',
  297. 'updated',
  298. 'beforeDestroy',
  299. 'destroyed',
  300. 'activated',
  301. 'deactivated'
  302. ],
  303. /**
  304. * Max circular updates allowed in a scheduler flush cycle.
  305. */
  306. _maxUpdateCount: 100
  307. };
  308. /* */
  309. /* globals MutationObserver */
  310. // can we use __proto__?
  311. var hasProto = '__proto__' in {};
  312. // Browser environment sniffing
  313. var inBrowser = typeof window !== 'undefined';
  314. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  315. var isIE = UA && /msie|trident/.test(UA);
  316. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  317. var isEdge = UA && UA.indexOf('edge/') > 0;
  318. var isAndroid = UA && UA.indexOf('android') > 0;
  319. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  320. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  321. // this needs to be lazy-evaled because vue may be required before
  322. // vue-server-renderer can set VUE_ENV
  323. var _isServer;
  324. var isServerRendering = function () {
  325. if (_isServer === undefined) {
  326. /* istanbul ignore if */
  327. if (!inBrowser && typeof global !== 'undefined') {
  328. // detect presence of vue-server-renderer and avoid
  329. // Webpack shimming the process
  330. _isServer = global['process'].env.VUE_ENV === 'server';
  331. } else {
  332. _isServer = false;
  333. }
  334. }
  335. return _isServer
  336. };
  337. // detect devtools
  338. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  339. /* istanbul ignore next */
  340. function isNative (Ctor) {
  341. return /native code/.test(Ctor.toString())
  342. }
  343. var hasSymbol =
  344. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  345. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  346. /**
  347. * Defer a task to execute it asynchronously.
  348. */
  349. var nextTick = (function () {
  350. var callbacks = [];
  351. var pending = false;
  352. var timerFunc;
  353. function nextTickHandler () {
  354. pending = false;
  355. var copies = callbacks.slice(0);
  356. callbacks.length = 0;
  357. for (var i = 0; i < copies.length; i++) {
  358. copies[i]();
  359. }
  360. }
  361. // the nextTick behavior leverages the microtask queue, which can be accessed
  362. // via either native Promise.then or MutationObserver.
  363. // MutationObserver has wider support, however it is seriously bugged in
  364. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  365. // completely stops working after triggering a few times... so, if native
  366. // Promise is available, we will use it:
  367. /* istanbul ignore if */
  368. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  369. var p = Promise.resolve();
  370. var logError = function (err) { console.error(err); };
  371. timerFunc = function () {
  372. p.then(nextTickHandler).catch(logError);
  373. // in problematic UIWebViews, Promise.then doesn't completely break, but
  374. // it can get stuck in a weird state where callbacks are pushed into the
  375. // microtask queue but the queue isn't being flushed, until the browser
  376. // needs to do some other work, e.g. handle a timer. Therefore we can
  377. // "force" the microtask queue to be flushed by adding an empty timer.
  378. if (isIOS) { setTimeout(noop); }
  379. };
  380. } else if (typeof MutationObserver !== 'undefined' && (
  381. isNative(MutationObserver) ||
  382. // PhantomJS and iOS 7.x
  383. MutationObserver.toString() === '[object MutationObserverConstructor]'
  384. )) {
  385. // use MutationObserver where native Promise is not available,
  386. // e.g. PhantomJS IE11, iOS7, Android 4.4
  387. var counter = 1;
  388. var observer = new MutationObserver(nextTickHandler);
  389. var textNode = document.createTextNode(String(counter));
  390. observer.observe(textNode, {
  391. characterData: true
  392. });
  393. timerFunc = function () {
  394. counter = (counter + 1) % 2;
  395. textNode.data = String(counter);
  396. };
  397. } else {
  398. // fallback to setTimeout
  399. /* istanbul ignore next */
  400. timerFunc = function () {
  401. setTimeout(nextTickHandler, 0);
  402. };
  403. }
  404. return function queueNextTick (cb, ctx) {
  405. var _resolve;
  406. callbacks.push(function () {
  407. if (cb) { cb.call(ctx); }
  408. if (_resolve) { _resolve(ctx); }
  409. });
  410. if (!pending) {
  411. pending = true;
  412. timerFunc();
  413. }
  414. if (!cb && typeof Promise !== 'undefined') {
  415. return new Promise(function (resolve) {
  416. _resolve = resolve;
  417. })
  418. }
  419. }
  420. })();
  421. var _Set;
  422. /* istanbul ignore if */
  423. if (typeof Set !== 'undefined' && isNative(Set)) {
  424. // use native Set when available.
  425. _Set = Set;
  426. } else {
  427. // a non-standard Set polyfill that only works with primitive keys.
  428. _Set = (function () {
  429. function Set () {
  430. this.set = Object.create(null);
  431. }
  432. Set.prototype.has = function has (key) {
  433. return this.set[key] === true
  434. };
  435. Set.prototype.add = function add (key) {
  436. this.set[key] = true;
  437. };
  438. Set.prototype.clear = function clear () {
  439. this.set = Object.create(null);
  440. };
  441. return Set;
  442. }());
  443. }
  444. var perf;
  445. if (process.env.NODE_ENV !== 'production') {
  446. perf = inBrowser && window.performance;
  447. if (perf && (!perf.mark || !perf.measure)) {
  448. perf = undefined;
  449. }
  450. }
  451. /* */
  452. var emptyObject = Object.freeze({});
  453. /**
  454. * Check if a string starts with $ or _
  455. */
  456. function isReserved (str) {
  457. var c = (str + '').charCodeAt(0);
  458. return c === 0x24 || c === 0x5F
  459. }
  460. /**
  461. * Define a property.
  462. */
  463. function def (obj, key, val, enumerable) {
  464. Object.defineProperty(obj, key, {
  465. value: val,
  466. enumerable: !!enumerable,
  467. writable: true,
  468. configurable: true
  469. });
  470. }
  471. /**
  472. * Parse simple path.
  473. */
  474. var bailRE = /[^\w.$]/;
  475. function parsePath (path) {
  476. if (bailRE.test(path)) {
  477. return
  478. }
  479. var segments = path.split('.');
  480. return function (obj) {
  481. for (var i = 0; i < segments.length; i++) {
  482. if (!obj) { return }
  483. obj = obj[segments[i]];
  484. }
  485. return obj
  486. }
  487. }
  488. var warn = noop;
  489. var tip = noop;
  490. var formatComponentName;
  491. if (process.env.NODE_ENV !== 'production') {
  492. var hasConsole = typeof console !== 'undefined';
  493. var classifyRE = /(?:^|[-_])(\w)/g;
  494. var classify = function (str) { return str
  495. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  496. .replace(/[-_]/g, ''); };
  497. warn = function (msg, vm) {
  498. if (hasConsole && (!config.silent)) {
  499. console.error("[Vue warn]: " + msg + " " + (
  500. vm ? formatLocation(formatComponentName(vm)) : ''
  501. ));
  502. }
  503. };
  504. tip = function (msg, vm) {
  505. if (hasConsole && (!config.silent)) {
  506. console.warn("[Vue tip]: " + msg + " " + (
  507. vm ? formatLocation(formatComponentName(vm)) : ''
  508. ));
  509. }
  510. };
  511. formatComponentName = function (vm, includeFile) {
  512. if (vm.$root === vm) {
  513. return '<Root>'
  514. }
  515. var name = vm._isVue
  516. ? vm.$options.name || vm.$options._componentTag
  517. : vm.name;
  518. var file = vm._isVue && vm.$options.__file;
  519. if (!name && file) {
  520. var 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. var formatLocation = function (str) {
  529. if (str === "<Anonymous>") {
  530. str += " - use the \"name\" option for better debugging messages.";
  531. }
  532. return ("\n(found in " + str + ")")
  533. };
  534. }
  535. /* */
  536. var uid$1 = 0;
  537. /**
  538. * A dep is an observable that can have multiple
  539. * directives subscribing to it.
  540. */
  541. var Dep = function Dep () {
  542. this.id = uid$1++;
  543. this.subs = [];
  544. };
  545. Dep.prototype.addSub = function addSub (sub) {
  546. this.subs.push(sub);
  547. };
  548. Dep.prototype.removeSub = function removeSub (sub) {
  549. remove(this.subs, sub);
  550. };
  551. Dep.prototype.depend = function depend () {
  552. if (Dep.target) {
  553. Dep.target.addDep(this);
  554. }
  555. };
  556. Dep.prototype.notify = function notify () {
  557. // stabilize the subscriber list first
  558. var subs = this.subs.slice();
  559. for (var i = 0, l = subs.length; i < l; i++) {
  560. subs[i].update();
  561. }
  562. };
  563. // the current target watcher being evaluated.
  564. // this is globally unique because there could be only one
  565. // watcher being evaluated at any time.
  566. Dep.target = null;
  567. var targetStack = [];
  568. function pushTarget (_target) {
  569. if (Dep.target) { targetStack.push(Dep.target); }
  570. Dep.target = _target;
  571. }
  572. function popTarget () {
  573. Dep.target = targetStack.pop();
  574. }
  575. /*
  576. * not type checking this file because flow doesn't play well with
  577. * dynamically accessing methods on Array prototype
  578. */
  579. var arrayProto = Array.prototype;
  580. var arrayMethods = Object.create(arrayProto);[
  581. 'push',
  582. 'pop',
  583. 'shift',
  584. 'unshift',
  585. 'splice',
  586. 'sort',
  587. 'reverse'
  588. ]
  589. .forEach(function (method) {
  590. // cache original method
  591. var original = arrayProto[method];
  592. def(arrayMethods, method, function mutator () {
  593. var arguments$1 = arguments;
  594. // avoid leaking arguments:
  595. // http://jsperf.com/closure-with-arguments
  596. var i = arguments.length;
  597. var args = new Array(i);
  598. while (i--) {
  599. args[i] = arguments$1[i];
  600. }
  601. var result = original.apply(this, args);
  602. var ob = this.__ob__;
  603. var inserted;
  604. switch (method) {
  605. case 'push':
  606. inserted = args;
  607. break
  608. case 'unshift':
  609. inserted = args;
  610. break
  611. case 'splice':
  612. inserted = args.slice(2);
  613. break
  614. }
  615. if (inserted) { ob.observeArray(inserted); }
  616. // notify change
  617. ob.dep.notify();
  618. return result
  619. });
  620. });
  621. /* */
  622. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  623. /**
  624. * By default, when a reactive property is set, the new value is
  625. * also converted to become reactive. However when passing down props,
  626. * we don't want to force conversion because the value may be a nested value
  627. * under a frozen data structure. Converting it would defeat the optimization.
  628. */
  629. var observerState = {
  630. shouldConvert: true,
  631. isSettingProps: false
  632. };
  633. /**
  634. * Observer class that are attached to each observed
  635. * object. Once attached, the observer converts target
  636. * object's property keys into getter/setters that
  637. * collect dependencies and dispatches updates.
  638. */
  639. var Observer = function Observer (value) {
  640. this.value = value;
  641. this.dep = new Dep();
  642. this.vmCount = 0;
  643. def(value, '__ob__', this);
  644. if (Array.isArray(value)) {
  645. var augment = hasProto
  646. ? protoAugment
  647. : copyAugment;
  648. augment(value, arrayMethods, arrayKeys);
  649. this.observeArray(value);
  650. } else {
  651. this.walk(value);
  652. }
  653. };
  654. /**
  655. * Walk through each property and convert them into
  656. * getter/setters. This method should only be called when
  657. * value type is Object.
  658. */
  659. Observer.prototype.walk = function walk (obj) {
  660. var keys = Object.keys(obj);
  661. for (var i = 0; i < keys.length; i++) {
  662. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  663. }
  664. };
  665. /**
  666. * Observe a list of Array items.
  667. */
  668. Observer.prototype.observeArray = function observeArray (items) {
  669. for (var i = 0, l = items.length; i < l; i++) {
  670. observe(items[i]);
  671. }
  672. };
  673. // helpers
  674. /**
  675. * Augment an target Object or Array by intercepting
  676. * the prototype chain using __proto__
  677. */
  678. function protoAugment (target, src) {
  679. /* eslint-disable no-proto */
  680. target.__proto__ = src;
  681. /* eslint-enable no-proto */
  682. }
  683. /**
  684. * Augment an target Object or Array by defining
  685. * hidden properties.
  686. */
  687. /* istanbul ignore next */
  688. function copyAugment (target, src, keys) {
  689. for (var i = 0, l = keys.length; i < l; i++) {
  690. var key = keys[i];
  691. def(target, key, src[key]);
  692. }
  693. }
  694. /**
  695. * Attempt to create an observer instance for a value,
  696. * returns the new observer if successfully observed,
  697. * or the existing observer if the value already has one.
  698. */
  699. function observe (value, asRootData) {
  700. if (!isObject(value)) {
  701. return
  702. }
  703. var ob;
  704. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  705. ob = value.__ob__;
  706. } else if (
  707. observerState.shouldConvert &&
  708. !isServerRendering() &&
  709. (Array.isArray(value) || isPlainObject(value)) &&
  710. Object.isExtensible(value) &&
  711. !value._isVue
  712. ) {
  713. ob = new Observer(value);
  714. }
  715. if (asRootData && ob) {
  716. ob.vmCount++;
  717. }
  718. return ob
  719. }
  720. /**
  721. * Define a reactive property on an Object.
  722. */
  723. function defineReactive$$1 (
  724. obj,
  725. key,
  726. val,
  727. customSetter
  728. ) {
  729. var dep = new Dep();
  730. var property = Object.getOwnPropertyDescriptor(obj, key);
  731. if (property && property.configurable === false) {
  732. return
  733. }
  734. // cater for pre-defined getter/setters
  735. var getter = property && property.get;
  736. var setter = property && property.set;
  737. var childOb = observe(val);
  738. Object.defineProperty(obj, key, {
  739. enumerable: true,
  740. configurable: true,
  741. get: function reactiveGetter () {
  742. var value = getter ? getter.call(obj) : val;
  743. if (Dep.target) {
  744. dep.depend();
  745. if (childOb) {
  746. childOb.dep.depend();
  747. }
  748. if (Array.isArray(value)) {
  749. dependArray(value);
  750. }
  751. }
  752. return value
  753. },
  754. set: function reactiveSetter (newVal) {
  755. var value = getter ? getter.call(obj) : val;
  756. /* eslint-disable no-self-compare */
  757. if (newVal === value || (newVal !== newVal && value !== value)) {
  758. return
  759. }
  760. /* eslint-enable no-self-compare */
  761. if (process.env.NODE_ENV !== 'production' && customSetter) {
  762. customSetter();
  763. }
  764. if (setter) {
  765. setter.call(obj, newVal);
  766. } else {
  767. val = newVal;
  768. }
  769. childOb = observe(newVal);
  770. dep.notify();
  771. }
  772. });
  773. }
  774. /**
  775. * Set a property on an object. Adds the new property and
  776. * triggers change notification if the property doesn't
  777. * already exist.
  778. */
  779. function set (target, key, val) {
  780. if (Array.isArray(target)) {
  781. target.length = Math.max(target.length, key);
  782. target.splice(key, 1, val);
  783. return val
  784. }
  785. if (hasOwn(target, key)) {
  786. target[key] = val;
  787. return val
  788. }
  789. var ob = target.__ob__;
  790. if (target._isVue || (ob && ob.vmCount)) {
  791. process.env.NODE_ENV !== 'production' && warn(
  792. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  793. 'at runtime - declare it upfront in the data option.'
  794. );
  795. return val
  796. }
  797. if (!ob) {
  798. target[key] = val;
  799. return val
  800. }
  801. defineReactive$$1(ob.value, key, val);
  802. ob.dep.notify();
  803. return val
  804. }
  805. /**
  806. * Delete a property and trigger change if necessary.
  807. */
  808. function del (target, key) {
  809. if (Array.isArray(target)) {
  810. target.splice(key, 1);
  811. return
  812. }
  813. var ob = target.__ob__;
  814. if (target._isVue || (ob && ob.vmCount)) {
  815. process.env.NODE_ENV !== 'production' && warn(
  816. 'Avoid deleting properties on a Vue instance or its root $data ' +
  817. '- just set it to null.'
  818. );
  819. return
  820. }
  821. if (!hasOwn(target, key)) {
  822. return
  823. }
  824. delete target[key];
  825. if (!ob) {
  826. return
  827. }
  828. ob.dep.notify();
  829. }
  830. /**
  831. * Collect dependencies on array elements when the array is touched, since
  832. * we cannot intercept array element access like property getters.
  833. */
  834. function dependArray (value) {
  835. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  836. e = value[i];
  837. e && e.__ob__ && e.__ob__.dep.depend();
  838. if (Array.isArray(e)) {
  839. dependArray(e);
  840. }
  841. }
  842. }
  843. /* */
  844. /**
  845. * Option overwriting strategies are functions that handle
  846. * how to merge a parent option value and a child option
  847. * value into the final value.
  848. */
  849. var strats = config.optionMergeStrategies;
  850. /**
  851. * Options with restrictions
  852. */
  853. if (process.env.NODE_ENV !== 'production') {
  854. strats.el = strats.propsData = function (parent, child, vm, key) {
  855. if (!vm) {
  856. warn(
  857. "option \"" + key + "\" can only be used during instance " +
  858. 'creation with the `new` keyword.'
  859. );
  860. }
  861. return defaultStrat(parent, child)
  862. };
  863. }
  864. /**
  865. * Helper that recursively merges two data objects together.
  866. */
  867. function mergeData (to, from) {
  868. if (!from) { return to }
  869. var key, toVal, fromVal;
  870. var keys = Object.keys(from);
  871. for (var i = 0; i < keys.length; i++) {
  872. key = keys[i];
  873. toVal = to[key];
  874. fromVal = from[key];
  875. if (!hasOwn(to, key)) {
  876. set(to, key, fromVal);
  877. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  878. mergeData(toVal, fromVal);
  879. }
  880. }
  881. return to
  882. }
  883. /**
  884. * Data
  885. */
  886. strats.data = function (
  887. parentVal,
  888. childVal,
  889. vm
  890. ) {
  891. if (!vm) {
  892. // in a Vue.extend merge, both should be functions
  893. if (!childVal) {
  894. return parentVal
  895. }
  896. if (typeof childVal !== 'function') {
  897. process.env.NODE_ENV !== 'production' && warn(
  898. 'The "data" option should be a function ' +
  899. 'that returns a per-instance value in component ' +
  900. 'definitions.',
  901. vm
  902. );
  903. return parentVal
  904. }
  905. if (!parentVal) {
  906. return childVal
  907. }
  908. // when parentVal & childVal are both present,
  909. // we need to return a function that returns the
  910. // merged result of both functions... no need to
  911. // check if parentVal is a function here because
  912. // it has to be a function to pass previous merges.
  913. return function mergedDataFn () {
  914. return mergeData(
  915. childVal.call(this),
  916. parentVal.call(this)
  917. )
  918. }
  919. } else if (parentVal || childVal) {
  920. return function mergedInstanceDataFn () {
  921. // instance merge
  922. var instanceData = typeof childVal === 'function'
  923. ? childVal.call(vm)
  924. : childVal;
  925. var defaultData = typeof parentVal === 'function'
  926. ? parentVal.call(vm)
  927. : undefined;
  928. if (instanceData) {
  929. return mergeData(instanceData, defaultData)
  930. } else {
  931. return defaultData
  932. }
  933. }
  934. }
  935. };
  936. /**
  937. * Hooks and props are merged as arrays.
  938. */
  939. function mergeHook (
  940. parentVal,
  941. childVal
  942. ) {
  943. return childVal
  944. ? parentVal
  945. ? parentVal.concat(childVal)
  946. : Array.isArray(childVal)
  947. ? childVal
  948. : [childVal]
  949. : parentVal
  950. }
  951. config._lifecycleHooks.forEach(function (hook) {
  952. strats[hook] = mergeHook;
  953. });
  954. /**
  955. * Assets
  956. *
  957. * When a vm is present (instance creation), we need to do
  958. * a three-way merge between constructor options, instance
  959. * options and parent options.
  960. */
  961. function mergeAssets (parentVal, childVal) {
  962. var res = Object.create(parentVal || null);
  963. return childVal
  964. ? extend(res, childVal)
  965. : res
  966. }
  967. config._assetTypes.forEach(function (type) {
  968. strats[type + 's'] = mergeAssets;
  969. });
  970. /**
  971. * Watchers.
  972. *
  973. * Watchers hashes should not overwrite one
  974. * another, so we merge them as arrays.
  975. */
  976. strats.watch = function (parentVal, childVal) {
  977. /* istanbul ignore if */
  978. if (!childVal) { return Object.create(parentVal || null) }
  979. if (!parentVal) { return childVal }
  980. var ret = {};
  981. extend(ret, parentVal);
  982. for (var key in childVal) {
  983. var parent = ret[key];
  984. var child = childVal[key];
  985. if (parent && !Array.isArray(parent)) {
  986. parent = [parent];
  987. }
  988. ret[key] = parent
  989. ? parent.concat(child)
  990. : [child];
  991. }
  992. return ret
  993. };
  994. /**
  995. * Other object hashes.
  996. */
  997. strats.props =
  998. strats.methods =
  999. strats.computed = function (parentVal, childVal) {
  1000. if (!childVal) { return Object.create(parentVal || null) }
  1001. if (!parentVal) { return childVal }
  1002. var ret = Object.create(null);
  1003. extend(ret, parentVal);
  1004. extend(ret, childVal);
  1005. return ret
  1006. };
  1007. /**
  1008. * Default strategy.
  1009. */
  1010. var defaultStrat = function (parentVal, childVal) {
  1011. return childVal === undefined
  1012. ? parentVal
  1013. : childVal
  1014. };
  1015. /**
  1016. * Validate component names
  1017. */
  1018. function checkComponents (options) {
  1019. for (var key in options.components) {
  1020. var lower = key.toLowerCase();
  1021. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  1022. warn(
  1023. 'Do not use built-in or reserved HTML elements as component ' +
  1024. 'id: ' + key
  1025. );
  1026. }
  1027. }
  1028. }
  1029. /**
  1030. * Ensure all props option syntax are normalized into the
  1031. * Object-based format.
  1032. */
  1033. function normalizeProps (options) {
  1034. var props = options.props;
  1035. if (!props) { return }
  1036. var res = {};
  1037. var i, val, name;
  1038. if (Array.isArray(props)) {
  1039. i = props.length;
  1040. while (i--) {
  1041. val = props[i];
  1042. if (typeof val === 'string') {
  1043. name = camelize(val);
  1044. res[name] = { type: null };
  1045. } else if (process.env.NODE_ENV !== 'production') {
  1046. warn('props must be strings when using array syntax.');
  1047. }
  1048. }
  1049. } else if (isPlainObject(props)) {
  1050. for (var key in props) {
  1051. val = props[key];
  1052. name = camelize(key);
  1053. res[name] = isPlainObject(val)
  1054. ? val
  1055. : { type: val };
  1056. }
  1057. }
  1058. options.props = res;
  1059. }
  1060. /**
  1061. * Normalize raw function directives into object format.
  1062. */
  1063. function normalizeDirectives (options) {
  1064. var dirs = options.directives;
  1065. if (dirs) {
  1066. for (var key in dirs) {
  1067. var def = dirs[key];
  1068. if (typeof def === 'function') {
  1069. dirs[key] = { bind: def, update: def };
  1070. }
  1071. }
  1072. }
  1073. }
  1074. /**
  1075. * Merge two option objects into a new one.
  1076. * Core utility used in both instantiation and inheritance.
  1077. */
  1078. function mergeOptions (
  1079. parent,
  1080. child,
  1081. vm
  1082. ) {
  1083. if (process.env.NODE_ENV !== 'production') {
  1084. checkComponents(child);
  1085. }
  1086. normalizeProps(child);
  1087. normalizeDirectives(child);
  1088. var extendsFrom = child.extends;
  1089. if (extendsFrom) {
  1090. parent = typeof extendsFrom === 'function'
  1091. ? mergeOptions(parent, extendsFrom.options, vm)
  1092. : mergeOptions(parent, extendsFrom, vm);
  1093. }
  1094. if (child.mixins) {
  1095. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1096. var mixin = child.mixins[i];
  1097. if (mixin.prototype instanceof Vue$2) {
  1098. mixin = mixin.options;
  1099. }
  1100. parent = mergeOptions(parent, mixin, vm);
  1101. }
  1102. }
  1103. var options = {};
  1104. var key;
  1105. for (key in parent) {
  1106. mergeField(key);
  1107. }
  1108. for (key in child) {
  1109. if (!hasOwn(parent, key)) {
  1110. mergeField(key);
  1111. }
  1112. }
  1113. function mergeField (key) {
  1114. var strat = strats[key] || defaultStrat;
  1115. options[key] = strat(parent[key], child[key], vm, key);
  1116. }
  1117. return options
  1118. }
  1119. /**
  1120. * Resolve an asset.
  1121. * This function is used because child instances need access
  1122. * to assets defined in its ancestor chain.
  1123. */
  1124. function resolveAsset (
  1125. options,
  1126. type,
  1127. id,
  1128. warnMissing
  1129. ) {
  1130. /* istanbul ignore if */
  1131. if (typeof id !== 'string') {
  1132. return
  1133. }
  1134. var assets = options[type];
  1135. // check local registration variations first
  1136. if (hasOwn(assets, id)) { return assets[id] }
  1137. var camelizedId = camelize(id);
  1138. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1139. var PascalCaseId = capitalize(camelizedId);
  1140. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1141. // fallback to prototype chain
  1142. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1143. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  1144. warn(
  1145. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1146. options
  1147. );
  1148. }
  1149. return res
  1150. }
  1151. /* */
  1152. function validateProp (
  1153. key,
  1154. propOptions,
  1155. propsData,
  1156. vm
  1157. ) {
  1158. var prop = propOptions[key];
  1159. var absent = !hasOwn(propsData, key);
  1160. var value = propsData[key];
  1161. // handle boolean props
  1162. if (isType(Boolean, prop.type)) {
  1163. if (absent && !hasOwn(prop, 'default')) {
  1164. value = false;
  1165. } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
  1166. value = true;
  1167. }
  1168. }
  1169. // check default value
  1170. if (value === undefined) {
  1171. value = getPropDefaultValue(vm, prop, key);
  1172. // since the default value is a fresh copy,
  1173. // make sure to observe it.
  1174. var prevShouldConvert = observerState.shouldConvert;
  1175. observerState.shouldConvert = true;
  1176. observe(value);
  1177. observerState.shouldConvert = prevShouldConvert;
  1178. }
  1179. if (process.env.NODE_ENV !== 'production') {
  1180. assertProp(prop, key, value, vm, absent);
  1181. }
  1182. return value
  1183. }
  1184. /**
  1185. * Get the default value of a prop.
  1186. */
  1187. function getPropDefaultValue (vm, prop, key) {
  1188. // no default, return undefined
  1189. if (!hasOwn(prop, 'default')) {
  1190. return undefined
  1191. }
  1192. var def = prop.default;
  1193. // warn against non-factory defaults for Object & Array
  1194. if (process.env.NODE_ENV !== 'production' && isObject(def)) {
  1195. warn(
  1196. 'Invalid default value for prop "' + key + '": ' +
  1197. 'Props with type Object/Array must use a factory function ' +
  1198. 'to return the default value.',
  1199. vm
  1200. );
  1201. }
  1202. // the raw prop value was also undefined from previous render,
  1203. // return previous default value to avoid unnecessary watcher trigger
  1204. if (vm && vm.$options.propsData &&
  1205. vm.$options.propsData[key] === undefined &&
  1206. vm._props[key] !== undefined) {
  1207. return vm._props[key]
  1208. }
  1209. // call factory function for non-Function types
  1210. // a value is Function if its prototype is function even across different execution context
  1211. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1212. ? def.call(vm)
  1213. : def
  1214. }
  1215. /**
  1216. * Assert whether a prop is valid.
  1217. */
  1218. function assertProp (
  1219. prop,
  1220. name,
  1221. value,
  1222. vm,
  1223. absent
  1224. ) {
  1225. if (prop.required && absent) {
  1226. warn(
  1227. 'Missing required prop: "' + name + '"',
  1228. vm
  1229. );
  1230. return
  1231. }
  1232. if (value == null && !prop.required) {
  1233. return
  1234. }
  1235. var type = prop.type;
  1236. var valid = !type || type === true;
  1237. var expectedTypes = [];
  1238. if (type) {
  1239. if (!Array.isArray(type)) {
  1240. type = [type];
  1241. }
  1242. for (var i = 0; i < type.length && !valid; i++) {
  1243. var assertedType = assertType(value, type[i]);
  1244. expectedTypes.push(assertedType.expectedType || '');
  1245. valid = assertedType.valid;
  1246. }
  1247. }
  1248. if (!valid) {
  1249. warn(
  1250. 'Invalid prop: type check failed for prop "' + name + '".' +
  1251. ' Expected ' + expectedTypes.map(capitalize).join(', ') +
  1252. ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
  1253. vm
  1254. );
  1255. return
  1256. }
  1257. var validator = prop.validator;
  1258. if (validator) {
  1259. if (!validator(value)) {
  1260. warn(
  1261. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1262. vm
  1263. );
  1264. }
  1265. }
  1266. }
  1267. /**
  1268. * Assert the type of a value
  1269. */
  1270. function assertType (value, type) {
  1271. var valid;
  1272. var expectedType = getType(type);
  1273. if (expectedType === 'String') {
  1274. valid = typeof value === (expectedType = 'string');
  1275. } else if (expectedType === 'Number') {
  1276. valid = typeof value === (expectedType = 'number');
  1277. } else if (expectedType === 'Boolean') {
  1278. valid = typeof value === (expectedType = 'boolean');
  1279. } else if (expectedType === 'Function') {
  1280. valid = typeof value === (expectedType = 'function');
  1281. } else if (expectedType === 'Object') {
  1282. valid = isPlainObject(value);
  1283. } else if (expectedType === 'Array') {
  1284. valid = Array.isArray(value);
  1285. } else {
  1286. valid = value instanceof type;
  1287. }
  1288. return {
  1289. valid: valid,
  1290. expectedType: expectedType
  1291. }
  1292. }
  1293. /**
  1294. * Use function string name to check built-in types,
  1295. * because a simple equality check will fail when running
  1296. * across different vms / iframes.
  1297. */
  1298. function getType (fn) {
  1299. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  1300. return match && match[1]
  1301. }
  1302. function isType (type, fn) {
  1303. if (!Array.isArray(fn)) {
  1304. return getType(fn) === getType(type)
  1305. }
  1306. for (var i = 0, len = fn.length; i < len; i++) {
  1307. if (getType(fn[i]) === getType(type)) {
  1308. return true
  1309. }
  1310. }
  1311. /* istanbul ignore next */
  1312. return false
  1313. }
  1314. function handleError (err, vm, info) {
  1315. if (config.errorHandler) {
  1316. config.errorHandler.call(null, err, vm, info);
  1317. } else {
  1318. if (process.env.NODE_ENV !== 'production') {
  1319. warn(("Error in " + info + ":"), vm);
  1320. }
  1321. /* istanbul ignore else */
  1322. if (inBrowser && typeof console !== 'undefined') {
  1323. console.error(err);
  1324. } else {
  1325. throw err
  1326. }
  1327. }
  1328. }
  1329. /* not type checking this file because flow doesn't play well with Proxy */
  1330. var initProxy;
  1331. if (process.env.NODE_ENV !== 'production') {
  1332. var allowedGlobals = makeMap(
  1333. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1334. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1335. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  1336. 'require' // for Webpack/Browserify
  1337. );
  1338. var warnNonPresent = function (target, key) {
  1339. warn(
  1340. "Property or method \"" + key + "\" is not defined on the instance but " +
  1341. "referenced during render. Make sure to declare reactive data " +
  1342. "properties in the data option.",
  1343. target
  1344. );
  1345. };
  1346. var hasProxy =
  1347. typeof Proxy !== 'undefined' &&
  1348. Proxy.toString().match(/native code/);
  1349. if (hasProxy) {
  1350. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
  1351. config.keyCodes = new Proxy(config.keyCodes, {
  1352. set: function set (target, key, value) {
  1353. if (isBuiltInModifier(key)) {
  1354. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  1355. return false
  1356. } else {
  1357. target[key] = value;
  1358. return true
  1359. }
  1360. }
  1361. });
  1362. }
  1363. var hasHandler = {
  1364. has: function has (target, key) {
  1365. var has = key in target;
  1366. var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
  1367. if (!has && !isAllowed) {
  1368. warnNonPresent(target, key);
  1369. }
  1370. return has || !isAllowed
  1371. }
  1372. };
  1373. var getHandler = {
  1374. get: function get (target, key) {
  1375. if (typeof key === 'string' && !(key in target)) {
  1376. warnNonPresent(target, key);
  1377. }
  1378. return target[key]
  1379. }
  1380. };
  1381. initProxy = function initProxy (vm) {
  1382. if (hasProxy) {
  1383. // determine which proxy handler to use
  1384. var options = vm.$options;
  1385. var handlers = options.render && options.render._withStripped
  1386. ? getHandler
  1387. : hasHandler;
  1388. vm._renderProxy = new Proxy(vm, handlers);
  1389. } else {
  1390. vm._renderProxy = vm;
  1391. }
  1392. };
  1393. }
  1394. /* */
  1395. var VNode = function VNode (
  1396. tag,
  1397. data,
  1398. children,
  1399. text,
  1400. elm,
  1401. context,
  1402. componentOptions
  1403. ) {
  1404. this.tag = tag;
  1405. this.data = data;
  1406. this.children = children;
  1407. this.text = text;
  1408. this.elm = elm;
  1409. this.ns = undefined;
  1410. this.context = context;
  1411. this.functionalContext = undefined;
  1412. this.key = data && data.key;
  1413. this.componentOptions = componentOptions;
  1414. this.componentInstance = undefined;
  1415. this.parent = undefined;
  1416. this.raw = false;
  1417. this.isStatic = false;
  1418. this.isRootInsert = true;
  1419. this.isComment = false;
  1420. this.isCloned = false;
  1421. this.isOnce = false;
  1422. };
  1423. var prototypeAccessors = { child: {} };
  1424. // DEPRECATED: alias for componentInstance for backwards compat.
  1425. /* istanbul ignore next */
  1426. prototypeAccessors.child.get = function () {
  1427. return this.componentInstance
  1428. };
  1429. Object.defineProperties( VNode.prototype, prototypeAccessors );
  1430. var createEmptyVNode = function () {
  1431. var node = new VNode();
  1432. node.text = '';
  1433. node.isComment = true;
  1434. return node
  1435. };
  1436. function createTextVNode (val) {
  1437. return new VNode(undefined, undefined, undefined, String(val))
  1438. }
  1439. // optimized shallow clone
  1440. // used for static nodes and slot nodes because they may be reused across
  1441. // multiple renders, cloning them avoids errors when DOM manipulations rely
  1442. // on their elm reference.
  1443. function cloneVNode (vnode) {
  1444. var cloned = new VNode(
  1445. vnode.tag,
  1446. vnode.data,
  1447. vnode.children,
  1448. vnode.text,
  1449. vnode.elm,
  1450. vnode.context,
  1451. vnode.componentOptions
  1452. );
  1453. cloned.ns = vnode.ns;
  1454. cloned.isStatic = vnode.isStatic;
  1455. cloned.key = vnode.key;
  1456. cloned.isCloned = true;
  1457. return cloned
  1458. }
  1459. function cloneVNodes (vnodes) {
  1460. var len = vnodes.length;
  1461. var res = new Array(len);
  1462. for (var i = 0; i < len; i++) {
  1463. res[i] = cloneVNode(vnodes[i]);
  1464. }
  1465. return res
  1466. }
  1467. /* */
  1468. var normalizeEvent = cached(function (name) {
  1469. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1470. name = once$$1 ? name.slice(1) : name;
  1471. var capture = name.charAt(0) === '!';
  1472. name = capture ? name.slice(1) : name;
  1473. return {
  1474. name: name,
  1475. once: once$$1,
  1476. capture: capture
  1477. }
  1478. });
  1479. function createFnInvoker (fns) {
  1480. function invoker () {
  1481. var arguments$1 = arguments;
  1482. var fns = invoker.fns;
  1483. if (Array.isArray(fns)) {
  1484. for (var i = 0; i < fns.length; i++) {
  1485. fns[i].apply(null, arguments$1);
  1486. }
  1487. } else {
  1488. // return handler return value for single handlers
  1489. return fns.apply(null, arguments)
  1490. }
  1491. }
  1492. invoker.fns = fns;
  1493. return invoker
  1494. }
  1495. function updateListeners (
  1496. on,
  1497. oldOn,
  1498. add,
  1499. remove$$1,
  1500. vm
  1501. ) {
  1502. var name, cur, old, event;
  1503. for (name in on) {
  1504. cur = on[name];
  1505. old = oldOn[name];
  1506. event = normalizeEvent(name);
  1507. if (!cur) {
  1508. process.env.NODE_ENV !== 'production' && warn(
  1509. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  1510. vm
  1511. );
  1512. } else if (!old) {
  1513. if (!cur.fns) {
  1514. cur = on[name] = createFnInvoker(cur);
  1515. }
  1516. add(event.name, cur, event.once, event.capture);
  1517. } else if (cur !== old) {
  1518. old.fns = cur;
  1519. on[name] = old;
  1520. }
  1521. }
  1522. for (name in oldOn) {
  1523. if (!on[name]) {
  1524. event = normalizeEvent(name);
  1525. remove$$1(event.name, oldOn[name], event.capture);
  1526. }
  1527. }
  1528. }
  1529. /* */
  1530. function mergeVNodeHook (def, hookKey, hook) {
  1531. var invoker;
  1532. var oldHook = def[hookKey];
  1533. function wrappedHook () {
  1534. hook.apply(this, arguments);
  1535. // important: remove merged hook to ensure it's called only once
  1536. // and prevent memory leak
  1537. remove(invoker.fns, wrappedHook);
  1538. }
  1539. if (!oldHook) {
  1540. // no existing hook
  1541. invoker = createFnInvoker([wrappedHook]);
  1542. } else {
  1543. /* istanbul ignore if */
  1544. if (oldHook.fns && oldHook.merged) {
  1545. // already a merged invoker
  1546. invoker = oldHook;
  1547. invoker.fns.push(wrappedHook);
  1548. } else {
  1549. // existing plain hook
  1550. invoker = createFnInvoker([oldHook, wrappedHook]);
  1551. }
  1552. }
  1553. invoker.merged = true;
  1554. def[hookKey] = invoker;
  1555. }
  1556. /* */
  1557. // The template compiler attempts to minimize the need for normalization by
  1558. // statically analyzing the template at compile time.
  1559. //
  1560. // For plain HTML markup, normalization can be completely skipped because the
  1561. // generated render function is guaranteed to return Array<VNode>. There are
  1562. // two cases where extra normalization is needed:
  1563. // 1. When the children contains components - because a functional component
  1564. // may return an Array instead of a single root. In this case, just a simple
  1565. // normalization is needed - if any child is an Array, we flatten the whole
  1566. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1567. // because functional components already normalize their own children.
  1568. function simpleNormalizeChildren (children) {
  1569. for (var i = 0; i < children.length; i++) {
  1570. if (Array.isArray(children[i])) {
  1571. return Array.prototype.concat.apply([], children)
  1572. }
  1573. }
  1574. return children
  1575. }
  1576. // 2. When the children contains constructs that always generated nested Arrays,
  1577. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1578. // with hand-written render functions / JSX. In such cases a full normalization
  1579. // is needed to cater to all possible types of children values.
  1580. function normalizeChildren (children) {
  1581. return isPrimitive(children)
  1582. ? [createTextVNode(children)]
  1583. : Array.isArray(children)
  1584. ? normalizeArrayChildren(children)
  1585. : undefined
  1586. }
  1587. function normalizeArrayChildren (children, nestedIndex) {
  1588. var res = [];
  1589. var i, c, last;
  1590. for (i = 0; i < children.length; i++) {
  1591. c = children[i];
  1592. if (c == null || typeof c === 'boolean') { continue }
  1593. last = res[res.length - 1];
  1594. // nested
  1595. if (Array.isArray(c)) {
  1596. res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
  1597. } else if (isPrimitive(c)) {
  1598. if (last && last.text) {
  1599. last.text += String(c);
  1600. } else if (c !== '') {
  1601. // convert primitive to vnode
  1602. res.push(createTextVNode(c));
  1603. }
  1604. } else {
  1605. if (c.text && last && last.text) {
  1606. res[res.length - 1] = createTextVNode(last.text + c.text);
  1607. } else {
  1608. // default key for nested array children (likely generated by v-for)
  1609. if (c.tag && c.key == null && nestedIndex != null) {
  1610. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  1611. }
  1612. res.push(c);
  1613. }
  1614. }
  1615. }
  1616. return res
  1617. }
  1618. /* */
  1619. function getFirstComponentChild (children) {
  1620. return children && children.filter(function (c) { return c && c.componentOptions; })[0]
  1621. }
  1622. /* */
  1623. function initEvents (vm) {
  1624. vm._events = Object.create(null);
  1625. vm._hasHookEvent = false;
  1626. // init parent attached events
  1627. var listeners = vm.$options._parentListeners;
  1628. if (listeners) {
  1629. updateComponentListeners(vm, listeners);
  1630. }
  1631. }
  1632. var target;
  1633. function add (event, fn, once$$1) {
  1634. if (once$$1) {
  1635. target.$once(event, fn);
  1636. } else {
  1637. target.$on(event, fn);
  1638. }
  1639. }
  1640. function remove$1 (event, fn) {
  1641. target.$off(event, fn);
  1642. }
  1643. function updateComponentListeners (
  1644. vm,
  1645. listeners,
  1646. oldListeners
  1647. ) {
  1648. target = vm;
  1649. updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
  1650. }
  1651. function eventsMixin (Vue) {
  1652. var hookRE = /^hook:/;
  1653. Vue.prototype.$on = function (event, fn) {
  1654. var this$1 = this;
  1655. var vm = this;
  1656. if (Array.isArray(event)) {
  1657. for (var i = 0, l = event.length; i < l; i++) {
  1658. this$1.$on(event[i], fn);
  1659. }
  1660. } else {
  1661. (vm._events[event] || (vm._events[event] = [])).push(fn);
  1662. // optimize hook:event cost by using a boolean flag marked at registration
  1663. // instead of a hash lookup
  1664. if (hookRE.test(event)) {
  1665. vm._hasHookEvent = true;
  1666. }
  1667. }
  1668. return vm
  1669. };
  1670. Vue.prototype.$once = function (event, fn) {
  1671. var vm = this;
  1672. function on () {
  1673. vm.$off(event, on);
  1674. fn.apply(vm, arguments);
  1675. }
  1676. on.fn = fn;
  1677. vm.$on(event, on);
  1678. return vm
  1679. };
  1680. Vue.prototype.$off = function (event, fn) {
  1681. var this$1 = this;
  1682. var vm = this;
  1683. // all
  1684. if (!arguments.length) {
  1685. vm._events = Object.create(null);
  1686. return vm
  1687. }
  1688. // array of events
  1689. if (Array.isArray(event)) {
  1690. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  1691. this$1.$off(event[i$1], fn);
  1692. }
  1693. return vm
  1694. }
  1695. // specific event
  1696. var cbs = vm._events[event];
  1697. if (!cbs) {
  1698. return vm
  1699. }
  1700. if (arguments.length === 1) {
  1701. vm._events[event] = null;
  1702. return vm
  1703. }
  1704. // specific handler
  1705. var cb;
  1706. var i = cbs.length;
  1707. while (i--) {
  1708. cb = cbs[i];
  1709. if (cb === fn || cb.fn === fn) {
  1710. cbs.splice(i, 1);
  1711. break
  1712. }
  1713. }
  1714. return vm
  1715. };
  1716. Vue.prototype.$emit = function (event) {
  1717. var vm = this;
  1718. var cbs = vm._events[event];
  1719. if (cbs) {
  1720. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  1721. var args = toArray(arguments, 1);
  1722. for (var i = 0, l = cbs.length; i < l; i++) {
  1723. cbs[i].apply(vm, args);
  1724. }
  1725. }
  1726. return vm
  1727. };
  1728. }
  1729. /* */
  1730. /**
  1731. * Runtime helper for resolving raw children VNodes into a slot object.
  1732. */
  1733. function resolveSlots (
  1734. children,
  1735. context
  1736. ) {
  1737. var slots = {};
  1738. if (!children) {
  1739. return slots
  1740. }
  1741. var defaultSlot = [];
  1742. var name, child;
  1743. for (var i = 0, l = children.length; i < l; i++) {
  1744. child = children[i];
  1745. // named slots should only be respected if the vnode was rendered in the
  1746. // same context.
  1747. if ((child.context === context || child.functionalContext === context) &&
  1748. child.data && (name = child.data.slot)) {
  1749. var slot = (slots[name] || (slots[name] = []));
  1750. if (child.tag === 'template') {
  1751. slot.push.apply(slot, child.children);
  1752. } else {
  1753. slot.push(child);
  1754. }
  1755. } else {
  1756. defaultSlot.push(child);
  1757. }
  1758. }
  1759. // ignore whitespace
  1760. if (!defaultSlot.every(isWhitespace)) {
  1761. slots.default = defaultSlot;
  1762. }
  1763. return slots
  1764. }
  1765. function isWhitespace (node) {
  1766. return node.isComment || node.text === ' '
  1767. }
  1768. function resolveScopedSlots (
  1769. fns
  1770. ) {
  1771. var res = {};
  1772. for (var i = 0; i < fns.length; i++) {
  1773. res[fns[i][0]] = fns[i][1];
  1774. }
  1775. return res
  1776. }
  1777. /* */
  1778. var activeInstance = null;
  1779. function initLifecycle (vm) {
  1780. var options = vm.$options;
  1781. // locate first non-abstract parent
  1782. var parent = options.parent;
  1783. if (parent && !options.abstract) {
  1784. while (parent.$options.abstract && parent.$parent) {
  1785. parent = parent.$parent;
  1786. }
  1787. parent.$children.push(vm);
  1788. }
  1789. vm.$parent = parent;
  1790. vm.$root = parent ? parent.$root : vm;
  1791. vm.$children = [];
  1792. vm.$refs = {};
  1793. vm._watcher = null;
  1794. vm._inactive = null;
  1795. vm._directInactive = false;
  1796. vm._isMounted = false;
  1797. vm._isDestroyed = false;
  1798. vm._isBeingDestroyed = false;
  1799. }
  1800. function lifecycleMixin (Vue) {
  1801. Vue.prototype._update = function (vnode, hydrating) {
  1802. var vm = this;
  1803. if (vm._isMounted) {
  1804. callHook(vm, 'beforeUpdate');
  1805. }
  1806. var prevEl = vm.$el;
  1807. var prevVnode = vm._vnode;
  1808. var prevActiveInstance = activeInstance;
  1809. activeInstance = vm;
  1810. vm._vnode = vnode;
  1811. // Vue.prototype.__patch__ is injected in entry points
  1812. // based on the rendering backend used.
  1813. if (!prevVnode) {
  1814. // initial render
  1815. vm.$el = vm.__patch__(
  1816. vm.$el, vnode, hydrating, false /* removeOnly */,
  1817. vm.$options._parentElm,
  1818. vm.$options._refElm
  1819. );
  1820. } else {
  1821. // updates
  1822. vm.$el = vm.__patch__(prevVnode, vnode);
  1823. }
  1824. activeInstance = prevActiveInstance;
  1825. // update __vue__ reference
  1826. if (prevEl) {
  1827. prevEl.__vue__ = null;
  1828. }
  1829. if (vm.$el) {
  1830. vm.$el.__vue__ = vm;
  1831. }
  1832. // if parent is an HOC, update its $el as well
  1833. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  1834. vm.$parent.$el = vm.$el;
  1835. }
  1836. // updated hook is called by the scheduler to ensure that children are
  1837. // updated in a parent's updated hook.
  1838. };
  1839. Vue.prototype.$forceUpdate = function () {
  1840. var vm = this;
  1841. if (vm._watcher) {
  1842. vm._watcher.update();
  1843. }
  1844. };
  1845. Vue.prototype.$destroy = function () {
  1846. var vm = this;
  1847. if (vm._isBeingDestroyed) {
  1848. return
  1849. }
  1850. callHook(vm, 'beforeDestroy');
  1851. vm._isBeingDestroyed = true;
  1852. // remove self from parent
  1853. var parent = vm.$parent;
  1854. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  1855. remove(parent.$children, vm);
  1856. }
  1857. // teardown watchers
  1858. if (vm._watcher) {
  1859. vm._watcher.teardown();
  1860. }
  1861. var i = vm._watchers.length;
  1862. while (i--) {
  1863. vm._watchers[i].teardown();
  1864. }
  1865. // remove reference from data ob
  1866. // frozen object may not have observer.
  1867. if (vm._data.__ob__) {
  1868. vm._data.__ob__.vmCount--;
  1869. }
  1870. // call the last hook...
  1871. vm._isDestroyed = true;
  1872. callHook(vm, 'destroyed');
  1873. // turn off all instance listeners.
  1874. vm.$off();
  1875. // remove __vue__ reference
  1876. if (vm.$el) {
  1877. vm.$el.__vue__ = null;
  1878. }
  1879. // invoke destroy hooks on current rendered tree
  1880. vm.__patch__(vm._vnode, null);
  1881. };
  1882. }
  1883. function mountComponent (
  1884. vm,
  1885. el,
  1886. hydrating
  1887. ) {
  1888. vm.$el = el;
  1889. if (!vm.$options.render) {
  1890. vm.$options.render = createEmptyVNode;
  1891. if (process.env.NODE_ENV !== 'production') {
  1892. /* istanbul ignore if */
  1893. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  1894. vm.$options.el || el) {
  1895. warn(
  1896. 'You are using the runtime-only build of Vue where the template ' +
  1897. 'compiler is not available. Either pre-compile the templates into ' +
  1898. 'render functions, or use the compiler-included build.',
  1899. vm
  1900. );
  1901. } else {
  1902. warn(
  1903. 'Failed to mount component: template or render function not defined.',
  1904. vm
  1905. );
  1906. }
  1907. }
  1908. }
  1909. callHook(vm, 'beforeMount');
  1910. var updateComponent;
  1911. /* istanbul ignore if */
  1912. if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
  1913. updateComponent = function () {
  1914. var name = vm._name;
  1915. var startTag = "start " + name;
  1916. var endTag = "end " + name;
  1917. perf.mark(startTag);
  1918. var vnode = vm._render();
  1919. perf.mark(endTag);
  1920. perf.measure((name + " render"), startTag, endTag);
  1921. perf.mark(startTag);
  1922. vm._update(vnode, hydrating);
  1923. perf.mark(endTag);
  1924. perf.measure((name + " patch"), startTag, endTag);
  1925. };
  1926. } else {
  1927. updateComponent = function () {
  1928. vm._update(vm._render(), hydrating);
  1929. };
  1930. }
  1931. vm._watcher = new Watcher(vm, updateComponent, noop);
  1932. hydrating = false;
  1933. // manually mounted instance, call mounted on self
  1934. // mounted is called for render-created child components in its inserted hook
  1935. if (vm.$vnode == null) {
  1936. vm._isMounted = true;
  1937. callHook(vm, 'mounted');
  1938. }
  1939. return vm
  1940. }
  1941. function updateChildComponent (
  1942. vm,
  1943. propsData,
  1944. listeners,
  1945. parentVnode,
  1946. renderChildren
  1947. ) {
  1948. // determine whether component has slot children
  1949. // we need to do this before overwriting $options._renderChildren
  1950. var hasChildren = !!(
  1951. renderChildren || // has new static slots
  1952. vm.$options._renderChildren || // has old static slots
  1953. parentVnode.data.scopedSlots || // has new scoped slots
  1954. vm.$scopedSlots !== emptyObject // has old scoped slots
  1955. );
  1956. vm.$options._parentVnode = parentVnode;
  1957. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  1958. if (vm._vnode) { // update child tree's parent
  1959. vm._vnode.parent = parentVnode;
  1960. }
  1961. vm.$options._renderChildren = renderChildren;
  1962. // update props
  1963. if (propsData && vm.$options.props) {
  1964. observerState.shouldConvert = false;
  1965. if (process.env.NODE_ENV !== 'production') {
  1966. observerState.isSettingProps = true;
  1967. }
  1968. var props = vm._props;
  1969. var propKeys = vm.$options._propKeys || [];
  1970. for (var i = 0; i < propKeys.length; i++) {
  1971. var key = propKeys[i];
  1972. props[key] = validateProp(key, vm.$options.props, propsData, vm);
  1973. }
  1974. observerState.shouldConvert = true;
  1975. if (process.env.NODE_ENV !== 'production') {
  1976. observerState.isSettingProps = false;
  1977. }
  1978. // keep a copy of raw propsData
  1979. vm.$options.propsData = propsData;
  1980. }
  1981. // update listeners
  1982. if (listeners) {
  1983. var oldListeners = vm.$options._parentListeners;
  1984. vm.$options._parentListeners = listeners;
  1985. updateComponentListeners(vm, listeners, oldListeners);
  1986. }
  1987. // resolve slots + force update if has children
  1988. if (hasChildren) {
  1989. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  1990. vm.$forceUpdate();
  1991. }
  1992. }
  1993. function isInInactiveTree (vm) {
  1994. while (vm && (vm = vm.$parent)) {
  1995. if (vm._inactive) { return true }
  1996. }
  1997. return false
  1998. }
  1999. function activateChildComponent (vm, direct) {
  2000. if (direct) {
  2001. vm._directInactive = false;
  2002. if (isInInactiveTree(vm)) {
  2003. return
  2004. }
  2005. } else if (vm._directInactive) {
  2006. return
  2007. }
  2008. if (vm._inactive || vm._inactive == null) {
  2009. vm._inactive = false;
  2010. for (var i = 0; i < vm.$children.length; i++) {
  2011. activateChildComponent(vm.$children[i]);
  2012. }
  2013. callHook(vm, 'activated');
  2014. }
  2015. }
  2016. function deactivateChildComponent (vm, direct) {
  2017. if (direct) {
  2018. vm._directInactive = true;
  2019. if (isInInactiveTree(vm)) {
  2020. return
  2021. }
  2022. }
  2023. if (!vm._inactive) {
  2024. vm._inactive = true;
  2025. for (var i = 0; i < vm.$children.length; i++) {
  2026. deactivateChildComponent(vm.$children[i]);
  2027. }
  2028. callHook(vm, 'deactivated');
  2029. }
  2030. }
  2031. function callHook (vm, hook) {
  2032. var handlers = vm.$options[hook];
  2033. if (handlers) {
  2034. for (var i = 0, j = handlers.length; i < j; i++) {
  2035. try {
  2036. handlers[i].call(vm);
  2037. } catch (e) {
  2038. handleError(e, vm, (hook + " hook"));
  2039. }
  2040. }
  2041. }
  2042. if (vm._hasHookEvent) {
  2043. vm.$emit('hook:' + hook);
  2044. }
  2045. }
  2046. /* */
  2047. var queue = [];
  2048. var has = {};
  2049. var circular = {};
  2050. var waiting = false;
  2051. var flushing = false;
  2052. var index = 0;
  2053. /**
  2054. * Reset the scheduler's state.
  2055. */
  2056. function resetSchedulerState () {
  2057. queue.length = 0;
  2058. has = {};
  2059. if (process.env.NODE_ENV !== 'production') {
  2060. circular = {};
  2061. }
  2062. waiting = flushing = false;
  2063. }
  2064. /**
  2065. * Flush both queues and run the watchers.
  2066. */
  2067. function flushSchedulerQueue () {
  2068. flushing = true;
  2069. var watcher, id, vm;
  2070. // Sort queue before flush.
  2071. // This ensures that:
  2072. // 1. Components are updated from parent to child. (because parent is always
  2073. // created before the child)
  2074. // 2. A component's user watchers are run before its render watcher (because
  2075. // user watchers are created before the render watcher)
  2076. // 3. If a component is destroyed during a parent component's watcher run,
  2077. // its watchers can be skipped.
  2078. queue.sort(function (a, b) { return a.id - b.id; });
  2079. // do not cache length because more watchers might be pushed
  2080. // as we run existing watchers
  2081. for (index = 0; index < queue.length; index++) {
  2082. watcher = queue[index];
  2083. id = watcher.id;
  2084. has[id] = null;
  2085. watcher.run();
  2086. // in dev build, check and stop circular updates.
  2087. if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  2088. circular[id] = (circular[id] || 0) + 1;
  2089. if (circular[id] > config._maxUpdateCount) {
  2090. warn(
  2091. 'You may have an infinite update loop ' + (
  2092. watcher.user
  2093. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  2094. : "in a component render function."
  2095. ),
  2096. watcher.vm
  2097. );
  2098. break
  2099. }
  2100. }
  2101. }
  2102. // call updated hooks
  2103. index = queue.length;
  2104. while (index--) {
  2105. watcher = queue[index];
  2106. vm = watcher.vm;
  2107. if (vm._watcher === watcher && vm._isMounted) {
  2108. callHook(vm, 'updated');
  2109. }
  2110. }
  2111. // devtool hook
  2112. /* istanbul ignore if */
  2113. if (devtools && config.devtools) {
  2114. devtools.emit('flush');
  2115. }
  2116. resetSchedulerState();
  2117. }
  2118. /**
  2119. * Push a watcher into the watcher queue.
  2120. * Jobs with duplicate IDs will be skipped unless it's
  2121. * pushed when the queue is being flushed.
  2122. */
  2123. function queueWatcher (watcher) {
  2124. var id = watcher.id;
  2125. if (has[id] == null) {
  2126. has[id] = true;
  2127. if (!flushing) {
  2128. queue.push(watcher);
  2129. } else {
  2130. // if already flushing, splice the watcher based on its id
  2131. // if already past its id, it will be run next immediately.
  2132. var i = queue.length - 1;
  2133. while (i >= 0 && queue[i].id > watcher.id) {
  2134. i--;
  2135. }
  2136. queue.splice(Math.max(i, index) + 1, 0, watcher);
  2137. }
  2138. // queue the flush
  2139. if (!waiting) {
  2140. waiting = true;
  2141. nextTick(flushSchedulerQueue);
  2142. }
  2143. }
  2144. }
  2145. /* */
  2146. var uid$2 = 0;
  2147. /**
  2148. * A watcher parses an expression, collects dependencies,
  2149. * and fires callback when the expression value changes.
  2150. * This is used for both the $watch() api and directives.
  2151. */
  2152. var Watcher = function Watcher (
  2153. vm,
  2154. expOrFn,
  2155. cb,
  2156. options
  2157. ) {
  2158. this.vm = vm;
  2159. vm._watchers.push(this);
  2160. // options
  2161. if (options) {
  2162. this.deep = !!options.deep;
  2163. this.user = !!options.user;
  2164. this.lazy = !!options.lazy;
  2165. this.sync = !!options.sync;
  2166. } else {
  2167. this.deep = this.user = this.lazy = this.sync = false;
  2168. }
  2169. this.cb = cb;
  2170. this.id = ++uid$2; // uid for batching
  2171. this.active = true;
  2172. this.dirty = this.lazy; // for lazy watchers
  2173. this.deps = [];
  2174. this.newDeps = [];
  2175. this.depIds = new _Set();
  2176. this.newDepIds = new _Set();
  2177. this.expression = process.env.NODE_ENV !== 'production'
  2178. ? expOrFn.toString()
  2179. : '';
  2180. // parse expression for getter
  2181. if (typeof expOrFn === 'function') {
  2182. this.getter = expOrFn;
  2183. } else {
  2184. this.getter = parsePath(expOrFn);
  2185. if (!this.getter) {
  2186. this.getter = function () {};
  2187. process.env.NODE_ENV !== 'production' && warn(
  2188. "Failed watching path: \"" + expOrFn + "\" " +
  2189. 'Watcher only accepts simple dot-delimited paths. ' +
  2190. 'For full control, use a function instead.',
  2191. vm
  2192. );
  2193. }
  2194. }
  2195. this.value = this.lazy
  2196. ? undefined
  2197. : this.get();
  2198. };
  2199. /**
  2200. * Evaluate the getter, and re-collect dependencies.
  2201. */
  2202. Watcher.prototype.get = function get () {
  2203. pushTarget(this);
  2204. var value;
  2205. var vm = this.vm;
  2206. if (this.user) {
  2207. try {
  2208. value = this.getter.call(vm, vm);
  2209. } catch (e) {
  2210. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  2211. }
  2212. } else {
  2213. value = this.getter.call(vm, vm);
  2214. }
  2215. // "touch" every property so they are all tracked as
  2216. // dependencies for deep watching
  2217. if (this.deep) {
  2218. traverse(value);
  2219. }
  2220. popTarget();
  2221. this.cleanupDeps();
  2222. return value
  2223. };
  2224. /**
  2225. * Add a dependency to this directive.
  2226. */
  2227. Watcher.prototype.addDep = function addDep (dep) {
  2228. var id = dep.id;
  2229. if (!this.newDepIds.has(id)) {
  2230. this.newDepIds.add(id);
  2231. this.newDeps.push(dep);
  2232. if (!this.depIds.has(id)) {
  2233. dep.addSub(this);
  2234. }
  2235. }
  2236. };
  2237. /**
  2238. * Clean up for dependency collection.
  2239. */
  2240. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  2241. var this$1 = this;
  2242. var i = this.deps.length;
  2243. while (i--) {
  2244. var dep = this$1.deps[i];
  2245. if (!this$1.newDepIds.has(dep.id)) {
  2246. dep.removeSub(this$1);
  2247. }
  2248. }
  2249. var tmp = this.depIds;
  2250. this.depIds = this.newDepIds;
  2251. this.newDepIds = tmp;
  2252. this.newDepIds.clear();
  2253. tmp = this.deps;
  2254. this.deps = this.newDeps;
  2255. this.newDeps = tmp;
  2256. this.newDeps.length = 0;
  2257. };
  2258. /**
  2259. * Subscriber interface.
  2260. * Will be called when a dependency changes.
  2261. */
  2262. Watcher.prototype.update = function update () {
  2263. /* istanbul ignore else */
  2264. if (this.lazy) {
  2265. this.dirty = true;
  2266. } else if (this.sync) {
  2267. this.run();
  2268. } else {
  2269. queueWatcher(this);
  2270. }
  2271. };
  2272. /**
  2273. * Scheduler job interface.
  2274. * Will be called by the scheduler.
  2275. */
  2276. Watcher.prototype.run = function run () {
  2277. if (this.active) {
  2278. var value = this.get();
  2279. if (
  2280. value !== this.value ||
  2281. // Deep watchers and watchers on Object/Arrays should fire even
  2282. // when the value is the same, because the value may
  2283. // have mutated.
  2284. isObject(value) ||
  2285. this.deep
  2286. ) {
  2287. // set new value
  2288. var oldValue = this.value;
  2289. this.value = value;
  2290. if (this.user) {
  2291. try {
  2292. this.cb.call(this.vm, value, oldValue);
  2293. } catch (e) {
  2294. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  2295. }
  2296. } else {
  2297. this.cb.call(this.vm, value, oldValue);
  2298. }
  2299. }
  2300. }
  2301. };
  2302. /**
  2303. * Evaluate the value of the watcher.
  2304. * This only gets called for lazy watchers.
  2305. */
  2306. Watcher.prototype.evaluate = function evaluate () {
  2307. this.value = this.get();
  2308. this.dirty = false;
  2309. };
  2310. /**
  2311. * Depend on all deps collected by this watcher.
  2312. */
  2313. Watcher.prototype.depend = function depend () {
  2314. var this$1 = this;
  2315. var i = this.deps.length;
  2316. while (i--) {
  2317. this$1.deps[i].depend();
  2318. }
  2319. };
  2320. /**
  2321. * Remove self from all dependencies' subscriber list.
  2322. */
  2323. Watcher.prototype.teardown = function teardown () {
  2324. var this$1 = this;
  2325. if (this.active) {
  2326. // remove self from vm's watcher list
  2327. // this is a somewhat expensive operation so we skip it
  2328. // if the vm is being destroyed.
  2329. if (!this.vm._isBeingDestroyed) {
  2330. remove(this.vm._watchers, this);
  2331. }
  2332. var i = this.deps.length;
  2333. while (i--) {
  2334. this$1.deps[i].removeSub(this$1);
  2335. }
  2336. this.active = false;
  2337. }
  2338. };
  2339. /**
  2340. * Recursively traverse an object to evoke all converted
  2341. * getters, so that every nested property inside the object
  2342. * is collected as a "deep" dependency.
  2343. */
  2344. var seenObjects = new _Set();
  2345. function traverse (val) {
  2346. seenObjects.clear();
  2347. _traverse(val, seenObjects);
  2348. }
  2349. function _traverse (val, seen) {
  2350. var i, keys;
  2351. var isA = Array.isArray(val);
  2352. if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
  2353. return
  2354. }
  2355. if (val.__ob__) {
  2356. var depId = val.__ob__.dep.id;
  2357. if (seen.has(depId)) {
  2358. return
  2359. }
  2360. seen.add(depId);
  2361. }
  2362. if (isA) {
  2363. i = val.length;
  2364. while (i--) { _traverse(val[i], seen); }
  2365. } else {
  2366. keys = Object.keys(val);
  2367. i = keys.length;
  2368. while (i--) { _traverse(val[keys[i]], seen); }
  2369. }
  2370. }
  2371. /* */
  2372. var sharedPropertyDefinition = {
  2373. enumerable: true,
  2374. configurable: true,
  2375. get: noop,
  2376. set: noop
  2377. };
  2378. function proxy (target, sourceKey, key) {
  2379. sharedPropertyDefinition.get = function proxyGetter () {
  2380. return this[sourceKey][key]
  2381. };
  2382. sharedPropertyDefinition.set = function proxySetter (val) {
  2383. this[sourceKey][key] = val;
  2384. };
  2385. Object.defineProperty(target, key, sharedPropertyDefinition);
  2386. }
  2387. function initState (vm) {
  2388. vm._watchers = [];
  2389. var opts = vm.$options;
  2390. if (opts.props) { initProps(vm, opts.props); }
  2391. if (opts.methods) { initMethods(vm, opts.methods); }
  2392. if (opts.data) {
  2393. initData(vm);
  2394. } else {
  2395. observe(vm._data = {}, true /* asRootData */);
  2396. }
  2397. if (opts.computed) { initComputed(vm, opts.computed); }
  2398. if (opts.watch) { initWatch(vm, opts.watch); }
  2399. }
  2400. var isReservedProp = { key: 1, ref: 1, slot: 1 };
  2401. function initProps (vm, propsOptions) {
  2402. var propsData = vm.$options.propsData || {};
  2403. var props = vm._props = {};
  2404. // cache prop keys so that future props updates can iterate using Array
  2405. // instead of dynamic object key enumeration.
  2406. var keys = vm.$options._propKeys = [];
  2407. var isRoot = !vm.$parent;
  2408. // root instance props should be converted
  2409. observerState.shouldConvert = isRoot;
  2410. var loop = function ( key ) {
  2411. keys.push(key);
  2412. var value = validateProp(key, propsOptions, propsData, vm);
  2413. /* istanbul ignore else */
  2414. if (process.env.NODE_ENV !== 'production') {
  2415. if (isReservedProp[key]) {
  2416. warn(
  2417. ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
  2418. vm
  2419. );
  2420. }
  2421. defineReactive$$1(props, key, value, function () {
  2422. if (vm.$parent && !observerState.isSettingProps) {
  2423. warn(
  2424. "Avoid mutating a prop directly since the value will be " +
  2425. "overwritten whenever the parent component re-renders. " +
  2426. "Instead, use a data or computed property based on the prop's " +
  2427. "value. Prop being mutated: \"" + key + "\"",
  2428. vm
  2429. );
  2430. }
  2431. });
  2432. } else {
  2433. defineReactive$$1(props, key, value);
  2434. }
  2435. // static props are already proxied on the component's prototype
  2436. // during Vue.extend(). We only need to proxy props defined at
  2437. // instantiation here.
  2438. if (!(key in vm)) {
  2439. proxy(vm, "_props", key);
  2440. }
  2441. };
  2442. for (var key in propsOptions) loop( key );
  2443. observerState.shouldConvert = true;
  2444. }
  2445. function initData (vm) {
  2446. var data = vm.$options.data;
  2447. data = vm._data = typeof data === 'function'
  2448. ? data.call(vm)
  2449. : data || {};
  2450. if (!isPlainObject(data)) {
  2451. data = {};
  2452. process.env.NODE_ENV !== 'production' && warn(
  2453. 'data functions should return an object:\n' +
  2454. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  2455. vm
  2456. );
  2457. }
  2458. // proxy data on instance
  2459. var keys = Object.keys(data);
  2460. var props = vm.$options.props;
  2461. var i = keys.length;
  2462. while (i--) {
  2463. if (props && hasOwn(props, keys[i])) {
  2464. process.env.NODE_ENV !== 'production' && warn(
  2465. "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
  2466. "Use prop default value instead.",
  2467. vm
  2468. );
  2469. } else if (!isReserved(keys[i])) {
  2470. proxy(vm, "_data", keys[i]);
  2471. }
  2472. }
  2473. // observe data
  2474. observe(data, true /* asRootData */);
  2475. }
  2476. var computedWatcherOptions = { lazy: true };
  2477. function initComputed (vm, computed) {
  2478. var watchers = vm._computedWatchers = Object.create(null);
  2479. for (var key in computed) {
  2480. var userDef = computed[key];
  2481. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  2482. // create internal watcher for the computed property.
  2483. watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
  2484. // component-defined computed properties are already defined on the
  2485. // component prototype. We only need to define computed properties defined
  2486. // at instantiation here.
  2487. if (!(key in vm)) {
  2488. defineComputed(vm, key, userDef);
  2489. }
  2490. }
  2491. }
  2492. function defineComputed (target, key, userDef) {
  2493. if (typeof userDef === 'function') {
  2494. sharedPropertyDefinition.get = createComputedGetter(key);
  2495. sharedPropertyDefinition.set = noop;
  2496. } else {
  2497. sharedPropertyDefinition.get = userDef.get
  2498. ? userDef.cache !== false
  2499. ? createComputedGetter(key)
  2500. : userDef.get
  2501. : noop;
  2502. sharedPropertyDefinition.set = userDef.set
  2503. ? userDef.set
  2504. : noop;
  2505. }
  2506. Object.defineProperty(target, key, sharedPropertyDefinition);
  2507. }
  2508. function createComputedGetter (key) {
  2509. return function computedGetter () {
  2510. var watcher = this._computedWatchers && this._computedWatchers[key];
  2511. if (watcher) {
  2512. if (watcher.dirty) {
  2513. watcher.evaluate();
  2514. }
  2515. if (Dep.target) {
  2516. watcher.depend();
  2517. }
  2518. return watcher.value
  2519. }
  2520. }
  2521. }
  2522. function initMethods (vm, methods) {
  2523. var props = vm.$options.props;
  2524. for (var key in methods) {
  2525. vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
  2526. if (process.env.NODE_ENV !== 'production') {
  2527. if (methods[key] == null) {
  2528. warn(
  2529. "method \"" + key + "\" has an undefined value in the component definition. " +
  2530. "Did you reference the function correctly?",
  2531. vm
  2532. );
  2533. }
  2534. if (props && hasOwn(props, key)) {
  2535. warn(
  2536. ("method \"" + key + "\" has already been defined as a prop."),
  2537. vm
  2538. );
  2539. }
  2540. }
  2541. }
  2542. }
  2543. function initWatch (vm, watch) {
  2544. for (var key in watch) {
  2545. var handler = watch[key];
  2546. if (Array.isArray(handler)) {
  2547. for (var i = 0; i < handler.length; i++) {
  2548. createWatcher(vm, key, handler[i]);
  2549. }
  2550. } else {
  2551. createWatcher(vm, key, handler);
  2552. }
  2553. }
  2554. }
  2555. function createWatcher (vm, key, handler) {
  2556. var options;
  2557. if (isPlainObject(handler)) {
  2558. options = handler;
  2559. handler = handler.handler;
  2560. }
  2561. if (typeof handler === 'string') {
  2562. handler = vm[handler];
  2563. }
  2564. vm.$watch(key, handler, options);
  2565. }
  2566. function stateMixin (Vue) {
  2567. // flow somehow has problems with directly declared definition object
  2568. // when using Object.defineProperty, so we have to procedurally build up
  2569. // the object here.
  2570. var dataDef = {};
  2571. dataDef.get = function () { return this._data };
  2572. var propsDef = {};
  2573. propsDef.get = function () { return this._props };
  2574. if (process.env.NODE_ENV !== 'production') {
  2575. dataDef.set = function (newData) {
  2576. warn(
  2577. 'Avoid replacing instance root $data. ' +
  2578. 'Use nested data properties instead.',
  2579. this
  2580. );
  2581. };
  2582. propsDef.set = function () {
  2583. warn("$props is readonly.", this);
  2584. };
  2585. }
  2586. Object.defineProperty(Vue.prototype, '$data', dataDef);
  2587. Object.defineProperty(Vue.prototype, '$props', propsDef);
  2588. Vue.prototype.$set = set;
  2589. Vue.prototype.$delete = del;
  2590. Vue.prototype.$watch = function (
  2591. expOrFn,
  2592. cb,
  2593. options
  2594. ) {
  2595. var vm = this;
  2596. options = options || {};
  2597. options.user = true;
  2598. var watcher = new Watcher(vm, expOrFn, cb, options);
  2599. if (options.immediate) {
  2600. cb.call(vm, watcher.value);
  2601. }
  2602. return function unwatchFn () {
  2603. watcher.teardown();
  2604. }
  2605. };
  2606. }
  2607. /* */
  2608. var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
  2609. var hooksToMerge = Object.keys(hooks);
  2610. function createComponent (
  2611. Ctor,
  2612. data,
  2613. context,
  2614. children,
  2615. tag
  2616. ) {
  2617. if (!Ctor) {
  2618. return
  2619. }
  2620. var baseCtor = context.$options._base;
  2621. if (isObject(Ctor)) {
  2622. Ctor = baseCtor.extend(Ctor);
  2623. }
  2624. if (typeof Ctor !== 'function') {
  2625. if (process.env.NODE_ENV !== 'production') {
  2626. warn(("Invalid Component definition: " + (String(Ctor))), context);
  2627. }
  2628. return
  2629. }
  2630. // async component
  2631. if (!Ctor.cid) {
  2632. if (Ctor.resolved) {
  2633. Ctor = Ctor.resolved;
  2634. } else {
  2635. Ctor = resolveAsyncComponent(Ctor, baseCtor, function () {
  2636. // it's ok to queue this on every render because
  2637. // $forceUpdate is buffered by the scheduler.
  2638. context.$forceUpdate();
  2639. });
  2640. if (!Ctor) {
  2641. // return nothing if this is indeed an async component
  2642. // wait for the callback to trigger parent update.
  2643. return
  2644. }
  2645. }
  2646. }
  2647. // resolve constructor options in case global mixins are applied after
  2648. // component constructor creation
  2649. resolveConstructorOptions(Ctor);
  2650. data = data || {};
  2651. // transform component v-model data into props & events
  2652. if (data.model) {
  2653. transformModel(Ctor.options, data);
  2654. }
  2655. // extract props
  2656. var propsData = extractProps(data, Ctor);
  2657. // functional component
  2658. if (Ctor.options.functional) {
  2659. return createFunctionalComponent(Ctor, propsData, data, context, children)
  2660. }
  2661. // extract listeners, since these needs to be treated as
  2662. // child component listeners instead of DOM listeners
  2663. var listeners = data.on;
  2664. // replace with listeners with .native modifier
  2665. data.on = data.nativeOn;
  2666. if (Ctor.options.abstract) {
  2667. // abstract components do not keep anything
  2668. // other than props & listeners
  2669. data = {};
  2670. }
  2671. // merge component management hooks onto the placeholder node
  2672. mergeHooks(data);
  2673. // return a placeholder vnode
  2674. var name = Ctor.options.name || tag;
  2675. var vnode = new VNode(
  2676. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  2677. data, undefined, undefined, undefined, context,
  2678. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
  2679. );
  2680. return vnode
  2681. }
  2682. function createFunctionalComponent (
  2683. Ctor,
  2684. propsData,
  2685. data,
  2686. context,
  2687. children
  2688. ) {
  2689. var props = {};
  2690. var propOptions = Ctor.options.props;
  2691. if (propOptions) {
  2692. for (var key in propOptions) {
  2693. props[key] = validateProp(key, propOptions, propsData);
  2694. }
  2695. }
  2696. // ensure the createElement function in functional components
  2697. // gets a unique context - this is necessary for correct named slot check
  2698. var _context = Object.create(context);
  2699. var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
  2700. var vnode = Ctor.options.render.call(null, h, {
  2701. props: props,
  2702. data: data,
  2703. parent: context,
  2704. children: children,
  2705. slots: function () { return resolveSlots(children, context); }
  2706. });
  2707. if (vnode instanceof VNode) {
  2708. vnode.functionalContext = context;
  2709. if (data.slot) {
  2710. (vnode.data || (vnode.data = {})).slot = data.slot;
  2711. }
  2712. }
  2713. return vnode
  2714. }
  2715. function createComponentInstanceForVnode (
  2716. vnode, // we know it's MountedComponentVNode but flow doesn't
  2717. parent, // activeInstance in lifecycle state
  2718. parentElm,
  2719. refElm
  2720. ) {
  2721. var vnodeComponentOptions = vnode.componentOptions;
  2722. var options = {
  2723. _isComponent: true,
  2724. parent: parent,
  2725. propsData: vnodeComponentOptions.propsData,
  2726. _componentTag: vnodeComponentOptions.tag,
  2727. _parentVnode: vnode,
  2728. _parentListeners: vnodeComponentOptions.listeners,
  2729. _renderChildren: vnodeComponentOptions.children,
  2730. _parentElm: parentElm || null,
  2731. _refElm: refElm || null
  2732. };
  2733. // check inline-template render functions
  2734. var inlineTemplate = vnode.data.inlineTemplate;
  2735. if (inlineTemplate) {
  2736. options.render = inlineTemplate.render;
  2737. options.staticRenderFns = inlineTemplate.staticRenderFns;
  2738. }
  2739. return new vnodeComponentOptions.Ctor(options)
  2740. }
  2741. function init (
  2742. vnode,
  2743. hydrating,
  2744. parentElm,
  2745. refElm
  2746. ) {
  2747. if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
  2748. var child = vnode.componentInstance = createComponentInstanceForVnode(
  2749. vnode,
  2750. activeInstance,
  2751. parentElm,
  2752. refElm
  2753. );
  2754. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  2755. } else if (vnode.data.keepAlive) {
  2756. // kept-alive components, treat as a patch
  2757. var mountedNode = vnode; // work around flow
  2758. prepatch(mountedNode, mountedNode);
  2759. }
  2760. }
  2761. function prepatch (
  2762. oldVnode,
  2763. vnode
  2764. ) {
  2765. var options = vnode.componentOptions;
  2766. var child = vnode.componentInstance = oldVnode.componentInstance;
  2767. updateChildComponent(
  2768. child,
  2769. options.propsData, // updated props
  2770. options.listeners, // updated listeners
  2771. vnode, // new parent vnode
  2772. options.children // new children
  2773. );
  2774. }
  2775. function insert (vnode) {
  2776. if (!vnode.componentInstance._isMounted) {
  2777. vnode.componentInstance._isMounted = true;
  2778. callHook(vnode.componentInstance, 'mounted');
  2779. }
  2780. if (vnode.data.keepAlive) {
  2781. activateChildComponent(vnode.componentInstance, true /* direct */);
  2782. }
  2783. }
  2784. function destroy (vnode) {
  2785. if (!vnode.componentInstance._isDestroyed) {
  2786. if (!vnode.data.keepAlive) {
  2787. vnode.componentInstance.$destroy();
  2788. } else {
  2789. deactivateChildComponent(vnode.componentInstance, true /* direct */);
  2790. }
  2791. }
  2792. }
  2793. function resolveAsyncComponent (
  2794. factory,
  2795. baseCtor,
  2796. cb
  2797. ) {
  2798. if (factory.requested) {
  2799. // pool callbacks
  2800. factory.pendingCallbacks.push(cb);
  2801. } else {
  2802. factory.requested = true;
  2803. var cbs = factory.pendingCallbacks = [cb];
  2804. var sync = true;
  2805. var resolve = function (res) {
  2806. if (isObject(res)) {
  2807. res = baseCtor.extend(res);
  2808. }
  2809. // cache resolved
  2810. factory.resolved = res;
  2811. // invoke callbacks only if this is not a synchronous resolve
  2812. // (async resolves are shimmed as synchronous during SSR)
  2813. if (!sync) {
  2814. for (var i = 0, l = cbs.length; i < l; i++) {
  2815. cbs[i](res);
  2816. }
  2817. }
  2818. };
  2819. var reject = function (reason) {
  2820. process.env.NODE_ENV !== 'production' && warn(
  2821. "Failed to resolve async component: " + (String(factory)) +
  2822. (reason ? ("\nReason: " + reason) : '')
  2823. );
  2824. };
  2825. var res = factory(resolve, reject);
  2826. // handle promise
  2827. if (res && typeof res.then === 'function' && !factory.resolved) {
  2828. res.then(resolve, reject);
  2829. }
  2830. sync = false;
  2831. // return in case resolved synchronously
  2832. return factory.resolved
  2833. }
  2834. }
  2835. function extractProps (data, Ctor) {
  2836. // we are only extracting raw values here.
  2837. // validation and default values are handled in the child
  2838. // component itself.
  2839. var propOptions = Ctor.options.props;
  2840. if (!propOptions) {
  2841. return
  2842. }
  2843. var res = {};
  2844. var attrs = data.attrs;
  2845. var props = data.props;
  2846. var domProps = data.domProps;
  2847. if (attrs || props || domProps) {
  2848. for (var key in propOptions) {
  2849. var altKey = hyphenate(key);
  2850. checkProp(res, props, key, altKey, true) ||
  2851. checkProp(res, attrs, key, altKey) ||
  2852. checkProp(res, domProps, key, altKey);
  2853. }
  2854. }
  2855. return res
  2856. }
  2857. function checkProp (
  2858. res,
  2859. hash,
  2860. key,
  2861. altKey,
  2862. preserve
  2863. ) {
  2864. if (hash) {
  2865. if (hasOwn(hash, key)) {
  2866. res[key] = hash[key];
  2867. if (!preserve) {
  2868. delete hash[key];
  2869. }
  2870. return true
  2871. } else if (hasOwn(hash, altKey)) {
  2872. res[key] = hash[altKey];
  2873. if (!preserve) {
  2874. delete hash[altKey];
  2875. }
  2876. return true
  2877. }
  2878. }
  2879. return false
  2880. }
  2881. function mergeHooks (data) {
  2882. if (!data.hook) {
  2883. data.hook = {};
  2884. }
  2885. for (var i = 0; i < hooksToMerge.length; i++) {
  2886. var key = hooksToMerge[i];
  2887. var fromParent = data.hook[key];
  2888. var ours = hooks[key];
  2889. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  2890. }
  2891. }
  2892. function mergeHook$1 (one, two) {
  2893. return function (a, b, c, d) {
  2894. one(a, b, c, d);
  2895. two(a, b, c, d);
  2896. }
  2897. }
  2898. // transform component v-model info (value and callback) into
  2899. // prop and event handler respectively.
  2900. function transformModel (options, data) {
  2901. var prop = (options.model && options.model.prop) || 'value';
  2902. var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
  2903. var on = data.on || (data.on = {});
  2904. if (on[event]) {
  2905. on[event] = [data.model.callback].concat(on[event]);
  2906. } else {
  2907. on[event] = data.model.callback;
  2908. }
  2909. }
  2910. /* */
  2911. var SIMPLE_NORMALIZE = 1;
  2912. var ALWAYS_NORMALIZE = 2;
  2913. // wrapper function for providing a more flexible interface
  2914. // without getting yelled at by flow
  2915. function createElement (
  2916. context,
  2917. tag,
  2918. data,
  2919. children,
  2920. normalizationType,
  2921. alwaysNormalize
  2922. ) {
  2923. if (Array.isArray(data) || isPrimitive(data)) {
  2924. normalizationType = children;
  2925. children = data;
  2926. data = undefined;
  2927. }
  2928. if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
  2929. return _createElement(context, tag, data, children, normalizationType)
  2930. }
  2931. function _createElement (
  2932. context,
  2933. tag,
  2934. data,
  2935. children,
  2936. normalizationType
  2937. ) {
  2938. if (data && data.__ob__) {
  2939. process.env.NODE_ENV !== 'production' && warn(
  2940. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  2941. 'Always create fresh vnode data objects in each render!',
  2942. context
  2943. );
  2944. return createEmptyVNode()
  2945. }
  2946. if (!tag) {
  2947. // in case of component :is set to falsy value
  2948. return createEmptyVNode()
  2949. }
  2950. // support single function children as default scoped slot
  2951. if (Array.isArray(children) &&
  2952. typeof children[0] === 'function') {
  2953. data = data || {};
  2954. data.scopedSlots = { default: children[0] };
  2955. children.length = 0;
  2956. }
  2957. if (normalizationType === ALWAYS_NORMALIZE) {
  2958. children = normalizeChildren(children);
  2959. } else if (normalizationType === SIMPLE_NORMALIZE) {
  2960. children = simpleNormalizeChildren(children);
  2961. }
  2962. var vnode, ns;
  2963. if (typeof tag === 'string') {
  2964. var Ctor;
  2965. ns = config.getTagNamespace(tag);
  2966. if (config.isReservedTag(tag)) {
  2967. // platform built-in elements
  2968. vnode = new VNode(
  2969. config.parsePlatformTagName(tag), data, children,
  2970. undefined, undefined, context
  2971. );
  2972. } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
  2973. // component
  2974. vnode = createComponent(Ctor, data, context, children, tag);
  2975. } else {
  2976. // unknown or unlisted namespaced elements
  2977. // check at runtime because it may get assigned a namespace when its
  2978. // parent normalizes children
  2979. vnode = new VNode(
  2980. tag, data, children,
  2981. undefined, undefined, context
  2982. );
  2983. }
  2984. } else {
  2985. // direct component options / constructor
  2986. vnode = createComponent(tag, data, context, children);
  2987. }
  2988. if (vnode) {
  2989. if (ns) { applyNS(vnode, ns); }
  2990. return vnode
  2991. } else {
  2992. return createEmptyVNode()
  2993. }
  2994. }
  2995. function applyNS (vnode, ns) {
  2996. vnode.ns = ns;
  2997. if (vnode.tag === 'foreignObject') {
  2998. // use default namespace inside foreignObject
  2999. return
  3000. }
  3001. if (vnode.children) {
  3002. for (var i = 0, l = vnode.children.length; i < l; i++) {
  3003. var child = vnode.children[i];
  3004. if (child.tag && !child.ns) {
  3005. applyNS(child, ns);
  3006. }
  3007. }
  3008. }
  3009. }
  3010. /* */
  3011. /**
  3012. * Runtime helper for rendering v-for lists.
  3013. */
  3014. function renderList (
  3015. val,
  3016. render
  3017. ) {
  3018. var ret, i, l, keys, key;
  3019. if (Array.isArray(val) || typeof val === 'string') {
  3020. ret = new Array(val.length);
  3021. for (i = 0, l = val.length; i < l; i++) {
  3022. ret[i] = render(val[i], i);
  3023. }
  3024. } else if (typeof val === 'number') {
  3025. ret = new Array(val);
  3026. for (i = 0; i < val; i++) {
  3027. ret[i] = render(i + 1, i);
  3028. }
  3029. } else if (isObject(val)) {
  3030. keys = Object.keys(val);
  3031. ret = new Array(keys.length);
  3032. for (i = 0, l = keys.length; i < l; i++) {
  3033. key = keys[i];
  3034. ret[i] = render(val[key], key, i);
  3035. }
  3036. }
  3037. return ret
  3038. }
  3039. /* */
  3040. /**
  3041. * Runtime helper for rendering <slot>
  3042. */
  3043. function renderSlot (
  3044. name,
  3045. fallback,
  3046. props,
  3047. bindObject
  3048. ) {
  3049. var scopedSlotFn = this.$scopedSlots[name];
  3050. if (scopedSlotFn) { // scoped slot
  3051. props = props || {};
  3052. if (bindObject) {
  3053. extend(props, bindObject);
  3054. }
  3055. return scopedSlotFn(props) || fallback
  3056. } else {
  3057. var slotNodes = this.$slots[name];
  3058. // warn duplicate slot usage
  3059. if (slotNodes && process.env.NODE_ENV !== 'production') {
  3060. slotNodes._rendered && warn(
  3061. "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
  3062. "- this will likely cause render errors.",
  3063. this
  3064. );
  3065. slotNodes._rendered = true;
  3066. }
  3067. return slotNodes || fallback
  3068. }
  3069. }
  3070. /* */
  3071. /**
  3072. * Runtime helper for resolving filters
  3073. */
  3074. function resolveFilter (id) {
  3075. return resolveAsset(this.$options, 'filters', id, true) || identity
  3076. }
  3077. /* */
  3078. /**
  3079. * Runtime helper for checking keyCodes from config.
  3080. */
  3081. function checkKeyCodes (
  3082. eventKeyCode,
  3083. key,
  3084. builtInAlias
  3085. ) {
  3086. var keyCodes = config.keyCodes[key] || builtInAlias;
  3087. if (Array.isArray(keyCodes)) {
  3088. return keyCodes.indexOf(eventKeyCode) === -1
  3089. } else {
  3090. return keyCodes !== eventKeyCode
  3091. }
  3092. }
  3093. /* */
  3094. /**
  3095. * Runtime helper for merging v-bind="object" into a VNode's data.
  3096. */
  3097. function bindObjectProps (
  3098. data,
  3099. tag,
  3100. value,
  3101. asProp
  3102. ) {
  3103. if (value) {
  3104. if (!isObject(value)) {
  3105. process.env.NODE_ENV !== 'production' && warn(
  3106. 'v-bind without argument expects an Object or Array value',
  3107. this
  3108. );
  3109. } else {
  3110. if (Array.isArray(value)) {
  3111. value = toObject(value);
  3112. }
  3113. for (var key in value) {
  3114. if (key === 'class' || key === 'style') {
  3115. data[key] = value[key];
  3116. } else {
  3117. var type = data.attrs && data.attrs.type;
  3118. var hash = asProp || config.mustUseProp(tag, type, key)
  3119. ? data.domProps || (data.domProps = {})
  3120. : data.attrs || (data.attrs = {});
  3121. hash[key] = value[key];
  3122. }
  3123. }
  3124. }
  3125. }
  3126. return data
  3127. }
  3128. /* */
  3129. /**
  3130. * Runtime helper for rendering static trees.
  3131. */
  3132. function renderStatic (
  3133. index,
  3134. isInFor
  3135. ) {
  3136. var tree = this._staticTrees[index];
  3137. // if has already-rendered static tree and not inside v-for,
  3138. // we can reuse the same tree by doing a shallow clone.
  3139. if (tree && !isInFor) {
  3140. return Array.isArray(tree)
  3141. ? cloneVNodes(tree)
  3142. : cloneVNode(tree)
  3143. }
  3144. // otherwise, render a fresh tree.
  3145. tree = this._staticTrees[index] =
  3146. this.$options.staticRenderFns[index].call(this._renderProxy);
  3147. markStatic(tree, ("__static__" + index), false);
  3148. return tree
  3149. }
  3150. /**
  3151. * Runtime helper for v-once.
  3152. * Effectively it means marking the node as static with a unique key.
  3153. */
  3154. function markOnce (
  3155. tree,
  3156. index,
  3157. key
  3158. ) {
  3159. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  3160. return tree
  3161. }
  3162. function markStatic (
  3163. tree,
  3164. key,
  3165. isOnce
  3166. ) {
  3167. if (Array.isArray(tree)) {
  3168. for (var i = 0; i < tree.length; i++) {
  3169. if (tree[i] && typeof tree[i] !== 'string') {
  3170. markStaticNode(tree[i], (key + "_" + i), isOnce);
  3171. }
  3172. }
  3173. } else {
  3174. markStaticNode(tree, key, isOnce);
  3175. }
  3176. }
  3177. function markStaticNode (node, key, isOnce) {
  3178. node.isStatic = true;
  3179. node.key = key;
  3180. node.isOnce = isOnce;
  3181. }
  3182. /* */
  3183. function initRender (vm) {
  3184. vm.$vnode = null; // the placeholder node in parent tree
  3185. vm._vnode = null; // the root of the child tree
  3186. vm._staticTrees = null;
  3187. var parentVnode = vm.$options._parentVnode;
  3188. var renderContext = parentVnode && parentVnode.context;
  3189. vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
  3190. vm.$scopedSlots = emptyObject;
  3191. // bind the createElement fn to this instance
  3192. // so that we get proper render context inside it.
  3193. // args order: tag, data, children, normalizationType, alwaysNormalize
  3194. // internal version is used by render functions compiled from templates
  3195. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  3196. // normalization is always applied for the public version, used in
  3197. // user-written render functions.
  3198. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  3199. }
  3200. function renderMixin (Vue) {
  3201. Vue.prototype.$nextTick = function (fn) {
  3202. return nextTick(fn, this)
  3203. };
  3204. Vue.prototype._render = function () {
  3205. var vm = this;
  3206. var ref = vm.$options;
  3207. var render = ref.render;
  3208. var staticRenderFns = ref.staticRenderFns;
  3209. var _parentVnode = ref._parentVnode;
  3210. if (vm._isMounted) {
  3211. // clone slot nodes on re-renders
  3212. for (var key in vm.$slots) {
  3213. vm.$slots[key] = cloneVNodes(vm.$slots[key]);
  3214. }
  3215. }
  3216. vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
  3217. if (staticRenderFns && !vm._staticTrees) {
  3218. vm._staticTrees = [];
  3219. }
  3220. // set parent vnode. this allows render functions to have access
  3221. // to the data on the placeholder node.
  3222. vm.$vnode = _parentVnode;
  3223. // render self
  3224. var vnode;
  3225. try {
  3226. vnode = render.call(vm._renderProxy, vm.$createElement);
  3227. } catch (e) {
  3228. handleError(e, vm, "render function");
  3229. // return error render result,
  3230. // or previous vnode to prevent render error causing blank component
  3231. /* istanbul ignore else */
  3232. if (process.env.NODE_ENV !== 'production') {
  3233. vnode = vm.$options.renderError
  3234. ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
  3235. : vm._vnode;
  3236. } else {
  3237. vnode = vm._vnode;
  3238. }
  3239. }
  3240. // return empty vnode in case the render function errored out
  3241. if (!(vnode instanceof VNode)) {
  3242. if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
  3243. warn(
  3244. 'Multiple root nodes returned from render function. Render function ' +
  3245. 'should return a single root node.',
  3246. vm
  3247. );
  3248. }
  3249. vnode = createEmptyVNode();
  3250. }
  3251. // set parent
  3252. vnode.parent = _parentVnode;
  3253. return vnode
  3254. };
  3255. // internal render helpers.
  3256. // these are exposed on the instance prototype to reduce generated render
  3257. // code size.
  3258. Vue.prototype._o = markOnce;
  3259. Vue.prototype._n = toNumber;
  3260. Vue.prototype._s = _toString;
  3261. Vue.prototype._l = renderList;
  3262. Vue.prototype._t = renderSlot;
  3263. Vue.prototype._q = looseEqual;
  3264. Vue.prototype._i = looseIndexOf;
  3265. Vue.prototype._m = renderStatic;
  3266. Vue.prototype._f = resolveFilter;
  3267. Vue.prototype._k = checkKeyCodes;
  3268. Vue.prototype._b = bindObjectProps;
  3269. Vue.prototype._v = createTextVNode;
  3270. Vue.prototype._e = createEmptyVNode;
  3271. Vue.prototype._u = resolveScopedSlots;
  3272. }
  3273. /* */
  3274. function initProvide (vm) {
  3275. var provide = vm.$options.provide;
  3276. if (provide) {
  3277. vm._provided = typeof provide === 'function'
  3278. ? provide.call(vm)
  3279. : provide;
  3280. }
  3281. }
  3282. function initInjections (vm) {
  3283. var inject = vm.$options.inject;
  3284. if (inject) {
  3285. // inject is :any because flow is not smart enough to figure out cached
  3286. // isArray here
  3287. var isArray = Array.isArray(inject);
  3288. var keys = isArray
  3289. ? inject
  3290. : hasSymbol
  3291. ? Reflect.ownKeys(inject)
  3292. : Object.keys(inject);
  3293. for (var i = 0; i < keys.length; i++) {
  3294. var key = keys[i];
  3295. var provideKey = isArray ? key : inject[key];
  3296. var source = vm;
  3297. while (source) {
  3298. if (source._provided && provideKey in source._provided) {
  3299. vm[key] = source._provided[provideKey];
  3300. break
  3301. }
  3302. source = source.$parent;
  3303. }
  3304. }
  3305. }
  3306. }
  3307. /* */
  3308. var uid = 0;
  3309. function initMixin (Vue) {
  3310. Vue.prototype._init = function (options) {
  3311. /* istanbul ignore if */
  3312. if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
  3313. perf.mark('init');
  3314. }
  3315. var vm = this;
  3316. // a uid
  3317. vm._uid = uid++;
  3318. // a flag to avoid this being observed
  3319. vm._isVue = true;
  3320. // merge options
  3321. if (options && options._isComponent) {
  3322. // optimize internal component instantiation
  3323. // since dynamic options merging is pretty slow, and none of the
  3324. // internal component options needs special treatment.
  3325. initInternalComponent(vm, options);
  3326. } else {
  3327. vm.$options = mergeOptions(
  3328. resolveConstructorOptions(vm.constructor),
  3329. options || {},
  3330. vm
  3331. );
  3332. }
  3333. /* istanbul ignore else */
  3334. if (process.env.NODE_ENV !== 'production') {
  3335. initProxy(vm);
  3336. } else {
  3337. vm._renderProxy = vm;
  3338. }
  3339. // expose real self
  3340. vm._self = vm;
  3341. initLifecycle(vm);
  3342. initEvents(vm);
  3343. initRender(vm);
  3344. callHook(vm, 'beforeCreate');
  3345. initInjections(vm); // resolve injections before data/props
  3346. initState(vm);
  3347. initProvide(vm); // resolve provide after data/props
  3348. callHook(vm, 'created');
  3349. /* istanbul ignore if */
  3350. if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
  3351. vm._name = formatComponentName(vm, false);
  3352. perf.mark('init end');
  3353. perf.measure(((vm._name) + " init"), 'init', 'init end');
  3354. }
  3355. if (vm.$options.el) {
  3356. vm.$mount(vm.$options.el);
  3357. }
  3358. };
  3359. }
  3360. function initInternalComponent (vm, options) {
  3361. var opts = vm.$options = Object.create(vm.constructor.options);
  3362. // doing this because it's faster than dynamic enumeration.
  3363. opts.parent = options.parent;
  3364. opts.propsData = options.propsData;
  3365. opts._parentVnode = options._parentVnode;
  3366. opts._parentListeners = options._parentListeners;
  3367. opts._renderChildren = options._renderChildren;
  3368. opts._componentTag = options._componentTag;
  3369. opts._parentElm = options._parentElm;
  3370. opts._refElm = options._refElm;
  3371. if (options.render) {
  3372. opts.render = options.render;
  3373. opts.staticRenderFns = options.staticRenderFns;
  3374. }
  3375. }
  3376. function resolveConstructorOptions (Ctor) {
  3377. var options = Ctor.options;
  3378. if (Ctor.super) {
  3379. var superOptions = resolveConstructorOptions(Ctor.super);
  3380. var cachedSuperOptions = Ctor.superOptions;
  3381. if (superOptions !== cachedSuperOptions) {
  3382. // super option changed,
  3383. // need to resolve new options.
  3384. Ctor.superOptions = superOptions;
  3385. // check if there are any late-modified/attached options (#4976)
  3386. var modifiedOptions = resolveModifiedOptions(Ctor);
  3387. // update base extend options
  3388. if (modifiedOptions) {
  3389. extend(Ctor.extendOptions, modifiedOptions);
  3390. }
  3391. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  3392. if (options.name) {
  3393. options.components[options.name] = Ctor;
  3394. }
  3395. }
  3396. }
  3397. return options
  3398. }
  3399. function resolveModifiedOptions (Ctor) {
  3400. var modified;
  3401. var latest = Ctor.options;
  3402. var sealed = Ctor.sealedOptions;
  3403. for (var key in latest) {
  3404. if (latest[key] !== sealed[key]) {
  3405. if (!modified) { modified = {}; }
  3406. modified[key] = dedupe(latest[key], sealed[key]);
  3407. }
  3408. }
  3409. return modified
  3410. }
  3411. function dedupe (latest, sealed) {
  3412. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  3413. // between merges
  3414. if (Array.isArray(latest)) {
  3415. var res = [];
  3416. sealed = Array.isArray(sealed) ? sealed : [sealed];
  3417. for (var i = 0; i < latest.length; i++) {
  3418. if (sealed.indexOf(latest[i]) < 0) {
  3419. res.push(latest[i]);
  3420. }
  3421. }
  3422. return res
  3423. } else {
  3424. return latest
  3425. }
  3426. }
  3427. function Vue$2 (options) {
  3428. if (process.env.NODE_ENV !== 'production' &&
  3429. !(this instanceof Vue$2)) {
  3430. warn('Vue is a constructor and should be called with the `new` keyword');
  3431. }
  3432. this._init(options);
  3433. }
  3434. initMixin(Vue$2);
  3435. stateMixin(Vue$2);
  3436. eventsMixin(Vue$2);
  3437. lifecycleMixin(Vue$2);
  3438. renderMixin(Vue$2);
  3439. /* */
  3440. function initUse (Vue) {
  3441. Vue.use = function (plugin) {
  3442. /* istanbul ignore if */
  3443. if (plugin.installed) {
  3444. return
  3445. }
  3446. // additional parameters
  3447. var args = toArray(arguments, 1);
  3448. args.unshift(this);
  3449. if (typeof plugin.install === 'function') {
  3450. plugin.install.apply(plugin, args);
  3451. } else if (typeof plugin === 'function') {
  3452. plugin.apply(null, args);
  3453. }
  3454. plugin.installed = true;
  3455. return this
  3456. };
  3457. }
  3458. /* */
  3459. function initMixin$1 (Vue) {
  3460. Vue.mixin = function (mixin) {
  3461. this.options = mergeOptions(this.options, mixin);
  3462. };
  3463. }
  3464. /* */
  3465. function initExtend (Vue) {
  3466. /**
  3467. * Each instance constructor, including Vue, has a unique
  3468. * cid. This enables us to create wrapped "child
  3469. * constructors" for prototypal inheritance and cache them.
  3470. */
  3471. Vue.cid = 0;
  3472. var cid = 1;
  3473. /**
  3474. * Class inheritance
  3475. */
  3476. Vue.extend = function (extendOptions) {
  3477. extendOptions = extendOptions || {};
  3478. var Super = this;
  3479. var SuperId = Super.cid;
  3480. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  3481. if (cachedCtors[SuperId]) {
  3482. return cachedCtors[SuperId]
  3483. }
  3484. var name = extendOptions.name || Super.options.name;
  3485. if (process.env.NODE_ENV !== 'production') {
  3486. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  3487. warn(
  3488. 'Invalid component name: "' + name + '". Component names ' +
  3489. 'can only contain alphanumeric characters and the hyphen, ' +
  3490. 'and must start with a letter.'
  3491. );
  3492. }
  3493. }
  3494. var Sub = function VueComponent (options) {
  3495. this._init(options);
  3496. };
  3497. Sub.prototype = Object.create(Super.prototype);
  3498. Sub.prototype.constructor = Sub;
  3499. Sub.cid = cid++;
  3500. Sub.options = mergeOptions(
  3501. Super.options,
  3502. extendOptions
  3503. );
  3504. Sub['super'] = Super;
  3505. // For props and computed properties, we define the proxy getters on
  3506. // the Vue instances at extension time, on the extended prototype. This
  3507. // avoids Object.defineProperty calls for each instance created.
  3508. if (Sub.options.props) {
  3509. initProps$1(Sub);
  3510. }
  3511. if (Sub.options.computed) {
  3512. initComputed$1(Sub);
  3513. }
  3514. // allow further extension/mixin/plugin usage
  3515. Sub.extend = Super.extend;
  3516. Sub.mixin = Super.mixin;
  3517. Sub.use = Super.use;
  3518. // create asset registers, so extended classes
  3519. // can have their private assets too.
  3520. config._assetTypes.forEach(function (type) {
  3521. Sub[type] = Super[type];
  3522. });
  3523. // enable recursive self-lookup
  3524. if (name) {
  3525. Sub.options.components[name] = Sub;
  3526. }
  3527. // keep a reference to the super options at extension time.
  3528. // later at instantiation we can check if Super's options have
  3529. // been updated.
  3530. Sub.superOptions = Super.options;
  3531. Sub.extendOptions = extendOptions;
  3532. Sub.sealedOptions = extend({}, Sub.options);
  3533. // cache constructor
  3534. cachedCtors[SuperId] = Sub;
  3535. return Sub
  3536. };
  3537. }
  3538. function initProps$1 (Comp) {
  3539. var props = Comp.options.props;
  3540. for (var key in props) {
  3541. proxy(Comp.prototype, "_props", key);
  3542. }
  3543. }
  3544. function initComputed$1 (Comp) {
  3545. var computed = Comp.options.computed;
  3546. for (var key in computed) {
  3547. defineComputed(Comp.prototype, key, computed[key]);
  3548. }
  3549. }
  3550. /* */
  3551. function initAssetRegisters (Vue) {
  3552. /**
  3553. * Create asset registration methods.
  3554. */
  3555. config._assetTypes.forEach(function (type) {
  3556. Vue[type] = function (
  3557. id,
  3558. definition
  3559. ) {
  3560. if (!definition) {
  3561. return this.options[type + 's'][id]
  3562. } else {
  3563. /* istanbul ignore if */
  3564. if (process.env.NODE_ENV !== 'production') {
  3565. if (type === 'component' && config.isReservedTag(id)) {
  3566. warn(
  3567. 'Do not use built-in or reserved HTML elements as component ' +
  3568. 'id: ' + id
  3569. );
  3570. }
  3571. }
  3572. if (type === 'component' && isPlainObject(definition)) {
  3573. definition.name = definition.name || id;
  3574. definition = this.options._base.extend(definition);
  3575. }
  3576. if (type === 'directive' && typeof definition === 'function') {
  3577. definition = { bind: definition, update: definition };
  3578. }
  3579. this.options[type + 's'][id] = definition;
  3580. return definition
  3581. }
  3582. };
  3583. });
  3584. }
  3585. /* */
  3586. var patternTypes = [String, RegExp];
  3587. function getComponentName (opts) {
  3588. return opts && (opts.Ctor.options.name || opts.tag)
  3589. }
  3590. function matches (pattern, name) {
  3591. if (typeof pattern === 'string') {
  3592. return pattern.split(',').indexOf(name) > -1
  3593. } else if (pattern instanceof RegExp) {
  3594. return pattern.test(name)
  3595. }
  3596. /* istanbul ignore next */
  3597. return false
  3598. }
  3599. function pruneCache (cache, filter) {
  3600. for (var key in cache) {
  3601. var cachedNode = cache[key];
  3602. if (cachedNode) {
  3603. var name = getComponentName(cachedNode.componentOptions);
  3604. if (name && !filter(name)) {
  3605. pruneCacheEntry(cachedNode);
  3606. cache[key] = null;
  3607. }
  3608. }
  3609. }
  3610. }
  3611. function pruneCacheEntry (vnode) {
  3612. if (vnode) {
  3613. if (!vnode.componentInstance._inactive) {
  3614. callHook(vnode.componentInstance, 'deactivated');
  3615. }
  3616. vnode.componentInstance.$destroy();
  3617. }
  3618. }
  3619. var KeepAlive = {
  3620. name: 'keep-alive',
  3621. abstract: true,
  3622. props: {
  3623. include: patternTypes,
  3624. exclude: patternTypes
  3625. },
  3626. created: function created () {
  3627. this.cache = Object.create(null);
  3628. },
  3629. destroyed: function destroyed () {
  3630. var this$1 = this;
  3631. for (var key in this$1.cache) {
  3632. pruneCacheEntry(this$1.cache[key]);
  3633. }
  3634. },
  3635. watch: {
  3636. include: function include (val) {
  3637. pruneCache(this.cache, function (name) { return matches(val, name); });
  3638. },
  3639. exclude: function exclude (val) {
  3640. pruneCache(this.cache, function (name) { return !matches(val, name); });
  3641. }
  3642. },
  3643. render: function render () {
  3644. var vnode = getFirstComponentChild(this.$slots.default);
  3645. var componentOptions = vnode && vnode.componentOptions;
  3646. if (componentOptions) {
  3647. // check pattern
  3648. var name = getComponentName(componentOptions);
  3649. if (name && (
  3650. (this.include && !matches(this.include, name)) ||
  3651. (this.exclude && matches(this.exclude, name))
  3652. )) {
  3653. return vnode
  3654. }
  3655. var key = vnode.key == null
  3656. // same constructor may get registered as different local components
  3657. // so cid alone is not enough (#3269)
  3658. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  3659. : vnode.key;
  3660. if (this.cache[key]) {
  3661. vnode.componentInstance = this.cache[key].componentInstance;
  3662. } else {
  3663. this.cache[key] = vnode;
  3664. }
  3665. vnode.data.keepAlive = true;
  3666. }
  3667. return vnode
  3668. }
  3669. };
  3670. var builtInComponents = {
  3671. KeepAlive: KeepAlive
  3672. };
  3673. /* */
  3674. function initGlobalAPI (Vue) {
  3675. // config
  3676. var configDef = {};
  3677. configDef.get = function () { return config; };
  3678. if (process.env.NODE_ENV !== 'production') {
  3679. configDef.set = function () {
  3680. warn(
  3681. 'Do not replace the Vue.config object, set individual fields instead.'
  3682. );
  3683. };
  3684. }
  3685. Object.defineProperty(Vue, 'config', configDef);
  3686. // exposed util methods.
  3687. // NOTE: these are not considered part of the public API - avoid relying on
  3688. // them unless you are aware of the risk.
  3689. Vue.util = {
  3690. warn: warn,
  3691. extend: extend,
  3692. mergeOptions: mergeOptions,
  3693. defineReactive: defineReactive$$1
  3694. };
  3695. Vue.set = set;
  3696. Vue.delete = del;
  3697. Vue.nextTick = nextTick;
  3698. Vue.options = Object.create(null);
  3699. config._assetTypes.forEach(function (type) {
  3700. Vue.options[type + 's'] = Object.create(null);
  3701. });
  3702. // this is used to identify the "base" constructor to extend all plain-object
  3703. // components with in Weex's multi-instance scenarios.
  3704. Vue.options._base = Vue;
  3705. extend(Vue.options.components, builtInComponents);
  3706. initUse(Vue);
  3707. initMixin$1(Vue);
  3708. initExtend(Vue);
  3709. initAssetRegisters(Vue);
  3710. }
  3711. initGlobalAPI(Vue$2);
  3712. Object.defineProperty(Vue$2.prototype, '$isServer', {
  3713. get: isServerRendering
  3714. });
  3715. Vue$2.version = '2.2.2';
  3716. /* */
  3717. // attributes that should be using props for binding
  3718. var acceptValue = makeMap('input,textarea,option,select');
  3719. var mustUseProp = function (tag, type, attr) {
  3720. return (
  3721. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  3722. (attr === 'selected' && tag === 'option') ||
  3723. (attr === 'checked' && tag === 'input') ||
  3724. (attr === 'muted' && tag === 'video')
  3725. )
  3726. };
  3727. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  3728. var isBooleanAttr = makeMap(
  3729. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  3730. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  3731. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  3732. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  3733. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  3734. 'truespeed,typemustmatch,visible'
  3735. );
  3736. var xlinkNS = 'http://www.w3.org/1999/xlink';
  3737. var isXlink = function (name) {
  3738. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  3739. };
  3740. var getXlinkProp = function (name) {
  3741. return isXlink(name) ? name.slice(6, name.length) : ''
  3742. };
  3743. var isFalsyAttrValue = function (val) {
  3744. return val == null || val === false
  3745. };
  3746. /* */
  3747. function genClassForVnode (vnode) {
  3748. var data = vnode.data;
  3749. var parentNode = vnode;
  3750. var childNode = vnode;
  3751. while (childNode.componentInstance) {
  3752. childNode = childNode.componentInstance._vnode;
  3753. if (childNode.data) {
  3754. data = mergeClassData(childNode.data, data);
  3755. }
  3756. }
  3757. while ((parentNode = parentNode.parent)) {
  3758. if (parentNode.data) {
  3759. data = mergeClassData(data, parentNode.data);
  3760. }
  3761. }
  3762. return genClassFromData(data)
  3763. }
  3764. function mergeClassData (child, parent) {
  3765. return {
  3766. staticClass: concat(child.staticClass, parent.staticClass),
  3767. class: child.class
  3768. ? [child.class, parent.class]
  3769. : parent.class
  3770. }
  3771. }
  3772. function genClassFromData (data) {
  3773. var dynamicClass = data.class;
  3774. var staticClass = data.staticClass;
  3775. if (staticClass || dynamicClass) {
  3776. return concat(staticClass, stringifyClass(dynamicClass))
  3777. }
  3778. /* istanbul ignore next */
  3779. return ''
  3780. }
  3781. function concat (a, b) {
  3782. return a ? b ? (a + ' ' + b) : a : (b || '')
  3783. }
  3784. function stringifyClass (value) {
  3785. var res = '';
  3786. if (!value) {
  3787. return res
  3788. }
  3789. if (typeof value === 'string') {
  3790. return value
  3791. }
  3792. if (Array.isArray(value)) {
  3793. var stringified;
  3794. for (var i = 0, l = value.length; i < l; i++) {
  3795. if (value[i]) {
  3796. if ((stringified = stringifyClass(value[i]))) {
  3797. res += stringified + ' ';
  3798. }
  3799. }
  3800. }
  3801. return res.slice(0, -1)
  3802. }
  3803. if (isObject(value)) {
  3804. for (var key in value) {
  3805. if (value[key]) { res += key + ' '; }
  3806. }
  3807. return res.slice(0, -1)
  3808. }
  3809. /* istanbul ignore next */
  3810. return res
  3811. }
  3812. /* */
  3813. var namespaceMap = {
  3814. svg: 'http://www.w3.org/2000/svg',
  3815. math: 'http://www.w3.org/1998/Math/MathML'
  3816. };
  3817. var isHTMLTag = makeMap(
  3818. 'html,body,base,head,link,meta,style,title,' +
  3819. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  3820. 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
  3821. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  3822. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  3823. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  3824. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  3825. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  3826. 'output,progress,select,textarea,' +
  3827. 'details,dialog,menu,menuitem,summary,' +
  3828. 'content,element,shadow,template'
  3829. );
  3830. // this map is intentionally selective, only covering SVG elements that may
  3831. // contain child elements.
  3832. var isSVG = makeMap(
  3833. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  3834. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  3835. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  3836. true
  3837. );
  3838. var isReservedTag = function (tag) {
  3839. return isHTMLTag(tag) || isSVG(tag)
  3840. };
  3841. function getTagNamespace (tag) {
  3842. if (isSVG(tag)) {
  3843. return 'svg'
  3844. }
  3845. // basic support for MathML
  3846. // note it doesn't support other MathML elements being component roots
  3847. if (tag === 'math') {
  3848. return 'math'
  3849. }
  3850. }
  3851. var unknownElementCache = Object.create(null);
  3852. function isUnknownElement (tag) {
  3853. /* istanbul ignore if */
  3854. if (!inBrowser) {
  3855. return true
  3856. }
  3857. if (isReservedTag(tag)) {
  3858. return false
  3859. }
  3860. tag = tag.toLowerCase();
  3861. /* istanbul ignore if */
  3862. if (unknownElementCache[tag] != null) {
  3863. return unknownElementCache[tag]
  3864. }
  3865. var el = document.createElement(tag);
  3866. if (tag.indexOf('-') > -1) {
  3867. // http://stackoverflow.com/a/28210364/1070244
  3868. return (unknownElementCache[tag] = (
  3869. el.constructor === window.HTMLUnknownElement ||
  3870. el.constructor === window.HTMLElement
  3871. ))
  3872. } else {
  3873. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  3874. }
  3875. }
  3876. /* */
  3877. /**
  3878. * Query an element selector if it's not an element already.
  3879. */
  3880. function query (el) {
  3881. if (typeof el === 'string') {
  3882. var selected = document.querySelector(el);
  3883. if (!selected) {
  3884. process.env.NODE_ENV !== 'production' && warn(
  3885. 'Cannot find element: ' + el
  3886. );
  3887. return document.createElement('div')
  3888. }
  3889. return selected
  3890. } else {
  3891. return el
  3892. }
  3893. }
  3894. /* */
  3895. function createElement$1 (tagName, vnode) {
  3896. var elm = document.createElement(tagName);
  3897. if (tagName !== 'select') {
  3898. return elm
  3899. }
  3900. // false or null will remove the attribute but undefined will not
  3901. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  3902. elm.setAttribute('multiple', 'multiple');
  3903. }
  3904. return elm
  3905. }
  3906. function createElementNS (namespace, tagName) {
  3907. return document.createElementNS(namespaceMap[namespace], tagName)
  3908. }
  3909. function createTextNode (text) {
  3910. return document.createTextNode(text)
  3911. }
  3912. function createComment (text) {
  3913. return document.createComment(text)
  3914. }
  3915. function insertBefore (parentNode, newNode, referenceNode) {
  3916. parentNode.insertBefore(newNode, referenceNode);
  3917. }
  3918. function removeChild (node, child) {
  3919. node.removeChild(child);
  3920. }
  3921. function appendChild (node, child) {
  3922. node.appendChild(child);
  3923. }
  3924. function parentNode (node) {
  3925. return node.parentNode
  3926. }
  3927. function nextSibling (node) {
  3928. return node.nextSibling
  3929. }
  3930. function tagName (node) {
  3931. return node.tagName
  3932. }
  3933. function setTextContent (node, text) {
  3934. node.textContent = text;
  3935. }
  3936. function setAttribute (node, key, val) {
  3937. node.setAttribute(key, val);
  3938. }
  3939. var nodeOps = Object.freeze({
  3940. createElement: createElement$1,
  3941. createElementNS: createElementNS,
  3942. createTextNode: createTextNode,
  3943. createComment: createComment,
  3944. insertBefore: insertBefore,
  3945. removeChild: removeChild,
  3946. appendChild: appendChild,
  3947. parentNode: parentNode,
  3948. nextSibling: nextSibling,
  3949. tagName: tagName,
  3950. setTextContent: setTextContent,
  3951. setAttribute: setAttribute
  3952. });
  3953. /* */
  3954. var ref = {
  3955. create: function create (_, vnode) {
  3956. registerRef(vnode);
  3957. },
  3958. update: function update (oldVnode, vnode) {
  3959. if (oldVnode.data.ref !== vnode.data.ref) {
  3960. registerRef(oldVnode, true);
  3961. registerRef(vnode);
  3962. }
  3963. },
  3964. destroy: function destroy (vnode) {
  3965. registerRef(vnode, true);
  3966. }
  3967. };
  3968. function registerRef (vnode, isRemoval) {
  3969. var key = vnode.data.ref;
  3970. if (!key) { return }
  3971. var vm = vnode.context;
  3972. var ref = vnode.componentInstance || vnode.elm;
  3973. var refs = vm.$refs;
  3974. if (isRemoval) {
  3975. if (Array.isArray(refs[key])) {
  3976. remove(refs[key], ref);
  3977. } else if (refs[key] === ref) {
  3978. refs[key] = undefined;
  3979. }
  3980. } else {
  3981. if (vnode.data.refInFor) {
  3982. if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
  3983. refs[key].push(ref);
  3984. } else {
  3985. refs[key] = [ref];
  3986. }
  3987. } else {
  3988. refs[key] = ref;
  3989. }
  3990. }
  3991. }
  3992. /**
  3993. * Virtual DOM patching algorithm based on Snabbdom by
  3994. * Simon Friis Vindum (@paldepind)
  3995. * Licensed under the MIT License
  3996. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  3997. *
  3998. * modified by Evan You (@yyx990803)
  3999. *
  4000. /*
  4001. * Not type-checking this because this file is perf-critical and the cost
  4002. * of making flow understand it is not worth it.
  4003. */
  4004. var emptyNode = new VNode('', {}, []);
  4005. var hooks$1 = ['create', 'activate', 'update', 'remove', 'destroy'];
  4006. function isUndef (s) {
  4007. return s == null
  4008. }
  4009. function isDef (s) {
  4010. return s != null
  4011. }
  4012. function sameVnode (vnode1, vnode2) {
  4013. return (
  4014. vnode1.key === vnode2.key &&
  4015. vnode1.tag === vnode2.tag &&
  4016. vnode1.isComment === vnode2.isComment &&
  4017. !vnode1.data === !vnode2.data
  4018. )
  4019. }
  4020. function createKeyToOldIdx (children, beginIdx, endIdx) {
  4021. var i, key;
  4022. var map = {};
  4023. for (i = beginIdx; i <= endIdx; ++i) {
  4024. key = children[i].key;
  4025. if (isDef(key)) { map[key] = i; }
  4026. }
  4027. return map
  4028. }
  4029. function createPatchFunction (backend) {
  4030. var i, j;
  4031. var cbs = {};
  4032. var modules = backend.modules;
  4033. var nodeOps = backend.nodeOps;
  4034. for (i = 0; i < hooks$1.length; ++i) {
  4035. cbs[hooks$1[i]] = [];
  4036. for (j = 0; j < modules.length; ++j) {
  4037. if (modules[j][hooks$1[i]] !== undefined) { cbs[hooks$1[i]].push(modules[j][hooks$1[i]]); }
  4038. }
  4039. }
  4040. function emptyNodeAt (elm) {
  4041. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  4042. }
  4043. function createRmCb (childElm, listeners) {
  4044. function remove$$1 () {
  4045. if (--remove$$1.listeners === 0) {
  4046. removeNode(childElm);
  4047. }
  4048. }
  4049. remove$$1.listeners = listeners;
  4050. return remove$$1
  4051. }
  4052. function removeNode (el) {
  4053. var parent = nodeOps.parentNode(el);
  4054. // element may have already been removed due to v-html / v-text
  4055. if (parent) {
  4056. nodeOps.removeChild(parent, el);
  4057. }
  4058. }
  4059. var inPre = 0;
  4060. function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
  4061. vnode.isRootInsert = !nested; // for transition enter check
  4062. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  4063. return
  4064. }
  4065. var data = vnode.data;
  4066. var children = vnode.children;
  4067. var tag = vnode.tag;
  4068. if (isDef(tag)) {
  4069. if (process.env.NODE_ENV !== 'production') {
  4070. if (data && data.pre) {
  4071. inPre++;
  4072. }
  4073. if (
  4074. !inPre &&
  4075. !vnode.ns &&
  4076. !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
  4077. config.isUnknownElement(tag)
  4078. ) {
  4079. warn(
  4080. 'Unknown custom element: <' + tag + '> - did you ' +
  4081. 'register the component correctly? For recursive components, ' +
  4082. 'make sure to provide the "name" option.',
  4083. vnode.context
  4084. );
  4085. }
  4086. }
  4087. vnode.elm = vnode.ns
  4088. ? nodeOps.createElementNS(vnode.ns, tag)
  4089. : nodeOps.createElement(tag, vnode);
  4090. setScope(vnode);
  4091. /* istanbul ignore if */
  4092. {
  4093. createChildren(vnode, children, insertedVnodeQueue);
  4094. if (isDef(data)) {
  4095. invokeCreateHooks(vnode, insertedVnodeQueue);
  4096. }
  4097. insert(parentElm, vnode.elm, refElm);
  4098. }
  4099. if (process.env.NODE_ENV !== 'production' && data && data.pre) {
  4100. inPre--;
  4101. }
  4102. } else if (vnode.isComment) {
  4103. vnode.elm = nodeOps.createComment(vnode.text);
  4104. insert(parentElm, vnode.elm, refElm);
  4105. } else {
  4106. vnode.elm = nodeOps.createTextNode(vnode.text);
  4107. insert(parentElm, vnode.elm, refElm);
  4108. }
  4109. }
  4110. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  4111. var i = vnode.data;
  4112. if (isDef(i)) {
  4113. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  4114. if (isDef(i = i.hook) && isDef(i = i.init)) {
  4115. i(vnode, false /* hydrating */, parentElm, refElm);
  4116. }
  4117. // after calling the init hook, if the vnode is a child component
  4118. // it should've created a child instance and mounted it. the child
  4119. // component also has set the placeholder vnode's elm.
  4120. // in that case we can just return the element and be done.
  4121. if (isDef(vnode.componentInstance)) {
  4122. initComponent(vnode, insertedVnodeQueue);
  4123. if (isReactivated) {
  4124. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  4125. }
  4126. return true
  4127. }
  4128. }
  4129. }
  4130. function initComponent (vnode, insertedVnodeQueue) {
  4131. if (vnode.data.pendingInsert) {
  4132. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  4133. }
  4134. vnode.elm = vnode.componentInstance.$el;
  4135. if (isPatchable(vnode)) {
  4136. invokeCreateHooks(vnode, insertedVnodeQueue);
  4137. setScope(vnode);
  4138. } else {
  4139. // empty component root.
  4140. // skip all element-related modules except for ref (#3455)
  4141. registerRef(vnode);
  4142. // make sure to invoke the insert hook
  4143. insertedVnodeQueue.push(vnode);
  4144. }
  4145. }
  4146. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  4147. var i;
  4148. // hack for #4339: a reactivated component with inner transition
  4149. // does not trigger because the inner node's created hooks are not called
  4150. // again. It's not ideal to involve module-specific logic in here but
  4151. // there doesn't seem to be a better way to do it.
  4152. var innerNode = vnode;
  4153. while (innerNode.componentInstance) {
  4154. innerNode = innerNode.componentInstance._vnode;
  4155. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  4156. for (i = 0; i < cbs.activate.length; ++i) {
  4157. cbs.activate[i](emptyNode, innerNode);
  4158. }
  4159. insertedVnodeQueue.push(innerNode);
  4160. break
  4161. }
  4162. }
  4163. // unlike a newly created component,
  4164. // a reactivated keep-alive component doesn't insert itself
  4165. insert(parentElm, vnode.elm, refElm);
  4166. }
  4167. function insert (parent, elm, ref) {
  4168. if (parent) {
  4169. if (ref) {
  4170. nodeOps.insertBefore(parent, elm, ref);
  4171. } else {
  4172. nodeOps.appendChild(parent, elm);
  4173. }
  4174. }
  4175. }
  4176. function createChildren (vnode, children, insertedVnodeQueue) {
  4177. if (Array.isArray(children)) {
  4178. for (var i = 0; i < children.length; ++i) {
  4179. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
  4180. }
  4181. } else if (isPrimitive(vnode.text)) {
  4182. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
  4183. }
  4184. }
  4185. function isPatchable (vnode) {
  4186. while (vnode.componentInstance) {
  4187. vnode = vnode.componentInstance._vnode;
  4188. }
  4189. return isDef(vnode.tag)
  4190. }
  4191. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  4192. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  4193. cbs.create[i$1](emptyNode, vnode);
  4194. }
  4195. i = vnode.data.hook; // Reuse variable
  4196. if (isDef(i)) {
  4197. if (i.create) { i.create(emptyNode, vnode); }
  4198. if (i.insert) { insertedVnodeQueue.push(vnode); }
  4199. }
  4200. }
  4201. // set scope id attribute for scoped CSS.
  4202. // this is implemented as a special case to avoid the overhead
  4203. // of going through the normal attribute patching process.
  4204. function setScope (vnode) {
  4205. var i;
  4206. var ancestor = vnode;
  4207. while (ancestor) {
  4208. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  4209. nodeOps.setAttribute(vnode.elm, i, '');
  4210. }
  4211. ancestor = ancestor.parent;
  4212. }
  4213. // for slot content they should also get the scopeId from the host instance.
  4214. if (isDef(i = activeInstance) &&
  4215. i !== vnode.context &&
  4216. isDef(i = i.$options._scopeId)) {
  4217. nodeOps.setAttribute(vnode.elm, i, '');
  4218. }
  4219. }
  4220. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  4221. for (; startIdx <= endIdx; ++startIdx) {
  4222. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
  4223. }
  4224. }
  4225. function invokeDestroyHook (vnode) {
  4226. var i, j;
  4227. var data = vnode.data;
  4228. if (isDef(data)) {
  4229. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  4230. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  4231. }
  4232. if (isDef(i = vnode.children)) {
  4233. for (j = 0; j < vnode.children.length; ++j) {
  4234. invokeDestroyHook(vnode.children[j]);
  4235. }
  4236. }
  4237. }
  4238. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  4239. for (; startIdx <= endIdx; ++startIdx) {
  4240. var ch = vnodes[startIdx];
  4241. if (isDef(ch)) {
  4242. if (isDef(ch.tag)) {
  4243. removeAndInvokeRemoveHook(ch);
  4244. invokeDestroyHook(ch);
  4245. } else { // Text node
  4246. removeNode(ch.elm);
  4247. }
  4248. }
  4249. }
  4250. }
  4251. function removeAndInvokeRemoveHook (vnode, rm) {
  4252. if (rm || isDef(vnode.data)) {
  4253. var listeners = cbs.remove.length + 1;
  4254. if (!rm) {
  4255. // directly removing
  4256. rm = createRmCb(vnode.elm, listeners);
  4257. } else {
  4258. // we have a recursively passed down rm callback
  4259. // increase the listeners count
  4260. rm.listeners += listeners;
  4261. }
  4262. // recursively invoke hooks on child component root node
  4263. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  4264. removeAndInvokeRemoveHook(i, rm);
  4265. }
  4266. for (i = 0; i < cbs.remove.length; ++i) {
  4267. cbs.remove[i](vnode, rm);
  4268. }
  4269. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  4270. i(vnode, rm);
  4271. } else {
  4272. rm();
  4273. }
  4274. } else {
  4275. removeNode(vnode.elm);
  4276. }
  4277. }
  4278. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  4279. var oldStartIdx = 0;
  4280. var newStartIdx = 0;
  4281. var oldEndIdx = oldCh.length - 1;
  4282. var oldStartVnode = oldCh[0];
  4283. var oldEndVnode = oldCh[oldEndIdx];
  4284. var newEndIdx = newCh.length - 1;
  4285. var newStartVnode = newCh[0];
  4286. var newEndVnode = newCh[newEndIdx];
  4287. var oldKeyToIdx, idxInOld, elmToMove, refElm;
  4288. // removeOnly is a special flag used only by <transition-group>
  4289. // to ensure removed elements stay in correct relative positions
  4290. // during leaving transitions
  4291. var canMove = !removeOnly;
  4292. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  4293. if (isUndef(oldStartVnode)) {
  4294. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  4295. } else if (isUndef(oldEndVnode)) {
  4296. oldEndVnode = oldCh[--oldEndIdx];
  4297. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  4298. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  4299. oldStartVnode = oldCh[++oldStartIdx];
  4300. newStartVnode = newCh[++newStartIdx];
  4301. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  4302. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  4303. oldEndVnode = oldCh[--oldEndIdx];
  4304. newEndVnode = newCh[--newEndIdx];
  4305. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  4306. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  4307. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  4308. oldStartVnode = oldCh[++oldStartIdx];
  4309. newEndVnode = newCh[--newEndIdx];
  4310. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  4311. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  4312. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  4313. oldEndVnode = oldCh[--oldEndIdx];
  4314. newStartVnode = newCh[++newStartIdx];
  4315. } else {
  4316. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  4317. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
  4318. if (isUndef(idxInOld)) { // New element
  4319. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  4320. newStartVnode = newCh[++newStartIdx];
  4321. } else {
  4322. elmToMove = oldCh[idxInOld];
  4323. /* istanbul ignore if */
  4324. if (process.env.NODE_ENV !== 'production' && !elmToMove) {
  4325. warn(
  4326. 'It seems there are duplicate keys that is causing an update error. ' +
  4327. 'Make sure each v-for item has a unique key.'
  4328. );
  4329. }
  4330. if (sameVnode(elmToMove, newStartVnode)) {
  4331. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  4332. oldCh[idxInOld] = undefined;
  4333. canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
  4334. newStartVnode = newCh[++newStartIdx];
  4335. } else {
  4336. // same key but different element. treat as new element
  4337. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  4338. newStartVnode = newCh[++newStartIdx];
  4339. }
  4340. }
  4341. }
  4342. }
  4343. if (oldStartIdx > oldEndIdx) {
  4344. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  4345. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  4346. } else if (newStartIdx > newEndIdx) {
  4347. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  4348. }
  4349. }
  4350. function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  4351. if (oldVnode === vnode) {
  4352. return
  4353. }
  4354. // reuse element for static trees.
  4355. // note we only do this if the vnode is cloned -
  4356. // if the new node is not cloned it means the render functions have been
  4357. // reset by the hot-reload-api and we need to do a proper re-render.
  4358. if (vnode.isStatic &&
  4359. oldVnode.isStatic &&
  4360. vnode.key === oldVnode.key &&
  4361. (vnode.isCloned || vnode.isOnce)) {
  4362. vnode.elm = oldVnode.elm;
  4363. vnode.componentInstance = oldVnode.componentInstance;
  4364. return
  4365. }
  4366. var i;
  4367. var data = vnode.data;
  4368. var hasData = isDef(data);
  4369. if (hasData && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  4370. i(oldVnode, vnode);
  4371. }
  4372. var elm = vnode.elm = oldVnode.elm;
  4373. var oldCh = oldVnode.children;
  4374. var ch = vnode.children;
  4375. if (hasData && isPatchable(vnode)) {
  4376. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  4377. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  4378. }
  4379. if (isUndef(vnode.text)) {
  4380. if (isDef(oldCh) && isDef(ch)) {
  4381. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  4382. } else if (isDef(ch)) {
  4383. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  4384. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  4385. } else if (isDef(oldCh)) {
  4386. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  4387. } else if (isDef(oldVnode.text)) {
  4388. nodeOps.setTextContent(elm, '');
  4389. }
  4390. } else if (oldVnode.text !== vnode.text) {
  4391. nodeOps.setTextContent(elm, vnode.text);
  4392. }
  4393. if (hasData) {
  4394. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  4395. }
  4396. }
  4397. function invokeInsertHook (vnode, queue, initial) {
  4398. // delay insert hooks for component root nodes, invoke them after the
  4399. // element is really inserted
  4400. if (initial && vnode.parent) {
  4401. vnode.parent.data.pendingInsert = queue;
  4402. } else {
  4403. for (var i = 0; i < queue.length; ++i) {
  4404. queue[i].data.hook.insert(queue[i]);
  4405. }
  4406. }
  4407. }
  4408. var bailed = false;
  4409. // list of modules that can skip create hook during hydration because they
  4410. // are already rendered on the client or has no need for initialization
  4411. var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
  4412. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  4413. function hydrate (elm, vnode, insertedVnodeQueue) {
  4414. if (process.env.NODE_ENV !== 'production') {
  4415. if (!assertNodeMatch(elm, vnode)) {
  4416. return false
  4417. }
  4418. }
  4419. vnode.elm = elm;
  4420. var tag = vnode.tag;
  4421. var data = vnode.data;
  4422. var children = vnode.children;
  4423. if (isDef(data)) {
  4424. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  4425. if (isDef(i = vnode.componentInstance)) {
  4426. // child component. it should have hydrated its own tree.
  4427. initComponent(vnode, insertedVnodeQueue);
  4428. return true
  4429. }
  4430. }
  4431. if (isDef(tag)) {
  4432. if (isDef(children)) {
  4433. // empty element, allow client to pick up and populate children
  4434. if (!elm.hasChildNodes()) {
  4435. createChildren(vnode, children, insertedVnodeQueue);
  4436. } else {
  4437. var childrenMatch = true;
  4438. var childNode = elm.firstChild;
  4439. for (var i$1 = 0; i$1 < children.length; i$1++) {
  4440. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
  4441. childrenMatch = false;
  4442. break
  4443. }
  4444. childNode = childNode.nextSibling;
  4445. }
  4446. // if childNode is not null, it means the actual childNodes list is
  4447. // longer than the virtual children list.
  4448. if (!childrenMatch || childNode) {
  4449. if (process.env.NODE_ENV !== 'production' &&
  4450. typeof console !== 'undefined' &&
  4451. !bailed) {
  4452. bailed = true;
  4453. console.warn('Parent: ', elm);
  4454. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  4455. }
  4456. return false
  4457. }
  4458. }
  4459. }
  4460. if (isDef(data)) {
  4461. for (var key in data) {
  4462. if (!isRenderedModule(key)) {
  4463. invokeCreateHooks(vnode, insertedVnodeQueue);
  4464. break
  4465. }
  4466. }
  4467. }
  4468. } else if (elm.data !== vnode.text) {
  4469. elm.data = vnode.text;
  4470. }
  4471. return true
  4472. }
  4473. function assertNodeMatch (node, vnode) {
  4474. if (vnode.tag) {
  4475. return (
  4476. vnode.tag.indexOf('vue-component') === 0 ||
  4477. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  4478. )
  4479. } else {
  4480. return node.nodeType === (vnode.isComment ? 8 : 3)
  4481. }
  4482. }
  4483. return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
  4484. if (!vnode) {
  4485. if (oldVnode) { invokeDestroyHook(oldVnode); }
  4486. return
  4487. }
  4488. var isInitialPatch = false;
  4489. var insertedVnodeQueue = [];
  4490. if (!oldVnode) {
  4491. // empty mount (likely as component), create new root element
  4492. isInitialPatch = true;
  4493. createElm(vnode, insertedVnodeQueue, parentElm, refElm);
  4494. } else {
  4495. var isRealElement = isDef(oldVnode.nodeType);
  4496. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  4497. // patch existing root node
  4498. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  4499. } else {
  4500. if (isRealElement) {
  4501. // mounting to a real element
  4502. // check if this is server-rendered content and if we can perform
  4503. // a successful hydration.
  4504. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute('server-rendered')) {
  4505. oldVnode.removeAttribute('server-rendered');
  4506. hydrating = true;
  4507. }
  4508. if (hydrating) {
  4509. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  4510. invokeInsertHook(vnode, insertedVnodeQueue, true);
  4511. return oldVnode
  4512. } else if (process.env.NODE_ENV !== 'production') {
  4513. warn(
  4514. 'The client-side rendered virtual DOM tree is not matching ' +
  4515. 'server-rendered content. This is likely caused by incorrect ' +
  4516. 'HTML markup, for example nesting block-level elements inside ' +
  4517. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  4518. 'full client-side render.'
  4519. );
  4520. }
  4521. }
  4522. // either not server-rendered, or hydration failed.
  4523. // create an empty node and replace it
  4524. oldVnode = emptyNodeAt(oldVnode);
  4525. }
  4526. // replacing existing element
  4527. var oldElm = oldVnode.elm;
  4528. var parentElm$1 = nodeOps.parentNode(oldElm);
  4529. createElm(
  4530. vnode,
  4531. insertedVnodeQueue,
  4532. // extremely rare edge case: do not insert if old element is in a
  4533. // leaving transition. Only happens when combining transition +
  4534. // keep-alive + HOCs. (#4590)
  4535. oldElm._leaveCb ? null : parentElm$1,
  4536. nodeOps.nextSibling(oldElm)
  4537. );
  4538. if (vnode.parent) {
  4539. // component root element replaced.
  4540. // update parent placeholder node element, recursively
  4541. var ancestor = vnode.parent;
  4542. while (ancestor) {
  4543. ancestor.elm = vnode.elm;
  4544. ancestor = ancestor.parent;
  4545. }
  4546. if (isPatchable(vnode)) {
  4547. for (var i = 0; i < cbs.create.length; ++i) {
  4548. cbs.create[i](emptyNode, vnode.parent);
  4549. }
  4550. }
  4551. }
  4552. if (parentElm$1 !== null) {
  4553. removeVnodes(parentElm$1, [oldVnode], 0, 0);
  4554. } else if (isDef(oldVnode.tag)) {
  4555. invokeDestroyHook(oldVnode);
  4556. }
  4557. }
  4558. }
  4559. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  4560. return vnode.elm
  4561. }
  4562. }
  4563. /* */
  4564. var directives = {
  4565. create: updateDirectives,
  4566. update: updateDirectives,
  4567. destroy: function unbindDirectives (vnode) {
  4568. updateDirectives(vnode, emptyNode);
  4569. }
  4570. };
  4571. function updateDirectives (oldVnode, vnode) {
  4572. if (oldVnode.data.directives || vnode.data.directives) {
  4573. _update(oldVnode, vnode);
  4574. }
  4575. }
  4576. function _update (oldVnode, vnode) {
  4577. var isCreate = oldVnode === emptyNode;
  4578. var isDestroy = vnode === emptyNode;
  4579. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  4580. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  4581. var dirsWithInsert = [];
  4582. var dirsWithPostpatch = [];
  4583. var key, oldDir, dir;
  4584. for (key in newDirs) {
  4585. oldDir = oldDirs[key];
  4586. dir = newDirs[key];
  4587. if (!oldDir) {
  4588. // new directive, bind
  4589. callHook$1(dir, 'bind', vnode, oldVnode);
  4590. if (dir.def && dir.def.inserted) {
  4591. dirsWithInsert.push(dir);
  4592. }
  4593. } else {
  4594. // existing directive, update
  4595. dir.oldValue = oldDir.value;
  4596. callHook$1(dir, 'update', vnode, oldVnode);
  4597. if (dir.def && dir.def.componentUpdated) {
  4598. dirsWithPostpatch.push(dir);
  4599. }
  4600. }
  4601. }
  4602. if (dirsWithInsert.length) {
  4603. var callInsert = function () {
  4604. for (var i = 0; i < dirsWithInsert.length; i++) {
  4605. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  4606. }
  4607. };
  4608. if (isCreate) {
  4609. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
  4610. } else {
  4611. callInsert();
  4612. }
  4613. }
  4614. if (dirsWithPostpatch.length) {
  4615. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
  4616. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  4617. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  4618. }
  4619. });
  4620. }
  4621. if (!isCreate) {
  4622. for (key in oldDirs) {
  4623. if (!newDirs[key]) {
  4624. // no longer present, unbind
  4625. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  4626. }
  4627. }
  4628. }
  4629. }
  4630. var emptyModifiers = Object.create(null);
  4631. function normalizeDirectives$1 (
  4632. dirs,
  4633. vm
  4634. ) {
  4635. var res = Object.create(null);
  4636. if (!dirs) {
  4637. return res
  4638. }
  4639. var i, dir;
  4640. for (i = 0; i < dirs.length; i++) {
  4641. dir = dirs[i];
  4642. if (!dir.modifiers) {
  4643. dir.modifiers = emptyModifiers;
  4644. }
  4645. res[getRawDirName(dir)] = dir;
  4646. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  4647. }
  4648. return res
  4649. }
  4650. function getRawDirName (dir) {
  4651. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  4652. }
  4653. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  4654. var fn = dir.def && dir.def[hook];
  4655. if (fn) {
  4656. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  4657. }
  4658. }
  4659. var baseModules = [
  4660. ref,
  4661. directives
  4662. ];
  4663. /* */
  4664. function updateAttrs (oldVnode, vnode) {
  4665. if (!oldVnode.data.attrs && !vnode.data.attrs) {
  4666. return
  4667. }
  4668. var key, cur, old;
  4669. var elm = vnode.elm;
  4670. var oldAttrs = oldVnode.data.attrs || {};
  4671. var attrs = vnode.data.attrs || {};
  4672. // clone observed objects, as the user probably wants to mutate it
  4673. if (attrs.__ob__) {
  4674. attrs = vnode.data.attrs = extend({}, attrs);
  4675. }
  4676. for (key in attrs) {
  4677. cur = attrs[key];
  4678. old = oldAttrs[key];
  4679. if (old !== cur) {
  4680. setAttr(elm, key, cur);
  4681. }
  4682. }
  4683. // #4391: in IE9, setting type can reset value for input[type=radio]
  4684. /* istanbul ignore if */
  4685. if (isIE9 && attrs.value !== oldAttrs.value) {
  4686. setAttr(elm, 'value', attrs.value);
  4687. }
  4688. for (key in oldAttrs) {
  4689. if (attrs[key] == null) {
  4690. if (isXlink(key)) {
  4691. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  4692. } else if (!isEnumeratedAttr(key)) {
  4693. elm.removeAttribute(key);
  4694. }
  4695. }
  4696. }
  4697. }
  4698. function setAttr (el, key, value) {
  4699. if (isBooleanAttr(key)) {
  4700. // set attribute for blank value
  4701. // e.g. <option disabled>Select one</option>
  4702. if (isFalsyAttrValue(value)) {
  4703. el.removeAttribute(key);
  4704. } else {
  4705. el.setAttribute(key, key);
  4706. }
  4707. } else if (isEnumeratedAttr(key)) {
  4708. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  4709. } else if (isXlink(key)) {
  4710. if (isFalsyAttrValue(value)) {
  4711. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  4712. } else {
  4713. el.setAttributeNS(xlinkNS, key, value);
  4714. }
  4715. } else {
  4716. if (isFalsyAttrValue(value)) {
  4717. el.removeAttribute(key);
  4718. } else {
  4719. el.setAttribute(key, value);
  4720. }
  4721. }
  4722. }
  4723. var attrs = {
  4724. create: updateAttrs,
  4725. update: updateAttrs
  4726. };
  4727. /* */
  4728. function updateClass (oldVnode, vnode) {
  4729. var el = vnode.elm;
  4730. var data = vnode.data;
  4731. var oldData = oldVnode.data;
  4732. if (!data.staticClass && !data.class &&
  4733. (!oldData || (!oldData.staticClass && !oldData.class))) {
  4734. return
  4735. }
  4736. var cls = genClassForVnode(vnode);
  4737. // handle transition classes
  4738. var transitionClass = el._transitionClasses;
  4739. if (transitionClass) {
  4740. cls = concat(cls, stringifyClass(transitionClass));
  4741. }
  4742. // set the class
  4743. if (cls !== el._prevClass) {
  4744. el.setAttribute('class', cls);
  4745. el._prevClass = cls;
  4746. }
  4747. }
  4748. var klass = {
  4749. create: updateClass,
  4750. update: updateClass
  4751. };
  4752. /* */
  4753. var validDivisionCharRE = /[\w).+\-_$\]]/;
  4754. function wrapFilter (exp, filter) {
  4755. var i = filter.indexOf('(');
  4756. if (i < 0) {
  4757. // _f: resolveFilter
  4758. return ("_f(\"" + filter + "\")(" + exp + ")")
  4759. } else {
  4760. var name = filter.slice(0, i);
  4761. var args = filter.slice(i + 1);
  4762. return ("_f(\"" + name + "\")(" + exp + "," + args)
  4763. }
  4764. }
  4765. /* */
  4766. /* */
  4767. /**
  4768. * Cross-platform code generation for component v-model
  4769. */
  4770. /**
  4771. * Cross-platform codegen helper for generating v-model value assignment code.
  4772. */
  4773. /**
  4774. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  4775. *
  4776. * for loop possible cases:
  4777. *
  4778. * - test
  4779. * - test[idx]
  4780. * - test[test1[idx]]
  4781. * - test["a"][idx]
  4782. * - xxx.test[a[a].test1[idx]]
  4783. * - test.xxx.a["asa"][test1[idx]]
  4784. *
  4785. */
  4786. var str;
  4787. var index$1;
  4788. /* */
  4789. // in some cases, the event used has to be determined at runtime
  4790. // so we used some reserved tokens during compile.
  4791. var RANGE_TOKEN = '__r';
  4792. var CHECKBOX_RADIO_TOKEN = '__c';
  4793. /* */
  4794. // normalize v-model event tokens that can only be determined at runtime.
  4795. // it's important to place the event as the first in the array because
  4796. // the whole point is ensuring the v-model callback gets called before
  4797. // user-attached handlers.
  4798. function normalizeEvents (on) {
  4799. var event;
  4800. /* istanbul ignore if */
  4801. if (on[RANGE_TOKEN]) {
  4802. // IE input[type=range] only supports `change` event
  4803. event = isIE ? 'change' : 'input';
  4804. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  4805. delete on[RANGE_TOKEN];
  4806. }
  4807. if (on[CHECKBOX_RADIO_TOKEN]) {
  4808. // Chrome fires microtasks in between click/change, leads to #4521
  4809. event = isChrome ? 'click' : 'change';
  4810. on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []);
  4811. delete on[CHECKBOX_RADIO_TOKEN];
  4812. }
  4813. }
  4814. var target$1;
  4815. function add$1 (
  4816. event,
  4817. handler,
  4818. once,
  4819. capture
  4820. ) {
  4821. if (once) {
  4822. var oldHandler = handler;
  4823. var _target = target$1; // save current target element in closure
  4824. handler = function (ev) {
  4825. var res = arguments.length === 1
  4826. ? oldHandler(ev)
  4827. : oldHandler.apply(null, arguments);
  4828. if (res !== null) {
  4829. remove$2(event, handler, capture, _target);
  4830. }
  4831. };
  4832. }
  4833. target$1.addEventListener(event, handler, capture);
  4834. }
  4835. function remove$2 (
  4836. event,
  4837. handler,
  4838. capture,
  4839. _target
  4840. ) {
  4841. (_target || target$1).removeEventListener(event, handler, capture);
  4842. }
  4843. function updateDOMListeners (oldVnode, vnode) {
  4844. if (!oldVnode.data.on && !vnode.data.on) {
  4845. return
  4846. }
  4847. var on = vnode.data.on || {};
  4848. var oldOn = oldVnode.data.on || {};
  4849. target$1 = vnode.elm;
  4850. normalizeEvents(on);
  4851. updateListeners(on, oldOn, add$1, remove$2, vnode.context);
  4852. }
  4853. var events = {
  4854. create: updateDOMListeners,
  4855. update: updateDOMListeners
  4856. };
  4857. /* */
  4858. function updateDOMProps (oldVnode, vnode) {
  4859. if (!oldVnode.data.domProps && !vnode.data.domProps) {
  4860. return
  4861. }
  4862. var key, cur;
  4863. var elm = vnode.elm;
  4864. var oldProps = oldVnode.data.domProps || {};
  4865. var props = vnode.data.domProps || {};
  4866. // clone observed objects, as the user probably wants to mutate it
  4867. if (props.__ob__) {
  4868. props = vnode.data.domProps = extend({}, props);
  4869. }
  4870. for (key in oldProps) {
  4871. if (props[key] == null) {
  4872. elm[key] = '';
  4873. }
  4874. }
  4875. for (key in props) {
  4876. cur = props[key];
  4877. // ignore children if the node has textContent or innerHTML,
  4878. // as these will throw away existing DOM nodes and cause removal errors
  4879. // on subsequent patches (#3360)
  4880. if (key === 'textContent' || key === 'innerHTML') {
  4881. if (vnode.children) { vnode.children.length = 0; }
  4882. if (cur === oldProps[key]) { continue }
  4883. }
  4884. if (key === 'value') {
  4885. // store value as _value as well since
  4886. // non-string values will be stringified
  4887. elm._value = cur;
  4888. // avoid resetting cursor position when value is the same
  4889. var strCur = cur == null ? '' : String(cur);
  4890. if (shouldUpdateValue(elm, vnode, strCur)) {
  4891. elm.value = strCur;
  4892. }
  4893. } else {
  4894. elm[key] = cur;
  4895. }
  4896. }
  4897. }
  4898. // check platforms/web/util/attrs.js acceptValue
  4899. function shouldUpdateValue (
  4900. elm,
  4901. vnode,
  4902. checkVal
  4903. ) {
  4904. return (!elm.composing && (
  4905. vnode.tag === 'option' ||
  4906. isDirty(elm, checkVal) ||
  4907. isInputChanged(elm, checkVal)
  4908. ))
  4909. }
  4910. function isDirty (elm, checkVal) {
  4911. // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
  4912. return document.activeElement !== elm && elm.value !== checkVal
  4913. }
  4914. function isInputChanged (elm, newVal) {
  4915. var value = elm.value;
  4916. var modifiers = elm._vModifiers; // injected by v-model runtime
  4917. if ((modifiers && modifiers.number) || elm.type === 'number') {
  4918. return toNumber(value) !== toNumber(newVal)
  4919. }
  4920. if (modifiers && modifiers.trim) {
  4921. return value.trim() !== newVal.trim()
  4922. }
  4923. return value !== newVal
  4924. }
  4925. var domProps = {
  4926. create: updateDOMProps,
  4927. update: updateDOMProps
  4928. };
  4929. /* */
  4930. var parseStyleText = cached(function (cssText) {
  4931. var res = {};
  4932. var listDelimiter = /;(?![^(]*\))/g;
  4933. var propertyDelimiter = /:(.+)/;
  4934. cssText.split(listDelimiter).forEach(function (item) {
  4935. if (item) {
  4936. var tmp = item.split(propertyDelimiter);
  4937. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  4938. }
  4939. });
  4940. return res
  4941. });
  4942. // merge static and dynamic style data on the same vnode
  4943. function normalizeStyleData (data) {
  4944. var style = normalizeStyleBinding(data.style);
  4945. // static style is pre-processed into an object during compilation
  4946. // and is always a fresh object, so it's safe to merge into it
  4947. return data.staticStyle
  4948. ? extend(data.staticStyle, style)
  4949. : style
  4950. }
  4951. // normalize possible array / string values into Object
  4952. function normalizeStyleBinding (bindingStyle) {
  4953. if (Array.isArray(bindingStyle)) {
  4954. return toObject(bindingStyle)
  4955. }
  4956. if (typeof bindingStyle === 'string') {
  4957. return parseStyleText(bindingStyle)
  4958. }
  4959. return bindingStyle
  4960. }
  4961. /**
  4962. * parent component style should be after child's
  4963. * so that parent component's style could override it
  4964. */
  4965. function getStyle (vnode, checkChild) {
  4966. var res = {};
  4967. var styleData;
  4968. if (checkChild) {
  4969. var childNode = vnode;
  4970. while (childNode.componentInstance) {
  4971. childNode = childNode.componentInstance._vnode;
  4972. if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
  4973. extend(res, styleData);
  4974. }
  4975. }
  4976. }
  4977. if ((styleData = normalizeStyleData(vnode.data))) {
  4978. extend(res, styleData);
  4979. }
  4980. var parentNode = vnode;
  4981. while ((parentNode = parentNode.parent)) {
  4982. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  4983. extend(res, styleData);
  4984. }
  4985. }
  4986. return res
  4987. }
  4988. /* */
  4989. var cssVarRE = /^--/;
  4990. var importantRE = /\s*!important$/;
  4991. var setProp = function (el, name, val) {
  4992. /* istanbul ignore if */
  4993. if (cssVarRE.test(name)) {
  4994. el.style.setProperty(name, val);
  4995. } else if (importantRE.test(val)) {
  4996. el.style.setProperty(name, val.replace(importantRE, ''), 'important');
  4997. } else {
  4998. el.style[normalize(name)] = val;
  4999. }
  5000. };
  5001. var prefixes = ['Webkit', 'Moz', 'ms'];
  5002. var testEl;
  5003. var normalize = cached(function (prop) {
  5004. testEl = testEl || document.createElement('div');
  5005. prop = camelize(prop);
  5006. if (prop !== 'filter' && (prop in testEl.style)) {
  5007. return prop
  5008. }
  5009. var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
  5010. for (var i = 0; i < prefixes.length; i++) {
  5011. var prefixed = prefixes[i] + upper;
  5012. if (prefixed in testEl.style) {
  5013. return prefixed
  5014. }
  5015. }
  5016. });
  5017. function updateStyle (oldVnode, vnode) {
  5018. var data = vnode.data;
  5019. var oldData = oldVnode.data;
  5020. if (!data.staticStyle && !data.style &&
  5021. !oldData.staticStyle && !oldData.style) {
  5022. return
  5023. }
  5024. var cur, name;
  5025. var el = vnode.elm;
  5026. var oldStaticStyle = oldVnode.data.staticStyle;
  5027. var oldStyleBinding = oldVnode.data.style || {};
  5028. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  5029. var oldStyle = oldStaticStyle || oldStyleBinding;
  5030. var style = normalizeStyleBinding(vnode.data.style) || {};
  5031. vnode.data.style = style.__ob__ ? extend({}, style) : style;
  5032. var newStyle = getStyle(vnode, true);
  5033. for (name in oldStyle) {
  5034. if (newStyle[name] == null) {
  5035. setProp(el, name, '');
  5036. }
  5037. }
  5038. for (name in newStyle) {
  5039. cur = newStyle[name];
  5040. if (cur !== oldStyle[name]) {
  5041. // ie9 setting to null has no effect, must use empty string
  5042. setProp(el, name, cur == null ? '' : cur);
  5043. }
  5044. }
  5045. }
  5046. var style = {
  5047. create: updateStyle,
  5048. update: updateStyle
  5049. };
  5050. /* */
  5051. /**
  5052. * Add class with compatibility for SVG since classList is not supported on
  5053. * SVG elements in IE
  5054. */
  5055. function addClass (el, cls) {
  5056. /* istanbul ignore if */
  5057. if (!cls || !(cls = cls.trim())) {
  5058. return
  5059. }
  5060. /* istanbul ignore else */
  5061. if (el.classList) {
  5062. if (cls.indexOf(' ') > -1) {
  5063. cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
  5064. } else {
  5065. el.classList.add(cls);
  5066. }
  5067. } else {
  5068. var cur = " " + (el.getAttribute('class') || '') + " ";
  5069. if (cur.indexOf(' ' + cls + ' ') < 0) {
  5070. el.setAttribute('class', (cur + cls).trim());
  5071. }
  5072. }
  5073. }
  5074. /**
  5075. * Remove class with compatibility for SVG since classList is not supported on
  5076. * SVG elements in IE
  5077. */
  5078. function removeClass (el, cls) {
  5079. /* istanbul ignore if */
  5080. if (!cls || !(cls = cls.trim())) {
  5081. return
  5082. }
  5083. /* istanbul ignore else */
  5084. if (el.classList) {
  5085. if (cls.indexOf(' ') > -1) {
  5086. cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
  5087. } else {
  5088. el.classList.remove(cls);
  5089. }
  5090. } else {
  5091. var cur = " " + (el.getAttribute('class') || '') + " ";
  5092. var tar = ' ' + cls + ' ';
  5093. while (cur.indexOf(tar) >= 0) {
  5094. cur = cur.replace(tar, ' ');
  5095. }
  5096. el.setAttribute('class', cur.trim());
  5097. }
  5098. }
  5099. /* */
  5100. function resolveTransition (def$$1) {
  5101. if (!def$$1) {
  5102. return
  5103. }
  5104. /* istanbul ignore else */
  5105. if (typeof def$$1 === 'object') {
  5106. var res = {};
  5107. if (def$$1.css !== false) {
  5108. extend(res, autoCssTransition(def$$1.name || 'v'));
  5109. }
  5110. extend(res, def$$1);
  5111. return res
  5112. } else if (typeof def$$1 === 'string') {
  5113. return autoCssTransition(def$$1)
  5114. }
  5115. }
  5116. var autoCssTransition = cached(function (name) {
  5117. return {
  5118. enterClass: (name + "-enter"),
  5119. enterToClass: (name + "-enter-to"),
  5120. enterActiveClass: (name + "-enter-active"),
  5121. leaveClass: (name + "-leave"),
  5122. leaveToClass: (name + "-leave-to"),
  5123. leaveActiveClass: (name + "-leave-active")
  5124. }
  5125. });
  5126. var hasTransition = inBrowser && !isIE9;
  5127. var TRANSITION = 'transition';
  5128. var ANIMATION = 'animation';
  5129. // Transition property/event sniffing
  5130. var transitionProp = 'transition';
  5131. var transitionEndEvent = 'transitionend';
  5132. var animationProp = 'animation';
  5133. var animationEndEvent = 'animationend';
  5134. if (hasTransition) {
  5135. /* istanbul ignore if */
  5136. if (window.ontransitionend === undefined &&
  5137. window.onwebkittransitionend !== undefined) {
  5138. transitionProp = 'WebkitTransition';
  5139. transitionEndEvent = 'webkitTransitionEnd';
  5140. }
  5141. if (window.onanimationend === undefined &&
  5142. window.onwebkitanimationend !== undefined) {
  5143. animationProp = 'WebkitAnimation';
  5144. animationEndEvent = 'webkitAnimationEnd';
  5145. }
  5146. }
  5147. // binding to window is necessary to make hot reload work in IE in strict mode
  5148. var raf = inBrowser && window.requestAnimationFrame
  5149. ? window.requestAnimationFrame.bind(window)
  5150. : setTimeout;
  5151. function nextFrame (fn) {
  5152. raf(function () {
  5153. raf(fn);
  5154. });
  5155. }
  5156. function addTransitionClass (el, cls) {
  5157. (el._transitionClasses || (el._transitionClasses = [])).push(cls);
  5158. addClass(el, cls);
  5159. }
  5160. function removeTransitionClass (el, cls) {
  5161. if (el._transitionClasses) {
  5162. remove(el._transitionClasses, cls);
  5163. }
  5164. removeClass(el, cls);
  5165. }
  5166. function whenTransitionEnds (
  5167. el,
  5168. expectedType,
  5169. cb
  5170. ) {
  5171. var ref = getTransitionInfo(el, expectedType);
  5172. var type = ref.type;
  5173. var timeout = ref.timeout;
  5174. var propCount = ref.propCount;
  5175. if (!type) { return cb() }
  5176. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  5177. var ended = 0;
  5178. var end = function () {
  5179. el.removeEventListener(event, onEnd);
  5180. cb();
  5181. };
  5182. var onEnd = function (e) {
  5183. if (e.target === el) {
  5184. if (++ended >= propCount) {
  5185. end();
  5186. }
  5187. }
  5188. };
  5189. setTimeout(function () {
  5190. if (ended < propCount) {
  5191. end();
  5192. }
  5193. }, timeout + 1);
  5194. el.addEventListener(event, onEnd);
  5195. }
  5196. var transformRE = /\b(transform|all)(,|$)/;
  5197. function getTransitionInfo (el, expectedType) {
  5198. var styles = window.getComputedStyle(el);
  5199. var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
  5200. var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
  5201. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  5202. var animationDelays = styles[animationProp + 'Delay'].split(', ');
  5203. var animationDurations = styles[animationProp + 'Duration'].split(', ');
  5204. var animationTimeout = getTimeout(animationDelays, animationDurations);
  5205. var type;
  5206. var timeout = 0;
  5207. var propCount = 0;
  5208. /* istanbul ignore if */
  5209. if (expectedType === TRANSITION) {
  5210. if (transitionTimeout > 0) {
  5211. type = TRANSITION;
  5212. timeout = transitionTimeout;
  5213. propCount = transitionDurations.length;
  5214. }
  5215. } else if (expectedType === ANIMATION) {
  5216. if (animationTimeout > 0) {
  5217. type = ANIMATION;
  5218. timeout = animationTimeout;
  5219. propCount = animationDurations.length;
  5220. }
  5221. } else {
  5222. timeout = Math.max(transitionTimeout, animationTimeout);
  5223. type = timeout > 0
  5224. ? transitionTimeout > animationTimeout
  5225. ? TRANSITION
  5226. : ANIMATION
  5227. : null;
  5228. propCount = type
  5229. ? type === TRANSITION
  5230. ? transitionDurations.length
  5231. : animationDurations.length
  5232. : 0;
  5233. }
  5234. var hasTransform =
  5235. type === TRANSITION &&
  5236. transformRE.test(styles[transitionProp + 'Property']);
  5237. return {
  5238. type: type,
  5239. timeout: timeout,
  5240. propCount: propCount,
  5241. hasTransform: hasTransform
  5242. }
  5243. }
  5244. function getTimeout (delays, durations) {
  5245. /* istanbul ignore next */
  5246. while (delays.length < durations.length) {
  5247. delays = delays.concat(delays);
  5248. }
  5249. return Math.max.apply(null, durations.map(function (d, i) {
  5250. return toMs(d) + toMs(delays[i])
  5251. }))
  5252. }
  5253. function toMs (s) {
  5254. return Number(s.slice(0, -1)) * 1000
  5255. }
  5256. /* */
  5257. function enter (vnode, toggleDisplay) {
  5258. var el = vnode.elm;
  5259. // call leave callback now
  5260. if (el._leaveCb) {
  5261. el._leaveCb.cancelled = true;
  5262. el._leaveCb();
  5263. }
  5264. var data = resolveTransition(vnode.data.transition);
  5265. if (!data) {
  5266. return
  5267. }
  5268. /* istanbul ignore if */
  5269. if (el._enterCb || el.nodeType !== 1) {
  5270. return
  5271. }
  5272. var css = data.css;
  5273. var type = data.type;
  5274. var enterClass = data.enterClass;
  5275. var enterToClass = data.enterToClass;
  5276. var enterActiveClass = data.enterActiveClass;
  5277. var appearClass = data.appearClass;
  5278. var appearToClass = data.appearToClass;
  5279. var appearActiveClass = data.appearActiveClass;
  5280. var beforeEnter = data.beforeEnter;
  5281. var enter = data.enter;
  5282. var afterEnter = data.afterEnter;
  5283. var enterCancelled = data.enterCancelled;
  5284. var beforeAppear = data.beforeAppear;
  5285. var appear = data.appear;
  5286. var afterAppear = data.afterAppear;
  5287. var appearCancelled = data.appearCancelled;
  5288. var duration = data.duration;
  5289. // activeInstance will always be the <transition> component managing this
  5290. // transition. One edge case to check is when the <transition> is placed
  5291. // as the root node of a child component. In that case we need to check
  5292. // <transition>'s parent for appear check.
  5293. var context = activeInstance;
  5294. var transitionNode = activeInstance.$vnode;
  5295. while (transitionNode && transitionNode.parent) {
  5296. transitionNode = transitionNode.parent;
  5297. context = transitionNode.context;
  5298. }
  5299. var isAppear = !context._isMounted || !vnode.isRootInsert;
  5300. if (isAppear && !appear && appear !== '') {
  5301. return
  5302. }
  5303. var startClass = isAppear && appearClass
  5304. ? appearClass
  5305. : enterClass;
  5306. var activeClass = isAppear && appearActiveClass
  5307. ? appearActiveClass
  5308. : enterActiveClass;
  5309. var toClass = isAppear && appearToClass
  5310. ? appearToClass
  5311. : enterToClass;
  5312. var beforeEnterHook = isAppear
  5313. ? (beforeAppear || beforeEnter)
  5314. : beforeEnter;
  5315. var enterHook = isAppear
  5316. ? (typeof appear === 'function' ? appear : enter)
  5317. : enter;
  5318. var afterEnterHook = isAppear
  5319. ? (afterAppear || afterEnter)
  5320. : afterEnter;
  5321. var enterCancelledHook = isAppear
  5322. ? (appearCancelled || enterCancelled)
  5323. : enterCancelled;
  5324. var explicitEnterDuration = toNumber(
  5325. isObject(duration)
  5326. ? duration.enter
  5327. : duration
  5328. );
  5329. if (process.env.NODE_ENV !== 'production' && explicitEnterDuration != null) {
  5330. checkDuration(explicitEnterDuration, 'enter', vnode);
  5331. }
  5332. var expectsCSS = css !== false && !isIE9;
  5333. var userWantsControl = getHookArgumentsLength(enterHook);
  5334. var cb = el._enterCb = once(function () {
  5335. if (expectsCSS) {
  5336. removeTransitionClass(el, toClass);
  5337. removeTransitionClass(el, activeClass);
  5338. }
  5339. if (cb.cancelled) {
  5340. if (expectsCSS) {
  5341. removeTransitionClass(el, startClass);
  5342. }
  5343. enterCancelledHook && enterCancelledHook(el);
  5344. } else {
  5345. afterEnterHook && afterEnterHook(el);
  5346. }
  5347. el._enterCb = null;
  5348. });
  5349. if (!vnode.data.show) {
  5350. // remove pending leave element on enter by injecting an insert hook
  5351. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
  5352. var parent = el.parentNode;
  5353. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  5354. if (pendingNode &&
  5355. pendingNode.tag === vnode.tag &&
  5356. pendingNode.elm._leaveCb) {
  5357. pendingNode.elm._leaveCb();
  5358. }
  5359. enterHook && enterHook(el, cb);
  5360. });
  5361. }
  5362. // start enter transition
  5363. beforeEnterHook && beforeEnterHook(el);
  5364. if (expectsCSS) {
  5365. addTransitionClass(el, startClass);
  5366. addTransitionClass(el, activeClass);
  5367. nextFrame(function () {
  5368. addTransitionClass(el, toClass);
  5369. removeTransitionClass(el, startClass);
  5370. if (!cb.cancelled && !userWantsControl) {
  5371. if (isValidDuration(explicitEnterDuration)) {
  5372. setTimeout(cb, explicitEnterDuration);
  5373. } else {
  5374. whenTransitionEnds(el, type, cb);
  5375. }
  5376. }
  5377. });
  5378. }
  5379. if (vnode.data.show) {
  5380. toggleDisplay && toggleDisplay();
  5381. enterHook && enterHook(el, cb);
  5382. }
  5383. if (!expectsCSS && !userWantsControl) {
  5384. cb();
  5385. }
  5386. }
  5387. function leave (vnode, rm) {
  5388. var el = vnode.elm;
  5389. // call enter callback now
  5390. if (el._enterCb) {
  5391. el._enterCb.cancelled = true;
  5392. el._enterCb();
  5393. }
  5394. var data = resolveTransition(vnode.data.transition);
  5395. if (!data) {
  5396. return rm()
  5397. }
  5398. /* istanbul ignore if */
  5399. if (el._leaveCb || el.nodeType !== 1) {
  5400. return
  5401. }
  5402. var css = data.css;
  5403. var type = data.type;
  5404. var leaveClass = data.leaveClass;
  5405. var leaveToClass = data.leaveToClass;
  5406. var leaveActiveClass = data.leaveActiveClass;
  5407. var beforeLeave = data.beforeLeave;
  5408. var leave = data.leave;
  5409. var afterLeave = data.afterLeave;
  5410. var leaveCancelled = data.leaveCancelled;
  5411. var delayLeave = data.delayLeave;
  5412. var duration = data.duration;
  5413. var expectsCSS = css !== false && !isIE9;
  5414. var userWantsControl = getHookArgumentsLength(leave);
  5415. var explicitLeaveDuration = toNumber(
  5416. isObject(duration)
  5417. ? duration.leave
  5418. : duration
  5419. );
  5420. if (process.env.NODE_ENV !== 'production' && explicitLeaveDuration != null) {
  5421. checkDuration(explicitLeaveDuration, 'leave', vnode);
  5422. }
  5423. var cb = el._leaveCb = once(function () {
  5424. if (el.parentNode && el.parentNode._pending) {
  5425. el.parentNode._pending[vnode.key] = null;
  5426. }
  5427. if (expectsCSS) {
  5428. removeTransitionClass(el, leaveToClass);
  5429. removeTransitionClass(el, leaveActiveClass);
  5430. }
  5431. if (cb.cancelled) {
  5432. if (expectsCSS) {
  5433. removeTransitionClass(el, leaveClass);
  5434. }
  5435. leaveCancelled && leaveCancelled(el);
  5436. } else {
  5437. rm();
  5438. afterLeave && afterLeave(el);
  5439. }
  5440. el._leaveCb = null;
  5441. });
  5442. if (delayLeave) {
  5443. delayLeave(performLeave);
  5444. } else {
  5445. performLeave();
  5446. }
  5447. function performLeave () {
  5448. // the delayed leave may have already been cancelled
  5449. if (cb.cancelled) {
  5450. return
  5451. }
  5452. // record leaving element
  5453. if (!vnode.data.show) {
  5454. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
  5455. }
  5456. beforeLeave && beforeLeave(el);
  5457. if (expectsCSS) {
  5458. addTransitionClass(el, leaveClass);
  5459. addTransitionClass(el, leaveActiveClass);
  5460. nextFrame(function () {
  5461. addTransitionClass(el, leaveToClass);
  5462. removeTransitionClass(el, leaveClass);
  5463. if (!cb.cancelled && !userWantsControl) {
  5464. if (isValidDuration(explicitLeaveDuration)) {
  5465. setTimeout(cb, explicitLeaveDuration);
  5466. } else {
  5467. whenTransitionEnds(el, type, cb);
  5468. }
  5469. }
  5470. });
  5471. }
  5472. leave && leave(el, cb);
  5473. if (!expectsCSS && !userWantsControl) {
  5474. cb();
  5475. }
  5476. }
  5477. }
  5478. // only used in dev mode
  5479. function checkDuration (val, name, vnode) {
  5480. if (typeof val !== 'number') {
  5481. warn(
  5482. "<transition> explicit " + name + " duration is not a valid number - " +
  5483. "got " + (JSON.stringify(val)) + ".",
  5484. vnode.context
  5485. );
  5486. } else if (isNaN(val)) {
  5487. warn(
  5488. "<transition> explicit " + name + " duration is NaN - " +
  5489. 'the duration expression might be incorrect.',
  5490. vnode.context
  5491. );
  5492. }
  5493. }
  5494. function isValidDuration (val) {
  5495. return typeof val === 'number' && !isNaN(val)
  5496. }
  5497. /**
  5498. * Normalize a transition hook's argument length. The hook may be:
  5499. * - a merged hook (invoker) with the original in .fns
  5500. * - a wrapped component method (check ._length)
  5501. * - a plain function (.length)
  5502. */
  5503. function getHookArgumentsLength (fn) {
  5504. if (!fn) { return false }
  5505. var invokerFns = fn.fns;
  5506. if (invokerFns) {
  5507. // invoker
  5508. return getHookArgumentsLength(
  5509. Array.isArray(invokerFns)
  5510. ? invokerFns[0]
  5511. : invokerFns
  5512. )
  5513. } else {
  5514. return (fn._length || fn.length) > 1
  5515. }
  5516. }
  5517. function _enter (_, vnode) {
  5518. if (!vnode.data.show) {
  5519. enter(vnode);
  5520. }
  5521. }
  5522. var transition = inBrowser ? {
  5523. create: _enter,
  5524. activate: _enter,
  5525. remove: function remove$$1 (vnode, rm) {
  5526. /* istanbul ignore else */
  5527. if (!vnode.data.show) {
  5528. leave(vnode, rm);
  5529. } else {
  5530. rm();
  5531. }
  5532. }
  5533. } : {};
  5534. var platformModules = [
  5535. attrs,
  5536. klass,
  5537. events,
  5538. domProps,
  5539. style,
  5540. transition
  5541. ];
  5542. /* */
  5543. // the directive module should be applied last, after all
  5544. // built-in modules have been applied.
  5545. var modules = platformModules.concat(baseModules);
  5546. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  5547. /**
  5548. * Not type checking this file because flow doesn't like attaching
  5549. * properties to Elements.
  5550. */
  5551. /* istanbul ignore if */
  5552. if (isIE9) {
  5553. // http://www.matts411.com/post/internet-explorer-9-oninput/
  5554. document.addEventListener('selectionchange', function () {
  5555. var el = document.activeElement;
  5556. if (el && el.vmodel) {
  5557. trigger(el, 'input');
  5558. }
  5559. });
  5560. }
  5561. var model$1 = {
  5562. inserted: function inserted (el, binding, vnode) {
  5563. if (vnode.tag === 'select') {
  5564. var cb = function () {
  5565. setSelected(el, binding, vnode.context);
  5566. };
  5567. cb();
  5568. /* istanbul ignore if */
  5569. if (isIE || isEdge) {
  5570. setTimeout(cb, 0);
  5571. }
  5572. } else if (vnode.tag === 'textarea' || el.type === 'text') {
  5573. el._vModifiers = binding.modifiers;
  5574. if (!binding.modifiers.lazy) {
  5575. if (!isAndroid) {
  5576. el.addEventListener('compositionstart', onCompositionStart);
  5577. el.addEventListener('compositionend', onCompositionEnd);
  5578. }
  5579. /* istanbul ignore if */
  5580. if (isIE9) {
  5581. el.vmodel = true;
  5582. }
  5583. }
  5584. }
  5585. },
  5586. componentUpdated: function componentUpdated (el, binding, vnode) {
  5587. if (vnode.tag === 'select') {
  5588. setSelected(el, binding, vnode.context);
  5589. // in case the options rendered by v-for have changed,
  5590. // it's possible that the value is out-of-sync with the rendered options.
  5591. // detect such cases and filter out values that no longer has a matching
  5592. // option in the DOM.
  5593. var needReset = el.multiple
  5594. ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
  5595. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
  5596. if (needReset) {
  5597. trigger(el, 'change');
  5598. }
  5599. }
  5600. }
  5601. };
  5602. function setSelected (el, binding, vm) {
  5603. var value = binding.value;
  5604. var isMultiple = el.multiple;
  5605. if (isMultiple && !Array.isArray(value)) {
  5606. process.env.NODE_ENV !== 'production' && warn(
  5607. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  5608. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  5609. vm
  5610. );
  5611. return
  5612. }
  5613. var selected, option;
  5614. for (var i = 0, l = el.options.length; i < l; i++) {
  5615. option = el.options[i];
  5616. if (isMultiple) {
  5617. selected = looseIndexOf(value, getValue(option)) > -1;
  5618. if (option.selected !== selected) {
  5619. option.selected = selected;
  5620. }
  5621. } else {
  5622. if (looseEqual(getValue(option), value)) {
  5623. if (el.selectedIndex !== i) {
  5624. el.selectedIndex = i;
  5625. }
  5626. return
  5627. }
  5628. }
  5629. }
  5630. if (!isMultiple) {
  5631. el.selectedIndex = -1;
  5632. }
  5633. }
  5634. function hasNoMatchingOption (value, options) {
  5635. for (var i = 0, l = options.length; i < l; i++) {
  5636. if (looseEqual(getValue(options[i]), value)) {
  5637. return false
  5638. }
  5639. }
  5640. return true
  5641. }
  5642. function getValue (option) {
  5643. return '_value' in option
  5644. ? option._value
  5645. : option.value
  5646. }
  5647. function onCompositionStart (e) {
  5648. e.target.composing = true;
  5649. }
  5650. function onCompositionEnd (e) {
  5651. e.target.composing = false;
  5652. trigger(e.target, 'input');
  5653. }
  5654. function trigger (el, type) {
  5655. var e = document.createEvent('HTMLEvents');
  5656. e.initEvent(type, true, true);
  5657. el.dispatchEvent(e);
  5658. }
  5659. /* */
  5660. // recursively search for possible transition defined inside the component root
  5661. function locateNode (vnode) {
  5662. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  5663. ? locateNode(vnode.componentInstance._vnode)
  5664. : vnode
  5665. }
  5666. var show = {
  5667. bind: function bind (el, ref, vnode) {
  5668. var value = ref.value;
  5669. vnode = locateNode(vnode);
  5670. var transition = vnode.data && vnode.data.transition;
  5671. var originalDisplay = el.__vOriginalDisplay =
  5672. el.style.display === 'none' ? '' : el.style.display;
  5673. if (value && transition && !isIE9) {
  5674. vnode.data.show = true;
  5675. enter(vnode, function () {
  5676. el.style.display = originalDisplay;
  5677. });
  5678. } else {
  5679. el.style.display = value ? originalDisplay : 'none';
  5680. }
  5681. },
  5682. update: function update (el, ref, vnode) {
  5683. var value = ref.value;
  5684. var oldValue = ref.oldValue;
  5685. /* istanbul ignore if */
  5686. if (value === oldValue) { return }
  5687. vnode = locateNode(vnode);
  5688. var transition = vnode.data && vnode.data.transition;
  5689. if (transition && !isIE9) {
  5690. vnode.data.show = true;
  5691. if (value) {
  5692. enter(vnode, function () {
  5693. el.style.display = el.__vOriginalDisplay;
  5694. });
  5695. } else {
  5696. leave(vnode, function () {
  5697. el.style.display = 'none';
  5698. });
  5699. }
  5700. } else {
  5701. el.style.display = value ? el.__vOriginalDisplay : 'none';
  5702. }
  5703. },
  5704. unbind: function unbind (
  5705. el,
  5706. binding,
  5707. vnode,
  5708. oldVnode,
  5709. isDestroy
  5710. ) {
  5711. if (!isDestroy) {
  5712. el.style.display = el.__vOriginalDisplay;
  5713. }
  5714. }
  5715. };
  5716. var platformDirectives = {
  5717. model: model$1,
  5718. show: show
  5719. };
  5720. /* */
  5721. // Provides transition support for a single element/component.
  5722. // supports transition mode (out-in / in-out)
  5723. var transitionProps = {
  5724. name: String,
  5725. appear: Boolean,
  5726. css: Boolean,
  5727. mode: String,
  5728. type: String,
  5729. enterClass: String,
  5730. leaveClass: String,
  5731. enterToClass: String,
  5732. leaveToClass: String,
  5733. enterActiveClass: String,
  5734. leaveActiveClass: String,
  5735. appearClass: String,
  5736. appearActiveClass: String,
  5737. appearToClass: String,
  5738. duration: [Number, String, Object]
  5739. };
  5740. // in case the child is also an abstract component, e.g. <keep-alive>
  5741. // we want to recursively retrieve the real component to be rendered
  5742. function getRealChild (vnode) {
  5743. var compOptions = vnode && vnode.componentOptions;
  5744. if (compOptions && compOptions.Ctor.options.abstract) {
  5745. return getRealChild(getFirstComponentChild(compOptions.children))
  5746. } else {
  5747. return vnode
  5748. }
  5749. }
  5750. function extractTransitionData (comp) {
  5751. var data = {};
  5752. var options = comp.$options;
  5753. // props
  5754. for (var key in options.propsData) {
  5755. data[key] = comp[key];
  5756. }
  5757. // events.
  5758. // extract listeners and pass them directly to the transition methods
  5759. var listeners = options._parentListeners;
  5760. for (var key$1 in listeners) {
  5761. data[camelize(key$1)] = listeners[key$1];
  5762. }
  5763. return data
  5764. }
  5765. function placeholder (h, rawChild) {
  5766. return /\d-keep-alive$/.test(rawChild.tag)
  5767. ? h('keep-alive')
  5768. : null
  5769. }
  5770. function hasParentTransition (vnode) {
  5771. while ((vnode = vnode.parent)) {
  5772. if (vnode.data.transition) {
  5773. return true
  5774. }
  5775. }
  5776. }
  5777. function isSameChild (child, oldChild) {
  5778. return oldChild.key === child.key && oldChild.tag === child.tag
  5779. }
  5780. var Transition = {
  5781. name: 'transition',
  5782. props: transitionProps,
  5783. abstract: true,
  5784. render: function render (h) {
  5785. var this$1 = this;
  5786. var children = this.$slots.default;
  5787. if (!children) {
  5788. return
  5789. }
  5790. // filter out text nodes (possible whitespaces)
  5791. children = children.filter(function (c) { return c.tag; });
  5792. /* istanbul ignore if */
  5793. if (!children.length) {
  5794. return
  5795. }
  5796. // warn multiple elements
  5797. if (process.env.NODE_ENV !== 'production' && children.length > 1) {
  5798. warn(
  5799. '<transition> can only be used on a single element. Use ' +
  5800. '<transition-group> for lists.',
  5801. this.$parent
  5802. );
  5803. }
  5804. var mode = this.mode;
  5805. // warn invalid mode
  5806. if (process.env.NODE_ENV !== 'production' &&
  5807. mode && mode !== 'in-out' && mode !== 'out-in') {
  5808. warn(
  5809. 'invalid <transition> mode: ' + mode,
  5810. this.$parent
  5811. );
  5812. }
  5813. var rawChild = children[0];
  5814. // if this is a component root node and the component's
  5815. // parent container node also has transition, skip.
  5816. if (hasParentTransition(this.$vnode)) {
  5817. return rawChild
  5818. }
  5819. // apply transition data to child
  5820. // use getRealChild() to ignore abstract components e.g. keep-alive
  5821. var child = getRealChild(rawChild);
  5822. /* istanbul ignore if */
  5823. if (!child) {
  5824. return rawChild
  5825. }
  5826. if (this._leaving) {
  5827. return placeholder(h, rawChild)
  5828. }
  5829. // ensure a key that is unique to the vnode type and to this transition
  5830. // component instance. This key will be used to remove pending leaving nodes
  5831. // during entering.
  5832. var id = "__transition-" + (this._uid) + "-";
  5833. child.key = child.key == null
  5834. ? id + child.tag
  5835. : isPrimitive(child.key)
  5836. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  5837. : child.key;
  5838. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  5839. var oldRawChild = this._vnode;
  5840. var oldChild = getRealChild(oldRawChild);
  5841. // mark v-show
  5842. // so that the transition module can hand over the control to the directive
  5843. if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
  5844. child.data.show = true;
  5845. }
  5846. if (oldChild && oldChild.data && !isSameChild(child, oldChild)) {
  5847. // replace old child transition data with fresh one
  5848. // important for dynamic transitions!
  5849. var oldData = oldChild && (oldChild.data.transition = extend({}, data));
  5850. // handle transition mode
  5851. if (mode === 'out-in') {
  5852. // return placeholder node and queue update when leave finishes
  5853. this._leaving = true;
  5854. mergeVNodeHook(oldData, 'afterLeave', function () {
  5855. this$1._leaving = false;
  5856. this$1.$forceUpdate();
  5857. });
  5858. return placeholder(h, rawChild)
  5859. } else if (mode === 'in-out') {
  5860. var delayedLeave;
  5861. var performLeave = function () { delayedLeave(); };
  5862. mergeVNodeHook(data, 'afterEnter', performLeave);
  5863. mergeVNodeHook(data, 'enterCancelled', performLeave);
  5864. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  5865. }
  5866. }
  5867. return rawChild
  5868. }
  5869. };
  5870. /* */
  5871. // Provides transition support for list items.
  5872. // supports move transitions using the FLIP technique.
  5873. // Because the vdom's children update algorithm is "unstable" - i.e.
  5874. // it doesn't guarantee the relative positioning of removed elements,
  5875. // we force transition-group to update its children into two passes:
  5876. // in the first pass, we remove all nodes that need to be removed,
  5877. // triggering their leaving transition; in the second pass, we insert/move
  5878. // into the final desired state. This way in the second pass removed
  5879. // nodes will remain where they should be.
  5880. var props = extend({
  5881. tag: String,
  5882. moveClass: String
  5883. }, transitionProps);
  5884. delete props.mode;
  5885. var TransitionGroup = {
  5886. props: props,
  5887. render: function render (h) {
  5888. var tag = this.tag || this.$vnode.data.tag || 'span';
  5889. var map = Object.create(null);
  5890. var prevChildren = this.prevChildren = this.children;
  5891. var rawChildren = this.$slots.default || [];
  5892. var children = this.children = [];
  5893. var transitionData = extractTransitionData(this);
  5894. for (var i = 0; i < rawChildren.length; i++) {
  5895. var c = rawChildren[i];
  5896. if (c.tag) {
  5897. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  5898. children.push(c);
  5899. map[c.key] = c
  5900. ;(c.data || (c.data = {})).transition = transitionData;
  5901. } else if (process.env.NODE_ENV !== 'production') {
  5902. var opts = c.componentOptions;
  5903. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  5904. warn(("<transition-group> children must be keyed: <" + name + ">"));
  5905. }
  5906. }
  5907. }
  5908. if (prevChildren) {
  5909. var kept = [];
  5910. var removed = [];
  5911. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  5912. var c$1 = prevChildren[i$1];
  5913. c$1.data.transition = transitionData;
  5914. c$1.data.pos = c$1.elm.getBoundingClientRect();
  5915. if (map[c$1.key]) {
  5916. kept.push(c$1);
  5917. } else {
  5918. removed.push(c$1);
  5919. }
  5920. }
  5921. this.kept = h(tag, null, kept);
  5922. this.removed = removed;
  5923. }
  5924. return h(tag, null, children)
  5925. },
  5926. beforeUpdate: function beforeUpdate () {
  5927. // force removing pass
  5928. this.__patch__(
  5929. this._vnode,
  5930. this.kept,
  5931. false, // hydrating
  5932. true // removeOnly (!important, avoids unnecessary moves)
  5933. );
  5934. this._vnode = this.kept;
  5935. },
  5936. updated: function updated () {
  5937. var children = this.prevChildren;
  5938. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  5939. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  5940. return
  5941. }
  5942. // we divide the work into three loops to avoid mixing DOM reads and writes
  5943. // in each iteration - which helps prevent layout thrashing.
  5944. children.forEach(callPendingCbs);
  5945. children.forEach(recordPosition);
  5946. children.forEach(applyTranslation);
  5947. // force reflow to put everything in position
  5948. var body = document.body;
  5949. var f = body.offsetHeight; // eslint-disable-line
  5950. children.forEach(function (c) {
  5951. if (c.data.moved) {
  5952. var el = c.elm;
  5953. var s = el.style;
  5954. addTransitionClass(el, moveClass);
  5955. s.transform = s.WebkitTransform = s.transitionDuration = '';
  5956. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  5957. if (!e || /transform$/.test(e.propertyName)) {
  5958. el.removeEventListener(transitionEndEvent, cb);
  5959. el._moveCb = null;
  5960. removeTransitionClass(el, moveClass);
  5961. }
  5962. });
  5963. }
  5964. });
  5965. },
  5966. methods: {
  5967. hasMove: function hasMove (el, moveClass) {
  5968. /* istanbul ignore if */
  5969. if (!hasTransition) {
  5970. return false
  5971. }
  5972. if (this._hasMove != null) {
  5973. return this._hasMove
  5974. }
  5975. // Detect whether an element with the move class applied has
  5976. // CSS transitions. Since the element may be inside an entering
  5977. // transition at this very moment, we make a clone of it and remove
  5978. // all other transition classes applied to ensure only the move class
  5979. // is applied.
  5980. var clone = el.cloneNode();
  5981. if (el._transitionClasses) {
  5982. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  5983. }
  5984. addClass(clone, moveClass);
  5985. clone.style.display = 'none';
  5986. this.$el.appendChild(clone);
  5987. var info = getTransitionInfo(clone);
  5988. this.$el.removeChild(clone);
  5989. return (this._hasMove = info.hasTransform)
  5990. }
  5991. }
  5992. };
  5993. function callPendingCbs (c) {
  5994. /* istanbul ignore if */
  5995. if (c.elm._moveCb) {
  5996. c.elm._moveCb();
  5997. }
  5998. /* istanbul ignore if */
  5999. if (c.elm._enterCb) {
  6000. c.elm._enterCb();
  6001. }
  6002. }
  6003. function recordPosition (c) {
  6004. c.data.newPos = c.elm.getBoundingClientRect();
  6005. }
  6006. function applyTranslation (c) {
  6007. var oldPos = c.data.pos;
  6008. var newPos = c.data.newPos;
  6009. var dx = oldPos.left - newPos.left;
  6010. var dy = oldPos.top - newPos.top;
  6011. if (dx || dy) {
  6012. c.data.moved = true;
  6013. var s = c.elm.style;
  6014. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  6015. s.transitionDuration = '0s';
  6016. }
  6017. }
  6018. var platformComponents = {
  6019. Transition: Transition,
  6020. TransitionGroup: TransitionGroup
  6021. };
  6022. /* */
  6023. // install platform specific utils
  6024. Vue$2.config.mustUseProp = mustUseProp;
  6025. Vue$2.config.isReservedTag = isReservedTag;
  6026. Vue$2.config.getTagNamespace = getTagNamespace;
  6027. Vue$2.config.isUnknownElement = isUnknownElement;
  6028. // install platform runtime directives & components
  6029. extend(Vue$2.options.directives, platformDirectives);
  6030. extend(Vue$2.options.components, platformComponents);
  6031. // install platform patch function
  6032. Vue$2.prototype.__patch__ = inBrowser ? patch : noop;
  6033. // public mount method
  6034. Vue$2.prototype.$mount = function (
  6035. el,
  6036. hydrating
  6037. ) {
  6038. el = el && inBrowser ? query(el) : undefined;
  6039. return mountComponent(this, el, hydrating)
  6040. };
  6041. // devtools global hook
  6042. /* istanbul ignore next */
  6043. setTimeout(function () {
  6044. if (config.devtools) {
  6045. if (devtools) {
  6046. devtools.emit('init', Vue$2);
  6047. } else if (process.env.NODE_ENV !== 'production' && isChrome) {
  6048. console[console.info ? 'info' : 'log'](
  6049. 'Download the Vue Devtools extension for a better development experience:\n' +
  6050. 'https://github.com/vuejs/vue-devtools'
  6051. );
  6052. }
  6053. }
  6054. if (process.env.NODE_ENV !== 'production' &&
  6055. config.productionTip !== false &&
  6056. inBrowser && typeof console !== 'undefined') {
  6057. console[console.info ? 'info' : 'log'](
  6058. "You are running Vue in development mode.\n" +
  6059. "Make sure to turn on production mode when deploying for production.\n" +
  6060. "See more tips at https://vuejs.org/guide/deployment.html"
  6061. );
  6062. }
  6063. }, 0);
  6064. module.exports = Vue$2;