vue.runtime.common.js 152 KB

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