vue.runtime.common.js 149 KB

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