index.js 135 KB

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