vue.common.js 114 KB

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