vue.common.js 129 KB

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