vue.common.js 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710
  1. 'use strict';
  2. /**
  3. * Convert a value to a string that is actually rendered.
  4. */
  5. function _toString(val) {
  6. return val == null ? '' : typeof val === 'object' ? JSON.stringify(val, null, 2) : String(val);
  7. }
  8. /**
  9. * Convert a input value to a number for persistence.
  10. * If the conversion fails, return original string.
  11. */
  12. function toNumber(val) {
  13. var n = parseFloat(val, 10);
  14. return n || n === 0 ? n : val;
  15. }
  16. /**
  17. * Make a map and return a function for checking if a key
  18. * is in that map.
  19. */
  20. function makeMap(str, expectsLowerCase) {
  21. var map = Object.create(null);
  22. var list = str.split(',');
  23. for (var i = 0; i < list.length; i++) {
  24. map[list[i]] = true;
  25. }
  26. return expectsLowerCase ? function (val) {
  27. return map[val.toLowerCase()];
  28. } : function (val) {
  29. return map[val];
  30. };
  31. }
  32. /**
  33. * Check if a tag is a built-in tag.
  34. */
  35. var isBuiltInTag = makeMap('slot,component', true);
  36. /**
  37. * Remove an item from an array
  38. */
  39. function remove(arr, item) {
  40. if (arr.length) {
  41. var index = arr.indexOf(item);
  42. if (index > -1) {
  43. return arr.splice(index, 1);
  44. }
  45. }
  46. }
  47. /**
  48. * Check whether the object has the property.
  49. */
  50. var hasOwnProperty = Object.prototype.hasOwnProperty;
  51. function hasOwn(obj, key) {
  52. return hasOwnProperty.call(obj, key);
  53. }
  54. /**
  55. * Check if value is primitive
  56. */
  57. function isPrimitive(value) {
  58. return typeof value === 'string' || typeof value === 'number';
  59. }
  60. /**
  61. * Create a cached version of a pure function.
  62. */
  63. function cached(fn) {
  64. var cache = Object.create(null);
  65. return function cachedFn(str) {
  66. var hit = cache[str];
  67. return hit || (cache[str] = fn(str));
  68. };
  69. }
  70. /**
  71. * Camelize a hyphen-delmited string.
  72. */
  73. var camelizeRE = /-(\w)/g;
  74. var camelize = cached(function (str) {
  75. return str.replace(camelizeRE, function (_, c) {
  76. return c ? c.toUpperCase() : '';
  77. });
  78. });
  79. /**
  80. * Capitalize a string.
  81. */
  82. var capitalize = cached(function (str) {
  83. return str.charAt(0).toUpperCase() + str.slice(1);
  84. });
  85. /**
  86. * Hyphenate a camelCase string.
  87. */
  88. var hyphenateRE = /([^-])([A-Z])/g;
  89. var hyphenate = cached(function (str) {
  90. return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase();
  91. });
  92. /**
  93. * Simple bind, faster than native
  94. */
  95. function bind(fn, ctx) {
  96. function boundFn(a) {
  97. var l = arguments.length;
  98. return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
  99. }
  100. // record original fn length
  101. boundFn._length = fn.length;
  102. return boundFn;
  103. }
  104. /**
  105. * Convert an Array-like object to a real Array.
  106. */
  107. function toArray(list, start) {
  108. start = start || 0;
  109. var i = list.length - start;
  110. var ret = new Array(i);
  111. while (i--) {
  112. ret[i] = list[i + start];
  113. }
  114. return ret;
  115. }
  116. /**
  117. * Mix properties into target object.
  118. */
  119. function extend(to, _from) {
  120. for (var _key in _from) {
  121. to[_key] = _from[_key];
  122. }
  123. return to;
  124. }
  125. /**
  126. * Quick object check - this is primarily used to tell
  127. * Objects from primitive values when we know the value
  128. * is a JSON-compliant type.
  129. */
  130. function isObject(obj) {
  131. return obj !== null && typeof obj === 'object';
  132. }
  133. /**
  134. * Strict object type check. Only returns true
  135. * for plain JavaScript objects.
  136. */
  137. var toString = Object.prototype.toString;
  138. var OBJECT_STRING = '[object Object]';
  139. function isPlainObject(obj) {
  140. return toString.call(obj) === OBJECT_STRING;
  141. }
  142. /**
  143. * Merge an Array of Objects into a single Object.
  144. */
  145. function toObject(arr) {
  146. var res = arr[0] || {};
  147. for (var i = 1; i < arr.length; i++) {
  148. if (arr[i]) {
  149. extend(res, arr[i]);
  150. }
  151. }
  152. return res;
  153. }
  154. /**
  155. * Perform no operation.
  156. */
  157. function noop() {}
  158. /**
  159. * Always return false.
  160. */
  161. var no = function no() {
  162. return false;
  163. };
  164. /**
  165. * Generate a static keys string from compiler modules.
  166. */
  167. function genStaticKeys(modules) {
  168. return modules.reduce(function (keys, m) {
  169. return keys.concat(m.staticKeys || []);
  170. }, []).join(',');
  171. }
  172. var config = {
  173. /**
  174. * Option merge strategies (used in core/util/options)
  175. */
  176. optionMergeStrategies: Object.create(null),
  177. /**
  178. * Whether to suppress warnings.
  179. */
  180. silent: false,
  181. /**
  182. * Whether to enable devtools
  183. */
  184. devtools: process.env.NODE_ENV !== 'production',
  185. /**
  186. * Error handler for watcher errors
  187. */
  188. errorHandler: null,
  189. /**
  190. * Ignore certain custom elements
  191. */
  192. ignoredElements: null,
  193. /**
  194. * Custom user key aliases for v-on
  195. */
  196. keyCodes: Object.create(null),
  197. /**
  198. * Check if a tag is reserved so that it cannot be registered as a
  199. * component. This is platform-dependent and may be overwritten.
  200. */
  201. isReservedTag: no,
  202. /**
  203. * Check if a tag is an unknown element.
  204. * Platform-dependent.
  205. */
  206. isUnknownElement: no,
  207. /**
  208. * Get the namespace of an element
  209. */
  210. getTagNamespace: noop,
  211. /**
  212. * Check if an attribute must be bound using property, e.g. value
  213. * Platform-dependent.
  214. */
  215. mustUseProp: no,
  216. /**
  217. * List of asset types that a component can own.
  218. */
  219. _assetTypes: ['component', 'directive', 'filter'],
  220. /**
  221. * List of lifecycle hooks.
  222. */
  223. _lifecycleHooks: ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeDestroy', 'destroyed', 'activated', 'deactivated'],
  224. /**
  225. * Max circular updates allowed in a scheduler flush cycle.
  226. */
  227. _maxUpdateCount: 100,
  228. /**
  229. * Server rendering?
  230. */
  231. _isServer: process.env.VUE_ENV === 'server'
  232. };
  233. /**
  234. * Check if a string starts with $ or _
  235. */
  236. function isReserved(str) {
  237. var c = (str + '').charCodeAt(0);
  238. return c === 0x24 || c === 0x5F;
  239. }
  240. /**
  241. * Define a property.
  242. */
  243. function def(obj, key, val, enumerable) {
  244. Object.defineProperty(obj, key, {
  245. value: val,
  246. enumerable: !!enumerable,
  247. writable: true,
  248. configurable: true
  249. });
  250. }
  251. /**
  252. * Parse simple path.
  253. */
  254. var bailRE = /[^\w\.\$]/;
  255. function parsePath(path) {
  256. if (bailRE.test(path)) {
  257. return;
  258. } else {
  259. var _ret = function () {
  260. var segments = path.split('.');
  261. return {
  262. v: function v(obj) {
  263. for (var i = 0; i < segments.length; i++) {
  264. if (!obj) return;
  265. obj = obj[segments[i]];
  266. }
  267. return obj;
  268. }
  269. };
  270. }();
  271. if (typeof _ret === "object") return _ret.v;
  272. }
  273. }
  274. /* global MutationObserver */
  275. // can we use __proto__?
  276. var hasProto = '__proto__' in {};
  277. // Browser environment sniffing
  278. var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]';
  279. // detect devtools
  280. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  281. // UA sniffing for working around browser-specific quirks
  282. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  283. var isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA);
  284. var iosVersionMatch = UA && isIos && UA.match(/os ([\d_]+)/);
  285. var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_');
  286. // MutationObserver is unreliable in iOS 9.3 UIWebView
  287. // detecting it by checking presence of IndexedDB
  288. // ref #3027
  289. var hasMutationObserverBug = iosVersion && Number(iosVersion[0]) >= 9 && Number(iosVersion[1]) >= 3 && !window.indexedDB;
  290. /**
  291. * Defer a task to execute it asynchronously. Ideally this
  292. * should be executed as a microtask, so we leverage
  293. * MutationObserver if it's available, and fallback to
  294. * setTimeout(0).
  295. *
  296. * @param {Function} cb
  297. * @param {Object} ctx
  298. */
  299. var nextTick = function () {
  300. var callbacks = [];
  301. var pending = false;
  302. var timerFunc = void 0;
  303. function nextTickHandler() {
  304. pending = false;
  305. var copies = callbacks.slice(0);
  306. callbacks = [];
  307. for (var i = 0; i < copies.length; i++) {
  308. copies[i]();
  309. }
  310. }
  311. /* istanbul ignore else */
  312. if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
  313. (function () {
  314. var counter = 1;
  315. var observer = new MutationObserver(nextTickHandler);
  316. var textNode = document.createTextNode(String(counter));
  317. observer.observe(textNode, {
  318. characterData: true
  319. });
  320. timerFunc = function timerFunc() {
  321. counter = (counter + 1) % 2;
  322. textNode.data = String(counter);
  323. };
  324. })();
  325. } else {
  326. // webpack attempts to inject a shim for setImmediate
  327. // if it is used as a global, so we have to work around that to
  328. // avoid bundling unnecessary code.
  329. var context = inBrowser ? window : typeof global !== 'undefined' ? global : {};
  330. timerFunc = context.setImmediate || setTimeout;
  331. }
  332. return function (cb, ctx) {
  333. var func = ctx ? function () {
  334. cb.call(ctx);
  335. } : cb;
  336. callbacks.push(func);
  337. if (pending) return;
  338. pending = true;
  339. timerFunc(nextTickHandler, 0);
  340. };
  341. }();
  342. var _Set = void 0;
  343. /* istanbul ignore if */
  344. if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
  345. // use native Set when available.
  346. _Set = Set;
  347. } else {
  348. // a non-standard Set polyfill that only works with primitive keys.
  349. _Set = function () {
  350. function Set() {
  351. this.set = Object.create(null);
  352. }
  353. Set.prototype.has = function has(key) {
  354. return this.set[key] !== undefined;
  355. };
  356. Set.prototype.add = function add(key) {
  357. this.set[key] = 1;
  358. };
  359. Set.prototype.clear = function clear() {
  360. this.set = Object.create(null);
  361. };
  362. return Set;
  363. }();
  364. }
  365. var hasProxy = void 0;
  366. var proxyHandlers = void 0;
  367. var initProxy = void 0;
  368. if (process.env.NODE_ENV !== 'production') {
  369. (function () {
  370. var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__' // for Webpack/Browserify
  371. );
  372. hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
  373. proxyHandlers = {
  374. has: function has(target, key) {
  375. var has = key in target;
  376. var isAllowedGlobal = allowedGlobals(key);
  377. if (!has && !isAllowedGlobal) {
  378. warn('Trying to access non-existent property "' + key + '" while rendering. ' + 'Make sure to declare reactive data properties in the data option.', target);
  379. }
  380. return !isAllowedGlobal;
  381. }
  382. };
  383. initProxy = function initProxy(vm) {
  384. if (hasProxy) {
  385. vm._renderProxy = new Proxy(vm, proxyHandlers);
  386. } else {
  387. vm._renderProxy = vm;
  388. }
  389. };
  390. })();
  391. }
  392. var uid$2 = 0;
  393. /**
  394. * A dep is an observable that can have multiple
  395. * directives subscribing to it.
  396. */
  397. var Dep = function () {
  398. function Dep() {
  399. this.id = uid$2++;
  400. this.subs = [];
  401. }
  402. Dep.prototype.addSub = function addSub(sub) {
  403. this.subs.push(sub);
  404. };
  405. Dep.prototype.removeSub = function removeSub(sub) {
  406. remove(this.subs, sub);
  407. };
  408. Dep.prototype.depend = function depend() {
  409. if (Dep.target) {
  410. Dep.target.addDep(this);
  411. }
  412. };
  413. Dep.prototype.notify = function notify() {
  414. // stablize the subscriber list first
  415. var subs = this.subs.slice();
  416. for (var i = 0, l = subs.length; i < l; i++) {
  417. subs[i].update();
  418. }
  419. };
  420. return Dep;
  421. }();
  422. Dep.target = null;
  423. var targetStack = [];
  424. function pushTarget(_target) {
  425. if (Dep.target) targetStack.push(Dep.target);
  426. Dep.target = _target;
  427. }
  428. function popTarget() {
  429. Dep.target = targetStack.pop();
  430. }
  431. var queue = [];
  432. var has = {};
  433. var circular = {};
  434. var waiting = false;
  435. var flushing = false;
  436. var index = 0;
  437. /**
  438. * Reset the scheduler's state.
  439. */
  440. function resetSchedulerState() {
  441. queue.length = 0;
  442. has = {};
  443. if (process.env.NODE_ENV !== 'production') {
  444. circular = {};
  445. }
  446. waiting = flushing = false;
  447. }
  448. /**
  449. * Flush both queues and run the watchers.
  450. */
  451. function flushSchedulerQueue() {
  452. flushing = true;
  453. // Sort queue before flush.
  454. // This ensures that:
  455. // 1. Components are updated from parent to child. (because parent is always
  456. // created before the child)
  457. // 2. A component's user watchers are run before its render watcher (because
  458. // user watchers are created before the render watcher)
  459. // 3. If a component is destroyed during a parent component's watcher run,
  460. // its watchers can be skipped.
  461. queue.sort(function (a, b) {
  462. return a.id - b.id;
  463. });
  464. // do not cache length because more watchers might be pushed
  465. // as we run existing watchers
  466. for (index = 0; index < queue.length; index++) {
  467. var watcher = queue[index];
  468. var id = watcher.id;
  469. has[id] = null;
  470. watcher.run();
  471. // in dev build, check and stop circular updates.
  472. if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  473. circular[id] = (circular[id] || 0) + 1;
  474. if (circular[id] > config._maxUpdateCount) {
  475. warn('You may have an infinite update loop ' + (watcher.user ? 'in watcher with expression "' + watcher.expression + '"' : 'in a component render function.'), watcher.vm);
  476. break;
  477. }
  478. }
  479. }
  480. // devtool hook
  481. /* istanbul ignore if */
  482. if (devtools && config.devtools) {
  483. devtools.emit('flush');
  484. }
  485. resetSchedulerState();
  486. }
  487. /**
  488. * Push a watcher into the watcher queue.
  489. * Jobs with duplicate IDs will be skipped unless it's
  490. * pushed when the queue is being flushed.
  491. */
  492. function queueWatcher(watcher) {
  493. var id = watcher.id;
  494. if (has[id] == null) {
  495. has[id] = true;
  496. if (!flushing) {
  497. queue.push(watcher);
  498. } else {
  499. // if already flushing, splice the watcher based on its id
  500. // if already past its id, it will be run next immediately.
  501. var i = queue.length - 1;
  502. while (i >= 0 && queue[i].id > watcher.id) {
  503. i--;
  504. }
  505. queue.splice(Math.max(i, index) + 1, 0, watcher);
  506. }
  507. // queue the flush
  508. if (!waiting) {
  509. waiting = true;
  510. nextTick(flushSchedulerQueue);
  511. }
  512. }
  513. }
  514. var uid$1 = 0;
  515. /**
  516. * A watcher parses an expression, collects dependencies,
  517. * and fires callback when the expression value changes.
  518. * This is used for both the $watch() api and directives.
  519. */
  520. var Watcher = function () {
  521. function Watcher(vm, expOrFn, cb) {
  522. var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
  523. this.vm = vm;
  524. vm._watchers.push(this);
  525. // options
  526. this.deep = !!options.deep;
  527. this.user = !!options.user;
  528. this.lazy = !!options.lazy;
  529. this.sync = !!options.sync;
  530. this.expression = expOrFn.toString();
  531. this.cb = cb;
  532. this.id = ++uid$1; // uid for batching
  533. this.active = true;
  534. this.dirty = this.lazy; // for lazy watchers
  535. this.deps = [];
  536. this.newDeps = [];
  537. this.depIds = new _Set();
  538. this.newDepIds = new _Set();
  539. // parse expression for getter
  540. if (typeof expOrFn === 'function') {
  541. this.getter = expOrFn;
  542. } else {
  543. this.getter = parsePath(expOrFn);
  544. if (!this.getter) {
  545. this.getter = function () {};
  546. process.env.NODE_ENV !== 'production' && warn('Failed watching path: "' + expOrFn + '" ' + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
  547. }
  548. }
  549. this.value = this.lazy ? undefined : this.get();
  550. }
  551. /**
  552. * Evaluate the getter, and re-collect dependencies.
  553. */
  554. Watcher.prototype.get = function get() {
  555. pushTarget(this);
  556. var value = this.getter.call(this.vm, this.vm);
  557. // "touch" every property so they are all tracked as
  558. // dependencies for deep watching
  559. if (this.deep) {
  560. traverse(value);
  561. }
  562. popTarget();
  563. this.cleanupDeps();
  564. return value;
  565. };
  566. /**
  567. * Add a dependency to this directive.
  568. */
  569. Watcher.prototype.addDep = function addDep(dep) {
  570. var id = dep.id;
  571. if (!this.newDepIds.has(id)) {
  572. this.newDepIds.add(id);
  573. this.newDeps.push(dep);
  574. if (!this.depIds.has(id)) {
  575. dep.addSub(this);
  576. }
  577. }
  578. };
  579. /**
  580. * Clean up for dependency collection.
  581. */
  582. Watcher.prototype.cleanupDeps = function cleanupDeps() {
  583. var i = this.deps.length;
  584. while (i--) {
  585. var dep = this.deps[i];
  586. if (!this.newDepIds.has(dep.id)) {
  587. dep.removeSub(this);
  588. }
  589. }
  590. var tmp = this.depIds;
  591. this.depIds = this.newDepIds;
  592. this.newDepIds = tmp;
  593. this.newDepIds.clear();
  594. tmp = this.deps;
  595. this.deps = this.newDeps;
  596. this.newDeps = tmp;
  597. this.newDeps.length = 0;
  598. };
  599. /**
  600. * Subscriber interface.
  601. * Will be called when a dependency changes.
  602. */
  603. Watcher.prototype.update = function update() {
  604. /* istanbul ignore else */
  605. if (this.lazy) {
  606. this.dirty = true;
  607. } else if (this.sync) {
  608. this.run();
  609. } else {
  610. queueWatcher(this);
  611. }
  612. };
  613. /**
  614. * Scheduler job interface.
  615. * Will be called by the scheduler.
  616. */
  617. Watcher.prototype.run = function run() {
  618. if (this.active) {
  619. var value = this.get();
  620. if (value !== this.value ||
  621. // Deep watchers and watchers on Object/Arrays should fire even
  622. // when the value is the same, because the value may
  623. // have mutated.
  624. isObject(value) || this.deep) {
  625. // set new value
  626. var oldValue = this.value;
  627. this.value = value;
  628. if (this.user) {
  629. try {
  630. this.cb.call(this.vm, value, oldValue);
  631. } catch (e) {
  632. process.env.NODE_ENV !== 'production' && warn('Error in watcher "' + this.expression + '"', this.vm);
  633. /* istanbul ignore else */
  634. if (config.errorHandler) {
  635. config.errorHandler.call(null, e, this.vm);
  636. } else {
  637. throw e;
  638. }
  639. }
  640. } else {
  641. this.cb.call(this.vm, value, oldValue);
  642. }
  643. }
  644. }
  645. };
  646. /**
  647. * Evaluate the value of the watcher.
  648. * This only gets called for lazy watchers.
  649. */
  650. Watcher.prototype.evaluate = function evaluate() {
  651. this.value = this.get();
  652. this.dirty = false;
  653. };
  654. /**
  655. * Depend on all deps collected by this watcher.
  656. */
  657. Watcher.prototype.depend = function depend() {
  658. var i = this.deps.length;
  659. while (i--) {
  660. this.deps[i].depend();
  661. }
  662. };
  663. /**
  664. * Remove self from all dependencies' subcriber list.
  665. */
  666. Watcher.prototype.teardown = function teardown() {
  667. if (this.active) {
  668. // remove self from vm's watcher list
  669. // this is a somewhat expensive operation so we skip it
  670. // if the vm is being destroyed or is performing a v-for
  671. // re-render (the watcher list is then filtered by v-for).
  672. if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) {
  673. remove(this.vm._watchers, this);
  674. }
  675. var i = this.deps.length;
  676. while (i--) {
  677. this.deps[i].removeSub(this);
  678. }
  679. this.active = false;
  680. }
  681. };
  682. return Watcher;
  683. }();
  684. var seenObjects = new _Set();
  685. function traverse(val, seen) {
  686. var i = void 0,
  687. keys = void 0;
  688. if (!seen) {
  689. seen = seenObjects;
  690. seen.clear();
  691. }
  692. var isA = Array.isArray(val);
  693. var isO = isObject(val);
  694. if ((isA || isO) && Object.isExtensible(val)) {
  695. if (val.__ob__) {
  696. var depId = val.__ob__.dep.id;
  697. if (seen.has(depId)) {
  698. return;
  699. } else {
  700. seen.add(depId);
  701. }
  702. }
  703. if (isA) {
  704. i = val.length;
  705. while (i--) {
  706. traverse(val[i], seen);
  707. }
  708. } else if (isO) {
  709. keys = Object.keys(val);
  710. i = keys.length;
  711. while (i--) {
  712. traverse(val[keys[i]], seen);
  713. }
  714. }
  715. }
  716. }
  717. var arrayProto = Array.prototype;
  718. var arrayMethods = Object.create(arrayProto)
  719. /**
  720. * Intercept mutating methods and emit events
  721. */
  722. ;['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(function (method) {
  723. // cache original method
  724. var original = arrayProto[method];
  725. def(arrayMethods, method, function mutator() {
  726. // avoid leaking arguments:
  727. // http://jsperf.com/closure-with-arguments
  728. var i = arguments.length;
  729. var args = new Array(i);
  730. while (i--) {
  731. args[i] = arguments[i];
  732. }
  733. var result = original.apply(this, args);
  734. var ob = this.__ob__;
  735. var inserted = void 0;
  736. switch (method) {
  737. case 'push':
  738. inserted = args;
  739. break;
  740. case 'unshift':
  741. inserted = args;
  742. break;
  743. case 'splice':
  744. inserted = args.slice(2);
  745. break;
  746. }
  747. if (inserted) ob.observeArray(inserted);
  748. // notify change
  749. ob.dep.notify();
  750. return result;
  751. });
  752. });
  753. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  754. /**
  755. * By default, when a reactive property is set, the new value is
  756. * also converted to become reactive. However when passing down props,
  757. * we don't want to force conversion because the value may be a nested value
  758. * under a frozen data structure. Converting it would defeat the optimization.
  759. */
  760. var observerState = {
  761. shouldConvert: true,
  762. isSettingProps: false
  763. };
  764. /**
  765. * Observer class that are attached to each observed
  766. * object. Once attached, the observer converts target
  767. * object's property keys into getter/setters that
  768. * collect dependencies and dispatches updates.
  769. */
  770. var Observer = function () {
  771. // number of vms that has this object as root $data
  772. function Observer(value) {
  773. this.value = value;
  774. this.dep = new Dep();
  775. this.vmCount = 0;
  776. def(value, '__ob__', this);
  777. if (Array.isArray(value)) {
  778. var augment = hasProto ? protoAugment : copyAugment;
  779. augment(value, arrayMethods, arrayKeys);
  780. this.observeArray(value);
  781. } else {
  782. this.walk(value);
  783. }
  784. }
  785. /**
  786. * Walk through each property and convert them into
  787. * getter/setters. This method should only be called when
  788. * value type is Object.
  789. */
  790. Observer.prototype.walk = function walk(obj) {
  791. var val = this.value;
  792. for (var key in obj) {
  793. defineReactive(val, key, obj[key]);
  794. }
  795. };
  796. /**
  797. * Observe a list of Array items.
  798. */
  799. Observer.prototype.observeArray = function observeArray(items) {
  800. for (var i = 0, l = items.length; i < l; i++) {
  801. observe(items[i]);
  802. }
  803. };
  804. return Observer;
  805. }();
  806. // helpers
  807. /**
  808. * Augment an target Object or Array by intercepting
  809. * the prototype chain using __proto__
  810. */
  811. function protoAugment(target, src) {
  812. /* eslint-disable no-proto */
  813. target.__proto__ = src;
  814. /* eslint-enable no-proto */
  815. }
  816. /**
  817. * Augment an target Object or Array by defining
  818. * hidden properties.
  819. *
  820. * istanbul ignore next
  821. */
  822. function copyAugment(target, src, keys) {
  823. for (var i = 0, l = keys.length; i < l; i++) {
  824. var key = keys[i];
  825. def(target, key, src[key]);
  826. }
  827. }
  828. /**
  829. * Attempt to create an observer instance for a value,
  830. * returns the new observer if successfully observed,
  831. * or the existing observer if the value already has one.
  832. */
  833. function observe(value) {
  834. if (!isObject(value)) {
  835. return;
  836. }
  837. var ob = void 0;
  838. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  839. ob = value.__ob__;
  840. } else if (observerState.shouldConvert && !config._isServer && (Array.isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
  841. ob = new Observer(value);
  842. }
  843. return ob;
  844. }
  845. /**
  846. * Define a reactive property on an Object.
  847. */
  848. function defineReactive(obj, key, val, customSetter) {
  849. var dep = new Dep();
  850. var property = Object.getOwnPropertyDescriptor(obj, key);
  851. if (property && property.configurable === false) {
  852. return;
  853. }
  854. // cater for pre-defined getter/setters
  855. var getter = property && property.get;
  856. var setter = property && property.set;
  857. var childOb = observe(val);
  858. Object.defineProperty(obj, key, {
  859. enumerable: true,
  860. configurable: true,
  861. get: function reactiveGetter() {
  862. var value = getter ? getter.call(obj) : val;
  863. if (Dep.target) {
  864. dep.depend();
  865. if (childOb) {
  866. childOb.dep.depend();
  867. }
  868. if (Array.isArray(value)) {
  869. for (var e, i = 0, l = value.length; i < l; i++) {
  870. e = value[i];
  871. e && e.__ob__ && e.__ob__.dep.depend();
  872. }
  873. }
  874. }
  875. return value;
  876. },
  877. set: function reactiveSetter(newVal) {
  878. var value = getter ? getter.call(obj) : val;
  879. if (newVal === value) {
  880. return;
  881. }
  882. if (process.env.NODE_ENV !== 'production' && customSetter) {
  883. customSetter();
  884. }
  885. if (setter) {
  886. setter.call(obj, newVal);
  887. } else {
  888. val = newVal;
  889. }
  890. childOb = observe(newVal);
  891. dep.notify();
  892. }
  893. });
  894. }
  895. /**
  896. * Set a property on an object. Adds the new property and
  897. * triggers change notification if the property doesn't
  898. * already exist.
  899. */
  900. function set(obj, key, val) {
  901. if (Array.isArray(obj)) {
  902. obj.splice(key, 1, val);
  903. return val;
  904. }
  905. if (hasOwn(obj, key)) {
  906. obj[key] = val;
  907. return;
  908. }
  909. var ob = obj.__ob__;
  910. if (obj._isVue || ob && ob.vmCount) {
  911. process.env.NODE_ENV !== 'production' && warn('Avoid adding reactive properties to a Vue instance or its root $data ' + 'at runtime - delcare it upfront in the data option.');
  912. return;
  913. }
  914. if (!ob) {
  915. obj[key] = val;
  916. return;
  917. }
  918. defineReactive(ob.value, key, val);
  919. ob.dep.notify();
  920. return val;
  921. }
  922. /**
  923. * Delete a property and trigger change if necessary.
  924. */
  925. function del(obj, key) {
  926. var ob = obj.__ob__;
  927. if (obj._isVue || ob && ob.vmCount) {
  928. process.env.NODE_ENV !== 'production' && warn('Avoid deleting properties on a Vue instance or its root $data ' + '- just set it to null.');
  929. return;
  930. }
  931. if (!hasOwn(obj, key)) {
  932. return;
  933. }
  934. delete obj[key];
  935. if (!ob) {
  936. return;
  937. }
  938. ob.dep.notify();
  939. }
  940. function initState(vm) {
  941. vm._watchers = [];
  942. initProps(vm);
  943. initData(vm);
  944. initComputed(vm);
  945. initMethods(vm);
  946. initWatch(vm);
  947. }
  948. function initProps(vm) {
  949. var props = vm.$options.props;
  950. var propsData = vm.$options.propsData;
  951. if (props) {
  952. var keys = vm.$options._propKeys = Object.keys(props);
  953. var isRoot = !vm.$parent;
  954. // root instance props should be converted
  955. observerState.shouldConvert = isRoot;
  956. var _loop = function _loop(i) {
  957. var key = keys[i];
  958. /* istanbul ignore else */
  959. if (process.env.NODE_ENV !== 'production') {
  960. defineReactive(vm, key, validateProp(key, props, propsData, vm), function () {
  961. if (vm.$parent && !observerState.isSettingProps) {
  962. warn('Avoid mutating a prop directly since the value will be ' + 'overwritten whenever the parent component re-renders. ' + 'Instead, use a data or computed property based on the prop\'s ' + ('value. Prop being mutated: "' + key + '"'), vm);
  963. }
  964. });
  965. } else {
  966. defineReactive(vm, key, validateProp(key, props, propsData, vm));
  967. }
  968. };
  969. for (var i = 0; i < keys.length; i++) {
  970. _loop(i);
  971. }
  972. observerState.shouldConvert = true;
  973. }
  974. }
  975. function initData(vm) {
  976. var data = vm.$options.data;
  977. data = vm._data = typeof data === 'function' ? data.call(vm) : data || {};
  978. if (!isPlainObject(data)) {
  979. data = {};
  980. process.env.NODE_ENV !== 'production' && warn('data functions should return an object.', vm);
  981. }
  982. // proxy data on instance
  983. var keys = Object.keys(data);
  984. var props = vm.$options.props;
  985. var i = keys.length;
  986. while (i--) {
  987. if (props && hasOwn(props, keys[i])) {
  988. process.env.NODE_ENV !== 'production' && warn('The data property "' + keys[i] + '" is already declared as a prop. ' + 'Use prop default value instead.', vm);
  989. } else {
  990. proxy(vm, keys[i]);
  991. }
  992. }
  993. // observe data
  994. observe(data);
  995. data.__ob__ && data.__ob__.vmCount++;
  996. }
  997. var computedSharedDefinition = {
  998. enumerable: true,
  999. configurable: true,
  1000. get: noop,
  1001. set: noop
  1002. };
  1003. function initComputed(vm) {
  1004. var computed = vm.$options.computed;
  1005. if (computed) {
  1006. for (var _key in computed) {
  1007. var userDef = computed[_key];
  1008. if (typeof userDef === 'function') {
  1009. computedSharedDefinition.get = makeComputedGetter(userDef, vm);
  1010. computedSharedDefinition.set = noop;
  1011. } else {
  1012. computedSharedDefinition.get = userDef.get ? userDef.cache !== false ? makeComputedGetter(userDef.get, vm) : bind(userDef.get, vm) : noop;
  1013. computedSharedDefinition.set = userDef.set ? bind(userDef.set, vm) : noop;
  1014. }
  1015. Object.defineProperty(vm, _key, computedSharedDefinition);
  1016. }
  1017. }
  1018. }
  1019. function makeComputedGetter(getter, owner) {
  1020. var watcher = new Watcher(owner, getter, noop, {
  1021. lazy: true
  1022. });
  1023. return function computedGetter() {
  1024. if (watcher.dirty) {
  1025. watcher.evaluate();
  1026. }
  1027. if (Dep.target) {
  1028. watcher.depend();
  1029. }
  1030. return watcher.value;
  1031. };
  1032. }
  1033. function initMethods(vm) {
  1034. var methods = vm.$options.methods;
  1035. if (methods) {
  1036. for (var _key2 in methods) {
  1037. vm[_key2] = bind(methods[_key2], vm);
  1038. }
  1039. }
  1040. }
  1041. function initWatch(vm) {
  1042. var watch = vm.$options.watch;
  1043. if (watch) {
  1044. for (var _key3 in watch) {
  1045. var handler = watch[_key3];
  1046. if (Array.isArray(handler)) {
  1047. for (var i = 0; i < handler.length; i++) {
  1048. createWatcher(vm, _key3, handler[i]);
  1049. }
  1050. } else {
  1051. createWatcher(vm, _key3, handler);
  1052. }
  1053. }
  1054. }
  1055. }
  1056. function createWatcher(vm, key, handler) {
  1057. var options = void 0;
  1058. if (isPlainObject(handler)) {
  1059. options = handler;
  1060. handler = handler.handler;
  1061. }
  1062. if (typeof handler === 'string') {
  1063. handler = vm[handler];
  1064. }
  1065. vm.$watch(key, handler, options);
  1066. }
  1067. function stateMixin(Vue) {
  1068. // flow somehow has problems with directly declared definition object
  1069. // when using Object.defineProperty, so we have to procedurally build up
  1070. // the object here.
  1071. var dataDef = {};
  1072. dataDef.get = function () {
  1073. return this._data;
  1074. };
  1075. if (process.env.NODE_ENV !== 'production') {
  1076. dataDef.set = function (newData) {
  1077. warn('Avoid replacing instance root $data. ' + 'Use nested data properties instead.', this);
  1078. };
  1079. }
  1080. Object.defineProperty(Vue.prototype, '$data', dataDef);
  1081. Vue.prototype.$watch = function (expOrFn, cb, options) {
  1082. var vm = this;
  1083. options = options || {};
  1084. options.user = true;
  1085. var watcher = new Watcher(vm, expOrFn, cb, options);
  1086. if (options.immediate) {
  1087. cb.call(vm, watcher.value);
  1088. }
  1089. return function unwatchFn() {
  1090. watcher.teardown();
  1091. };
  1092. };
  1093. }
  1094. function proxy(vm, key) {
  1095. if (!isReserved(key)) {
  1096. Object.defineProperty(vm, key, {
  1097. configurable: true,
  1098. enumerable: true,
  1099. get: function proxyGetter() {
  1100. return vm._data[key];
  1101. },
  1102. set: function proxySetter(val) {
  1103. vm._data[key] = val;
  1104. }
  1105. });
  1106. }
  1107. }
  1108. var VNode = function VNode(tag, data, children, text, elm, ns, context, host, componentOptions) {
  1109. this.tag = tag;
  1110. this.data = data;
  1111. this.children = children;
  1112. this.text = text;
  1113. this.elm = elm;
  1114. this.ns = ns;
  1115. this.context = context;
  1116. this.host = host;
  1117. this.key = data && data.key;
  1118. this.componentOptions = componentOptions;
  1119. this.child = undefined;
  1120. this.parent = undefined;
  1121. this.raw = false;
  1122. this.isStatic = false;
  1123. // apply construct hook.
  1124. // this is applied during render, before patch happens.
  1125. // unlike other hooks, this is applied on both client and server.
  1126. var constructHook = data && data.hook && data.hook.construct;
  1127. if (constructHook) {
  1128. constructHook(this);
  1129. }
  1130. };
  1131. var emptyVNode = function emptyVNode() {
  1132. return new VNode(undefined, undefined, undefined, '');
  1133. };
  1134. function normalizeChildren(children, ns) {
  1135. // Invoke children thunks. Components always receive their children
  1136. // as thunks so that they can perform the actual render inside their
  1137. // own dependency collection cycle. Also, since JSX automatically
  1138. // wraps component children in a thunk, we handle nested thunks to
  1139. // prevent situations such as <MyComponent>{ children }</MyComponent>
  1140. // from failing when it produces a double thunk.
  1141. while (typeof children === 'function') {
  1142. children = children();
  1143. }
  1144. if (isPrimitive(children)) {
  1145. return [createTextVNode(children)];
  1146. }
  1147. if (Array.isArray(children)) {
  1148. var res = [];
  1149. for (var i = 0, l = children.length; i < l; i++) {
  1150. var c = children[i];
  1151. var last = res[res.length - 1];
  1152. // nested
  1153. if (Array.isArray(c)) {
  1154. res.push.apply(res, normalizeChildren(c, ns));
  1155. } else if (isPrimitive(c)) {
  1156. if (last && last.text) {
  1157. last.text += String(c);
  1158. } else {
  1159. // convert primitive to vnode
  1160. res.push(createTextVNode(c));
  1161. }
  1162. } else if (c instanceof VNode) {
  1163. if (c.text && last && last.text) {
  1164. last.text += c.text;
  1165. } else {
  1166. // inherit parent namespace
  1167. if (ns) {
  1168. applyNS(c, ns);
  1169. }
  1170. res.push(c);
  1171. }
  1172. }
  1173. }
  1174. return res;
  1175. }
  1176. }
  1177. function createTextVNode(val) {
  1178. return new VNode(undefined, undefined, undefined, String(val));
  1179. }
  1180. function applyNS(vnode, ns) {
  1181. if (vnode.tag && !vnode.ns) {
  1182. vnode.ns = ns;
  1183. if (vnode.children) {
  1184. for (var i = 0, l = vnode.children.length; i < l; i++) {
  1185. applyNS(vnode.children[i], ns);
  1186. }
  1187. }
  1188. }
  1189. }
  1190. // in case the child is also an abstract component, e.g. <transition-control>
  1191. // we want to recrusively retrieve the real component to be rendered
  1192. function getRealChild(vnode) {
  1193. var compOptions = vnode && vnode.componentOptions;
  1194. if (compOptions && compOptions.Ctor.options.abstract) {
  1195. return getRealChild(compOptions.propsData && compOptions.propsData.child);
  1196. } else {
  1197. return vnode;
  1198. }
  1199. }
  1200. function mergeVNodeHook(def, key, hook) {
  1201. var oldHook = def[key];
  1202. if (oldHook) {
  1203. def[key] = function () {
  1204. oldHook.apply(this, arguments);
  1205. hook.apply(this, arguments);
  1206. };
  1207. } else {
  1208. def[key] = hook;
  1209. }
  1210. }
  1211. function updateListeners(on, oldOn, add, remove) {
  1212. var name = void 0,
  1213. cur = void 0,
  1214. old = void 0,
  1215. fn = void 0,
  1216. event = void 0,
  1217. capture = void 0;
  1218. for (name in on) {
  1219. cur = on[name];
  1220. old = oldOn[name];
  1221. if (!old) {
  1222. capture = name.charAt(0) === '!';
  1223. event = capture ? name.slice(1) : name;
  1224. if (Array.isArray(cur)) {
  1225. add(event, cur.invoker = arrInvoker(cur), capture);
  1226. } else {
  1227. fn = cur;
  1228. cur = on[name] = {};
  1229. cur.fn = fn;
  1230. add(event, cur.invoker = fnInvoker(cur), capture);
  1231. }
  1232. } else if (Array.isArray(old)) {
  1233. old.length = cur.length;
  1234. for (var i = 0; i < old.length; i++) {
  1235. old[i] = cur[i];
  1236. }on[name] = old;
  1237. } else {
  1238. old.fn = cur;
  1239. on[name] = old;
  1240. }
  1241. }
  1242. for (name in oldOn) {
  1243. if (!on[name]) {
  1244. event = name.charAt(0) === '!' ? name.slice(1) : name;
  1245. remove(event, oldOn[name].invoker);
  1246. }
  1247. }
  1248. }
  1249. function arrInvoker(arr) {
  1250. return function (ev) {
  1251. var single = arguments.length === 1;
  1252. for (var i = 0; i < arr.length; i++) {
  1253. single ? arr[i](ev) : arr[i].apply(null, arguments);
  1254. }
  1255. };
  1256. }
  1257. function fnInvoker(o) {
  1258. return function (ev) {
  1259. var single = arguments.length === 1;
  1260. single ? o.fn(ev) : o.fn.apply(null, arguments);
  1261. };
  1262. }
  1263. function initLifecycle(vm) {
  1264. var options = vm.$options;
  1265. // locate first non-abstract parent
  1266. var parent = options.parent;
  1267. if (parent && !options.abstract) {
  1268. while (parent.$options.abstract && parent.$parent) {
  1269. parent = parent.$parent;
  1270. }
  1271. parent.$children.push(vm);
  1272. }
  1273. vm.$parent = parent;
  1274. vm.$root = parent ? parent.$root : vm;
  1275. vm.$children = [];
  1276. vm.$refs = {};
  1277. vm._watcher = null;
  1278. vm._inactive = false;
  1279. vm._isMounted = false;
  1280. vm._isDestroyed = false;
  1281. vm._isBeingDestroyed = false;
  1282. }
  1283. function lifecycleMixin(Vue) {
  1284. Vue.prototype._mount = function (el, hydrating) {
  1285. var vm = this;
  1286. vm.$el = el;
  1287. if (!vm.$options.render) {
  1288. vm.$options.render = emptyVNode;
  1289. if (process.env.NODE_ENV !== 'production') {
  1290. /* istanbul ignore if */
  1291. if (vm.$options.template) {
  1292. warn('You are using the runtime-only build of Vue where the template ' + 'option is not available. Either pre-compile the templates into ' + 'render functions, or use the compiler-included build.', vm);
  1293. } else {
  1294. warn('Failed to mount component: template or render function not defined.', vm);
  1295. }
  1296. }
  1297. }
  1298. callHook(vm, 'beforeMount');
  1299. vm._watcher = new Watcher(vm, function () {
  1300. vm._update(vm._render(), hydrating);
  1301. }, noop);
  1302. hydrating = false;
  1303. // root instance, call mounted on self
  1304. // mounted is called for child components in its inserted hook
  1305. if (vm.$root === vm) {
  1306. vm._isMounted = true;
  1307. callHook(vm, 'mounted');
  1308. }
  1309. return vm;
  1310. };
  1311. Vue.prototype._update = function (vnode, hydrating) {
  1312. var vm = this;
  1313. if (vm._isMounted) {
  1314. callHook(vm, 'beforeUpdate');
  1315. }
  1316. var prevEl = vm.$el;
  1317. if (!vm._vnode) {
  1318. // Vue.prototype.__patch__ is injected in entry points
  1319. // based on the rendering backend used.
  1320. vm.$el = vm.__patch__(vm.$el, vnode, hydrating);
  1321. } else {
  1322. vm.$el = vm.__patch__(vm._vnode, vnode);
  1323. }
  1324. vm._vnode = vnode;
  1325. // update __vue__ reference
  1326. if (prevEl) {
  1327. prevEl.__vue__ = null;
  1328. }
  1329. if (vm.$el) {
  1330. vm.$el.__vue__ = vm;
  1331. }
  1332. // if parent is an HOC, update its $el as well
  1333. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  1334. vm.$parent.$el = vm.$el;
  1335. }
  1336. if (vm._isMounted) {
  1337. callHook(vm, 'updated');
  1338. }
  1339. };
  1340. Vue.prototype._updateFromParent = function (propsData, listeners, parentVnode, renderChildren) {
  1341. var vm = this;
  1342. vm.$options._parentVnode = parentVnode;
  1343. vm.$options._renderChildren = renderChildren;
  1344. // update props
  1345. if (propsData && vm.$options.props) {
  1346. observerState.shouldConvert = false;
  1347. if (process.env.NODE_ENV !== 'production') {
  1348. observerState.isSettingProps = true;
  1349. }
  1350. var propKeys = vm.$options._propKeys || [];
  1351. for (var i = 0; i < propKeys.length; i++) {
  1352. var key = propKeys[i];
  1353. vm[key] = validateProp(key, vm.$options.props, propsData, vm);
  1354. }
  1355. observerState.shouldConvert = true;
  1356. if (process.env.NODE_ENV !== 'production') {
  1357. observerState.isSettingProps = false;
  1358. }
  1359. }
  1360. // update listeners
  1361. if (listeners) {
  1362. var oldListeners = vm.$options._parentListeners;
  1363. vm.$options._parentListeners = listeners;
  1364. vm._updateListeners(listeners, oldListeners);
  1365. }
  1366. };
  1367. Vue.prototype.$forceUpdate = function () {
  1368. var vm = this;
  1369. if (vm._watcher) {
  1370. vm._watcher.update();
  1371. }
  1372. if (vm._watchers.length) {
  1373. for (var i = 0; i < vm._watchers.length; i++) {
  1374. vm._watchers[i].update(true /* shallow */);
  1375. }
  1376. }
  1377. };
  1378. Vue.prototype.$destroy = function () {
  1379. var vm = this;
  1380. if (vm._isBeingDestroyed) {
  1381. return;
  1382. }
  1383. callHook(vm, 'beforeDestroy');
  1384. vm._isBeingDestroyed = true;
  1385. // remove self from parent
  1386. var parent = vm.$parent;
  1387. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  1388. remove(parent.$children, vm);
  1389. }
  1390. // teardown watchers
  1391. if (vm._watcher) {
  1392. vm._watcher.teardown();
  1393. }
  1394. var i = vm._watchers.length;
  1395. while (i--) {
  1396. vm._watchers[i].teardown();
  1397. }
  1398. // remove reference from data ob
  1399. // frozen object may not have observer.
  1400. if (vm._data.__ob__) {
  1401. vm._data.__ob__.vmCount--;
  1402. }
  1403. // call the last hook...
  1404. vm._isDestroyed = true;
  1405. callHook(vm, 'destroyed');
  1406. // turn off all instance listeners.
  1407. vm.$off();
  1408. // remove __vue__ reference
  1409. if (vm.$el) {
  1410. vm.$el.__vue__ = null;
  1411. }
  1412. };
  1413. }
  1414. function callHook(vm, hook) {
  1415. var handlers = vm.$options[hook];
  1416. if (handlers) {
  1417. for (var i = 0, j = handlers.length; i < j; i++) {
  1418. handlers[i].call(vm);
  1419. }
  1420. }
  1421. vm.$emit('hook:' + hook);
  1422. }
  1423. var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
  1424. var hooksToMerge = Object.keys(hooks);
  1425. function createComponent(Ctor, data, parent, context, host, _children, tag) {
  1426. // ensure children is a thunk
  1427. if (process.env.NODE_ENV !== 'production' && _children && typeof _children !== 'function') {
  1428. warn('A component\'s children should be a function that returns the ' + 'children array. This allows the component to track the children ' + 'dependencies and optimizes re-rendering.');
  1429. }
  1430. if (!Ctor) {
  1431. return;
  1432. }
  1433. if (isObject(Ctor)) {
  1434. Ctor = Vue.extend(Ctor);
  1435. }
  1436. if (typeof Ctor !== 'function') {
  1437. if (process.env.NODE_ENV !== 'production') {
  1438. warn('Invalid Component definition: ' + Ctor, parent);
  1439. }
  1440. return;
  1441. }
  1442. // async component
  1443. if (!Ctor.cid) {
  1444. if (Ctor.resolved) {
  1445. Ctor = Ctor.resolved;
  1446. } else {
  1447. Ctor = resolveAsyncComponent(Ctor, function () {
  1448. // it's ok to queue this on every render because
  1449. // $forceUpdate is buffered. this is only called
  1450. // if the
  1451. parent.$forceUpdate();
  1452. });
  1453. if (!Ctor) {
  1454. // return nothing if this is indeed an async component
  1455. // wait for the callback to trigger parent update.
  1456. return;
  1457. }
  1458. }
  1459. }
  1460. data = data || {};
  1461. // extract props
  1462. var propsData = extractProps(data, Ctor);
  1463. // functional component
  1464. if (Ctor.options.functional) {
  1465. var _ret = function () {
  1466. var props = {};
  1467. var propOptions = Ctor.options.props;
  1468. if (propOptions) {
  1469. Object.keys(propOptions).forEach(function (key) {
  1470. props[key] = validateProp(key, propOptions, propsData);
  1471. });
  1472. }
  1473. return {
  1474. v: Ctor.options.render.call(null, parent.$createElement, {
  1475. props: props,
  1476. parent: parent,
  1477. data: data,
  1478. children: function children() {
  1479. return normalizeChildren(_children);
  1480. },
  1481. slots: function slots() {
  1482. return resolveSlots(_children);
  1483. }
  1484. })
  1485. };
  1486. }();
  1487. if (typeof _ret === "object") return _ret.v;
  1488. }
  1489. // extract listeners, since these needs to be treated as
  1490. // child component listeners instead of DOM listeners
  1491. var listeners = data.on;
  1492. // replace with listeners with .native modifier
  1493. data.on = data.nativeOn;
  1494. if (Ctor.options.abstract) {
  1495. // abstract components do not keep anything
  1496. // other than props & listeners
  1497. data = {};
  1498. }
  1499. // merge component management hooks onto the placeholder node
  1500. mergeHooks(data);
  1501. // return a placeholder vnode
  1502. var name = Ctor.options.name || tag;
  1503. var vnode = new VNode('vue-component-' + Ctor.cid + (name ? '-' + name : ''), data, undefined, undefined, undefined, undefined, context, host, { Ctor: Ctor, propsData: propsData, listeners: listeners, parent: parent, tag: tag, children: _children });
  1504. return vnode;
  1505. }
  1506. function createComponentInstanceForVnode(vnode // we know it's MountedComponentVNode but flow doesn't
  1507. ) {
  1508. var vnodeComponentOptions = vnode.componentOptions;
  1509. var options = {
  1510. _isComponent: true,
  1511. parent: vnodeComponentOptions.parent,
  1512. propsData: vnodeComponentOptions.propsData,
  1513. _componentTag: vnodeComponentOptions.tag,
  1514. _parentVnode: vnode,
  1515. _parentListeners: vnodeComponentOptions.listeners,
  1516. _renderChildren: vnodeComponentOptions.children
  1517. };
  1518. // check inline-template render functions
  1519. var inlineTemplate = vnode.data.inlineTemplate;
  1520. if (inlineTemplate) {
  1521. options.render = inlineTemplate.render;
  1522. options.staticRenderFns = inlineTemplate.staticRenderFns;
  1523. }
  1524. return new vnodeComponentOptions.Ctor(options);
  1525. }
  1526. function init(vnode, hydrating) {
  1527. if (!vnode.child) {
  1528. var child = vnode.child = createComponentInstanceForVnode(vnode);
  1529. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  1530. }
  1531. }
  1532. function prepatch(oldVnode, vnode) {
  1533. var options = vnode.componentOptions;
  1534. var child = vnode.child = oldVnode.child;
  1535. child._updateFromParent(options.propsData, // updated props
  1536. options.listeners, // updated listeners
  1537. vnode, // new parent vnode
  1538. options.children // new children
  1539. );
  1540. // always update abstract components.
  1541. if (child.$options.abstract) {
  1542. child.$forceUpdate();
  1543. }
  1544. }
  1545. function insert(vnode) {
  1546. if (!vnode.child._isMounted) {
  1547. vnode.child._isMounted = true;
  1548. callHook(vnode.child, 'mounted');
  1549. }
  1550. if (vnode.data.keepAlive) {
  1551. vnode.child._inactive = false;
  1552. callHook(vnode.child, 'activated');
  1553. }
  1554. }
  1555. function destroy(vnode) {
  1556. if (!vnode.child._isDestroyed) {
  1557. if (!vnode.data.keepAlive) {
  1558. vnode.child.$destroy();
  1559. } else {
  1560. vnode.child._inactive = true;
  1561. callHook(vnode.child, 'deactivated');
  1562. }
  1563. }
  1564. }
  1565. function resolveAsyncComponent(factory, cb) {
  1566. if (factory.requested) {
  1567. // pool callbacks
  1568. factory.pendingCallbacks.push(cb);
  1569. } else {
  1570. var _ret2 = function () {
  1571. factory.requested = true;
  1572. var cbs = factory.pendingCallbacks = [cb];
  1573. var sync = true;
  1574. factory(
  1575. // resolve
  1576. function (res) {
  1577. if (isObject(res)) {
  1578. res = Vue.extend(res);
  1579. }
  1580. // cache resolved
  1581. factory.resolved = res;
  1582. // invoke callbacks only if this is not a synchronous resolve
  1583. // (async resolves are shimmed as synchronous during SSR)
  1584. if (!sync) {
  1585. for (var i = 0, l = cbs.length; i < l; i++) {
  1586. cbs[i](res);
  1587. }
  1588. }
  1589. },
  1590. // reject
  1591. function (reason) {
  1592. process.env.NODE_ENV !== 'production' && warn('Failed to resolve async component: ' + factory + (reason ? '\nReason: ' + reason : ''));
  1593. });
  1594. sync = false;
  1595. // return in case resolved synchronously
  1596. return {
  1597. v: factory.resolved
  1598. };
  1599. }();
  1600. if (typeof _ret2 === "object") return _ret2.v;
  1601. }
  1602. }
  1603. function extractProps(data, Ctor) {
  1604. // we are only extrating raw values here.
  1605. // validation and default values are handled in the child
  1606. // component itself.
  1607. var propOptions = Ctor.options.props;
  1608. if (!propOptions) {
  1609. return;
  1610. }
  1611. var res = {};
  1612. var attrs = data.attrs;
  1613. var props = data.props;
  1614. var domProps = data.domProps;
  1615. if (attrs || props || domProps) {
  1616. for (var key in propOptions) {
  1617. var altKey = hyphenate(key);
  1618. checkProp(res, props, key, altKey, true) || checkProp(res, attrs, key, altKey) || checkProp(res, domProps, key, altKey);
  1619. }
  1620. }
  1621. return res;
  1622. }
  1623. function checkProp(res, hash, key, altKey, preserve) {
  1624. if (hash) {
  1625. if (hasOwn(hash, key)) {
  1626. res[key] = hash[key];
  1627. if (!preserve) {
  1628. delete hash[key];
  1629. }
  1630. return true;
  1631. } else if (hasOwn(hash, altKey)) {
  1632. res[key] = hash[altKey];
  1633. if (!preserve) {
  1634. delete hash[altKey];
  1635. }
  1636. return true;
  1637. }
  1638. }
  1639. return false;
  1640. }
  1641. function mergeHooks(data) {
  1642. if (!data.hook) {
  1643. data.hook = {};
  1644. }
  1645. for (var i = 0; i < hooksToMerge.length; i++) {
  1646. var key = hooksToMerge[i];
  1647. var fromParent = data.hook[key];
  1648. var ours = hooks[key];
  1649. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  1650. }
  1651. }
  1652. function mergeHook$1(a, b) {
  1653. // since all hooks have at most two args, use fixed args
  1654. // to avoid having to use fn.apply().
  1655. return function (_, __) {
  1656. a(_, __);
  1657. b(_, __);
  1658. };
  1659. }
  1660. // wrapper function for providing a more flexible interface
  1661. // without getting yelled at by flow
  1662. function createElement(tag, data, children) {
  1663. if (data && (Array.isArray(data) || typeof data !== 'object')) {
  1664. children = data;
  1665. data = undefined;
  1666. }
  1667. // make sure to use real instance instead of proxy as context
  1668. return _createElement(this._self, tag, data, children);
  1669. }
  1670. function _createElement(context, tag, data, children) {
  1671. var parent = renderState.activeInstance;
  1672. var host = context !== parent ? parent : undefined;
  1673. if (!parent) {
  1674. process.env.NODE_ENV !== 'production' && warn('createElement cannot be called outside of component ' + 'render functions.');
  1675. return;
  1676. }
  1677. if (data && data.__ob__) {
  1678. process.env.NODE_ENV !== 'production' && warn('Avoid using observed data object as vnode data: ' + JSON.stringify(data) + '\n' + 'Always create fresh vnode data objects in each render!', context);
  1679. return;
  1680. }
  1681. if (!tag) {
  1682. // in case of component :is set to falsy value
  1683. return emptyVNode();
  1684. }
  1685. if (typeof tag === 'string') {
  1686. var Ctor = void 0;
  1687. var ns = config.getTagNamespace(tag);
  1688. if (config.isReservedTag(tag)) {
  1689. // platform built-in elements
  1690. return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
  1691. } else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
  1692. // component
  1693. return createComponent(Ctor, data, parent, context, host, children, tag);
  1694. } else {
  1695. // unknown or unlisted namespaced elements
  1696. // check at runtime because it may get assigned a namespace when its
  1697. // parent normalizes children
  1698. return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
  1699. }
  1700. } else {
  1701. // direct component options / constructor
  1702. return createComponent(tag, data, parent, context, host, children);
  1703. }
  1704. }
  1705. var renderState = {
  1706. activeInstance: null
  1707. };
  1708. function initRender(vm) {
  1709. vm.$vnode = null; // the placeholder node in parent tree
  1710. vm._vnode = null; // the root of the child tree
  1711. vm._staticTrees = null;
  1712. vm.$slots = {};
  1713. // bind the public createElement fn to this instance
  1714. // so that we get proper render context inside it.
  1715. vm.$createElement = bind(createElement, vm);
  1716. if (vm.$options.el) {
  1717. vm.$mount(vm.$options.el);
  1718. }
  1719. }
  1720. function renderMixin(Vue) {
  1721. Vue.prototype.$nextTick = function (fn) {
  1722. nextTick(fn, this);
  1723. };
  1724. Vue.prototype._render = function () {
  1725. var vm = this;
  1726. // set current active instance
  1727. var prev = renderState.activeInstance;
  1728. renderState.activeInstance = vm;
  1729. var _vm$$options = vm.$options;
  1730. var render = _vm$$options.render;
  1731. var staticRenderFns = _vm$$options.staticRenderFns;
  1732. var _renderChildren = _vm$$options._renderChildren;
  1733. var _parentVnode = _vm$$options._parentVnode;
  1734. if (staticRenderFns && !vm._staticTrees) {
  1735. vm._staticTrees = [];
  1736. }
  1737. // set parent vnode. this allows render functions to have access
  1738. // to the data on the placeholder node.
  1739. vm.$vnode = _parentVnode;
  1740. // resolve slots. becaues slots are rendered in parent scope,
  1741. // we set the activeInstance to parent.
  1742. vm.$slots = resolveSlots(_renderChildren);
  1743. // render self
  1744. var vnode = void 0;
  1745. try {
  1746. vnode = render.call(vm._renderProxy, vm.$createElement);
  1747. } catch (e) {
  1748. if (process.env.NODE_ENV !== 'production') {
  1749. warn('Error when rendering ' + formatComponentName(vm) + ':');
  1750. }
  1751. /* istanbul ignore else */
  1752. if (config.errorHandler) {
  1753. config.errorHandler.call(null, e, vm);
  1754. } else {
  1755. if (config._isServer) {
  1756. throw e;
  1757. } else {
  1758. setTimeout(function () {
  1759. throw e;
  1760. }, 0);
  1761. }
  1762. }
  1763. // return previous vnode to prevent render error causing blank component
  1764. vnode = vm._vnode;
  1765. }
  1766. // return empty vnode in case the render function errored out
  1767. if (!(vnode instanceof VNode)) {
  1768. if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
  1769. warn('Multiple root nodes returned from render function. Render function ' + 'should return a single root node.', vm);
  1770. }
  1771. vnode = emptyVNode();
  1772. }
  1773. // set parent
  1774. vnode.parent = _parentVnode;
  1775. // restore render state
  1776. renderState.activeInstance = prev;
  1777. return vnode;
  1778. };
  1779. // shorthands used in render functions
  1780. Vue.prototype._h = createElement;
  1781. // toString for mustaches
  1782. Vue.prototype._s = _toString;
  1783. // number conversion
  1784. Vue.prototype._n = toNumber;
  1785. // render static tree by index
  1786. Vue.prototype._m = function renderStatic(index) {
  1787. var tree = this._staticTrees[index];
  1788. if (!tree) {
  1789. tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
  1790. tree.isStatic = true;
  1791. }
  1792. return tree;
  1793. };
  1794. // filter resolution helper
  1795. var identity = function identity(_) {
  1796. return _;
  1797. };
  1798. Vue.prototype._f = function resolveFilter(id) {
  1799. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1800. };
  1801. // render v-for
  1802. Vue.prototype._l = function renderList(val, render) {
  1803. var ret = void 0,
  1804. i = void 0,
  1805. l = void 0,
  1806. keys = void 0,
  1807. key = void 0;
  1808. if (Array.isArray(val)) {
  1809. ret = new Array(val.length);
  1810. for (i = 0, l = val.length; i < l; i++) {
  1811. ret[i] = render(val[i], i);
  1812. }
  1813. } else if (typeof val === 'number') {
  1814. ret = new Array(val);
  1815. for (i = 0; i < val; i++) {
  1816. ret[i] = render(i + 1, i);
  1817. }
  1818. } else if (isObject(val)) {
  1819. keys = Object.keys(val);
  1820. ret = new Array(keys.length);
  1821. for (i = 0, l = keys.length; i < l; i++) {
  1822. key = keys[i];
  1823. ret[i] = render(val[key], key, i);
  1824. }
  1825. }
  1826. return ret;
  1827. };
  1828. // apply v-bind object
  1829. Vue.prototype._b = function bindProps(vnode, value, asProp) {
  1830. if (value) {
  1831. if (!isObject(value)) {
  1832. process.env.NODE_ENV !== 'production' && warn('v-bind without argument expects an Object or Array value', this);
  1833. } else {
  1834. if (Array.isArray(value)) {
  1835. value = toObject(value);
  1836. }
  1837. var data = vnode.data;
  1838. for (var key in value) {
  1839. var hash = asProp || config.mustUseProp(key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
  1840. hash[key] = value[key];
  1841. }
  1842. }
  1843. }
  1844. };
  1845. // expose v-on keyCodes
  1846. Vue.prototype._k = function getKeyCodes(key) {
  1847. return config.keyCodes[key];
  1848. };
  1849. }
  1850. function resolveSlots(renderChildren) {
  1851. var slots = {};
  1852. if (!renderChildren) {
  1853. return slots;
  1854. }
  1855. var children = normalizeChildren(renderChildren) || [];
  1856. var defaultSlot = [];
  1857. var name = void 0,
  1858. child = void 0;
  1859. for (var i = 0, l = children.length; i < l; i++) {
  1860. child = children[i];
  1861. if (child.data && (name = child.data.slot)) {
  1862. delete child.data.slot;
  1863. var slot = slots[name] || (slots[name] = []);
  1864. if (child.tag === 'template') {
  1865. slot.push.apply(slot, child.children);
  1866. } else {
  1867. slot.push(child);
  1868. }
  1869. } else {
  1870. defaultSlot.push(child);
  1871. }
  1872. }
  1873. // ignore single whitespace
  1874. if (defaultSlot.length && !(defaultSlot.length === 1 && defaultSlot[0].text === ' ')) {
  1875. slots.default = defaultSlot;
  1876. }
  1877. return slots;
  1878. }
  1879. function initEvents(vm) {
  1880. vm._events = Object.create(null);
  1881. // init parent attached events
  1882. var listeners = vm.$options._parentListeners;
  1883. var on = bind(vm.$on, vm);
  1884. var off = bind(vm.$off, vm);
  1885. vm._updateListeners = function (listeners, oldListeners) {
  1886. updateListeners(listeners, oldListeners || {}, on, off);
  1887. };
  1888. if (listeners) {
  1889. vm._updateListeners(listeners);
  1890. }
  1891. }
  1892. function eventsMixin(Vue) {
  1893. Vue.prototype.$on = function (event, fn) {
  1894. var vm = this;(vm._events[event] || (vm._events[event] = [])).push(fn);
  1895. return vm;
  1896. };
  1897. Vue.prototype.$once = function (event, fn) {
  1898. var vm = this;
  1899. function on() {
  1900. vm.$off(event, on);
  1901. fn.apply(vm, arguments);
  1902. }
  1903. on.fn = fn;
  1904. vm.$on(event, on);
  1905. return vm;
  1906. };
  1907. Vue.prototype.$off = function (event, fn) {
  1908. var vm = this;
  1909. // all
  1910. if (!arguments.length) {
  1911. vm._events = Object.create(null);
  1912. return vm;
  1913. }
  1914. // specific event
  1915. var cbs = vm._events[event];
  1916. if (!cbs) {
  1917. return vm;
  1918. }
  1919. if (arguments.length === 1) {
  1920. vm._events[event] = null;
  1921. return vm;
  1922. }
  1923. // specific handler
  1924. var cb = void 0;
  1925. var i = cbs.length;
  1926. while (i--) {
  1927. cb = cbs[i];
  1928. if (cb === fn || cb.fn === fn) {
  1929. cbs.splice(i, 1);
  1930. break;
  1931. }
  1932. }
  1933. return vm;
  1934. };
  1935. Vue.prototype.$emit = function (event) {
  1936. var vm = this;
  1937. var cbs = vm._events[event];
  1938. if (cbs) {
  1939. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  1940. var args = toArray(arguments, 1);
  1941. for (var i = 0, l = cbs.length; i < l; i++) {
  1942. cbs[i].apply(vm, args);
  1943. }
  1944. }
  1945. return vm;
  1946. };
  1947. }
  1948. var uid = 0;
  1949. function initMixin(Vue) {
  1950. Vue.prototype._init = function (options) {
  1951. var vm = this;
  1952. // a uid
  1953. vm._uid = uid++;
  1954. // a flag to avoid this being observed
  1955. vm._isVue = true;
  1956. // merge options
  1957. if (options && options._isComponent) {
  1958. // optimize internal component instantiation
  1959. // since dynamic options merging is pretty slow, and none of the
  1960. // internal component options needs special treatment.
  1961. initInternalComponent(vm, options);
  1962. } else {
  1963. vm.$options = mergeOptions(resolveConstructorOptions(vm), options || {}, vm);
  1964. }
  1965. /* istanbul ignore else */
  1966. if (process.env.NODE_ENV !== 'production') {
  1967. initProxy(vm);
  1968. } else {
  1969. vm._renderProxy = vm;
  1970. }
  1971. // expose real self
  1972. vm._self = vm;
  1973. initLifecycle(vm);
  1974. initEvents(vm);
  1975. callHook(vm, 'beforeCreate');
  1976. initState(vm);
  1977. callHook(vm, 'created');
  1978. initRender(vm);
  1979. };
  1980. function initInternalComponent(vm, options) {
  1981. var opts = vm.$options = Object.create(resolveConstructorOptions(vm));
  1982. // doing this because it's faster than dynamic enumeration.
  1983. opts.parent = options.parent;
  1984. opts.propsData = options.propsData;
  1985. opts._parentVnode = options._parentVnode;
  1986. opts._parentListeners = options._parentListeners;
  1987. opts._renderChildren = options._renderChildren;
  1988. opts._componentTag = options._componentTag;
  1989. if (options.render) {
  1990. opts.render = options.render;
  1991. opts.staticRenderFns = options.staticRenderFns;
  1992. }
  1993. }
  1994. function resolveConstructorOptions(vm) {
  1995. var Ctor = vm.constructor;
  1996. var options = Ctor.options;
  1997. if (Ctor.super) {
  1998. var superOptions = Ctor.super.options;
  1999. var cachedSuperOptions = Ctor.superOptions;
  2000. if (superOptions !== cachedSuperOptions) {
  2001. // super option changed
  2002. Ctor.superOptions = superOptions;
  2003. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  2004. if (options.name) {
  2005. options.components[options.name] = Ctor;
  2006. }
  2007. }
  2008. }
  2009. return options;
  2010. }
  2011. }
  2012. function Vue(options) {
  2013. this._init(options);
  2014. }
  2015. initMixin(Vue);
  2016. stateMixin(Vue);
  2017. eventsMixin(Vue);
  2018. lifecycleMixin(Vue);
  2019. renderMixin(Vue);
  2020. var warn = void 0;
  2021. var formatComponentName = void 0;
  2022. if (process.env.NODE_ENV !== 'production') {
  2023. (function () {
  2024. var hasConsole = typeof console !== 'undefined';
  2025. warn = function warn(msg, vm) {
  2026. if (hasConsole && !config.silent) {
  2027. console.error('[Vue warn]: ' + msg + ' ' + (vm ? formatLocation(formatComponentName(vm)) : ''));
  2028. }
  2029. };
  2030. formatComponentName = function formatComponentName(vm) {
  2031. if (vm.$root === vm) {
  2032. return 'root instance';
  2033. }
  2034. var name = vm._isVue ? vm.$options.name || vm.$options._componentTag : vm.name;
  2035. return name ? 'component <' + name + '>' : 'anonymous component';
  2036. };
  2037. var formatLocation = function formatLocation(str) {
  2038. if (str === 'anonymous component') {
  2039. str += ' - use the "name" option for better debugging messages.)';
  2040. }
  2041. return '(found in ' + str + ')';
  2042. };
  2043. })();
  2044. }
  2045. /**
  2046. * Option overwriting strategies are functions that handle
  2047. * how to merge a parent option value and a child option
  2048. * value into the final value.
  2049. */
  2050. var strats = config.optionMergeStrategies;
  2051. /**
  2052. * Options with restrictions
  2053. */
  2054. if (process.env.NODE_ENV !== 'production') {
  2055. strats.el = strats.propsData = function (parent, child, vm, key) {
  2056. if (!vm) {
  2057. warn('option "' + key + '" can only be used during instance ' + 'creation with the `new` keyword.');
  2058. }
  2059. return defaultStrat(parent, child);
  2060. };
  2061. strats.name = function (parent, child, vm) {
  2062. if (vm) {
  2063. warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
  2064. }
  2065. return defaultStrat(parent, child);
  2066. };
  2067. }
  2068. /**
  2069. * Helper that recursively merges two data objects together.
  2070. */
  2071. function mergeData(to, from) {
  2072. var key = void 0,
  2073. toVal = void 0,
  2074. fromVal = void 0;
  2075. for (key in from) {
  2076. toVal = to[key];
  2077. fromVal = from[key];
  2078. if (!hasOwn(to, key)) {
  2079. set(to, key, fromVal);
  2080. } else if (isObject(toVal) && isObject(fromVal)) {
  2081. mergeData(toVal, fromVal);
  2082. }
  2083. }
  2084. return to;
  2085. }
  2086. /**
  2087. * Data
  2088. */
  2089. strats.data = function (parentVal, childVal, vm) {
  2090. if (!vm) {
  2091. // in a Vue.extend merge, both should be functions
  2092. if (!childVal) {
  2093. return parentVal;
  2094. }
  2095. if (typeof childVal !== 'function') {
  2096. process.env.NODE_ENV !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  2097. return parentVal;
  2098. }
  2099. if (!parentVal) {
  2100. return childVal;
  2101. }
  2102. // when parentVal & childVal are both present,
  2103. // we need to return a function that returns the
  2104. // merged result of both functions... no need to
  2105. // check if parentVal is a function here because
  2106. // it has to be a function to pass previous merges.
  2107. return function mergedDataFn() {
  2108. return mergeData(childVal.call(this), parentVal.call(this));
  2109. };
  2110. } else if (parentVal || childVal) {
  2111. return function mergedInstanceDataFn() {
  2112. // instance merge
  2113. var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
  2114. var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
  2115. if (instanceData) {
  2116. return mergeData(instanceData, defaultData);
  2117. } else {
  2118. return defaultData;
  2119. }
  2120. };
  2121. }
  2122. };
  2123. /**
  2124. * Hooks and param attributes are merged as arrays.
  2125. */
  2126. function mergeHook(parentVal, childVal) {
  2127. return childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [childVal] : parentVal;
  2128. }
  2129. config._lifecycleHooks.forEach(function (hook) {
  2130. strats[hook] = mergeHook;
  2131. });
  2132. /**
  2133. * Assets
  2134. *
  2135. * When a vm is present (instance creation), we need to do
  2136. * a three-way merge between constructor options, instance
  2137. * options and parent options.
  2138. */
  2139. function mergeAssets(parentVal, childVal) {
  2140. var res = Object.create(parentVal || null);
  2141. return childVal ? extend(res, childVal) : res;
  2142. }
  2143. config._assetTypes.forEach(function (type) {
  2144. strats[type + 's'] = mergeAssets;
  2145. });
  2146. /**
  2147. * Watchers.
  2148. *
  2149. * Watchers hashes should not overwrite one
  2150. * another, so we merge them as arrays.
  2151. */
  2152. strats.watch = function (parentVal, childVal) {
  2153. /* istanbul ignore if */
  2154. if (!childVal) return parentVal;
  2155. if (!parentVal) return childVal;
  2156. var ret = {};
  2157. extend(ret, parentVal);
  2158. for (var key in childVal) {
  2159. var parent = ret[key];
  2160. var child = childVal[key];
  2161. if (parent && !Array.isArray(parent)) {
  2162. parent = [parent];
  2163. }
  2164. ret[key] = parent ? parent.concat(child) : [child];
  2165. }
  2166. return ret;
  2167. };
  2168. /**
  2169. * Other object hashes.
  2170. */
  2171. strats.props = strats.methods = strats.computed = function (parentVal, childVal) {
  2172. if (!childVal) return parentVal;
  2173. if (!parentVal) return childVal;
  2174. var ret = Object.create(null);
  2175. extend(ret, parentVal);
  2176. extend(ret, childVal);
  2177. return ret;
  2178. };
  2179. /**
  2180. * Default strategy.
  2181. */
  2182. var defaultStrat = function defaultStrat(parentVal, childVal) {
  2183. return childVal === undefined ? parentVal : childVal;
  2184. };
  2185. /**
  2186. * Make sure component options get converted to actual
  2187. * constructors.
  2188. */
  2189. function normalizeComponents(options) {
  2190. if (options.components) {
  2191. var components = options.components;
  2192. var def = void 0;
  2193. for (var key in components) {
  2194. var lower = key.toLowerCase();
  2195. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  2196. process.env.NODE_ENV !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
  2197. continue;
  2198. }
  2199. def = components[key];
  2200. if (isPlainObject(def)) {
  2201. components[key] = Vue.extend(def);
  2202. }
  2203. }
  2204. }
  2205. }
  2206. /**
  2207. * Ensure all props option syntax are normalized into the
  2208. * Object-based format.
  2209. */
  2210. function normalizeProps(options) {
  2211. var props = options.props;
  2212. if (!props) return;
  2213. var res = {};
  2214. var i = void 0,
  2215. val = void 0,
  2216. name = void 0;
  2217. if (Array.isArray(props)) {
  2218. i = props.length;
  2219. while (i--) {
  2220. val = props[i];
  2221. if (typeof val === 'string') {
  2222. name = camelize(val);
  2223. res[name] = { type: null };
  2224. } else if (process.env.NODE_ENV !== 'production') {
  2225. warn('props must be strings when using array syntax.');
  2226. }
  2227. }
  2228. } else if (isPlainObject(props)) {
  2229. for (var key in props) {
  2230. val = props[key];
  2231. name = camelize(key);
  2232. res[name] = isPlainObject(val) ? val : { type: val };
  2233. }
  2234. }
  2235. options.props = res;
  2236. }
  2237. /**
  2238. * Normalize raw function directives into object format.
  2239. */
  2240. function normalizeDirectives(options) {
  2241. var dirs = options.directives;
  2242. if (dirs) {
  2243. for (var key in dirs) {
  2244. var def = dirs[key];
  2245. if (typeof def === 'function') {
  2246. dirs[key] = { bind: def, update: def };
  2247. }
  2248. }
  2249. }
  2250. }
  2251. /**
  2252. * Merge two option objects into a new one.
  2253. * Core utility used in both instantiation and inheritance.
  2254. */
  2255. function mergeOptions(parent, child, vm) {
  2256. normalizeComponents(child);
  2257. normalizeProps(child);
  2258. normalizeDirectives(child);
  2259. var extendsFrom = child.extends;
  2260. if (extendsFrom) {
  2261. parent = typeof extendsFrom === 'function' ? mergeOptions(parent, extendsFrom.options, vm) : mergeOptions(parent, extendsFrom, vm);
  2262. }
  2263. if (child.mixins) {
  2264. for (var i = 0, l = child.mixins.length; i < l; i++) {
  2265. var mixin = child.mixins[i];
  2266. if (mixin.prototype instanceof Vue) {
  2267. mixin = mixin.options;
  2268. }
  2269. parent = mergeOptions(parent, mixin, vm);
  2270. }
  2271. }
  2272. var options = {};
  2273. var key = void 0;
  2274. for (key in parent) {
  2275. mergeField(key);
  2276. }
  2277. for (key in child) {
  2278. if (!hasOwn(parent, key)) {
  2279. mergeField(key);
  2280. }
  2281. }
  2282. function mergeField(key) {
  2283. var strat = strats[key] || defaultStrat;
  2284. options[key] = strat(parent[key], child[key], vm, key);
  2285. }
  2286. return options;
  2287. }
  2288. /**
  2289. * Resolve an asset.
  2290. * This function is used because child instances need access
  2291. * to assets defined in its ancestor chain.
  2292. */
  2293. function resolveAsset(options, type, id, warnMissing) {
  2294. /* istanbul ignore if */
  2295. if (typeof id !== 'string') {
  2296. return;
  2297. }
  2298. var assets = options[type];
  2299. var res = assets[id] ||
  2300. // camelCase ID
  2301. assets[camelize(id)] ||
  2302. // Pascal Case ID
  2303. assets[capitalize(camelize(id))];
  2304. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  2305. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id, options);
  2306. }
  2307. return res;
  2308. }
  2309. function validateProp(key, propOptions, propsData, vm) {
  2310. /* istanbul ignore if */
  2311. if (!propsData) return;
  2312. var prop = propOptions[key];
  2313. var absent = !hasOwn(propsData, key);
  2314. var value = propsData[key];
  2315. // handle boolean props
  2316. if (prop.type === Boolean) {
  2317. if (absent && !hasOwn(prop, 'default')) {
  2318. value = false;
  2319. } else if (value === '' || value === hyphenate(key)) {
  2320. value = true;
  2321. }
  2322. }
  2323. // check default value
  2324. if (value === undefined) {
  2325. value = getPropDefaultValue(vm, prop, key);
  2326. // since the default value is a fresh copy,
  2327. // make sure to observe it.
  2328. var prevShouldConvert = observerState.shouldConvert;
  2329. observerState.shouldConvert = true;
  2330. observe(value);
  2331. observerState.shouldConvert = prevShouldConvert;
  2332. }
  2333. if (process.env.NODE_ENV !== 'production') {
  2334. assertProp(prop, key, value, vm, absent);
  2335. }
  2336. return value;
  2337. }
  2338. /**
  2339. * Get the default value of a prop.
  2340. */
  2341. function getPropDefaultValue(vm, prop, name) {
  2342. // no default, return undefined
  2343. if (!hasOwn(prop, 'default')) {
  2344. return undefined;
  2345. }
  2346. var def = prop.default;
  2347. // warn against non-factory defaults for Object & Array
  2348. if (isObject(def)) {
  2349. process.env.NODE_ENV !== 'production' && warn('Invalid default value for prop "' + name + '": ' + 'Props with type Object/Array must use a factory function ' + 'to return the default value.', vm);
  2350. }
  2351. // call factory function for non-Function types
  2352. return typeof def === 'function' && prop.type !== Function ? def.call(vm) : def;
  2353. }
  2354. /**
  2355. * Assert whether a prop is valid.
  2356. */
  2357. function assertProp(prop, name, value, vm, absent) {
  2358. if (prop.required && absent) {
  2359. warn('Missing required prop: "' + name + '"', vm);
  2360. return;
  2361. }
  2362. if (value == null && !prop.required) {
  2363. return;
  2364. }
  2365. var type = prop.type;
  2366. var valid = !type;
  2367. var expectedTypes = [];
  2368. if (type) {
  2369. if (!Array.isArray(type)) {
  2370. type = [type];
  2371. }
  2372. for (var i = 0; i < type.length && !valid; i++) {
  2373. var assertedType = assertType(value, type[i]);
  2374. expectedTypes.push(assertedType.expectedType);
  2375. valid = assertedType.valid;
  2376. }
  2377. }
  2378. if (!valid) {
  2379. warn('Invalid prop: type check failed for prop "' + name + '".' + ' Expected ' + expectedTypes.map(capitalize).join(', ') + ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.', vm);
  2380. return;
  2381. }
  2382. var validator = prop.validator;
  2383. if (validator) {
  2384. if (!validator(value)) {
  2385. warn('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  2386. }
  2387. }
  2388. }
  2389. /**
  2390. * Assert the type of a value
  2391. */
  2392. function assertType(value, type) {
  2393. var valid = void 0;
  2394. var expectedType = void 0;
  2395. if (type === String) {
  2396. expectedType = 'string';
  2397. valid = typeof value === expectedType;
  2398. } else if (type === Number) {
  2399. expectedType = 'number';
  2400. valid = typeof value === expectedType;
  2401. } else if (type === Boolean) {
  2402. expectedType = 'boolean';
  2403. valid = typeof value === expectedType;
  2404. } else if (type === Function) {
  2405. expectedType = 'function';
  2406. valid = typeof value === expectedType;
  2407. } else if (type === Object) {
  2408. expectedType = 'Object';
  2409. valid = isPlainObject(value);
  2410. } else if (type === Array) {
  2411. expectedType = 'Array';
  2412. valid = Array.isArray(value);
  2413. } else {
  2414. expectedType = type.name || type.toString();
  2415. valid = value instanceof type;
  2416. }
  2417. return {
  2418. valid: valid,
  2419. expectedType: expectedType
  2420. };
  2421. }
  2422. var util = Object.freeze({
  2423. defineReactive: defineReactive,
  2424. _toString: _toString,
  2425. toNumber: toNumber,
  2426. makeMap: makeMap,
  2427. isBuiltInTag: isBuiltInTag,
  2428. remove: remove,
  2429. hasOwn: hasOwn,
  2430. isPrimitive: isPrimitive,
  2431. cached: cached,
  2432. camelize: camelize,
  2433. capitalize: capitalize,
  2434. hyphenate: hyphenate,
  2435. bind: bind,
  2436. toArray: toArray,
  2437. extend: extend,
  2438. isObject: isObject,
  2439. isPlainObject: isPlainObject,
  2440. toObject: toObject,
  2441. noop: noop,
  2442. no: no,
  2443. genStaticKeys: genStaticKeys,
  2444. isReserved: isReserved,
  2445. def: def,
  2446. parsePath: parsePath,
  2447. hasProto: hasProto,
  2448. inBrowser: inBrowser,
  2449. devtools: devtools,
  2450. UA: UA,
  2451. nextTick: nextTick,
  2452. get _Set () { return _Set; },
  2453. mergeOptions: mergeOptions,
  2454. resolveAsset: resolveAsset,
  2455. get warn () { return warn; },
  2456. get formatComponentName () { return formatComponentName; },
  2457. validateProp: validateProp
  2458. });
  2459. function initUse(Vue) {
  2460. Vue.use = function (plugin) {
  2461. /* istanbul ignore if */
  2462. if (plugin.installed) {
  2463. return;
  2464. }
  2465. // additional parameters
  2466. var args = toArray(arguments, 1);
  2467. args.unshift(this);
  2468. if (typeof plugin.install === 'function') {
  2469. plugin.install.apply(plugin, args);
  2470. } else {
  2471. plugin.apply(null, args);
  2472. }
  2473. plugin.installed = true;
  2474. return this;
  2475. };
  2476. }
  2477. function initMixin$1(Vue) {
  2478. Vue.mixin = function (mixin) {
  2479. Vue.options = mergeOptions(Vue.options, mixin);
  2480. };
  2481. }
  2482. function initExtend(Vue) {
  2483. /**
  2484. * Each instance constructor, including Vue, has a unique
  2485. * cid. This enables us to create wrapped "child
  2486. * constructors" for prototypal inheritance and cache them.
  2487. */
  2488. Vue.cid = 0;
  2489. var cid = 1;
  2490. /**
  2491. * Class inheritance
  2492. */
  2493. Vue.extend = function (extendOptions) {
  2494. extendOptions = extendOptions || {};
  2495. var Super = this;
  2496. var isFirstExtend = Super.cid === 0;
  2497. if (isFirstExtend && extendOptions._Ctor) {
  2498. return extendOptions._Ctor;
  2499. }
  2500. var name = extendOptions.name || Super.options.name;
  2501. if (process.env.NODE_ENV !== 'production') {
  2502. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  2503. warn('Invalid component name: "' + name + '". Component names ' + 'can only contain alphanumeric characaters and the hyphen.');
  2504. name = null;
  2505. }
  2506. }
  2507. var Sub = function VueComponent(options) {
  2508. this._init(options);
  2509. };
  2510. Sub.prototype = Object.create(Super.prototype);
  2511. Sub.prototype.constructor = Sub;
  2512. Sub.cid = cid++;
  2513. Sub.options = mergeOptions(Super.options, extendOptions);
  2514. Sub['super'] = Super;
  2515. // allow further extension
  2516. Sub.extend = Super.extend;
  2517. // create asset registers, so extended classes
  2518. // can have their private assets too.
  2519. config._assetTypes.forEach(function (type) {
  2520. Sub[type] = Super[type];
  2521. });
  2522. // enable recursive self-lookup
  2523. if (name) {
  2524. Sub.options.components[name] = Sub;
  2525. }
  2526. // keep a reference to the super options at extension time.
  2527. // later at instantiation we can check if Super's options have
  2528. // been updated.
  2529. Sub.superOptions = Super.options;
  2530. Sub.extendOptions = extendOptions;
  2531. // cache constructor
  2532. if (isFirstExtend) {
  2533. extendOptions._Ctor = Sub;
  2534. }
  2535. return Sub;
  2536. };
  2537. }
  2538. function initAssetRegisters(Vue) {
  2539. /**
  2540. * Create asset registration methods.
  2541. */
  2542. config._assetTypes.forEach(function (type) {
  2543. Vue[type] = function (id, definition) {
  2544. if (!definition) {
  2545. return this.options[type + 's'][id];
  2546. } else {
  2547. /* istanbul ignore if */
  2548. if (process.env.NODE_ENV !== 'production') {
  2549. if (type === 'component' && config.isReservedTag(id)) {
  2550. warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + id);
  2551. }
  2552. }
  2553. if (type === 'component' && isPlainObject(definition)) {
  2554. definition.name = definition.name || id;
  2555. definition = Vue.extend(definition);
  2556. }
  2557. if (type === 'directive' && typeof definition === 'function') {
  2558. definition = { bind: definition, update: definition };
  2559. }
  2560. this.options[type + 's'][id] = definition;
  2561. return definition;
  2562. }
  2563. };
  2564. });
  2565. }
  2566. var KeepAlive = {
  2567. name: 'keep-alive',
  2568. abstract: true,
  2569. props: {
  2570. child: Object
  2571. },
  2572. created: function created() {
  2573. this.cache = Object.create(null);
  2574. },
  2575. render: function render() {
  2576. var rawChild = this.child;
  2577. var realChild = getRealChild(this.child);
  2578. if (realChild && realChild.componentOptions) {
  2579. var opts = realChild.componentOptions;
  2580. // same constructor may get registered as different local components
  2581. // so cid alone is not enough (#3269)
  2582. var key = opts.Ctor.cid + '::' + opts.tag;
  2583. if (this.cache[key]) {
  2584. var child = realChild.child = this.cache[key].child;
  2585. realChild.elm = this.$el = child.$el;
  2586. } else {
  2587. this.cache[key] = realChild;
  2588. }
  2589. realChild.data.keepAlive = true;
  2590. }
  2591. return rawChild;
  2592. },
  2593. destroyed: function destroyed() {
  2594. for (var key in this.cache) {
  2595. var vnode = this.cache[key];
  2596. callHook(vnode.child, 'deactivated');
  2597. vnode.child.$destroy();
  2598. }
  2599. }
  2600. };
  2601. var builtInComponents = {
  2602. KeepAlive: KeepAlive
  2603. };
  2604. function initGlobalAPI(Vue) {
  2605. // config
  2606. var configDef = {};
  2607. configDef.get = function () {
  2608. return config;
  2609. };
  2610. if (process.env.NODE_ENV !== 'production') {
  2611. configDef.set = function () {
  2612. warn('Do not replace the Vue.config object, set individual fields instead.');
  2613. };
  2614. }
  2615. Object.defineProperty(Vue, 'config', configDef);
  2616. Vue.util = util;
  2617. Vue.set = set;
  2618. Vue.delete = del;
  2619. Vue.nextTick = nextTick;
  2620. Vue.options = Object.create(null);
  2621. config._assetTypes.forEach(function (type) {
  2622. Vue.options[type + 's'] = Object.create(null);
  2623. });
  2624. extend(Vue.options.components, builtInComponents);
  2625. initUse(Vue);
  2626. initMixin$1(Vue);
  2627. initExtend(Vue);
  2628. initAssetRegisters(Vue);
  2629. }
  2630. initGlobalAPI(Vue);
  2631. Object.defineProperty(Vue.prototype, '$isServer', {
  2632. get: function get() {
  2633. return config._isServer;
  2634. }
  2635. });
  2636. Vue.version = '2.0.0-beta.6';
  2637. // attributes that should be using props for binding
  2638. var mustUseProp = makeMap('value,selected,checked,muted');
  2639. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  2640. var isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 'required,reversed,scoped,seamless,selected,sortable,translate,' + 'truespeed,typemustmatch,visible');
  2641. var isAttr = makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' + 'form,formaction,headers,<th>,height,hidden,high,href,hreflang,http-equiv,' + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' + 'target,title,type,usemap,value,width,wrap');
  2642. var xlinkNS = 'http://www.w3.org/1999/xlink';
  2643. var isXlink = function isXlink(name) {
  2644. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  2645. };
  2646. var getXlinkProp = function getXlinkProp(name) {
  2647. return isXlink(name) ? name.slice(6, name.length) : '';
  2648. };
  2649. var isFalsyAttrValue = function isFalsyAttrValue(val) {
  2650. return val == null || val === false;
  2651. };
  2652. function genClassForVnode(vnode) {
  2653. var data = vnode.data;
  2654. var parentNode = vnode;
  2655. var childNode = vnode;
  2656. while (childNode.child) {
  2657. childNode = childNode.child._vnode;
  2658. if (childNode.data) {
  2659. data = mergeClassData(childNode.data, data);
  2660. }
  2661. }
  2662. while (parentNode = parentNode.parent) {
  2663. if (parentNode.data) {
  2664. data = mergeClassData(data, parentNode.data);
  2665. }
  2666. }
  2667. return genClassFromData(data);
  2668. }
  2669. function mergeClassData(child, parent) {
  2670. return {
  2671. staticClass: concat(child.staticClass, parent.staticClass),
  2672. class: child.class ? [child.class, parent.class] : parent.class
  2673. };
  2674. }
  2675. function genClassFromData(data) {
  2676. var dynamicClass = data.class;
  2677. var staticClass = data.staticClass;
  2678. if (staticClass || dynamicClass) {
  2679. return concat(staticClass, stringifyClass(dynamicClass));
  2680. }
  2681. /* istanbul ignore next */
  2682. return '';
  2683. }
  2684. function concat(a, b) {
  2685. return a ? b ? a + ' ' + b : a : b || '';
  2686. }
  2687. function stringifyClass(value) {
  2688. var res = '';
  2689. if (!value) {
  2690. return res;
  2691. }
  2692. if (typeof value === 'string') {
  2693. return value;
  2694. }
  2695. if (Array.isArray(value)) {
  2696. var stringified = void 0;
  2697. for (var i = 0, l = value.length; i < l; i++) {
  2698. if (value[i]) {
  2699. if (stringified = stringifyClass(value[i])) {
  2700. res += stringified + ' ';
  2701. }
  2702. }
  2703. }
  2704. return res.slice(0, -1);
  2705. }
  2706. if (isObject(value)) {
  2707. for (var key in value) {
  2708. if (value[key]) res += key + ' ';
  2709. }
  2710. return res.slice(0, -1);
  2711. }
  2712. /* istanbul ignore next */
  2713. return res;
  2714. }
  2715. var namespaceMap = {
  2716. svg: 'http://www.w3.org/2000/svg',
  2717. math: 'http://www.w3.org/1998/Math/MathML'
  2718. };
  2719. var isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' + 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' + 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 'embed,object,param,source,canvas,script,noscript,del,ins,' + 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 'output,progress,select,textarea,' + 'details,dialog,menu,menuitem,summary,' + 'content,element,shadow,template');
  2720. var isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 'link,meta,param,source,track,wbr', true);
  2721. // Elements that you can, intentionally, leave open
  2722. // (and which close themselves)
  2723. var canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source', true);
  2724. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  2725. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  2726. var isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 'title,tr,track', true);
  2727. // this map is intentionally selective, only covering SVG elements that may
  2728. // contain child elements.
  2729. var isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font,' + 'font-face,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  2730. var isReservedTag = function isReservedTag(tag) {
  2731. return isHTMLTag(tag) || isSVG(tag);
  2732. };
  2733. function getTagNamespace(tag) {
  2734. if (isSVG(tag)) {
  2735. return 'svg';
  2736. }
  2737. // basic support for MathML
  2738. // note it doesn't support other MathML elements being component roots
  2739. if (tag === 'math') {
  2740. return 'math';
  2741. }
  2742. }
  2743. var unknownElementCache = Object.create(null);
  2744. function isUnknownElement(tag) {
  2745. /* istanbul ignore if */
  2746. if (!inBrowser) {
  2747. return true;
  2748. }
  2749. if (isReservedTag(tag)) {
  2750. return false;
  2751. }
  2752. tag = tag.toLowerCase();
  2753. /* istanbul ignore if */
  2754. if (unknownElementCache[tag] != null) {
  2755. return unknownElementCache[tag];
  2756. }
  2757. var el = document.createElement(tag);
  2758. if (tag.indexOf('-') > -1) {
  2759. // http://stackoverflow.com/a/28210364/1070244
  2760. return unknownElementCache[tag] = el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
  2761. } else {
  2762. return unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString());
  2763. }
  2764. }
  2765. var UA$1 = inBrowser && window.navigator.userAgent.toLowerCase();
  2766. var isIE = UA$1 && /msie|trident/.test(UA$1);
  2767. var isIE9 = UA$1 && UA$1.indexOf('msie 9.0') > 0;
  2768. var isAndroid = UA$1 && UA$1.indexOf('android') > 0;
  2769. // some browsers, e.g. PhantomJS, encodes angular brackets
  2770. // inside attribute values when retrieving innerHTML.
  2771. // this causes problems with the in-browser parser.
  2772. var shouldDecodeTags = inBrowser ? function () {
  2773. var div = document.createElement('div');
  2774. div.innerHTML = '<div a=">">';
  2775. return div.innerHTML.indexOf('&gt;') > 0;
  2776. }() : false;
  2777. /**
  2778. * Query an element selector if it's not an element already.
  2779. */
  2780. function query(el) {
  2781. if (typeof el === 'string') {
  2782. var selector = el;
  2783. el = document.querySelector(el);
  2784. if (!el) {
  2785. process.env.NODE_ENV !== 'production' && warn('Cannot find element: ' + selector);
  2786. return document.createElement('div');
  2787. }
  2788. }
  2789. return el;
  2790. }
  2791. function createElement$1(tagName) {
  2792. return document.createElement(tagName);
  2793. }
  2794. function createElementNS(namespace, tagName) {
  2795. return document.createElementNS(namespaceMap[namespace], tagName);
  2796. }
  2797. function createTextNode(text) {
  2798. return document.createTextNode(text);
  2799. }
  2800. function insertBefore(parentNode, newNode, referenceNode) {
  2801. parentNode.insertBefore(newNode, referenceNode);
  2802. }
  2803. function removeChild(node, child) {
  2804. node.removeChild(child);
  2805. }
  2806. function appendChild(node, child) {
  2807. node.appendChild(child);
  2808. }
  2809. function parentNode(node) {
  2810. return node.parentNode;
  2811. }
  2812. function nextSibling(node) {
  2813. return node.nextSibling;
  2814. }
  2815. function tagName(node) {
  2816. return node.tagName;
  2817. }
  2818. function setTextContent(node, text) {
  2819. node.textContent = text;
  2820. }
  2821. function childNodes(node) {
  2822. return node.childNodes;
  2823. }
  2824. function setAttribute(node, key, val) {
  2825. node.setAttribute(key, val);
  2826. }
  2827. var nodeOps = Object.freeze({
  2828. createElement: createElement$1,
  2829. createElementNS: createElementNS,
  2830. createTextNode: createTextNode,
  2831. insertBefore: insertBefore,
  2832. removeChild: removeChild,
  2833. appendChild: appendChild,
  2834. parentNode: parentNode,
  2835. nextSibling: nextSibling,
  2836. tagName: tagName,
  2837. setTextContent: setTextContent,
  2838. childNodes: childNodes,
  2839. setAttribute: setAttribute
  2840. });
  2841. var emptyData = {};
  2842. var emptyNode = new VNode('', emptyData, []);
  2843. var hooks$1 = ['create', 'update', 'postpatch', 'remove', 'destroy'];
  2844. function isUndef(s) {
  2845. return s == null;
  2846. }
  2847. function isDef(s) {
  2848. return s != null;
  2849. }
  2850. function sameVnode(vnode1, vnode2) {
  2851. if (vnode1.isStatic || vnode2.isStatic) {
  2852. return vnode1 === vnode2;
  2853. }
  2854. return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag && !vnode1.data === !vnode2.data;
  2855. }
  2856. function createKeyToOldIdx(children, beginIdx, endIdx) {
  2857. var i = void 0,
  2858. key = void 0;
  2859. var map = {};
  2860. for (i = beginIdx; i <= endIdx; ++i) {
  2861. key = children[i].key;
  2862. if (isDef(key)) map[key] = i;
  2863. }
  2864. return map;
  2865. }
  2866. function createPatchFunction(backend) {
  2867. var i = void 0,
  2868. j = void 0;
  2869. var cbs = {};
  2870. var modules = backend.modules;
  2871. var nodeOps = backend.nodeOps;
  2872. for (i = 0; i < hooks$1.length; ++i) {
  2873. cbs[hooks$1[i]] = [];
  2874. for (j = 0; j < modules.length; ++j) {
  2875. if (modules[j][hooks$1[i]] !== undefined) cbs[hooks$1[i]].push(modules[j][hooks$1[i]]);
  2876. }
  2877. }
  2878. function emptyNodeAt(elm) {
  2879. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  2880. }
  2881. function createRmCb(childElm, listeners) {
  2882. function remove() {
  2883. if (--remove.listeners === 0) {
  2884. removeElement(childElm);
  2885. }
  2886. }
  2887. remove.listeners = listeners;
  2888. return remove;
  2889. }
  2890. function removeElement(el) {
  2891. var parent = nodeOps.parentNode(el);
  2892. nodeOps.removeChild(parent, el);
  2893. }
  2894. function createElm(vnode, insertedVnodeQueue) {
  2895. var i = void 0,
  2896. elm = void 0;
  2897. var data = vnode.data;
  2898. if (isDef(data)) {
  2899. if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode);
  2900. // after calling the init hook, if the vnode is a child component
  2901. // it should've created a child instance and mounted it. the child
  2902. // component also has set the placeholder vnode's elm.
  2903. // in that case we can just return the element and be done.
  2904. if (isDef(i = vnode.child)) {
  2905. if (vnode.data.pendingInsert) {
  2906. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  2907. }
  2908. vnode.elm = vnode.child.$el;
  2909. invokeCreateHooks(vnode, insertedVnodeQueue);
  2910. setScope(vnode);
  2911. return vnode.elm;
  2912. }
  2913. }
  2914. var children = vnode.children;
  2915. var tag = vnode.tag;
  2916. if (isDef(tag)) {
  2917. if (process.env.NODE_ENV !== 'production') {
  2918. if (!vnode.ns && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
  2919. warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.', vnode.context);
  2920. }
  2921. }
  2922. elm = vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag);
  2923. setScope(vnode);
  2924. if (Array.isArray(children)) {
  2925. for (i = 0; i < children.length; ++i) {
  2926. nodeOps.appendChild(elm, createElm(children[i], insertedVnodeQueue));
  2927. }
  2928. } else if (isPrimitive(vnode.text)) {
  2929. nodeOps.appendChild(elm, nodeOps.createTextNode(vnode.text));
  2930. }
  2931. if (isDef(data)) {
  2932. invokeCreateHooks(vnode, insertedVnodeQueue);
  2933. }
  2934. } else {
  2935. elm = vnode.elm = nodeOps.createTextNode(vnode.text);
  2936. }
  2937. return vnode.elm;
  2938. }
  2939. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  2940. for (var _i = 0; _i < cbs.create.length; ++_i) {
  2941. cbs.create[_i](emptyNode, vnode);
  2942. }
  2943. i = vnode.data.hook; // Reuse variable
  2944. if (isDef(i)) {
  2945. if (i.create) i.create(emptyNode, vnode);
  2946. if (i.insert) insertedVnodeQueue.push(vnode);
  2947. }
  2948. }
  2949. // set scope id attribute for scoped CSS.
  2950. // this is implemented as a special case to avoid the overhead
  2951. // of going through the normal attribute patching process.
  2952. function setScope(vnode) {
  2953. var i = void 0;
  2954. if (isDef(i = vnode.host) && isDef(i = i.$options._scopeId)) {
  2955. nodeOps.setAttribute(vnode.elm, i, '');
  2956. }
  2957. if (isDef(i = vnode.context) && isDef(i = i.$options._scopeId)) {
  2958. nodeOps.setAttribute(vnode.elm, i, '');
  2959. }
  2960. }
  2961. function addVnodes(parentElm, before, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  2962. for (; startIdx <= endIdx; ++startIdx) {
  2963. nodeOps.insertBefore(parentElm, createElm(vnodes[startIdx], insertedVnodeQueue), before);
  2964. }
  2965. }
  2966. function invokeDestroyHook(vnode) {
  2967. var i = void 0,
  2968. j = void 0;
  2969. var data = vnode.data;
  2970. if (isDef(data)) {
  2971. if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
  2972. for (i = 0; i < cbs.destroy.length; ++i) {
  2973. cbs.destroy[i](vnode);
  2974. }
  2975. }
  2976. if (isDef(i = vnode.child) && !data.keepAlive) {
  2977. invokeDestroyHook(i._vnode);
  2978. }
  2979. if (isDef(i = vnode.children)) {
  2980. for (j = 0; j < vnode.children.length; ++j) {
  2981. invokeDestroyHook(vnode.children[j]);
  2982. }
  2983. }
  2984. }
  2985. function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
  2986. for (; startIdx <= endIdx; ++startIdx) {
  2987. var ch = vnodes[startIdx];
  2988. if (isDef(ch)) {
  2989. if (isDef(ch.tag)) {
  2990. invokeDestroyHook(ch);
  2991. removeAndInvokeRemoveHook(ch);
  2992. } else {
  2993. // Text node
  2994. nodeOps.removeChild(parentElm, ch.elm);
  2995. }
  2996. }
  2997. }
  2998. }
  2999. function removeAndInvokeRemoveHook(vnode, rm) {
  3000. if (rm || isDef(vnode.data)) {
  3001. var listeners = cbs.remove.length + 1;
  3002. if (!rm) {
  3003. // directly removing
  3004. rm = createRmCb(vnode.elm, listeners);
  3005. } else {
  3006. // we have a recursively passed down rm callback
  3007. // increase the listeners count
  3008. rm.listeners += listeners;
  3009. }
  3010. // recursively invoke hooks on child component root node
  3011. if (isDef(i = vnode.child) && isDef(i = i._vnode) && isDef(i.data)) {
  3012. removeAndInvokeRemoveHook(i, rm);
  3013. }
  3014. for (i = 0; i < cbs.remove.length; ++i) {
  3015. cbs.remove[i](vnode, rm);
  3016. }
  3017. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  3018. i(vnode, rm);
  3019. } else {
  3020. rm();
  3021. }
  3022. } else {
  3023. removeElement(vnode.elm);
  3024. }
  3025. }
  3026. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  3027. var oldStartIdx = 0;
  3028. var newStartIdx = 0;
  3029. var oldEndIdx = oldCh.length - 1;
  3030. var oldStartVnode = oldCh[0];
  3031. var oldEndVnode = oldCh[oldEndIdx];
  3032. var newEndIdx = newCh.length - 1;
  3033. var newStartVnode = newCh[0];
  3034. var newEndVnode = newCh[newEndIdx];
  3035. var oldKeyToIdx = void 0,
  3036. idxInOld = void 0,
  3037. elmToMove = void 0,
  3038. before = void 0;
  3039. // removeOnly is a special flag used only by <transition-group>
  3040. // to ensure removed elements stay in correct relative positions
  3041. // during leaving transitions
  3042. var canMove = !removeOnly;
  3043. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  3044. if (isUndef(oldStartVnode)) {
  3045. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  3046. } else if (isUndef(oldEndVnode)) {
  3047. oldEndVnode = oldCh[--oldEndIdx];
  3048. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  3049. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  3050. oldStartVnode = oldCh[++oldStartIdx];
  3051. newStartVnode = newCh[++newStartIdx];
  3052. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  3053. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  3054. oldEndVnode = oldCh[--oldEndIdx];
  3055. newEndVnode = newCh[--newEndIdx];
  3056. } else if (sameVnode(oldStartVnode, newEndVnode)) {
  3057. // Vnode moved right
  3058. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  3059. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  3060. oldStartVnode = oldCh[++oldStartIdx];
  3061. newEndVnode = newCh[--newEndIdx];
  3062. } else if (sameVnode(oldEndVnode, newStartVnode)) {
  3063. // Vnode moved left
  3064. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  3065. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  3066. oldEndVnode = oldCh[--oldEndIdx];
  3067. newStartVnode = newCh[++newStartIdx];
  3068. } else {
  3069. if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  3070. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : newStartVnode.isStatic ? oldCh.indexOf(newStartVnode) : null;
  3071. if (isUndef(idxInOld) || idxInOld === -1) {
  3072. // New element
  3073. nodeOps.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
  3074. newStartVnode = newCh[++newStartIdx];
  3075. } else {
  3076. elmToMove = oldCh[idxInOld];
  3077. /* istanbul ignore if */
  3078. if (process.env.NODE_ENV !== 'production' && !elmToMove) {
  3079. warn('It seems there are duplicate keys that is causing an update error. ' + 'Make sure each v-for item has a unique key.');
  3080. }
  3081. if (elmToMove.tag !== newStartVnode.tag) {
  3082. // same key but different element. treat as new element
  3083. nodeOps.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
  3084. newStartVnode = newCh[++newStartIdx];
  3085. } else {
  3086. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  3087. oldCh[idxInOld] = undefined;
  3088. canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
  3089. newStartVnode = newCh[++newStartIdx];
  3090. }
  3091. }
  3092. }
  3093. }
  3094. if (oldStartIdx > oldEndIdx) {
  3095. before = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  3096. addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  3097. } else if (newStartIdx > newEndIdx) {
  3098. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  3099. }
  3100. }
  3101. function patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  3102. if (oldVnode === vnode) return;
  3103. var i = void 0,
  3104. hook = void 0;
  3105. var hasData = isDef(i = vnode.data);
  3106. if (hasData && isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
  3107. i(oldVnode, vnode);
  3108. }
  3109. var elm = vnode.elm = oldVnode.elm;
  3110. var oldCh = oldVnode.children;
  3111. var ch = vnode.children;
  3112. if (hasData) {
  3113. for (i = 0; i < cbs.update.length; ++i) {
  3114. cbs.update[i](oldVnode, vnode);
  3115. }if (isDef(hook) && isDef(i = hook.update)) i(oldVnode, vnode);
  3116. }
  3117. if (isUndef(vnode.text)) {
  3118. if (isDef(oldCh) && isDef(ch)) {
  3119. if (oldCh !== ch) updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  3120. } else if (isDef(ch)) {
  3121. if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '');
  3122. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  3123. } else if (isDef(oldCh)) {
  3124. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  3125. } else if (isDef(oldVnode.text)) {
  3126. nodeOps.setTextContent(elm, '');
  3127. }
  3128. } else if (oldVnode.text !== vnode.text) {
  3129. nodeOps.setTextContent(elm, vnode.text);
  3130. }
  3131. if (hasData) {
  3132. for (i = 0; i < cbs.postpatch.length; ++i) {
  3133. cbs.postpatch[i](oldVnode, vnode);
  3134. }if (isDef(hook) && isDef(i = hook.postpatch)) i(oldVnode, vnode);
  3135. }
  3136. }
  3137. function invokeInsertHook(vnode, queue, initial) {
  3138. // delay insert hooks for component root nodes, invoke them after the
  3139. // element is really inserted
  3140. if (initial && vnode.parent) {
  3141. vnode.parent.data.pendingInsert = queue;
  3142. } else {
  3143. for (var _i2 = 0; _i2 < queue.length; ++_i2) {
  3144. queue[_i2].data.hook.insert(queue[_i2]);
  3145. }
  3146. }
  3147. }
  3148. function hydrate(elm, vnode, insertedVnodeQueue) {
  3149. if (process.env.NODE_ENV !== 'production') {
  3150. if (!assertNodeMatch(elm, vnode)) {
  3151. return false;
  3152. }
  3153. }
  3154. vnode.elm = elm;
  3155. var tag = vnode.tag;
  3156. var data = vnode.data;
  3157. var children = vnode.children;
  3158. if (isDef(data)) {
  3159. if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */);
  3160. if (isDef(i = vnode.child)) {
  3161. // child component. it should have hydrated its own tree.
  3162. invokeCreateHooks(vnode, insertedVnodeQueue);
  3163. return true;
  3164. }
  3165. }
  3166. if (isDef(tag)) {
  3167. if (isDef(children)) {
  3168. var childNodes = nodeOps.childNodes(elm);
  3169. for (var _i3 = 0; _i3 < children.length; _i3++) {
  3170. var success = hydrate(childNodes[_i3], children[_i3], insertedVnodeQueue);
  3171. if (!success) {
  3172. return false;
  3173. }
  3174. }
  3175. }
  3176. if (isDef(data)) {
  3177. invokeCreateHooks(vnode, insertedVnodeQueue);
  3178. }
  3179. }
  3180. return true;
  3181. }
  3182. function assertNodeMatch(node, vnode) {
  3183. var match = true;
  3184. if (!node) {
  3185. match = false;
  3186. } else if (vnode.tag) {
  3187. match = vnode.tag.indexOf('vue-component') === 0 || vnode.tag === nodeOps.tagName(node).toLowerCase();
  3188. } else {
  3189. match = _toString(vnode.text) === node.data;
  3190. }
  3191. if (process.env.NODE_ENV !== 'production' && !match) {
  3192. warn('The client-side rendered virtual DOM tree is not matching ' + 'server-rendered content. Bailing hydration and performing ' + 'full client-side render.');
  3193. }
  3194. return match;
  3195. }
  3196. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  3197. var elm = void 0,
  3198. parent = void 0;
  3199. var isInitialPatch = false;
  3200. var insertedVnodeQueue = [];
  3201. if (!oldVnode) {
  3202. // empty mount, create new root element
  3203. isInitialPatch = true;
  3204. createElm(vnode, insertedVnodeQueue);
  3205. } else {
  3206. var isRealElement = isDef(oldVnode.nodeType);
  3207. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  3208. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  3209. } else {
  3210. if (isRealElement) {
  3211. // mounting to a real element
  3212. // check if this is server-rendered content and if we can perform
  3213. // a successful hydration.
  3214. if (oldVnode.hasAttribute('server-rendered')) {
  3215. oldVnode.removeAttribute('server-rendered');
  3216. hydrating = true;
  3217. }
  3218. if (hydrating) {
  3219. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  3220. invokeInsertHook(vnode, insertedVnodeQueue, true);
  3221. return oldVnode;
  3222. }
  3223. }
  3224. // either not server-rendered, or hydration failed.
  3225. // create an empty node and replace it
  3226. oldVnode = emptyNodeAt(oldVnode);
  3227. }
  3228. elm = oldVnode.elm;
  3229. parent = nodeOps.parentNode(elm);
  3230. createElm(vnode, insertedVnodeQueue);
  3231. // component root element replaced.
  3232. // update parent placeholder node element.
  3233. if (vnode.parent) {
  3234. vnode.parent.elm = vnode.elm;
  3235. for (var _i4 = 0; _i4 < cbs.create.length; ++_i4) {
  3236. cbs.create[_i4](emptyNode, vnode.parent);
  3237. }
  3238. }
  3239. if (parent !== null) {
  3240. nodeOps.insertBefore(parent, vnode.elm, nodeOps.nextSibling(elm));
  3241. removeVnodes(parent, [oldVnode], 0, 0);
  3242. } else if (isDef(oldVnode.tag)) {
  3243. invokeDestroyHook(oldVnode);
  3244. }
  3245. }
  3246. }
  3247. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  3248. return vnode.elm;
  3249. };
  3250. }
  3251. var directives = {
  3252. create: function bindDirectives(oldVnode, vnode) {
  3253. applyDirectives(oldVnode, vnode, 'bind');
  3254. },
  3255. update: function updateDirectives(oldVnode, vnode) {
  3256. applyDirectives(oldVnode, vnode, 'update');
  3257. },
  3258. postpatch: function postupdateDirectives(oldVnode, vnode) {
  3259. applyDirectives(oldVnode, vnode, 'componentUpdated');
  3260. },
  3261. destroy: function unbindDirectives(vnode) {
  3262. applyDirectives(vnode, vnode, 'unbind');
  3263. }
  3264. };
  3265. var emptyModifiers = Object.create(null);
  3266. function applyDirectives(oldVnode, vnode, hook) {
  3267. var dirs = vnode.data.directives;
  3268. if (dirs) {
  3269. var oldDirs = oldVnode.data.directives;
  3270. var isUpdate = hook === 'update';
  3271. for (var i = 0; i < dirs.length; i++) {
  3272. var dir = dirs[i];
  3273. var def = resolveAsset(vnode.context.$options, 'directives', dir.name, true);
  3274. var fn = def && def[hook];
  3275. if (fn) {
  3276. if (isUpdate && oldDirs) {
  3277. dir.oldValue = oldDirs[i].value;
  3278. }
  3279. if (!dir.modifiers) {
  3280. dir.modifiers = emptyModifiers;
  3281. }
  3282. fn(vnode.elm, dir, vnode, oldVnode);
  3283. }
  3284. }
  3285. }
  3286. }
  3287. var ref = {
  3288. create: function create(_, vnode) {
  3289. registerRef(vnode);
  3290. },
  3291. update: function update(oldVnode, vnode) {
  3292. if (oldVnode.data.ref !== vnode.data.ref) {
  3293. registerRef(oldVnode, true);
  3294. registerRef(vnode);
  3295. }
  3296. },
  3297. destroy: function destroy(vnode) {
  3298. registerRef(vnode, true);
  3299. }
  3300. };
  3301. function registerRef(vnode, isRemoval) {
  3302. var key = vnode.data.ref;
  3303. if (!key) return;
  3304. var vm = vnode.context;
  3305. var ref = vnode.child || vnode.elm;
  3306. var refs = vm.$refs;
  3307. if (isRemoval) {
  3308. if (Array.isArray(refs[key])) {
  3309. remove(refs[key], ref);
  3310. } else if (refs[key] === ref) {
  3311. refs[key] = undefined;
  3312. }
  3313. } else {
  3314. if (vnode.data.refInFor) {
  3315. if (Array.isArray(refs[key])) {
  3316. refs[key].push(ref);
  3317. } else {
  3318. refs[key] = [ref];
  3319. }
  3320. } else {
  3321. refs[key] = ref;
  3322. }
  3323. }
  3324. }
  3325. var baseModules = [ref, directives];
  3326. function updateAttrs(oldVnode, vnode) {
  3327. if (!oldVnode.data.attrs && !vnode.data.attrs) {
  3328. return;
  3329. }
  3330. var key = void 0,
  3331. cur = void 0,
  3332. old = void 0;
  3333. var elm = vnode.elm;
  3334. var oldAttrs = oldVnode.data.attrs || {};
  3335. var attrs = vnode.data.attrs || {};
  3336. // clone observed objects, as the user probably wants to mutate it
  3337. if (attrs.__ob__) {
  3338. attrs = vnode.data.attrs = extend({}, attrs);
  3339. }
  3340. for (key in attrs) {
  3341. cur = attrs[key];
  3342. old = oldAttrs[key];
  3343. if (old !== cur) {
  3344. setAttr(elm, key, cur);
  3345. }
  3346. }
  3347. for (key in oldAttrs) {
  3348. if (attrs[key] == null) {
  3349. if (isXlink(key)) {
  3350. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  3351. } else if (!isEnumeratedAttr(key)) {
  3352. elm.removeAttribute(key);
  3353. }
  3354. }
  3355. }
  3356. }
  3357. function setAttr(el, key, value) {
  3358. if (isBooleanAttr(key)) {
  3359. // set attribute for blank value
  3360. // e.g. <option disabled>Select one</option>
  3361. if (isFalsyAttrValue(value)) {
  3362. el.removeAttribute(key);
  3363. } else {
  3364. el.setAttribute(key, key);
  3365. }
  3366. } else if (isEnumeratedAttr(key)) {
  3367. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  3368. } else if (isXlink(key)) {
  3369. if (isFalsyAttrValue(value)) {
  3370. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  3371. } else {
  3372. el.setAttributeNS(xlinkNS, key, value);
  3373. }
  3374. } else {
  3375. if (isFalsyAttrValue(value)) {
  3376. el.removeAttribute(key);
  3377. } else {
  3378. el.setAttribute(key, value);
  3379. }
  3380. }
  3381. }
  3382. var attrs = {
  3383. create: updateAttrs,
  3384. update: updateAttrs
  3385. };
  3386. function updateClass(oldVnode, vnode) {
  3387. var el = vnode.elm;
  3388. var data = vnode.data;
  3389. var oldData = oldVnode.data;
  3390. if (!data.staticClass && !data.class && (!oldData || !oldData.staticClass && !oldData.class)) {
  3391. return;
  3392. }
  3393. var cls = genClassForVnode(vnode);
  3394. // handle transition classes
  3395. var transitionClass = el._transitionClasses;
  3396. if (transitionClass) {
  3397. cls = concat(cls, stringifyClass(transitionClass));
  3398. }
  3399. // set the class
  3400. if (cls !== el._prevClass) {
  3401. el.setAttribute('class', cls);
  3402. el._prevClass = cls;
  3403. }
  3404. }
  3405. var klass = {
  3406. create: updateClass,
  3407. update: updateClass
  3408. };
  3409. function updateDOMListeners(oldVnode, vnode) {
  3410. if (!oldVnode.data.on && !vnode.data.on) {
  3411. return;
  3412. }
  3413. var on = vnode.data.on || {};
  3414. var oldOn = oldVnode.data.on || {};
  3415. var add = vnode.elm._v_add || (vnode.elm._v_add = function (event, handler, capture) {
  3416. vnode.elm.addEventListener(event, handler, capture);
  3417. });
  3418. var remove = vnode.elm._v_remove || (vnode.elm._v_remove = function (event, handler) {
  3419. vnode.elm.removeEventListener(event, handler);
  3420. });
  3421. updateListeners(on, oldOn, add, remove);
  3422. }
  3423. var events = {
  3424. create: updateDOMListeners,
  3425. update: updateDOMListeners
  3426. };
  3427. function updateDOMProps(oldVnode, vnode) {
  3428. if (!oldVnode.data.domProps && !vnode.data.domProps) {
  3429. return;
  3430. }
  3431. var key = void 0,
  3432. cur = void 0;
  3433. var elm = vnode.elm;
  3434. var oldProps = oldVnode.data.domProps || {};
  3435. var props = vnode.data.domProps || {};
  3436. // clone observed objects, as the user probably wants to mutate it
  3437. if (props.__ob__) {
  3438. props = vnode.data.domProps = extend({}, props);
  3439. }
  3440. for (key in oldProps) {
  3441. if (props[key] == null) {
  3442. elm[key] = undefined;
  3443. }
  3444. }
  3445. for (key in props) {
  3446. // ignore children if the node has textContent or innerHTML,
  3447. // as these will throw away existing DOM nodes and cause removal errors
  3448. // on subsequent patches (#3360)
  3449. if ((key === 'textContent' || key === 'innerHTML') && vnode.children) {
  3450. vnode.children.length = 0;
  3451. }
  3452. cur = props[key];
  3453. if (key === 'value') {
  3454. // store value as _value as well since
  3455. // non-string values will be stringified
  3456. elm._value = cur;
  3457. // avoid resetting cursor position when value is the same
  3458. var strCur = cur == null ? '' : String(cur);
  3459. if (elm.value !== strCur) {
  3460. elm.value = strCur;
  3461. }
  3462. } else {
  3463. elm[key] = cur;
  3464. }
  3465. }
  3466. }
  3467. var domProps = {
  3468. create: updateDOMProps,
  3469. update: updateDOMProps
  3470. };
  3471. var prefixes = ['Webkit', 'Moz', 'ms'];
  3472. var testEl = void 0;
  3473. var normalize = cached(function (prop) {
  3474. testEl = testEl || document.createElement('div');
  3475. prop = camelize(prop);
  3476. if (prop !== 'filter' && prop in testEl.style) {
  3477. return prop;
  3478. }
  3479. var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
  3480. for (var i = 0; i < prefixes.length; i++) {
  3481. var prefixed = prefixes[i] + upper;
  3482. if (prefixed in testEl.style) {
  3483. return prefixed;
  3484. }
  3485. }
  3486. });
  3487. function updateStyle(oldVnode, vnode) {
  3488. if (!oldVnode.data.style && !vnode.data.style) {
  3489. return;
  3490. }
  3491. var cur = void 0,
  3492. name = void 0;
  3493. var elm = vnode.elm;
  3494. var oldStyle = oldVnode.data.style || {};
  3495. var style = vnode.data.style || {};
  3496. var needClone = style.__ob__;
  3497. // handle array syntax
  3498. if (Array.isArray(style)) {
  3499. style = vnode.data.style = toObject(style);
  3500. }
  3501. // clone the style for future updates,
  3502. // in case the user mutates the style object in-place.
  3503. if (needClone) {
  3504. style = vnode.data.style = extend({}, style);
  3505. }
  3506. for (name in oldStyle) {
  3507. if (!style[name]) {
  3508. elm.style[normalize(name)] = '';
  3509. }
  3510. }
  3511. for (name in style) {
  3512. cur = style[name];
  3513. if (cur !== oldStyle[name]) {
  3514. // ie9 setting to null has no effect, must use empty string
  3515. elm.style[normalize(name)] = cur || '';
  3516. }
  3517. }
  3518. }
  3519. var style = {
  3520. create: updateStyle,
  3521. update: updateStyle
  3522. };
  3523. /**
  3524. * Add class with compatibility for SVG since classList is not supported on
  3525. * SVG elements in IE
  3526. */
  3527. function addClass(el, cls) {
  3528. /* istanbul ignore else */
  3529. if (el.classList) {
  3530. if (cls.indexOf(' ') > -1) {
  3531. cls.split(/\s+/).forEach(function (c) {
  3532. return el.classList.add(c);
  3533. });
  3534. } else {
  3535. el.classList.add(cls);
  3536. }
  3537. } else {
  3538. var cur = ' ' + el.getAttribute('class') + ' ';
  3539. if (cur.indexOf(' ' + cls + ' ') < 0) {
  3540. el.setAttribute('class', (cur + cls).trim());
  3541. }
  3542. }
  3543. }
  3544. /**
  3545. * Remove class with compatibility for SVG since classList is not supported on
  3546. * SVG elements in IE
  3547. */
  3548. function removeClass(el, cls) {
  3549. /* istanbul ignore else */
  3550. if (el.classList) {
  3551. if (cls.indexOf(' ') > -1) {
  3552. cls.split(/\s+/).forEach(function (c) {
  3553. return el.classList.remove(c);
  3554. });
  3555. } else {
  3556. el.classList.remove(cls);
  3557. }
  3558. } else {
  3559. var cur = ' ' + el.getAttribute('class') + ' ';
  3560. var tar = ' ' + cls + ' ';
  3561. while (cur.indexOf(tar) >= 0) {
  3562. cur = cur.replace(tar, ' ');
  3563. }
  3564. el.setAttribute('class', cur.trim());
  3565. }
  3566. }
  3567. var hasTransition = inBrowser && !isIE9;
  3568. var TRANSITION = 'transition';
  3569. var ANIMATION = 'animation';
  3570. // Transition property/event sniffing
  3571. var transitionProp = 'transition';
  3572. var transitionEndEvent = 'transitionend';
  3573. var animationProp = 'animation';
  3574. var animationEndEvent = 'animationend';
  3575. if (hasTransition) {
  3576. /* istanbul ignore if */
  3577. if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
  3578. transitionProp = 'WebkitTransition';
  3579. transitionEndEvent = 'webkitTransitionEnd';
  3580. }
  3581. if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
  3582. animationProp = 'WebkitAnimation';
  3583. animationEndEvent = 'webkitAnimationEnd';
  3584. }
  3585. }
  3586. var raf = inBrowser && window.requestAnimationFrame || setTimeout;
  3587. function nextFrame(fn) {
  3588. raf(function () {
  3589. raf(fn);
  3590. });
  3591. }
  3592. function addTransitionClass(el, cls) {
  3593. (el._transitionClasses || (el._transitionClasses = [])).push(cls);
  3594. addClass(el, cls);
  3595. }
  3596. function removeTransitionClass(el, cls) {
  3597. if (el._transitionClasses) {
  3598. remove(el._transitionClasses, cls);
  3599. }
  3600. removeClass(el, cls);
  3601. }
  3602. function whenTransitionEnds(el, expectedType, cb) {
  3603. var _getTransitionInfo = getTransitionInfo(el, expectedType);
  3604. var type = _getTransitionInfo.type;
  3605. var timeout = _getTransitionInfo.timeout;
  3606. var propCount = _getTransitionInfo.propCount;
  3607. if (!type) return cb();
  3608. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  3609. var ended = 0;
  3610. var end = function end() {
  3611. el.removeEventListener(event, onEnd);
  3612. cb();
  3613. };
  3614. var onEnd = function onEnd() {
  3615. if (++ended >= propCount) {
  3616. end();
  3617. }
  3618. };
  3619. setTimeout(function () {
  3620. if (ended < propCount) {
  3621. end();
  3622. }
  3623. }, timeout + 1);
  3624. el.addEventListener(event, onEnd);
  3625. }
  3626. var transformRE = /\b(transform|all)(,|$)/;
  3627. function getTransitionInfo(el, expectedType) {
  3628. var styles = window.getComputedStyle(el);
  3629. var transitioneDelays = styles[transitionProp + 'Delay'].split(', ');
  3630. var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
  3631. var transitionTimeout = getTimeout(transitioneDelays, transitionDurations);
  3632. var animationDelays = styles[animationProp + 'Delay'].split(', ');
  3633. var animationDurations = styles[animationProp + 'Duration'].split(', ');
  3634. var animationTimeout = getTimeout(animationDelays, animationDurations);
  3635. var type = void 0;
  3636. var timeout = 0;
  3637. var propCount = 0;
  3638. /* istanbul ignore if */
  3639. if (expectedType === TRANSITION) {
  3640. if (transitionTimeout > 0) {
  3641. type = TRANSITION;
  3642. timeout = transitionTimeout;
  3643. propCount = transitionDurations.length;
  3644. }
  3645. } else if (expectedType === ANIMATION) {
  3646. if (animationTimeout > 0) {
  3647. type = ANIMATION;
  3648. timeout = animationTimeout;
  3649. propCount = animationDurations.length;
  3650. }
  3651. } else {
  3652. timeout = Math.max(transitionTimeout, animationTimeout);
  3653. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
  3654. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
  3655. }
  3656. var hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  3657. return {
  3658. type: type,
  3659. timeout: timeout,
  3660. propCount: propCount,
  3661. hasTransform: hasTransform
  3662. };
  3663. }
  3664. function getTimeout(delays, durations) {
  3665. return Math.max.apply(null, durations.map(function (d, i) {
  3666. return toMs(d) + toMs(delays[i]);
  3667. }));
  3668. }
  3669. function toMs(s) {
  3670. return Number(s.slice(0, -1)) * 1000;
  3671. }
  3672. function enter(vnode) {
  3673. var el = vnode.elm;
  3674. // call leave callback now
  3675. if (el._leaveCb) {
  3676. el._leaveCb.cancelled = true;
  3677. el._leaveCb();
  3678. }
  3679. var data = resolveTransition(vnode.data.transition);
  3680. if (!data) {
  3681. return;
  3682. }
  3683. /* istanbul ignore if */
  3684. if (el._enterCb) {
  3685. return;
  3686. }
  3687. var css = data.css;
  3688. var type = data.type;
  3689. var enterClass = data.enterClass;
  3690. var enterActiveClass = data.enterActiveClass;
  3691. var appearClass = data.appearClass;
  3692. var appearActiveClass = data.appearActiveClass;
  3693. var beforeEnter = data.beforeEnter;
  3694. var enter = data.enter;
  3695. var afterEnter = data.afterEnter;
  3696. var enterCancelled = data.enterCancelled;
  3697. var beforeAppear = data.beforeAppear;
  3698. var appear = data.appear;
  3699. var afterAppear = data.afterAppear;
  3700. var appearCancelled = data.appearCancelled;
  3701. var context = vnode.context.$parent || vnode.context;
  3702. var isAppear = !context._isMounted;
  3703. if (isAppear && !appear && appear !== '') {
  3704. return;
  3705. }
  3706. var startClass = isAppear ? appearClass : enterClass;
  3707. var activeClass = isAppear ? appearActiveClass : enterActiveClass;
  3708. var beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  3709. var enterHook = isAppear ? typeof appear === 'function' ? appear : enter : enter;
  3710. var afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  3711. var enterCancelledHook = isAppear ? appearCancelled || enterCancelled : enterCancelled;
  3712. var expectsCSS = css !== false && !isIE9;
  3713. var userWantsControl = enterHook &&
  3714. // enterHook may be a bound method which exposes
  3715. // the length of original fn as _length
  3716. (enterHook._length || enterHook.length) > 1;
  3717. var cb = el._enterCb = once(function () {
  3718. if (expectsCSS) {
  3719. removeTransitionClass(el, activeClass);
  3720. }
  3721. if (cb.cancelled) {
  3722. if (expectsCSS) {
  3723. removeTransitionClass(el, startClass);
  3724. }
  3725. enterCancelledHook && enterCancelledHook(el);
  3726. } else {
  3727. afterEnterHook && afterEnterHook(el);
  3728. }
  3729. el._enterCb = null;
  3730. });
  3731. // remove pending leave element on enter by injecting an insert hook
  3732. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
  3733. var parent = el.parentNode;
  3734. var pendingNode = parent._pending && parent._pending[vnode.key];
  3735. if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
  3736. pendingNode.elm._leaveCb();
  3737. }
  3738. enterHook && enterHook(el, cb);
  3739. });
  3740. // start enter transition
  3741. beforeEnterHook && beforeEnterHook(el);
  3742. if (expectsCSS) {
  3743. addTransitionClass(el, startClass);
  3744. addTransitionClass(el, activeClass);
  3745. nextFrame(function () {
  3746. removeTransitionClass(el, startClass);
  3747. if (!cb.cancelled && !userWantsControl) {
  3748. whenTransitionEnds(el, type, cb);
  3749. }
  3750. });
  3751. }
  3752. if (!expectsCSS && !userWantsControl) {
  3753. cb();
  3754. }
  3755. }
  3756. function leave(vnode, rm) {
  3757. var el = vnode.elm;
  3758. // call enter callback now
  3759. if (el._enterCb) {
  3760. el._enterCb.cancelled = true;
  3761. el._enterCb();
  3762. }
  3763. var data = resolveTransition(vnode.data.transition);
  3764. if (!data) {
  3765. return rm();
  3766. }
  3767. /* istanbul ignore if */
  3768. if (el._leaveCb) {
  3769. return;
  3770. }
  3771. var css = data.css;
  3772. var type = data.type;
  3773. var leaveClass = data.leaveClass;
  3774. var leaveActiveClass = data.leaveActiveClass;
  3775. var beforeLeave = data.beforeLeave;
  3776. var leave = data.leave;
  3777. var afterLeave = data.afterLeave;
  3778. var leaveCancelled = data.leaveCancelled;
  3779. var delayLeave = data.delayLeave;
  3780. var expectsCSS = css !== false && !isIE9;
  3781. var userWantsControl = leave &&
  3782. // leave hook may be a bound method which exposes
  3783. // the length of original fn as _length
  3784. (leave._length || leave.length) > 1;
  3785. var cb = el._leaveCb = once(function () {
  3786. if (el.parentNode && el.parentNode._pending) {
  3787. el.parentNode._pending[vnode.key] = null;
  3788. }
  3789. if (expectsCSS) {
  3790. removeTransitionClass(el, leaveActiveClass);
  3791. }
  3792. if (cb.cancelled) {
  3793. if (expectsCSS) {
  3794. removeTransitionClass(el, leaveClass);
  3795. }
  3796. leaveCancelled && leaveCancelled(el);
  3797. } else {
  3798. rm();
  3799. afterLeave && afterLeave(el);
  3800. }
  3801. el._leaveCb = null;
  3802. });
  3803. if (delayLeave) {
  3804. delayLeave(performLeave);
  3805. } else {
  3806. performLeave();
  3807. }
  3808. function performLeave() {
  3809. // the delayed leave may have already been cancelled
  3810. if (cb.cancelled) {
  3811. return;
  3812. }
  3813. // record leaving element
  3814. if (!vnode.data.show) {
  3815. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
  3816. }
  3817. beforeLeave && beforeLeave(el);
  3818. if (expectsCSS) {
  3819. addTransitionClass(el, leaveClass);
  3820. addTransitionClass(el, leaveActiveClass);
  3821. nextFrame(function () {
  3822. removeTransitionClass(el, leaveClass);
  3823. if (!cb.cancelled && !userWantsControl) {
  3824. whenTransitionEnds(el, type, cb);
  3825. }
  3826. });
  3827. }
  3828. leave && leave(el, cb);
  3829. if (!expectsCSS && !userWantsControl) {
  3830. cb();
  3831. }
  3832. }
  3833. }
  3834. function resolveTransition(def) {
  3835. if (!def) {
  3836. return;
  3837. }
  3838. /* istanbul ignore else */
  3839. if (typeof def === 'object') {
  3840. var res = {};
  3841. if (def.css !== false) {
  3842. extend(res, autoCssTransition(def.name || 'v'));
  3843. }
  3844. extend(res, def);
  3845. return res;
  3846. } else if (typeof def === 'string') {
  3847. return autoCssTransition(def);
  3848. }
  3849. }
  3850. var autoCssTransition = cached(function (name) {
  3851. return {
  3852. enterClass: name + '-enter',
  3853. leaveClass: name + '-leave',
  3854. appearClass: name + '-enter',
  3855. enterActiveClass: name + '-enter-active',
  3856. leaveActiveClass: name + '-leave-active',
  3857. appearActiveClass: name + '-enter-active'
  3858. };
  3859. });
  3860. function once(fn) {
  3861. var called = false;
  3862. return function () {
  3863. if (!called) {
  3864. called = true;
  3865. fn();
  3866. }
  3867. };
  3868. }
  3869. var transition = inBrowser ? {
  3870. create: function create(_, vnode) {
  3871. if (!vnode.data.show) {
  3872. enter(vnode);
  3873. }
  3874. },
  3875. remove: function remove(vnode, rm) {
  3876. /* istanbul ignore else */
  3877. if (!vnode.data.show) {
  3878. leave(vnode, rm);
  3879. } else {
  3880. rm();
  3881. }
  3882. }
  3883. } : {};
  3884. var platformModules = [attrs, klass, events, domProps, style, transition];
  3885. // the directive module should be applied last, after all
  3886. // built-in modules have been applied.
  3887. var modules = platformModules.concat(baseModules);
  3888. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  3889. var modelableTagRE = /^input|select|textarea|vue-component-[0-9]+(-[0-9a-zA-Z_\-]*)?$/;
  3890. /* istanbul ignore if */
  3891. if (isIE9) {
  3892. // http://www.matts411.com/post/internet-explorer-9-oninput/
  3893. document.addEventListener('selectionchange', function () {
  3894. var el = document.activeElement;
  3895. if (el && el.vmodel) {
  3896. trigger(el, 'input');
  3897. }
  3898. });
  3899. }
  3900. var model = {
  3901. bind: function bind(el, binding, vnode) {
  3902. if (process.env.NODE_ENV !== 'production') {
  3903. if (!modelableTagRE.test(vnode.tag)) {
  3904. warn('v-model is not supported on element type: <' + vnode.tag + '>. ' + 'If you are working with contenteditable, it\'s recommended to ' + 'wrap a library dedicated for that purpose inside a custom component.', vnode.context);
  3905. }
  3906. }
  3907. if (vnode.tag === 'select') {
  3908. setSelected(el, binding, vnode.context);
  3909. } else {
  3910. if (!isAndroid) {
  3911. el.addEventListener('compositionstart', onCompositionStart);
  3912. el.addEventListener('compositionend', onCompositionEnd);
  3913. }
  3914. /* istanbul ignore if */
  3915. if (isIE9) {
  3916. el.vmodel = true;
  3917. }
  3918. }
  3919. },
  3920. componentUpdated: function componentUpdated(el, binding, vnode) {
  3921. if (vnode.tag === 'select') {
  3922. setSelected(el, binding, vnode.context);
  3923. // in case the options rendered by v-for have changed,
  3924. // it's possible that the value is out-of-sync with the rendered options.
  3925. // detect such cases and filter out values that no longer has a matchig
  3926. // option in the DOM.
  3927. var needReset = el.multiple ? binding.value.some(function (v) {
  3928. return hasNoMatchingOption(v, el.options);
  3929. }) : hasNoMatchingOption(binding.value, el.options);
  3930. if (needReset) {
  3931. trigger(el, 'change');
  3932. }
  3933. }
  3934. }
  3935. };
  3936. function setSelected(el, binding, vm) {
  3937. var value = binding.value;
  3938. var isMultiple = el.multiple;
  3939. if (!isMultiple) {
  3940. el.selectedIndex = -1;
  3941. } else if (!Array.isArray(value)) {
  3942. process.env.NODE_ENV !== 'production' && warn('<select multiple v-model="' + binding.expression + '"> ' + ('expects an Array value for its binding, but got ' + Object.prototype.toString.call(value).slice(8, -1)), vm);
  3943. return;
  3944. }
  3945. for (var i = 0, l = el.options.length; i < l; i++) {
  3946. var option = el.options[i];
  3947. if (isMultiple) {
  3948. option.selected = value.indexOf(getValue(option)) > -1;
  3949. } else {
  3950. if (getValue(option) === value) {
  3951. el.selectedIndex = i;
  3952. break;
  3953. }
  3954. }
  3955. }
  3956. }
  3957. function hasNoMatchingOption(value, options) {
  3958. for (var i = 0, l = options.length; i < l; i++) {
  3959. if (getValue(options[i]) === value) {
  3960. return false;
  3961. }
  3962. }
  3963. return true;
  3964. }
  3965. function getValue(option) {
  3966. return '_value' in option ? option._value : option.value || option.text;
  3967. }
  3968. function onCompositionStart(e) {
  3969. e.target.composing = true;
  3970. }
  3971. function onCompositionEnd(e) {
  3972. e.target.composing = false;
  3973. trigger(e.target, 'input');
  3974. }
  3975. function trigger(el, type) {
  3976. var e = document.createEvent('HTMLEvents');
  3977. e.initEvent(type, true, true);
  3978. el.dispatchEvent(e);
  3979. }
  3980. // recursively search for possible transition defined inside the component root
  3981. function locateNode(vnode) {
  3982. return vnode.child && (!vnode.data || !vnode.data.transition) ? locateNode(vnode.child._vnode) : vnode;
  3983. }
  3984. var show = {
  3985. bind: function bind(el, _ref, vnode) {
  3986. var value = _ref.value;
  3987. vnode = locateNode(vnode);
  3988. var transition = vnode.data && vnode.data.transition;
  3989. if (value && transition && transition.appear && !isIE9) {
  3990. enter(vnode);
  3991. }
  3992. el.style.display = value ? '' : 'none';
  3993. },
  3994. update: function update(el, _ref2, vnode) {
  3995. var value = _ref2.value;
  3996. vnode = locateNode(vnode);
  3997. var transition = vnode.data && vnode.data.transition;
  3998. if (transition && !isIE9) {
  3999. if (value) {
  4000. enter(vnode);
  4001. el.style.display = '';
  4002. } else {
  4003. leave(vnode, function () {
  4004. el.style.display = 'none';
  4005. });
  4006. }
  4007. } else {
  4008. el.style.display = value ? '' : 'none';
  4009. }
  4010. }
  4011. };
  4012. var platformDirectives = {
  4013. model: model,
  4014. show: show
  4015. };
  4016. var transitionProps = {
  4017. name: String,
  4018. appear: Boolean,
  4019. css: Boolean,
  4020. mode: String,
  4021. type: String,
  4022. enterClass: String,
  4023. leaveClass: String,
  4024. enterActiveClass: String,
  4025. leaveActiveClass: String,
  4026. appearClass: String,
  4027. appearActiveClass: String
  4028. };
  4029. function extractTransitionData(comp) {
  4030. var data = {};
  4031. var options = comp.$options;
  4032. // props
  4033. for (var key in options.propsData) {
  4034. data[key] = comp[key];
  4035. }
  4036. // events.
  4037. // extract listeners and pass them directly to the transition methods
  4038. var listeners = options._parentListeners;
  4039. for (var _key in listeners) {
  4040. data[camelize(_key)] = listeners[_key].fn;
  4041. }
  4042. return data;
  4043. }
  4044. var Transition = {
  4045. name: 'transition',
  4046. props: transitionProps,
  4047. abstract: true,
  4048. render: function render(h) {
  4049. var _this = this;
  4050. var children = this.$slots.default;
  4051. if (!children) {
  4052. return;
  4053. }
  4054. // filter out text nodes (possible whitespaces)
  4055. children = children.filter(function (c) {
  4056. return c.tag;
  4057. });
  4058. /* istanbul ignore if */
  4059. if (!children.length) {
  4060. return;
  4061. }
  4062. // warn multiple elements
  4063. if (process.env.NODE_ENV !== 'production' && children.length > 1) {
  4064. warn('<transition> can only be used on a single element. Use ' + '<transition-group> for lists.', this.$parent);
  4065. }
  4066. var mode = this.mode;
  4067. // warn invalid mode
  4068. if (process.env.NODE_ENV !== 'production' && mode && mode !== 'in-out' && mode !== 'out-in') {
  4069. warn('invalid <transition> mode: ' + mode, this.$parent);
  4070. }
  4071. var rawChild = children[0];
  4072. // if this is a component root node and the component's
  4073. // parent container node also has transition, skip.
  4074. if (this.$vnode.parent && this.$vnode.parent.data.transition) {
  4075. return rawChild;
  4076. }
  4077. // apply transition data to child
  4078. // use getRealChild() to ignore abstract components e.g. keep-alive
  4079. var child = getRealChild(rawChild);
  4080. /* istanbul ignore if */
  4081. if (!child) return;
  4082. child.key = child.key || '__v' + (child.tag + this._uid) + '__';
  4083. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  4084. var oldRawChild = this._vnode;
  4085. var oldChild = getRealChild(oldRawChild);
  4086. if (oldChild && oldChild.data && oldChild.key !== child.key) {
  4087. // replace old child transition data with fresh one
  4088. // important for dynamic transitions!
  4089. var oldData = oldChild.data.transition = extend({}, data);
  4090. // handle transition mode
  4091. if (mode === 'out-in') {
  4092. // return empty node and queue update when leave finishes
  4093. mergeVNodeHook(oldData, 'afterLeave', function () {
  4094. _this.$forceUpdate();
  4095. });
  4096. return (/\d-keep-alive$/.test(rawChild.tag) ? h('keep-alive') : null
  4097. );
  4098. } else if (mode === 'in-out') {
  4099. (function () {
  4100. var delayedLeave = void 0;
  4101. var performLeave = function performLeave() {
  4102. delayedLeave();
  4103. };
  4104. mergeVNodeHook(data, 'afterEnter', performLeave);
  4105. mergeVNodeHook(data, 'enterCancelled', performLeave);
  4106. mergeVNodeHook(oldData, 'delayLeave', function (leave) {
  4107. delayedLeave = leave;
  4108. });
  4109. })();
  4110. }
  4111. }
  4112. return rawChild;
  4113. }
  4114. };
  4115. var props = extend({
  4116. tag: String,
  4117. moveClass: String
  4118. }, transitionProps);
  4119. delete props.mode;
  4120. var TransitionGroup = {
  4121. props: props,
  4122. render: function render(h) {
  4123. var tag = this.tag || this.$vnode.data.tag || 'span';
  4124. var map = Object.create(null);
  4125. var prevChildren = this.prevChildren = this.children;
  4126. var rawChildren = this.$slots.default || [];
  4127. var children = this.children = [];
  4128. var transitionData = extractTransitionData(this);
  4129. for (var i = 0; i < rawChildren.length; i++) {
  4130. var c = rawChildren[i];
  4131. if (c.tag) {
  4132. if (c.key != null) {
  4133. children.push(c);
  4134. map[c.key] = c;(c.data || (c.data = {})).transition = transitionData;
  4135. } else if (process.env.NODE_ENV !== 'production') {
  4136. var opts = c.componentOptions;
  4137. var name = opts ? opts.Ctor.options.name || opts.tag : c.tag;
  4138. warn('<transition-group> children must be keyed: <' + name + '>');
  4139. }
  4140. }
  4141. }
  4142. if (prevChildren) {
  4143. var kept = [];
  4144. var removed = [];
  4145. for (var _i = 0; _i < prevChildren.length; _i++) {
  4146. var _c = prevChildren[_i];
  4147. _c.data.transition = transitionData;
  4148. _c.data.pos = _c.elm.getBoundingClientRect();
  4149. if (map[_c.key]) {
  4150. kept.push(_c);
  4151. } else {
  4152. removed.push(_c);
  4153. }
  4154. }
  4155. this.kept = h(tag, null, kept);
  4156. this.removed = removed;
  4157. }
  4158. return h(tag, null, children);
  4159. },
  4160. beforeUpdate: function beforeUpdate() {
  4161. // force removing pass
  4162. this.__patch__(this._vnode, this.kept, false, // hydrating
  4163. true // removeOnly (!important, avoids unnecessary moves)
  4164. );
  4165. this._vnode = this.kept;
  4166. },
  4167. updated: function updated() {
  4168. var children = this.prevChildren;
  4169. var moveClass = this.moveClass || this.name + '-move';
  4170. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  4171. return;
  4172. }
  4173. children.forEach(function (c) {
  4174. /* istanbul ignore if */
  4175. if (c.elm._moveCb) {
  4176. c.elm._moveCb();
  4177. }
  4178. /* istanbul ignore if */
  4179. if (c.elm._enterCb) {
  4180. c.elm._enterCb();
  4181. }
  4182. var oldPos = c.data.pos;
  4183. var newPos = c.data.pos = c.elm.getBoundingClientRect();
  4184. var dx = oldPos.left - newPos.left;
  4185. var dy = oldPos.top - newPos.top;
  4186. if (dx || dy) {
  4187. c.data.moved = true;
  4188. var s = c.elm.style;
  4189. s.transform = s.WebkitTransform = 'translate(' + dx + 'px,' + dy + 'px)';
  4190. s.transitionDuration = '0s';
  4191. }
  4192. });
  4193. // force reflow to put everything in position
  4194. var f = document.body.offsetHeight; // eslint-disable-line
  4195. children.forEach(function (c) {
  4196. if (c.data.moved) {
  4197. (function () {
  4198. var el = c.elm;
  4199. var s = el.style;
  4200. addTransitionClass(el, moveClass);
  4201. s.transform = s.WebkitTransform = s.transitionDuration = '';
  4202. el._moveDest = c.data.pos;
  4203. el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) {
  4204. if (!e || /transform$/.test(e.propertyName)) {
  4205. el.removeEventListener(transitionEndEvent, cb);
  4206. el._moveCb = null;
  4207. removeTransitionClass(el, moveClass);
  4208. }
  4209. });
  4210. })();
  4211. }
  4212. });
  4213. },
  4214. methods: {
  4215. hasMove: function hasMove(el, moveClass) {
  4216. /* istanbul ignore if */
  4217. if (!hasTransition) {
  4218. return false;
  4219. }
  4220. if (this._hasMove != null) {
  4221. return this._hasMove;
  4222. }
  4223. addTransitionClass(el, moveClass);
  4224. var info = getTransitionInfo(el);
  4225. removeTransitionClass(el, moveClass);
  4226. return this._hasMove = info.hasTransform;
  4227. }
  4228. }
  4229. };
  4230. var platformComponents = {
  4231. Transition: Transition,
  4232. TransitionGroup: TransitionGroup
  4233. };
  4234. // install platform specific utils
  4235. Vue.config.isUnknownElement = isUnknownElement;
  4236. Vue.config.isReservedTag = isReservedTag;
  4237. Vue.config.getTagNamespace = getTagNamespace;
  4238. Vue.config.mustUseProp = mustUseProp;
  4239. // install platform runtime directives & components
  4240. extend(Vue.options.directives, platformDirectives);
  4241. extend(Vue.options.components, platformComponents);
  4242. // install platform patch function
  4243. Vue.prototype.__patch__ = config._isServer ? noop : patch;
  4244. // wrap mount
  4245. Vue.prototype.$mount = function (el, hydrating) {
  4246. el = el && !config._isServer ? query(el) : undefined;
  4247. return this._mount(el, hydrating);
  4248. };
  4249. // devtools global hook
  4250. /* istanbul ignore next */
  4251. setTimeout(function () {
  4252. if (config.devtools) {
  4253. if (devtools) {
  4254. devtools.emit('init', Vue);
  4255. } else if (process.env.NODE_ENV !== 'production' && inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)) {
  4256. console.log('Download the Vue Devtools for a better development experience:\n' + 'https://github.com/vuejs/vue-devtools');
  4257. }
  4258. }
  4259. }, 0);
  4260. module.exports = Vue;