build.js 162 KB

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