vue.common.js 137 KB

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