vue.common.js 118 KB

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