vue.common.js 113 KB

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