vue.common.js 117 KB

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