build.js 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var entities = require('entities');
  5. var deindent = _interopDefault(require('de-indent'));
  6. /**
  7. * Convert a value to a string that is actually rendered.
  8. */
  9. function _toString(val) {
  10. return val == null ? '' : typeof val === 'object' ? JSON.stringify(val, null, 2) : String(val);
  11. }
  12. /**
  13. * Convert a input value to a number for persistence.
  14. * If the conversion fails, return original string.
  15. */
  16. function toNumber(val) {
  17. var n = parseFloat(val, 10);
  18. return n || n === 0 ? n : val;
  19. }
  20. /**
  21. * Make a map and return a function for checking if a key
  22. * is in that map.
  23. */
  24. function makeMap(str, expectsLowerCase) {
  25. var map = Object.create(null);
  26. var list = str.split(',');
  27. for (var i = 0; i < list.length; i++) {
  28. map[list[i]] = true;
  29. }
  30. return expectsLowerCase ? function (val) {
  31. return map[val.toLowerCase()];
  32. } : function (val) {
  33. return map[val];
  34. };
  35. }
  36. /**
  37. * Check if a tag is a built-in tag.
  38. */
  39. var isBuiltInTag = makeMap('slot,component', true);
  40. /**
  41. * Remove an item from an array
  42. */
  43. function remove(arr, item) {
  44. if (arr.length) {
  45. var index = arr.indexOf(item);
  46. if (index > -1) {
  47. return arr.splice(index, 1);
  48. }
  49. }
  50. }
  51. /**
  52. * Check whether the object has the property.
  53. */
  54. var hasOwnProperty = Object.prototype.hasOwnProperty;
  55. function hasOwn(obj, key) {
  56. return hasOwnProperty.call(obj, key);
  57. }
  58. /**
  59. * Check if value is primitive
  60. */
  61. function isPrimitive(value) {
  62. return typeof value === 'string' || typeof value === 'number';
  63. }
  64. /**
  65. * Create a cached version of a pure function.
  66. */
  67. function cached(fn) {
  68. var cache = Object.create(null);
  69. return function cachedFn(str) {
  70. var hit = cache[str];
  71. return hit || (cache[str] = fn(str));
  72. };
  73. }
  74. /**
  75. * Camelize a hyphen-delmited string.
  76. */
  77. var camelizeRE = /-(\w)/g;
  78. var camelize = cached(function (str) {
  79. return str.replace(camelizeRE, function (_, c) {
  80. return c ? c.toUpperCase() : '';
  81. });
  82. });
  83. /**
  84. * Capitalize a string.
  85. */
  86. var capitalize = cached(function (str) {
  87. return str.charAt(0).toUpperCase() + str.slice(1);
  88. });
  89. /**
  90. * Hyphenate a camelCase string.
  91. */
  92. var hyphenateRE = /([^-])([A-Z])/g;
  93. var hyphenate = cached(function (str) {
  94. return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase();
  95. });
  96. /**
  97. * Simple bind, faster than native
  98. */
  99. function bind(fn, ctx) {
  100. function boundFn(a) {
  101. var l = arguments.length;
  102. return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
  103. }
  104. // record original fn length
  105. boundFn._length = fn.length;
  106. return boundFn;
  107. }
  108. /**
  109. * Convert an Array-like object to a real Array.
  110. */
  111. function toArray(list, start) {
  112. start = start || 0;
  113. var i = list.length - start;
  114. var ret = new Array(i);
  115. while (i--) {
  116. ret[i] = list[i + start];
  117. }
  118. return ret;
  119. }
  120. /**
  121. * Mix properties into target object.
  122. */
  123. function extend(to, _from) {
  124. for (var _key in _from) {
  125. to[_key] = _from[_key];
  126. }
  127. return to;
  128. }
  129. /**
  130. * Quick object check - this is primarily used to tell
  131. * Objects from primitive values when we know the value
  132. * is a JSON-compliant type.
  133. */
  134. function isObject(obj) {
  135. return obj !== null && typeof obj === 'object';
  136. }
  137. /**
  138. * Strict object type check. Only returns true
  139. * for plain JavaScript objects.
  140. */
  141. var toString = Object.prototype.toString;
  142. var OBJECT_STRING = '[object Object]';
  143. function isPlainObject(obj) {
  144. return toString.call(obj) === OBJECT_STRING;
  145. }
  146. /**
  147. * Merge an Array of Objects into a single Object.
  148. */
  149. function toObject(arr) {
  150. var res = arr[0] || {};
  151. for (var i = 1; i < arr.length; i++) {
  152. if (arr[i]) {
  153. extend(res, arr[i]);
  154. }
  155. }
  156. return res;
  157. }
  158. /**
  159. * Perform no operation.
  160. */
  161. function noop() {}
  162. /**
  163. * Always return false.
  164. */
  165. var no = function no() {
  166. return false;
  167. };
  168. /**
  169. * Generate a static keys string from compiler modules.
  170. */
  171. function genStaticKeys(modules) {
  172. return modules.reduce(function (keys, m) {
  173. return keys.concat(m.staticKeys || []);
  174. }, []).join(',');
  175. }
  176. var config = {
  177. /**
  178. * Option merge strategies (used in core/util/options)
  179. */
  180. optionMergeStrategies: Object.create(null),
  181. /**
  182. * Whether to suppress warnings.
  183. */
  184. silent: false,
  185. /**
  186. * Whether to enable devtools
  187. */
  188. devtools: process.env.NODE_ENV !== 'production',
  189. /**
  190. * Error handler for watcher errors
  191. */
  192. errorHandler: null,
  193. /**
  194. * Ignore certain custom elements
  195. */
  196. ignoredElements: null,
  197. /**
  198. * Custom user key aliases for v-on
  199. */
  200. keyCodes: Object.create(null),
  201. /**
  202. * Check if a tag is reserved so that it cannot be registered as a
  203. * component. This is platform-dependent and may be overwritten.
  204. */
  205. isReservedTag: no,
  206. /**
  207. * Check if a tag is an unknown element.
  208. * Platform-dependent.
  209. */
  210. isUnknownElement: no,
  211. /**
  212. * Get the namespace of an element
  213. */
  214. getTagNamespace: noop,
  215. /**
  216. * Check if an attribute must be bound using property, e.g. value
  217. * Platform-dependent.
  218. */
  219. mustUseProp: no,
  220. /**
  221. * List of asset types that a component can own.
  222. */
  223. _assetTypes: ['component', 'directive', 'filter'],
  224. /**
  225. * List of lifecycle hooks.
  226. */
  227. _lifecycleHooks: ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeDestroy', 'destroyed', 'activated', 'deactivated'],
  228. /**
  229. * Max circular updates allowed in a scheduler flush cycle.
  230. */
  231. _maxUpdateCount: 100,
  232. /**
  233. * Server rendering?
  234. */
  235. _isServer: process.env.VUE_ENV === 'server'
  236. };
  237. var warn = void 0;
  238. var formatComponentName = void 0;
  239. if (process.env.NODE_ENV !== 'production') {
  240. (function () {
  241. var hasConsole = typeof console !== 'undefined';
  242. warn = function warn(msg, vm) {
  243. if (hasConsole && !config.silent) {
  244. console.error('[Vue warn]: ' + msg + ' ' + (vm ? formatLocation(formatComponentName(vm)) : ''));
  245. }
  246. };
  247. formatComponentName = function formatComponentName(vm) {
  248. if (vm.$root === vm) {
  249. return 'root instance';
  250. }
  251. var name = vm._isVue ? vm.$options.name || vm.$options._componentTag : vm.name;
  252. return name ? 'component <' + name + '>' : 'anonymous component';
  253. };
  254. var formatLocation = function formatLocation(str) {
  255. if (str === 'anonymous component') {
  256. str += ' - use the "name" option for better debugging messages.)';
  257. }
  258. return '(found in ' + str + ')';
  259. };
  260. })();
  261. }
  262. /**
  263. * Check if a string starts with $ or _
  264. */
  265. function isReserved(str) {
  266. var c = (str + '').charCodeAt(0);
  267. return c === 0x24 || c === 0x5F;
  268. }
  269. /**
  270. * Define a property.
  271. */
  272. function def(obj, key, val, enumerable) {
  273. Object.defineProperty(obj, key, {
  274. value: val,
  275. enumerable: !!enumerable,
  276. writable: true,
  277. configurable: true
  278. });
  279. }
  280. /**
  281. * Parse simple path.
  282. */
  283. var bailRE = /[^\w\.\$]/;
  284. function parsePath(path) {
  285. if (bailRE.test(path)) {
  286. return;
  287. } else {
  288. var _ret = function () {
  289. var segments = path.split('.');
  290. return {
  291. v: function v(obj) {
  292. for (var i = 0; i < segments.length; i++) {
  293. if (!obj) return;
  294. obj = obj[segments[i]];
  295. }
  296. return obj;
  297. }
  298. };
  299. }();
  300. if (typeof _ret === "object") return _ret.v;
  301. }
  302. }
  303. /* global MutationObserver */
  304. // can we use __proto__?
  305. var hasProto = '__proto__' in {};
  306. // Browser environment sniffing
  307. var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]';
  308. // detect devtools
  309. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  310. // UA sniffing for working around browser-specific quirks
  311. var UA$1 = inBrowser && window.navigator.userAgent.toLowerCase();
  312. var isIos = UA$1 && /(iphone|ipad|ipod|ios)/i.test(UA$1);
  313. var iosVersionMatch = UA$1 && isIos && UA$1.match(/os ([\d_]+)/);
  314. var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_');
  315. // MutationObserver is unreliable in iOS 9.3 UIWebView
  316. // detecting it by checking presence of IndexedDB
  317. // ref #3027
  318. var hasMutationObserverBug = iosVersion && Number(iosVersion[0]) >= 9 && Number(iosVersion[1]) >= 3 && !window.indexedDB;
  319. /**
  320. * Defer a task to execute it asynchronously. Ideally this
  321. * should be executed as a microtask, so we leverage
  322. * MutationObserver if it's available, and fallback to
  323. * setTimeout(0).
  324. *
  325. * @param {Function} cb
  326. * @param {Object} ctx
  327. */
  328. var nextTick = function () {
  329. var callbacks = [];
  330. var pending = false;
  331. var timerFunc = void 0;
  332. function nextTickHandler() {
  333. pending = false;
  334. var copies = callbacks.slice(0);
  335. callbacks = [];
  336. for (var i = 0; i < copies.length; i++) {
  337. copies[i]();
  338. }
  339. }
  340. /* istanbul ignore else */
  341. if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
  342. (function () {
  343. var counter = 1;
  344. var observer = new MutationObserver(nextTickHandler);
  345. var textNode = document.createTextNode(String(counter));
  346. observer.observe(textNode, {
  347. characterData: true
  348. });
  349. timerFunc = function timerFunc() {
  350. counter = (counter + 1) % 2;
  351. textNode.data = String(counter);
  352. };
  353. })();
  354. } else {
  355. // webpack attempts to inject a shim for setImmediate
  356. // if it is used as a global, so we have to work around that to
  357. // avoid bundling unnecessary code.
  358. var context = inBrowser ? window : typeof global !== 'undefined' ? global : {};
  359. timerFunc = context.setImmediate || setTimeout;
  360. }
  361. return function (cb, ctx) {
  362. var func = ctx ? function () {
  363. cb.call(ctx);
  364. } : cb;
  365. callbacks.push(func);
  366. if (pending) return;
  367. pending = true;
  368. timerFunc(nextTickHandler, 0);
  369. };
  370. }();
  371. var _Set = void 0;
  372. /* istanbul ignore if */
  373. if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
  374. // use native Set when available.
  375. _Set = Set;
  376. } else {
  377. // a non-standard Set polyfill that only works with primitive keys.
  378. _Set = function () {
  379. function Set() {
  380. this.set = Object.create(null);
  381. }
  382. Set.prototype.has = function has(key) {
  383. return this.set[key] !== undefined;
  384. };
  385. Set.prototype.add = function add(key) {
  386. this.set[key] = 1;
  387. };
  388. Set.prototype.clear = function clear() {
  389. this.set = Object.create(null);
  390. };
  391. return Set;
  392. }();
  393. }
  394. var hasProxy = void 0;
  395. var proxyHandlers = void 0;
  396. var initProxy = void 0;
  397. if (process.env.NODE_ENV !== 'production') {
  398. (function () {
  399. 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
  400. );
  401. hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
  402. proxyHandlers = {
  403. has: function has(target, key) {
  404. var has = key in target;
  405. var isAllowedGlobal = allowedGlobals(key);
  406. if (!has && !isAllowedGlobal) {
  407. warn('Trying to access non-existent property "' + key + '" while rendering. ' + 'Make sure to declare reactive data properties in the data option.', target);
  408. }
  409. return !isAllowedGlobal;
  410. }
  411. };
  412. initProxy = function initProxy(vm) {
  413. if (hasProxy) {
  414. vm._renderProxy = new Proxy(vm, proxyHandlers);
  415. } else {
  416. vm._renderProxy = vm;
  417. }
  418. };
  419. })();
  420. }
  421. var uid$2 = 0;
  422. /**
  423. * A dep is an observable that can have multiple
  424. * directives subscribing to it.
  425. */
  426. var Dep = function () {
  427. function Dep() {
  428. this.id = uid$2++;
  429. this.subs = [];
  430. }
  431. Dep.prototype.addSub = function addSub(sub) {
  432. this.subs.push(sub);
  433. };
  434. Dep.prototype.removeSub = function removeSub(sub) {
  435. remove(this.subs, sub);
  436. };
  437. Dep.prototype.depend = function depend() {
  438. if (Dep.target) {
  439. Dep.target.addDep(this);
  440. }
  441. };
  442. Dep.prototype.notify = function notify() {
  443. // stablize the subscriber list first
  444. var subs = this.subs.slice();
  445. for (var i = 0, l = subs.length; i < l; i++) {
  446. subs[i].update();
  447. }
  448. };
  449. return Dep;
  450. }();
  451. Dep.target = null;
  452. var targetStack = [];
  453. function pushTarget(_target) {
  454. if (Dep.target) targetStack.push(Dep.target);
  455. Dep.target = _target;
  456. }
  457. function popTarget() {
  458. Dep.target = targetStack.pop();
  459. }
  460. var queue = [];
  461. var has = {};
  462. var circular = {};
  463. var waiting = false;
  464. var flushing = false;
  465. var index = 0;
  466. /**
  467. * Reset the scheduler's state.
  468. */
  469. function resetSchedulerState() {
  470. queue.length = 0;
  471. has = {};
  472. if (process.env.NODE_ENV !== 'production') {
  473. circular = {};
  474. }
  475. waiting = flushing = false;
  476. }
  477. /**
  478. * Flush both queues and run the watchers.
  479. */
  480. function flushSchedulerQueue() {
  481. flushing = true;
  482. // Sort queue before flush.
  483. // This ensures that:
  484. // 1. Components are updated from parent to child. (because parent is always
  485. // created before the child)
  486. // 2. A component's user watchers are run before its render watcher (because
  487. // user watchers are created before the render watcher)
  488. // 3. If a component is destroyed during a parent component's watcher run,
  489. // its watchers can be skipped.
  490. queue.sort(function (a, b) {
  491. return a.id - b.id;
  492. });
  493. // do not cache length because more watchers might be pushed
  494. // as we run existing watchers
  495. for (index = 0; index < queue.length; index++) {
  496. var watcher = queue[index];
  497. var id = watcher.id;
  498. has[id] = null;
  499. watcher.run();
  500. // in dev build, check and stop circular updates.
  501. if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  502. circular[id] = (circular[id] || 0) + 1;
  503. if (circular[id] > config._maxUpdateCount) {
  504. warn('You may have an infinite update loop ' + (watcher.user ? 'in watcher with expression "' + watcher.expression + '"' : 'in a component render function.'), watcher.vm);
  505. break;
  506. }
  507. }
  508. }
  509. // devtool hook
  510. /* istanbul ignore if */
  511. if (devtools && config.devtools) {
  512. devtools.emit('flush');
  513. }
  514. resetSchedulerState();
  515. }
  516. /**
  517. * Push a watcher into the watcher queue.
  518. * Jobs with duplicate IDs will be skipped unless it's
  519. * pushed when the queue is being flushed.
  520. */
  521. function queueWatcher(watcher) {
  522. var id = watcher.id;
  523. if (has[id] == null) {
  524. has[id] = true;
  525. if (!flushing) {
  526. queue.push(watcher);
  527. } else {
  528. // if already flushing, splice the watcher based on its id
  529. // if already past its id, it will be run next immediately.
  530. var i = queue.length - 1;
  531. while (i >= 0 && queue[i].id > watcher.id) {
  532. i--;
  533. }
  534. queue.splice(Math.max(i, index) + 1, 0, watcher);
  535. }
  536. // queue the flush
  537. if (!waiting) {
  538. waiting = true;
  539. nextTick(flushSchedulerQueue);
  540. }
  541. }
  542. }
  543. var uid$1 = 0;
  544. /**
  545. * A watcher parses an expression, collects dependencies,
  546. * and fires callback when the expression value changes.
  547. * This is used for both the $watch() api and directives.
  548. */
  549. var Watcher = function () {
  550. function Watcher(vm, expOrFn, cb) {
  551. var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
  552. this.vm = vm;
  553. vm._watchers.push(this);
  554. // options
  555. this.deep = !!options.deep;
  556. this.user = !!options.user;
  557. this.lazy = !!options.lazy;
  558. this.sync = !!options.sync;
  559. this.expression = expOrFn.toString();
  560. this.cb = cb;
  561. this.id = ++uid$1; // uid for batching
  562. this.active = true;
  563. this.dirty = this.lazy; // for lazy watchers
  564. this.deps = [];
  565. this.newDeps = [];
  566. this.depIds = new _Set();
  567. this.newDepIds = new _Set();
  568. // parse expression for getter
  569. if (typeof expOrFn === 'function') {
  570. this.getter = expOrFn;
  571. } else {
  572. this.getter = parsePath(expOrFn);
  573. if (!this.getter) {
  574. this.getter = function () {};
  575. 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);
  576. }
  577. }
  578. this.value = this.lazy ? undefined : this.get();
  579. }
  580. /**
  581. * Evaluate the getter, and re-collect dependencies.
  582. */
  583. Watcher.prototype.get = function get() {
  584. pushTarget(this);
  585. var value = this.getter.call(this.vm, this.vm);
  586. // "touch" every property so they are all tracked as
  587. // dependencies for deep watching
  588. if (this.deep) {
  589. traverse(value);
  590. }
  591. popTarget();
  592. this.cleanupDeps();
  593. return value;
  594. };
  595. /**
  596. * Add a dependency to this directive.
  597. */
  598. Watcher.prototype.addDep = function addDep(dep) {
  599. var id = dep.id;
  600. if (!this.newDepIds.has(id)) {
  601. this.newDepIds.add(id);
  602. this.newDeps.push(dep);
  603. if (!this.depIds.has(id)) {
  604. dep.addSub(this);
  605. }
  606. }
  607. };
  608. /**
  609. * Clean up for dependency collection.
  610. */
  611. Watcher.prototype.cleanupDeps = function cleanupDeps() {
  612. var i = this.deps.length;
  613. while (i--) {
  614. var dep = this.deps[i];
  615. if (!this.newDepIds.has(dep.id)) {
  616. dep.removeSub(this);
  617. }
  618. }
  619. var tmp = this.depIds;
  620. this.depIds = this.newDepIds;
  621. this.newDepIds = tmp;
  622. this.newDepIds.clear();
  623. tmp = this.deps;
  624. this.deps = this.newDeps;
  625. this.newDeps = tmp;
  626. this.newDeps.length = 0;
  627. };
  628. /**
  629. * Subscriber interface.
  630. * Will be called when a dependency changes.
  631. */
  632. Watcher.prototype.update = function update() {
  633. /* istanbul ignore else */
  634. if (this.lazy) {
  635. this.dirty = true;
  636. } else if (this.sync) {
  637. this.run();
  638. } else {
  639. queueWatcher(this);
  640. }
  641. };
  642. /**
  643. * Scheduler job interface.
  644. * Will be called by the scheduler.
  645. */
  646. Watcher.prototype.run = function run() {
  647. if (this.active) {
  648. var value = this.get();
  649. if (value !== this.value ||
  650. // Deep watchers and watchers on Object/Arrays should fire even
  651. // when the value is the same, because the value may
  652. // have mutated.
  653. isObject(value) || this.deep) {
  654. // set new value
  655. var oldValue = this.value;
  656. this.value = value;
  657. if (this.user) {
  658. try {
  659. this.cb.call(this.vm, value, oldValue);
  660. } catch (e) {
  661. process.env.NODE_ENV !== 'production' && warn('Error in watcher "' + this.expression + '"', this.vm);
  662. /* istanbul ignore else */
  663. if (config.errorHandler) {
  664. config.errorHandler.call(null, e, this.vm);
  665. } else {
  666. throw e;
  667. }
  668. }
  669. } else {
  670. this.cb.call(this.vm, value, oldValue);
  671. }
  672. }
  673. }
  674. };
  675. /**
  676. * Evaluate the value of the watcher.
  677. * This only gets called for lazy watchers.
  678. */
  679. Watcher.prototype.evaluate = function evaluate() {
  680. this.value = this.get();
  681. this.dirty = false;
  682. };
  683. /**
  684. * Depend on all deps collected by this watcher.
  685. */
  686. Watcher.prototype.depend = function depend() {
  687. var i = this.deps.length;
  688. while (i--) {
  689. this.deps[i].depend();
  690. }
  691. };
  692. /**
  693. * Remove self from all dependencies' subcriber list.
  694. */
  695. Watcher.prototype.teardown = function teardown() {
  696. if (this.active) {
  697. // remove self from vm's watcher list
  698. // this is a somewhat expensive operation so we skip it
  699. // if the vm is being destroyed or is performing a v-for
  700. // re-render (the watcher list is then filtered by v-for).
  701. if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) {
  702. remove(this.vm._watchers, this);
  703. }
  704. var i = this.deps.length;
  705. while (i--) {
  706. this.deps[i].removeSub(this);
  707. }
  708. this.active = false;
  709. }
  710. };
  711. return Watcher;
  712. }();
  713. var seenObjects = new _Set();
  714. function traverse(val, seen) {
  715. var i = void 0,
  716. keys = void 0;
  717. if (!seen) {
  718. seen = seenObjects;
  719. seen.clear();
  720. }
  721. var isA = Array.isArray(val);
  722. var isO = isObject(val);
  723. if ((isA || isO) && Object.isExtensible(val)) {
  724. if (val.__ob__) {
  725. var depId = val.__ob__.dep.id;
  726. if (seen.has(depId)) {
  727. return;
  728. } else {
  729. seen.add(depId);
  730. }
  731. }
  732. if (isA) {
  733. i = val.length;
  734. while (i--) {
  735. traverse(val[i], seen);
  736. }
  737. } else if (isO) {
  738. keys = Object.keys(val);
  739. i = keys.length;
  740. while (i--) {
  741. traverse(val[keys[i]], seen);
  742. }
  743. }
  744. }
  745. }
  746. var arrayProto = Array.prototype;
  747. var arrayMethods = Object.create(arrayProto)
  748. /**
  749. * Intercept mutating methods and emit events
  750. */
  751. ;['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(function (method) {
  752. // cache original method
  753. var original = arrayProto[method];
  754. def(arrayMethods, method, function mutator() {
  755. // avoid leaking arguments:
  756. // http://jsperf.com/closure-with-arguments
  757. var i = arguments.length;
  758. var args = new Array(i);
  759. while (i--) {
  760. args[i] = arguments[i];
  761. }
  762. var result = original.apply(this, args);
  763. var ob = this.__ob__;
  764. var inserted = void 0;
  765. switch (method) {
  766. case 'push':
  767. inserted = args;
  768. break;
  769. case 'unshift':
  770. inserted = args;
  771. break;
  772. case 'splice':
  773. inserted = args.slice(2);
  774. break;
  775. }
  776. if (inserted) ob.observeArray(inserted);
  777. // notify change
  778. ob.dep.notify();
  779. return result;
  780. });
  781. });
  782. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  783. /**
  784. * By default, when a reactive property is set, the new value is
  785. * also converted to become reactive. However when passing down props,
  786. * we don't want to force conversion because the value may be a nested value
  787. * under a frozen data structure. Converting it would defeat the optimization.
  788. */
  789. var observerState = {
  790. shouldConvert: true,
  791. isSettingProps: false
  792. };
  793. /**
  794. * Observer class that are attached to each observed
  795. * object. Once attached, the observer converts target
  796. * object's property keys into getter/setters that
  797. * collect dependencies and dispatches updates.
  798. */
  799. var Observer = function () {
  800. // number of vms that has this object as root $data
  801. function Observer(value) {
  802. this.value = value;
  803. this.dep = new Dep();
  804. this.vmCount = 0;
  805. def(value, '__ob__', this);
  806. if (Array.isArray(value)) {
  807. var augment = hasProto ? protoAugment : copyAugment;
  808. augment(value, arrayMethods, arrayKeys);
  809. this.observeArray(value);
  810. } else {
  811. this.walk(value);
  812. }
  813. }
  814. /**
  815. * Walk through each property and convert them into
  816. * getter/setters. This method should only be called when
  817. * value type is Object.
  818. */
  819. Observer.prototype.walk = function walk(obj) {
  820. var val = this.value;
  821. for (var key in obj) {
  822. defineReactive(val, key, obj[key]);
  823. }
  824. };
  825. /**
  826. * Observe a list of Array items.
  827. */
  828. Observer.prototype.observeArray = function observeArray(items) {
  829. for (var i = 0, l = items.length; i < l; i++) {
  830. observe(items[i]);
  831. }
  832. };
  833. return Observer;
  834. }();
  835. // helpers
  836. /**
  837. * Augment an target Object or Array by intercepting
  838. * the prototype chain using __proto__
  839. */
  840. function protoAugment(target, src) {
  841. /* eslint-disable no-proto */
  842. target.__proto__ = src;
  843. /* eslint-enable no-proto */
  844. }
  845. /**
  846. * Augment an target Object or Array by defining
  847. * hidden properties.
  848. *
  849. * istanbul ignore next
  850. */
  851. function copyAugment(target, src, keys) {
  852. for (var i = 0, l = keys.length; i < l; i++) {
  853. var key = keys[i];
  854. def(target, key, src[key]);
  855. }
  856. }
  857. /**
  858. * Attempt to create an observer instance for a value,
  859. * returns the new observer if successfully observed,
  860. * or the existing observer if the value already has one.
  861. */
  862. function observe(value) {
  863. if (!isObject(value)) {
  864. return;
  865. }
  866. var ob = void 0;
  867. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  868. ob = value.__ob__;
  869. } else if (observerState.shouldConvert && !config._isServer && (Array.isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
  870. ob = new Observer(value);
  871. }
  872. return ob;
  873. }
  874. /**
  875. * Define a reactive property on an Object.
  876. */
  877. function defineReactive(obj, key, val, customSetter) {
  878. var dep = new Dep();
  879. var property = Object.getOwnPropertyDescriptor(obj, key);
  880. if (property && property.configurable === false) {
  881. return;
  882. }
  883. // cater for pre-defined getter/setters
  884. var getter = property && property.get;
  885. var setter = property && property.set;
  886. var childOb = observe(val);
  887. Object.defineProperty(obj, key, {
  888. enumerable: true,
  889. configurable: true,
  890. get: function reactiveGetter() {
  891. var value = getter ? getter.call(obj) : val;
  892. if (Dep.target) {
  893. dep.depend();
  894. if (childOb) {
  895. childOb.dep.depend();
  896. }
  897. if (Array.isArray(value)) {
  898. for (var e, i = 0, l = value.length; i < l; i++) {
  899. e = value[i];
  900. e && e.__ob__ && e.__ob__.dep.depend();
  901. }
  902. }
  903. }
  904. return value;
  905. },
  906. set: function reactiveSetter(newVal) {
  907. var value = getter ? getter.call(obj) : val;
  908. if (newVal === value) {
  909. return;
  910. }
  911. if (process.env.NODE_ENV !== 'production' && customSetter) {
  912. customSetter();
  913. }
  914. if (setter) {
  915. setter.call(obj, newVal);
  916. } else {
  917. val = newVal;
  918. }
  919. childOb = observe(newVal);
  920. dep.notify();
  921. }
  922. });
  923. }
  924. /**
  925. * Set a property on an object. Adds the new property and
  926. * triggers change notification if the property doesn't
  927. * already exist.
  928. */
  929. function set(obj, key, val) {
  930. if (Array.isArray(obj)) {
  931. obj.splice(key, 1, val);
  932. return val;
  933. }
  934. if (hasOwn(obj, key)) {
  935. obj[key] = val;
  936. return;
  937. }
  938. var ob = obj.__ob__;
  939. if (obj._isVue || ob && ob.vmCount) {
  940. 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.');
  941. return;
  942. }
  943. if (!ob) {
  944. obj[key] = val;
  945. return;
  946. }
  947. defineReactive(ob.value, key, val);
  948. ob.dep.notify();
  949. return val;
  950. }
  951. function initState(vm) {
  952. vm._watchers = [];
  953. initProps(vm);
  954. initData(vm);
  955. initComputed(vm);
  956. initMethods(vm);
  957. initWatch(vm);
  958. }
  959. function initProps(vm) {
  960. var props = vm.$options.props;
  961. var propsData = vm.$options.propsData;
  962. if (props) {
  963. var keys = vm.$options._propKeys = Object.keys(props);
  964. var isRoot = !vm.$parent;
  965. // root instance props should be converted
  966. observerState.shouldConvert = isRoot;
  967. var _loop = function _loop(i) {
  968. var key = keys[i];
  969. /* istanbul ignore else */
  970. if (process.env.NODE_ENV !== 'production') {
  971. defineReactive(vm, key, validateProp(key, props, propsData, vm), function () {
  972. if (vm.$parent && !observerState.isSettingProps) {
  973. 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);
  974. }
  975. });
  976. } else {
  977. defineReactive(vm, key, validateProp(key, props, propsData, vm));
  978. }
  979. };
  980. for (var i = 0; i < keys.length; i++) {
  981. _loop(i);
  982. }
  983. observerState.shouldConvert = true;
  984. }
  985. }
  986. function initData(vm) {
  987. var data = vm.$options.data;
  988. data = vm._data = typeof data === 'function' ? data.call(vm) : data || {};
  989. if (!isPlainObject(data)) {
  990. data = {};
  991. process.env.NODE_ENV !== 'production' && warn('data functions should return an object.', vm);
  992. }
  993. // proxy data on instance
  994. var keys = Object.keys(data);
  995. var props = vm.$options.props;
  996. var i = keys.length;
  997. while (i--) {
  998. if (props && hasOwn(props, keys[i])) {
  999. process.env.NODE_ENV !== 'production' && warn('The data property "' + keys[i] + '" is already declared as a prop. ' + 'Use prop default value instead.', vm);
  1000. } else {
  1001. proxy(vm, keys[i]);
  1002. }
  1003. }
  1004. // observe data
  1005. observe(data);
  1006. data.__ob__ && data.__ob__.vmCount++;
  1007. }
  1008. var computedSharedDefinition = {
  1009. enumerable: true,
  1010. configurable: true,
  1011. get: noop,
  1012. set: noop
  1013. };
  1014. function initComputed(vm) {
  1015. var computed = vm.$options.computed;
  1016. if (computed) {
  1017. for (var _key in computed) {
  1018. var userDef = computed[_key];
  1019. if (typeof userDef === 'function') {
  1020. computedSharedDefinition.get = makeComputedGetter(userDef, vm);
  1021. computedSharedDefinition.set = noop;
  1022. } else {
  1023. computedSharedDefinition.get = userDef.get ? userDef.cache !== false ? makeComputedGetter(userDef.get, vm) : bind(userDef.get, vm) : noop;
  1024. computedSharedDefinition.set = userDef.set ? bind(userDef.set, vm) : noop;
  1025. }
  1026. Object.defineProperty(vm, _key, computedSharedDefinition);
  1027. }
  1028. }
  1029. }
  1030. function makeComputedGetter(getter, owner) {
  1031. var watcher = new Watcher(owner, getter, noop, {
  1032. lazy: true
  1033. });
  1034. return function computedGetter() {
  1035. if (watcher.dirty) {
  1036. watcher.evaluate();
  1037. }
  1038. if (Dep.target) {
  1039. watcher.depend();
  1040. }
  1041. return watcher.value;
  1042. };
  1043. }
  1044. function initMethods(vm) {
  1045. var methods = vm.$options.methods;
  1046. if (methods) {
  1047. for (var _key2 in methods) {
  1048. vm[_key2] = bind(methods[_key2], vm);
  1049. }
  1050. }
  1051. }
  1052. function initWatch(vm) {
  1053. var watch = vm.$options.watch;
  1054. if (watch) {
  1055. for (var _key3 in watch) {
  1056. var handler = watch[_key3];
  1057. if (Array.isArray(handler)) {
  1058. for (var i = 0; i < handler.length; i++) {
  1059. createWatcher(vm, _key3, handler[i]);
  1060. }
  1061. } else {
  1062. createWatcher(vm, _key3, handler);
  1063. }
  1064. }
  1065. }
  1066. }
  1067. function createWatcher(vm, key, handler) {
  1068. var options = void 0;
  1069. if (isPlainObject(handler)) {
  1070. options = handler;
  1071. handler = handler.handler;
  1072. }
  1073. if (typeof handler === 'string') {
  1074. handler = vm[handler];
  1075. }
  1076. vm.$watch(key, handler, options);
  1077. }
  1078. function stateMixin(Vue) {
  1079. // flow somehow has problems with directly declared definition object
  1080. // when using Object.defineProperty, so we have to procedurally build up
  1081. // the object here.
  1082. var dataDef = {};
  1083. dataDef.get = function () {
  1084. return this._data;
  1085. };
  1086. if (process.env.NODE_ENV !== 'production') {
  1087. dataDef.set = function (newData) {
  1088. warn('Avoid replacing instance root $data. ' + 'Use nested data properties instead.', this);
  1089. };
  1090. }
  1091. Object.defineProperty(Vue.prototype, '$data', dataDef);
  1092. Vue.prototype.$watch = function (expOrFn, cb, options) {
  1093. var vm = this;
  1094. options = options || {};
  1095. options.user = true;
  1096. var watcher = new Watcher(vm, expOrFn, cb, options);
  1097. if (options.immediate) {
  1098. cb.call(vm, watcher.value);
  1099. }
  1100. return function unwatchFn() {
  1101. watcher.teardown();
  1102. };
  1103. };
  1104. }
  1105. function proxy(vm, key) {
  1106. if (!isReserved(key)) {
  1107. Object.defineProperty(vm, key, {
  1108. configurable: true,
  1109. enumerable: true,
  1110. get: function proxyGetter() {
  1111. return vm._data[key];
  1112. },
  1113. set: function proxySetter(val) {
  1114. vm._data[key] = val;
  1115. }
  1116. });
  1117. }
  1118. }
  1119. var VNode = // hoisted static node
  1120. // compoennt placeholder node
  1121. // rendered in this component's scope
  1122. function VNode(tag, data, children, text, elm, ns, context, componentOptions) {
  1123. this.tag = tag;
  1124. this.data = data;
  1125. this.children = children;
  1126. this.text = text;
  1127. this.elm = elm;
  1128. this.ns = ns;
  1129. this.context = context;
  1130. this.key = data && data.key;
  1131. this.componentOptions = componentOptions;
  1132. this.child = undefined;
  1133. this.parent = undefined;
  1134. this.raw = false;
  1135. this.isStatic = false;
  1136. this.isRootInsert = true;
  1137. this.isComment = false;
  1138. // apply construct hook.
  1139. // this is applied during render, before patch happens.
  1140. // unlike other hooks, this is applied on both client and server.
  1141. var constructHook = data && data.hook && data.hook.construct;
  1142. if (constructHook) {
  1143. constructHook(this);
  1144. }
  1145. } // necessary for enter transition check
  1146. // contains raw HTML
  1147. // component instance
  1148. ;
  1149. var emptyVNode = function emptyVNode() {
  1150. var node = new VNode();
  1151. node.text = '';
  1152. node.isComment = true;
  1153. return node;
  1154. };
  1155. function normalizeChildren(children, ns) {
  1156. if (isPrimitive(children)) {
  1157. return [createTextVNode(children)];
  1158. }
  1159. if (Array.isArray(children)) {
  1160. var res = [];
  1161. for (var i = 0, l = children.length; i < l; i++) {
  1162. var c = children[i];
  1163. var last = res[res.length - 1];
  1164. // nested
  1165. if (Array.isArray(c)) {
  1166. res.push.apply(res, normalizeChildren(c, ns));
  1167. } else if (isPrimitive(c)) {
  1168. if (last && last.text) {
  1169. last.text += String(c);
  1170. } else if (c !== '') {
  1171. // convert primitive to vnode
  1172. res.push(createTextVNode(c));
  1173. }
  1174. } else if (c instanceof VNode) {
  1175. if (c.text && last && last.text) {
  1176. last.text += c.text;
  1177. } else {
  1178. // inherit parent namespace
  1179. if (ns) {
  1180. applyNS(c, ns);
  1181. }
  1182. res.push(c);
  1183. }
  1184. }
  1185. }
  1186. return res;
  1187. }
  1188. }
  1189. function createTextVNode(val) {
  1190. return new VNode(undefined, undefined, undefined, String(val));
  1191. }
  1192. function applyNS(vnode, ns) {
  1193. if (vnode.tag && !vnode.ns) {
  1194. vnode.ns = ns;
  1195. if (vnode.children) {
  1196. for (var i = 0, l = vnode.children.length; i < l; i++) {
  1197. applyNS(vnode.children[i], ns);
  1198. }
  1199. }
  1200. }
  1201. }
  1202. function updateListeners(on, oldOn, add, remove) {
  1203. var name = void 0,
  1204. cur = void 0,
  1205. old = void 0,
  1206. fn = void 0,
  1207. event = void 0,
  1208. capture = void 0;
  1209. for (name in on) {
  1210. cur = on[name];
  1211. old = oldOn[name];
  1212. if (!old) {
  1213. capture = name.charAt(0) === '!';
  1214. event = capture ? name.slice(1) : name;
  1215. if (Array.isArray(cur)) {
  1216. add(event, cur.invoker = arrInvoker(cur), capture);
  1217. } else {
  1218. fn = cur;
  1219. cur = on[name] = {};
  1220. cur.fn = fn;
  1221. add(event, cur.invoker = fnInvoker(cur), capture);
  1222. }
  1223. } else if (Array.isArray(old)) {
  1224. old.length = cur.length;
  1225. for (var i = 0; i < old.length; i++) {
  1226. old[i] = cur[i];
  1227. }on[name] = old;
  1228. } else {
  1229. old.fn = cur;
  1230. on[name] = old;
  1231. }
  1232. }
  1233. for (name in oldOn) {
  1234. if (!on[name]) {
  1235. event = name.charAt(0) === '!' ? name.slice(1) : name;
  1236. remove(event, oldOn[name].invoker);
  1237. }
  1238. }
  1239. }
  1240. function arrInvoker(arr) {
  1241. return function (ev) {
  1242. var single = arguments.length === 1;
  1243. for (var i = 0; i < arr.length; i++) {
  1244. single ? arr[i](ev) : arr[i].apply(null, arguments);
  1245. }
  1246. };
  1247. }
  1248. function fnInvoker(o) {
  1249. return function (ev) {
  1250. var single = arguments.length === 1;
  1251. single ? o.fn(ev) : o.fn.apply(null, arguments);
  1252. };
  1253. }
  1254. var activeInstance = null;
  1255. function initLifecycle(vm) {
  1256. var options = vm.$options;
  1257. // locate first non-abstract parent
  1258. var parent = options.parent;
  1259. if (parent && !options.abstract) {
  1260. while (parent.$options.abstract && parent.$parent) {
  1261. parent = parent.$parent;
  1262. }
  1263. parent.$children.push(vm);
  1264. }
  1265. vm.$parent = parent;
  1266. vm.$root = parent ? parent.$root : vm;
  1267. vm.$children = [];
  1268. vm.$refs = {};
  1269. vm._watcher = null;
  1270. vm._inactive = false;
  1271. vm._isMounted = false;
  1272. vm._isDestroyed = false;
  1273. vm._isBeingDestroyed = false;
  1274. }
  1275. function lifecycleMixin(Vue) {
  1276. Vue.prototype._mount = function (el, hydrating) {
  1277. var vm = this;
  1278. vm.$el = el;
  1279. if (!vm.$options.render) {
  1280. vm.$options.render = emptyVNode;
  1281. if (process.env.NODE_ENV !== 'production') {
  1282. /* istanbul ignore if */
  1283. if (vm.$options.template) {
  1284. 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);
  1285. } else {
  1286. warn('Failed to mount component: template or render function not defined.', vm);
  1287. }
  1288. }
  1289. }
  1290. callHook(vm, 'beforeMount');
  1291. vm._watcher = new Watcher(vm, function () {
  1292. vm._update(vm._render(), hydrating);
  1293. }, noop);
  1294. hydrating = false;
  1295. // root instance, call mounted on self
  1296. // mounted is called for child components in its inserted hook
  1297. if (vm.$root === vm) {
  1298. vm._isMounted = true;
  1299. callHook(vm, 'mounted');
  1300. }
  1301. return vm;
  1302. };
  1303. Vue.prototype._update = function (vnode, hydrating) {
  1304. var vm = this;
  1305. if (vm._isMounted) {
  1306. callHook(vm, 'beforeUpdate');
  1307. }
  1308. var prevEl = vm.$el;
  1309. var prevActiveInstance = activeInstance;
  1310. activeInstance = vm;
  1311. if (!vm._vnode) {
  1312. // Vue.prototype.__patch__ is injected in entry points
  1313. // based on the rendering backend used.
  1314. vm.$el = vm.__patch__(vm.$el, vnode, hydrating);
  1315. } else {
  1316. vm.$el = vm.__patch__(vm._vnode, vnode);
  1317. }
  1318. activeInstance = prevActiveInstance;
  1319. vm._vnode = vnode;
  1320. // update __vue__ reference
  1321. if (prevEl) {
  1322. prevEl.__vue__ = null;
  1323. }
  1324. if (vm.$el) {
  1325. vm.$el.__vue__ = vm;
  1326. }
  1327. // if parent is an HOC, update its $el as well
  1328. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  1329. vm.$parent.$el = vm.$el;
  1330. }
  1331. if (vm._isMounted) {
  1332. callHook(vm, 'updated');
  1333. }
  1334. };
  1335. Vue.prototype._updateFromParent = function (propsData, listeners, parentVnode, renderChildren) {
  1336. var vm = this;
  1337. var hasChildren = !!(vm.$options._renderChildren || renderChildren);
  1338. vm.$options._parentVnode = parentVnode;
  1339. vm.$options._renderChildren = renderChildren;
  1340. // update props
  1341. if (propsData && vm.$options.props) {
  1342. observerState.shouldConvert = false;
  1343. if (process.env.NODE_ENV !== 'production') {
  1344. observerState.isSettingProps = true;
  1345. }
  1346. var propKeys = vm.$options._propKeys || [];
  1347. for (var i = 0; i < propKeys.length; i++) {
  1348. var key = propKeys[i];
  1349. vm[key] = validateProp(key, vm.$options.props, propsData, vm);
  1350. }
  1351. observerState.shouldConvert = true;
  1352. if (process.env.NODE_ENV !== 'production') {
  1353. observerState.isSettingProps = false;
  1354. }
  1355. }
  1356. // update listeners
  1357. if (listeners) {
  1358. var oldListeners = vm.$options._parentListeners;
  1359. vm.$options._parentListeners = listeners;
  1360. vm._updateListeners(listeners, oldListeners);
  1361. }
  1362. // resolve slots + force update if has children
  1363. if (hasChildren) {
  1364. vm.$slots = resolveSlots(renderChildren);
  1365. vm.$forceUpdate();
  1366. }
  1367. };
  1368. Vue.prototype.$forceUpdate = function () {
  1369. var vm = this;
  1370. if (vm._watcher) {
  1371. vm._watcher.update();
  1372. }
  1373. if (vm._watchers.length) {
  1374. for (var i = 0; i < vm._watchers.length; i++) {
  1375. vm._watchers[i].update(true /* shallow */);
  1376. }
  1377. }
  1378. };
  1379. Vue.prototype.$destroy = function () {
  1380. var vm = this;
  1381. if (vm._isBeingDestroyed) {
  1382. return;
  1383. }
  1384. callHook(vm, 'beforeDestroy');
  1385. vm._isBeingDestroyed = true;
  1386. // remove self from parent
  1387. var parent = vm.$parent;
  1388. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  1389. remove(parent.$children, vm);
  1390. }
  1391. // teardown watchers
  1392. if (vm._watcher) {
  1393. vm._watcher.teardown();
  1394. }
  1395. var i = vm._watchers.length;
  1396. while (i--) {
  1397. vm._watchers[i].teardown();
  1398. }
  1399. // remove reference from data ob
  1400. // frozen object may not have observer.
  1401. if (vm._data.__ob__) {
  1402. vm._data.__ob__.vmCount--;
  1403. }
  1404. // call the last hook...
  1405. vm._isDestroyed = true;
  1406. callHook(vm, 'destroyed');
  1407. // turn off all instance listeners.
  1408. vm.$off();
  1409. // remove __vue__ reference
  1410. if (vm.$el) {
  1411. vm.$el.__vue__ = null;
  1412. }
  1413. };
  1414. }
  1415. function callHook(vm, hook) {
  1416. var handlers = vm.$options[hook];
  1417. if (handlers) {
  1418. for (var i = 0, j = handlers.length; i < j; i++) {
  1419. handlers[i].call(vm);
  1420. }
  1421. }
  1422. vm.$emit('hook:' + hook);
  1423. }
  1424. var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
  1425. var hooksToMerge = Object.keys(hooks);
  1426. function createComponent(Ctor, data, context, children, tag) {
  1427. if (!Ctor) {
  1428. return;
  1429. }
  1430. if (isObject(Ctor)) {
  1431. Ctor = Vue.extend(Ctor);
  1432. }
  1433. if (typeof Ctor !== 'function') {
  1434. if (process.env.NODE_ENV !== 'production') {
  1435. warn('Invalid Component definition: ' + Ctor, context);
  1436. }
  1437. return;
  1438. }
  1439. // async component
  1440. if (!Ctor.cid) {
  1441. if (Ctor.resolved) {
  1442. Ctor = Ctor.resolved;
  1443. } else {
  1444. Ctor = resolveAsyncComponent(Ctor, function () {
  1445. // it's ok to queue this on every render because
  1446. // $forceUpdate is buffered by the scheduler.
  1447. context.$forceUpdate();
  1448. });
  1449. if (!Ctor) {
  1450. // return nothing if this is indeed an async component
  1451. // wait for the callback to trigger parent update.
  1452. return;
  1453. }
  1454. }
  1455. }
  1456. data = data || {};
  1457. // extract props
  1458. var propsData = extractProps(data, Ctor);
  1459. // functional component
  1460. if (Ctor.options.functional) {
  1461. var _ret = function () {
  1462. var props = {};
  1463. var propOptions = Ctor.options.props;
  1464. if (propOptions) {
  1465. Object.keys(propOptions).forEach(function (key) {
  1466. props[key] = validateProp(key, propOptions, propsData);
  1467. });
  1468. }
  1469. return {
  1470. v: Ctor.options.render.call(null, context.$createElement, {
  1471. props: props,
  1472. data: data,
  1473. parent: context,
  1474. children: normalizeChildren(children),
  1475. slots: function slots() {
  1476. return resolveSlots(children);
  1477. }
  1478. })
  1479. };
  1480. }();
  1481. if (typeof _ret === "object") return _ret.v;
  1482. }
  1483. // extract listeners, since these needs to be treated as
  1484. // child component listeners instead of DOM listeners
  1485. var listeners = data.on;
  1486. // replace with listeners with .native modifier
  1487. data.on = data.nativeOn;
  1488. if (Ctor.options.abstract) {
  1489. // abstract components do not keep anything
  1490. // other than props & listeners
  1491. data = {};
  1492. }
  1493. // merge component management hooks onto the placeholder node
  1494. mergeHooks(data);
  1495. // return a placeholder vnode
  1496. var name = Ctor.options.name || tag;
  1497. var vnode = new VNode('vue-component-' + Ctor.cid + (name ? '-' + name : ''), data, undefined, undefined, undefined, undefined, context, { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children });
  1498. return vnode;
  1499. }
  1500. function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
  1501. parent // activeInstance in lifecycle state
  1502. ) {
  1503. var vnodeComponentOptions = vnode.componentOptions;
  1504. var options = {
  1505. _isComponent: true,
  1506. parent: parent,
  1507. propsData: vnodeComponentOptions.propsData,
  1508. _componentTag: vnodeComponentOptions.tag,
  1509. _parentVnode: vnode,
  1510. _parentListeners: vnodeComponentOptions.listeners,
  1511. _renderChildren: vnodeComponentOptions.children
  1512. };
  1513. // check inline-template render functions
  1514. var inlineTemplate = vnode.data.inlineTemplate;
  1515. if (inlineTemplate) {
  1516. options.render = inlineTemplate.render;
  1517. options.staticRenderFns = inlineTemplate.staticRenderFns;
  1518. }
  1519. return new vnodeComponentOptions.Ctor(options);
  1520. }
  1521. function init(vnode, hydrating) {
  1522. if (!vnode.child) {
  1523. var child = vnode.child = createComponentInstanceForVnode(vnode, activeInstance);
  1524. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  1525. }
  1526. }
  1527. function prepatch(oldVnode, vnode) {
  1528. var options = vnode.componentOptions;
  1529. var child = vnode.child = oldVnode.child;
  1530. child._updateFromParent(options.propsData, // updated props
  1531. options.listeners, // updated listeners
  1532. vnode, // new parent vnode
  1533. options.children // new children
  1534. );
  1535. }
  1536. function insert(vnode) {
  1537. if (!vnode.child._isMounted) {
  1538. vnode.child._isMounted = true;
  1539. callHook(vnode.child, 'mounted');
  1540. }
  1541. if (vnode.data.keepAlive) {
  1542. vnode.child._inactive = false;
  1543. callHook(vnode.child, 'activated');
  1544. }
  1545. }
  1546. function destroy(vnode) {
  1547. if (!vnode.child._isDestroyed) {
  1548. if (!vnode.data.keepAlive) {
  1549. vnode.child.$destroy();
  1550. } else {
  1551. vnode.child._inactive = true;
  1552. callHook(vnode.child, 'deactivated');
  1553. }
  1554. }
  1555. }
  1556. function resolveAsyncComponent(factory, cb) {
  1557. if (factory.requested) {
  1558. // pool callbacks
  1559. factory.pendingCallbacks.push(cb);
  1560. } else {
  1561. var _ret2 = function () {
  1562. factory.requested = true;
  1563. var cbs = factory.pendingCallbacks = [cb];
  1564. var sync = true;
  1565. factory(
  1566. // resolve
  1567. function (res) {
  1568. if (isObject(res)) {
  1569. res = Vue.extend(res);
  1570. }
  1571. // cache resolved
  1572. factory.resolved = res;
  1573. // invoke callbacks only if this is not a synchronous resolve
  1574. // (async resolves are shimmed as synchronous during SSR)
  1575. if (!sync) {
  1576. for (var i = 0, l = cbs.length; i < l; i++) {
  1577. cbs[i](res);
  1578. }
  1579. }
  1580. },
  1581. // reject
  1582. function (reason) {
  1583. process.env.NODE_ENV !== 'production' && warn('Failed to resolve async component: ' + factory + (reason ? '\nReason: ' + reason : ''));
  1584. });
  1585. sync = false;
  1586. // return in case resolved synchronously
  1587. return {
  1588. v: factory.resolved
  1589. };
  1590. }();
  1591. if (typeof _ret2 === "object") return _ret2.v;
  1592. }
  1593. }
  1594. function extractProps(data, Ctor) {
  1595. // we are only extrating raw values here.
  1596. // validation and default values are handled in the child
  1597. // component itself.
  1598. var propOptions = Ctor.options.props;
  1599. if (!propOptions) {
  1600. return;
  1601. }
  1602. var res = {};
  1603. var attrs = data.attrs;
  1604. var props = data.props;
  1605. var domProps = data.domProps;
  1606. if (attrs || props || domProps) {
  1607. for (var key in propOptions) {
  1608. var altKey = hyphenate(key);
  1609. checkProp(res, props, key, altKey, true) || checkProp(res, attrs, key, altKey) || checkProp(res, domProps, key, altKey);
  1610. }
  1611. }
  1612. return res;
  1613. }
  1614. function checkProp(res, hash, key, altKey, preserve) {
  1615. if (hash) {
  1616. if (hasOwn(hash, key)) {
  1617. res[key] = hash[key];
  1618. if (!preserve) {
  1619. delete hash[key];
  1620. }
  1621. return true;
  1622. } else if (hasOwn(hash, altKey)) {
  1623. res[key] = hash[altKey];
  1624. if (!preserve) {
  1625. delete hash[altKey];
  1626. }
  1627. return true;
  1628. }
  1629. }
  1630. return false;
  1631. }
  1632. function mergeHooks(data) {
  1633. if (!data.hook) {
  1634. data.hook = {};
  1635. }
  1636. for (var i = 0; i < hooksToMerge.length; i++) {
  1637. var key = hooksToMerge[i];
  1638. var fromParent = data.hook[key];
  1639. var ours = hooks[key];
  1640. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  1641. }
  1642. }
  1643. function mergeHook$1(a, b) {
  1644. // since all hooks have at most two args, use fixed args
  1645. // to avoid having to use fn.apply().
  1646. return function (_, __) {
  1647. a(_, __);
  1648. b(_, __);
  1649. };
  1650. }
  1651. // wrapper function for providing a more flexible interface
  1652. // without getting yelled at by flow
  1653. function createElement(tag, data, children) {
  1654. if (data && (Array.isArray(data) || typeof data !== 'object')) {
  1655. children = data;
  1656. data = undefined;
  1657. }
  1658. // make sure to use real instance instead of proxy as context
  1659. return _createElement(this._self, tag, data, children);
  1660. }
  1661. function _createElement(context, tag, data, children) {
  1662. if (data && data.__ob__) {
  1663. 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);
  1664. return;
  1665. }
  1666. if (!tag) {
  1667. // in case of component :is set to falsy value
  1668. return emptyVNode();
  1669. }
  1670. if (typeof tag === 'string') {
  1671. var Ctor = void 0;
  1672. var ns = config.getTagNamespace(tag);
  1673. if (config.isReservedTag(tag)) {
  1674. // platform built-in elements
  1675. return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context);
  1676. } else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
  1677. // component
  1678. return createComponent(Ctor, data, context, children, tag);
  1679. } else {
  1680. // unknown or unlisted namespaced elements
  1681. // check at runtime because it may get assigned a namespace when its
  1682. // parent normalizes children
  1683. return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context);
  1684. }
  1685. } else {
  1686. // direct component options / constructor
  1687. return createComponent(tag, data, context, children);
  1688. }
  1689. }
  1690. function initRender(vm) {
  1691. vm.$vnode = null; // the placeholder node in parent tree
  1692. vm._vnode = null; // the root of the child tree
  1693. vm._staticTrees = null;
  1694. vm.$slots = resolveSlots(vm.$options._renderChildren);
  1695. // bind the public createElement fn to this instance
  1696. // so that we get proper render context inside it.
  1697. vm.$createElement = bind(createElement, vm);
  1698. if (vm.$options.el) {
  1699. vm.$mount(vm.$options.el);
  1700. }
  1701. }
  1702. function renderMixin(Vue) {
  1703. Vue.prototype.$nextTick = function (fn) {
  1704. nextTick(fn, this);
  1705. };
  1706. Vue.prototype._render = function () {
  1707. var vm = this;
  1708. var _vm$$options = vm.$options;
  1709. var render = _vm$$options.render;
  1710. var staticRenderFns = _vm$$options.staticRenderFns;
  1711. var _parentVnode = _vm$$options._parentVnode;
  1712. if (staticRenderFns && !vm._staticTrees) {
  1713. vm._staticTrees = [];
  1714. }
  1715. // set parent vnode. this allows render functions to have access
  1716. // to the data on the placeholder node.
  1717. vm.$vnode = _parentVnode;
  1718. // render self
  1719. var vnode = void 0;
  1720. try {
  1721. vnode = render.call(vm._renderProxy, vm.$createElement);
  1722. } catch (e) {
  1723. if (process.env.NODE_ENV !== 'production') {
  1724. warn('Error when rendering ' + formatComponentName(vm) + ':');
  1725. }
  1726. /* istanbul ignore else */
  1727. if (config.errorHandler) {
  1728. config.errorHandler.call(null, e, vm);
  1729. } else {
  1730. if (config._isServer) {
  1731. throw e;
  1732. } else {
  1733. setTimeout(function () {
  1734. throw e;
  1735. }, 0);
  1736. }
  1737. }
  1738. // return previous vnode to prevent render error causing blank component
  1739. vnode = vm._vnode;
  1740. }
  1741. // return empty vnode in case the render function errored out
  1742. if (!(vnode instanceof VNode)) {
  1743. if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
  1744. warn('Multiple root nodes returned from render function. Render function ' + 'should return a single root node.', vm);
  1745. }
  1746. vnode = emptyVNode();
  1747. }
  1748. // set parent
  1749. vnode.parent = _parentVnode;
  1750. return vnode;
  1751. };
  1752. // shorthands used in render functions
  1753. Vue.prototype._h = createElement;
  1754. // toString for mustaches
  1755. Vue.prototype._s = _toString;
  1756. // number conversion
  1757. Vue.prototype._n = toNumber;
  1758. // render static tree by index
  1759. Vue.prototype._m = function renderStatic(index, isInFor) {
  1760. var tree = this._staticTrees[index];
  1761. // if has already-rendered static tree and not inside v-for,
  1762. // we can reuse the same tree by indentity.
  1763. if (tree && !isInFor) {
  1764. return tree;
  1765. }
  1766. // otherwise, render a fresh tree.
  1767. tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
  1768. if (Array.isArray(tree)) {
  1769. for (var i = 0; i < tree.length; i++) {
  1770. tree[i].isStatic = true;
  1771. tree[i].key = '__static__' + index + '_' + i;
  1772. }
  1773. } else {
  1774. tree.isStatic = true;
  1775. tree.key = '__static__' + index;
  1776. }
  1777. return tree;
  1778. };
  1779. // filter resolution helper
  1780. var identity = function identity(_) {
  1781. return _;
  1782. };
  1783. Vue.prototype._f = function resolveFilter(id) {
  1784. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1785. };
  1786. // render v-for
  1787. Vue.prototype._l = function renderList(val, render) {
  1788. var ret = void 0,
  1789. i = void 0,
  1790. l = void 0,
  1791. keys = void 0,
  1792. key = void 0;
  1793. if (Array.isArray(val)) {
  1794. ret = new Array(val.length);
  1795. for (i = 0, l = val.length; i < l; i++) {
  1796. ret[i] = render(val[i], i);
  1797. }
  1798. } else if (typeof val === 'number') {
  1799. ret = new Array(val);
  1800. for (i = 0; i < val; i++) {
  1801. ret[i] = render(i + 1, i);
  1802. }
  1803. } else if (isObject(val)) {
  1804. keys = Object.keys(val);
  1805. ret = new Array(keys.length);
  1806. for (i = 0, l = keys.length; i < l; i++) {
  1807. key = keys[i];
  1808. ret[i] = render(val[key], key, i);
  1809. }
  1810. }
  1811. return ret;
  1812. };
  1813. // apply v-bind object
  1814. Vue.prototype._b = function bindProps(vnode, value, asProp) {
  1815. if (value) {
  1816. if (!isObject(value)) {
  1817. process.env.NODE_ENV !== 'production' && warn('v-bind without argument expects an Object or Array value', this);
  1818. } else {
  1819. if (Array.isArray(value)) {
  1820. value = toObject(value);
  1821. }
  1822. var data = vnode.data;
  1823. for (var _key in value) {
  1824. if (_key === 'class' || _key === 'style') {
  1825. data[_key] = value[_key];
  1826. } else {
  1827. var hash = asProp || config.mustUseProp(_key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
  1828. hash[_key] = value[_key];
  1829. }
  1830. }
  1831. }
  1832. }
  1833. };
  1834. // expose v-on keyCodes
  1835. Vue.prototype._k = function getKeyCodes(key) {
  1836. return config.keyCodes[key];
  1837. };
  1838. }
  1839. function resolveSlots(renderChildren) {
  1840. var slots = {};
  1841. if (!renderChildren) {
  1842. return slots;
  1843. }
  1844. var children = normalizeChildren(renderChildren) || [];
  1845. var defaultSlot = [];
  1846. var name = void 0,
  1847. child = void 0;
  1848. for (var i = 0, l = children.length; i < l; i++) {
  1849. child = children[i];
  1850. if (child.data && (name = child.data.slot)) {
  1851. delete child.data.slot;
  1852. var slot = slots[name] || (slots[name] = []);
  1853. if (child.tag === 'template') {
  1854. slot.push.apply(slot, child.children);
  1855. } else {
  1856. slot.push(child);
  1857. }
  1858. } else {
  1859. defaultSlot.push(child);
  1860. }
  1861. }
  1862. // ignore single whitespace
  1863. if (defaultSlot.length && !(defaultSlot.length === 1 && defaultSlot[0].text === ' ')) {
  1864. slots.default = defaultSlot;
  1865. }
  1866. return slots;
  1867. }
  1868. function initEvents(vm) {
  1869. vm._events = Object.create(null);
  1870. // init parent attached events
  1871. var listeners = vm.$options._parentListeners;
  1872. var on = bind(vm.$on, vm);
  1873. var off = bind(vm.$off, vm);
  1874. vm._updateListeners = function (listeners, oldListeners) {
  1875. updateListeners(listeners, oldListeners || {}, on, off);
  1876. };
  1877. if (listeners) {
  1878. vm._updateListeners(listeners);
  1879. }
  1880. }
  1881. function eventsMixin(Vue) {
  1882. Vue.prototype.$on = function (event, fn) {
  1883. var vm = this;(vm._events[event] || (vm._events[event] = [])).push(fn);
  1884. return vm;
  1885. };
  1886. Vue.prototype.$once = function (event, fn) {
  1887. var vm = this;
  1888. function on() {
  1889. vm.$off(event, on);
  1890. fn.apply(vm, arguments);
  1891. }
  1892. on.fn = fn;
  1893. vm.$on(event, on);
  1894. return vm;
  1895. };
  1896. Vue.prototype.$off = function (event, fn) {
  1897. var vm = this;
  1898. // all
  1899. if (!arguments.length) {
  1900. vm._events = Object.create(null);
  1901. return vm;
  1902. }
  1903. // specific event
  1904. var cbs = vm._events[event];
  1905. if (!cbs) {
  1906. return vm;
  1907. }
  1908. if (arguments.length === 1) {
  1909. vm._events[event] = null;
  1910. return vm;
  1911. }
  1912. // specific handler
  1913. var cb = void 0;
  1914. var i = cbs.length;
  1915. while (i--) {
  1916. cb = cbs[i];
  1917. if (cb === fn || cb.fn === fn) {
  1918. cbs.splice(i, 1);
  1919. break;
  1920. }
  1921. }
  1922. return vm;
  1923. };
  1924. Vue.prototype.$emit = function (event) {
  1925. var vm = this;
  1926. var cbs = vm._events[event];
  1927. if (cbs) {
  1928. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  1929. var args = toArray(arguments, 1);
  1930. for (var i = 0, l = cbs.length; i < l; i++) {
  1931. cbs[i].apply(vm, args);
  1932. }
  1933. }
  1934. return vm;
  1935. };
  1936. }
  1937. var uid = 0;
  1938. function initMixin(Vue) {
  1939. Vue.prototype._init = function (options) {
  1940. var vm = this;
  1941. // a uid
  1942. vm._uid = uid++;
  1943. // a flag to avoid this being observed
  1944. vm._isVue = true;
  1945. // merge options
  1946. if (options && options._isComponent) {
  1947. // optimize internal component instantiation
  1948. // since dynamic options merging is pretty slow, and none of the
  1949. // internal component options needs special treatment.
  1950. initInternalComponent(vm, options);
  1951. } else {
  1952. vm.$options = mergeOptions(resolveConstructorOptions(vm), options || {}, vm);
  1953. }
  1954. /* istanbul ignore else */
  1955. if (process.env.NODE_ENV !== 'production') {
  1956. initProxy(vm);
  1957. } else {
  1958. vm._renderProxy = vm;
  1959. }
  1960. // expose real self
  1961. vm._self = vm;
  1962. initLifecycle(vm);
  1963. initEvents(vm);
  1964. callHook(vm, 'beforeCreate');
  1965. initState(vm);
  1966. callHook(vm, 'created');
  1967. initRender(vm);
  1968. };
  1969. function initInternalComponent(vm, options) {
  1970. var opts = vm.$options = Object.create(resolveConstructorOptions(vm));
  1971. // doing this because it's faster than dynamic enumeration.
  1972. opts.parent = options.parent;
  1973. opts.propsData = options.propsData;
  1974. opts._parentVnode = options._parentVnode;
  1975. opts._parentListeners = options._parentListeners;
  1976. opts._renderChildren = options._renderChildren;
  1977. opts._componentTag = options._componentTag;
  1978. if (options.render) {
  1979. opts.render = options.render;
  1980. opts.staticRenderFns = options.staticRenderFns;
  1981. }
  1982. }
  1983. function resolveConstructorOptions(vm) {
  1984. var Ctor = vm.constructor;
  1985. var options = Ctor.options;
  1986. if (Ctor.super) {
  1987. var superOptions = Ctor.super.options;
  1988. var cachedSuperOptions = Ctor.superOptions;
  1989. if (superOptions !== cachedSuperOptions) {
  1990. // super option changed
  1991. Ctor.superOptions = superOptions;
  1992. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  1993. if (options.name) {
  1994. options.components[options.name] = Ctor;
  1995. }
  1996. }
  1997. }
  1998. return options;
  1999. }
  2000. }
  2001. function Vue(options) {
  2002. this._init(options);
  2003. }
  2004. initMixin(Vue);
  2005. stateMixin(Vue);
  2006. eventsMixin(Vue);
  2007. lifecycleMixin(Vue);
  2008. renderMixin(Vue);
  2009. /**
  2010. * Option overwriting strategies are functions that handle
  2011. * how to merge a parent option value and a child option
  2012. * value into the final value.
  2013. */
  2014. var strats = config.optionMergeStrategies;
  2015. /**
  2016. * Options with restrictions
  2017. */
  2018. if (process.env.NODE_ENV !== 'production') {
  2019. strats.el = strats.propsData = function (parent, child, vm, key) {
  2020. if (!vm) {
  2021. warn('option "' + key + '" can only be used during instance ' + 'creation with the `new` keyword.');
  2022. }
  2023. return defaultStrat(parent, child);
  2024. };
  2025. strats.name = function (parent, child, vm) {
  2026. if (vm) {
  2027. warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
  2028. }
  2029. return defaultStrat(parent, child);
  2030. };
  2031. }
  2032. /**
  2033. * Helper that recursively merges two data objects together.
  2034. */
  2035. function mergeData(to, from) {
  2036. var key = void 0,
  2037. toVal = void 0,
  2038. fromVal = void 0;
  2039. for (key in from) {
  2040. toVal = to[key];
  2041. fromVal = from[key];
  2042. if (!hasOwn(to, key)) {
  2043. set(to, key, fromVal);
  2044. } else if (isObject(toVal) && isObject(fromVal)) {
  2045. mergeData(toVal, fromVal);
  2046. }
  2047. }
  2048. return to;
  2049. }
  2050. /**
  2051. * Data
  2052. */
  2053. strats.data = function (parentVal, childVal, vm) {
  2054. if (!vm) {
  2055. // in a Vue.extend merge, both should be functions
  2056. if (!childVal) {
  2057. return parentVal;
  2058. }
  2059. if (typeof childVal !== 'function') {
  2060. process.env.NODE_ENV !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  2061. return parentVal;
  2062. }
  2063. if (!parentVal) {
  2064. return childVal;
  2065. }
  2066. // when parentVal & childVal are both present,
  2067. // we need to return a function that returns the
  2068. // merged result of both functions... no need to
  2069. // check if parentVal is a function here because
  2070. // it has to be a function to pass previous merges.
  2071. return function mergedDataFn() {
  2072. return mergeData(childVal.call(this), parentVal.call(this));
  2073. };
  2074. } else if (parentVal || childVal) {
  2075. return function mergedInstanceDataFn() {
  2076. // instance merge
  2077. var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
  2078. var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
  2079. if (instanceData) {
  2080. return mergeData(instanceData, defaultData);
  2081. } else {
  2082. return defaultData;
  2083. }
  2084. };
  2085. }
  2086. };
  2087. /**
  2088. * Hooks and param attributes are merged as arrays.
  2089. */
  2090. function mergeHook(parentVal, childVal) {
  2091. return childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [childVal] : parentVal;
  2092. }
  2093. config._lifecycleHooks.forEach(function (hook) {
  2094. strats[hook] = mergeHook;
  2095. });
  2096. /**
  2097. * Assets
  2098. *
  2099. * When a vm is present (instance creation), we need to do
  2100. * a three-way merge between constructor options, instance
  2101. * options and parent options.
  2102. */
  2103. function mergeAssets(parentVal, childVal) {
  2104. var res = Object.create(parentVal || null);
  2105. return childVal ? extend(res, childVal) : res;
  2106. }
  2107. config._assetTypes.forEach(function (type) {
  2108. strats[type + 's'] = mergeAssets;
  2109. });
  2110. /**
  2111. * Watchers.
  2112. *
  2113. * Watchers hashes should not overwrite one
  2114. * another, so we merge them as arrays.
  2115. */
  2116. strats.watch = function (parentVal, childVal) {
  2117. /* istanbul ignore if */
  2118. if (!childVal) return parentVal;
  2119. if (!parentVal) return childVal;
  2120. var ret = {};
  2121. extend(ret, parentVal);
  2122. for (var key in childVal) {
  2123. var parent = ret[key];
  2124. var child = childVal[key];
  2125. if (parent && !Array.isArray(parent)) {
  2126. parent = [parent];
  2127. }
  2128. ret[key] = parent ? parent.concat(child) : [child];
  2129. }
  2130. return ret;
  2131. };
  2132. /**
  2133. * Other object hashes.
  2134. */
  2135. strats.props = strats.methods = strats.computed = function (parentVal, childVal) {
  2136. if (!childVal) return parentVal;
  2137. if (!parentVal) return childVal;
  2138. var ret = Object.create(null);
  2139. extend(ret, parentVal);
  2140. extend(ret, childVal);
  2141. return ret;
  2142. };
  2143. /**
  2144. * Default strategy.
  2145. */
  2146. var defaultStrat = function defaultStrat(parentVal, childVal) {
  2147. return childVal === undefined ? parentVal : childVal;
  2148. };
  2149. /**
  2150. * Make sure component options get converted to actual
  2151. * constructors.
  2152. */
  2153. function normalizeComponents(options) {
  2154. if (options.components) {
  2155. var components = options.components;
  2156. var def = void 0;
  2157. for (var key in components) {
  2158. var lower = key.toLowerCase();
  2159. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  2160. process.env.NODE_ENV !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
  2161. continue;
  2162. }
  2163. def = components[key];
  2164. if (isPlainObject(def)) {
  2165. components[key] = Vue.extend(def);
  2166. }
  2167. }
  2168. }
  2169. }
  2170. /**
  2171. * Ensure all props option syntax are normalized into the
  2172. * Object-based format.
  2173. */
  2174. function normalizeProps(options) {
  2175. var props = options.props;
  2176. if (!props) return;
  2177. var res = {};
  2178. var i = void 0,
  2179. val = void 0,
  2180. name = void 0;
  2181. if (Array.isArray(props)) {
  2182. i = props.length;
  2183. while (i--) {
  2184. val = props[i];
  2185. if (typeof val === 'string') {
  2186. name = camelize(val);
  2187. res[name] = { type: null };
  2188. } else if (process.env.NODE_ENV !== 'production') {
  2189. warn('props must be strings when using array syntax.');
  2190. }
  2191. }
  2192. } else if (isPlainObject(props)) {
  2193. for (var key in props) {
  2194. val = props[key];
  2195. name = camelize(key);
  2196. res[name] = isPlainObject(val) ? val : { type: val };
  2197. }
  2198. }
  2199. options.props = res;
  2200. }
  2201. /**
  2202. * Normalize raw function directives into object format.
  2203. */
  2204. function normalizeDirectives(options) {
  2205. var dirs = options.directives;
  2206. if (dirs) {
  2207. for (var key in dirs) {
  2208. var def = dirs[key];
  2209. if (typeof def === 'function') {
  2210. dirs[key] = { bind: def, update: def };
  2211. }
  2212. }
  2213. }
  2214. }
  2215. /**
  2216. * Merge two option objects into a new one.
  2217. * Core utility used in both instantiation and inheritance.
  2218. */
  2219. function mergeOptions(parent, child, vm) {
  2220. normalizeComponents(child);
  2221. normalizeProps(child);
  2222. normalizeDirectives(child);
  2223. var extendsFrom = child.extends;
  2224. if (extendsFrom) {
  2225. parent = typeof extendsFrom === 'function' ? mergeOptions(parent, extendsFrom.options, vm) : mergeOptions(parent, extendsFrom, vm);
  2226. }
  2227. if (child.mixins) {
  2228. for (var i = 0, l = child.mixins.length; i < l; i++) {
  2229. var mixin = child.mixins[i];
  2230. if (mixin.prototype instanceof Vue) {
  2231. mixin = mixin.options;
  2232. }
  2233. parent = mergeOptions(parent, mixin, vm);
  2234. }
  2235. }
  2236. var options = {};
  2237. var key = void 0;
  2238. for (key in parent) {
  2239. mergeField(key);
  2240. }
  2241. for (key in child) {
  2242. if (!hasOwn(parent, key)) {
  2243. mergeField(key);
  2244. }
  2245. }
  2246. function mergeField(key) {
  2247. var strat = strats[key] || defaultStrat;
  2248. options[key] = strat(parent[key], child[key], vm, key);
  2249. }
  2250. return options;
  2251. }
  2252. /**
  2253. * Resolve an asset.
  2254. * This function is used because child instances need access
  2255. * to assets defined in its ancestor chain.
  2256. */
  2257. function resolveAsset(options, type, id, warnMissing) {
  2258. /* istanbul ignore if */
  2259. if (typeof id !== 'string') {
  2260. return;
  2261. }
  2262. var assets = options[type];
  2263. var res = assets[id] ||
  2264. // camelCase ID
  2265. assets[camelize(id)] ||
  2266. // Pascal Case ID
  2267. assets[capitalize(camelize(id))];
  2268. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  2269. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id, options);
  2270. }
  2271. return res;
  2272. }
  2273. function validateProp(key, propOptions, propsData, vm) {
  2274. /* istanbul ignore if */
  2275. if (!propsData) return;
  2276. var prop = propOptions[key];
  2277. var absent = !hasOwn(propsData, key);
  2278. var value = propsData[key];
  2279. // handle boolean props
  2280. if (getType(prop.type) === 'Boolean') {
  2281. if (absent && !hasOwn(prop, 'default')) {
  2282. value = false;
  2283. } else if (value === '' || value === hyphenate(key)) {
  2284. value = true;
  2285. }
  2286. }
  2287. // check default value
  2288. if (value === undefined) {
  2289. value = getPropDefaultValue(vm, prop, key);
  2290. // since the default value is a fresh copy,
  2291. // make sure to observe it.
  2292. var prevShouldConvert = observerState.shouldConvert;
  2293. observerState.shouldConvert = true;
  2294. observe(value);
  2295. observerState.shouldConvert = prevShouldConvert;
  2296. }
  2297. if (process.env.NODE_ENV !== 'production') {
  2298. assertProp(prop, key, value, vm, absent);
  2299. }
  2300. return value;
  2301. }
  2302. /**
  2303. * Get the default value of a prop.
  2304. */
  2305. function getPropDefaultValue(vm, prop, name) {
  2306. // no default, return undefined
  2307. if (!hasOwn(prop, 'default')) {
  2308. return undefined;
  2309. }
  2310. var def = prop.default;
  2311. // warn against non-factory defaults for Object & Array
  2312. if (isObject(def)) {
  2313. 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);
  2314. }
  2315. // call factory function for non-Function types
  2316. return typeof def === 'function' && prop.type !== Function ? def.call(vm) : def;
  2317. }
  2318. /**
  2319. * Assert whether a prop is valid.
  2320. */
  2321. function assertProp(prop, name, value, vm, absent) {
  2322. if (prop.required && absent) {
  2323. warn('Missing required prop: "' + name + '"', vm);
  2324. return;
  2325. }
  2326. if (value == null && !prop.required) {
  2327. return;
  2328. }
  2329. var type = prop.type;
  2330. var valid = !type;
  2331. var expectedTypes = [];
  2332. if (type) {
  2333. if (!Array.isArray(type)) {
  2334. type = [type];
  2335. }
  2336. for (var i = 0; i < type.length && !valid; i++) {
  2337. var assertedType = assertType(value, type[i]);
  2338. expectedTypes.push(assertedType.expectedType);
  2339. valid = assertedType.valid;
  2340. }
  2341. }
  2342. if (!valid) {
  2343. warn('Invalid prop: type check failed for prop "' + name + '".' + ' Expected ' + expectedTypes.map(capitalize).join(', ') + ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.', vm);
  2344. return;
  2345. }
  2346. var validator = prop.validator;
  2347. if (validator) {
  2348. if (!validator(value)) {
  2349. warn('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  2350. }
  2351. }
  2352. }
  2353. /**
  2354. * Assert the type of a value
  2355. */
  2356. function assertType(value, type) {
  2357. var valid = void 0;
  2358. var expectedType = getType(type);
  2359. if (expectedType === 'String') {
  2360. valid = typeof value === (expectedType = 'string');
  2361. } else if (expectedType === 'Number') {
  2362. valid = typeof value === (expectedType = 'number');
  2363. } else if (expectedType === 'Boolean') {
  2364. valid = typeof value === (expectedType = 'boolean');
  2365. } else if (expectedType === 'Function') {
  2366. valid = typeof value === (expectedType = 'function');
  2367. } else if (expectedType === 'Object') {
  2368. valid = isPlainObject(value);
  2369. } else if (expectedType === 'Array') {
  2370. valid = Array.isArray(value);
  2371. } else {
  2372. valid = value instanceof type;
  2373. }
  2374. return {
  2375. valid: valid,
  2376. expectedType: expectedType
  2377. };
  2378. }
  2379. /**
  2380. * Use function string name to check built-in types,
  2381. * because a simple equality check will fail when running
  2382. * across different vms / iframes.
  2383. */
  2384. function getType(fn) {
  2385. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  2386. return match && match[1];
  2387. }
  2388. // attributes that should be using props for binding
  2389. var mustUseProp = makeMap('value,selected,checked,muted');
  2390. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  2391. 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');
  2392. 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');
  2393. 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');
  2394. var isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 'link,meta,param,source,track,wbr', true);
  2395. // Elements that you can, intentionally, leave open
  2396. // (and which close themselves)
  2397. var canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source', true);
  2398. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  2399. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  2400. 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);
  2401. // this map is intentionally selective, only covering SVG elements that may
  2402. // contain child elements.
  2403. 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);
  2404. var isPreTag = function isPreTag(tag) {
  2405. return tag === 'pre';
  2406. };
  2407. var isReservedTag = function isReservedTag(tag) {
  2408. return isHTMLTag(tag) || isSVG(tag);
  2409. };
  2410. function getTagNamespace(tag) {
  2411. if (isSVG(tag)) {
  2412. return 'svg';
  2413. }
  2414. // basic support for MathML
  2415. // note it doesn't support other MathML elements being component roots
  2416. if (tag === 'math') {
  2417. return 'math';
  2418. }
  2419. }
  2420. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  2421. var isIE = UA && /msie|trident/.test(UA);
  2422. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  2423. var isAndroid = UA && UA.indexOf('android') > 0;
  2424. // According to
  2425. // https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
  2426. // when serializing innerHTML, <, >, ", & should be encoded as entities.
  2427. // However, only some browsers, e.g. PhantomJS, encodes < and >.
  2428. // this causes problems with the in-browser parser.
  2429. var shouldDecodeTags = inBrowser ? function () {
  2430. var div = document.createElement('div');
  2431. div.innerHTML = '<div a=">">';
  2432. return div.innerHTML.indexOf('&gt;') > 0;
  2433. }() : false;
  2434. // Regular Expressions for parsing tags and attributes
  2435. var singleAttrIdentifier = /([^\s"'<>\/=]+)/;
  2436. var singleAttrAssign = /(?:=)/;
  2437. var singleAttrValues = [
  2438. // attr value double quotes
  2439. /"([^"]*)"+/.source,
  2440. // attr value, single quotes
  2441. /'([^']*)'+/.source,
  2442. // attr value, no quotes
  2443. /([^\s"'=<>`]+)/.source];
  2444. var attribute = new RegExp('^\\s*' + singleAttrIdentifier.source + '(?:\\s*(' + singleAttrAssign.source + ')' + '\\s*(?:' + singleAttrValues.join('|') + '))?');
  2445. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  2446. // but for Vue templates we can enforce a simple charset
  2447. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  2448. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  2449. var startTagOpen = new RegExp('^<' + qnameCapture);
  2450. var startTagClose = /^\s*(\/?)>/;
  2451. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  2452. var doctype = /^<!DOCTYPE [^>]+>/i;
  2453. var IS_REGEX_CAPTURING_BROKEN = false;
  2454. 'x'.replace(/x(.)?/g, function (m, g) {
  2455. IS_REGEX_CAPTURING_BROKEN = g === '';
  2456. });
  2457. // Special Elements (can contain anything)
  2458. var isSpecialTag = makeMap('script,style', true);
  2459. var reCache = {};
  2460. var ampRE = /&amp;/g;
  2461. var ltRE = /&lt;/g;
  2462. var gtRE = /&gt;/g;
  2463. var quoteRE = /&quot;/g;
  2464. function decodeAttr(value, shouldDecodeTags) {
  2465. if (shouldDecodeTags) {
  2466. value = value.replace(ltRE, '<').replace(gtRE, '>');
  2467. }
  2468. return value.replace(ampRE, '&').replace(quoteRE, '"');
  2469. }
  2470. function parseHTML(html, options) {
  2471. var stack = [];
  2472. var expectHTML = options.expectHTML;
  2473. var isUnaryTag = options.isUnaryTag || no;
  2474. var isFromDOM = options.isFromDOM;
  2475. var shouldDecodeTags = options.shouldDecodeTags;
  2476. var index = 0;
  2477. var last = void 0,
  2478. lastTag = void 0;
  2479. while (html) {
  2480. last = html;
  2481. // Make sure we're not in a script or style element
  2482. if (!lastTag || !isSpecialTag(lastTag)) {
  2483. var textEnd = html.indexOf('<');
  2484. if (textEnd === 0) {
  2485. // Comment:
  2486. if (/^<!--/.test(html)) {
  2487. var commentEnd = html.indexOf('-->');
  2488. if (commentEnd >= 0) {
  2489. advance(commentEnd + 3);
  2490. continue;
  2491. }
  2492. }
  2493. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  2494. if (/^<!\[/.test(html)) {
  2495. var conditionalEnd = html.indexOf(']>');
  2496. if (conditionalEnd >= 0) {
  2497. advance(conditionalEnd + 2);
  2498. continue;
  2499. }
  2500. }
  2501. // Doctype:
  2502. var doctypeMatch = html.match(doctype);
  2503. if (doctypeMatch) {
  2504. advance(doctypeMatch[0].length);
  2505. continue;
  2506. }
  2507. // End tag:
  2508. var endTagMatch = html.match(endTag);
  2509. if (endTagMatch) {
  2510. var curIndex = index;
  2511. advance(endTagMatch[0].length);
  2512. parseEndTag(endTagMatch[0], endTagMatch[1], curIndex, index);
  2513. continue;
  2514. }
  2515. // Start tag:
  2516. var startTagMatch = parseStartTag();
  2517. if (startTagMatch) {
  2518. handleStartTag(startTagMatch);
  2519. continue;
  2520. }
  2521. }
  2522. var text = void 0;
  2523. if (textEnd >= 0) {
  2524. text = html.substring(0, textEnd);
  2525. advance(textEnd);
  2526. } else {
  2527. text = html;
  2528. html = '';
  2529. }
  2530. if (options.chars) {
  2531. options.chars(text);
  2532. }
  2533. } else {
  2534. (function () {
  2535. var stackedTag = lastTag.toLowerCase();
  2536. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  2537. var endTagLength = 0;
  2538. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  2539. endTagLength = endTag.length;
  2540. if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
  2541. text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
  2542. }
  2543. if (options.chars) {
  2544. options.chars(text);
  2545. }
  2546. return '';
  2547. });
  2548. index += html.length - rest.length;
  2549. html = rest;
  2550. parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
  2551. })();
  2552. }
  2553. if (html === last) {
  2554. throw new Error('Error parsing template:\n\n' + html);
  2555. }
  2556. }
  2557. // Clean up any remaining tags
  2558. parseEndTag();
  2559. function advance(n) {
  2560. index += n;
  2561. html = html.substring(n);
  2562. }
  2563. function parseStartTag() {
  2564. var start = html.match(startTagOpen);
  2565. if (start) {
  2566. var match = {
  2567. tagName: start[1],
  2568. attrs: [],
  2569. start: index
  2570. };
  2571. advance(start[0].length);
  2572. var end = void 0,
  2573. attr = void 0;
  2574. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  2575. advance(attr[0].length);
  2576. match.attrs.push(attr);
  2577. }
  2578. if (end) {
  2579. match.unarySlash = end[1];
  2580. advance(end[0].length);
  2581. match.end = index;
  2582. return match;
  2583. }
  2584. }
  2585. }
  2586. function handleStartTag(match) {
  2587. var tagName = match.tagName;
  2588. var unarySlash = match.unarySlash;
  2589. if (expectHTML) {
  2590. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  2591. parseEndTag('', lastTag);
  2592. }
  2593. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  2594. parseEndTag('', tagName);
  2595. }
  2596. }
  2597. var unary = isUnaryTag(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  2598. var l = match.attrs.length;
  2599. var attrs = new Array(l);
  2600. for (var i = 0; i < l; i++) {
  2601. var args = match.attrs[i];
  2602. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  2603. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  2604. if (args[3] === '') {
  2605. delete args[3];
  2606. }
  2607. if (args[4] === '') {
  2608. delete args[4];
  2609. }
  2610. if (args[5] === '') {
  2611. delete args[5];
  2612. }
  2613. }
  2614. var value = args[3] || args[4] || args[5] || '';
  2615. attrs[i] = {
  2616. name: args[1],
  2617. value: isFromDOM ? decodeAttr(value, shouldDecodeTags) : value
  2618. };
  2619. }
  2620. if (!unary) {
  2621. stack.push({ tag: tagName, attrs: attrs });
  2622. lastTag = tagName;
  2623. unarySlash = '';
  2624. }
  2625. if (options.start) {
  2626. options.start(tagName, attrs, unary, match.start, match.end);
  2627. }
  2628. }
  2629. function parseEndTag(tag, tagName, start, end) {
  2630. var pos = void 0;
  2631. if (start == null) start = index;
  2632. if (end == null) end = index;
  2633. // Find the closest opened tag of the same type
  2634. if (tagName) {
  2635. var needle = tagName.toLowerCase();
  2636. for (pos = stack.length - 1; pos >= 0; pos--) {
  2637. if (stack[pos].tag.toLowerCase() === needle) {
  2638. break;
  2639. }
  2640. }
  2641. } else {
  2642. // If no tag name is provided, clean shop
  2643. pos = 0;
  2644. }
  2645. if (pos >= 0) {
  2646. // Close all the open elements, up the stack
  2647. for (var i = stack.length - 1; i >= pos; i--) {
  2648. if (options.end) {
  2649. options.end(stack[i].tag, start, end);
  2650. }
  2651. }
  2652. // Remove the open elements from the stack
  2653. stack.length = pos;
  2654. lastTag = pos && stack[pos - 1].tag;
  2655. } else if (tagName.toLowerCase() === 'br') {
  2656. if (options.start) {
  2657. options.start(tagName, [], true, start, end);
  2658. }
  2659. } else if (tagName.toLowerCase() === 'p') {
  2660. if (options.start) {
  2661. options.start(tagName, [], false, start, end);
  2662. }
  2663. if (options.end) {
  2664. options.end(tagName, start, end);
  2665. }
  2666. }
  2667. }
  2668. }
  2669. function parseFilters(exp) {
  2670. var inSingle = false;
  2671. var inDouble = false;
  2672. var curly = 0;
  2673. var square = 0;
  2674. var paren = 0;
  2675. var lastFilterIndex = 0;
  2676. var c = void 0,
  2677. prev = void 0,
  2678. i = void 0,
  2679. expression = void 0,
  2680. filters = void 0;
  2681. for (i = 0; i < exp.length; i++) {
  2682. prev = c;
  2683. c = exp.charCodeAt(i);
  2684. if (inSingle) {
  2685. // check single quote
  2686. if (c === 0x27 && prev !== 0x5C) inSingle = !inSingle;
  2687. } else if (inDouble) {
  2688. // check double quote
  2689. if (c === 0x22 && prev !== 0x5C) inDouble = !inDouble;
  2690. } else if (c === 0x7C && // pipe
  2691. exp.charCodeAt(i + 1) !== 0x7C && exp.charCodeAt(i - 1) !== 0x7C && !curly && !square && !paren) {
  2692. if (expression === undefined) {
  2693. // first filter, end of expression
  2694. lastFilterIndex = i + 1;
  2695. expression = exp.slice(0, i).trim();
  2696. } else {
  2697. pushFilter();
  2698. }
  2699. } else {
  2700. switch (c) {
  2701. case 0x22:
  2702. inDouble = true;break; // "
  2703. case 0x27:
  2704. inSingle = true;break; // '
  2705. case 0x28:
  2706. paren++;break; // (
  2707. case 0x29:
  2708. paren--;break; // )
  2709. case 0x5B:
  2710. square++;break; // [
  2711. case 0x5D:
  2712. square--;break; // ]
  2713. case 0x7B:
  2714. curly++;break; // {
  2715. case 0x7D:
  2716. curly--;break; // }
  2717. }
  2718. }
  2719. }
  2720. if (expression === undefined) {
  2721. expression = exp.slice(0, i).trim();
  2722. } else if (lastFilterIndex !== 0) {
  2723. pushFilter();
  2724. }
  2725. function pushFilter() {
  2726. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  2727. lastFilterIndex = i + 1;
  2728. }
  2729. if (filters) {
  2730. for (i = 0; i < filters.length; i++) {
  2731. expression = wrapFilter(expression, filters[i]);
  2732. }
  2733. }
  2734. return expression;
  2735. }
  2736. function wrapFilter(exp, filter) {
  2737. var i = filter.indexOf('(');
  2738. if (i < 0) {
  2739. // _f: resolveFilter
  2740. return '_f("' + filter + '")(' + exp + ')';
  2741. } else {
  2742. var name = filter.slice(0, i);
  2743. var args = filter.slice(i + 1);
  2744. return '_f("' + name + '")(' + exp + ',' + args;
  2745. }
  2746. }
  2747. var defaultTagRE = /\{\{((?:.|\\n)+?)\}\}/g;
  2748. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  2749. var buildRegex = cached(function (delimiters) {
  2750. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  2751. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  2752. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  2753. });
  2754. function parseText(text, delimiters) {
  2755. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  2756. if (!tagRE.test(text)) {
  2757. return;
  2758. }
  2759. var tokens = [];
  2760. var lastIndex = tagRE.lastIndex = 0;
  2761. var match = void 0,
  2762. index = void 0;
  2763. while (match = tagRE.exec(text)) {
  2764. index = match.index;
  2765. // push text token
  2766. if (index > lastIndex) {
  2767. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  2768. }
  2769. // tag token
  2770. var exp = parseFilters(match[1].trim());
  2771. tokens.push('_s(' + exp + ')');
  2772. lastIndex = index + match[0].length;
  2773. }
  2774. if (lastIndex < text.length) {
  2775. tokens.push(JSON.stringify(text.slice(lastIndex)));
  2776. }
  2777. return tokens.join('+');
  2778. }
  2779. function baseWarn(msg) {
  2780. console.error('[Vue parser]: ' + msg);
  2781. }
  2782. function pluckModuleFunction(modules, key) {
  2783. return modules ? modules.map(function (m) {
  2784. return m[key];
  2785. }).filter(function (_) {
  2786. return _;
  2787. }) : [];
  2788. }
  2789. function addProp(el, name, value) {
  2790. (el.props || (el.props = [])).push({ name: name, value: value });
  2791. }
  2792. function addAttr(el, name, value) {
  2793. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  2794. }
  2795. function addDirective(el, name, value, arg, modifiers) {
  2796. (el.directives || (el.directives = [])).push({ name: name, value: value, arg: arg, modifiers: modifiers });
  2797. }
  2798. function addHook(el, name, code) {
  2799. var hooks = el.hooks || (el.hooks = {});
  2800. var hook = hooks[name];
  2801. /* istanbul ignore if */
  2802. if (hook) {
  2803. hook.push(code);
  2804. } else {
  2805. hooks[name] = [code];
  2806. }
  2807. }
  2808. function addHandler(el, name, value, modifiers) {
  2809. // check capture modifier
  2810. if (modifiers && modifiers.capture) {
  2811. delete modifiers.capture;
  2812. name = '!' + name; // mark the event as captured
  2813. }
  2814. var events = void 0;
  2815. if (modifiers && modifiers.native) {
  2816. delete modifiers.native;
  2817. events = el.nativeEvents || (el.nativeEvents = {});
  2818. } else {
  2819. events = el.events || (el.events = {});
  2820. }
  2821. var newHandler = { value: value, modifiers: modifiers };
  2822. var handlers = events[name];
  2823. /* istanbul ignore if */
  2824. if (Array.isArray(handlers)) {
  2825. handlers.push(newHandler);
  2826. } else if (handlers) {
  2827. events[name] = [handlers, newHandler];
  2828. } else {
  2829. events[name] = newHandler;
  2830. }
  2831. }
  2832. function getBindingAttr(el, name, getStatic) {
  2833. var dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  2834. if (dynamicValue != null) {
  2835. return dynamicValue;
  2836. } else if (getStatic !== false) {
  2837. var staticValue = getAndRemoveAttr(el, name);
  2838. if (staticValue != null) {
  2839. return JSON.stringify(staticValue);
  2840. }
  2841. }
  2842. }
  2843. function getAndRemoveAttr(el, name) {
  2844. var val = void 0;
  2845. if ((val = el.attrsMap[name]) != null) {
  2846. var list = el.attrsList;
  2847. for (var i = 0, l = list.length; i < l; i++) {
  2848. if (list[i].name === name) {
  2849. list.splice(i, 1);
  2850. break;
  2851. }
  2852. }
  2853. }
  2854. return val;
  2855. }
  2856. var dirRE = /^v-|^@|^:/;
  2857. var forAliasRE = /(.*)\s+(?:in|of)\s+(.*)/;
  2858. var forIteratorRE = /\(([^,]*),([^,]*)(?:,([^,]*))?\)/;
  2859. var bindRE = /^:|^v-bind:/;
  2860. var onRE = /^@|^v-on:/;
  2861. var argRE = /:(.*)$/;
  2862. var modifierRE = /\.[^\.]+/g;
  2863. var decodeHTMLCached = cached(entities.decodeHTML);
  2864. // configurable state
  2865. var warn$1 = void 0;
  2866. var platformGetTagNamespace = void 0;
  2867. var platformMustUseProp = void 0;
  2868. var platformIsPreTag = void 0;
  2869. var preTransforms = void 0;
  2870. var transforms = void 0;
  2871. var postTransforms = void 0;
  2872. var delimiters = void 0;
  2873. /**
  2874. * Convert HTML string to AST.
  2875. */
  2876. function parse(template, options) {
  2877. warn$1 = options.warn || baseWarn;
  2878. platformGetTagNamespace = options.getTagNamespace || no;
  2879. platformMustUseProp = options.mustUseProp || no;
  2880. platformIsPreTag = options.isPreTag || no;
  2881. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  2882. transforms = pluckModuleFunction(options.modules, 'transformNode');
  2883. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  2884. delimiters = options.delimiters;
  2885. var stack = [];
  2886. var preserveWhitespace = options.preserveWhitespace !== false;
  2887. var root = void 0;
  2888. var currentParent = void 0;
  2889. var inVPre = false;
  2890. var inPre = false;
  2891. var warned = false;
  2892. parseHTML(template, {
  2893. expectHTML: options.expectHTML,
  2894. isUnaryTag: options.isUnaryTag,
  2895. isFromDOM: options.isFromDOM,
  2896. shouldDecodeTags: options.shouldDecodeTags,
  2897. start: function start(tag, attrs, unary) {
  2898. // check namespace.
  2899. // inherit parent ns if there is one
  2900. var ns = currentParent && currentParent.ns || platformGetTagNamespace(tag);
  2901. // handle IE svg bug
  2902. /* istanbul ignore if */
  2903. if (options.isIE && ns === 'svg') {
  2904. attrs = guardIESVGBug(attrs);
  2905. }
  2906. var element = {
  2907. type: 1,
  2908. tag: tag,
  2909. attrsList: attrs,
  2910. attrsMap: makeAttrsMap(attrs),
  2911. parent: currentParent,
  2912. children: []
  2913. };
  2914. if (ns) {
  2915. element.ns = ns;
  2916. }
  2917. if (isForbiddenTag(element)) {
  2918. element.forbidden = true;
  2919. process.env.NODE_ENV !== 'production' && warn$1('Templates should only be responsbile for mapping the state to the ' + 'UI. Avoid placing tags with side-effects in your templates, such as ' + ('<' + tag + '>.'));
  2920. }
  2921. // apply pre-transforms
  2922. for (var i = 0; i < preTransforms.length; i++) {
  2923. preTransforms[i](element, options);
  2924. }
  2925. if (!inVPre) {
  2926. processPre(element);
  2927. if (element.pre) {
  2928. inVPre = true;
  2929. }
  2930. }
  2931. if (platformIsPreTag(element.tag)) {
  2932. inPre = true;
  2933. }
  2934. if (inVPre) {
  2935. processRawAttrs(element);
  2936. } else {
  2937. processFor(element);
  2938. processIf(element);
  2939. processOnce(element);
  2940. // determine whether this is a plain element after
  2941. // removing structural attributes
  2942. element.plain = !element.key && !attrs.length;
  2943. processKey(element);
  2944. processRef(element);
  2945. processSlot(element);
  2946. processComponent(element);
  2947. for (var _i = 0; _i < transforms.length; _i++) {
  2948. transforms[_i](element, options);
  2949. }
  2950. processAttrs(element);
  2951. }
  2952. function checkRootConstraints(el) {
  2953. if (process.env.NODE_ENV !== 'production') {
  2954. if (el.tag === 'slot' || el.tag === 'template') {
  2955. warn$1('Cannot use <' + el.tag + '> as component root element because it may ' + 'contain multiple nodes:\n' + template);
  2956. }
  2957. if (el.attrsMap.hasOwnProperty('v-for')) {
  2958. warn$1('Cannot use v-for on stateful component root element because ' + 'it renders multiple elements:\n' + template);
  2959. }
  2960. }
  2961. }
  2962. // tree management
  2963. if (!root) {
  2964. root = element;
  2965. checkRootConstraints(root);
  2966. } else if (process.env.NODE_ENV !== 'production' && !stack.length && !warned) {
  2967. // allow 2 root elements with v-if and v-else
  2968. if (root.attrsMap.hasOwnProperty('v-if') && element.attrsMap.hasOwnProperty('v-else')) {
  2969. checkRootConstraints(element);
  2970. } else {
  2971. warned = true;
  2972. warn$1('Component template should contain exactly one root element:\n\n' + template);
  2973. }
  2974. }
  2975. if (currentParent && !element.forbidden) {
  2976. if (element.else) {
  2977. processElse(element, currentParent);
  2978. } else {
  2979. currentParent.children.push(element);
  2980. element.parent = currentParent;
  2981. }
  2982. }
  2983. if (!unary) {
  2984. currentParent = element;
  2985. stack.push(element);
  2986. }
  2987. // apply post-transforms
  2988. for (var _i2 = 0; _i2 < postTransforms.length; _i2++) {
  2989. postTransforms[_i2](element, options);
  2990. }
  2991. },
  2992. end: function end() {
  2993. // remove trailing whitespace
  2994. var element = stack[stack.length - 1];
  2995. var lastNode = element.children[element.children.length - 1];
  2996. if (lastNode && lastNode.type === 3 && lastNode.text === ' ') {
  2997. element.children.pop();
  2998. }
  2999. // pop stack
  3000. stack.length -= 1;
  3001. currentParent = stack[stack.length - 1];
  3002. // check pre state
  3003. if (element.pre) {
  3004. inVPre = false;
  3005. }
  3006. if (platformIsPreTag(element.tag)) {
  3007. inPre = false;
  3008. }
  3009. },
  3010. chars: function chars(text) {
  3011. if (!currentParent) {
  3012. if (process.env.NODE_ENV !== 'production' && !warned) {
  3013. warned = true;
  3014. warn$1('Component template should contain exactly one root element:\n\n' + template);
  3015. }
  3016. return;
  3017. }
  3018. text = inPre || text.trim() ? decodeHTMLCached(text)
  3019. // only preserve whitespace if its not right after a starting tag
  3020. : preserveWhitespace && currentParent.children.length ? ' ' : '';
  3021. if (text) {
  3022. var expression = void 0;
  3023. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  3024. currentParent.children.push({
  3025. type: 2,
  3026. expression: expression,
  3027. text: text
  3028. });
  3029. } else {
  3030. currentParent.children.push({
  3031. type: 3,
  3032. text: text
  3033. });
  3034. }
  3035. }
  3036. }
  3037. });
  3038. return root;
  3039. }
  3040. function processPre(el) {
  3041. if (getAndRemoveAttr(el, 'v-pre') != null) {
  3042. el.pre = true;
  3043. }
  3044. }
  3045. function processRawAttrs(el) {
  3046. var l = el.attrsList.length;
  3047. if (l) {
  3048. var attrs = el.attrs = new Array(l);
  3049. for (var i = 0; i < l; i++) {
  3050. attrs[i] = {
  3051. name: el.attrsList[i].name,
  3052. value: JSON.stringify(el.attrsList[i].value)
  3053. };
  3054. }
  3055. } else if (!el.pre) {
  3056. // non root node in pre blocks with no attributes
  3057. el.plain = true;
  3058. }
  3059. }
  3060. function processKey(el) {
  3061. var exp = getBindingAttr(el, 'key');
  3062. if (exp) {
  3063. el.key = exp;
  3064. }
  3065. }
  3066. function processRef(el) {
  3067. var ref = getBindingAttr(el, 'ref');
  3068. if (ref) {
  3069. el.ref = ref;
  3070. var parent = el;
  3071. while (parent) {
  3072. if (parent.for !== undefined) {
  3073. el.refInFor = true;
  3074. break;
  3075. }
  3076. parent = parent.parent;
  3077. }
  3078. }
  3079. }
  3080. function processFor(el) {
  3081. var exp = void 0;
  3082. if (exp = getAndRemoveAttr(el, 'v-for')) {
  3083. var inMatch = exp.match(forAliasRE);
  3084. if (!inMatch) {
  3085. process.env.NODE_ENV !== 'production' && warn$1('Invalid v-for expression: ' + exp);
  3086. return;
  3087. }
  3088. el.for = inMatch[2].trim();
  3089. var alias = inMatch[1].trim();
  3090. var iteratorMatch = alias.match(forIteratorRE);
  3091. if (iteratorMatch) {
  3092. el.alias = iteratorMatch[1].trim();
  3093. el.iterator1 = iteratorMatch[2].trim();
  3094. if (iteratorMatch[3]) {
  3095. el.iterator2 = iteratorMatch[3].trim();
  3096. }
  3097. } else {
  3098. el.alias = alias;
  3099. }
  3100. }
  3101. }
  3102. function processIf(el) {
  3103. var exp = getAndRemoveAttr(el, 'v-if');
  3104. if (exp) {
  3105. el.if = exp;
  3106. }
  3107. if (getAndRemoveAttr(el, 'v-else') != null) {
  3108. el.else = true;
  3109. }
  3110. }
  3111. function processElse(el, parent) {
  3112. var prev = findPrevElement(parent.children);
  3113. if (prev && prev.if) {
  3114. prev.elseBlock = el;
  3115. } else if (process.env.NODE_ENV !== 'production') {
  3116. warn$1('v-else used on element <' + el.tag + '> without corresponding v-if.');
  3117. }
  3118. }
  3119. function processOnce(el) {
  3120. var once = getAndRemoveAttr(el, 'v-once');
  3121. if (once != null) {
  3122. el.once = true;
  3123. }
  3124. }
  3125. function processSlot(el) {
  3126. if (el.tag === 'slot') {
  3127. el.slotName = getBindingAttr(el, 'name');
  3128. } else {
  3129. var slotTarget = getBindingAttr(el, 'slot');
  3130. if (slotTarget) {
  3131. el.slotTarget = slotTarget;
  3132. }
  3133. }
  3134. }
  3135. function processComponent(el) {
  3136. var binding = void 0;
  3137. if (binding = getBindingAttr(el, 'is')) {
  3138. el.component = binding;
  3139. }
  3140. if (getAndRemoveAttr(el, 'inline-template') != null) {
  3141. el.inlineTemplate = true;
  3142. }
  3143. }
  3144. function processAttrs(el) {
  3145. var list = el.attrsList;
  3146. var i = void 0,
  3147. l = void 0,
  3148. name = void 0,
  3149. value = void 0,
  3150. arg = void 0,
  3151. modifiers = void 0,
  3152. isProp = void 0;
  3153. for (i = 0, l = list.length; i < l; i++) {
  3154. name = list[i].name;
  3155. value = list[i].value;
  3156. if (dirRE.test(name)) {
  3157. // mark element as dynamic
  3158. el.hasBindings = true;
  3159. // modifiers
  3160. modifiers = parseModifiers(name);
  3161. if (modifiers) {
  3162. name = name.replace(modifierRE, '');
  3163. }
  3164. if (bindRE.test(name)) {
  3165. // v-bind
  3166. name = name.replace(bindRE, '');
  3167. if (modifiers && modifiers.prop) {
  3168. isProp = true;
  3169. name = camelize(name);
  3170. if (name === 'innerHtml') name = 'innerHTML';
  3171. }
  3172. if (isProp || platformMustUseProp(name)) {
  3173. addProp(el, name, value);
  3174. } else {
  3175. addAttr(el, name, value);
  3176. }
  3177. } else if (onRE.test(name)) {
  3178. // v-on
  3179. name = name.replace(onRE, '');
  3180. addHandler(el, name, value, modifiers);
  3181. } else {
  3182. // normal directives
  3183. name = name.replace(dirRE, '');
  3184. // parse arg
  3185. var argMatch = name.match(argRE);
  3186. if (argMatch && (arg = argMatch[1])) {
  3187. name = name.slice(0, -(arg.length + 1));
  3188. }
  3189. addDirective(el, name, value, arg, modifiers);
  3190. }
  3191. } else {
  3192. // literal attribute
  3193. if (process.env.NODE_ENV !== 'production') {
  3194. var expression = parseText(value, delimiters);
  3195. if (expression) {
  3196. warn$1(name + '="' + value + '": ' + 'Interpolation inside attributes has been deprecated. ' + 'Use v-bind or the colon shorthand instead.');
  3197. }
  3198. }
  3199. addAttr(el, name, JSON.stringify(value));
  3200. }
  3201. }
  3202. }
  3203. function parseModifiers(name) {
  3204. var match = name.match(modifierRE);
  3205. if (match) {
  3206. var _ret = function () {
  3207. var ret = {};
  3208. match.forEach(function (m) {
  3209. ret[m.slice(1)] = true;
  3210. });
  3211. return {
  3212. v: ret
  3213. };
  3214. }();
  3215. if (typeof _ret === "object") return _ret.v;
  3216. }
  3217. }
  3218. function makeAttrsMap(attrs) {
  3219. var map = {};
  3220. for (var i = 0, l = attrs.length; i < l; i++) {
  3221. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name]) {
  3222. warn$1('duplicate attribute: ' + attrs[i].name);
  3223. }
  3224. map[attrs[i].name] = attrs[i].value;
  3225. }
  3226. return map;
  3227. }
  3228. function findPrevElement(children) {
  3229. var i = children.length;
  3230. while (i--) {
  3231. if (children[i].tag) return children[i];
  3232. }
  3233. }
  3234. function isForbiddenTag(el) {
  3235. return el.tag === 'style' || el.tag === 'script' && (!el.attrsMap.type || el.attrsMap.type === 'text/javascript');
  3236. }
  3237. var ieNSBug = /^xmlns:NS\d+/;
  3238. var ieNSPrefix = /^NS\d+:/;
  3239. /* istanbul ignore next */
  3240. function guardIESVGBug(attrs) {
  3241. var res = [];
  3242. for (var i = 0; i < attrs.length; i++) {
  3243. var attr = attrs[i];
  3244. if (!ieNSBug.test(attr.name)) {
  3245. attr.name = attr.name.replace(ieNSPrefix, '');
  3246. res.push(attr);
  3247. }
  3248. }
  3249. return res;
  3250. }
  3251. var isStaticKey = void 0;
  3252. var isPlatformReservedTag = void 0;
  3253. var genStaticKeysCached = cached(genStaticKeys$1);
  3254. /**
  3255. * Goal of the optimizier: walk the generated template AST tree
  3256. * and detect sub-trees that are purely static, i.e. parts of
  3257. * the DOM that never needs to change.
  3258. *
  3259. * Once we detect these sub-trees, we can:
  3260. *
  3261. * 1. Hoist them into constants, so that we no longer need to
  3262. * create fresh nodes for them on each re-render;
  3263. * 2. Completely skip them in the patching process.
  3264. */
  3265. function optimize(root, options) {
  3266. if (!root) return;
  3267. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  3268. isPlatformReservedTag = options.isReservedTag || function () {
  3269. return false;
  3270. };
  3271. // first pass: mark all non-static nodes.
  3272. markStatic(root);
  3273. // second pass: mark static roots.
  3274. markStaticRoots(root, false);
  3275. }
  3276. function genStaticKeys$1(keys) {
  3277. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs' + (keys ? ',' + keys : ''));
  3278. }
  3279. function markStatic(node) {
  3280. node.static = isStatic(node);
  3281. if (node.type === 1) {
  3282. for (var i = 0, l = node.children.length; i < l; i++) {
  3283. var child = node.children[i];
  3284. markStatic(child);
  3285. if (!child.static) {
  3286. node.static = false;
  3287. }
  3288. }
  3289. }
  3290. }
  3291. function markStaticRoots(node, isInFor) {
  3292. if (node.type === 1) {
  3293. if (node.once || node.static) {
  3294. node.staticRoot = true;
  3295. node.staticInFor = isInFor;
  3296. return;
  3297. }
  3298. if (node.children) {
  3299. for (var i = 0, l = node.children.length; i < l; i++) {
  3300. markStaticRoots(node.children[i], !!node.for);
  3301. }
  3302. }
  3303. }
  3304. }
  3305. function isStatic(node) {
  3306. if (node.type === 2) {
  3307. // expression
  3308. return false;
  3309. }
  3310. if (node.type === 3) {
  3311. // text
  3312. return true;
  3313. }
  3314. return !!(node.pre || !node.hasBindings && // no dynamic bindings
  3315. !node.if && !node.for && // not v-if or v-for or v-else
  3316. !isBuiltInTag(node.tag) && // not a built-in
  3317. isPlatformReservedTag(node.tag) && // not a component
  3318. Object.keys(node).every(isStaticKey));
  3319. }
  3320. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/;
  3321. // keyCode aliases
  3322. var keyCodes = {
  3323. esc: 27,
  3324. tab: 9,
  3325. enter: 13,
  3326. space: 32,
  3327. up: 38,
  3328. left: 37,
  3329. right: 39,
  3330. down: 40,
  3331. 'delete': [8, 46]
  3332. };
  3333. var modifierCode = {
  3334. stop: '$event.stopPropagation();',
  3335. prevent: '$event.preventDefault();',
  3336. self: 'if($event.target !== $event.currentTarget)return;'
  3337. };
  3338. function genHandlers(events, native) {
  3339. var res = native ? 'nativeOn:{' : 'on:{';
  3340. for (var name in events) {
  3341. res += '"' + name + '":' + genHandler(events[name]) + ',';
  3342. }
  3343. return res.slice(0, -1) + '}';
  3344. }
  3345. function genHandler(handler) {
  3346. if (!handler) {
  3347. return 'function(){}';
  3348. } else if (Array.isArray(handler)) {
  3349. return '[' + handler.map(genHandler).join(',') + ']';
  3350. } else if (!handler.modifiers) {
  3351. return simplePathRE.test(handler.value) ? handler.value : 'function($event){' + handler.value + '}';
  3352. } else {
  3353. var code = 'function($event){';
  3354. for (var key in handler.modifiers) {
  3355. code += modifierCode[key] || genKeyFilter(key);
  3356. }
  3357. var handlerCode = simplePathRE.test(handler.value) ? handler.value + '($event)' : handler.value;
  3358. return code + handlerCode + '}';
  3359. }
  3360. }
  3361. function genKeyFilter(key) {
  3362. var code = parseInt(key, 10) || // number keyCode
  3363. keyCodes[key] || // built-in alias
  3364. '_k(' + JSON.stringify(key) + ')'; // custom alias
  3365. if (Array.isArray(code)) {
  3366. return 'if(' + code.map(function (c) {
  3367. return '$event.keyCode!==' + c;
  3368. }).join('&&') + ')return;';
  3369. } else {
  3370. return 'if($event.keyCode!==' + code + ')return;';
  3371. }
  3372. }
  3373. function bind$1(el, dir) {
  3374. addHook(el, 'construct', '_b(n1,' + dir.value + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ')');
  3375. }
  3376. var baseDirectives = {
  3377. bind: bind$1,
  3378. cloak: noop
  3379. };
  3380. // configurable state
  3381. var warn$2 = void 0;
  3382. var transforms$1 = void 0;
  3383. var dataGenFns = void 0;
  3384. var platformDirectives = void 0;
  3385. var staticRenderFns = void 0;
  3386. var currentOptions = void 0;
  3387. function generate(ast, options) {
  3388. // save previous staticRenderFns so generate calls can be nested
  3389. var prevStaticRenderFns = staticRenderFns;
  3390. var currentStaticRenderFns = staticRenderFns = [];
  3391. currentOptions = options;
  3392. warn$2 = options.warn || baseWarn;
  3393. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  3394. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  3395. platformDirectives = options.directives || {};
  3396. var code = ast ? genElement(ast) : '_h("div")';
  3397. staticRenderFns = prevStaticRenderFns;
  3398. return {
  3399. render: 'with(this){return ' + code + '}',
  3400. staticRenderFns: currentStaticRenderFns
  3401. };
  3402. }
  3403. function genElement(el) {
  3404. if (el.staticRoot && !el.staticProcessed) {
  3405. // hoist static sub-trees out
  3406. el.staticProcessed = true;
  3407. staticRenderFns.push('with(this){return ' + genElement(el) + '}');
  3408. return '_m(' + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ')';
  3409. } else if (el.for && !el.forProcessed) {
  3410. return genFor(el);
  3411. } else if (el.if && !el.ifProcessed) {
  3412. return genIf(el);
  3413. } else if (el.tag === 'template' && !el.slotTarget) {
  3414. return genChildren(el) || 'void 0';
  3415. } else if (el.tag === 'slot') {
  3416. return genSlot(el);
  3417. } else {
  3418. // component or element
  3419. var code = void 0;
  3420. if (el.component) {
  3421. code = genComponent(el);
  3422. } else {
  3423. var data = genData(el);
  3424. var children = el.inlineTemplate ? null : genChildren(el);
  3425. code = '_h(\'' + el.tag + '\'' + (data ? ',' + data : '' // data
  3426. ) + (children ? ',' + children : '' // children
  3427. ) + ')';
  3428. }
  3429. // module transforms
  3430. for (var i = 0; i < transforms$1.length; i++) {
  3431. code = transforms$1[i](el, code);
  3432. }
  3433. return code;
  3434. }
  3435. }
  3436. function genIf(el) {
  3437. var exp = el.if;
  3438. el.ifProcessed = true; // avoid recursion
  3439. return '(' + exp + ')?' + genElement(el) + ':' + genElse(el);
  3440. }
  3441. function genElse(el) {
  3442. return el.elseBlock ? genElement(el.elseBlock) : 'void 0';
  3443. }
  3444. function genFor(el) {
  3445. var exp = el.for;
  3446. var alias = el.alias;
  3447. var iterator1 = el.iterator1 ? ',' + el.iterator1 : '';
  3448. var iterator2 = el.iterator2 ? ',' + el.iterator2 : '';
  3449. el.forProcessed = true; // avoid recursion
  3450. return '(' + exp + ')&&_l((' + exp + '),' + ('function(' + alias + iterator1 + iterator2 + '){') + ('return ' + genElement(el)) + '})';
  3451. }
  3452. function genData(el) {
  3453. if (el.plain) {
  3454. return;
  3455. }
  3456. var data = '{';
  3457. // directives first.
  3458. // directives may mutate the el's other properties before they are generated.
  3459. var dirs = genDirectives(el);
  3460. if (dirs) data += dirs + ',';
  3461. // key
  3462. if (el.key) {
  3463. data += 'key:' + el.key + ',';
  3464. }
  3465. // ref
  3466. if (el.ref) {
  3467. data += 'ref:' + el.ref + ',';
  3468. }
  3469. if (el.refInFor) {
  3470. data += 'refInFor:true,';
  3471. }
  3472. // record original tag name for components using "is" attribute
  3473. if (el.component) {
  3474. data += 'tag:"' + el.tag + '",';
  3475. }
  3476. // slot target
  3477. if (el.slotTarget) {
  3478. data += 'slot:' + el.slotTarget + ',';
  3479. }
  3480. // module data generation functions
  3481. for (var i = 0; i < dataGenFns.length; i++) {
  3482. data += dataGenFns[i](el);
  3483. }
  3484. // v-show, used to avoid transition being applied
  3485. // since v-show takes it over
  3486. if (el.attrsMap['v-show']) {
  3487. data += 'show:true,';
  3488. }
  3489. // attributes
  3490. if (el.attrs) {
  3491. data += 'attrs:{' + genProps(el.attrs) + '},';
  3492. }
  3493. // DOM props
  3494. if (el.props) {
  3495. data += 'domProps:{' + genProps(el.props) + '},';
  3496. }
  3497. // hooks
  3498. if (el.hooks) {
  3499. data += 'hook:{' + genHooks(el.hooks) + '},';
  3500. }
  3501. // event handlers
  3502. if (el.events) {
  3503. data += genHandlers(el.events) + ',';
  3504. }
  3505. if (el.nativeEvents) {
  3506. data += '' + genHandlers(el.nativeEvents, true);
  3507. }
  3508. // inline-template
  3509. if (el.inlineTemplate) {
  3510. var ast = el.children[0];
  3511. if (process.env.NODE_ENV !== 'production' && (el.children.length > 1 || ast.type !== 1)) {
  3512. warn$2('Inline-template components must have exactly one child element.');
  3513. }
  3514. if (ast.type === 1) {
  3515. var inlineRenderFns = generate(ast, currentOptions);
  3516. data += 'inlineTemplate:{render:function(){' + inlineRenderFns.render + '},staticRenderFns:[' + inlineRenderFns.staticRenderFns.map(function (code) {
  3517. return 'function(){' + code + '}';
  3518. }).join(',') + ']}';
  3519. }
  3520. }
  3521. return data.replace(/,$/, '') + '}';
  3522. }
  3523. function genDirectives(el) {
  3524. var dirs = el.directives;
  3525. if (!dirs) return;
  3526. var res = 'directives:[';
  3527. var hasRuntime = false;
  3528. var i = void 0,
  3529. l = void 0,
  3530. dir = void 0,
  3531. needRuntime = void 0;
  3532. for (i = 0, l = dirs.length; i < l; i++) {
  3533. dir = dirs[i];
  3534. needRuntime = true;
  3535. var gen = platformDirectives[dir.name] || baseDirectives[dir.name];
  3536. if (gen) {
  3537. // compile-time directive that manipulates AST.
  3538. // returns true if it also needs a runtime counterpart.
  3539. needRuntime = !!gen(el, dir, warn$2);
  3540. }
  3541. if (needRuntime) {
  3542. hasRuntime = true;
  3543. res += '{name:"' + dir.name + '"' + (dir.value ? ',value:(' + dir.value + '),expression:' + JSON.stringify(dir.value) : '') + (dir.arg ? ',arg:"' + dir.arg + '"' : '') + (dir.modifiers ? ',modifiers:' + JSON.stringify(dir.modifiers) : '') + '},';
  3544. }
  3545. }
  3546. if (hasRuntime) {
  3547. return res.slice(0, -1) + ']';
  3548. }
  3549. }
  3550. function genChildren(el) {
  3551. if (el.children.length) {
  3552. return '[' + el.children.map(genNode).join(',') + ']';
  3553. }
  3554. }
  3555. function genNode(node) {
  3556. if (node.type === 1) {
  3557. return genElement(node);
  3558. } else {
  3559. return genText(node);
  3560. }
  3561. }
  3562. function genText(text) {
  3563. return text.type === 2 ? text.expression // no need for () because already wrapped in _s()
  3564. : JSON.stringify(text.text);
  3565. }
  3566. function genSlot(el) {
  3567. var slot = '$slots[' + (el.slotName || '"default"') + ']';
  3568. var children = genChildren(el);
  3569. return children ? '(' + slot + '||' + children + ')' : slot;
  3570. }
  3571. function genComponent(el) {
  3572. var children = genChildren(el);
  3573. return '_h(' + el.component + ',' + genData(el) + (children ? ',' + children : '') + ')';
  3574. }
  3575. function genProps(props) {
  3576. var res = '';
  3577. for (var i = 0; i < props.length; i++) {
  3578. var prop = props[i];
  3579. res += '"' + prop.name + '":' + prop.value + ',';
  3580. }
  3581. return res.slice(0, -1);
  3582. }
  3583. function genHooks(hooks) {
  3584. var res = '';
  3585. for (var _key in hooks) {
  3586. res += '"' + _key + '":function(n1,n2){' + hooks[_key].join(';') + '},';
  3587. }
  3588. return res.slice(0, -1);
  3589. }
  3590. /**
  3591. * Compile a template.
  3592. */
  3593. function compile$2(template, options) {
  3594. var ast = parse(template.trim(), options);
  3595. optimize(ast, options);
  3596. var code = generate(ast, options);
  3597. return {
  3598. ast: ast,
  3599. render: code.render,
  3600. staticRenderFns: code.staticRenderFns
  3601. };
  3602. }
  3603. // operators like typeof, instanceof and in are allowed
  3604. var prohibitedKeywordRE = new RegExp('\\b' + ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 'super,throw,while,yield,delete,export,import,return,switch,default,' + 'extends,finally,continue,debugger,function,arguments').split(',').join('\\b|\\b') + '\\b');
  3605. // check valid identifier for v-for
  3606. var identRE = /[A-Za-z_$][\w$]*/;
  3607. // strip strings in expressions
  3608. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  3609. // detect problematic expressions in a template
  3610. function detectErrors(ast) {
  3611. var errors = [];
  3612. if (ast) {
  3613. checkNode(ast, errors);
  3614. }
  3615. return errors;
  3616. }
  3617. function checkNode(node, errors) {
  3618. if (node.type === 1) {
  3619. for (var name in node.attrsMap) {
  3620. if (dirRE.test(name)) {
  3621. var value = node.attrsMap[name];
  3622. if (value) {
  3623. if (name === 'v-for') {
  3624. checkFor(node, 'v-for="' + value + '"', errors);
  3625. } else {
  3626. checkExpression(value, name + '="' + value + '"', errors);
  3627. }
  3628. }
  3629. }
  3630. }
  3631. if (node.children) {
  3632. for (var i = 0; i < node.children.length; i++) {
  3633. checkNode(node.children[i], errors);
  3634. }
  3635. }
  3636. } else if (node.type === 2) {
  3637. checkExpression(node.expression, node.text, errors);
  3638. }
  3639. }
  3640. function checkFor(node, text, errors) {
  3641. checkExpression(node.for || '', text, errors);
  3642. checkIdentifier(node.alias, 'v-for alias', text, errors);
  3643. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  3644. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  3645. }
  3646. function checkIdentifier(ident, type, text, errors) {
  3647. if (typeof ident === 'string' && !identRE.test(ident)) {
  3648. errors.push('- invalid ' + type + ' "' + ident + '" in expression: ' + text);
  3649. }
  3650. }
  3651. function checkExpression(exp, text, errors) {
  3652. try {
  3653. new Function('return ' + exp);
  3654. } catch (e) {
  3655. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  3656. if (keywordMatch) {
  3657. errors.push('- avoid using JavaScript keyword as property name: ' + ('"' + keywordMatch[0] + '" in expression ' + text));
  3658. } else {
  3659. errors.push('- invalid expression: ' + text);
  3660. }
  3661. }
  3662. }
  3663. function transformNode(el, options) {
  3664. var warn = options.warn || baseWarn;
  3665. var staticClass = getAndRemoveAttr(el, 'class');
  3666. if (process.env.NODE_ENV !== 'production' && staticClass) {
  3667. var expression = parseText(staticClass, options.delimiters);
  3668. if (expression) {
  3669. warn('class="' + staticClass + '": ' + 'Interpolation inside attributes has been deprecated. ' + 'Use v-bind or the colon shorthand instead.');
  3670. }
  3671. }
  3672. if (staticClass) {
  3673. el.staticClass = JSON.stringify(staticClass);
  3674. }
  3675. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  3676. if (classBinding) {
  3677. el.classBinding = classBinding;
  3678. }
  3679. }
  3680. function genData$1(el) {
  3681. var data = '';
  3682. if (el.staticClass) {
  3683. data += 'staticClass:' + el.staticClass + ',';
  3684. }
  3685. if (el.classBinding) {
  3686. data += 'class:' + el.classBinding + ',';
  3687. }
  3688. return data;
  3689. }
  3690. var klass = {
  3691. staticKeys: ['staticClass'],
  3692. transformNode: transformNode,
  3693. genData: genData$1
  3694. };
  3695. function transformNode$1(el) {
  3696. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  3697. if (styleBinding) {
  3698. el.styleBinding = styleBinding;
  3699. }
  3700. }
  3701. function genData$2(el) {
  3702. return el.styleBinding ? 'style:(' + el.styleBinding + '),' : '';
  3703. }
  3704. var style = {
  3705. transformNode: transformNode$1,
  3706. genData: genData$2
  3707. };
  3708. var modules = [klass, style];
  3709. var warn$3 = void 0;
  3710. function model(el, dir, _warn) {
  3711. warn$3 = _warn;
  3712. var value = dir.value;
  3713. var modifiers = dir.modifiers;
  3714. if (el.tag === 'select') {
  3715. return genSelect(el, value);
  3716. } else {
  3717. switch (el.attrsMap.type) {
  3718. case 'checkbox':
  3719. genCheckboxModel(el, value);
  3720. break;
  3721. case 'radio':
  3722. genRadioModel(el, value);
  3723. break;
  3724. default:
  3725. return genDefaultModel(el, value, modifiers);
  3726. }
  3727. }
  3728. }
  3729. function genCheckboxModel(el, value) {
  3730. if (process.env.NODE_ENV !== 'production' && el.attrsMap.checked != null) {
  3731. warn$3('<' + el.tag + ' v-model="' + value + '" checked>:\n' + 'inline checked attributes will be ignored when using v-model. ' + 'Declare initial values in the component\'s data option instead.');
  3732. }
  3733. var valueBinding = getBindingAttr(el, 'value');
  3734. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  3735. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  3736. addProp(el, 'checked', 'Array.isArray(' + value + ')' + ('?(' + value + ').indexOf(' + valueBinding + ')>-1') + (':(' + value + ')===(' + trueValueBinding + ')'));
  3737. addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'));
  3738. }
  3739. function genRadioModel(el, value) {
  3740. if (process.env.NODE_ENV !== 'production' && el.attrsMap.checked != null) {
  3741. warn$3('<' + el.tag + ' v-model="' + value + '" checked>:\n' + 'inline checked attributes will be ignored when using v-model. ' + 'Declare initial values in the component\'s data option instead.');
  3742. }
  3743. var valueBinding = getBindingAttr(el, 'value');
  3744. addProp(el, 'checked', '(' + value + ')===(' + valueBinding + ')');
  3745. addHandler(el, 'change', value + '=' + valueBinding);
  3746. }
  3747. function genDefaultModel(el, value, modifiers) {
  3748. if (process.env.NODE_ENV !== 'production') {
  3749. if (el.tag === 'input' && el.attrsMap.value) {
  3750. warn$3('<' + el.tag + ' v-model="' + value + '" value="' + el.attrsMap.value + '">:\n' + 'inline value attributes will be ignored when using v-model. ' + 'Declare initial values in the component\'s data option instead.');
  3751. }
  3752. if (el.tag === 'textarea' && el.children.length) {
  3753. warn$3('<textarea v-model="' + value + '">:\n' + 'inline content inside <textarea> will be ignored when using v-model. ' + 'Declare initial values in the component\'s data option instead.');
  3754. }
  3755. }
  3756. var type = el.attrsMap.type;
  3757. var _ref = modifiers || {};
  3758. var lazy = _ref.lazy;
  3759. var number = _ref.number;
  3760. var trim = _ref.trim;
  3761. var event = lazy ? 'change' : 'input';
  3762. var needCompositionGuard = !lazy && type !== 'range';
  3763. var isNative = el.tag === 'input' || el.tag === 'textarea';
  3764. var valueExpression = isNative ? '$event.target.value' + (trim ? '.trim()' : '') : '$event';
  3765. var code = number || type === 'number' ? value + '=_n(' + valueExpression + ')' : value + '=' + valueExpression;
  3766. if (isNative && needCompositionGuard) {
  3767. code = 'if($event.target.composing)return;' + code;
  3768. }
  3769. addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
  3770. addHandler(el, event, code);
  3771. if (needCompositionGuard) {
  3772. // need runtime directive code to help with composition events
  3773. return true;
  3774. }
  3775. }
  3776. function genSelect(el, value) {
  3777. if (process.env.NODE_ENV !== 'production') {
  3778. el.children.some(checkOptionWarning);
  3779. }
  3780. var code = value + '=Array.prototype.filter' + '.call($event.target.options,function(o){return o.selected})' + '.map(function(o){return "_value" in o ? o._value : o.value})' + (el.attrsMap.multiple == null ? '[0]' : '');
  3781. addHandler(el, 'change', code);
  3782. // need runtime to help with possible dynamically generated options
  3783. return true;
  3784. }
  3785. function checkOptionWarning(option) {
  3786. if (option.type === 1 && option.tag === 'option' && option.attrsMap.selected != null) {
  3787. var parentModel = option.parent && option.parent.type === 1 && option.parent.attrsMap['v-model'];
  3788. warn$3('<select v-model="' + parentModel + '">:\n' + 'inline selected attributes on <option> will be ignored when using v-model. ' + 'Declare initial values in the component\'s data option instead.');
  3789. return true;
  3790. }
  3791. }
  3792. function text(el, dir) {
  3793. if (dir.value) {
  3794. addProp(el, 'textContent', '_s(' + dir.value + ')');
  3795. }
  3796. }
  3797. function html(el, dir) {
  3798. if (dir.value) {
  3799. addProp(el, 'innerHTML', '_s(' + dir.value + ')');
  3800. }
  3801. }
  3802. var directives = {
  3803. model: model,
  3804. text: text,
  3805. html: html
  3806. };
  3807. var cache = Object.create(null);
  3808. var baseOptions = {
  3809. isIE: isIE,
  3810. expectHTML: true,
  3811. modules: modules,
  3812. staticKeys: genStaticKeys(modules),
  3813. directives: directives,
  3814. isReservedTag: isReservedTag,
  3815. isUnaryTag: isUnaryTag,
  3816. mustUseProp: mustUseProp,
  3817. getTagNamespace: getTagNamespace,
  3818. isPreTag: isPreTag
  3819. };
  3820. function compile$1(template, options) {
  3821. options = options ? extend(extend({}, baseOptions), options) : baseOptions;
  3822. return compile$2(template, options);
  3823. }
  3824. function compileToFunctions(template, options, vm) {
  3825. var _warn = options && options.warn || warn;
  3826. // detect possible CSP restriction
  3827. /* istanbul ignore if */
  3828. if (process.env.NODE_ENV !== 'production') {
  3829. try {
  3830. new Function('return 1');
  3831. } catch (e) {
  3832. if (e.toString().match(/unsafe-eval|CSP/)) {
  3833. _warn('It seems you are using the standalone build of Vue.js in an ' + 'environment with Content Security Policy that prohibits unsafe-eval. ' + 'The template compiler cannot work in this environment. Consider ' + 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + 'templates into render functions.');
  3834. }
  3835. }
  3836. }
  3837. var key = options && options.delimiters ? String(options.delimiters) + template : template;
  3838. if (cache[key]) {
  3839. return cache[key];
  3840. }
  3841. var res = {};
  3842. var compiled = compile$1(template, options);
  3843. res.render = makeFunction(compiled.render);
  3844. var l = compiled.staticRenderFns.length;
  3845. res.staticRenderFns = new Array(l);
  3846. for (var i = 0; i < l; i++) {
  3847. res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i]);
  3848. }
  3849. if (process.env.NODE_ENV !== 'production') {
  3850. if (res.render === noop || res.staticRenderFns.some(function (fn) {
  3851. return fn === noop;
  3852. })) {
  3853. _warn('failed to compile template:\n\n' + template + '\n\n' + detectErrors(compiled.ast).join('\n') + '\n\n', vm);
  3854. }
  3855. }
  3856. return cache[key] = res;
  3857. }
  3858. function makeFunction(code) {
  3859. try {
  3860. return new Function(code);
  3861. } catch (e) {
  3862. return noop;
  3863. }
  3864. }
  3865. var splitRE = /\r?\n/g;
  3866. var isSpecialTag$1 = makeMap('script,style,template', true);
  3867. /**
  3868. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  3869. */
  3870. function parseComponent(content) {
  3871. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  3872. var sfc = {
  3873. template: null,
  3874. script: null,
  3875. styles: []
  3876. };
  3877. var depth = 0;
  3878. var currentBlock = null;
  3879. function start(tag, attrs, unary, start, end) {
  3880. if (isSpecialTag$1(tag) && depth === 0) {
  3881. currentBlock = {
  3882. type: tag,
  3883. content: '',
  3884. start: end
  3885. };
  3886. checkAttrs(currentBlock, attrs);
  3887. if (tag === 'style') {
  3888. sfc.styles.push(currentBlock);
  3889. } else {
  3890. sfc[tag] = currentBlock;
  3891. }
  3892. }
  3893. if (!unary) {
  3894. depth++;
  3895. }
  3896. }
  3897. function checkAttrs(block, attrs) {
  3898. for (var i = 0; i < attrs.length; i++) {
  3899. var attr = attrs[i];
  3900. if (attr.name === 'lang') {
  3901. block.lang = attr.value;
  3902. }
  3903. if (attr.name === 'scoped') {
  3904. block.scoped = true;
  3905. }
  3906. if (attr.name === 'src') {
  3907. block.src = attr.value;
  3908. }
  3909. }
  3910. }
  3911. function end(tag, start, end) {
  3912. if (isSpecialTag$1(tag) && depth === 1 && currentBlock) {
  3913. currentBlock.end = start;
  3914. var text = deindent(content.slice(currentBlock.start, currentBlock.end));
  3915. // pad content so that linters and pre-processors can output correct
  3916. // line numbers in errors and warnings
  3917. if (currentBlock.type !== 'template' && options.pad) {
  3918. text = padContent(currentBlock) + text;
  3919. }
  3920. currentBlock.content = text;
  3921. currentBlock = null;
  3922. }
  3923. depth--;
  3924. }
  3925. function padContent(block) {
  3926. var offset = content.slice(0, block.start).split(splitRE).length;
  3927. var padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
  3928. return Array(offset).join(padChar);
  3929. }
  3930. parseHTML(content, {
  3931. start: start,
  3932. end: end
  3933. });
  3934. return sfc;
  3935. }
  3936. function compile(template, options) {
  3937. options = options || {};
  3938. var errors = [];
  3939. // allow injecting modules/directives
  3940. var modules = options.modules ? baseOptions.modules.concat(options.modules) : baseOptions.modules;
  3941. var directives = options.directives ? extend(extend({}, baseOptions.directives), options.directives) : baseOptions.directives;
  3942. var compiled = compile$1(template, {
  3943. modules: modules,
  3944. directives: directives,
  3945. warn: function warn(msg) {
  3946. errors.push(msg);
  3947. }
  3948. });
  3949. compiled.errors = errors.concat(detectErrors(compiled.ast));
  3950. return compiled;
  3951. }
  3952. exports.compile = compile;
  3953. exports.parseComponent = parseComponent;
  3954. exports.compileToFunctions = compileToFunctions;